mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-11 21:38:19 +00:00
PR9346: Prevent SimplifyDemandedBits from incorrectly introducing
INT_MIN % -1. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@127306 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -684,6 +684,10 @@ Value *InstCombiner::SimplifyDemandedUseBits(Value *V, APInt DemandedMask,
|
||||
break;
|
||||
case Instruction::SRem:
|
||||
if (ConstantInt *Rem = dyn_cast<ConstantInt>(I->getOperand(1))) {
|
||||
// X % -1 demands all the bits because we don't want to introduce
|
||||
// INT_MIN % -1 (== undef) by accident.
|
||||
if (Rem->isAllOnesValue())
|
||||
break;
|
||||
APInt RA = Rem->getValue().abs();
|
||||
if (RA.isPowerOf2()) {
|
||||
if (DemandedMask.ult(RA)) // srem won't affect demanded bits
|
||||
|
Reference in New Issue
Block a user