1- // RUN: %clang_cc1 -triple spirv-unknown-vulkan-compute -finclude-default-header -fnative-half-type -emit-llvm -disable-llvm-passes %s -o - -DSPIRV | FileCheck %s
1+ // RUN: %clang_cc1 -triple spirv-unknown-vulkan-compute -finclude-default-header -fnative-half-type -emit-llvm -disable-llvm-passes %s -o - | FileCheck %s
22// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-compute -finclude-default-header -fnative-half-type -emit-llvm -disable-llvm-passes %s -o - | FileCheck %s
33
44// Test explicit matrix casts.
55// This is adapted to HLSL from CodeGen/matrix-cast.c.
66
77// CHECK-LABEL: define {{.*}}cast_int16_matrix_to_int
8- void cast_int16_matrix_to_int () {
9- int16_t4x4 c;
10- int4x4 i;
11-
8+ void cast_int16_matrix_to_int ( int16_t4x4 c, int4x4 i) {
129 // CHECK: [[C:%.*]] = load <16 x i16>, ptr {{.*}}, align 2
1310 // CHECK-NEXT: [[CONV:%.*]] = sext <16 x i16> [[C]] to <16 x i32>
1411 // CHECK-NEXT: store <16 x i32> [[CONV]], ptr {{.*}}, align 4
@@ -18,9 +15,7 @@ void cast_int16_matrix_to_int() {
1815}
1916
2017// CHECK-LABEL: define {{.*}}cast_int16_matrix_to_uint
21- void cast_int16_matrix_to_uint () {
22- int16_t4x4 c;
23- uint4x4 u;
18+ void cast_int16_matrix_to_uint ( int16_t4x4 c, uint4x4 u) {
2419 // CHECK: [[C:%.*]] = load <16 x i16>, ptr {{.*}}, align 2
2520 // CHECK-NEXT: [[CONV:%.*]] = sext <16 x i16> [[C]] to <16 x i32>
2621 // CHECK-NEXT: store <16 x i32> [[CONV]], ptr {{.*}}, align 4
@@ -30,9 +25,7 @@ void cast_int16_matrix_to_uint() {
3025}
3126
3227// CHECK-LABEL: define {{.*}}cast_uint64_matrix_to_int16
33- void cast_uint64_matrix_to_int16 () {
34- uint64_t4x4 u;
35- int16_t4x4 s;
28+ void cast_uint64_matrix_to_int16 ( uint64_t4x4 u, int16_t4x4 s) {
3629 // CHECK: [[U:%.*]] = load <16 x i64>, ptr {{.*}}, align 8
3730 // CHECK-NEXT: [[CONV:%.*]] = trunc <16 x i64> [[U]] to <16 x i16>
3831 // CHECK-NEXT: store <16 x i16> [[CONV]], ptr {{.*}}, align 2
@@ -42,9 +35,7 @@ void cast_uint64_matrix_to_int16() {
4235}
4336
4437// CHECK-LABEL: define {{.*}}cast_int_matrix_to_int16
45- void cast_int_matrix_to_int16 () {
46- int4x4 i;
47- int16_t4x4 s;
38+ void cast_int_matrix_to_int16 ( int4x4 i, int16_t4x4 s) {
4839 // CHECK: [[I:%.*]] = load <16 x i32>, ptr {{.*}}, align 4
4940 // CHECK-NEXT: [[CONV:%.*]] = trunc <16 x i32> [[I]] to <16 x i16>
5041 // CHECK-NEXT: store <16 x i16> [[CONV]], ptr {{.*}}, align 2
@@ -54,9 +45,7 @@ void cast_int_matrix_to_int16() {
5445}
5546
5647// CHECK-LABEL: define {{.*}}cast_int_matrix_to_float
57- void cast_int_matrix_to_float () {
58- int4x4 i;
59- float4x4 f;
48+ void cast_int_matrix_to_float ( int4x4 i, float4x4 f) {
6049 // CHECK: [[I:%.*]] = load <16 x i32>, ptr {{.*}}, align 4
6150 // CHECK-NEXT: [[CONV:%.*]] = sitofp <16 x i32> [[I]] to <16 x float>
6251 // CHECK-NEXT: store <16 x float> [[CONV]], ptr {{.*}}, align 4
@@ -66,9 +55,7 @@ void cast_int_matrix_to_float() {
6655}
6756
6857// CHECK-LABEL: define {{.*}}cast_uint_matrix_to_float
69- void cast_uint_matrix_to_float () {
70- uint16_t4x4 u;
71- float4x4 f;
58+ void cast_uint_matrix_to_float ( uint16_t4x4 u, float4x4 f) {
7259 // CHECK: [[U:%.*]] = load <16 x i16>, ptr {{.*}}, align 2
7360 // CHECK-NEXT: [[CONV:%.*]] = uitofp <16 x i16> [[U]] to <16 x float>
7461 // CHECK-NEXT: store <16 x float> [[CONV]], ptr {{.*}}, align 4
@@ -78,9 +65,7 @@ void cast_uint_matrix_to_float() {
7865}
7966
8067// CHECK-LABEL: define {{.*}}cast_double_matrix_to_int
81- void cast_double_matrix_to_int () {
82- double4x4 d;
83- int4x4 i;
68+ void cast_double_matrix_to_int ( double4x4 d, int4x4 i) {
8469 // CHECK: [[D:%.*]] = load <16 x double>, ptr {{.*}}, align 8
8570 // CHECK-NEXT: [[CONV:%.*]] = fptosi <16 x double> [[D]] to <16 x i32>
8671 // CHECK-NEXT: store <16 x i32> [[CONV]], ptr {{.*}}, align 4
@@ -90,9 +75,7 @@ void cast_double_matrix_to_int() {
9075}
9176
9277// CHECK-LABEL: define {{.*}}cast_float_matrix_to_uint16
93- void cast_float_matrix_to_uint16 () {
94- float4x4 f;
95- uint16_t4x4 i;
78+ void cast_float_matrix_to_uint16 ( float4x4 f, uint16_t4x4 i) {
9679 // CHECK: [[F:%.*]] = load <16 x float>, ptr {{.*}}, align 4
9780 // CHECK-NEXT: [[CONV:%.*]] = fptoui <16 x float> [[F]] to <16 x i16>
9881 // CHECK-NEXT: store <16 x i16> [[CONV]], ptr {{.*}}, align 2
@@ -102,9 +85,7 @@ void cast_float_matrix_to_uint16() {
10285}
10386
10487// CHECK-LABEL: define {{.*}}cast_double_matrix_to_float
105- void cast_double_matrix_to_float () {
106- double4x4 d;
107- float4x4 f;
88+ void cast_double_matrix_to_float ( double4x4 d, float4x4 f) {
10889 // CHECK: [[D:%.*]] = load <16 x double>, ptr {{.*}}, align 8
10990 // CHECK-NEXT: [[CONV:%.*]] = fptrunc <16 x double> [[D]] to <16 x float>
11091 // CHECK-NEXT: store <16 x float> [[CONV]], ptr {{.*}}, align 4
@@ -114,9 +95,7 @@ void cast_double_matrix_to_float() {
11495}
11596
11697// CHECK-LABEL: define {{.*}}cast_uint16_to_uint
117- void cast_uint16_to_uint () {
118- uint16_t4x4 s;
119- uint4x4 i;
98+ void cast_uint16_to_uint ( uint16_t4x4 s, uint4x4 i) {
12099 // CHECK: [[S:%.*]] = load <16 x i16>, ptr {{.*}}, align 2
121100 // CHECK-NEXT: [[CONV:%.*]] = zext <16 x i16> [[S]] to <16 x i32>
122101 // CHECK-NEXT: store <16 x i32> [[CONV]], ptr {{.*}}, align 4
@@ -126,9 +105,7 @@ void cast_uint16_to_uint() {
126105}
127106
128107// CHECK-LABEL: define {{.*}}cast_uint64_to_uint16
129- void cast_uint64_to_uint16 () {
130- uint64_t4x4 l;
131- uint16_t4x4 s;
108+ void cast_uint64_to_uint16 ( uint64_t4x4 l, uint16_t4x4 s) {
132109 // CHECK: [[L:%.*]] = load <16 x i64>, ptr {{.*}}, align 8
133110 // CHECK-NEXT: [[CONV:%.*]] = trunc <16 x i64> [[L]] to <16 x i16>
134111 // CHECK-NEXT: store <16 x i16> [[CONV]], ptr {{.*}}, align 2
@@ -138,9 +115,7 @@ void cast_uint64_to_uint16() {
138115}
139116
140117// CHECK-LABEL: define {{.*}}cast_uint16_to_int
141- void cast_uint16_to_int () {
142- uint16_t4x4 u;
143- int4x4 i;
118+ void cast_uint16_to_int ( uint16_t4x4 u, int4x4 i) {
144119 // CHECK: [[U:%.*]] = load <16 x i16>, ptr {{.*}}, align 2
145120 // CHECK-NEXT: [[CONV:%.*]] = zext <16 x i16> [[U]] to <16 x i32>
146121 // CHECK-NEXT: store <16 x i32> [[CONV]], ptr {{.*}}, align 4
@@ -150,9 +125,7 @@ void cast_uint16_to_int() {
150125}
151126
152127// CHECK-LABEL: define {{.*}}cast_int_to_uint64
153- void cast_int_to_uint64 () {
154- int4x4 i;
155- uint64_t4x4 u;
128+ void cast_int_to_uint64 ( int4x4 i, uint64_t4x4 u) {
156129 // CHECK: [[I:%.*]] = load <16 x i32>, ptr {{.*}}, align 4
157130 // CHECK-NEXT: [[CONV:%.*]] = sext <16 x i32> [[I]] to <16 x i64>
158131 // CHECK-NEXT: store <16 x i64> [[CONV]], ptr {{.*}}, align 8
0 commit comments