summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2005-08-03 23:44:42 +0000
committerChris Lattner <sabre@nondot.org>2005-08-03 23:44:42 +0000
commitfc62470466ac9928e222786352afc1266aff6fc0 (patch)
tree2e7d513ab9d17b8b83f7a7f41205058e11fefd85 /llvm/lib/Transforms
parentbb78c97e24ddbefc8069abec3ac762c62eb9159e (diff)
downloadbcm5719-llvm-fc62470466ac9928e222786352afc1266aff6fc0.tar.gz
bcm5719-llvm-fc62470466ac9928e222786352afc1266aff6fc0.zip
Teach loop-reduce to see into nested loops, to pull out immediate values
pushed down by SCEV. In a nested loop case, this allows us to emit this: lis r3, ha16(L_A$non_lazy_ptr) lwz r3, lo16(L_A$non_lazy_ptr)(r3) add r2, r2, r3 li r3, 1 .LBB_foo_2: ; no_exit.1 lfd f0, 8(r2) ;; Uses offset of 8 instead of 0 stfd f0, 0(r2) addi r4, r3, 1 addi r2, r2, 8 cmpwi cr0, r3, 100 or r3, r4, r4 bne .LBB_foo_2 ; no_exit.1 instead of this: lis r3, ha16(L_A$non_lazy_ptr) lwz r3, lo16(L_A$non_lazy_ptr)(r3) add r2, r2, r3 addi r3, r3, 8 li r4, 1 .LBB_foo_2: ; no_exit.1 lfd f0, 0(r3) stfd f0, 0(r2) addi r5, r4, 1 addi r2, r2, 8 addi r3, r3, 8 cmpwi cr0, r4, 100 or r4, r5, r5 bne .LBB_foo_2 ; no_exit.1 llvm-svn: 22639
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp b/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
index ddce7511042..9a9b0c2aeca 100644
--- a/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
@@ -483,8 +483,7 @@ static SCEVHandle GetImmediateValues(SCEVHandle Val, bool isAddress) {
if (isTargetConstant(Val))
return Val;
- SCEVAddExpr *SAE = dyn_cast<SCEVAddExpr>(Val);
- if (SAE) {
+ if (SCEVAddExpr *SAE = dyn_cast<SCEVAddExpr>(Val)) {
unsigned i = 0;
for (; i != SAE->getNumOperands(); ++i)
if (isTargetConstant(SAE->getOperand(i))) {
@@ -497,6 +496,9 @@ static SCEVHandle GetImmediateValues(SCEVHandle Val, bool isAddress) {
ImmVal = SCEVAddExpr::get(ImmVal, SAE->getOperand(i));
return ImmVal;
}
+ } else if (SCEVAddRecExpr *SARE = dyn_cast<SCEVAddRecExpr>(Val)) {
+ // Try to pull immediates out of the start value of nested addrec's.
+ return GetImmediateValues(SARE->getStart(), isAddress);
}
return SCEVUnknown::getIntegerSCEV(0, Val->getType());
OpenPOWER on IntegriCloud