[PATCH] D38415: [SimplifyIndVar] Correctly extract constant LLVM value from SCEV during constant folding

Hongbin Zheng via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 29 12:40:52 PDT 2017


etherzhhb added inline comments.


================
Comment at: lib/Transforms/Utils/SimplifyIndVar.cpp:551
+      V = ConstantPointerNull::get(PT);
+    }
+
----------------
efriedma wrote:
> Could you use SCEVExpander rather than writing out the cast logic here?  I'm not sure this covers all the relevant cases.
Ok, will do


================
Comment at: lib/Transforms/Utils/SimplifyIndVar.cpp:557
+  if (auto *U = dyn_cast<SCEVUnknown>(S))
+    return dyn_cast<Constant>(U->getValue());
+
----------------
efriedma wrote:
> Does it actually matter whether the value here is a Constant?
You means we gain something if we can "simplify" the IV user from a SCEVAddRec to a SCEVUnknown?*

SE->getSCEV(I); may directly return an SCEUnknown, so we need to compare the new LLVM Value and the original one.
We are not going to do the replace if they are the same



Repository:
  rL LLVM

https://reviews.llvm.org/D38415





More information about the llvm-commits mailing list