[llvm] daa8e08 - [InstCombine] Fix vector icmp handling in alloc removal (#196031)

via llvm-commits llvm-commits at lists.llvm.org
Wed May 6 02:23:07 PDT 2026


Author: Nikita Popov
Date: 2026-05-06T11:23:01+02:00
New Revision: daa8e08c635d2cbb1d0c5c1108b887a6c9dd4e31

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

LOG: [InstCombine] Fix vector icmp handling in alloc removal (#196031)

A vector icmp can occur after #195486.

Added: 
    

Modified: 
    llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
    llvm/test/Transforms/InstCombine/compare-unescaped.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
index 489fe9f904a14..a09f881e06595 100644
--- a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
@@ -3977,9 +3977,8 @@ Instruction *InstCombinerImpl::visitAllocSite(Instruction &MI) {
       Instruction *I = cast<Instruction>(&*User);
 
       if (ICmpInst *C = dyn_cast<ICmpInst>(I)) {
-        replaceInstUsesWith(*C,
-                            ConstantInt::get(Type::getInt1Ty(C->getContext()),
-                                             C->isFalseWhenEqual()));
+        replaceInstUsesWith(
+            *C, ConstantInt::get(C->getType(), C->isFalseWhenEqual()));
       } else if (auto *SI = dyn_cast<StoreInst>(I)) {
         for (auto *DVR : DVRs)
           if (DVR->isAddressOfVariable())

diff  --git a/llvm/test/Transforms/InstCombine/compare-unescaped.ll b/llvm/test/Transforms/InstCombine/compare-unescaped.ll
index 31e3e4581a2ef..333358446c235 100644
--- a/llvm/test/Transforms/InstCombine/compare-unescaped.ll
+++ b/llvm/test/Transforms/InstCombine/compare-unescaped.ll
@@ -395,6 +395,15 @@ define i1 @two_nonnull_mallocs_hidden() {
   ret i1 %cmp
 }
 
+define <4 x i1> @test_vector_icmp() {
+; CHECK-LABEL: @test_vector_icmp(
+; CHECK-NEXT:    ret <4 x i1> zeroinitializer
+;
+  %ptr = call ptr @malloc(i64 16)
+  %gep = getelementptr i8, ptr %ptr, <4 x i64> <i64 4, i64 8, i64 12, i64 16>
+  %cmp = icmp eq <4 x ptr> %gep, splat (ptr null)
+  ret <4 x i1> %cmp
+}
 
 !0 = !{}
 


        


More information about the llvm-commits mailing list