diff options
author | Andrew Trick <atrick@apple.com> | 2012-07-13 23:33:05 +0000 |
---|---|---|
committer | Andrew Trick <atrick@apple.com> | 2012-07-13 23:33:05 +0000 |
commit | 31f61e8b221eee4f839687e9ec4df89a469a2652 (patch) | |
tree | b0f1a63e7f2550fd9639287c45e3c9f366aee795 | |
parent | 8b7036b0f4ae3f76ad24a6b9bc2d874620406306 (diff) | |
download | external_llvm-31f61e8b221eee4f839687e9ec4df89a469a2652.zip external_llvm-31f61e8b221eee4f839687e9ec4df89a469a2652.tar.gz external_llvm-31f61e8b221eee4f839687e9ec4df89a469a2652.tar.bz2 |
IVUsers should only generate SCEV's for values that are safe to speculate.
This allows SCEVExpander to run on the IV expressions.
This codifies an assumption made by LSR to complete the fix for
PR11356, but I haven't been able to generate a separate unit test for
this part. I'm adding it as an extra safety check.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@160204 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Analysis/IVUsers.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/Analysis/IVUsers.cpp b/lib/Analysis/IVUsers.cpp index b80966b..0a6682a 100644 --- a/lib/Analysis/IVUsers.cpp +++ b/lib/Analysis/IVUsers.cpp @@ -21,6 +21,7 @@ #include "llvm/Analysis/Dominators.h" #include "llvm/Analysis/LoopPass.h" #include "llvm/Analysis/ScalarEvolutionExpressions.h" +#include "llvm/Analysis/ValueTracking.h" #include "llvm/Target/TargetData.h" #include "llvm/Assembly/Writer.h" #include "llvm/ADT/STLExtras.h" @@ -120,6 +121,12 @@ bool IVUsers::AddUsersImpl(Instruction *I, if (!SE->isSCEVable(I->getType())) return false; // Void and FP expressions cannot be reduced. + // IVUsers is used by LSR which assumes that all SCEV expressions are safe to + // pass to SCEVExpander. Expressions are not safe to expand if they represent + // operations that are not safe to speculate, namely integer division. + if (!isa<PHINode>(I) && !isSafeToSpeculativelyExecute(I, TD)) + return false; + // LSR is not APInt clean, do not touch integers bigger than 64-bits. // Also avoid creating IVs of non-native types. For example, we don't want a // 64-bit IV in 32-bit code just because the loop has one 64-bit cast. |