[llvm] 3e7ca05 - [InstCombine] Use disjoint flag instead of calling haveNoCommonBitsSet. (#74222)

via llvm-commits llvm-commits at lists.llvm.org
Sun Dec 3 12:34:54 PST 2023


Author: Craig Topper
Date: 2023-12-03T12:34:49-08:00
New Revision: 3e7ca05e93e3c6251edef928a08ce613b5c7aebb

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

LOG: [InstCombine] Use disjoint flag instead of calling haveNoCommonBitsSet. (#74222)

Added: 
    

Modified: 
    llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
    llvm/test/Transforms/InstCombine/or.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp b/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
index 7379bdf93169e..481fcdf181946 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
@@ -3395,7 +3395,7 @@ Instruction *InstCombinerImpl::visitOr(BinaryOperator &I) {
   // or (mul X, Y), X --> add (mul X, Y), X --> mul X, (Y + 1)
   if (match(&I,
             m_c_Or(m_OneUse(m_Mul(m_Value(X), m_Value(Y))), m_Deferred(X))) &&
-      haveNoCommonBitsSet(Op0, Op1, DL)) {
+      cast<PossiblyDisjointInst>(I).isDisjoint()) {
     Value *IncrementY = Builder.CreateAdd(Y, ConstantInt::get(Ty, 1));
     return BinaryOperator::CreateMul(X, IncrementY);
   }

diff  --git a/llvm/test/Transforms/InstCombine/or.ll b/llvm/test/Transforms/InstCombine/or.ll
index 8bf8c6fcd928b..fd415682b67f3 100644
--- a/llvm/test/Transforms/InstCombine/or.ll
+++ b/llvm/test/Transforms/InstCombine/or.ll
@@ -1511,6 +1511,27 @@ define <2 x i12> @mul_no_common_bits_commute(<2 x i12> %p) {
   ret <2 x i12> %r
 }
 
+define i32 @mul_no_common_bits_disjoint(i32 %x, i32 %y) {
+; CHECK-LABEL: @mul_no_common_bits_disjoint(
+; CHECK-NEXT:    [[TMP1:%.*]] = add i32 [[Y:%.*]], 1
+; CHECK-NEXT:    [[R:%.*]] = mul i32 [[TMP1]], [[X:%.*]]
+; CHECK-NEXT:    ret i32 [[R]]
+;
+  %m = mul i32 %x, %y
+  %r = or disjoint i32 %m, %x
+  ret i32 %r
+}
+
+define i32 @mul_no_common_bits_const_op_disjoint(i32 %x, i32 %y) {
+; CHECK-LABEL: @mul_no_common_bits_const_op_disjoint(
+; CHECK-NEXT:    [[R:%.*]] = mul i32 [[X:%.*]], 25
+; CHECK-NEXT:    ret i32 [[R]]
+;
+  %m = mul i32 %x, 24
+  %r = or disjoint i32 %m, %x
+  ret i32 %r
+}
+
 ; negative test - extra use requires extra instructions
 
 define i32 @mul_no_common_bits_uses(i32 %p1, i32 %p2) {


        


More information about the llvm-commits mailing list