1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 10:42:39 +01:00

[NFC][InstCombine] PR43251 - valid for other predicates too

llvm-svn: 371519
This commit is contained in:
Roman Lebedev 2019-09-10 13:29:40 +00:00
parent 830d01fc77
commit c766525476

View File

@ -54,6 +54,26 @@ define i1 @t1(i8 %base, i8 %offset) {
%r = and i1 %not_null, %no_underflow
ret i1 %r
}
define i1 @t1_strict(i8 %base, i8 %offset) {
; CHECK-LABEL: @t1_strict(
; CHECK-NEXT: [[ADJUSTED:%.*]] = sub i8 [[BASE:%.*]], [[OFFSET:%.*]]
; CHECK-NEXT: call void @use8(i8 [[ADJUSTED]])
; CHECK-NEXT: [[NO_UNDERFLOW:%.*]] = icmp ugt i8 [[BASE]], [[OFFSET]]
; CHECK-NEXT: call void @use1(i1 [[NO_UNDERFLOW]])
; CHECK-NEXT: [[NOT_NULL:%.*]] = icmp ne i8 [[ADJUSTED]], 0
; CHECK-NEXT: call void @use1(i1 [[NOT_NULL]])
; CHECK-NEXT: [[R:%.*]] = and i1 [[NOT_NULL]], [[NO_UNDERFLOW]]
; CHECK-NEXT: ret i1 [[R]]
;
%adjusted = sub i8 %base, %offset
call void @use8(i8 %adjusted)
%no_underflow = icmp ugt i8 %base, %offset ; same is valid for strict predicate
call void @use1(i1 %no_underflow)
%not_null = icmp ne i8 %adjusted, 0
call void @use1(i1 %not_null)
%r = and i1 %not_null, %no_underflow
ret i1 %r
}
define i1 @t2(i8 %base, i8 %offset) {
; CHECK-LABEL: @t2(
@ -117,7 +137,7 @@ define i1 @t4_commutability1(i8 %base, i8 %offset) {
;
%adjusted = sub i8 %base, %offset
call void @use8(i8 %adjusted)
%no_underflow = icmp uge i8 %base, %offset ; swapped
%no_underflow = icmp uge i8 %base, %offset
call void @use1(i1 %no_underflow)
%not_null = icmp ne i8 %adjusted, 0
call void @use1(i1 %not_null)
@ -188,7 +208,27 @@ define i1 @t7(i8 %base, i8 %offset) {
;
%adjusted = sub i8 %base, %offset
call void @use8(i8 %adjusted)
%underflow = icmp ugt i8 %adjusted, %base
%underflow = icmp ult i8 %base, %offset
call void @use1(i1 %underflow)
%null = icmp eq i8 %adjusted, 0
call void @use1(i1 %null)
%r = or i1 %null, %underflow
ret i1 %r
}
define i1 @t7_nonstrict(i8 %base, i8 %offset) {
; CHECK-LABEL: @t7_nonstrict(
; CHECK-NEXT: [[ADJUSTED:%.*]] = sub i8 [[BASE:%.*]], [[OFFSET:%.*]]
; CHECK-NEXT: call void @use8(i8 [[ADJUSTED]])
; CHECK-NEXT: [[UNDERFLOW:%.*]] = icmp ule i8 [[BASE]], [[OFFSET]]
; CHECK-NEXT: call void @use1(i1 [[UNDERFLOW]])
; CHECK-NEXT: [[NULL:%.*]] = icmp eq i8 [[ADJUSTED]], 0
; CHECK-NEXT: call void @use1(i1 [[NULL]])
; CHECK-NEXT: [[R:%.*]] = or i1 [[NULL]], [[UNDERFLOW]]
; CHECK-NEXT: ret i1 [[R]]
;
%adjusted = sub i8 %base, %offset
call void @use8(i8 %adjusted)
%underflow = icmp ule i8 %base, %offset ; same is valid for non-strict predicate
call void @use1(i1 %underflow)
%null = icmp eq i8 %adjusted, 0
call void @use1(i1 %null)
@ -267,6 +307,26 @@ define i1 @t10(i8 %base, i8 %offset) {
%r = or i1 %not_null, %no_underflow
ret i1 %r
}
define i1 @t10_strict_bad(i8 %base, i8 %offset) {
; CHECK-LABEL: @t10_strict_bad(
; CHECK-NEXT: [[ADJUSTED:%.*]] = sub i8 [[BASE:%.*]], [[OFFSET:%.*]]
; CHECK-NEXT: call void @use8(i8 [[ADJUSTED]])
; CHECK-NEXT: [[NO_UNDERFLOW:%.*]] = icmp ugt i8 [[BASE]], [[OFFSET]]
; CHECK-NEXT: call void @use1(i1 [[NO_UNDERFLOW]])
; CHECK-NEXT: [[NOT_NULL:%.*]] = icmp ne i8 [[ADJUSTED]], 0
; CHECK-NEXT: call void @use1(i1 [[NOT_NULL]])
; CHECK-NEXT: [[R:%.*]] = or i1 [[NOT_NULL]], [[NO_UNDERFLOW]]
; CHECK-NEXT: ret i1 [[R]]
;
%adjusted = sub i8 %base, %offset
call void @use8(i8 %adjusted)
%no_underflow = icmp ugt i8 %base, %offset ; but not for non-strict predicate
call void @use1(i1 %no_underflow)
%not_null = icmp ne i8 %adjusted, 0
call void @use1(i1 %not_null)
%r = or i1 %not_null, %no_underflow
ret i1 %r
}
define i1 @t11(i8 %base, i8 %offset) {
; CHECK-LABEL: @t11(
@ -318,6 +378,26 @@ define i1 @t12(i8 %base, i8 %offset) {
%r = and i1 %null, %underflow
ret i1 %r
}
define i1 @t12_nonstrict_bad(i8 %base, i8 %offset) {
; CHECK-LABEL: @t12_nonstrict_bad(
; CHECK-NEXT: [[ADJUSTED:%.*]] = sub i8 [[BASE:%.*]], [[OFFSET:%.*]]
; CHECK-NEXT: call void @use8(i8 [[ADJUSTED]])
; CHECK-NEXT: [[UNDERFLOW:%.*]] = icmp uge i8 [[ADJUSTED]], [[BASE]]
; CHECK-NEXT: call void @use1(i1 [[UNDERFLOW]])
; CHECK-NEXT: [[NULL:%.*]] = icmp eq i8 [[ADJUSTED]], 0
; CHECK-NEXT: call void @use1(i1 [[NULL]])
; CHECK-NEXT: [[R:%.*]] = and i1 [[NULL]], [[UNDERFLOW]]
; CHECK-NEXT: ret i1 [[R]]
;
%adjusted = sub i8 %base, %offset
call void @use8(i8 %adjusted)
%underflow = icmp uge i8 %adjusted, %base ; but not for non-strict predicate
call void @use1(i1 %underflow)
%null = icmp eq i8 %adjusted, 0
call void @use1(i1 %null)
%r = and i1 %null, %underflow
ret i1 %r
}
define i1 @t13(i8 %base, i8 %offset) {
; CHECK-LABEL: @t13(