mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-10-19 11:02:59 +02:00
[NFC] Add option to disable IV widening if needed
IV widening is sometimes a strictly harmful transform (some examples of this are shown in tests 11, 12 in widen-loop-comp.ll). One of the reasons of this is that sometimes SCEV fails to prove some facts after part of guards has been widened. Though each single such case looks like a bug that can be addressed, it seems that disabling of IV widening may be profitable in some cases. We want to have an option to do so. By default, existing behavior is preserved and IV widening is on.
This commit is contained in:
parent
60367f78e7
commit
2cb9b29674
@ -131,6 +131,10 @@ static cl::opt<bool>
|
|||||||
LoopPredication("indvars-predicate-loops", cl::Hidden, cl::init(true),
|
LoopPredication("indvars-predicate-loops", cl::Hidden, cl::init(true),
|
||||||
cl::desc("Predicate conditions in read only loops"));
|
cl::desc("Predicate conditions in read only loops"));
|
||||||
|
|
||||||
|
static cl::opt<bool>
|
||||||
|
AllowIVWidening("indvars-widen-indvars", cl::Hidden, cl::init(true),
|
||||||
|
cl::desc("Allow widening of indvars to eliminate s/zext"));
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
struct RewritePhi;
|
struct RewritePhi;
|
||||||
@ -1392,6 +1396,10 @@ void WidenIV::pushNarrowIVUsers(Instruction *NarrowDef, Instruction *WideDef) {
|
|||||||
/// It would be simpler to delete uses as they are processed, but we must avoid
|
/// It would be simpler to delete uses as they are processed, but we must avoid
|
||||||
/// invalidating SCEV expressions.
|
/// invalidating SCEV expressions.
|
||||||
PHINode *WidenIV::createWideIV(SCEVExpander &Rewriter) {
|
PHINode *WidenIV::createWideIV(SCEVExpander &Rewriter) {
|
||||||
|
// Bail if we disallowed widening.
|
||||||
|
if(!AllowIVWidening)
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
// Is this phi an induction variable?
|
// Is this phi an induction variable?
|
||||||
const SCEVAddRecExpr *AddRec = dyn_cast<SCEVAddRecExpr>(SE->getSCEV(OrigPhi));
|
const SCEVAddRecExpr *AddRec = dyn_cast<SCEVAddRecExpr>(SE->getSCEV(OrigPhi));
|
||||||
if (!AddRec)
|
if (!AddRec)
|
||||||
|
Loading…
Reference in New Issue
Block a user