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

[InstCombine] Add tests for D84948; NFC

This commit is contained in:
Juneyoung Lee 2020-08-06 14:32:42 +09:00
parent 77d21dcd3f
commit fa59636db3
2 changed files with 89 additions and 0 deletions

View File

@ -18,3 +18,70 @@ define i32 @make_const() {
%x = freeze i32 10
ret i32 %x
}
define i32 @and_freeze_undef(i32 %x) {
; CHECK-LABEL: @and_freeze_undef(
; CHECK-NEXT: [[F:%.*]] = freeze i32 undef
; CHECK-NEXT: [[RES:%.*]] = and i32 [[F]], [[X:%.*]]
; CHECK-NEXT: ret i32 [[RES]]
;
%f = freeze i32 undef
%res = and i32 %x, %f
ret i32 %res
}
declare void @use_i32(i32)
define i32 @and_freeze_undef_multipleuses(i32 %x) {
; CHECK-LABEL: @and_freeze_undef_multipleuses(
; CHECK-NEXT: [[F:%.*]] = freeze i32 undef
; CHECK-NEXT: [[RES:%.*]] = and i32 [[F]], [[X:%.*]]
; CHECK-NEXT: call void @use_i32(i32 [[F]])
; CHECK-NEXT: ret i32 [[RES]]
;
%f = freeze i32 undef
%res = and i32 %x, %f
call void @use_i32(i32 %f)
ret i32 %res
}
define i32 @or_freeze_undef(i32 %x) {
; CHECK-LABEL: @or_freeze_undef(
; CHECK-NEXT: [[F:%.*]] = freeze i32 undef
; CHECK-NEXT: [[RES:%.*]] = or i32 [[F]], [[X:%.*]]
; CHECK-NEXT: ret i32 [[RES]]
;
%f = freeze i32 undef
%res = or i32 %x, %f
ret i32 %res
}
define i32 @or_freeze_undef_multipleuses(i32 %x) {
; CHECK-LABEL: @or_freeze_undef_multipleuses(
; CHECK-NEXT: [[F:%.*]] = freeze i32 undef
; CHECK-NEXT: [[RES:%.*]] = or i32 [[F]], [[X:%.*]]
; CHECK-NEXT: call void @use_i32(i32 [[F]])
; CHECK-NEXT: ret i32 [[RES]]
;
%f = freeze i32 undef
%res = or i32 %x, %f
call void @use_i32(i32 %f)
ret i32 %res
}
declare void @use_i32_i1(i32, i1)
define void @or_select_multipleuses(i32 %x, i1 %y) {
; CHECK-LABEL: @or_select_multipleuses(
; CHECK-NEXT: [[F:%.*]] = freeze i1 undef
; CHECK-NEXT: [[A:%.*]] = select i1 [[F]], i32 [[X:%.*]], i32 32
; CHECK-NEXT: [[B:%.*]] = or i1 [[F]], [[Y:%.*]]
; CHECK-NEXT: call void @use_i32_i1(i32 [[A]], i1 [[B]])
; CHECK-NEXT: ret void
;
%f = freeze i1 undef
%a = select i1 %f, i32 %x, i32 32 ; prefers %f to be false
%b = or i1 %f, %y ; prefers %f to be true
call void @use_i32_i1(i32 %a, i1 %b)
ret void
}

View File

@ -2510,6 +2510,28 @@ define i8 @cond_freeze2(i8 %x, i8 %y) {
ret i8 %s
}
define i8 @cond_freeze3(i8 %x) {
; CHECK-LABEL: @cond_freeze3(
; CHECK-NEXT: [[COND_FR:%.*]] = freeze i1 undef
; CHECK-NEXT: [[S:%.*]] = select i1 [[COND_FR]], i8 1, i8 [[X:%.*]]
; CHECK-NEXT: ret i8 [[S]]
;
%cond.fr = freeze i1 undef
%s = select i1 %cond.fr, i8 1, i8 %x
ret i8 %s
}
define <2 x i8> @cond_freeze_vec(<2 x i8> %x) {
; CHECK-LABEL: @cond_freeze_vec(
; CHECK-NEXT: [[COND_FR:%.*]] = freeze <2 x i1> undef
; CHECK-NEXT: [[S:%.*]] = select <2 x i1> [[COND_FR]], <2 x i8> <i8 1, i8 2>, <2 x i8> [[X:%.*]]
; CHECK-NEXT: ret <2 x i8> [[S]]
;
%cond.fr = freeze <2 x i1> <i1 undef, i1 undef>
%s = select <2 x i1> %cond.fr, <2 x i8> <i8 1, i8 2>, <2 x i8> %x
ret <2 x i8> %s
}
declare void @foo2(i8, i8)
define void @cond_freeze_multipleuses(i8 %x, i8 %y) {