1 ; RUN: llc -O0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s
3 ; CHECK-DAG: OpName [[VECTOR_ADD:%.+]] "vector_add"
4 ; CHECK-DAG: OpName [[VECTOR_SUB:%.+]] "vector_sub"
5 ; CHECK-DAG: OpName [[VECTOR_MUL:%.+]] "vector_mul"
6 ; CHECK-DAG: OpName [[VECTOR_UDIV:%.+]] "vector_udiv"
7 ; CHECK-DAG: OpName [[VECTOR_SDIV:%.+]] "vector_sdiv"
8 ;; TODO: add tests for urem + srem
9 ;; TODO: add test for OpSNegate
11 ; CHECK-NOT: DAG-FENCE
13 ; CHECK-DAG: [[I16:%.+]] = OpTypeInt 16
14 ; CHECK-DAG: [[VECTOR:%.+]] = OpTypeVector [[I16]]
15 ; CHECK-DAG: [[VECTOR_FN:%.+]] = OpTypeFunction [[VECTOR]] [[VECTOR]] [[VECTOR]]
17 ; CHECK-NOT: DAG-FENCE
20 ;; Test add on vector:
21 define <2 x i16> @vector_add(<2 x i16> %a, <2 x i16> %b) {
22 %c = add <2 x i16> %a, %b
26 ; CHECK: [[VECTOR_ADD]] = OpFunction [[VECTOR]] None [[VECTOR_FN]]
27 ; CHECK-NEXT: [[A:%.+]] = OpFunctionParameter [[VECTOR]]
28 ; CHECK-NEXT: [[B:%.+]] = OpFunctionParameter [[VECTOR]]
30 ; CHECK: [[C:%.+]] = OpIAdd [[VECTOR]] [[A]] [[B]]
31 ; CHECK: OpReturnValue [[C]]
32 ; CHECK-NEXT: OpFunctionEnd
35 ;; Test sub on vector:
36 define <2 x i16> @vector_sub(<2 x i16> %a, <2 x i16> %b) {
37 %c = sub <2 x i16> %a, %b
41 ; CHECK: [[VECTOR_SUB]] = OpFunction [[VECTOR]] None [[VECTOR_FN]]
42 ; CHECK-NEXT: [[A:%.+]] = OpFunctionParameter [[VECTOR]]
43 ; CHECK-NEXT: [[B:%.+]] = OpFunctionParameter [[VECTOR]]
45 ; CHECK: [[C:%.+]] = OpISub [[VECTOR]] [[A]] [[B]]
46 ; CHECK: OpReturnValue [[C]]
47 ; CHECK-NEXT: OpFunctionEnd
50 ;; Test mul on vector:
51 define <2 x i16> @vector_mul(<2 x i16> %a, <2 x i16> %b) {
52 %c = mul <2 x i16> %a, %b
56 ; CHECK: [[VECTOR_MUL]] = OpFunction [[VECTOR]] None [[VECTOR_FN]]
57 ; CHECK-NEXT: [[A:%.+]] = OpFunctionParameter [[VECTOR]]
58 ; CHECK-NEXT: [[B:%.+]] = OpFunctionParameter [[VECTOR]]
60 ; CHECK: [[C:%.+]] = OpIMul [[VECTOR]] [[A]] [[B]]
61 ; CHECK: OpReturnValue [[C]]
62 ; CHECK-NEXT: OpFunctionEnd
65 ;; Test udiv on vector:
66 define <2 x i16> @vector_udiv(<2 x i16> %a, <2 x i16> %b) {
67 %c = udiv <2 x i16> %a, %b
71 ; CHECK: [[VECTOR_UDIV]] = OpFunction [[VECTOR]] None [[VECTOR_FN]]
72 ; CHECK-NEXT: [[A:%.+]] = OpFunctionParameter [[VECTOR]]
73 ; CHECK-NEXT: [[B:%.+]] = OpFunctionParameter [[VECTOR]]
75 ; CHECK: [[C:%.+]] = OpUDiv [[VECTOR]] [[A]] [[B]]
76 ; CHECK: OpReturnValue [[C]]
77 ; CHECK-NEXT: OpFunctionEnd
80 ;; Test sdiv on vector:
81 define <2 x i16> @vector_sdiv(<2 x i16> %a, <2 x i16> %b) {
82 %c = sdiv <2 x i16> %a, %b
86 ; CHECK: [[VECTOR_SDIV]] = OpFunction [[VECTOR]] None [[VECTOR_FN]]
87 ; CHECK-NEXT: [[A:%.+]] = OpFunctionParameter [[VECTOR]]
88 ; CHECK-NEXT: [[B:%.+]] = OpFunctionParameter [[VECTOR]]
90 ; CHECK: [[C:%.+]] = OpSDiv [[VECTOR]] [[A]] [[B]]
91 ; CHECK: OpReturnValue [[C]]
92 ; CHECK-NEXT: OpFunctionEnd