[llvm] [SPIR-V] Coalesce chains of spv_gep into a single access chain (PR #194011)
Arseniy Obolenskiy via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 27 04:57:48 PDT 2026
================
@@ -0,0 +1,80 @@
+; RUN: llc -verify-machineinstrs -O0 -mtriple=spirv-pc-vulkan1.3-library %s -o - | FileCheck %s
+; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv-pc-vulkan1.3-library %s -o - -filetype=obj | spirv-val %}
+
+%struct.Inner = type { i32, <4 x float> }
+%struct.Outer = type { [5 x %struct.Inner], i32 }
+
+; CHECK-DAG: %[[#float:]] = OpTypeFloat 32
+; CHECK-DAG: %[[#vec4:]] = OpTypeVector %[[#float]] 4
+; CHECK-DAG: %[[#int:]] = OpTypeInt 32 0
+; CHECK-DAG: %[[#Inner:]] = OpTypeStruct %[[#int]] %[[#vec4]]
+; CHECK-DAG: %[[#idx_5:]] = OpConstant %[[#int]] 5
+; CHECK-DAG: %[[#Array:]] = OpTypeArray %[[#Inner]] %[[#idx_5]]
+; CHECK-DAG: %[[#Outer:]] = OpTypeStruct %[[#Array]] %[[#int]]
+; CHECK-DAG: %[[#ptr_Outer:]] = OpTypePointer Function %[[#Outer]]
+; CHECK-DAG: %[[#ptr_float:]] = OpTypePointer Function %[[#float]]
+; CHECK-DAG: %[[#int_0:]] = OpConstant %[[#int]] 0
+; CHECK-DAG: %[[#int_1:]] = OpConstant %[[#int]] 1
+; CHECK-DAG: %[[#int_2:]] = OpConstant %[[#int]] 2
+
+define spir_func float @two_deep(ptr %obj) convergent {
+entry:
+ %tok = call token @llvm.experimental.convergence.entry()
+ ; CHECK: %[[#obj2:]] = OpFunctionParameter %[[#ptr_Outer]]
+ ; CHECK: %[[#ptr2:]] = OpInBoundsAccessChain %[[#ptr_float]] %[[#obj2]] %[[#int_0]] %[[#int_2]] %[[#int_1]] %[[#int_1]]
+ ; CHECK-NOT: OpInBoundsAccessChain
+ ; CHECK: OpLoad %[[#float]] %[[#ptr2]]
+ %inner = getelementptr inbounds %struct.Outer, ptr %obj, i32 0, i32 0, i32 2
----------------
aobolensk wrote:
Ok, fair enough. Let's close it then. Thanks for the feedback!
https://github.com/llvm/llvm-project/pull/194011
More information about the llvm-commits
mailing list