[PATCH] D33129: [SCEVExpander] Try harder to avoid introducing inttoptr

Keno Fischer via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat May 20 21:31:06 PDT 2017


loladiro added inline comments.


================
Comment at: lib/Analysis/ScalarEvolutionExpander.cpp:1307
   // expand to an integer type to avoid the need for additional casting.
   Type *ExpandTy = PostLoopScale ? IntTy : STy;
+  // We can't use a pointer type for the addrec if the pointer type is
----------------
sanjoy wrote:
> Did you consider just making this `Type *ExpandTy = PostLoopScale ? IntTy : Normalized->getType();`?
Yes, I think I tried that first. You do still want to make it match the type of `S` eventually at the very end.


================
Comment at: lib/Analysis/ScalarEvolutionExpander.cpp:1392
+      if (Result->getType()->isIntegerTy()) {
+        Value *Base = expandCodeFor(PostLoopOffset, ExpandTy);
+        const SCEV *const OffsetArray[1] = {SE.getUnknown(Result)};
----------------
sanjoy wrote:
> This is to prevent an `ptrtoint` on the expansion of `PostLoopOffset`, right?  If so, I think phrasing this in terms of the type of `PostLoopOffset` may be more obvious.
Well, either way. Without this, it'll try to `gep (inttoptr Result to i8*), i64 (ptrtoint PostLoopOffset)`


https://reviews.llvm.org/D33129





More information about the llvm-commits mailing list