[PATCH] Handle cast instructions in complete loop unroll heuristic.

Michael Zolotukhin mzolotukhin at apple.com
Tue Jun 2 18:26:42 PDT 2015


Hi chandlerc,

Cast instructions are important to handle since induction variables are often extended to 64-bits.
This patch is intended to be applied after D10205 (though it could be applied independently with minor changes).

http://reviews.llvm.org/D10207

Files:
  lib/Transforms/Scalar/LoopUnrollPass.cpp

Index: lib/Transforms/Scalar/LoopUnrollPass.cpp
===================================================================
--- lib/Transforms/Scalar/LoopUnrollPass.cpp
+++ lib/Transforms/Scalar/LoopUnrollPass.cpp
@@ -419,6 +419,23 @@
     return true;
   }
 
+  bool visitCastInst(CastInst &I) {
+    if (SCEVSimplify(&I))
+      return true;
+    // Propagate constants through ptrtoint.
+    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 false;
+  }
+
   bool visitCmpInst(CmpInst &I) {
     if (SCEVSimplify(&I))
       return true;

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D10207.27022.patch
Type: text/x-patch
Size: 798 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150603/baf2f9ed/attachment.bin>


More information about the llvm-commits mailing list