From 43bb1c239c27de0ef9fdb8a43da1ef0bc16fc42a Mon Sep 17 00:00:00 2001 From: Matt Arsenault Date: Fri, 5 Jun 2020 13:57:29 -0400 Subject: [PATCH] AMDGPU: Fix incorrect selection of buffer atomic fadd There were additional standalone patterns for these nodes which were missing the subtarget predicate. --- llvm/lib/Target/AMDGPU/BUFInstructions.td | 2 ++ .../CodeGen/AMDGPU/fail-select-buffer-atomic-fadd.ll | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 llvm/test/CodeGen/AMDGPU/fail-select-buffer-atomic-fadd.ll diff --git a/llvm/lib/Target/AMDGPU/BUFInstructions.td b/llvm/lib/Target/AMDGPU/BUFInstructions.td index 7d6a6b9..2e5188b 100644 --- a/llvm/lib/Target/AMDGPU/BUFInstructions.td +++ b/llvm/lib/Target/AMDGPU/BUFInstructions.td @@ -1422,8 +1422,10 @@ multiclass BufferAtomicPatterns_NO_RTN; } +let SubtargetPredicate = HasAtomicFaddInsts in { defm : BufferAtomicPatterns_NO_RTN; defm : BufferAtomicPatterns_NO_RTN; +} def : GCNPat< (SIbuffer_atomic_cmpswap diff --git a/llvm/test/CodeGen/AMDGPU/fail-select-buffer-atomic-fadd.ll b/llvm/test/CodeGen/AMDGPU/fail-select-buffer-atomic-fadd.ll new file mode 100644 index 0000000..e52fcc7 --- /dev/null +++ b/llvm/test/CodeGen/AMDGPU/fail-select-buffer-atomic-fadd.ll @@ -0,0 +1,19 @@ +; RUN: not --crash llc -march=amdgcn -mcpu=tahiti -o /dev/null %s 2>&1 | FileCheck -check-prefix=FAIL %s +; RUN: not --crash llc -march=amdgcn -mcpu=hawaii -o /dev/null %s 2>&1 | FileCheck -check-prefix=FAIL %s +; RUN: not --crash llc -march=amdgcn -mcpu=fiji -o /dev/null %s 2>&1 | FileCheck -check-prefix=FAIL %s +; RUN: not --crash llc -march=amdgcn -mcpu=gfx900 -o /dev/null %s 2>&1 | FileCheck -check-prefix=FAIL %s +; RUN: not --crash llc -march=amdgcn -mcpu=gfx1010 -o /dev/null %s 2>&1 | FileCheck -check-prefix=FAIL %s + +; Make sure selection of these intrinsics fails on targets that do not +; have the instruction available. +; FIXME: Should also really make sure the v2f16 version fails. + +; FAIL: LLVM ERROR: Cannot select: {{.+}}: ch = BUFFER_ATOMIC_FADD +define amdgpu_cs void @atomic_fadd(<4 x i32> inreg %arg0) { + call void @llvm.amdgcn.buffer.atomic.fadd.f32(float 1.0, <4 x i32> %arg0, i32 0, i32 112, i1 false) + ret void +} + +declare void @llvm.amdgcn.buffer.atomic.fadd.f32(float, <4 x i32>, i32, i32, i1 immarg) #0 + +attributes #0 = { nounwind } -- 2.7.4