From 0532e48bcd896a98e94a52c8d272394b998f67f6 Mon Sep 17 00:00:00 2001 From: David Green Date: Sun, 26 May 2019 11:34:30 +0000 Subject: [PATCH] [ARM] Select fp16 fma This adds a pattern for fma, similar to the float and double patterns. Differential Revision: https://reviews.llvm.org/D62330 llvm-svn: 361719 --- lib/Target/ARM/ARMInstrVFP.td | 3 +++ test/CodeGen/ARM/fp16-fullfp16.ll | 24 +++++++++++++++--------- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/lib/Target/ARM/ARMInstrVFP.td b/lib/Target/ARM/ARMInstrVFP.td index e3d2a947788..d1b32f531c0 100644 --- a/lib/Target/ARM/ARMInstrVFP.td +++ b/lib/Target/ARM/ARMInstrVFP.td @@ -2073,6 +2073,9 @@ def : Pat<(f64 (fma DPR:$Dn, DPR:$Dm, DPR:$Ddin)), def : Pat<(f32 (fma SPR:$Sn, SPR:$Sm, SPR:$Sdin)), (VFMAS SPR:$Sdin, SPR:$Sn, SPR:$Sm)>, Requires<[HasVFP4]>; +def : Pat<(f16 (fma HPR:$Sn, HPR:$Sm, HPR:$Sdin)), + (VFMAH HPR:$Sdin, HPR:$Sn, HPR:$Sm)>, + Requires<[HasFullFP16]>; def VFMSD : ADbI<0b11101, 0b10, 1, 0, (outs DPR:$Dd), (ins DPR:$Ddin, DPR:$Dn, DPR:$Dm), diff --git a/test/CodeGen/ARM/fp16-fullfp16.ll b/test/CodeGen/ARM/fp16-fullfp16.ll index 19afba05db6..a30b62acbac 100644 --- a/test/CodeGen/ARM/fp16-fullfp16.ll +++ b/test/CodeGen/ARM/fp16-fullfp16.ll @@ -386,15 +386,21 @@ define void @test_log2(half* %p) { ret void } -; FIXME -;define void @test_fma(half* %p, half* %q, half* %r) { -; %a = load half, half* %p, align 2 -; %b = load half, half* %q, align 2 -; %c = load half, half* %r, align 2 -; %v = call half @llvm.fma.f16(half %a, half %b, half %c) -; store half %v, half* %p -; ret void -;} +define void @test_fma(half* %p, half* %q, half* %r) { +; CHECK-LABEL: test_fma: +; CHECK: vldr.16 s0, [r1] +; CHECK-NEXT: vldr.16 s2, [r0] +; CHECK-NEXT: vldr.16 s4, [r2] +; CHECK-NEXT: vfma.f16 s4, s2, s0 +; CHECK-NEXT: vstr.16 s4, [r0] +; CHECK-NEXT: bx lr + %a = load half, half* %p, align 2 + %b = load half, half* %q, align 2 + %c = load half, half* %r, align 2 + %v = call half @llvm.fma.f16(half %a, half %b, half %c) + store half %v, half* %p + ret void +} define void @test_fabs(half* %p) { ; CHECK-LABEL: test_fabs: