1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2025-01-31 20:51:52 +01:00

[NFC][InstCombine] Add forgotten variable tests for foldICmpWithLowBitMaskedVal()

llvm-svn: 337094
This commit is contained in:
Roman Lebedev 2018-07-14 12:19:56 +00:00
parent e5f9837b78
commit 9d349e2cd1
2 changed files with 116 additions and 0 deletions

View File

@ -23,6 +23,18 @@ define i1 @p0(i8 %x) {
ret i1 %ret
}
define i1 @pv(i8 %x, i8 %y) {
; CHECK-LABEL: @pv(
; CHECK-NEXT: [[TMP0:%.*]] = lshr i8 -1, [[Y:%.*]]
; CHECK-NEXT: [[TMP1:%.*]] = icmp uge i8 [[TMP0]], [[X:%.*]]
; CHECK-NEXT: ret i1 [[TMP1]]
;
%tmp0 = lshr i8 -1, %y
%tmp1 = and i8 %tmp0, %x
%ret = icmp eq i8 %tmp1, %x
ret i1 %ret
}
; ============================================================================ ;
; Vector tests
; ============================================================================ ;
@ -75,6 +87,52 @@ define i1 @c0() {
ret i1 %ret
}
; ============================================================================ ;
; Commutativity tests with variable
; ============================================================================ ;
define i1 @cv0(i8 %y) {
; CHECK-LABEL: @cv0(
; CHECK-NEXT: [[X:%.*]] = call i8 @gen8()
; CHECK-NEXT: [[TMP0:%.*]] = lshr i8 -1, [[Y:%.*]]
; CHECK-NEXT: [[TMP1:%.*]] = icmp ule i8 [[X]], [[TMP0]]
; CHECK-NEXT: ret i1 [[TMP1]]
;
%x = call i8 @gen8()
%tmp0 = lshr i8 -1, %y
%tmp1 = and i8 %x, %tmp0 ; swapped order
%ret = icmp eq i8 %tmp1, %x
ret i1 %ret
}
define i1 @cv1(i8 %y) {
; CHECK-LABEL: @cv1(
; CHECK-NEXT: [[X:%.*]] = call i8 @gen8()
; CHECK-NEXT: [[TMP0:%.*]] = lshr i8 -1, [[Y:%.*]]
; CHECK-NEXT: [[TMP1:%.*]] = icmp ule i8 [[X]], [[TMP0]]
; CHECK-NEXT: ret i1 [[TMP1]]
;
%x = call i8 @gen8()
%tmp0 = lshr i8 -1, %y
%tmp1 = and i8 %tmp0, %x
%ret = icmp eq i8 %x, %tmp1 ; swapped order
ret i1 %ret
}
define i1 @cv2(i8 %y) {
; CHECK-LABEL: @cv2(
; CHECK-NEXT: [[X:%.*]] = call i8 @gen8()
; CHECK-NEXT: [[TMP0:%.*]] = lshr i8 -1, [[Y:%.*]]
; CHECK-NEXT: [[TMP1:%.*]] = icmp ule i8 [[X]], [[TMP0]]
; CHECK-NEXT: ret i1 [[TMP1]]
;
%x = call i8 @gen8()
%tmp0 = lshr i8 -1, %y
%tmp1 = and i8 %x, %tmp0 ; swapped order
%ret = icmp eq i8 %x, %tmp1 ; swapped order
ret i1 %ret
}
; ============================================================================ ;
; One-use tests. We don't care about multi-uses here.
; ============================================================================ ;

View File

@ -23,6 +23,18 @@ define i1 @p0(i8 %x) {
ret i1 %ret
}
define i1 @pv(i8 %x, i8 %y) {
; CHECK-LABEL: @pv(
; CHECK-NEXT: [[TMP0:%.*]] = lshr i8 -1, [[Y:%.*]]
; CHECK-NEXT: [[TMP1:%.*]] = icmp ult i8 [[TMP0]], [[X:%.*]]
; CHECK-NEXT: ret i1 [[TMP1]]
;
%tmp0 = lshr i8 -1, %y
%tmp1 = and i8 %tmp0, %x
%ret = icmp ne i8 %tmp1, %x
ret i1 %ret
}
; ============================================================================ ;
; Vector tests
; ============================================================================ ;
@ -75,6 +87,52 @@ define i1 @c0() {
ret i1 %ret
}
; ============================================================================ ;
; Commutativity tests with variable
; ============================================================================ ;
define i1 @cv0(i8 %y) {
; CHECK-LABEL: @cv0(
; CHECK-NEXT: [[X:%.*]] = call i8 @gen8()
; CHECK-NEXT: [[TMP0:%.*]] = lshr i8 -1, [[Y:%.*]]
; CHECK-NEXT: [[TMP1:%.*]] = icmp ugt i8 [[X]], [[TMP0]]
; CHECK-NEXT: ret i1 [[TMP1]]
;
%x = call i8 @gen8()
%tmp0 = lshr i8 -1, %y
%tmp1 = and i8 %x, %tmp0 ; swapped order
%ret = icmp ne i8 %tmp1, %x
ret i1 %ret
}
define i1 @cv1(i8 %y) {
; CHECK-LABEL: @cv1(
; CHECK-NEXT: [[X:%.*]] = call i8 @gen8()
; CHECK-NEXT: [[TMP0:%.*]] = lshr i8 -1, [[Y:%.*]]
; CHECK-NEXT: [[TMP1:%.*]] = icmp ugt i8 [[X]], [[TMP0]]
; CHECK-NEXT: ret i1 [[TMP1]]
;
%x = call i8 @gen8()
%tmp0 = lshr i8 -1, %y
%tmp1 = and i8 %tmp0, %x
%ret = icmp ne i8 %x, %tmp1 ; swapped order
ret i1 %ret
}
define i1 @cv2(i8 %y) {
; CHECK-LABEL: @cv2(
; CHECK-NEXT: [[X:%.*]] = call i8 @gen8()
; CHECK-NEXT: [[TMP0:%.*]] = lshr i8 -1, [[Y:%.*]]
; CHECK-NEXT: [[TMP1:%.*]] = icmp ugt i8 [[X]], [[TMP0]]
; CHECK-NEXT: ret i1 [[TMP1]]
;
%x = call i8 @gen8()
%tmp0 = lshr i8 -1, %y
%tmp1 = and i8 %x, %tmp0 ; swapped order
%ret = icmp ne i8 %x, %tmp1 ; swapped order
ret i1 %ret
}
; ============================================================================ ;
; One-use tests. We don't care about multi-uses here.
; ============================================================================ ;