The motivation is that 'createInvariantCond' unconditionally builds icmp in the loop block,
while it could always do it in preheader.
Check that icmp's inputs are loop invariants and build it in preheader.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
llvm/lib/Transforms/Scalar/IndVarSimplify.cpp | ||
---|---|---|
1362–1364 | Shouldn't the Rewriter expand in the preheader as well? Can LHSV/RHSV ever *not* be loop invariant in this function? |
llvm/lib/Transforms/Scalar/IndVarSimplify.cpp | ||
---|---|---|
1371 | I guess you can assert these facts. LIP is supposed to produce loop-invariant SCEVs and expander, I guess, should always be able to expand it in preheader. Isn't it so? |
llvm/lib/Transforms/Scalar/IndVarSimplify.cpp | ||
---|---|---|
1362–1364 | They should always be invariant. I also think that expander's insertion point can be in preheader. |
llvm/lib/Transforms/Scalar/IndVarSimplify.cpp | ||
---|---|---|
1362–1364 | I still think that we should be adjusting this insertion point as well... |
llvm/lib/Transforms/Scalar/IndVarSimplify.cpp | ||
---|---|---|
1362–1364 | Got it, thanks! |
Shouldn't the Rewriter expand in the preheader as well? Can LHSV/RHSV ever *not* be loop invariant in this function?