Not all constants are legal immediates in load/store instructions.
authorChris Lattner <sabre@nondot.org>
Mon, 8 Aug 2005 06:25:50 +0000 (06:25 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 8 Aug 2005 06:25:50 +0000 (06:25 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22704 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/LoopStrengthReduce.cpp

index f11976fe879ead281d2b535640222c7a188bbb71..e7e9886e314fe329cdf1cac0e01322b8a93b1a84 100644 (file)
@@ -435,7 +435,13 @@ void BasedUser::RewriteInstructionToUseNewBase(Value *NewBase,
 static bool isTargetConstant(const SCEVHandle &V) {
 
   // FIXME: Look at the target to decide if &GV is a legal constant immediate.
-  if (isa<SCEVConstant>(V)) return true;
+  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;
+    return false;
+  }
 
   return false;     // ENABLE this for x86