[PATCH] D133984: [SDAG] Print divergence in SDNode::dump

Stanislav Mekhanoshin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 15 16:01:18 PDT 2022


rampitec created this revision.
rampitec added reviewers: arsenm, alex-t.
Herald added subscribers: kosarev, kerbowa, hiraditya, jvesely.
Herald added a project: All.
rampitec requested review of this revision.
Herald added a subscriber: wdng.
Herald added a project: LLVM.

If target does not support divergence the field is set to false
and not printed.


https://reviews.llvm.org/D133984

Files:
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp
  llvm/test/CodeGen/AMDGPU/sdag-print-divergence.ll


Index: llvm/test/CodeGen/AMDGPU/sdag-print-divergence.ll
===================================================================
--- /dev/null
+++ llvm/test/CodeGen/AMDGPU/sdag-print-divergence.ll
@@ -0,0 +1,23 @@
+; RUN: llc -march=amdgcn -mcpu=gfx900 -O0 -verify-machineinstrs < %s -debug-only=isel -o /dev/null |& FileCheck --check-prefix=GCN %s
+
+; REQUIRES: asserts
+
+; GCN-LABEL: === test_sdag_dump
+; GCN: Initial selection DAG: %bb.0 'test_sdag_dump:entry'
+; GCN: SelectionDAG has 10 nodes:
+; GCN:  t0: ch = EntryToken{{$}}
+; GCN:  t2: f32,ch = CopyFromReg t0, Register:f32 %0{{$}}
+; GCN:      t5: f32 = fadd t2, t2{{$}}
+; GCN:      t4: f32,ch = CopyFromReg t0, Register:f32 %1 :divergent{{$}}
+; GCN:    t6: f32 = fadd t5, t4 :divergent{{$}}
+; GCN:  t8: ch,glue = CopyToReg t0, Register:f32 $vgpr0, t6 :divergent{{$}}
+; GCN:  t9: ch = RETURN_TO_EPILOG t8, Register:f32 $vgpr0, t8:1 :divergent{{$}}
+
+define amdgpu_ps float @test_sdag_dump(float inreg %scalar, float %vector)  {
+entry:
+  %sadd = fadd float %scalar, %scalar
+  %ret = fadd float %sadd, %vector
+  ret float %ret
+}
+
+declare i32 @llvm.amdgcn.workitem.id.x()
Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp
===================================================================
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp
@@ -1063,6 +1063,9 @@
     if (i) OS << ", "; else OS << " ";
     printOperand(OS, G, getOperand(i));
   }
+  if (isDivergent()) {
+    OS << " :divergent";
+  }
   if (DebugLoc DL = getDebugLoc()) {
     OS << ", ";
     DL.print(OS);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D133984.460529.patch
Type: text/x-patch
Size: 1620 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220915/c015e263/attachment.bin>


More information about the llvm-commits mailing list