llvm-project/llvm/test/CodeGen/SPIRV/pointers/store-to-array-first-element.ll
Nathan Gauër 0431b71680
[SPIR-V] Fix store to first element array (#175546)
The IR can store to the first element of an array the same way it stores
to the first element of a struct by specifying the base pointer. This
commit fixes the pointercast legalization pass to support this.
2026-01-14 17:43:06 +01:00

21 lines
825 B
LLVM

; RUN: llc -verify-machineinstrs -O0 -mtriple=spirv-pc-vulkan1.3-compute %s -o - | FileCheck %s
; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv-pc-vulkan1.3-compute %s -o - -filetype=obj | spirv-val %}
; CHECK-DAG: %[[#Int:]] = OpTypeInt 32 0
; CHECK-DAG: %[[#IntPtr:]] = OpTypePointer Function %[[#Int]]
; CHECK-DAG: %[[#Array:]] = OpTypeArray %[[#Int]] %[[#]]
; CHECK-DAG: %[[#ArrayPtr:]] = OpTypePointer Function %[[#Array]]
; CHECK-DAG: %[[#Const:]] = OpConstant %[[#Int]] 123
; CHECK-DAG: %[[#Zero:]] = OpConstant %[[#Int]] 0
; CHECK: %[[#Var:]] = OpVariable %[[#ArrayPtr]] Function
; CHECK: %[[#GEP:]] = OpInBoundsAccessChain %[[#IntPtr]] %[[#Var]] %[[#Zero]]
; CHECK: OpStore %[[#GEP]] %[[#Const]]
define spir_func void @test_array_store() {
entry:
%var = alloca [4 x i32]
store i32 123, ptr %var
ret void
}