diff options
| author | Michael Zolotukhin <mzolotukhin@apple.com> | 2014-03-12 21:31:05 +0000 |
|---|---|---|
| committer | Michael Zolotukhin <mzolotukhin@apple.com> | 2014-03-12 21:31:05 +0000 |
| commit | 66806aef1efb2425696c588298c1b52a0a4c3c14 (patch) | |
| tree | c8bf397128c56c6b5fd5e257fabb3dce6c86d852 /llvm/lib/Analysis | |
| parent | d4e56073c768489d45e7941c6a839ab5c1d5eaf8 (diff) | |
| download | bcm5719-llvm-66806aef1efb2425696c588298c1b52a0a4c3c14.tar.gz bcm5719-llvm-66806aef1efb2425696c588298c1b52a0a4c3c14.zip | |
PR17473:
Don't normalize an expression during postinc transformation unless it's
invertible.
llvm-svn: 203719
Diffstat (limited to 'llvm/lib/Analysis')
| -rw-r--r-- | llvm/lib/Analysis/IVUsers.cpp | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/llvm/lib/Analysis/IVUsers.cpp b/llvm/lib/Analysis/IVUsers.cpp index 212e98c7f8d..5317a479598 100644 --- a/llvm/lib/Analysis/IVUsers.cpp +++ b/llvm/lib/Analysis/IVUsers.cpp @@ -12,7 +12,6 @@ // //===----------------------------------------------------------------------===// - #define DEBUG_TYPE "iv-users" #include "llvm/Analysis/IVUsers.h" #include "llvm/ADT/STLExtras.h" @@ -186,15 +185,34 @@ bool IVUsers::AddUsersImpl(Instruction *I, if (AddUserToIVUsers) { // Okay, we found a user that we cannot reduce. - IVUses.push_back(new IVStrideUse(this, User, I)); - IVStrideUse &NewUse = IVUses.back(); + IVStrideUse &NewUse = AddUser(User, I); // Autodetect the post-inc loop set, populating NewUse.PostIncLoops. // The regular return value here is discarded; instead of recording // it, we just recompute it when we need it. + const SCEV *OriginalISE = ISE; ISE = TransformForPostIncUse(NormalizeAutodetect, ISE, User, I, NewUse.PostIncLoops, *SE, *DT); + + // PostIncNormalization effectively simplifies the expression under + // pre-increment assumptions. Those assumptions (no wrapping) might not + // hold for the post-inc value. Catch such cases by making sure the + // transformation is invertible. + if (OriginalISE != ISE) { + const SCEV *DenormalizedISE = + TransformForPostIncUse(Denormalize, ISE, User, I, + NewUse.PostIncLoops, *SE, *DT); + + // If we normalized the expression, but denormalization doesn't give the + // original one, discard this user. + if (OriginalISE != DenormalizedISE) { + DEBUG(dbgs() << " DISCARDING (NORMALIZATION ISN'T INVERTIBLE): " + << *ISE << '\n'); + IVUses.pop_back(); + return false; + } + } DEBUG(if (SE->getSCEV(I) != ISE) dbgs() << " NORMALIZED TO: " << *ISE << '\n'); } |

