summaryrefslogtreecommitdiff
path: root/lib/Transforms/Scalar/LoopIdiomRecognize.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2011-02-21 02:08:54 +0000
committerChris Lattner <sabre@nondot.org>2011-02-21 02:08:54 +0000
commit408b534e431cc317f1116cd78df96da2af7cafd9 (patch)
tree4a9dd6ae2a7b77e43a3778bb05b2b627dabec683 /lib/Transforms/Scalar/LoopIdiomRecognize.cpp
parent477a98824aaa173e8b4c327a82426de5c1197923 (diff)
downloadllvm-408b534e431cc317f1116cd78df96da2af7cafd9.tar.gz
llvm-408b534e431cc317f1116cd78df96da2af7cafd9.tar.bz2
llvm-408b534e431cc317f1116cd78df96da2af7cafd9.tar.xz
Add some (disabled code) to print out negative strides.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@126102 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Scalar/LoopIdiomRecognize.cpp')
-rw-r--r--lib/Transforms/Scalar/LoopIdiomRecognize.cpp18
1 files changed, 15 insertions, 3 deletions
diff --git a/lib/Transforms/Scalar/LoopIdiomRecognize.cpp b/lib/Transforms/Scalar/LoopIdiomRecognize.cpp
index d7fa149492..568a143742 100644
--- a/lib/Transforms/Scalar/LoopIdiomRecognize.cpp
+++ b/lib/Transforms/Scalar/LoopIdiomRecognize.cpp
@@ -31,6 +31,11 @@
// void foo(_Complex float *P)
// for (i) { __real__(*P) = 0; __imag__(*P) = 0; }
//
+// We should enhance this to handle negative strides through memory.
+// Alternatively (and perhaps better) we could rely on an earlier pass to force
+// forward iteration through memory, which is generally better for cache
+// behavior. Negative strides *do* happen for memset/memcpy loops.
+//
// This could recognize common matrix multiplies and dot product idioms and
// replace them with calls to BLAS (if linked in??).
//
@@ -272,10 +277,17 @@ bool LoopIdiomRecognize::processLoopStore(StoreInst *SI, const SCEV *BECount) {
unsigned StoreSize = (unsigned)SizeInBits >> 3;
const SCEVConstant *Stride = dyn_cast<SCEVConstant>(StoreEv->getOperand(1));
- // TODO: Could also handle negative stride here someday, that will require the
- // validity check in mayLoopAccessLocation to be updated though.
- if (Stride == 0 || StoreSize != Stride->getValue()->getValue())
+ if (Stride == 0 || StoreSize != Stride->getValue()->getValue()) {
+ // TODO: Could also handle negative stride here someday, that will require
+ // the validity check in mayLoopAccessLocation to be updated though.
+ // Enable this to print exact negative strides.
+ if (0 && StoreSize == -Stride->getValue()->getValue()) {
+ dbgs() << "NEGATIVE STRIDE: " << *SI << "\n";
+ dbgs() << "BB: " << *SI->getParent();
+ }
+
return false;
+ }
// See if we can optimize just this store in isolation.
if (processLoopStridedStore(StorePtr, StoreSize, SI->getAlignment(),