Reland "[SCEVExpander] Add option to preserve LCSSA directly."
This reverts the revert commit dc2867576886247cbe351e7c63618c09ab6af808.
It includes a fix for Polly, which uses SCEVExpander on IR that is not
in LCSSA form. Set PreserveLCSSA = false in that case, to ensure we do
not introduce LCSSA phis where there were none before.
GitOrigin-RevId: f75564ad4e4799465cf14b96f761e3fae13f6976
diff --git a/lib/Support/ScopHelper.cpp b/lib/Support/ScopHelper.cpp
index 78af966..bf2d82e 100644
--- a/lib/Support/ScopHelper.cpp
+++ b/lib/Support/ScopHelper.cpp
@@ -243,8 +243,8 @@
explicit ScopExpander(const Region &R, ScalarEvolution &SE,
const DataLayout &DL, const char *Name, ValueMapT *VMap,
BasicBlock *RTCBB)
- : Expander(SE, DL, Name), SE(SE), Name(Name), R(R), VMap(VMap),
- RTCBB(RTCBB) {}
+ : Expander(SE, DL, Name, /*PreserveLCSSA=*/false), SE(SE), Name(Name),
+ R(R), VMap(VMap), RTCBB(RTCBB) {}
Value *expandCodeFor(const SCEV *E, Type *Ty, Instruction *I) {
// If we generate code in the region we will immediately fall back to the