Have SCEV turn sext(x) into zext(x) when x is s>= 0. This applies many times in
authorNick Lewycky <nicholas@mxc.ca>
Sat, 22 Jan 2011 22:06:21 +0000 (22:06 +0000)
committerNick Lewycky <nicholas@mxc.ca>
Sat, 22 Jan 2011 22:06:21 +0000 (22:06 +0000)
"make check" alone.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124046 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/ScalarEvolution.cpp

index 424f74427be48949250f36ad6711b0e7f5d9d4c2..63602ffaa78dff2bd493a64d9e3040fa24b5af31 100644 (file)
@@ -1035,6 +1035,10 @@ const SCEV *ScalarEvolution::getSignExtendExpr(const SCEV *Op,
   void *IP = 0;
   if (const SCEV *S = UniqueSCEVs.FindNodeOrInsertPos(ID, IP)) return S;
 
+  // If the input value is provably positive, build a zext instead.
+  if (isKnownNonNegative(Op))
+    return getZeroExtendExpr(Op, Ty);
+
   // If the input value is a chrec scev, and we can prove that the value
   // did not overflow the old, smaller, value, we can sign extend all of the
   // operands (often constants).  This allows analysis of something like