Skip to content

Commit a1a8fc7

Browse files
committed
Add more generic half tests (NFC)
1 parent 816eb9e commit a1a8fc7

File tree

3 files changed

+142
-41
lines changed

3 files changed

+142
-41
lines changed

llvm/test/CodeGen/BPF/half.ll

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
2+
; This is the BPF counterpart to the generic `half.ll` test as BPF has compilation errors on some
3+
; operations.
4+
; RUN: llc %s -o - -mtriple=bpfel | FileCheck %s
5+
6+
define half @from_bits(i16 %bits) nounwind {
7+
; CHECK-LABEL: from_bits:
8+
; CHECK: # %bb.0:
9+
; CHECK-NEXT: w0 = w1
10+
; CHECK-NEXT: exit
11+
%f = bitcast i16 %bits to half
12+
ret half %f
13+
}
14+
15+
define i16 @to_bits(half %f) nounwind {
16+
; CHECK-LABEL: to_bits:
17+
; CHECK: # %bb.0:
18+
; CHECK-NEXT: w0 = w1
19+
; CHECK-NEXT: exit
20+
%bits = bitcast half %f to i16
21+
ret i16 %bits
22+
}
23+
24+
define half @check_freeze(half %f) nounwind {
25+
; CHECK-LABEL: check_freeze:
26+
; CHECK: # %bb.0:
27+
; CHECK-NEXT: w0 = w1
28+
; CHECK-NEXT: exit
29+
%t0 = freeze half %f
30+
ret half %t0
31+
}

llvm/test/CodeGen/DirectX/half.ll

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
; This is the DirectX counterpart to the generic `half.ll` test as DirectX has compilation errors
2+
; on some operations.
3+
; RUN: llc %s -o - -mtriple=dxil-pc-shadermodel6.3-library | FileCheck %s
4+
5+
define half @from_bits(i16 %bits) nounwind {
6+
; CHECK-LABEL: @from_bits
7+
; CHECK: %f = bitcast i16 %bits to half
8+
; CHECK-NEXT: ret half %f
9+
%f = bitcast i16 %bits to half
10+
ret half %f
11+
}
12+
13+
define i16 @to_bits(half %f) nounwind {
14+
; CHECK-LABEL: @to_bits
15+
; CHECK: %bits = bitcast half %f to i16
16+
; CHECK-NEXT: ret i16 %bits
17+
%bits = bitcast half %f to i16
18+
ret i16 %bits
19+
}
20+
21+
define half @check_freeze(half %f) nounwind {
22+
; CHECK-LABEL: @check_freeze
23+
; CHECK: ret half %f
24+
%t0 = freeze half %f
25+
ret half %t0
26+
}

llvm/test/CodeGen/Generic/half.ll

Lines changed: 85 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -4,47 +4,47 @@
44
; check that here. Additionally do a small handful of smoke tests that work
55
; well cross-platform.
66

7-
; RUN: %if aarch64-registered-target %{ llc %s -o - -mtriple=aarch64-apple-darwin | FileCheck %s --check-prefixes=ALL,CHECK %}
8-
; RUN: %if aarch64-registered-target %{ llc %s -o - -mtriple=aarch64-pc-windows-msvc | FileCheck %s --check-prefixes=ALL,CHECK %}
9-
; RUN: %if aarch64-registered-target %{ llc %s -o - -mtriple=aarch64-unknown-linux-gnu | FileCheck %s --check-prefixes=ALL,CHECK %}
10-
; RUN: %if aarch64-registered-target %{ llc %s -o - -mtriple=arm64ec-pc-windows-msvc | FileCheck %s --check-prefixes=ALL,CHECK %}
11-
; RUN: %if amdgpu-registered-target %{ llc %s -o - -mtriple=amdgcn-amd-amdhsa | FileCheck %s --check-prefixes=ALL,CHECK %}
12-
; RUN: %if arc-registered-target %{ llc %s -o - -mtriple=arc-elf | FileCheck %s --check-prefixes=ALL,CHECK %}
13-
; RUN: %if arm-registered-target %{ llc %s -o - -mtriple=arm-unknown-linux-gnueabi | FileCheck %s --check-prefixes=ALL,CHECK %}
14-
; RUN: %if arm-registered-target %{ llc %s -o - -mtriple=thumbv7em-none-eabi | FileCheck %s --check-prefixes=ALL,CHECK %}
15-
; RUN: %if avr-registered-target %{ llc %s -o - -mtriple=avr-none | FileCheck %s --check-prefixes=ALL,CHECK %}
16-
; RUN: %if bpf-registered-target %{ llc %s -o - -mtriple=bpfel | FileCheck %s --check-prefixes=ALL,CHECK %}
17-
; RUN: %if csky-registered-target %{ llc %s -o - -mtriple=csky-unknown-linux-gnuabiv2 | FileCheck %s --check-prefixes=ALL,CHECK %}
18-
; RUN: %if csky-registered-target %{ llc %s -o - -mtriple=csky-unknown-linux-gnuabiv2 -mcpu=ck860fv -mattr=+hard-float | FileCheck %s --check-prefixes=ALL,BAD %}
19-
; RUN: %if directx-registered-target %{ llc %s -o - -mtriple=dxil-pc-shadermodel6.3-library | FileCheck %s --check-prefixes=NOCRASH %}
20-
; RUN: %if hexagon-registered-target %{ llc %s -o - -mtriple=hexagon-unknown-linux-musl | FileCheck %s --check-prefixes=ALL,CHECK %}
21-
; RUN: %if lanai-registered-target %{ llc %s -o - -mtriple=lanai-unknown-unknown | FileCheck %s --check-prefixes=ALL,CHECK %}
22-
; RUN: %if loongarch-registered-target %{ llc %s -o - -mtriple=loongarch32-unknown-linux-gnu | FileCheck %s --check-prefixes=ALL,CHECK %}
23-
; RUN: %if loongarch-registered-target %{ llc %s -o - -mtriple=loongarch64-unknown-linux-gnu | FileCheck %s --check-prefixes=ALL,CHECK %}
24-
; RUN: %if loongarch-registered-target %{ llc %s -o - -mtriple=loongarch64-unknown-linux-gnu -mattr=+f | FileCheck %s --check-prefixes=ALL,CHECK %}
25-
; RUN: %if m68k-registered-target %{ llc %s -o - -mtriple=m68k-unknown-linux-gnu | FileCheck %s --check-prefixes=ALL,CHECK %}
26-
; RUN: %if mips-registered-target %{ llc %s -o - -mtriple=mips-unknown-linux-gnu | FileCheck %s --check-prefixes=ALL,CHECK %}
27-
; RUN: %if mips-registered-target %{ llc %s -o - -mtriple=mips64-unknown-linux-gnuabi64 | FileCheck %s --check-prefixes=ALL,CHECK %}
28-
; RUN: %if mips-registered-target %{ llc %s -o - -mtriple=mips64el-unknown-linux-gnuabi64 | FileCheck %s --check-prefixes=ALL,CHECK %}
29-
; RUN: %if mips-registered-target %{ llc %s -o - -mtriple=mipsel-unknown-linux-gnu | FileCheck %s --check-prefixes=ALL,CHECK %}
30-
; RUN: %if msp430-registered-target %{ llc %s -o - -mtriple=msp430-none-elf | FileCheck %s --check-prefixes=ALL,CHECK %}
31-
; RUN: %if nvptx-registered-target %{ llc %s -o - -mtriple=nvptx64-nvidia-cuda | FileCheck %s --check-prefixes=NOCRASH %}
32-
; RUN: %if powerpc-registered-target %{ llc %s -o - -mtriple=powerpc-unknown-linux-gnu | FileCheck %s --check-prefixes=ALL,BAD %}
33-
; RUN: %if powerpc-registered-target %{ llc %s -o - -mtriple=powerpc64-unknown-linux-gnu | FileCheck %s --check-prefixes=ALL,BAD %}
34-
; RUN: %if powerpc-registered-target %{ llc %s -o - -mtriple=powerpc64le-unknown-linux-gnu | FileCheck %s --check-prefixes=ALL,BAD %}
35-
; RUN: %if riscv-registered-target %{ llc %s -o - -mtriple=riscv32-unknown-linux-gnu | FileCheck %s --check-prefixes=ALL,CHECK %}
36-
; RUN: %if riscv-registered-target %{ llc %s -o - -mtriple=riscv64-unknown-linux-gnu | FileCheck %s --check-prefixes=ALL,CHECK %}
37-
; RUN: %if sparc-registered-target %{ llc %s -o - -mtriple=sparc-unknown-linux-gnu | FileCheck %s --check-prefixes=ALL,CHECK %}
38-
; RUN: %if sparc-registered-target %{ llc %s -o - -mtriple=sparc64-unknown-linux-gnu | FileCheck %s --check-prefixes=ALL,CHECK %}
39-
; RUN: %if spirv-registered-target %{ llc %s -o - -mtriple=spirv-unknown-unknown | FileCheck %s --check-prefixes=NOCRASH %}
40-
; RUN: %if systemz-registered-target %{ llc %s -o - -mtriple=s390x-unknown-linux-gnu | FileCheck %s --check-prefixes=ALL,CHECK %}
41-
; RUN: %if ve-registered-target %{ llc %s -o - -mtriple=ve-unknown-unknown | FileCheck %s --check-prefixes=ALL,BAD %}
42-
; RUN: %if webassembly-registered-target %{ llc %s -o - -mtriple=wasm32-unknown-unknown | FileCheck %s --check-prefixes=ALL,BAD %}
43-
; RUN: %if x86-registered-target %{ llc %s -o - -mtriple=i686-unknown-linux-gnu | FileCheck %s --check-prefixes=ALL,CHECK %}
44-
; RUN: %if x86-registered-target %{ llc %s -o - -mtriple=x86_64-pc-windows-msvc | FileCheck %s --check-prefixes=ALL,CHECK %}
45-
; RUN: %if x86-registered-target %{ llc %s -o - -mtriple=x86_64-unknown-linux-gnu | FileCheck %s --check-prefixes=ALL,CHECK %}
46-
; RUN: %if xcore-registered-target %{ llc %s -o - -mtriple=xcore-unknown-unknown | FileCheck %s --check-prefixes=ALL,CHECK %}
47-
; RUN: %if xtensa-registered-target %{ llc %s -o - -mtriple=xtensa-none-elf | FileCheck %s --check-prefixes=ALL,CHECK %}
7+
; RUN: %if aarch64-registered-target %{ llc %s -o - -mtriple=aarch64-apple-darwin | FileCheck %s --check-prefixes=ALL,CHECK,CHECK-NEG-ABS,CHECK-COPYSIGN %}
8+
; RUN: %if aarch64-registered-target %{ llc %s -o - -mtriple=aarch64-pc-windows-msvc | FileCheck %s --check-prefixes=ALL,CHECK,CHECK-NEG-ABS,CHECK-COPYSIGN %}
9+
; RUN: %if aarch64-registered-target %{ llc %s -o - -mtriple=aarch64-unknown-linux-gnu | FileCheck %s --check-prefixes=ALL,CHECK,CHECK-NEG-ABS,CHECK-COPYSIGN %}
10+
; RUN: %if aarch64-registered-target %{ llc %s -o - -mtriple=arm64ec-pc-windows-msvc | FileCheck %s --check-prefixes=ALL,CHECK,CHECK-NEG-ABS,CHECK-COPYSIGN %}
11+
; RUN: %if amdgpu-registered-target %{ llc %s -o - -mtriple=amdgcn-amd-amdhsa | FileCheck %s --check-prefixes=ALL,CHECK,CHECK-NEG-ABS,CHECK-COPYSIGN %}
12+
; RUN: %if arc-registered-target %{ llc %s -o - -mtriple=arc-elf | FileCheck %s --check-prefixes=ALL,CHECK,BAD-NEG-ABS,BAD-COPYSIGN %}
13+
; RUN: %if arm-registered-target %{ llc %s -o - -mtriple=arm-unknown-linux-gnueabi | FileCheck %s --check-prefixes=ALL,CHECK,BAD-NEG-ABS,CHECK-COPYSIGN %}
14+
; RUN: %if arm-registered-target %{ llc %s -o - -mtriple=thumbv7em-none-eabi | FileCheck %s --check-prefixes=ALL,CHECK,BAD-NEG-ABS,CHECK-COPYSIGN %}
15+
; RUN: %if avr-registered-target %{ llc %s -o - -mtriple=avr-none | FileCheck %s --check-prefixes=ALL,CHECK,BAD-NEG-ABS,CHECK-COPYSIGN %}
16+
; BPF errors on some operations, so has its own separate `half.ll` test.
17+
; RUN: %if csky-registered-target %{ llc %s -o - -mtriple=csky-unknown-linux-gnuabiv2 | FileCheck %s --check-prefixes=ALL,CHECK,BAD-NEG-ABS,BAD-COPYSIGN %}
18+
; RUN: %if csky-registered-target %{ llc %s -o - -mtriple=csky-unknown-linux-gnuabiv2 -mcpu=ck860fv -mattr=+hard-float | FileCheck %s --check-prefixes=ALL,BAD,BAD-NEG-ABS,BAD-COPYSIGN %}
19+
; DirectX errors on some operations, so has its own separate `half.ll` test.
20+
; RUN: %if hexagon-registered-target %{ llc %s -o - -mtriple=hexagon-unknown-linux-musl | FileCheck %s --check-prefixes=ALL,CHECK,BAD-NEG-ABS,CHECK-COPYSIGN %}
21+
; RUN: %if lanai-registered-target %{ llc %s -o - -mtriple=lanai-unknown-unknown | FileCheck %s --check-prefixes=ALL,CHECK,BAD-NEG-ABS,BAD-COPYSIGN %}
22+
; RUN: %if loongarch-registered-target %{ llc %s -o - -mtriple=loongarch32-unknown-linux-gnu | FileCheck %s --check-prefixes=ALL,CHECK,BAD-NEG-ABS,CHECK-COPYSIGN %}
23+
; RUN: %if loongarch-registered-target %{ llc %s -o - -mtriple=loongarch64-unknown-linux-gnu | FileCheck %s --check-prefixes=ALL,CHECK,BAD-NEG-ABS,CHECK-COPYSIGN %}
24+
; RUN: %if loongarch-registered-target %{ llc %s -o - -mtriple=loongarch64-unknown-linux-gnu -mattr=+f | FileCheck %s --check-prefixes=ALL,CHECK,BAD-NEG-ABS,CHECK-COPYSIGN %}
25+
; RUN: %if m68k-registered-target %{ llc %s -o - -mtriple=m68k-unknown-linux-gnu | FileCheck %s --check-prefixes=ALL,CHECK,BAD-NEG-ABS,BAD-COPYSIGN %}
26+
; RUN: %if mips-registered-target %{ llc %s -o - -mtriple=mips-unknown-linux-gnu | FileCheck %s --check-prefixes=ALL,CHECK,BAD-NEG-ABS,CHECK-COPYSIGN %}
27+
; RUN: %if mips-registered-target %{ llc %s -o - -mtriple=mips64-unknown-linux-gnuabi64 | FileCheck %s --check-prefixes=ALL,CHECK,BAD-NEG-ABS,CHECK-COPYSIGN %}
28+
; RUN: %if mips-registered-target %{ llc %s -o - -mtriple=mips64el-unknown-linux-gnuabi64 | FileCheck %s --check-prefixes=ALL,CHECK,BAD-NEG-ABS,CHECK-COPYSIGN %}
29+
; RUN: %if mips-registered-target %{ llc %s -o - -mtriple=mipsel-unknown-linux-gnu | FileCheck %s --check-prefixes=ALL,CHECK,BAD-NEG-ABS,CHECK-COPYSIGN %}
30+
; RUN: %if msp430-registered-target %{ llc %s -o - -mtriple=msp430-none-elf | FileCheck %s --check-prefixes=ALL,CHECK,BAD-NEG-ABS,BAD-COPYSIGN %}
31+
; RUN: %if nvptx-registered-target %{ llc %s -o - -mtriple=nvptx64-nvidia-cuda | FileCheck %s --check-prefixes=NOCRASH %}
32+
; RUN: %if powerpc-registered-target %{ llc %s -o - -mtriple=powerpc-unknown-linux-gnu | FileCheck %s --check-prefixes=ALL,BAD,BAD-NEG-ABS,BAD-COPYSIGN %}
33+
; RUN: %if powerpc-registered-target %{ llc %s -o - -mtriple=powerpc64-unknown-linux-gnu | FileCheck %s --check-prefixes=ALL,BAD,BAD-NEG-ABS,BAD-COPYSIGN %}
34+
; RUN: %if powerpc-registered-target %{ llc %s -o - -mtriple=powerpc64le-unknown-linux-gnu | FileCheck %s --check-prefixes=ALL,BAD,BAD-NEG-ABS,BAD-COPYSIGN %}
35+
; RUN: %if riscv-registered-target %{ llc %s -o - -mtriple=riscv32-unknown-linux-gnu | FileCheck %s --check-prefixes=ALL,CHECK,BAD-NEG-ABS,CHECK-COPYSIGN %}
36+
; RUN: %if riscv-registered-target %{ llc %s -o - -mtriple=riscv64-unknown-linux-gnu | FileCheck %s --check-prefixes=ALL,CHECK,BAD-NEG-ABS,CHECK-COPYSIGN %}
37+
; RUN: %if sparc-registered-target %{ llc %s -o - -mtriple=sparc-unknown-linux-gnu | FileCheck %s --check-prefixes=ALL,CHECK,BAD-NEG-ABS,CHECK-COPYSIGN %}
38+
; RUN: %if sparc-registered-target %{ llc %s -o - -mtriple=sparc64-unknown-linux-gnu | FileCheck %s --check-prefixes=ALL,CHECK,BAD-NEG-ABS,CHECK-COPYSIGN %}
39+
; RUN: %if spirv-registered-target %{ llc %s -o - -mtriple=spirv-unknown-unknown | FileCheck %s --check-prefixes=NOCRASH %}
40+
; RUN: %if systemz-registered-target %{ llc %s -o - -mtriple=s390x-unknown-linux-gnu | FileCheck %s --check-prefixes=ALL,CHECK,CHECK-NEG-ABS,CHECK-COPYSIGN %}
41+
; RUN: %if ve-registered-target %{ llc %s -o - -mtriple=ve-unknown-unknown | FileCheck %s --check-prefixes=ALL,BAD,BAD-NEG-ABS,BAD-COPYSIGN %}
42+
; RUN: %if webassembly-registered-target %{ llc %s -o - -mtriple=wasm32-unknown-unknown | FileCheck %s --check-prefixes=ALL,BAD,BAD-NEG-ABS,BAD-COPYSIGN %}
43+
; RUN: %if x86-registered-target %{ llc %s -o - -mtriple=i686-unknown-linux-gnu | FileCheck %s --check-prefixes=ALL,CHECK,CHECK-NEG-ABS,CHECK-COPYSIGN %}
44+
; RUN: %if x86-registered-target %{ llc %s -o - -mtriple=x86_64-pc-windows-msvc | FileCheck %s --check-prefixes=ALL,CHECK,CHECK-NEG-ABS,CHECK-COPYSIGN %}
45+
; RUN: %if x86-registered-target %{ llc %s -o - -mtriple=x86_64-unknown-linux-gnu | FileCheck %s --check-prefixes=ALL,CHECK,CHECK-NEG-ABS,CHECK-COPYSIGN %}
46+
; RUN: %if xcore-registered-target %{ llc %s -o - -mtriple=xcore-unknown-unknown | FileCheck %s --check-prefixes=ALL,CHECK,BAD-NEG-ABS,BAD-COPYSIGN %}
47+
; RUN: %if xtensa-registered-target %{ llc %s -o - -mtriple=xtensa-none-elf | FileCheck %s --check-prefixes=ALL,CHECK,BAD-NEG-ABS,CHECK-COPYSIGN %}
4848

4949
; Note that arm64ec labels are quoted, hence the `{{"?}}:`.
5050

@@ -86,3 +86,47 @@ define half @check_freeze(half %f) nounwind {
8686
%t0 = freeze half %f
8787
ret half %t0
8888
}
89+
90+
; fneg, fabs and copysign all need to not quieten signalling NaNs, so should not call any conversion functions which do.
91+
; These tests won't catch cases where the everything is done using native instructions instead of builtins.
92+
; See https://github.com/llvm/llvm-project/issues/104915
93+
94+
define void @test_fneg(ptr %p1, ptr %p2) #0 {
95+
; ALL-LABEL: test_fneg{{"?}}:
96+
; CHECK-NEG-ABS-NOT: __extend
97+
; CHECK-NEG-ABS-NOT: __trunc
98+
; CHECK-NEG-ABS-NOT: __gnu
99+
; CHECK-NEG-ABS-NOT: __aeabi
100+
; BAD-NEG-ABS: {{__extendhfsf2|__gnu_h2f_ieee|__aeabi_h2f}}
101+
%v = load half, ptr %p1
102+
%res = fneg half %v
103+
store half %res, ptr %p2
104+
ret void
105+
}
106+
107+
define void @test_fabs(ptr %p1, ptr %p2) {
108+
; ALL-LABEL: test_fabs{{"?}}:
109+
; CHECK-NEG-ABS-NOT: __extend
110+
; CHECK-NEG-ABS-NOT: __trunc
111+
; CHECK-NEG-ABS-NOT: __gnu
112+
; CHECK-NEG-ABS-NOT: __aeabi
113+
; BAD-NEG-ABS: {{__extendhfsf2|__gnu_h2f_ieee|__aeabi_h2f}}
114+
%a = load half, ptr %p1
115+
%r = call half @llvm.fabs.f16(half %a)
116+
store half %r, ptr %p2
117+
ret void
118+
}
119+
120+
define void @test_copysign(ptr %p1, ptr %p2, ptr %p3) {
121+
; ALL-LABEL: test_copysign{{"?}}:
122+
; CHECK-COPYSIGN-NOT: __extend
123+
; CHECK-COPYSIGN-NOT: __trunc
124+
; CHECK-COPYSIGN-NOT: __gnu
125+
; CHECK-COPYSIGN-NOT: __aeabi
126+
; BAD-COPYSIGN: {{__extendhfsf2|__gnu_h2f_ieee}}
127+
%a = load half, ptr %p1
128+
%b = load half, ptr %p2
129+
%r = call half @llvm.copysign.f16(half %a, half %b)
130+
store half %r, ptr %p3
131+
ret void
132+
}

0 commit comments

Comments
 (0)