[llvm] [CodeGen] Improve `getLoadExtAction` and friends (PR #181104)

Nicolai Hähnle via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 10 10:52:50 PDT 2026


================
@@ -9911,10 +9906,16 @@ SDValue DAGCombiner::MatchLoadCombine(SDNode *N) {
   // Before legalize we can introduce too wide illegal loads which will be later
   // split into legal sized loads. This enables us to combine i64 load by i8
   // patterns to a couple of i32 loads on 32 bit targets.
-  if (LegalOperations &&
-      !TLI.isLoadExtLegal(NeedsZext ? ISD::ZEXTLOAD : ISD::NON_EXTLOAD, VT,
-                          MemVT))
-    return SDValue();
+  if (LegalOperations) {
+    for (auto *L : Loads) {
+      if (!TLI.isLoadLegal(VT, MemVT, L->getAlign(), L->getAddressSpace(),
+                           NeedsZext ? ISD::ZEXTLOAD : ISD::NON_EXTLOAD,
+                           false)) {
+
+        return SDValue();
+      }
+    }
+  }
----------------
nhaehnle wrote:

Is it really possible to combine loads from different address spaces? I would expect the checks that the loads are adjacent to cover that so that the address space is unique and we only need to query once.

https://github.com/llvm/llvm-project/pull/181104


More information about the llvm-commits mailing list