1 ; RUN: llc -O0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s
3 ; CHECK-DAG: OpName [[SCALAR_ADD:%.+]] "scalar_add"
4 ; CHECK-DAG: OpName [[SCALAR_SUB:%.+]] "scalar_sub"
5 ; CHECK-DAG: OpName [[SCALAR_MUL:%.+]] "scalar_mul"
6 ; CHECK-DAG: OpName [[SCALAR_UDIV:%.+]] "scalar_udiv"
7 ; CHECK-DAG: OpName [[SCALAR_SDIV:%.+]] "scalar_sdiv"
8 ;; TODO: add tests for urem + srem
9 ;; TODO: add test for OpSNegate
11 ; CHECK-NOT: DAG-FENCE
13 ; CHECK-DAG: [[SCALAR:%.+]] = OpTypeInt 32
14 ; CHECK-DAG: [[SCALAR_FN:%.+]] = OpTypeFunction [[SCALAR]] [[SCALAR]] [[SCALAR]]
16 ; CHECK-NOT: DAG-FENCE
19 ;; Test add on scalar:
20 define i32 @scalar_add(i32 %a, i32 %b) {
25 ; CHECK: [[SCALAR_ADD]] = OpFunction [[SCALAR]] None [[SCALAR_FN]]
26 ; CHECK-NEXT: [[A:%.+]] = OpFunctionParameter [[SCALAR]]
27 ; CHECK-NEXT: [[B:%.+]] = OpFunctionParameter [[SCALAR]]
29 ; CHECK: [[C:%.+]] = OpIAdd [[SCALAR]] [[A]] [[B]]
30 ; CHECK: OpReturnValue [[C]]
31 ; CHECK-NEXT: OpFunctionEnd
34 ;; Test sub on scalar:
35 define i32 @scalar_sub(i32 %a, i32 %b) {
40 ; CHECK: [[SCALAR_SUB]] = OpFunction [[SCALAR]] None [[SCALAR_FN]]
41 ; CHECK-NEXT: [[A:%.+]] = OpFunctionParameter [[SCALAR]]
42 ; CHECK-NEXT: [[B:%.+]] = OpFunctionParameter [[SCALAR]]
44 ; CHECK: [[C:%.+]] = OpISub [[SCALAR]] [[A]] [[B]]
45 ; CHECK: OpReturnValue [[C]]
46 ; CHECK-NEXT: OpFunctionEnd
49 ;; Test mul on scalar:
50 define i32 @scalar_mul(i32 %a, i32 %b) {
55 ; CHECK: [[SCALAR_MUL]] = OpFunction [[SCALAR]] None [[SCALAR_FN]]
56 ; CHECK-NEXT: [[A:%.+]] = OpFunctionParameter [[SCALAR]]
57 ; CHECK-NEXT: [[B:%.+]] = OpFunctionParameter [[SCALAR]]
59 ; CHECK: [[C:%.+]] = OpIMul [[SCALAR]] [[A]] [[B]]
60 ; CHECK: OpReturnValue [[C]]
61 ; CHECK-NEXT: OpFunctionEnd
64 ;; Test udiv on scalar:
65 define i32 @scalar_udiv(i32 %a, i32 %b) {
70 ; CHECK: [[SCALAR_UDIV]] = OpFunction [[SCALAR]] None [[SCALAR_FN]]
71 ; CHECK-NEXT: [[A:%.+]] = OpFunctionParameter [[SCALAR]]
72 ; CHECK-NEXT: [[B:%.+]] = OpFunctionParameter [[SCALAR]]
74 ; CHECK: [[C:%.+]] = OpUDiv [[SCALAR]] [[A]] [[B]]
75 ; CHECK: OpReturnValue [[C]]
76 ; CHECK-NEXT: OpFunctionEnd
79 ;; Test sdiv on scalar:
80 define i32 @scalar_sdiv(i32 %a, i32 %b) {
85 ; CHECK: [[SCALAR_SDIV]] = OpFunction [[SCALAR]] None [[SCALAR_FN]]
86 ; CHECK-NEXT: [[A:%.+]] = OpFunctionParameter [[SCALAR]]
87 ; CHECK-NEXT: [[B:%.+]] = OpFunctionParameter [[SCALAR]]
89 ; CHECK: [[C:%.+]] = OpSDiv [[SCALAR]] [[A]] [[B]]
90 ; CHECK: OpReturnValue [[C]]
91 ; CHECK-NEXT: OpFunctionEnd