llvm.org GIT mirror llvm / 0afed03
CodeGen: soften f16 type by default instead of marking legal. Actual support for softening f16 operations is still limited, and can be added when it's needed. But Soften is much closer to being a useful thing to try than keeping it Legal when no registers can actually hold such values. Longer term, we probably want something between Soften and Promote semantics for most targets, it'll be more efficient to promote the 4 basic operations to f32 than libcall them. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@213372 91177308-0d34-0410-b5e6-96231b3b80d8 Tim Northover 5 years ago
7 changed file(s) with 147 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
16341634 LegalizeTypeAction LA = ValueTypeActions.getTypeAction(SVT);
16351635
16361636 assert(
1637 (LA == TypeLegal ||
1637 (LA == TypeLegal || LA == TypeSoftenFloat ||
16381638 ValueTypeActions.getTypeAction(NVT) != TypePromoteInteger)
16391639 && "Promote may not follow Expand or Promote");
16401640
11031103 }
11041104 }
11051105
1106 if (!isTypeLegal(MVT::f16)) {
1107 NumRegistersForVT[MVT::f16] = NumRegistersForVT[MVT::i16];
1108 RegisterTypeForVT[MVT::f16] = RegisterTypeForVT[MVT::i16];
1109 TransformToType[MVT::f16] = MVT::i16;
1110 ValueTypeActions.setTypeAction(MVT::f16, TypeSoftenFloat);
1111 }
1112
11061113 // Loop over all of the vector value types to see which need transformations.
11071114 for (unsigned i = MVT::FIRST_VECTOR_VALUETYPE;
11081115 i <= (unsigned)MVT::LAST_VECTOR_VALUETYPE; ++i) {
0 ; RUN: llc < %s -mtriple=arm64-apple-ios7.0 | FileCheck %s
1
2 define void @test_load_store(half* %in, half* %out) {
3 ; CHECK-LABEL: test_load_store:
4 ; CHECK: ldr [[TMP:h[0-9]+]], [x0]
5 ; CHECK: str [[TMP]], [x1]
6 %val = load half* %in
7 store half %val, half* %out
8 ret void
9 }
10
11 define i16 @test_bitcast_from_half(half* %addr) {
12 ; CHECK-LABEL: test_bitcast_from_half:
13 ; CHECK: ldrh w0, [x0]
14 %val = load half* %addr
15 %val_int = bitcast half %val to i16
16 ret i16 %val_int
17 }
18
19 define void @test_bitcast_to_half(half* %addr, i16 %in) {
20 ; CHECK-LABEL: test_bitcast_to_half:
21 ; CHECK: strh w1, [x0]
22 %val_fp = bitcast i16 %in to half
23 store half %val_fp, half* %addr
24 ret void
25 }
0 ; RUN: llc < %s -mtriple=thumbv7s-apple-ios7.0 | FileCheck %s
1
2 define void @test_load_store(half* %in, half* %out) {
3 ; CHECK-LABEL: test_load_store:
4 ; CHECK: ldrh [[TMP:r[0-9]+]], [r0]
5 ; CHECK: strh [[TMP]], [r1]
6 %val = load half* %in
7 store half %val, half* %out
8 ret void
9 }
10
11 define i16 @test_bitcast_from_half(half* %addr) {
12 ; CHECK-LABEL: test_bitcast_from_half:
13 ; CHECK: ldrh r0, [r0]
14 %val = load half* %addr
15 %val_int = bitcast half %val to i16
16 ret i16 %val_int
17 }
18
19 define void @test_bitcast_to_half(half* %addr, i16 %in) {
20 ; CHECK-LABEL: test_bitcast_to_half:
21 ; CHECK: strh r1, [r0]
22 %val_fp = bitcast i16 %in to half
23 store half %val_fp, half* %addr
24 ret void
25 }
0 ; RUN: llc < %s -march=nvptx | FileCheck %s
1
2 define void @test_load_store(half addrspace(1)* %in, half addrspace(1)* %out) {
3 ; CHECK-LABEL: @test_load_store
4 ; CHECK: ld.global.u16 [[TMP:%rs[0-9]+]], [{{%r[0-9]+}}]
5 ; CHECK: st.global.u16 [{{%r[0-9]+}}], [[TMP]]
6 %val = load half addrspace(1)* %in
7 store half %val, half addrspace(1) * %out
8 ret void
9 }
10
11 define void @test_bitcast_from_half(half addrspace(1)* %in, i16 addrspace(1)* %out) {
12 ; CHECK-LABEL: @test_bitcast_from_half
13 ; CHECK: ld.global.u16 [[TMP:%rs[0-9]+]], [{{%r[0-9]+}}]
14 ; CHECK: st.global.u16 [{{%r[0-9]+}}], [[TMP]]
15 %val = load half addrspace(1) * %in
16 %val_int = bitcast half %val to i16
17 store i16 %val_int, i16 addrspace(1)* %out
18 ret void
19 }
20
21 define void @test_bitcast_to_half(half addrspace(1)* %out, i16 addrspace(1)* %in) {
22 ; CHECK-LABEL: @test_bitcast_to_half
23 ; CHECK: ld.global.u16 [[TMP:%rs[0-9]+]], [{{%r[0-9]+}}]
24 ; CHECK: st.global.u16 [{{%r[0-9]+}}], [[TMP]]
25 %val = load i16 addrspace(1)* %in
26 %val_fp = bitcast i16 %val to half
27 store half %val_fp, half addrspace(1)* %out
28 ret void
29 }
0 ; RUN: llc < %s -march=r600 -mcpu=SI | FileCheck %s
1
2 define void @test_load_store(half addrspace(1)* %in, half addrspace(1)* %out) {
3 ; CHECK-LABEL: @test_load_store
4 ; CHECK: BUFFER_LOAD_USHORT [[TMP:v[0-9]+]]
5 ; CHECK: BUFFER_STORE_SHORT [[TMP]]
6 %val = load half addrspace(1)* %in
7 store half %val, half addrspace(1) * %out
8 ret void
9 }
10
11 define void @test_bitcast_from_half(half addrspace(1)* %in, i16 addrspace(1)* %out) {
12 ; CHECK-LABEL: @test_bitcast_from_half
13 ; CHECK: BUFFER_LOAD_USHORT [[TMP:v[0-9]+]]
14 ; CHECK: BUFFER_STORE_SHORT [[TMP]]
15 %val = load half addrspace(1) * %in
16 %val_int = bitcast half %val to i16
17 store i16 %val_int, i16 addrspace(1)* %out
18 ret void
19 }
20
21 define void @test_bitcast_to_half(half addrspace(1)* %out, i16 addrspace(1)* %in) {
22 ; CHECK-LABEL: @test_bitcast_to_half
23 ; CHECK: BUFFER_LOAD_USHORT [[TMP:v[0-9]+]]
24 ; CHECK: BUFFER_STORE_SHORT [[TMP]]
25 %val = load i16 addrspace(1)* %in
26 %val_fp = bitcast i16 %val to half
27 store half %val_fp, half addrspace(1)* %out
28 ret void
29 }
0 ; RUN: llc < %s -march=x86-64 -mtriple=x86_64-unknown-linux-gnu -mcpu=corei7 -mattr=-f16c | FileCheck %s -check-prefix=CHECK -check-prefix=CHECK-LIBCALL
1 ; RUN: llc < %s -march=x86-64 -mtriple=x86_64-unknown-linux-gnu -mcpu=corei7 -mattr=+f16c | FileCheck %s -check-prefix=CHECK -check-prefix=CHECK-F16C
2
3 define void @test_load_store(half* %in, half* %out) {
4 ; CHECK-LABEL: test_load_store:
5 ; CHECK: movw (%rdi), [[TMP:%[a-z0-9]+]]
6 ; CHECK: movw [[TMP]], (%rsi)
7 %val = load half* %in
8 store half %val, half* %out
9 ret void
10 }
11
12 define i16 @test_bitcast_from_half(half* %addr) {
13 ; CHECK-LABEL: test_bitcast_from_half:
14 ; CHECK: movzwl (%rdi), %eax
15 %val = load half* %addr
16 %val_int = bitcast half %val to i16
17 ret i16 %val_int
18 }
19
20 define void @test_bitcast_to_half(half* %addr, i16 %in) {
21 ; CHECK-LABEL: test_bitcast_to_half:
22 ; CHECK: movw %si, (%rdi)
23 %val_fp = bitcast i16 %in to half
24 store half %val_fp, half* %addr
25 ret void
26 }