forked from OSchip/llvm-project
[InstCombine] Add extra use tests for abs canonicalization (NFC)
This commit is contained in:
parent
7da9419399
commit
c34a99fe58
|
@ -461,6 +461,7 @@ define i8 @shifty_abs_commute3(i8 %x) {
|
|||
; Negative test - don't transform if it would increase instruction count.
|
||||
|
||||
declare void @extra_use(i8)
|
||||
declare void @extra_use_i1(i1)
|
||||
|
||||
define i8 @shifty_abs_too_many_uses(i8 %x) {
|
||||
; CHECK-LABEL: @shifty_abs_too_many_uses(
|
||||
|
@ -534,8 +535,8 @@ define i8 @negate_abs(i8 %x) {
|
|||
; CHECK-LABEL: @negate_abs(
|
||||
; CHECK-NEXT: [[N:%.*]] = sub i8 0, [[X:%.*]]
|
||||
; CHECK-NEXT: [[C:%.*]] = icmp slt i8 [[X]], 0
|
||||
; CHECK-NEXT: [[S:%.*]] = select i1 [[C]], i8 [[X]], i8 [[N]]
|
||||
; CHECK-NEXT: ret i8 [[S]]
|
||||
; CHECK-NEXT: [[TMP1:%.*]] = select i1 [[C]], i8 [[X]], i8 [[N]]
|
||||
; CHECK-NEXT: ret i8 [[TMP1]]
|
||||
;
|
||||
%n = sub i8 0, %x
|
||||
%c = icmp slt i8 %x, 0
|
||||
|
@ -548,8 +549,8 @@ define <2 x i8> @negate_nabs(<2 x i8> %x) {
|
|||
; CHECK-LABEL: @negate_nabs(
|
||||
; CHECK-NEXT: [[N:%.*]] = sub <2 x i8> zeroinitializer, [[X:%.*]]
|
||||
; CHECK-NEXT: [[C:%.*]] = icmp slt <2 x i8> [[X]], zeroinitializer
|
||||
; CHECK-NEXT: [[S:%.*]] = select <2 x i1> [[C]], <2 x i8> [[N]], <2 x i8> [[X]]
|
||||
; CHECK-NEXT: ret <2 x i8> [[S]]
|
||||
; CHECK-NEXT: [[TMP1:%.*]] = select <2 x i1> [[C]], <2 x i8> [[N]], <2 x i8> [[X]]
|
||||
; CHECK-NEXT: ret <2 x i8> [[TMP1]]
|
||||
;
|
||||
%n = sub <2 x i8> zeroinitializer, %x
|
||||
%c = icmp slt <2 x i8> %x, zeroinitializer
|
||||
|
@ -647,3 +648,97 @@ define i64 @infinite_loop_constant_expression_abs(i64 %arg) {
|
|||
%t3 = select i1 %t1, i64 %t2, i64 %t
|
||||
ret i64 %t3
|
||||
}
|
||||
|
||||
define i8 @abs_extra_use_icmp(i8 %x) {
|
||||
; CHECK-LABEL: @abs_extra_use_icmp(
|
||||
; CHECK-NEXT: [[C:%.*]] = icmp slt i8 [[X:%.*]], 0
|
||||
; CHECK-NEXT: call void @extra_use_i1(i1 [[C]])
|
||||
; CHECK-NEXT: [[N:%.*]] = sub i8 0, [[X]]
|
||||
; CHECK-NEXT: [[S:%.*]] = select i1 [[C]], i8 [[N]], i8 [[X]]
|
||||
; CHECK-NEXT: ret i8 [[S]]
|
||||
;
|
||||
%c = icmp slt i8 %x, 0
|
||||
call void @extra_use_i1(i1 %c)
|
||||
%n = sub i8 0, %x
|
||||
%s = select i1 %c, i8 %n, i8 %x
|
||||
ret i8 %s
|
||||
}
|
||||
|
||||
define i8 @abs_extra_use_sub(i8 %x) {
|
||||
; CHECK-LABEL: @abs_extra_use_sub(
|
||||
; CHECK-NEXT: [[C:%.*]] = icmp slt i8 [[X:%.*]], 0
|
||||
; CHECK-NEXT: [[N:%.*]] = sub i8 0, [[X]]
|
||||
; CHECK-NEXT: call void @extra_use(i8 [[N]])
|
||||
; CHECK-NEXT: [[S:%.*]] = select i1 [[C]], i8 [[N]], i8 [[X]]
|
||||
; CHECK-NEXT: ret i8 [[S]]
|
||||
;
|
||||
%c = icmp slt i8 %x, 0
|
||||
%n = sub i8 0, %x
|
||||
call void @extra_use(i8 %n)
|
||||
%s = select i1 %c, i8 %n, i8 %x
|
||||
ret i8 %s
|
||||
}
|
||||
|
||||
define i8 @abs_extra_use_icmp_sub(i8 %x) {
|
||||
; CHECK-LABEL: @abs_extra_use_icmp_sub(
|
||||
; CHECK-NEXT: [[C:%.*]] = icmp slt i8 [[X:%.*]], 0
|
||||
; CHECK-NEXT: call void @extra_use_i1(i1 [[C]])
|
||||
; CHECK-NEXT: [[N:%.*]] = sub i8 0, [[X]]
|
||||
; CHECK-NEXT: call void @extra_use(i8 [[N]])
|
||||
; CHECK-NEXT: [[S:%.*]] = select i1 [[C]], i8 [[N]], i8 [[X]]
|
||||
; CHECK-NEXT: ret i8 [[S]]
|
||||
;
|
||||
%c = icmp slt i8 %x, 0
|
||||
call void @extra_use_i1(i1 %c)
|
||||
%n = sub i8 0, %x
|
||||
call void @extra_use(i8 %n)
|
||||
%s = select i1 %c, i8 %n, i8 %x
|
||||
ret i8 %s
|
||||
}
|
||||
|
||||
define i8 @nabs_extra_use_icmp(i8 %x) {
|
||||
; CHECK-LABEL: @nabs_extra_use_icmp(
|
||||
; CHECK-NEXT: [[C:%.*]] = icmp slt i8 [[X:%.*]], 0
|
||||
; CHECK-NEXT: call void @extra_use_i1(i1 [[C]])
|
||||
; CHECK-NEXT: [[N:%.*]] = sub i8 0, [[X]]
|
||||
; CHECK-NEXT: [[S:%.*]] = select i1 [[C]], i8 [[X]], i8 [[N]]
|
||||
; CHECK-NEXT: ret i8 [[S]]
|
||||
;
|
||||
%c = icmp slt i8 %x, 0
|
||||
call void @extra_use_i1(i1 %c)
|
||||
%n = sub i8 0, %x
|
||||
%s = select i1 %c, i8 %x, i8 %n
|
||||
ret i8 %s
|
||||
}
|
||||
|
||||
define i8 @nabs_extra_use_sub(i8 %x) {
|
||||
; CHECK-LABEL: @nabs_extra_use_sub(
|
||||
; CHECK-NEXT: [[C:%.*]] = icmp slt i8 [[X:%.*]], 0
|
||||
; CHECK-NEXT: [[N:%.*]] = sub i8 0, [[X]]
|
||||
; CHECK-NEXT: call void @extra_use(i8 [[N]])
|
||||
; CHECK-NEXT: [[S:%.*]] = select i1 [[C]], i8 [[X]], i8 [[N]]
|
||||
; CHECK-NEXT: ret i8 [[S]]
|
||||
;
|
||||
%c = icmp slt i8 %x, 0
|
||||
%n = sub i8 0, %x
|
||||
call void @extra_use(i8 %n)
|
||||
%s = select i1 %c, i8 %x, i8 %n
|
||||
ret i8 %s
|
||||
}
|
||||
|
||||
define i8 @nabs_extra_use_icmp_sub(i8 %x) {
|
||||
; CHECK-LABEL: @nabs_extra_use_icmp_sub(
|
||||
; CHECK-NEXT: [[C:%.*]] = icmp slt i8 [[X:%.*]], 0
|
||||
; CHECK-NEXT: call void @extra_use_i1(i1 [[C]])
|
||||
; CHECK-NEXT: [[N:%.*]] = sub i8 0, [[X]]
|
||||
; CHECK-NEXT: call void @extra_use(i8 [[N]])
|
||||
; CHECK-NEXT: [[S:%.*]] = select i1 [[C]], i8 [[X]], i8 [[N]]
|
||||
; CHECK-NEXT: ret i8 [[S]]
|
||||
;
|
||||
%c = icmp slt i8 %x, 0
|
||||
call void @extra_use_i1(i1 %c)
|
||||
%n = sub i8 0, %x
|
||||
call void @extra_use(i8 %n)
|
||||
%s = select i1 %c, i8 %x, i8 %n
|
||||
ret i8 %s
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue