1 ; RUN: llc -verify-machineinstrs -O0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s
3 ; DISABLED-CHECK-DAG: OpName [[SCALAR_FNEG:%.+]] "scalar_fneg"
4 ; CHECK-DAG: OpName [[SCALAR_FADD:%.+]] "scalar_fadd"
5 ; CHECK-DAG: OpName [[SCALAR_FSUB:%.+]] "scalar_fsub"
6 ; CHECK-DAG: OpName [[SCALAR_FMUL:%.+]] "scalar_fmul"
7 ; CHECK-DAG: OpName [[SCALAR_FDIV:%.+]] "scalar_fdiv"
8 ; CHECK-DAG: OpName [[SCALAR_FREM:%.+]] "scalar_frem"
9 ; CHECK-DAG: OpName [[SCALAR_FMA:%.+]] "scalar_fma"
10 ;; FIXME: add test for OpFMod
12 ; CHECK-NOT: DAG-FENCE
14 ; CHECK-DAG: [[SCALAR:%.+]] = OpTypeFloat 32
15 ; CHECK-DAG: [[SCALAR_FN:%.+]] = OpTypeFunction [[SCALAR]] [[SCALAR]] [[SCALAR]]
17 ; CHECK-NOT: DAG-FENCE
20 ;; Test fneg on scalar:
21 ;; FIXME: Uncomment this test once we have rebased onto a more recent LLVM
22 ;; version -- IRTranslator::translateFNeg was fixed.
23 ;; define float @scalar_fneg(float %a, float %unused) {
28 ; DISABLED-CHECK: [[SCALAR_FNEG]] = OpFunction [[SCALAR]] None [[SCALAR_FN]]
29 ; DISABLED-CHECK-NEXT: [[A:%.+]] = OpFunctionParameter [[SCALAR]]
30 ; DISABLED-CHECK-NEXT: [[B:%.+]] = OpFunctionParameter [[SCALAR]]
31 ; DISABLED-CHECK: OpLabel
32 ; DISABLED-CHECK: [[C:%.+]] = OpFNegate [[SCALAR]] [[A]]
33 ; DISABLED-CHECK: OpReturnValue [[C]]
34 ; DISABLED-CHECK-NEXT: OpFunctionEnd
37 ;; Test fadd on scalar:
38 define float @scalar_fadd(float %a, float %b) {
39 %c = fadd float %a, %b
43 ; CHECK: [[SCALAR_FADD]] = OpFunction [[SCALAR]] None [[SCALAR_FN]]
44 ; CHECK-NEXT: [[A:%.+]] = OpFunctionParameter [[SCALAR]]
45 ; CHECK-NEXT: [[B:%.+]] = OpFunctionParameter [[SCALAR]]
47 ; CHECK: [[C:%.+]] = OpFAdd [[SCALAR]] [[A]] [[B]]
48 ; CHECK: OpReturnValue [[C]]
49 ; CHECK-NEXT: OpFunctionEnd
52 ;; Test fsub on scalar:
53 define float @scalar_fsub(float %a, float %b) {
54 %c = fsub float %a, %b
58 ; CHECK: [[SCALAR_FSUB]] = OpFunction [[SCALAR]] None [[SCALAR_FN]]
59 ; CHECK-NEXT: [[A:%.+]] = OpFunctionParameter [[SCALAR]]
60 ; CHECK-NEXT: [[B:%.+]] = OpFunctionParameter [[SCALAR]]
62 ; CHECK: [[C:%.+]] = OpFSub [[SCALAR]] [[A]] [[B]]
63 ; CHECK: OpReturnValue [[C]]
64 ; CHECK-NEXT: OpFunctionEnd
67 ;; Test fmul on scalar:
68 define float @scalar_fmul(float %a, float %b) {
69 %c = fmul float %a, %b
73 ; CHECK: [[SCALAR_FMUL]] = OpFunction [[SCALAR]] None [[SCALAR_FN]]
74 ; CHECK-NEXT: [[A:%.+]] = OpFunctionParameter [[SCALAR]]
75 ; CHECK-NEXT: [[B:%.+]] = OpFunctionParameter [[SCALAR]]
77 ; CHECK: [[C:%.+]] = OpFMul [[SCALAR]] [[A]] [[B]]
78 ; CHECK: OpReturnValue [[C]]
79 ; CHECK-NEXT: OpFunctionEnd
82 ;; Test fdiv on scalar:
83 define float @scalar_fdiv(float %a, float %b) {
84 %c = fdiv float %a, %b
88 ; CHECK: [[SCALAR_FDIV]] = OpFunction [[SCALAR]] None [[SCALAR_FN]]
89 ; CHECK-NEXT: [[A:%.+]] = OpFunctionParameter [[SCALAR]]
90 ; CHECK-NEXT: [[B:%.+]] = OpFunctionParameter [[SCALAR]]
92 ; CHECK: [[C:%.+]] = OpFDiv [[SCALAR]] [[A]] [[B]]
93 ; CHECK: OpReturnValue [[C]]
94 ; CHECK-NEXT: OpFunctionEnd
97 ;; Test frem on scalar:
98 define float @scalar_frem(float %a, float %b) {
99 %c = frem float %a, %b
103 ; CHECK: [[SCALAR_FREM]] = OpFunction [[SCALAR]] None [[SCALAR_FN]]
104 ; CHECK-NEXT: [[A:%.+]] = OpFunctionParameter [[SCALAR]]
105 ; CHECK-NEXT: [[B:%.+]] = OpFunctionParameter [[SCALAR]]
107 ; CHECK: [[C:%.+]] = OpFRem [[SCALAR]] [[A]] [[B]]
108 ; CHECK: OpReturnValue [[C]]
109 ; CHECK-NEXT: OpFunctionEnd
111 declare float @llvm.fma.f32(float, float, float)
113 ;; Test fma on scalar:
114 define float @scalar_fma(float %a, float %b, float %c) {
115 %r = call float @llvm.fma.f32(float %a, float %b, float %c)
119 ; CHECK: [[SCALAR_FMA]] = OpFunction
120 ; CHECK-NEXT: [[A:%.+]] = OpFunctionParameter [[SCALAR]]
121 ; CHECK-NEXT: [[B:%.+]] = OpFunctionParameter [[SCALAR]]
122 ; CHECK-NEXT: [[C:%.+]] = OpFunctionParameter [[SCALAR]]
124 ; CHECK: [[R:%.+]] = OpExtInst [[SCALAR]] {{%.+}} fma [[A]] [[B]] [[C]]
125 ; CHECK: OpReturnValue [[R]]
126 ; CHECK-NEXT: OpFunctionEnd