[llvm-commits] [llvm] r73717 - /llvm/trunk/lib/Analysis/ScalarEvolution.cpp
Dan Gohman
gohman at apple.com
Thu Jun 18 13:21:22 PDT 2009
Author: djg
Date: Thu Jun 18 15:21:07 2009
New Revision: 73717
URL: http://llvm.org/viewvc/llvm-project?rev=73717&view=rev
Log:
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.
Modified:
llvm/trunk/lib/Analysis/ScalarEvolution.cpp
Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolution.cpp?rev=73717&r1=73716&r2=73717&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original)
+++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Thu Jun 18 15:21:07 2009
@@ -2580,6 +2580,24 @@
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;
}
More information about the llvm-commits
mailing list