xref: /aosp_15_r20/external/llvm/test/CodeGen/X86/fast-isel-float-half-convertion.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: llc -fast-isel -fast-isel-abort=1 -asm-verbose=false -mtriple=x86_64-unknown-unknown -mattr=+f16c < %s | FileCheck %s
2*9880d681SAndroid Build Coastguard Worker
3*9880d681SAndroid Build Coastguard Worker; Verify that fast-isel correctly expands float-half conversions.
4*9880d681SAndroid Build Coastguard Worker
5*9880d681SAndroid Build Coastguard Workerdefine i16 @test_fp32_to_fp16(float %a) {
6*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: test_fp32_to_fp16:
7*9880d681SAndroid Build Coastguard Worker; CHECK: vcvtps2ph $4, %xmm0, %xmm0
8*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: vmovd %xmm0, %eax
9*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: retq
10*9880d681SAndroid Build Coastguard Workerentry:
11*9880d681SAndroid Build Coastguard Worker  %0 = call i16 @llvm.convert.to.fp16.f32(float %a)
12*9880d681SAndroid Build Coastguard Worker  ret i16 %0
13*9880d681SAndroid Build Coastguard Worker}
14*9880d681SAndroid Build Coastguard Worker
15*9880d681SAndroid Build Coastguard Workerdefine float @test_fp16_to_fp32(i32 %a) {
16*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: test_fp16_to_fp32:
17*9880d681SAndroid Build Coastguard Worker; CHECK: movswl %di, %eax
18*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: vmovd %eax, %xmm0
19*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: vcvtph2ps %xmm0, %xmm0
20*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: retq
21*9880d681SAndroid Build Coastguard Workerentry:
22*9880d681SAndroid Build Coastguard Worker  %0 = trunc i32 %a to i16
23*9880d681SAndroid Build Coastguard Worker  %1 = call float @llvm.convert.from.fp16.f32(i16 %0)
24*9880d681SAndroid Build Coastguard Worker  ret float %1
25*9880d681SAndroid Build Coastguard Worker}
26*9880d681SAndroid Build Coastguard Worker
27*9880d681SAndroid Build Coastguard Workerdeclare i16 @llvm.convert.to.fp16.f32(float)
28*9880d681SAndroid Build Coastguard Workerdeclare float @llvm.convert.from.fp16.f32(i16)
29