[PATCH] D19043: AMDGPU/SI: Fix regression with no-return atomics

Nicolai Hähnle via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 12 17:48:37 PDT 2016


nhaehnle created this revision.
nhaehnle added reviewers: arsenm, tstellarAMD.
nhaehnle added a subscriber: llvm-commits.
Herald added a subscriber: arsenm.

In the added test-case, the atomic instruction feeds into a non-machine
CopyToReg node which hasn't been selected yet, so guard against
non-machine opcodes here.

http://reviews.llvm.org/D19043

Files:
  lib/Target/AMDGPU/SIISelLowering.cpp
  test/CodeGen/AMDGPU/llvm.amdgcn.buffer.atomic.ll

Index: test/CodeGen/AMDGPU/llvm.amdgcn.buffer.atomic.ll
===================================================================
--- test/CodeGen/AMDGPU/llvm.amdgcn.buffer.atomic.ll
+++ test/CodeGen/AMDGPU/llvm.amdgcn.buffer.atomic.ll
@@ -100,6 +100,15 @@
   ret float %out
 }
 
+;CHECK-LABEL: {{^}}test4:
+;CHECK: buffer_atomic_add v0,
+define amdgpu_ps float @test4() {
+main_body:
+  %v = call i32 @llvm.amdgcn.buffer.atomic.add(i32 1, <4 x i32> undef, i32 0, i32 4, i1 false)
+  %v.float = bitcast i32 %v to float
+  ret float %v.float
+}
+
 declare i32 @llvm.amdgcn.buffer.atomic.swap(i32, <4 x i32>, i32, i32, i1) #0
 declare i32 @llvm.amdgcn.buffer.atomic.add(i32, <4 x i32>, i32, i32, i1) #0
 declare i32 @llvm.amdgcn.buffer.atomic.sub(i32, <4 x i32>, i32, i32, i1) #0
Index: lib/Target/AMDGPU/SIISelLowering.cpp
===================================================================
--- lib/Target/AMDGPU/SIISelLowering.cpp
+++ lib/Target/AMDGPU/SIISelLowering.cpp
@@ -2974,6 +2974,7 @@
     // special case to check if the atomic has only one extract_subreg use,
     // which itself has no uses.
     if ((Node->hasNUsesOfValue(1, 0) &&
+         Node->use_begin()->isMachineOpcode() &&
          Node->use_begin()->getMachineOpcode() == AMDGPU::EXTRACT_SUBREG &&
          !Node->use_begin()->hasAnyUseOfValue(0))) {
       unsigned Def = MI->getOperand(0).getReg();


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D19043.53503.patch
Type: text/x-patch
Size: 1371 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160413/4a50561f/attachment.bin>


More information about the llvm-commits mailing list