mirror of
https://github.com/RPCSX/llvm.git
synced 2024-11-28 06:00:28 +00:00
[InstCombine] auto-generate checks
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@285045 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
12e2f72b91
commit
5aa57a1a64
@ -1,105 +1,124 @@
|
||||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
|
||||
; RUN: opt -S -instcombine < %s | FileCheck %s
|
||||
|
||||
; CHECK-LABEL: @t1
|
||||
; CHECK-NEXT: fcmp oge float %a, 5.000000e+00
|
||||
; CHECK-NEXT: select i1 %.inv, float 5.000000e+00, float %a
|
||||
; CHECK-NEXT: fpext float %1 to double
|
||||
; This is the canonical form for a type-changing min/max.
|
||||
define double @t1(float %a) {
|
||||
; This is the canonical form for a type-changing min/max.
|
||||
; CHECK-LABEL: @t1(
|
||||
; CHECK-NEXT: [[DOTINV:%.*]] = fcmp oge float %a, 5.000000e+00
|
||||
; CHECK-NEXT: [[TMP1:%.*]] = select i1 [[DOTINV]], float 5.000000e+00, float %a
|
||||
; CHECK-NEXT: [[TMP2:%.*]] = fpext float [[TMP1]] to double
|
||||
; CHECK-NEXT: ret double [[TMP2]]
|
||||
;
|
||||
%1 = fcmp ult float %a, 5.0
|
||||
%2 = select i1 %1, float %a, float 5.0
|
||||
%3 = fpext float %2 to double
|
||||
ret double %3
|
||||
}
|
||||
|
||||
; CHECK-LABEL: @t2
|
||||
; CHECK-NEXT: fcmp oge float %a, 5.000000e+00
|
||||
; CHECK-NEXT: select i1 %.inv, float 5.000000e+00, float %a
|
||||
; CHECK-NEXT: fpext float %1 to double
|
||||
; Check this is converted into canonical form, as above.
|
||||
define double @t2(float %a) {
|
||||
; Check this is converted into canonical form, as above.
|
||||
; CHECK-LABEL: @t2(
|
||||
; CHECK-NEXT: [[DOTINV:%.*]] = fcmp oge float %a, 5.000000e+00
|
||||
; CHECK-NEXT: [[TMP1:%.*]] = select i1 [[DOTINV]], float 5.000000e+00, float %a
|
||||
; CHECK-NEXT: [[TMP2:%.*]] = fpext float [[TMP1]] to double
|
||||
; CHECK-NEXT: ret double [[TMP2]]
|
||||
;
|
||||
%1 = fcmp ult float %a, 5.0
|
||||
%2 = fpext float %a to double
|
||||
%3 = select i1 %1, double %2, double 5.0
|
||||
ret double %3
|
||||
}
|
||||
|
||||
; CHECK-LABEL: @t4
|
||||
; CHECK-NEXT: fcmp oge double %a, 5.000000e+00
|
||||
; CHECK-NEXT: select i1 %.inv, double 5.000000e+00, double %a
|
||||
; CHECK-NEXT: fptrunc double %1 to float
|
||||
; Same again, with trunc.
|
||||
define float @t4(double %a) {
|
||||
; Same again, with trunc.
|
||||
; CHECK-LABEL: @t4(
|
||||
; CHECK-NEXT: [[DOTINV:%.*]] = fcmp oge double %a, 5.000000e+00
|
||||
; CHECK-NEXT: [[TMP1:%.*]] = select i1 [[DOTINV]], double 5.000000e+00, double %a
|
||||
; CHECK-NEXT: [[TMP2:%.*]] = fptrunc double [[TMP1]] to float
|
||||
; CHECK-NEXT: ret float [[TMP2]]
|
||||
;
|
||||
%1 = fcmp ult double %a, 5.0
|
||||
%2 = fptrunc double %a to float
|
||||
%3 = select i1 %1, float %2, float 5.0
|
||||
ret float %3
|
||||
}
|
||||
|
||||
; CHECK-LABEL: @t5
|
||||
; CHECK-NEXT: fcmp ult float %a, 5.000000e+00
|
||||
; CHECK-NEXT: fpext float %a to double
|
||||
; CHECK-NEXT: select i1 %1, double %2, double 5.001
|
||||
; different values, should not be converted.
|
||||
define double @t5(float %a) {
|
||||
; different values, should not be converted.
|
||||
; CHECK-LABEL: @t5(
|
||||
; CHECK-NEXT: [[TMP1:%.*]] = fcmp ult float %a, 5.000000e+00
|
||||
; CHECK-NEXT: [[TMP2:%.*]] = fpext float %a to double
|
||||
; CHECK-NEXT: [[TMP3:%.*]] = select i1 [[TMP1]], double [[TMP2]], double 5.001000e+00
|
||||
; CHECK-NEXT: ret double [[TMP3]]
|
||||
;
|
||||
%1 = fcmp ult float %a, 5.0
|
||||
%2 = fpext float %a to double
|
||||
%3 = select i1 %1, double %2, double 5.001
|
||||
ret double %3
|
||||
}
|
||||
|
||||
; CHECK-LABEL: @t6
|
||||
; CHECK-NEXT: fcmp ult float %a, -0.0
|
||||
; CHECK-NEXT: fpext float %a to double
|
||||
; CHECK-NEXT: select i1 %1, double %2, double 0.0
|
||||
; Signed zero, should not be converted
|
||||
define double @t6(float %a) {
|
||||
; Signed zero, should not be converted
|
||||
; CHECK-LABEL: @t6(
|
||||
; CHECK-NEXT: [[TMP1:%.*]] = fcmp ult float %a, -0.000000e+00
|
||||
; CHECK-NEXT: [[TMP2:%.*]] = fpext float %a to double
|
||||
; CHECK-NEXT: [[TMP3:%.*]] = select i1 [[TMP1]], double [[TMP2]], double 0.000000e+00
|
||||
; CHECK-NEXT: ret double [[TMP3]]
|
||||
;
|
||||
%1 = fcmp ult float %a, -0.0
|
||||
%2 = fpext float %a to double
|
||||
%3 = select i1 %1, double %2, double 0.0
|
||||
ret double %3
|
||||
}
|
||||
|
||||
; CHECK-LABEL: @t7
|
||||
; CHECK-NEXT: fcmp ult float %a, 0.0
|
||||
; CHECK-NEXT: fpext float %a to double
|
||||
; CHECK-NEXT: select i1 %1, double %2, double -0.0
|
||||
; Signed zero, should not be converted
|
||||
define double @t7(float %a) {
|
||||
; Signed zero, should not be converted
|
||||
; CHECK-LABEL: @t7(
|
||||
; CHECK-NEXT: [[TMP1:%.*]] = fcmp ult float %a, 0.000000e+00
|
||||
; CHECK-NEXT: [[TMP2:%.*]] = fpext float %a to double
|
||||
; CHECK-NEXT: [[TMP3:%.*]] = select i1 [[TMP1]], double [[TMP2]], double -0.000000e+00
|
||||
; CHECK-NEXT: ret double [[TMP3]]
|
||||
;
|
||||
%1 = fcmp ult float %a, 0.0
|
||||
%2 = fpext float %a to double
|
||||
%3 = select i1 %1, double %2, double -0.0
|
||||
ret double %3
|
||||
}
|
||||
|
||||
; CHECK-LABEL: @t8
|
||||
; CHECK-NEXT: fcmp oge float %a, 5.000000e+00
|
||||
; CHECK-NEXT: select i1 %.inv, float 5.000000e+00, float %a
|
||||
; CHECK-NEXT: fptoui float %1 to i64
|
||||
define i64 @t8(float %a) {
|
||||
; CHECK-LABEL: @t8(
|
||||
; CHECK-NEXT: [[DOTINV:%.*]] = fcmp oge float %a, 5.000000e+00
|
||||
; CHECK-NEXT: [[TMP1:%.*]] = select i1 [[DOTINV]], float 5.000000e+00, float %a
|
||||
; CHECK-NEXT: [[TMP2:%.*]] = fptoui float [[TMP1]] to i64
|
||||
; CHECK-NEXT: ret i64 [[TMP2]]
|
||||
;
|
||||
%1 = fcmp ult float %a, 5.0
|
||||
%2 = fptoui float %a to i64
|
||||
%3 = select i1 %1, i64 %2, i64 5
|
||||
ret i64 %3
|
||||
}
|
||||
|
||||
; CHECK-LABEL: @t9
|
||||
; CHECK-NEXT: fcmp oge float %a, 0.000000e+00
|
||||
; CHECK-NEXT: select i1 %.inv, float 0.000000e+00, float %a
|
||||
; CHECK-NEXT: fptosi float %1 to i8
|
||||
define i8 @t9(float %a) {
|
||||
; CHECK-LABEL: @t9(
|
||||
; CHECK-NEXT: [[DOTINV:%.*]] = fcmp oge float %a, 0.000000e+00
|
||||
; CHECK-NEXT: [[TMP1:%.*]] = select i1 [[DOTINV]], float 0.000000e+00, float %a
|
||||
; CHECK-NEXT: [[TMP2:%.*]] = fptosi float [[TMP1]] to i8
|
||||
; CHECK-NEXT: ret i8 [[TMP2]]
|
||||
;
|
||||
%1 = fcmp ult float %a, 0.0
|
||||
%2 = fptosi float %a to i8
|
||||
%3 = select i1 %1, i8 %2, i8 0
|
||||
ret i8 %3
|
||||
}
|
||||
|
||||
; CHECK-LABEL: @t11
|
||||
; CHECK-NEXT: fcmp fast oge float %b, %a
|
||||
; CHECK-NEXT: select i1 %.inv, float %a, float %b
|
||||
; CHECK-NEXT: fptosi
|
||||
define i8 @t11(float %a, float %b) {
|
||||
; Either operand could be NaN, but fast modifier applied.
|
||||
define i8 @t11(float %a, float %b) {
|
||||
; CHECK-LABEL: @t11(
|
||||
; CHECK-NEXT: [[DOTINV:%.*]] = fcmp fast oge float %b, %a
|
||||
; CHECK-NEXT: [[DOTV:%.*]] = select i1 [[DOTINV]], float %a, float %b
|
||||
; CHECK-NEXT: [[TMP1:%.*]] = fptosi float [[DOTV]] to i8
|
||||
; CHECK-NEXT: ret i8 [[TMP1]]
|
||||
;
|
||||
%1 = fcmp fast ult float %b, %a
|
||||
%2 = fptosi float %a to i8
|
||||
%3 = fptosi float %b to i8
|
||||
@ -107,12 +126,14 @@ define i8 @t11(float %a, float %b) {
|
||||
ret i8 %4
|
||||
}
|
||||
|
||||
; CHECK-LABEL: @t12
|
||||
; CHECK-NEXT: fcmp nnan oge float %b, %a
|
||||
; CHECK-NEXT: select i1 %.inv, float %a, float %b
|
||||
; CHECK-NEXT: fptosi float %.v to i8
|
||||
; Either operand could be NaN, but nnan modifier applied.
|
||||
define i8 @t12(float %a, float %b) {
|
||||
; Either operand could be NaN, but nnan modifier applied.
|
||||
; CHECK-LABEL: @t12(
|
||||
; CHECK-NEXT: [[DOTINV:%.*]] = fcmp nnan oge float %b, %a
|
||||
; CHECK-NEXT: [[DOTV:%.*]] = select i1 [[DOTINV]], float %a, float %b
|
||||
; CHECK-NEXT: [[TMP1:%.*]] = fptosi float [[DOTV]] to i8
|
||||
; CHECK-NEXT: ret i8 [[TMP1]]
|
||||
;
|
||||
%1 = fcmp nnan ult float %b, %a
|
||||
%2 = fptosi float %a to i8
|
||||
%3 = fptosi float %b to i8
|
||||
@ -120,63 +141,70 @@ define i8 @t12(float %a, float %b) {
|
||||
ret i8 %4
|
||||
}
|
||||
|
||||
; CHECK-LABEL: @t13
|
||||
; CHECK-NEXT: fcmp ult float %a, 1.500000e+00
|
||||
; CHECK-NEXT: fptosi float %a to i8
|
||||
; CHECK-NEXT: select i1 %1, i8 %2, i8 1
|
||||
; Float and int values do not match.
|
||||
define i8 @t13(float %a) {
|
||||
; Float and int values do not match.
|
||||
; CHECK-LABEL: @t13(
|
||||
; CHECK-NEXT: [[TMP1:%.*]] = fcmp ult float %a, 1.500000e+00
|
||||
; CHECK-NEXT: [[TMP2:%.*]] = fptosi float %a to i8
|
||||
; CHECK-NEXT: [[TMP3:%.*]] = select i1 [[TMP1]], i8 [[TMP2]], i8 1
|
||||
; CHECK-NEXT: ret i8 [[TMP3]]
|
||||
;
|
||||
%1 = fcmp ult float %a, 1.5
|
||||
%2 = fptosi float %a to i8
|
||||
%3 = select i1 %1, i8 %2, i8 1
|
||||
ret i8 %3
|
||||
}
|
||||
|
||||
; CHECK-LABEL: @t14
|
||||
; CHECK-NEXT: fcmp ule float %a, 0.000000e+00
|
||||
; CHECK-NEXT: fptosi float %a to i8
|
||||
; CHECK-NEXT: select i1 %1, i8 %2, i8 0
|
||||
; <= comparison, where %a could be -0.0. Not safe.
|
||||
define i8 @t14(float %a) {
|
||||
; <= comparison, where %a could be -0.0. Not safe.
|
||||
; CHECK-LABEL: @t14(
|
||||
; CHECK-NEXT: [[TMP1:%.*]] = fcmp ule float %a, 0.000000e+00
|
||||
; CHECK-NEXT: [[TMP2:%.*]] = fptosi float %a to i8
|
||||
; CHECK-NEXT: [[TMP3:%.*]] = select i1 [[TMP1]], i8 [[TMP2]], i8 0
|
||||
; CHECK-NEXT: ret i8 [[TMP3]]
|
||||
;
|
||||
%1 = fcmp ule float %a, 0.0
|
||||
%2 = fptosi float %a to i8
|
||||
%3 = select i1 %1, i8 %2, i8 0
|
||||
ret i8 %3
|
||||
}
|
||||
|
||||
; CHECK-LABEL: @t15
|
||||
; CHECK-NEXT: fcmp nsz oge float %a, 0.000000e+00
|
||||
; CHECK-NEXT: select i1 %.inv, float 0.000000e+00, float %a
|
||||
; CHECK-NEXT: fptosi float %1 to i8
|
||||
define i8 @t15(float %a) {
|
||||
; CHECK-LABEL: @t15(
|
||||
; CHECK-NEXT: [[DOTINV:%.*]] = fcmp nsz oge float %a, 0.000000e+00
|
||||
; CHECK-NEXT: [[TMP1:%.*]] = select i1 [[DOTINV]], float 0.000000e+00, float %a
|
||||
; CHECK-NEXT: [[TMP2:%.*]] = fptosi float [[TMP1]] to i8
|
||||
; CHECK-NEXT: ret i8 [[TMP2]]
|
||||
;
|
||||
%1 = fcmp nsz ule float %a, 0.0
|
||||
%2 = fptosi float %a to i8
|
||||
%3 = select i1 %1, i8 %2, i8 0
|
||||
ret i8 %3
|
||||
}
|
||||
|
||||
; CHECK-LABEL: @t16
|
||||
; CHECK: %[[cmp:.*]] = icmp sgt i32 %x, 0
|
||||
; CHECK: %[[cst:.*]] = sitofp i32 %x to double
|
||||
; CHECK: %[[sel:.*]] = select i1 %[[cmp]], double %[[cst]], double 5.000000e-01
|
||||
; CHECK: ret double %[[sel]]
|
||||
define double @t16(i32 %x) {
|
||||
entry:
|
||||
; CHECK-LABEL: @t16(
|
||||
; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i32 %x, 0
|
||||
; CHECK-NEXT: [[CST:%.*]] = sitofp i32 %x to double
|
||||
; CHECK-NEXT: [[SEL:%.*]] = select i1 [[CMP]], double [[CST]], double 5.000000e-01
|
||||
; CHECK-NEXT: ret double [[SEL]]
|
||||
;
|
||||
%cmp = icmp sgt i32 %x, 0
|
||||
%cst = sitofp i32 %x to double
|
||||
%sel = select i1 %cmp, double %cst, double 5.000000e-01
|
||||
ret double %sel
|
||||
}
|
||||
|
||||
; CHECK-LABEL: @t17
|
||||
; CHECK: %[[cmp:.*]] = icmp sgt i32 %x, 2
|
||||
; CHECK: %[[sel:.*]] = select i1 %[[cmp]], i32 %x, i32 2
|
||||
; CHECK: %[[cst:.*]] = sitofp i32 %[[sel]] to double
|
||||
; CHECK: ret double %[[cst]]
|
||||
define double @t17(i32 %x) {
|
||||
entry:
|
||||
; CHECK-LABEL: @t17(
|
||||
; CHECK-NEXT: [[TMP1:%.*]] = icmp sgt i32 %x, 2
|
||||
; CHECK-NEXT: [[SEL1:%.*]] = select i1 [[TMP1]], i32 %x, i32 2
|
||||
; CHECK-NEXT: [[TMP2:%.*]] = sitofp i32 [[SEL1]] to double
|
||||
; CHECK-NEXT: ret double [[TMP2]]
|
||||
;
|
||||
%cmp = icmp sgt i32 %x, 2
|
||||
%cst = sitofp i32 %x to double
|
||||
%sel = select i1 %cmp, double %cst, double 2.0
|
||||
ret double %sel
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user