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

Sanjoy Das via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 16 13:33:44 PDT 2017


sanjoy added inline comments.


================
Comment at: lib/Analysis/ScalarEvolutionExpander.cpp:494
+    Value *Idx = nullptr;
+    if (AddExpr->getType()->isPointerTy() && V->getType()->isIntegerTy()) {
+      // The AddExpr is of pointer type, while V is of integer type, so
----------------
Just to be clear, this is intentionally kicking in for all pointers?  If so, a test case showing that will be great.


================
Comment at: lib/Analysis/ScalarEvolutionExpander.cpp:498
+      Idx = InsertNoopCastOfTo(V, Ty);
+      auto BasePtrTy = cast<PointerType>(AddExpr->getType());
+      V = expandCodeFor(AddExpr,
----------------
`auto *`.


================
Comment at: lib/Analysis/ScalarEvolutionExpander.cpp:1322
   Type *ExpandTy = PostLoopScale ? IntTy : STy;
+  // We can't use a pointer type for the addrec is the pointer type is
+  // non-integral.
----------------
s/is the/if the/


================
Comment at: lib/Analysis/ScalarEvolutionExpander.cpp:1396
     assert(S->isAffine() && "Can't linearly scale non-affine recurrences.");
     Result = InsertNoopCastOfTo(Result, IntTy);
     Result = Builder.CreateMul(Result,
----------------
This is annoying, but won't a non-null `PostLoopScale` with an ni pointer type fail here?



https://reviews.llvm.org/D33129





More information about the llvm-commits mailing list