[llvm] [NVPTX] Attempt to load params using symbol addition node directly (PR #119935)

Kevin McAfee via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 8 11:10:57 PST 2025


================
@@ -0,0 +1,44 @@
+; RUN: llc < %s -march=nvptx64 --debug-counter=dagcombine=0 | FileCheck %s
+; RUN: %if ptxas %{ llc < %s -march=nvptx64 | %ptxas-verify %}
+
+%struct.8float = type <{ [8 x float] }>
+
+declare i32 @callee(%struct.8float %a)
+
+define i32 @test(%struct.8float alignstack(32) %data) {
+  ;CHECK-NOT: add.
+  ;CHECK-DAG: ld.param.u8 %r{{.*}}, [test_param_0];
+  ;CHECK-DAG: ld.param.u8 %r{{.*}}, [test_param_0+1];
----------------
kalxr wrote:

>If they are intended to modify compiler output it's fine, just don't use the assertion on/off as the control knob for that.

[They use assertion on/off as the control knob.](https://github.com/llvm/llvm-project/blob/f69585235ec85d54e0f3fc41b2d5700430907f99/llvm/include/llvm/Support/DebugCounter.h#L155)

>I can't tell if those debug counters are doing something wrong, and NVPTX was never intended to handle the IR modified that way, or if the debug counter-enabled mode does things correctly, and just happens to expose a corner case NVPTX does not handle correctly

Let's explore both possibilities. In this test case, we are using [`DAGCombineCounter`](https://github.com/llvm/llvm-project/blob/f69585235ec85d54e0f3fc41b2d5700430907f99/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp#L94) to control whether or not we try to [execute a DAG combine on a given node](https://github.com/llvm/llvm-project/blob/f69585235ec85d54e0f3fc41b2d5700430907f99/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp#L2019).

Assuming debug counters work as intended - since we set the counter to 0, no combines execute. Legalization happens as usual, but the final SelectionDAG is unoptimized. This is the extent of the debug counter's impact. ISEL takes this unoptimized SelectionDAG and the resulting machine code is illegal.
Should NVPTX be capable of handling a legalized SelectionDAG where none of its nodes went through combines? If so, we need a fix.

Assuming debug counters are broken - the only place `DAGCombineCounter` is used is where I linked, where it controls whether or not we attempt a combine on a node. If `DebugCounter::shouldExecute` returns an arbitrary value, the result is that we perform DAG combines on some arbitrary set of nodes during SelectionDAG optimization.
Should NVPTX be capable of handling a legalized SelectionDAG where an arbitrary set of nodes went through combines?  If so, we need a fix.

https://github.com/llvm/llvm-project/pull/119935


More information about the llvm-commits mailing list