From c557d3109a942bc4fb93b690ceb70de8a3d53d30 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Wed, 17 May 2023 15:54:11 +0200 Subject: [PATCH] [InstCombine] Use computeKnownBits() for srem SimplifyDemandedBits() For the case of a non-constant operand, fall back to computeKnownBits() rather than trying to reimplement logic. Found while testing a consistency assertion for both functions. --- llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp b/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp index 231739d..c9c7f4a 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp @@ -852,14 +852,7 @@ Value *InstCombinerImpl::SimplifyDemandedUseBits(Value *V, APInt DemandedMask, } } - // The sign bit is the LHS's sign bit, except when the result of the - // remainder is zero. - if (DemandedMask.isSignBitSet()) { - computeKnownBits(I->getOperand(0), LHSKnown, Depth + 1, CxtI); - // If it's known zero, our sign bit is also zero. - if (LHSKnown.isNonNegative()) - Known.makeNonNegative(); - } + computeKnownBits(I, Known, Depth, CxtI); break; } case Instruction::URem: { -- 2.7.4