[llvm] ffc32ca - [InstCombine] Don't change the type of elementwise atomic loads (#213414)

via llvm-commits llvm-commits at lists.llvm.org
Sun Aug 2 01:54:25 PDT 2026


Author: Harrison Hao
Date: 2026-08-02T16:54:20+08:00
New Revision: ffc32ca95939e131c87072fdbfb36e08e0a495cc

URL: https://github.com/llvm/llvm-project/commit/ffc32ca95939e131c87072fdbfb36e08e0a495cc
DIFF: https://github.com/llvm/llvm-project/commit/ffc32ca95939e131c87072fdbfb36e08e0a495cc.diff

LOG: [InstCombine] Don't change the type of elementwise atomic loads (#213414)

Skip load type canonicalization for elementwise atomic loads, which
would
otherwise drop the vector type and produce an invalid scalar elementwise
load.

Reference: https://github.com/llvm/llvm-project/pull/204556

Added: 
    

Modified: 
    llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
    llvm/test/Transforms/InstCombine/atomic.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp b/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
index 99ed22c97c3a8..fe6c3d6c893ac 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
@@ -684,6 +684,9 @@ static Instruction *combineLoadToOperationType(InstCombinerImpl &IC,
   if (!Load.isUnordered())
     return nullptr;
 
+  if (Load.isElementwise())
+    return nullptr;
+
   if (Load.use_empty())
     return nullptr;
 

diff  --git a/llvm/test/Transforms/InstCombine/atomic.ll b/llvm/test/Transforms/InstCombine/atomic.ll
index 75ee53982dfe1..02f7929951035 100644
--- a/llvm/test/Transforms/InstCombine/atomic.ll
+++ b/llvm/test/Transforms/InstCombine/atomic.ll
@@ -452,4 +452,15 @@ define void @volatile_load_from_constant_global() {
   ret void
 }
 
+define i64 @load_elementwise_bitcast(ptr %p) {
+; CHECK-LABEL: @load_elementwise_bitcast(
+; CHECK-NEXT:    [[V:%.*]] = load atomic elementwise <2 x i32>, ptr [[P:%.*]] unordered, align 8
+; CHECK-NEXT:    [[R:%.*]] = bitcast <2 x i32> [[V]] to i64
+; CHECK-NEXT:    ret i64 [[R]]
+;
+  %v = load atomic elementwise <2 x i32>, ptr %p unordered, align 8
+  %r = bitcast <2 x i32> %v to i64
+  ret i64 %r
+}
+
 attributes #0 = { null_pointer_is_valid }


        


More information about the llvm-commits mailing list