summaryrefslogtreecommitdiff
path: root/lib/Transforms/Scalar/LoopStrengthReduce.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2007-04-02 06:34:44 +0000
committerChris Lattner <sabre@nondot.org>2007-04-02 06:34:44 +0000
commit1ebd89eb6b4f5df8d8171ee654a73ecdf3f66580 (patch)
tree62a7a54bbb59c53accbb1cc33e275cd244c64634 /lib/Transforms/Scalar/LoopStrengthReduce.cpp
parent44ad85e0e89d56ca19c131aec6f840c4fc332163 (diff)
downloadllvm-1ebd89eb6b4f5df8d8171ee654a73ecdf3f66580.tar.gz
llvm-1ebd89eb6b4f5df8d8171ee654a73ecdf3f66580.tar.bz2
llvm-1ebd89eb6b4f5df8d8171ee654a73ecdf3f66580.tar.xz
Pass the type of the store access, not the type of the store, into the
target hook. This allows us to codegen a loop as: LBB1_1: @cond_next mov r2, #0 str r2, [r0, +r3, lsl #2] add r3, r3, #1 cmn r3, #1 bne LBB1_1 @cond_next instead of: LBB1_1: @cond_next mov r2, #0 str r2, [r0], #+4 add r3, r3, #1 cmn r3, #1 bne LBB1_1 @cond_next This looks the same, but has one fewer induction variable (and therefore, one fewer register) live in the loop. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35592 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Scalar/LoopStrengthReduce.cpp')
-rw-r--r--lib/Transforms/Scalar/LoopStrengthReduce.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/Transforms/Scalar/LoopStrengthReduce.cpp b/lib/Transforms/Scalar/LoopStrengthReduce.cpp
index 9cb8d484de..744e0548ba 100644
--- a/lib/Transforms/Scalar/LoopStrengthReduce.cpp
+++ b/lib/Transforms/Scalar/LoopStrengthReduce.cpp
@@ -899,8 +899,15 @@ bool LoopStrengthReduce::ValidStride(int64_t Scale,
Imm = SC->getValue()->getSExtValue();
else
Imm = 0;
- if (!TLI->isLegalAddressScaleAndImm(Scale, Imm,
- UsersToProcess[i].Inst->getType()))
+
+ // If this is a load or other access, pass the type of the access in.
+ const Type *AccessTy = Type::VoidTy;
+ if (StoreInst *SI = dyn_cast<StoreInst>(UsersToProcess[i].Inst))
+ AccessTy = SI->getOperand(0)->getType();
+ else if (LoadInst *LI = dyn_cast<LoadInst>(UsersToProcess[i].Inst))
+ AccessTy = LI->getType();
+
+ if (!TLI->isLegalAddressScaleAndImm(Scale, Imm, AccessTy))
return false;
}
return true;