[PATCH] D38415: [SimplifyIndVar] Replace IVUsers with loop invariant if possible

Hongbin Zheng via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Sep 30 09:17:35 PDT 2017


etherzhhb added inline comments.


================
Comment at: lib/Transforms/Utils/SimplifyIndVar.cpp:553-554
 
-  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;
+  SCEVExpander Expander(*SE, SE->getDataLayout(), "loop.invarant");
+  auto *Invariant = Expander.expandCodeFor(S, I->getType(), I);
 
----------------
Should we only expand SCEVConstant and SCEVUnknown?

If we should expand all SCEV that is Loop Invariant, should we make the SCEVExpander global, such that we have a global "InsertedExpressions" map (in the SCEVExpander) to remember the SCEV expression that we expanded?


Repository:
  rL LLVM

https://reviews.llvm.org/D38415





More information about the llvm-commits mailing list