[PATCH] D38415: [SimplifyIndVar] Replace IVUsers with loop invariant if possible
Hongbin Zheng via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 2 14:16:02 PDT 2017
etherzhhb added inline comments.
================
Comment at: lib/Transforms/Utils/SimplifyIndVar.cpp:555
- Constant *V = C->getValue();
- // The SCEV will have a different type than the instruction if the instruction
- // has a pointer type. Skip the replacement
- // TODO: Replace ConstantInt Zero by ConstantPointerNull
- if (V->getType() != I->getType())
- return false;
+ auto *Invariant = Rewriter.expandCodeFor(S, I->getType(), I);
----------------
efriedma wrote:
> "I" is probably not the right place the put any expansion code, given it's inside the loop.
SCEVExpander figure out the correct place by itself (at least in test4 of test/Transforms/IndVarSimplify/replace-iv-with-loop-invariant.ll), otherwise we need to find the preheader (and fallback to I if there is no preheader)
================
Comment at: test/Transforms/IndVarSimplify/replace-iv-with-loop-invariant.ll:84
+; CHECK-LABEL: void @test4
+; CHECK: [[P:%[a-zA-Z$._0-9]+]] = getelementptr i32, i32* %loop.invariant
+; CHECK: phi
----------------
Here the SCEVExpander expand the expression before the loop (before the phi)
https://reviews.llvm.org/D38415
More information about the llvm-commits
mailing list