[llvm] r335128 - [InstSimplify] Add tests for missed optimizations in simplifyUnsignedRangeCheck (NFC)
Sanjay Patel via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 20 07:03:13 PDT 2018
Author: spatel
Date: Wed Jun 20 07:03:13 2018
New Revision: 335128
URL: http://llvm.org/viewvc/llvm-project?rev=335128&view=rev
Log:
[InstSimplify] Add tests for missed optimizations in simplifyUnsignedRangeCheck (NFC)
These are the baseline tests for the functional change in D47922.
Patch by Li Jia He!
Differential Revision: https://reviews.llvm.org/D48000
Modified:
llvm/trunk/test/Transforms/InstSimplify/AndOrXor.ll
Modified: llvm/trunk/test/Transforms/InstSimplify/AndOrXor.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstSimplify/AndOrXor.ll?rev=335128&r1=335127&r2=335128&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstSimplify/AndOrXor.ll (original)
+++ llvm/trunk/test/Transforms/InstSimplify/AndOrXor.ll Wed Jun 20 07:03:13 2018
@@ -374,6 +374,19 @@ define i1 @and_icmp1(i32 %x, i32 %y) {
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]]
+;
+ %1 = icmp ugt i32 %x, %y
+ %2 = icmp ne i32 %x, 0
+ %3 = and i1 %1, %2
+ ret i1 %3
+}
+
+define i1 @and_icmp3(i32 %x, i32 %y) {
+; CHECK-LABEL: @and_icmp3(
; CHECK-NEXT: ret i1 false
;
%1 = icmp ult i32 %x, %y
@@ -382,6 +395,19 @@ define i1 @and_icmp2(i32 %x, i32 %y) {
ret i1 %3
}
+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]]
+;
+ %1 = icmp ugt i32 %x, %y
+ %2 = icmp eq i32 %x, 0
+ %3 = and i1 %1, %2
+ ret i1 %3
+}
+
define i1 @or_icmp1(i32 %x, i32 %y) {
; CHECK-LABEL: @or_icmp1(
; CHECK-NEXT: [[TMP1:%.*]] = icmp ne i32 [[Y:%.*]], 0
@@ -395,6 +421,19 @@ define i1 @or_icmp1(i32 %x, i32 %y) {
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]]
+;
+ %1 = icmp ugt i32 %x, %y
+ %2 = icmp ne i32 %x, 0
+ %3 = or i1 %1, %2
+ ret i1 %3
+}
+
+define i1 @or_icmp3(i32 %x, i32 %y) {
+; CHECK-LABEL: @or_icmp3(
; CHECK-NEXT: ret i1 true
;
%1 = icmp uge i32 %x, %y
@@ -403,8 +442,21 @@ define i1 @or_icmp2(i32 %x, i32 %y) {
ret i1 %3
}
-define i1 @or_icmp3(i32 %x, i32 %y) {
-; CHECK-LABEL: @or_icmp3(
+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]]
+;
+ %1 = icmp ule i32 %x, %y
+ %2 = icmp ne i32 %x, 0
+ %3 = or i1 %1, %2
+ ret i1 %3
+}
+
+define i1 @or_icmp5(i32 %x, i32 %y) {
+; CHECK-LABEL: @or_icmp5(
; CHECK-NEXT: [[TMP1:%.*]] = icmp uge i32 [[X:%.*]], [[Y:%.*]]
; CHECK-NEXT: ret i1 [[TMP1]]
;
@@ -413,6 +465,19 @@ define i1 @or_icmp3(i32 %x, i32 %y) {
%3 = or i1 %1, %2
ret i1 %3
}
+
+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]]
+;
+ %1 = icmp ule i32 %x, %y
+ %2 = icmp eq i32 %x, 0
+ %3 = or i1 %1, %2
+ ret i1 %3
+}
; PR27869 - Look through casts to eliminate cmps and bitwise logic.
More information about the llvm-commits
mailing list