[PATCH] D14721: patch for missed constantFold optimization in InstCombine
Tejas via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 16 11:52:17 PST 2015
optimusPrime created this revision.
optimusPrime added a reviewer: llvm-commits.
optimusPrime added a subscriber: llvm-commits.
llvm::ConstantFoldCompareInstOperands misses an optimization when it tries to constantFold a compare instruction containing addrspacecast instead of combination of ptrtoint and inttoptr. Adding the patched code snippet in the code would enable the pass to handle addrspacecast and constantFold the missing cases.
Attached is the reproducer. Let me know if there are any suggestions/comments.{F1101148}
http://reviews.llvm.org/D14721
Files:
ConstantFolding.cpp
llvm/trunk/lib/Analysis/ConstantFolding.cpp
Index: llvm/trunk/lib/Analysis/ConstantFolding.cpp
===================================================================
--- llvm/trunk/lib/Analysis/ConstantFolding.cpp
+++ llvm/trunk/lib/Analysis/ConstantFolding.cpp
@@ -1137,6 +1137,12 @@
return ConstantFoldCompareInstOperands(Predicate, C, Null, DL, TLI);
}
}
+
+ if (CE0->getOpcode() == Instruction::AddrSpaceCast) {
+ Constant *C = CE0->getOperand(0);
+ Constant *Null = Constant::getNullValue(C->getType());
+ return ConstantFoldCompareInstOperands(Predicate, C, Null, TD, TLI);
+ }
}
if (ConstantExpr *CE1 = dyn_cast<ConstantExpr>(Ops1)) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D14721.40318.patch
Type: text/x-patch
Size: 677 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151116/01d7d53e/attachment.bin>
More information about the llvm-commits
mailing list