mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-16 14:31:59 +00:00
Recognize n != 0 ? n : 1 as umax(n, 1). Previously only ULT/UGT/ULE/UGE
comparisons were recognized for umax, but instcombine canonicalizes unsigned comparisons with zero to this simpler form. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73717 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
6cf69cfdee
commit
30fb512e95
@ -2580,6 +2580,24 @@ SCEVHandle ScalarEvolution::createSCEV(Value *V) {
|
||||
return getNotSCEV(getUMaxExpr(getNotSCEV(getSCEV(LHS)),
|
||||
getNotSCEV(getSCEV(RHS))));
|
||||
break;
|
||||
case ICmpInst::ICMP_NE:
|
||||
// n != 0 ? n : 1 -> umax(n, 1)
|
||||
if (LHS == U->getOperand(1) &&
|
||||
isa<ConstantInt>(U->getOperand(2)) &&
|
||||
cast<ConstantInt>(U->getOperand(2))->isOne() &&
|
||||
isa<ConstantInt>(RHS) &&
|
||||
cast<ConstantInt>(RHS)->isZero())
|
||||
return getUMaxExpr(getSCEV(LHS), getSCEV(U->getOperand(2)));
|
||||
break;
|
||||
case ICmpInst::ICMP_EQ:
|
||||
// n == 0 ? 1 : n -> umax(n, 1)
|
||||
if (LHS == U->getOperand(2) &&
|
||||
isa<ConstantInt>(U->getOperand(1)) &&
|
||||
cast<ConstantInt>(U->getOperand(1))->isOne() &&
|
||||
isa<ConstantInt>(RHS) &&
|
||||
cast<ConstantInt>(RHS)->isZero())
|
||||
return getUMaxExpr(getSCEV(LHS), getSCEV(U->getOperand(1)));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user