1 ; RUN: llc -verify-machineinstrs -O0 -mtriple=spirv64-unknown-unknown %s -o - | FileCheck %s
2 ; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv64-unknown-unknown %s -o - -filetype=obj | spirv-val %}
4 ; RUN: llc -verify-machineinstrs -O0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s
5 ; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv32-unknown-unknown %s -o - -filetype=obj | spirv-val %}
7 ; CHECK-DAG: OpName [[BOOL_ADD:%.+]] "bool_add"
8 ; CHECK-DAG: OpName [[BOOL_SUB:%.+]] "bool_sub"
9 ; CHECK-DAG: OpName [[SCALAR_ADD:%.+]] "scalar_add"
10 ; CHECK-DAG: OpName [[SCALAR_SUB:%.+]] "scalar_sub"
11 ; CHECK-DAG: OpName [[SCALAR_MUL:%.+]] "scalar_mul"
12 ; CHECK-DAG: OpName [[SCALAR_UDIV:%.+]] "scalar_udiv"
13 ; CHECK-DAG: OpName [[SCALAR_SDIV:%.+]] "scalar_sdiv"
14 ;; TODO: add tests for urem + srem
15 ;; TODO: add test for OpSNegate
17 ; CHECK-NOT: DAG-FENCE
19 ; CHECK-DAG: [[BOOL:%.+]] = OpTypeBool
20 ; CHECK-DAG: [[SCALAR:%.+]] = OpTypeInt 32
21 ; CHECK-DAG: [[SCALAR_FN:%.+]] = OpTypeFunction [[SCALAR]] [[SCALAR]] [[SCALAR]]
22 ; CHECK-DAG: [[BOOL_FN:%.+]] = OpTypeFunction [[BOOL]] [[BOOL]] [[BOOL]]
24 ; CHECK-NOT: DAG-FENCE
27 ;; Test add on scalar:
28 define i1 @bool_add(i1 %a, i1 %b) {
33 ; CHECK: [[BOOL_ADD]] = OpFunction [[BOOL]] None [[BOOL_FN]]
34 ; CHECK-NEXT: [[A:%.+]] = OpFunctionParameter [[BOOL]]
35 ; CHECK-NEXT: [[B:%.+]] = OpFunctionParameter [[BOOL]]
37 ; CHECK: [[C:%.+]] = OpLogicalNotEqual [[BOOL]] [[A]] [[B]]
38 ; CHECK: OpReturnValue [[C]]
39 ; CHECK-NEXT: OpFunctionEnd
41 define i32 @scalar_add(i32 %a, i32 %b) {
46 ; CHECK: [[SCALAR_ADD]] = OpFunction [[SCALAR]] None [[SCALAR_FN]]
47 ; CHECK-NEXT: [[A:%.+]] = OpFunctionParameter [[SCALAR]]
48 ; CHECK-NEXT: [[B:%.+]] = OpFunctionParameter [[SCALAR]]
50 ; CHECK: [[C:%.+]] = OpIAdd [[SCALAR]] [[A]] [[B]]
51 ; CHECK: OpReturnValue [[C]]
52 ; CHECK-NEXT: OpFunctionEnd
55 ;; Test sub on scalar:
56 define i1 @bool_sub(i1 %a, i1 %b) {
61 ; CHECK: [[BOOL_SUB]] = OpFunction [[BOOL]] None [[BOOL_FN]]
62 ; CHECK-NEXT: [[A:%.+]] = OpFunctionParameter [[BOOL]]
63 ; CHECK-NEXT: [[B:%.+]] = OpFunctionParameter [[BOOL]]
65 ; CHECK: [[C:%.+]] = OpLogicalNotEqual [[BOOL]] [[A]] [[B]]
66 ; CHECK: OpReturnValue [[C]]
67 ; CHECK-NEXT: OpFunctionEnd
69 define i32 @scalar_sub(i32 %a, i32 %b) {
74 ; CHECK: [[SCALAR_SUB]] = OpFunction [[SCALAR]] None [[SCALAR_FN]]
75 ; CHECK-NEXT: [[A:%.+]] = OpFunctionParameter [[SCALAR]]
76 ; CHECK-NEXT: [[B:%.+]] = OpFunctionParameter [[SCALAR]]
78 ; CHECK: [[C:%.+]] = OpISub [[SCALAR]] [[A]] [[B]]
79 ; CHECK: OpReturnValue [[C]]
80 ; CHECK-NEXT: OpFunctionEnd
83 ;; Test mul on scalar:
84 define i32 @scalar_mul(i32 %a, i32 %b) {
89 ; CHECK: [[SCALAR_MUL]] = OpFunction [[SCALAR]] None [[SCALAR_FN]]
90 ; CHECK-NEXT: [[A:%.+]] = OpFunctionParameter [[SCALAR]]
91 ; CHECK-NEXT: [[B:%.+]] = OpFunctionParameter [[SCALAR]]
93 ; CHECK: [[C:%.+]] = OpIMul [[SCALAR]] [[A]] [[B]]
94 ; CHECK: OpReturnValue [[C]]
95 ; CHECK-NEXT: OpFunctionEnd
98 ;; Test udiv on scalar:
99 define i32 @scalar_udiv(i32 %a, i32 %b) {
104 ; CHECK: [[SCALAR_UDIV]] = OpFunction [[SCALAR]] None [[SCALAR_FN]]
105 ; CHECK-NEXT: [[A:%.+]] = OpFunctionParameter [[SCALAR]]
106 ; CHECK-NEXT: [[B:%.+]] = OpFunctionParameter [[SCALAR]]
108 ; CHECK: [[C:%.+]] = OpUDiv [[SCALAR]] [[A]] [[B]]
109 ; CHECK: OpReturnValue [[C]]
110 ; CHECK-NEXT: OpFunctionEnd
113 ;; Test sdiv on scalar:
114 define i32 @scalar_sdiv(i32 %a, i32 %b) {
119 ; CHECK: [[SCALAR_SDIV]] = OpFunction [[SCALAR]] None [[SCALAR_FN]]
120 ; CHECK-NEXT: [[A:%.+]] = OpFunctionParameter [[SCALAR]]
121 ; CHECK-NEXT: [[B:%.+]] = OpFunctionParameter [[SCALAR]]
123 ; CHECK: [[C:%.+]] = OpSDiv [[SCALAR]] [[A]] [[B]]
124 ; CHECK: OpReturnValue [[C]]
125 ; CHECK-NEXT: OpFunctionEnd