diff options
author | Dan Gohman <gohman@apple.com> | 2009-06-24 14:46:22 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2009-06-24 14:46:22 +0000 |
commit | d156c0967d866e9ea9edb998fc516acf63d1a42d (patch) | |
tree | 4063a9e5a4a40386d090a0c304300a3ac4b52282 /lib/Analysis | |
parent | 4815a0efee67175bb11e09966247fc80afe4870a (diff) | |
download | external_llvm-d156c0967d866e9ea9edb998fc516acf63d1a42d.zip external_llvm-d156c0967d866e9ea9edb998fc516acf63d1a42d.tar.gz external_llvm-d156c0967d866e9ea9edb998fc516acf63d1a42d.tar.bz2 |
Simplify [su]max(MAX, n) to MAX. This comes up in loop tripcount
computations in loops with multiple exits.
Adjust the testcase for PR4436 so that the relevant portion isn't
optimized away.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74073 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis')
-rw-r--r-- | lib/Analysis/ScalarEvolution.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/Analysis/ScalarEvolution.cpp b/lib/Analysis/ScalarEvolution.cpp index 3bbeb95..6ac6efa 100644 --- a/lib/Analysis/ScalarEvolution.cpp +++ b/lib/Analysis/ScalarEvolution.cpp @@ -1690,10 +1690,14 @@ ScalarEvolution::getSMaxExpr(SmallVectorImpl<const SCEV*> &Ops) { LHSC = cast<SCEVConstant>(Ops[0]); } - // If we are left with a constant -inf, strip it off. + // If we are left with a constant minimum-int, strip it off. if (cast<SCEVConstant>(Ops[0])->getValue()->isMinValue(true)) { Ops.erase(Ops.begin()); --Idx; + } else if (cast<SCEVConstant>(Ops[0])->getValue()->isMaxValue(true)) { + // If we have an smax with a constant maximum-int, it will always be + // maximum-int. + return Ops[0]; } } @@ -1777,10 +1781,14 @@ ScalarEvolution::getUMaxExpr(SmallVectorImpl<const SCEV*> &Ops) { LHSC = cast<SCEVConstant>(Ops[0]); } - // If we are left with a constant zero, strip it off. + // If we are left with a constant minimum-int, strip it off. if (cast<SCEVConstant>(Ops[0])->getValue()->isMinValue(false)) { Ops.erase(Ops.begin()); --Idx; + } else if (cast<SCEVConstant>(Ops[0])->getValue()->isMaxValue(false)) { + // If we have an umax with a constant maximum-int, it will always be + // maximum-int. + return Ops[0]; } } |