[llvm] [Reassociate] Use disjoint flag to convert Or to Add. (PR #72772)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 20 05:51:21 PST 2023


================
@@ -2252,9 +2252,10 @@ void ReassociatePass::OptimizeInst(Instruction *I) {
   // with no common bits set, convert it to X+Y.
   if (I->getOpcode() == Instruction::Or &&
       shouldConvertOrWithNoCommonBitsToAdd(I) && !isLoadCombineCandidate(I) &&
-      haveNoCommonBitsSet(I->getOperand(0), I->getOperand(1),
-                          SimplifyQuery(I->getModule()->getDataLayout(),
-                                        /*DT=*/nullptr, /*AC=*/nullptr, I))) {
+      (I->isDisjoint() ||
+       haveNoCommonBitsSet(I->getOperand(0), I->getOperand(1),
+                           SimplifyQuery(I->getModule()->getDataLayout(),
+                                         /*DT=*/nullptr, /*AC=*/nullptr, I)))) {
----------------
nikic wrote:

I think we should instead infer `disjoint` in InstCombine and then replace all existing `haveNoCommonBitsSet()` checks with only a `isDisjoint()` check, not both.

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


More information about the llvm-commits mailing list