[InstCombine] Compute bits of first operand for multi-use sub
authorNikita Popov <npopov@redhat.com>
Wed, 17 May 2023 16:30:40 +0000 (18:30 +0200)
committerNikita Popov <npopov@redhat.com>
Wed, 17 May 2023 16:34:17 +0000 (18:34 +0200)
Otherwise the result will always be unknown anyway. This fixes one
of the last inconsistencies in results between computeKnownBits()
and SimplifyDemandedBits().

llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp

index 5a7ff48..ac824b2 100644 (file)
@@ -1090,6 +1090,7 @@ Value *InstCombinerImpl::SimplifyMultipleUseDemandedBits(
       return I->getOperand(0);
 
     bool NSW = cast<OverflowingBinaryOperator>(I)->hasNoSignedWrap();
+    computeKnownBits(I->getOperand(0), LHSKnown, Depth + 1, CxtI);
     Known = KnownBits::computeForAddSub(/*Add*/ false, NSW, LHSKnown, RHSKnown);
     break;
   }