Skip to content

Commit 047dd60

Browse files
bashbaugbader
authored andcommitted
add the Vector16 capability for both vec8 and vec16 types (KhronosGroup#229)
* add the Vector16 capability for both vec8 and vec16 types * added test to verify Vector16 capability is added for vectors with eight elements
1 parent 2bb7e2e commit 047dd60

File tree

2 files changed

+48
-1
lines changed

2 files changed

+48
-1
lines changed

lib/SPIRV/libSPIRV/SPIRVType.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,9 @@ class SPIRVTypeVector:public SPIRVType {
281281
bool isValidIndex(SPIRVWord Index) const { return Index < CompCount;}
282282
SPIRVCapVec getRequiredCapability() const {
283283
SPIRVCapVec V(getComponentType()->getRequiredCapability());
284-
if (CompCount > 8)
284+
// Even though the capability name is "Vector16", it describes
285+
// usage of 8-component or 16-component vectors.
286+
if (CompCount >= 8)
285287
V.push_back(CapabilityVector16);
286288
return std::move(V);
287289
}

test/transcoding/vec8.ll

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
; This test verifies that the Vector16 capability is correctly added
2+
; if an OpenCL kernel uses a vector of eight elements.
3+
;
4+
;Source:
5+
;__kernel void test( int8 v ) {}
6+
7+
; RUN: llvm-as %s -o %t.bc
8+
; RUN: llvm-spirv %t.bc -o - -spirv-text | FileCheck %s --check-prefix=CHECK-SPIRV
9+
; RUN: llvm-spirv %t.bc -o %t.spv
10+
; RUN: llvm-spirv -r %t.spv -o %t.rev.bc
11+
; RUN: llvm-dis < %t.rev.bc | FileCheck %s --check-prefix=CHECK-LLVM
12+
13+
; CHECK-SPIRV: Capability Vector16
14+
15+
target datalayout = "e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-n8:16:32:64"
16+
target triple = "spir"
17+
18+
; Function Attrs: nounwind
19+
define spir_kernel void @test(<8 x i32> %v) #0 {
20+
; CHECK-LLVM: <8 x i32>
21+
%1 = alloca <8 x i32>, align 32
22+
store <8 x i32> %v, <8 x i32>* %1, align 32
23+
ret void
24+
}
25+
26+
attributes #0 = { nounwind "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-realign-stack" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
27+
28+
!opencl.kernels = !{!0}
29+
!opencl.enable.FP_CONTRACT = !{}
30+
!opencl.spir.version = !{!6}
31+
!opencl.ocl.version = !{!6}
32+
!opencl.used.extensions = !{!7}
33+
!opencl.used.optional.core.features = !{!7}
34+
!opencl.compiler.options = !{!7}
35+
!llvm.ident = !{!8}
36+
37+
!0 = !{void (<8 x i32>)* @test, !1, !2, !3, !4, !5}
38+
!1 = !{!"kernel_arg_addr_space", i32 0}
39+
!2 = !{!"kernel_arg_access_qual", !"none"}
40+
!3 = !{!"kernel_arg_type", !"int8"}
41+
!4 = !{!"kernel_arg_base_type", !"int8"}
42+
!5 = !{!"kernel_arg_type_qual", !""}
43+
!6 = !{i32 1, i32 2}
44+
!7 = !{}
45+
!8 = !{!"clang version 3.6.1 (https://github.com/KhronosGroup/SPIR 2b577882b436ba3133457f27e0aa999f2ac8b11c) (https://github.com/KhronosGroup/SPIRV-LLVM.git 44ec76519179879c7900a5da4e724c751ce516a9)"}

0 commit comments

Comments
 (0)