Debian Codegraph @

llvm/test/CodeGen/SPIRV/llvm-intrinsics/arithmetic-fence.ll

raw
1 ; RUN: llc -verify-machineinstrs -O0 -mtriple=spirv64-unknown-linux %s -o - | FileCheck %s --check-prefixes=CHECK-NOEXT
2 ; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv64-unknown-unknown %s -o - -filetype=obj | spirv-val %}
3
4 ; RUN: llc -verify-machineinstrs -O0 -mtriple=spirv64-unknown-linux %s -o - --spirv-ext=+SPV_EXT_arithmetic_fence | FileCheck %s --check-prefixes=CHECK-EXT
5 ; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv64-unknown-unknown %s -o - -filetype=obj | spirv-val %}
6
7 ; CHECK-NOEXT-NO: OpCapability ArithmeticFenceEXT
8 ; CHECK-NOEXT-NO: OpExtension "SPV_EXT_arithmetic_fence"
9 ; CHECK-NOEXT: OpFunction
10 ; CHECK-NOEXT: OpFMul
11 ; CHECK-NOEXT: OpFAdd
12 ; CHECK-NOEXT-NO: OpArithmeticFenceEXT
13 ; CHECK-NOEXT: OpFunction
14 ; CHECK-NOEXT-NO: OpArithmeticFenceEXT
15 ; CHECK-NOEXT: OpFunction
16 ; CHECK-NOEXT-NO: OpArithmeticFenceEXT
17
18 ; CHECK-EXT: OpCapability ArithmeticFenceEXT
19 ; CHECK-EXT: OpExtension "SPV_EXT_arithmetic_fence"
20 ; CHECK-EXT: OpFunction
21 ; CHECK-EXT: [[R1:%.*]] = OpFMul [[I32Ty:%.*]] %[[#]] %[[#]]
22 ; CHECK-EXT: [[R2:%.*]] = OpArithmeticFenceEXT [[I32Ty]] [[R1]]
23 ; CHECK-EXT: %[[#]] = OpFAdd [[I32Ty]] [[R2]] %[[#]]
24 ; CHECK-EXT: OpFunction
25 ; CHECK-EXT: [[R3:%.*]] = OpFAdd [[I64Ty:%.*]] [[A1:%.*]] [[A1]]
26 ; CHECK-EXT: [[R4:%.*]] = OpArithmeticFenceEXT [[I64Ty]] [[R3]]
27 ; CHECK-EXT: [[R5:%.*]] = OpFAdd [[I64Ty]] [[A1]] [[A1]]
28 ; CHECK-EXT: %[[#]] = OpFAdd [[I64Ty]] [[R4]] [[R5]]
29 ; CHECK-EXT: OpFunction
30 ; CHECK-EXT: [[R6:%.*]] = OpFAdd [[I32VecTy:%.*]] [[A2:%.*]] [[A2]]
31 ; CHECK-EXT: [[R7:%.*]] = OpArithmeticFenceEXT [[I32VecTy]] [[R6]]
32 ; CHECK-EXT: [[R8:%.*]] = OpFAdd [[I32VecTy]] [[A2]] [[A2]]
33 ; CHECK-EXT: %[[#]] = OpFAdd [[I32VecTy]] [[R7]] [[R8]]
34
35 define float @f1(float %a, float %b, float %c) {
36 %mul = fmul fast float %b, %a
37 %tmp = call float @llvm.arithmetic.fence.f32(float %mul)
38 %add = fadd fast float %tmp, %c
39 ret float %add
40 }
41
42 define double @f2(double %a) {
43 %1 = fadd fast double %a, %a
44 %t = call double @llvm.arithmetic.fence.f64(double %1)
45 %2 = fadd fast double %a, %a
46 %3 = fadd fast double %t, %2
47 ret double %3
48 }
49
50 define <2 x float> @f3(<2 x float> %a) {
51 %1 = fadd fast <2 x float> %a, %a
52 %t = call <2 x float> @llvm.arithmetic.fence.v2f32(<2 x float> %1)
53 %2 = fadd fast <2 x float> %a, %a
54 %3 = fadd fast <2 x float> %t, %2
55 ret <2 x float> %3
56 }
57
58 declare float @llvm.arithmetic.fence.f32(float)
59 declare double @llvm.arithmetic.fence.f64(double)
60 declare <2 x float> @llvm.arithmetic.fence.v2f32(<2 x float>)