summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Scalar
diff options
context:
space:
mode:
authorAndrew Trick <atrick@apple.com>2011-07-21 01:05:01 +0000
committerAndrew Trick <atrick@apple.com>2011-07-21 01:05:01 +0000
commit858e9f083d03052fdec5d8c22b3ac61ab5624163 (patch)
tree3de58430ab9799673325902eaa81fea5ede7b4cc /llvm/lib/Transforms/Scalar
parent4ace035c552c2f272fda3f2a3ceb4738b4d3ecef (diff)
downloadbcm5719-llvm-858e9f083d03052fdec5d8c22b3ac61ab5624163.tar.gz
bcm5719-llvm-858e9f083d03052fdec5d8c22b3ac61ab5624163.zip
LSR must sometimes sign-extend before generating double constants.
rdar://9786536 llvm-svn: 135650
Diffstat (limited to 'llvm/lib/Transforms/Scalar')
-rw-r--r--llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp b/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
index 4598df0c428..92864817aee 100644
--- a/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
@@ -1427,6 +1427,7 @@ void LSRInstance::OptimizeShadowIV() {
++UI;
Instruction *ShadowUse = CandidateUI->getUser();
Type *DestTy = NULL;
+ bool IsSigned = false;
/* If shadow use is a int->float cast then insert a second IV
to eliminate this cast.
@@ -1440,10 +1441,14 @@ void LSRInstance::OptimizeShadowIV() {
for (unsigned i = 0; i < n; ++i, ++d)
foo(d);
*/
- if (UIToFPInst *UCast = dyn_cast<UIToFPInst>(CandidateUI->getUser()))
+ if (UIToFPInst *UCast = dyn_cast<UIToFPInst>(CandidateUI->getUser())) {
+ IsSigned = false;
DestTy = UCast->getDestTy();
- else if (SIToFPInst *SCast = dyn_cast<SIToFPInst>(CandidateUI->getUser()))
+ }
+ else if (SIToFPInst *SCast = dyn_cast<SIToFPInst>(CandidateUI->getUser())) {
+ IsSigned = true;
DestTy = SCast->getDestTy();
+ }
if (!DestTy) continue;
if (TLI) {
@@ -1474,7 +1479,9 @@ void LSRInstance::OptimizeShadowIV() {
ConstantInt *Init = dyn_cast<ConstantInt>(PH->getIncomingValue(Entry));
if (!Init) continue;
- Constant *NewInit = ConstantFP::get(DestTy, Init->getZExtValue());
+ Constant *NewInit = ConstantFP::get(DestTy, IsSigned ?
+ Init->getSExtValue() :
+ Init->getZExtValue());
BinaryOperator *Incr =
dyn_cast<BinaryOperator>(PH->getIncomingValue(Latch));
OpenPOWER on IntegriCloud