[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 13:20:44 PDT 2017


etherzhhb added inline comments.


================
Comment at: lib/Transforms/Utils/SimplifyIndVar.cpp:557
+  if (auto *U = dyn_cast<SCEVUnknown>(S))
+    return dyn_cast<Constant>(U->getValue());
+
----------------
efriedma wrote:
> etherzhhb wrote:
> > 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
> > 
> Rather than try to check for equality, you can just check whether the SCEVUnknown is loop-invariant.
This sounds great


Repository:
  rL LLVM

https://reviews.llvm.org/D38415





More information about the llvm-commits mailing list