[LoopUnrolling] Handle cast instructions.
[oota-llvm.git] / lib / Transforms / Scalar / LoopUnrollPass.cpp
index d78db6c369b3520d754ebfbc2b859db806ebc3d8..ff1acc1f5795db95486813511c3fbc60b0a39932 100644 (file)
@@ -436,6 +436,21 @@ private:
 
     return true;
   }
+
+  bool visitCastInst(CastInst &I) {
+    // Propagate constants through casts.
+    Constant *COp = dyn_cast<Constant>(I.getOperand(0));
+    if (!COp)
+      COp = SimplifiedValues.lookup(I.getOperand(0));
+    if (COp)
+      if (Constant *C =
+              ConstantExpr::getCast(I.getOpcode(), COp, I.getType())) {
+        SimplifiedValues[&I] = C;
+        return true;
+      }
+
+    return Base::visitCastInst(I);
+  }
 };
 } // namespace