From 77aaba6aae9667e5091bf35b1cfdef995840a8c9 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Wed, 17 May 2023 18:30:40 +0200 Subject: [PATCH] [InstCombine] Compute bits of first operand for multi-use sub 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 | 1 + 1 file changed, 1 insertion(+) diff --git a/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp b/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp index 5a7ff48..ac824b2 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp @@ -1090,6 +1090,7 @@ Value *InstCombinerImpl::SimplifyMultipleUseDemandedBits( return I->getOperand(0); bool NSW = cast(I)->hasNoSignedWrap(); + computeKnownBits(I->getOperand(0), LHSKnown, Depth + 1, CxtI); Known = KnownBits::computeForAddSub(/*Add*/ false, NSW, LHSKnown, RHSKnown); break; } -- 2.7.4