llvm.org GIT mirror llvm / da5824d
R600/SI: Fix [s|u]int_to_fp for i1 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@209971 91177308-0d34-0410-b5e6-96231b3b80d8 Matt Arsenault 6 years ago
6 changed file(s) with 146 addition(s) and 29 deletion(s). Raw diff Collapse all Expand all
251251 int PI = 0x40490fdb;
252252 int TWO_PI_INV = 0x3e22f983;
253253 int FP_UINT_MAX_PLUS_1 = 0x4f800000; // 1 << 32 in floating point encoding
254 int FP32_NEG_ONE = 0xbf800000;
255 int FP32_ONE = 0x3f800000;
254256 }
255257 def CONST : Constants;
256258
24382438 (S_MOV_B32 -1), sub1)
24392439 >;
24402440
2441 def : Pat <
2442 (f32 (sint_to_fp i1:$src)),
2443 (V_CNDMASK_B32_e64 (i32 0), CONST.FP32_NEG_ONE, $src)
2444 >;
2445
2446 def : Pat <
2447 (f32 (uint_to_fp i1:$src)),
2448 (V_CNDMASK_B32_e64 (i32 0), CONST.FP32_ONE, $src)
2449 >;
2450
2451 def : Pat <
2452 (f64 (sint_to_fp i1:$src)),
2453 (V_CVT_F64_I32_e32 (V_CNDMASK_B32_e64 (i32 0), (i32 -1), $src))
2454 >;
2455
2456 def : Pat <
2457 (f64 (uint_to_fp i1:$src)),
2458 (V_CVT_F64_U32_e32 (V_CNDMASK_B32_e64 (i32 0), (i32 1), $src))
2459 >;
2460
24412461 //===----------------------------------------------------------------------===//
24422462 // Miscellaneous Patterns
24432463 //===----------------------------------------------------------------------===//
2828 store <4 x float> %result, <4 x float> addrspace(1)* %out
2929 ret void
3030 }
31
32 ; FUNC-LABEL: @sint_to_fp_i1_f32:
33 ; SI: V_CMP_EQ_I32_e64 [[CMP:s\[[0-9]+:[0-9]\]]],
34 ; SI-NEXT: V_CNDMASK_B32_e64 [[RESULT:v[0-9]+]], 0, -1.000000e+00, [[CMP]]
35 ; SI: BUFFER_STORE_DWORD [[RESULT]],
36 ; SI: S_ENDPGM
37 define void @sint_to_fp_i1_f32(float addrspace(1)* %out, i32 %in) {
38 %cmp = icmp eq i32 %in, 0
39 %fp = uitofp i1 %cmp to float
40 store float %fp, float addrspace(1)* %out, align 4
41 ret void
42 }
43
44 ; FUNC-LABEL: @sint_to_fp_i1_f32_load:
45 ; SI: V_CNDMASK_B32_e64 [[RESULT:v[0-9]+]], 0, -1.000000e+00
46 ; SI: BUFFER_STORE_DWORD [[RESULT]],
47 ; SI: S_ENDPGM
48 define void @sint_to_fp_i1_f32_load(float addrspace(1)* %out, i1 %in) {
49 %fp = sitofp i1 %in to float
50 store float %fp, float addrspace(1)* %out, align 4
51 ret void
52 }
None ; RUN: llc < %s -march=r600 -mcpu=SI -verify-machineinstrs | FileCheck %s --check-prefix=CHECK
0 ; RUN: llc -march=r600 -mcpu=SI -verify-machineinstrs < %s | FileCheck -check-prefix=SI %s
11
2 ; CHECK: @sint_to_fp64
3 ; CHECK: V_CVT_F64_I32_e32
2 ; SI: @sint_to_fp64
3 ; SI: V_CVT_F64_I32_e32
44 define void @sint_to_fp64(double addrspace(1)* %out, i32 %in) {
55 %result = sitofp i32 %in to double
66 store double %result, double addrspace(1)* %out
77 ret void
88 }
9
10 ; SI-LABEL: @sint_to_fp_i1_f64:
11 ; SI: V_CMP_EQ_I32_e64 [[CMP:s\[[0-9]+:[0-9]\]]],
12 ; SI-NEXT: V_CNDMASK_B32_e64 [[IRESULT:v[0-9]+]], 0, -1, [[CMP]]
13 ; SI-NEXT: V_CVT_F64_I32_e32 [[RESULT:v\[[0-9]+:[0-9]\]]], [[IRESULT]]
14 ; SI: BUFFER_STORE_DWORDX2 [[RESULT]],
15 ; SI: S_ENDPGM
16 define void @sint_to_fp_i1_f64(double addrspace(1)* %out, i32 %in) {
17 %cmp = icmp eq i32 %in, 0
18 %fp = sitofp i1 %cmp to double
19 store double %fp, double addrspace(1)* %out, align 4
20 ret void
21 }
22
23 ; SI-LABEL: @sint_to_fp_i1_f64_load:
24 ; SI: V_CNDMASK_B32_e64 [[IRESULT:v[0-9]]], 0, -1
25 ; SI-NEXT: V_CVT_F64_I32_e32 [[RESULT:v\[[0-9]+:[0-9]\]]], [[IRESULT]]
26 ; SI: BUFFER_STORE_DWORDX2 [[RESULT]]
27 ; SI: S_ENDPGM
28 define void @sint_to_fp_i1_f64_load(double addrspace(1)* %out, i1 %in) {
29 %fp = sitofp i1 %in to double
30 store double %fp, double addrspace(1)* %out, align 8
31 ret void
32 }
11
22 ; SI-LABEL: @uint_to_fp_f64_i32
33 ; SI: V_CVT_F64_U32_e32
4 ; SI: S_ENDPGM
45 define void @uint_to_fp_f64_i32(double addrspace(1)* %out, i32 %in) {
56 %cast = uitofp i32 %in to double
67 store double %cast, double addrspace(1)* %out, align 8
78 ret void
89 }
10
11 ; SI-LABEL: @uint_to_fp_i1_f64:
12 ; SI: V_CMP_EQ_I32_e64 [[CMP:s\[[0-9]+:[0-9]\]]],
13 ; SI-NEXT: V_CNDMASK_B32_e64 [[IRESULT:v[0-9]+]], 0, 1, [[CMP]]
14 ; SI-NEXT: V_CVT_F64_U32_e32 [[RESULT:v\[[0-9]+:[0-9]\]]], [[IRESULT]]
15 ; SI: BUFFER_STORE_DWORDX2 [[RESULT]],
16 ; SI: S_ENDPGM
17 define void @uint_to_fp_i1_f64(double addrspace(1)* %out, i32 %in) {
18 %cmp = icmp eq i32 %in, 0
19 %fp = uitofp i1 %cmp to double
20 store double %fp, double addrspace(1)* %out, align 4
21 ret void
22 }
23
24 ; SI-LABEL: @uint_to_fp_i1_f64_load:
25 ; SI: V_CNDMASK_B32_e64 [[IRESULT:v[0-9]]], 0, 1
26 ; SI-NEXT: V_CVT_F64_U32_e32 [[RESULT:v\[[0-9]+:[0-9]\]]], [[IRESULT]]
27 ; SI: BUFFER_STORE_DWORDX2 [[RESULT]]
28 ; SI: S_ENDPGM
29 define void @uint_to_fp_i1_f64_load(double addrspace(1)* %out, i1 %in) {
30 %fp = uitofp i1 %in to double
31 store double %fp, double addrspace(1)* %out, align 8
32 ret void
33 }
None ; RUN: llc < %s -march=r600 -mcpu=redwood | FileCheck %s --check-prefix=R600-CHECK
1 ; RUN: llc < %s -march=r600 -mcpu=SI -verify-machineinstrs | FileCheck %s --check-prefix=SI-CHECK
0 ; RUN: llc -march=r600 -mcpu=SI -verify-machineinstrs < %s | FileCheck -check-prefix=SI -check-prefix=FUNC %s
1 ; RUN: llc -march=r600 -mcpu=redwood < %s | FileCheck -check-prefix=R600 -check-prefix=FUNC %s
22
3 ; R600-CHECK-LABEL: @uint_to_fp_v2i32
4 ; R600-CHECK-DAG: UINT_TO_FLT * T{{[0-9]+\.[XYZW]}}, KC0[2].W
5 ; R600-CHECK-DAG: UINT_TO_FLT * T{{[0-9]+\.[XYZW]}}, KC0[3].X
6 ; SI-CHECK-LABEL: @uint_to_fp_v2i32
7 ; SI-CHECK: V_CVT_F32_U32_e32
8 ; SI-CHECK: V_CVT_F32_U32_e32
3 ; FUNC-LABEL: @uint_to_fp_v2i32
4 ; R600-DAG: UINT_TO_FLT * T{{[0-9]+\.[XYZW]}}, KC0[2].W
5 ; R600-DAG: UINT_TO_FLT * T{{[0-9]+\.[XYZW]}}, KC0[3].X
6
7 ; SI: V_CVT_F32_U32_e32
8 ; SI: V_CVT_F32_U32_e32
9 ; SI: S_ENDPGM
910 define void @uint_to_fp_v2i32(<2 x float> addrspace(1)* %out, <2 x i32> %in) {
1011 %result = uitofp <2 x i32> %in to <2 x float>
1112 store <2 x float> %result, <2 x float> addrspace(1)* %out
1213 ret void
1314 }
1415
15 ; R600-CHECK-LABEL: @uint_to_fp_v4i32
16 ; R600-CHECK: UINT_TO_FLT * T{{[0-9]+\.[XYZW], T[0-9]+\.[XYZW]}}
17 ; R600-CHECK: UINT_TO_FLT * T{{[0-9]+\.[XYZW], T[0-9]+\.[XYZW]}}
18 ; R600-CHECK: UINT_TO_FLT * T{{[0-9]+\.[XYZW], T[0-9]+\.[XYZW]}}
19 ; R600-CHECK: UINT_TO_FLT * T{{[0-9]+\.[XYZW], T[0-9]+\.[XYZW]}}
20 ; SI-CHECK-LABEL: @uint_to_fp_v4i32
21 ; SI-CHECK: V_CVT_F32_U32_e32
22 ; SI-CHECK: V_CVT_F32_U32_e32
23 ; SI-CHECK: V_CVT_F32_U32_e32
24 ; SI-CHECK: V_CVT_F32_U32_e32
16 ; FUNC-LABEL: @uint_to_fp_v4i32
17 ; R600: UINT_TO_FLT * T{{[0-9]+\.[XYZW], T[0-9]+\.[XYZW]}}
18 ; R600: UINT_TO_FLT * T{{[0-9]+\.[XYZW], T[0-9]+\.[XYZW]}}
19 ; R600: UINT_TO_FLT * T{{[0-9]+\.[XYZW], T[0-9]+\.[XYZW]}}
20 ; R600: UINT_TO_FLT * T{{[0-9]+\.[XYZW], T[0-9]+\.[XYZW]}}
21
22 ; SI: V_CVT_F32_U32_e32
23 ; SI: V_CVT_F32_U32_e32
24 ; SI: V_CVT_F32_U32_e32
25 ; SI: V_CVT_F32_U32_e32
26 ; SI: S_ENDPGM
2527 define void @uint_to_fp_v4i32(<4 x float> addrspace(1)* %out, <4 x i32> addrspace(1)* %in) {
2628 %value = load <4 x i32> addrspace(1) * %in
2729 %result = uitofp <4 x i32> %value to <4 x float>
2931 ret void
3032 }
3133
32 ; R600-CHECK-LABEL: @uint_to_fp_i64_f32
33 ; R600-CHECK: UINT_TO_FLT
34 ; R600-CHECK: UINT_TO_FLT
35 ; R600-CHECK: MULADD_IEEE
36 ; SI-CHECK-LABEL: @uint_to_fp_i64_f32
37 ; SI-CHECK: V_CVT_F32_U32_e32
38 ; SI-CHECK: V_CVT_F32_U32_e32
39 ; SI-CHECK: V_MAD_F32
34 ; FUNC-LABEL: @uint_to_fp_i64_f32
35 ; R600: UINT_TO_FLT
36 ; R600: UINT_TO_FLT
37 ; R600: MULADD_IEEE
38 ; SI: V_CVT_F32_U32_e32
39 ; SI: V_CVT_F32_U32_e32
40 ; SI: V_MAD_F32
41 ; SI: S_ENDPGM
4042 define void @uint_to_fp_i64_f32(float addrspace(1)* %out, i64 %in) {
4143 entry:
4244 %0 = uitofp i64 %in to float
4345 store float %0, float addrspace(1)* %out
4446 ret void
4547 }
48
49 ; FUNC-LABEL: @uint_to_fp_i1_f32:
50 ; SI: V_CMP_EQ_I32_e64 [[CMP:s\[[0-9]+:[0-9]\]]],
51 ; SI-NEXT: V_CNDMASK_B32_e64 [[RESULT:v[0-9]+]], 0, 1.000000e+00, [[CMP]]
52 ; SI: BUFFER_STORE_DWORD [[RESULT]],
53 ; SI: S_ENDPGM
54 define void @uint_to_fp_i1_f32(float addrspace(1)* %out, i32 %in) {
55 %cmp = icmp eq i32 %in, 0
56 %fp = uitofp i1 %cmp to float
57 store float %fp, float addrspace(1)* %out, align 4
58 ret void
59 }
60
61 ; FUNC-LABEL: @uint_to_fp_i1_f32_load:
62 ; SI: V_CNDMASK_B32_e64 [[RESULT:v[0-9]+]], 0, 1.000000e+00
63 ; SI: BUFFER_STORE_DWORD [[RESULT]],
64 ; SI: S_ENDPGM
65 define void @uint_to_fp_i1_f32_load(float addrspace(1)* %out, i1 %in) {
66 %fp = uitofp i1 %in to float
67 store float %fp, float addrspace(1)* %out, align 4
68 ret void
69 }