Break circular dependency between FIR dialect and utilities
[llvm-project.git] / flang / test / Lower / real-operations-1.f90
blob67cb04237968efc18e890bdc5f3dc467d132b6f9
1 ! RUN: bbc %s -o - | FileCheck %s
3 ! Test real add on real kinds.
5 ! CHECK-LABEL: real2
6 REAL(2) FUNCTION real2(x0, x1)
7 REAL(2) :: x0
8 REAL(2) :: x1
9 ! CHECK-DAG: %[[v1:.+]] = fir.load %arg0 : !fir.ref<f16>
10 ! CHECK-DAG: %[[v2:.+]] = fir.load %arg1 : !fir.ref<f16>
11 ! CHECK: %[[v3:.+]] = arith.addf %[[v1]], %[[v2]] {{.*}}: f16
12 real2 = x0 + x1
13 ! CHECK: return %{{.*}} : f16
14 END FUNCTION real2
16 ! CHECK-LABEL: real3
17 REAL(3) FUNCTION real3(x0, x1)
18 REAL(3) :: x0
19 REAL(3) :: x1
20 ! CHECK-DAG: %[[v1:.+]] = fir.load %arg0 : !fir.ref<bf16>
21 ! CHECK-DAG: %[[v2:.+]] = fir.load %arg1 : !fir.ref<bf16>
22 ! CHECK: %[[v3:.+]] = arith.addf %[[v1]], %[[v2]] {{.*}}: bf16
23 real3 = x0 + x1
24 ! CHECK: return %{{.*}} : bf16
25 END FUNCTION real3
27 ! CHECK-LABEL: real4
28 REAL(4) FUNCTION real4(x0, x1)
29 REAL(4) :: x0
30 REAL(4) :: x1
31 ! CHECK-DAG: %[[v1:.+]] = fir.load %arg0 : !fir.ref<f32>
32 ! CHECK-DAG: %[[v2:.+]] = fir.load %arg1 : !fir.ref<f32>
33 ! CHECK: %[[v3:.+]] = arith.addf %[[v1]], %[[v2]] {{.*}}: f32
34 real4 = x0 + x1
35 ! CHECK: return %{{.*}} : f32
36 END FUNCTION real4
38 ! CHECK-LABEL: defreal
39 REAL FUNCTION defreal(x0, x1)
40 REAL :: x0
41 REAL :: x1
42 ! CHECK-DAG: %[[v1:.+]] = fir.load %arg0 : !fir.ref<f32>
43 ! CHECK-DAG: %[[v2:.+]] = fir.load %arg1 : !fir.ref<f32>
44 ! CHECK: %[[v3:.+]] = arith.addf %[[v1]], %[[v2]] {{.*}}: f32
45 defreal = x0 + x1
46 ! CHECK: return %{{.*}} : f32
47 END FUNCTION defreal
49 ! CHECK-LABEL: real8
50 REAL(8) FUNCTION real8(x0, x1)
51 REAL(8) :: x0
52 REAL(8) :: x1
53 ! CHECK-DAG: %[[v1:.+]] = fir.load %arg0 : !fir.ref<f64>
54 ! CHECK-DAG: %[[v2:.+]] = fir.load %arg1 : !fir.ref<f64>
55 ! CHECK: %[[v3:.+]] = arith.addf %[[v1]], %[[v2]] {{.*}}: f64
56 real8 = x0 + x1
57 ! CHECK: return %{{.*}} : f64
58 END FUNCTION real8
60 ! CHECK-LABEL: doubleprec
61 DOUBLE PRECISION FUNCTION doubleprec(x0, x1)
62 DOUBLE PRECISION :: x0
63 DOUBLE PRECISION :: x1
64 ! CHECK-DAG: %[[v1:.+]] = fir.load %arg0 : !fir.ref<f64>
65 ! CHECK-DAG: %[[v2:.+]] = fir.load %arg1 : !fir.ref<f64>
66 ! CHECK: %[[v3:.+]] = arith.addf %[[v1]], %[[v2]] {{.*}}: f64
67 doubleprec = x0 + x1
68 ! CHECK: return %{{.*}} : f64
69 END FUNCTION doubleprec
71 ! CHECK-LABEL: real10
72 REAL(10) FUNCTION real10(x0, x1)
73 REAL(10) :: x0
74 REAL(10) :: x1
75 ! CHECK-DAG: %[[v1:.+]] = fir.load %arg0 : !fir.ref<f80>
76 ! CHECK-DAG: %[[v2:.+]] = fir.load %arg1 : !fir.ref<f80>
77 ! CHECK: %[[v3:.+]] = arith.addf %[[v1]], %[[v2]] {{.*}}: f80
78 real10 = x0 + x1
79 ! CHECK: return %{{.*}} : f80
80 END FUNCTION real10
82 ! CHECK-LABEL: real16
83 REAL(16) FUNCTION real16(x0, x1)
84 REAL(16) :: x0
85 REAL(16) :: x1
86 ! CHECK-DAG: %[[v1:.+]] = fir.load %arg0 : !fir.ref<f128>
87 ! CHECK-DAG: %[[v2:.+]] = fir.load %arg1 : !fir.ref<f128>
88 ! CHECK: %[[v3:.+]] = arith.addf %[[v1]], %[[v2]] {{.*}}: f128
89 real16 = x0 + x1
90 ! CHECK: return %{{.*}} : f128
91 END FUNCTION real16
93 ! CHECK-LABEL: real16b
94 REAL(16) FUNCTION real16b(x0, x1)
95 REAL(16) :: x0
96 REAL(16) :: x1
97 ! CHECK-DAG: %[[v0:.+]] = arith.constant 4.0{{.*}} : f128
98 ! CHECK-DAG: %[[v1:.+]] = fir.load %arg0 : !fir.ref<f128>
99 ! CHECK-DAG: %[[v2:.+]] = fir.load %arg1 : !fir.ref<f128>
100 ! CHECK: %[[v3:.+]] = arith.addf %[[v1]], %[[v2]] {{.*}}: f128
101 ! CHECK: %[[v4:.+]] = arith.subf %[[v3]], %[[v0]] {{.*}}: f128
102 real16b = x0 + x1 - 4.0_16
103 ! CHECK: return %{{.*}} : f128
104 END FUNCTION real16b