[llvm] fb4a8f6 - [LLVM][InstCombine] foldICmpEquality: Compare APInt values rather than addresses. (#151726)

via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 4 05:54:48 PDT 2025


Author: Paul Walker
Date: 2025-08-04T13:54:44+01:00
New Revision: fb4a8f67b9f4b898b95dda7ba184f3f256876031

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

LOG: [LLVM][InstCombine] foldICmpEquality: Compare APInt values rather than addresses. (#151726)

Added: 
    

Modified: 
    llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
    llvm/test/Transforms/InstCombine/compare-signs.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
index d4f83ece98907..cf94d28100488 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
@@ -6090,7 +6090,7 @@ Instruction *InstCombinerImpl::foldICmpEquality(ICmpInst &I) {
        match(Op1, m_OneUse(m_LShr(m_Value(B), m_APIntAllowPoison(AP2))))) ||
       (match(Op0, m_OneUse(m_AShr(m_Value(A), m_APIntAllowPoison(AP1)))) &&
        match(Op1, m_OneUse(m_AShr(m_Value(B), m_APIntAllowPoison(AP2)))))) {
-    if (AP1 != AP2)
+    if (*AP1 != *AP2)
       return nullptr;
     unsigned TypeBits = AP1->getBitWidth();
     unsigned ShAmt = AP1->getLimitedValue(TypeBits);

diff  --git a/llvm/test/Transforms/InstCombine/compare-signs.ll b/llvm/test/Transforms/InstCombine/compare-signs.ll
index 59ec9adb30b9e..bed0f6966dd89 100644
--- a/llvm/test/Transforms/InstCombine/compare-signs.ll
+++ b/llvm/test/Transforms/InstCombine/compare-signs.ll
@@ -1,5 +1,6 @@
 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
 ; RUN: opt -passes=instcombine -S < %s | FileCheck %s
+; RUN: opt -passes=instcombine -use-constant-int-for-fixed-length-splat -S < %s | FileCheck %s
 
 ; PR5438
 


        


More information about the llvm-commits mailing list