[PATCH] D47922: x > y && x != 0 -> x > y
Li Jia He via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 7 18:59:10 PDT 2018
HLJ2009 created this revision.
Herald added a subscriber: llvm-commits.
Repository:
rL LLVM
https://reviews.llvm.org/D47922
Files:
lib/Analysis/InstructionSimplify.cpp
test/Transforms/InstCombine/and3.ll
Index: test/Transforms/InstCombine/and3.ll
===================================================================
--- /dev/null
+++ test/Transforms/InstCombine/and3.ll
@@ -0,0 +1,17 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt < %s -instcombine -S | FileCheck %s
+
+; x > y && x != 0 -> x > y
+
+define i32 @test1(i32 %x, i32 %y) {
+; CHECK-LABEL: @test1(
+; CHECK-NEXT: [[TMP1:%.*]] = icmp ugt i32 %x, %y
+; CHECK-NEXT: [[TMP2:%.*]] = zext i1 [[TMP1]] to i32
+; CHECK-NEXT: ret i32 [[TMP2]]
+;
+ %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.150440.patch
Type: text/x-patch
Size: 1224 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180608/f4929043/attachment.bin>
More information about the llvm-commits
mailing list