diff options
author | Nikita Popov <npopov@redhat.com> | 2024-09-25 14:21:07 +0200 |
---|---|---|
committer | Nikita Popov <npopov@redhat.com> | 2024-09-25 14:23:06 +0200 |
commit | 5ef02a3fd4758ae1b9151ac581eebd1109b4daad (patch) | |
tree | 6e621d6cf7e2329232c27e339aa4094c4f26458d | |
parent | 1e67e4bbba2a90ecaf5340acef110972413e3e5b (diff) | |
download | llvm-5ef02a3fd4758ae1b9151ac581eebd1109b4daad.zip llvm-5ef02a3fd4758ae1b9151ac581eebd1109b4daad.tar.gz llvm-5ef02a3fd4758ae1b9151ac581eebd1109b4daad.tar.bz2 |
[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 https://github.com/llvm/llvm-project/issues/109957.
-rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp b/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp index 9c4d206..c66db92 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp @@ -858,11 +858,9 @@ Value *InstCombinerImpl::SimplifyDemandedUseBits(Instruction *I, } case Instruction::SRem: { const APInt *Rem; - if (match(I->getOperand(1), m_APInt(Rem))) { - // X % -1 demands all the bits because we don't want to introduce - // INT_MIN % -1 (== undef) by accident. - if (Rem->isAllOnes()) - break; + // X % -1 demands all the bits because we don't want to introduce + // INT_MIN % -1 (== undef) by accident. + if (match(I->getOperand(1), m_APInt(Rem)) && !Rem->isAllOnes()) { APInt RA = Rem->abs(); if (RA.isPowerOf2()) { if (DemandedMask.ult(RA)) // srem won't affect demanded bits |