mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2026-04-24 13:18:17 +00:00
Thread comparisons over udiv/sdiv/ashr/lshr exact and lshr nuw/nsw whenever
possible. This goes into instcombine and instsimplify because instsimplify doesn't need to check hasOneUse since it returns (almost exclusively) constants. This fixes PR9343 #4 #5 and #8! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@127064 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -2393,6 +2393,27 @@ Instruction *InstCombiner::visitICmpInst(ICmpInst &I) {
|
||||
}
|
||||
}
|
||||
break;
|
||||
case Instruction::UDiv:
|
||||
case Instruction::LShr:
|
||||
if (I.isSigned())
|
||||
break;
|
||||
// fall-through
|
||||
case Instruction::SDiv:
|
||||
case Instruction::AShr:
|
||||
if (!BO0->isExact() && !BO1->isExact())
|
||||
break;
|
||||
return new ICmpInst(I.getPredicate(), BO0->getOperand(0),
|
||||
BO1->getOperand(0));
|
||||
case Instruction::Shl: {
|
||||
bool NUW = BO0->hasNoUnsignedWrap() && BO1->hasNoUnsignedWrap();
|
||||
bool NSW = BO0->hasNoSignedWrap() && BO1->hasNoSignedWrap();
|
||||
if (!NUW && !NSW)
|
||||
break;
|
||||
if (!NSW && I.isSigned())
|
||||
break;
|
||||
return new ICmpInst(I.getPredicate(), BO0->getOperand(0),
|
||||
BO1->getOperand(0));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user