[PATCH] D47922: [InstSimplify] Fix some missed optimization opportunities in simplifyUnsignedRangeCheck()

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 20 07:27:23 PDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL335129: [InstSimplify] Fix missed optimization in simplifyUnsignedRangeCheck() (authored by spatel, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D47922?vs=151454&id=152082#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D47922

Files:
  llvm/trunk/lib/Analysis/InstructionSimplify.cpp
  llvm/trunk/test/Transforms/InstSimplify/AndOrXor.ll


Index: llvm/trunk/lib/Analysis/InstructionSimplify.cpp
===================================================================
--- llvm/trunk/lib/Analysis/InstructionSimplify.cpp
+++ llvm/trunk/lib/Analysis/InstructionSimplify.cpp
@@ -1313,7 +1313,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
Index: llvm/trunk/test/Transforms/InstSimplify/AndOrXor.ll
===================================================================
--- llvm/trunk/test/Transforms/InstSimplify/AndOrXor.ll
+++ llvm/trunk/test/Transforms/InstSimplify/AndOrXor.ll
@@ -375,9 +375,7 @@
 define i1 @and_icmp2(i32 %x, i32 %y) {
 ; CHECK-LABEL: @and_icmp2(
 ; CHECK-NEXT:    [[TMP1:%.*]] = icmp ugt i32 [[X:%.*]], [[Y:%.*]]
-; CHECK-NEXT:    [[TMP2:%.*]] = icmp ne i32 [[X]], 0
-; CHECK-NEXT:    [[TMP3:%.*]] = and i1 [[TMP1]], [[TMP2]]
-; CHECK-NEXT:    ret i1 [[TMP3]]
+; CHECK-NEXT:    ret i1 [[TMP1]]
 ;
   %1 = icmp ugt i32 %x, %y
   %2 = icmp ne i32 %x, 0
@@ -397,10 +395,7 @@
 
 define i1 @and_icmp4(i32 %x, i32 %y) {
 ; CHECK-LABEL: @and_icmp4(
-; CHECK-NEXT:    [[TMP1:%.*]] = icmp ugt i32 [[X:%.*]], [[Y:%.*]]
-; CHECK-NEXT:    [[TMP2:%.*]] = icmp eq i32 [[X]], 0
-; CHECK-NEXT:    [[TMP3:%.*]] = and i1 [[TMP1]], [[TMP2]]
-; CHECK-NEXT:    ret i1 [[TMP3]]
+; CHECK-NEXT:    ret i1 false
 ;
   %1 = icmp ugt i32 %x, %y
   %2 = icmp eq i32 %x, 0
@@ -421,10 +416,8 @@
 
 define i1 @or_icmp2(i32 %x, i32 %y) {
 ; CHECK-LABEL: @or_icmp2(
-; CHECK-NEXT:    [[TMP1:%.*]] = icmp ugt i32 [[X:%.*]], [[Y:%.*]]
-; CHECK-NEXT:    [[TMP2:%.*]] = icmp ne i32 [[X]], 0
-; CHECK-NEXT:    [[TMP3:%.*]] = or i1 [[TMP1]], [[TMP2]]
-; CHECK-NEXT:    ret i1 [[TMP3]]
+; CHECK-NEXT:    [[TMP1:%.*]] = icmp ne i32 [[X:%.*]], 0
+; CHECK-NEXT:    ret i1 [[TMP1]]
 ;
   %1 = icmp ugt i32 %x, %y
   %2 = icmp ne i32 %x, 0
@@ -444,10 +437,7 @@
 
 define i1 @or_icmp4(i32 %x, i32 %y) {
 ; CHECK-LABEL: @or_icmp4(
-; CHECK-NEXT:    [[TMP1:%.*]] = icmp ule i32 [[X:%.*]], [[Y:%.*]]
-; CHECK-NEXT:    [[TMP2:%.*]] = icmp ne i32 [[X]], 0
-; CHECK-NEXT:    [[TMP3:%.*]] = or i1 [[TMP1]], [[TMP2]]
-; CHECK-NEXT:    ret i1 [[TMP3]]
+; CHECK-NEXT:    ret i1 true
 ;
   %1 = icmp ule i32 %x, %y
   %2 = icmp ne i32 %x, 0
@@ -469,9 +459,7 @@
 define i1 @or_icmp6(i32 %x, i32 %y) {
 ; CHECK-LABEL: @or_icmp6(
 ; CHECK-NEXT:    [[TMP1:%.*]] = icmp ule i32 [[X:%.*]], [[Y:%.*]]
-; CHECK-NEXT:    [[TMP2:%.*]] = icmp eq i32 [[X]], 0
-; CHECK-NEXT:    [[TMP3:%.*]] = or i1 [[TMP1]], [[TMP2]]
-; CHECK-NEXT:    ret i1 [[TMP3]]
+; CHECK-NEXT:    ret i1 [[TMP1]]
 ;
   %1 = icmp ule i32 %x, %y
   %2 = icmp eq i32 %x, 0


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D47922.152082.patch
Type: text/x-patch
Size: 2847 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180620/1ccec5c3/attachment.bin>


More information about the llvm-commits mailing list