-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[SPIR-V] Fix vloadn OpenCL builtin lowering #81148
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
michalpaszkowski
merged 3 commits into
llvm:main
from
michalpaszkowski:fix_vload_builtin
Feb 21, 2024
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
; RUN: llc -O0 -mtriple=spirv64-unknown-unknown %s -o - | FileCheck %s | ||
; This test only intends to check the vloadn builtin name resolution. | ||
; The calls to the OpenCL builtins are not valid and will not pass SPIR-V validation. | ||
|
||
; CHECK-DAG: %[[#IMPORT:]] = OpExtInstImport "OpenCL.std" | ||
|
||
; CHECK-DAG: %[[#INT8:]] = OpTypeInt 8 0 | ||
; CHECK-DAG: %[[#INT16:]] = OpTypeInt 16 0 | ||
; CHECK-DAG: %[[#INT32:]] = OpTypeInt 32 0 | ||
; CHECK-DAG: %[[#INT64:]] = OpTypeInt 64 0 | ||
; CHECK-DAG: %[[#FLOAT:]] = OpTypeFloat 32 | ||
; CHECK-DAG: %[[#VINT8:]] = OpTypeVector %[[#INT8]] 2 | ||
; CHECK-DAG: %[[#VINT16:]] = OpTypeVector %[[#INT16]] 2 | ||
; CHECK-DAG: %[[#VINT32:]] = OpTypeVector %[[#INT32]] 2 | ||
; CHECK-DAG: %[[#VINT64:]] = OpTypeVector %[[#INT64]] 2 | ||
; CHECK-DAG: %[[#VFLOAT:]] = OpTypeVector %[[#FLOAT]] 2 | ||
; CHECK-DAG: %[[#PTRINT8:]] = OpTypePointer CrossWorkgroup %[[#INT8]] | ||
|
||
; CHECK: %[[#OFFSET:]] = OpFunctionParameter %[[#INT64]] | ||
; CHECK: %[[#ADDRESS:]] = OpFunctionParameter %[[#PTRINT8]] | ||
|
||
define spir_kernel void @test_fn(i64 %offset, ptr addrspace(1) %address) { | ||
; CHECK: %[[#]] = OpExtInst %[[#VINT8]] %[[#IMPORT]] vloadn %[[#OFFSET]] %[[#ADDRESS]] 2 | ||
%call1 = call spir_func <2 x i8> @_Z6vload2mPU3AS1Kc(i64 %offset, ptr addrspace(1) %address) | ||
; CHECK: %[[#]] = OpExtInst %[[#VINT16]] %[[#IMPORT]] vloadn %[[#OFFSET]] %[[#ADDRESS]] 2 | ||
%call2 = call spir_func <2 x i16> @_Z6vload2mPU3AS1Ks(i64 %offset, ptr addrspace(1) %address) | ||
; CHECK: %[[#]] = OpExtInst %[[#VINT32]] %[[#IMPORT]] vloadn %[[#OFFSET]] %[[#ADDRESS]] 2 | ||
%call3 = call spir_func <2 x i32> @_Z6vload2mPU3AS1Ki(i64 %offset, ptr addrspace(1) %address) | ||
; CHECK: %[[#]] = OpExtInst %[[#VINT64]] %[[#IMPORT]] vloadn %[[#OFFSET]] %[[#ADDRESS]] 2 | ||
%call4 = call spir_func <2 x i64> @_Z6vload2mPU3AS1Kl(i64 %offset, ptr addrspace(1) %address) | ||
; CHECK: %[[#]] = OpExtInst %[[#VFLOAT]] %[[#IMPORT]] vloadn %[[#OFFSET]] %[[#ADDRESS]] 2 | ||
%call5 = call spir_func <2 x float> @_Z6vload2mPU3AS1Kf(i64 %offset, ptr addrspace(1) %address) | ||
ret void | ||
} | ||
|
||
declare spir_func <2 x i8> @_Z6vload2mPU3AS1Kc(i64, ptr addrspace(1)) | ||
declare spir_func <2 x i16> @_Z6vload2mPU3AS1Ks(i64, ptr addrspace(1)) | ||
declare spir_func <2 x i32> @_Z6vload2mPU3AS1Ki(i64, ptr addrspace(1)) | ||
declare spir_func <2 x i64> @_Z6vload2mPU3AS1Kl(i64, ptr addrspace(1)) | ||
declare spir_func <2 x float> @_Z6vload2mPU3AS1Kf(i64, ptr addrspace(1)) |
31 changes: 31 additions & 0 deletions
31
llvm/test/CodeGen/SPIRV/pointers/getelementptr-kernel-arg-char.ll
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
|
||
; RUN: llc -O0 -mtriple=spirv64-unknown-unknown %s -o - | FileCheck %s | ||
; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv64-unknown-unknown %s -o - -filetype=obj | spirv-val %} | ||
|
||
; CHECK-DAG: %[[#INT8:]] = OpTypeInt 8 0 | ||
; CHECK-DAG: %[[#INT64:]] = OpTypeInt 64 0 | ||
; CHECK-DAG: %[[#VINT8:]] = OpTypeVector %[[#INT8]] 2 | ||
; CHECK-DAG: %[[#PTRINT8:]] = OpTypePointer Workgroup %[[#INT8]] | ||
; CHECK-DAG: %[[#PTRVINT8:]] = OpTypePointer Workgroup %[[#VINT8]] | ||
; CHECK-DAG: %[[#CONST:]] = OpConstant %[[#INT64]] 1 | ||
|
||
; CHECK: %[[#PARAM1:]] = OpFunctionParameter %[[#PTRVINT8]] | ||
define spir_kernel void @test1(ptr addrspace(3) %address) !kernel_arg_type !1 { | ||
; CHECK: %[[#BITCAST1:]] = OpBitcast %[[#PTRINT8]] %[[#PARAM1]] | ||
; CHECK: %[[#]] = OpInBoundsPtrAccessChain %[[#PTRINT8]] %[[#BITCAST1]] %[[#CONST]] | ||
%cast = bitcast ptr addrspace(3) %address to ptr addrspace(3) | ||
%gep = getelementptr inbounds i8, ptr addrspace(3) %cast, i64 1 | ||
ret void | ||
} | ||
|
||
; CHECK: %[[#PARAM2:]] = OpFunctionParameter %[[#PTRVINT8]] | ||
define spir_kernel void @test2(ptr addrspace(3) %address) !kernel_arg_type !1 { | ||
; CHECK: %[[#BITCAST2:]] = OpBitcast %[[#PTRINT8]] %[[#PARAM2]] | ||
; CHECK: %[[#]] = OpInBoundsPtrAccessChain %[[#PTRINT8]] %[[#BITCAST2]] %[[#CONST]] | ||
%gep = getelementptr inbounds i8, ptr addrspace(3) %address, i64 1 | ||
ret void | ||
} | ||
|
||
declare spir_func <2 x i8> @_Z6vload2mPU3AS3Kc(i64, ptr addrspace(3)) | ||
|
||
!1 = !{!"char2*"} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: why not running spirv-val on this too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a comment below. It looks like the SPIR-V validator is doing additional checks on the arguments of those OpExtInst calls and those are not valid here. I want this test to only check the vloadn builtin name resolution to keep the tests as small as possible.