|
| 1 | +; Same as `half.ll`, but for `fneg`, `fabs`, `copysign` and `fma`. |
| 2 | +; Can be merged back into `half.ll` once BPF doesn't have a compiler error. |
| 3 | +; Once all targets are fixed, the `CHECK-*` prefixes should all be merged into a single `CHECK` prefix and the `BAD-*` prefixes should be removed. |
| 4 | + |
| 5 | +; RUN: %if aarch64-registered-target %{ llc %s -o - -mtriple=aarch64-apple-darwin | FileCheck %s --check-prefixes=ALL,CHECK-NEG-ABS,CHECK-COPYSIGN,CHECK-FMA %} |
| 6 | +; RUN: %if aarch64-registered-target %{ llc %s -o - -mtriple=aarch64-pc-windows-msvc | FileCheck %s --check-prefixes=ALL,CHECK-NEG-ABS,CHECK-COPYSIGN,CHECK-FMA %} |
| 7 | +; RUN: %if aarch64-registered-target %{ llc %s -o - -mtriple=aarch64-unknown-linux-gnu | FileCheck %s --check-prefixes=ALL,CHECK-NEG-ABS,CHECK-COPYSIGN,CHECK-FMA %} |
| 8 | +; RUN: %if aarch64-registered-target %{ llc %s -o - -mtriple=arm64ec-pc-windows-msvc | FileCheck %s --check-prefixes=ALL,CHECK-NEG-ABS,CHECK-COPYSIGN,CHECK-FMA %} |
| 9 | +; RUN: %if amdgpu-registered-target %{ llc %s -o - -mtriple=amdgcn-amd-amdhsa | FileCheck %s --check-prefixes=ALL,CHECK-NEG-ABS,CHECK-COPYSIGN,CHECK-FMA %} |
| 10 | +; RUN: %if arc-registered-target %{ llc %s -o - -mtriple=arc-elf | FileCheck %s --check-prefixes=ALL,BAD-NEG-ABS,BAD-COPYSIGN,BAD-FMA %} |
| 11 | +; RUN: %if arm-registered-target %{ llc %s -o - -mtriple=arm-unknown-linux-gnueabi | FileCheck %s --check-prefixes=ALL,BAD-NEG-ABS,CHECK-COPYSIGN,BAD-FMA %} |
| 12 | +; RUN: %if arm-registered-target %{ llc %s -o - -mtriple=thumbv7em-none-eabi | FileCheck %s --check-prefixes=ALL,BAD-NEG-ABS,CHECK-COPYSIGN,BAD-FMA %} |
| 13 | +; RUN: %if avr-registered-target %{ llc %s -o - -mtriple=avr-none | FileCheck %s --check-prefixes=ALL,BAD-NEG-ABS,CHECK-COPYSIGN,BAD-FMA %} |
| 14 | +; FIXME: BPF has a compiler error |
| 15 | +; RUN: %if csky-registered-target %{ llc %s -o - -mtriple=csky-unknown-linux-gnuabiv2 | FileCheck %s --check-prefixes=ALL,BAD-NEG-ABS,BAD-COPYSIGN,BAD-FMA %} |
| 16 | +; RUN: %if csky-registered-target %{ llc %s -o - -mtriple=csky-unknown-linux-gnuabiv2 -mcpu=ck860fv -mattr=+hard-float | FileCheck %s --check-prefixes=ALL,BAD-NEG-ABS,BAD-COPYSIGN,BAD-FMA %} |
| 17 | +; FIXME: directx has a compiler error |
| 18 | +; RUN: %if hexagon-registered-target %{ llc %s -o - -mtriple=hexagon-unknown-linux-musl | FileCheck %s --check-prefixes=ALL,BAD-NEG-ABS,CHECK-COPYSIGN,BAD-FMA %} |
| 19 | +; RUN: %if lanai-registered-target %{ llc %s -o - -mtriple=lanai-unknown-unknown | FileCheck %s --check-prefixes=ALL,BAD-NEG-ABS,BAD-COPYSIGN,BAD-FMA %} |
| 20 | +; RUN: %if loongarch-registered-target %{ llc %s -o - -mtriple=loongarch32-unknown-linux-gnu | FileCheck %s --check-prefixes=ALL,BAD-NEG-ABS,CHECK-COPYSIGN,BAD-FMA %} |
| 21 | +; RUN: %if loongarch-registered-target %{ llc %s -o - -mtriple=loongarch64-unknown-linux-gnu | FileCheck %s --check-prefixes=ALL,BAD-NEG-ABS,CHECK-COPYSIGN,BAD-FMA %} |
| 22 | +; RUN: %if loongarch-registered-target %{ llc %s -o - -mtriple=loongarch64-unknown-linux-gnu -mattr=+f | FileCheck %s --check-prefixes=ALL,BAD-NEG-ABS,CHECK-COPYSIGN,BAD-FMA %} |
| 23 | +; RUN: %if m68k-registered-target %{ llc %s -o - -mtriple=m68k-unknown-linux-gnu | FileCheck %s --check-prefixes=ALL,BAD-NEG-ABS,BAD-COPYSIGN,BAD-FMA %} |
| 24 | +; RUN: %if mips-registered-target %{ llc %s -o - -mtriple=mips-unknown-linux-gnu | FileCheck %s --check-prefixes=ALL,BAD-NEG-ABS,CHECK-COPYSIGN,BAD-FMA %} |
| 25 | +; RUN: %if mips-registered-target %{ llc %s -o - -mtriple=mips64-unknown-linux-gnuabi64 | FileCheck %s --check-prefixes=ALL,BAD-NEG-ABS,CHECK-COPYSIGN,BAD-FMA %} |
| 26 | +; RUN: %if mips-registered-target %{ llc %s -o - -mtriple=mips64el-unknown-linux-gnuabi64 | FileCheck %s --check-prefixes=ALL,BAD-NEG-ABS,CHECK-COPYSIGN,BAD-FMA %} |
| 27 | +; RUN: %if mips-registered-target %{ llc %s -o - -mtriple=mipsel-unknown-linux-gnu | FileCheck %s --check-prefixes=ALL,BAD-NEG-ABS,CHECK-COPYSIGN,BAD-FMA %} |
| 28 | +; RUN: %if msp430-registered-target %{ llc %s -o - -mtriple=msp430-none-elf | FileCheck %s --check-prefixes=ALL,BAD-NEG-ABS,BAD-COPYSIGN,BAD-FMA %} |
| 29 | +; RUN: %if nvptx-registered-target %{ llc %s -o - -mtriple=nvptx64-nvidia-cuda | FileCheck %s --check-prefixes=NOCRASH %} |
| 30 | +; RUN: %if powerpc-registered-target %{ llc %s -o - -mtriple=powerpc-unknown-linux-gnu | FileCheck %s --check-prefixes=ALL,BAD-NEG-ABS,BAD-COPYSIGN,BAD-FMA %} |
| 31 | +; RUN: %if powerpc-registered-target %{ llc %s -o - -mtriple=powerpc64-unknown-linux-gnu | FileCheck %s --check-prefixes=ALL,BAD-NEG-ABS,BAD-COPYSIGN,BAD-FMA %} |
| 32 | +; RUN: %if powerpc-registered-target %{ llc %s -o - -mtriple=powerpc64le-unknown-linux-gnu | FileCheck %s --check-prefixes=ALL,BAD-NEG-ABS,BAD-COPYSIGN,BAD-FMA %} |
| 33 | +; RUN: %if riscv-registered-target %{ llc %s -o - -mtriple=riscv32-unknown-linux-gnu | FileCheck %s --check-prefixes=ALL,BAD-NEG-ABS,CHECK-COPYSIGN,BAD-FMA %} |
| 34 | +; RUN: %if riscv-registered-target %{ llc %s -o - -mtriple=riscv64-unknown-linux-gnu | FileCheck %s --check-prefixes=ALL,BAD-NEG-ABS,CHECK-COPYSIGN,BAD-FMA %} |
| 35 | +; RUN: %if sparc-registered-target %{ llc %s -o - -mtriple=sparc-unknown-linux-gnu | FileCheck %s --check-prefixes=ALL,BAD-NEG-ABS,CHECK-COPYSIGN,BAD-FMA %} |
| 36 | +; RUN: %if sparc-registered-target %{ llc %s -o - -mtriple=sparc64-unknown-linux-gnu | FileCheck %s --check-prefixes=ALL,BAD-NEG-ABS,CHECK-COPYSIGN,BAD-FMA %} |
| 37 | +; RUN: %if spirv-registered-target %{ llc %s -o - -mtriple=spirv-unknown-unknown | FileCheck %s --check-prefixes=NOCRASH %} |
| 38 | +; RUN: %if systemz-registered-target %{ llc %s -o - -mtriple=s390x-unknown-linux-gnu | FileCheck %s --check-prefixes=ALL,CHECK-NEG-ABS,CHECK-COPYSIGN,BAD-FMA %} |
| 39 | +; RUN: %if ve-registered-target %{ llc %s -o - -mtriple=ve-unknown-unknown | FileCheck %s --check-prefixes=ALL,BAD-NEG-ABS,BAD-COPYSIGN,BAD-FMA %} |
| 40 | +; RUN: %if webassembly-registered-target %{ llc %s -o - -mtriple=wasm32-unknown-unknown | FileCheck %s --check-prefixes=ALL,BAD-NEG-ABS,BAD-COPYSIGN,BAD-FMA %} |
| 41 | +; RUN: %if x86-registered-target %{ llc %s -o - -mtriple=i686-unknown-linux-gnu | FileCheck %s --check-prefixes=ALL,CHECK-NEG-ABS,CHECK-COPYSIGN,BAD-FMA %} |
| 42 | +; RUN: %if x86-registered-target %{ llc %s -o - -mtriple=x86_64-pc-windows-msvc | FileCheck %s --check-prefixes=ALL,CHECK-NEG-ABS,CHECK-COPYSIGN,BAD-FMA %} |
| 43 | +; RUN: %if x86-registered-target %{ llc %s -o - -mtriple=x86_64-unknown-linux-gnu | FileCheck %s --check-prefixes=ALL,CHECK-NEG-ABS,CHECK-COPYSIGN,BAD-FMA %} |
| 44 | +; RUN: %if xcore-registered-target %{ llc %s -o - -mtriple=xcore-unknown-unknown | FileCheck %s --check-prefixes=ALL,BAD-NEG-ABS,BAD-COPYSIGN,BAD-FMA %} |
| 45 | +; RUN: %if xtensa-registered-target %{ llc %s -o - -mtriple=xtensa-none-elf | FileCheck %s --check-prefixes=ALL,BAD-NEG-ABS,BAD-COPYSIGN,CHECK-FMA %} |
| 46 | + |
| 47 | +; Note that arm64ec labels are quoted, hence the `{{"?}}:`. |
| 48 | + |
| 49 | +; Codegen tests don't work the same for graphics targets. Add a dummy directive |
| 50 | +; for filecheck, just make sure we don't crash. |
| 51 | +; NOCRASH: {{.*}} |
| 52 | + |
| 53 | +; fneg, fabs and copysign all need to not quieten signalling NaNs, so should not call any conversion functions which do. |
| 54 | +; These tests won't catch cases where the everything is done using native instructions instead of builtins. |
| 55 | +; See https://github.com/llvm/llvm-project/issues/104915 |
| 56 | + |
| 57 | +define void @test_fneg(ptr %p1, ptr %p2) #0 { |
| 58 | +; ALL-LABEL: test_fneg{{"?}}: |
| 59 | +; CHECK-NEG-ABS-NOT: __extend |
| 60 | +; CHECK-NEG-ABS-NOT: __trunc |
| 61 | +; CHECK-NEG-ABS-NOT: __gnu |
| 62 | +; CHECK-NEG-ABS-NOT: __aeabi |
| 63 | +; BAD-NEG-ABS: {{__extendhfsf2|__gnu_h2f_ieee|__aeabi_h2f}} |
| 64 | + %v = load half, ptr %p1 |
| 65 | + %res = fneg half %v |
| 66 | + store half %res, ptr %p2 |
| 67 | + ret void |
| 68 | +} |
| 69 | + |
| 70 | +define void @test_fabs(ptr %p1, ptr %p2) { |
| 71 | +; ALL-LABEL: test_fabs{{"?}}: |
| 72 | +; CHECK-NEG-ABS-NOT: __extend |
| 73 | +; CHECK-NEG-ABS-NOT: __trunc |
| 74 | +; CHECK-NEG-ABS-NOT: __gnu |
| 75 | +; CHECK-NEG-ABS-NOT: __aeabi |
| 76 | +; BAD-NEG-ABS: {{__extendhfsf2|__gnu_h2f_ieee|__aeabi_h2f}} |
| 77 | + %a = load half, ptr %p1 |
| 78 | + %r = call half @llvm.fabs.f16(half %a) |
| 79 | + store half %r, ptr %p2 |
| 80 | + ret void |
| 81 | +} |
| 82 | + |
| 83 | +define void @test_copysign(ptr %p1, ptr %p2, ptr %p3) { |
| 84 | +; ALL-LABEL: test_copysign{{"?}}: |
| 85 | +; CHECK-COPYSIGN-NOT: __extend |
| 86 | +; CHECK-COPYSIGN-NOT: __trunc |
| 87 | +; CHECK-COPYSIGN-NOT: __gnu |
| 88 | +; CHECK-COPYSIGN-NOT: __aeabi |
| 89 | +; BAD-COPYSIGN: {{__extendhfsf2|__gnu_h2f_ieee}} |
| 90 | + %a = load half, ptr %p1 |
| 91 | + %b = load half, ptr %p2 |
| 92 | + %r = call half @llvm.copysign.f16(half %a, half %b) |
| 93 | + store half %r, ptr %p3 |
| 94 | + ret void |
| 95 | +} |
| 96 | + |
| 97 | +; If promoting, fma must promote at least to f64 to avoid double rounding issues. |
| 98 | +; This checks for calls to f32 fmaf and truncating f32 to f16. |
| 99 | +; See https://github.com/llvm/llvm-project/issues/98389 |
| 100 | + |
| 101 | +define void @test_fma(ptr %p1, ptr %p2, ptr %p3, ptr %p4) { |
| 102 | +; ALL-LABEL: test_fma{{"?}}: |
| 103 | +; Allow fmaf16 |
| 104 | +; CHECK-FMA-NOT: fmaf{{\b}} |
| 105 | +; CHECK-FMA-NOT: __truncsfhf2 |
| 106 | +; CHECK-FMA-NOT: __gnu_f2h_ieee |
| 107 | +; CHECK-FMA-NOT: __aeabi_f2h |
| 108 | +; BAD-FMA: {{__truncsfhf2|__gnu_f2h_ieee|__aeabi_f2h|fmaf\b}} |
| 109 | + %a = load half, ptr %p1 |
| 110 | + %b = load half, ptr %p2 |
| 111 | + %c = load half, ptr %p3 |
| 112 | + %r = call half @llvm.fma.f16(half %a, half %b, half %c) |
| 113 | + store half %r, ptr %p4 |
| 114 | + ret void |
| 115 | +} |
0 commit comments