[PATCH] Handle cast instructions in complete loop unroll heuristic.
Michael Zolotukhin
mzolotukhin at apple.com
Fri Jun 5 21:09:46 PDT 2015
- Fallback to Base visitor if failed to constant fold (and only then call simplifyInstWithSCEV).
- Add TODO to visitCast.
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
@@ -440,6 +440,23 @@
return true;
}
+ bool visitCastInst(CastInst &I) {
+ // Propagate constants through ptrtoint.
+ Constant *COp = dyn_cast<Constant>(I.getOperand(0));
+ if (!COp)
+ COp = SimplifiedValues.lookup(I.getOperand(0));
+ // TODO: If we do ptrtoint of an expression, which is present in
+ // SimplifiedOffsets, we can propagate this information.
+ if (COp)
+ if (Constant *C =
+ ConstantExpr::getCast(I.getOpcode(), COp, I.getType())) {
+ SimplifiedValues[&I] = C;
+ return true;
+ }
+
+ return Base::visitCastInst(I);
+ }
+
bool visitCmpInst(CmpInst &I) {
Value *LHS = I.getOperand(0), *RHS = I.getOperand(1);
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D10207.27261.patch
Type: text/x-patch
Size: 914 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150606/5718b1b6/attachment.bin>
More information about the llvm-commits
mailing list