diff --git a/lib/Transforms/Scalar/LoopStrengthReduce.cpp b/lib/Transforms/Scalar/LoopStrengthReduce.cpp index f11976fe879..e7e9886e314 100644 --- a/lib/Transforms/Scalar/LoopStrengthReduce.cpp +++ b/lib/Transforms/Scalar/LoopStrengthReduce.cpp @@ -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(V)) return true; + if (SCEVConstant *SC = dyn_cast(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