getRawValue zero extens for unsigned values, use getsextvalue so that we
authorChris Lattner <sabre@nondot.org>
Mon, 5 Dec 2005 18:23:57 +0000 (18:23 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 5 Dec 2005 18:23:57 +0000 (18:23 +0000)
know that small negative values fit into the immediate field of addressing
modes.

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

lib/Transforms/Scalar/LoopStrengthReduce.cpp

index 4f18637c9f634dac71877dd9c34c4dca44d3fe54..f170592ece3d3e8f212b599c3459767b143d6381 100644 (file)
@@ -560,9 +560,9 @@ static bool isTargetConstant(const SCEVHandle &V) {
   // FIXME: Look at the target to decide if &GV is a legal constant immediate.
   if (SCEVConstant *SC = dyn_cast<SCEVConstant>(V)) {
     // PPC allows a sign-extended 16-bit immediate field.
   // FIXME: Look at the target to decide if &GV is a legal constant immediate.
   if (SCEVConstant *SC = dyn_cast<SCEVConstant>(V)) {
     // PPC allows a sign-extended 16-bit immediate field.
-    if ((int64_t)SC->getValue()->getRawValue() > -(1 << 16) &&
-        (int64_t)SC->getValue()->getRawValue() < (1 << 16)-1)
-      return true;
+    int64_t V = SC->getValue()->getSExtValue();
+    if (V > -(1 << 16) && V < (1 << 16)-1)
+        return true;
     return false;
   }
 
     return false;
   }