From a23b141cd2120232ef0a7088fa9bc480773dcfe1 Mon Sep 17 00:00:00 2001 From: Sanjay Patel Date: Mon, 15 May 2017 19:16:49 +0000 Subject: [InstSimplify] restrict icmp fold with 2 sdiv exact operands (PR32949) These folds were introduced with https://reviews.llvm.org/rL127064 as part of solving: https://bugs.llvm.org/show_bug.cgi?id=9343 As shown here: http://rise4fun.com/Alive/C8 ...however, the sdiv exact case needs a stronger predicate. I opted for duplicated code instead of adding another fallthrough because I think that's easier to read (and edit in case we need/want to restrict/loosen the predicates any more). This should fix: https://bugs.llvm.org/show_bug.cgi?id=32949 https://bugs.llvm.org/show_bug.cgi?id=32948 Differential Revision: https://reviews.llvm.org/D32954 llvm-svn: 303104 --- llvm/test/Transforms/InstSimplify/compare.ll | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'llvm/test/Transforms/InstSimplify/compare.ll') diff --git a/llvm/test/Transforms/InstSimplify/compare.ll b/llvm/test/Transforms/InstSimplify/compare.ll index 883bf31ff77..d6f1b634102 100644 --- a/llvm/test/Transforms/InstSimplify/compare.ll +++ b/llvm/test/Transforms/InstSimplify/compare.ll @@ -598,11 +598,14 @@ define i1 @sdiv_exact_equality(i32 %Z) { 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 -- cgit v1.2.3