[PATCH] D32954: [InstSimplify] restrict icmp fold with 2 sdiv exact operands (PR32949)
Sanjay Patel via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon May 15 12:30:20 PDT 2017
This revision was automatically updated to reflect the committed changes.
Closed by commit rL303104: [InstSimplify] restrict icmp fold with 2 sdiv exact operands (PR32949) (authored by spatel).
Changed prior to commit:
https://reviews.llvm.org/D32954?vs=98106&id=99043#toc
Repository:
rL LLVM
https://reviews.llvm.org/D32954
Files:
llvm/trunk/lib/Analysis/InstructionSimplify.cpp
llvm/trunk/test/Transforms/InstSimplify/compare.ll
Index: llvm/trunk/test/Transforms/InstSimplify/compare.ll
===================================================================
--- llvm/trunk/test/Transforms/InstSimplify/compare.ll
+++ llvm/trunk/test/Transforms/InstSimplify/compare.ll
@@ -598,11 +598,14 @@
ret i1 %C
}
-; FIXME: But not other preds: PR32949 - https://bugs.llvm.org/show_bug.cgi?id=32949
+; But not other preds: PR32949 - https://bugs.llvm.org/show_bug.cgi?id=32949
define i1 @sdiv_exact_not_equality(i32 %Z) {
; CHECK-LABEL: @sdiv_exact_not_equality(
-; CHECK-NEXT: ret i1 true
+; CHECK-NEXT: [[A:%.*]] = sdiv exact i32 10, %Z
+; CHECK-NEXT: [[B:%.*]] = sdiv exact i32 20, %Z
+; CHECK-NEXT: [[C:%.*]] = icmp ult i32 [[A]], [[B]]
+; CHECK-NEXT: ret i1 [[C]]
;
%A = sdiv exact i32 10, %Z
%B = sdiv exact i32 20, %Z
Index: llvm/trunk/lib/Analysis/InstructionSimplify.cpp
===================================================================
--- llvm/trunk/lib/Analysis/InstructionSimplify.cpp
+++ llvm/trunk/lib/Analysis/InstructionSimplify.cpp
@@ -2827,10 +2827,19 @@
break;
case Instruction::UDiv:
case Instruction::LShr:
- if (ICmpInst::isSigned(Pred))
+ if (ICmpInst::isSigned(Pred) || !LBO->isExact() || !RBO->isExact())
break;
- LLVM_FALLTHROUGH;
+ if (Value *V = SimplifyICmpInst(Pred, LBO->getOperand(0),
+ RBO->getOperand(0), Q, MaxRecurse - 1))
+ return V;
+ break;
case Instruction::SDiv:
+ if (!ICmpInst::isEquality(Pred) || !LBO->isExact() || !RBO->isExact())
+ break;
+ if (Value *V = SimplifyICmpInst(Pred, LBO->getOperand(0),
+ RBO->getOperand(0), Q, MaxRecurse - 1))
+ return V;
+ break;
case Instruction::AShr:
if (!LBO->isExact() || !RBO->isExact())
break;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D32954.99043.patch
Type: text/x-patch
Size: 1860 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170515/3844e73c/attachment.bin>
More information about the llvm-commits
mailing list