[PATCH] D47922: unsigned foo(unsigned x, unsigned y) { return x > y && x != 0; } should fold to x > y
Li Jia He via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 8 01:27:54 PDT 2018
HLJ2009 updated this revision to Diff 150464.
HLJ2009 added a comment.
modify the test file.
Repository:
rL LLVM
https://reviews.llvm.org/D47922
Files:
lib/Analysis/InstructionSimplify.cpp
test/Transforms/InstCombine/range-check.ll
Index: test/Transforms/InstCombine/range-check.ll
===================================================================
--- test/Transforms/InstCombine/range-check.ll
+++ test/Transforms/InstCombine/range-check.ll
@@ -157,3 +157,15 @@
ret i1 %c
}
+; CHECK-LABEL: @test1(
+; CHECK-NEXT: [[TMP1:%.*]] = icmp ugt i32 %x, %y
+; CHECK-NEXT: [[TMP2:%.*]] = zext i1 [[TMP1]] to i32
+; CHECK-NEXT: ret i32 [[TMP2]]
+define i32 @test1(i32 %x, i32 %y) {
+ %1 = icmp ugt i32 %x, %y
+ %2 = icmp ne i32 %x, 0
+ %3 = and i1 %2, %1
+ %4 = zext i1 %3 to i32
+ ret i32 %4
+}
+
Index: lib/Analysis/InstructionSimplify.cpp
===================================================================
--- lib/Analysis/InstructionSimplify.cpp
+++ lib/Analysis/InstructionSimplify.cpp
@@ -1309,7 +1309,7 @@
ICmpInst::isUnsigned(UnsignedPred))
;
else if (match(UnsignedICmp,
- m_ICmp(UnsignedPred, m_Value(Y), m_Specific(X))) &&
+ m_ICmp(UnsignedPred, m_Specific(Y), m_Value(X))) &&
ICmpInst::isUnsigned(UnsignedPred))
UnsignedPred = ICmpInst::getSwappedPredicate(UnsignedPred);
else
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D47922.150464.patch
Type: text/x-patch
Size: 1137 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180608/5ccb0d56/attachment.bin>
More information about the llvm-commits
mailing list