[PATCH] Add more opportunities for constant folding in ScalarEvolution.

Nick Lewycky nlewycky at google.com
Tue Dec 2 16:57:42 PST 2014


================
Comment at: lib/Analysis/ScalarEvolution.cpp:2212
@@ +2211,3 @@
+/// any of the add or multiply expressions in this SCEV contain a constant.
+static bool containsConstantSomewhere(const SCEV* StartExpr) {
+  SmallVector<const SCEV *, 4> Ops;
----------------
"SCEV* StartExpr" should be "SCEV *StartExpr".

================
Comment at: lib/Analysis/ScalarEvolution.cpp:2221
@@ +2220,3 @@
+    if (isa<SCEVAddExpr>(*CurrentExpr) || isa<SCEVMulExpr>(*CurrentExpr)) {
+      const auto *CurrentNAry = dyn_cast<SCEVNAryExpr>(CurrentExpr);
+      for (const SCEV *Operand : CurrentNAry->operands())
----------------
This cast is guaranteed to succeed because of the if isa's above. Use cast<> instead of dyn_cast<>.

http://reviews.llvm.org/D6487






More information about the llvm-commits mailing list