Skip to content

Commit 5ef02a3

Browse files
committed
[InstCombine] Fall through to computeKnownBits() for sdiv by -1
When dividing by -1 we were breaking out of the code entirely, while we should fall through to computeKnownBits(). This fixes an instcombine-verify-known-bits discrepancy. Fixes #109957.
1 parent 1e67e4b commit 5ef02a3

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -858,11 +858,9 @@ Value *InstCombinerImpl::SimplifyDemandedUseBits(Instruction *I,
858858
}
859859
case Instruction::SRem: {
860860
const APInt *Rem;
861-
if (match(I->getOperand(1), m_APInt(Rem))) {
862-
// X % -1 demands all the bits because we don't want to introduce
863-
// INT_MIN % -1 (== undef) by accident.
864-
if (Rem->isAllOnes())
865-
break;
861+
// X % -1 demands all the bits because we don't want to introduce
862+
// INT_MIN % -1 (== undef) by accident.
863+
if (match(I->getOperand(1), m_APInt(Rem)) && !Rem->isAllOnes()) {
866864
APInt RA = Rem->abs();
867865
if (RA.isPowerOf2()) {
868866
if (DemandedMask.ult(RA)) // srem won't affect demanded bits

0 commit comments

Comments
 (0)