Skip to content

Commit 6714da0

Browse files
banach-spacejeanPerierschweitzpgiclementvalmleair
committed
[flang][lowering] Add support for lowering the dot_product intrinsic
This patch adds support for lowering the `dot_product` intrinsic from Fortran to the FIR dialect of MLIR. This is part of the upstreaming effort from the `fir-dev` branch in [1]. [1] https://github.com/flang-compiler/f18-llvm-project Differential Revision: https://reviews.llvm.org/D121684 Co-authored-by: Jean Perier <[email protected]> Co-authored-by: Eric Schweitz <[email protected]> Co-authored-by: Valentin Clement <[email protected]> Co-authored-by: Mark Leair <[email protected]>
1 parent 3a42296 commit 6714da0

File tree

2 files changed

+288
-0
lines changed

2 files changed

+288
-0
lines changed

flang/lib/Lower/IntrinsicCall.cpp

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,33 @@ genProdOrSum(FN func, FD funcDim, mlir::Type resultType,
197197
args[1], mask, rank);
198198
}
199199

200+
/// Process calls to DotProduct
201+
template <typename FN>
202+
static fir::ExtendedValue
203+
genDotProd(FN func, mlir::Type resultType, fir::FirOpBuilder &builder,
204+
mlir::Location loc, Fortran::lower::StatementContext *stmtCtx,
205+
llvm::ArrayRef<fir::ExtendedValue> args) {
206+
207+
assert(args.size() == 2);
208+
209+
// Handle required vector arguments
210+
mlir::Value vectorA = fir::getBase(args[0]);
211+
mlir::Value vectorB = fir::getBase(args[1]);
212+
213+
mlir::Type eleTy = fir::dyn_cast_ptrOrBoxEleTy(vectorA.getType())
214+
.cast<fir::SequenceType>()
215+
.getEleTy();
216+
if (fir::isa_complex(eleTy)) {
217+
mlir::Value result = builder.createTemporary(loc, eleTy);
218+
func(builder, loc, vectorA, vectorB, result);
219+
return builder.create<fir::LoadOp>(loc, result);
220+
}
221+
222+
auto resultBox = builder.create<fir::AbsentOp>(
223+
loc, fir::BoxType::get(builder.getI1Type()));
224+
return func(builder, loc, vectorA, vectorB, resultBox);
225+
}
226+
200227
// TODO error handling -> return a code or directly emit messages ?
201228
struct IntrinsicLibrary {
202229

@@ -240,6 +267,8 @@ struct IntrinsicLibrary {
240267
fir::ExtendedValue genAssociated(mlir::Type,
241268
llvm::ArrayRef<fir::ExtendedValue>);
242269
fir::ExtendedValue genChar(mlir::Type, llvm::ArrayRef<fir::ExtendedValue>);
270+
fir::ExtendedValue genDotProduct(mlir::Type,
271+
llvm::ArrayRef<fir::ExtendedValue>);
243272
template <Extremum, ExtremumBehavior>
244273
mlir::Value genExtremum(mlir::Type, llvm::ArrayRef<mlir::Value>);
245274
/// Lowering for the IAND intrinsic. The IAND intrinsic expects two arguments
@@ -351,6 +380,10 @@ static constexpr IntrinsicHandler handlers[]{
351380
{{{"pointer", asInquired}, {"target", asInquired}}},
352381
/*isElemental=*/false},
353382
{"char", &I::genChar},
383+
{"dot_product",
384+
&I::genDotProduct,
385+
{{{"vector_a", asBox}, {"vector_b", asBox}}},
386+
/*isElemental=*/false},
354387
{"iand", &I::genIand},
355388
{"min", &I::genExtremum<Extremum::Min, ExtremumBehavior::MinMaxss>},
356389
{"sum",
@@ -1226,6 +1259,14 @@ IntrinsicLibrary::genChar(mlir::Type type,
12261259
return fir::CharBoxValue{cast, len};
12271260
}
12281261

1262+
// DOT_PRODUCT
1263+
fir::ExtendedValue
1264+
IntrinsicLibrary::genDotProduct(mlir::Type resultType,
1265+
llvm::ArrayRef<fir::ExtendedValue> args) {
1266+
return genDotProd(fir::runtime::genDotProduct, resultType, builder, loc,
1267+
stmtCtx, args);
1268+
}
1269+
12291270
// IAND
12301271
mlir::Value IntrinsicLibrary::genIand(mlir::Type resultType,
12311272
llvm::ArrayRef<mlir::Value> args) {
Lines changed: 247 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,247 @@
1+
! RUN: bbc -emit-fir %s -o - | FileCheck %s
2+
! RUN: %flang_fc1 -emit-fir %s -o - | FileCheck %s
3+
4+
! DOT_PROD
5+
! CHECK-LABEL: dot_prod_int_default
6+
! CHECK-SAME: %[[x:arg0]]: !fir.box<!fir.array<?xi32>>
7+
! CHECK-SAME: %[[y:arg1]]: !fir.box<!fir.array<?xi32>>
8+
! CHECK-SAME: %[[z:arg2]]: !fir.box<!fir.array<?xi32>>
9+
subroutine dot_prod_int_default (x, y, z)
10+
integer, dimension(1:) :: x,y
11+
integer, dimension(1:) :: z
12+
! CHECK-DAG: %[[x_conv:.*]] = fir.convert %[[x]] : (!fir.box<!fir.array<?xi32>>) -> !fir.box<none>
13+
! CHECK-DAG: %[[y_conv:.*]] = fir.convert %[[y]] : (!fir.box<!fir.array<?xi32>>) -> !fir.box<none>
14+
! CHECK-DAG: %[[res:.*]] = fir.call @_FortranADotProductInteger4(%[[x_conv]], %[[y_conv]], %{{[0-9]+}}, %{{.*}}) : (!fir.box<none>, !fir.box<none>, !fir.ref<i8>, i32) -> i32
15+
z = dot_product(x,y)
16+
end subroutine
17+
18+
! CHECK-LABEL: dot_prod_int_kind_1
19+
! CHECK-SAME: %[[x:arg0]]: !fir.box<!fir.array<?xi8>>
20+
! CHECK-SAME: %[[y:arg1]]: !fir.box<!fir.array<?xi8>>
21+
! CHECK-SAME: %[[z:arg2]]: !fir.box<!fir.array<?xi8>>
22+
subroutine dot_prod_int_kind_1 (x, y, z)
23+
integer(kind=1), dimension(1:) :: x,y
24+
integer(kind=1), dimension(1:) :: z
25+
! CHECK-DAG: %[[x_conv:.*]] = fir.convert %[[x]] : (!fir.box<!fir.array<?xi8>>) -> !fir.box<none>
26+
! CHECK-DAG: %[[y_conv:.*]] = fir.convert %[[y]] : (!fir.box<!fir.array<?xi8>>) -> !fir.box<none>
27+
! CHECK-DAG: %[[res:.*]] = fir.call @_FortranADotProductInteger1(%[[x_conv]], %[[y_conv]], %{{[0-9]+}}, %{{.*}}) : (!fir.box<none>, !fir.box<none>, !fir.ref<i8>, i32) -> i8
28+
z = dot_product(x,y)
29+
end subroutine
30+
31+
! CHECK-LABEL: dot_prod_int_kind_2
32+
! CHECK-SAME: %[[x:arg0]]: !fir.box<!fir.array<?xi16>>
33+
! CHECK-SAME: %[[y:arg1]]: !fir.box<!fir.array<?xi16>>
34+
! CHECK-SAME: %[[z:arg2]]: !fir.box<!fir.array<?xi16>>
35+
subroutine dot_prod_int_kind_2 (x, y, z)
36+
integer(kind=2), dimension(1:) :: x,y
37+
integer(kind=2), dimension(1:) :: z
38+
! CHECK-DAG: %[[x_conv:.*]] = fir.convert %[[x]] : (!fir.box<!fir.array<?xi16>>) -> !fir.box<none>
39+
! CHECK-DAG: %[[y_conv:.*]] = fir.convert %[[y]] : (!fir.box<!fir.array<?xi16>>) -> !fir.box<none>
40+
! CHECK-DAG: %[[res:.*]] = fir.call @_FortranADotProductInteger2(%[[x_conv]], %[[y_conv]], %{{[0-9]+}}, %{{.*}}) : (!fir.box<none>, !fir.box<none>, !fir.ref<i8>, i32) -> i16
41+
z = dot_product(x,y)
42+
end subroutine
43+
44+
! CHECK-LABEL: dot_prod_int_kind_4
45+
! CHECK-SAME: %[[x:arg0]]: !fir.box<!fir.array<?xi32>>
46+
! CHECK-SAME: %[[y:arg1]]: !fir.box<!fir.array<?xi32>>
47+
! CHECK-SAME: %[[z:arg2]]: !fir.box<!fir.array<?xi32>>
48+
subroutine dot_prod_int_kind_4 (x, y, z)
49+
integer(kind=4), dimension(1:) :: x,y
50+
integer(kind=4), dimension(1:) :: z
51+
! CHECK-DAG: %[[x_conv:.*]] = fir.convert %[[x]] : (!fir.box<!fir.array<?xi32>>) -> !fir.box<none>
52+
! CHECK-DAG: %[[y_conv:.*]] = fir.convert %[[y]] : (!fir.box<!fir.array<?xi32>>) -> !fir.box<none>
53+
! CHECK-DAG: %[[res:.*]] = fir.call @_FortranADotProductInteger4(%[[x_conv]], %[[y_conv]], %{{[0-9]+}}, %{{.*}}) : (!fir.box<none>, !fir.box<none>, !fir.ref<i8>, i32) -> i32
54+
z = dot_product(x,y)
55+
end subroutine
56+
57+
! CHECK-LABEL: dot_prod_int_kind_8
58+
! CHECK-SAME: %[[x:arg0]]: !fir.box<!fir.array<?xi64>>
59+
! CHECK-SAME: %[[y:arg1]]: !fir.box<!fir.array<?xi64>>
60+
! CHECK-SAME: %[[z:arg2]]: !fir.box<!fir.array<?xi64>>
61+
subroutine dot_prod_int_kind_8 (x, y, z)
62+
integer(kind=8), dimension(1:) :: x,y
63+
integer(kind=8), dimension(1:) :: z
64+
! CHECK-DAG: %[[x_conv:.*]] = fir.convert %[[x]] : (!fir.box<!fir.array<?xi64>>) -> !fir.box<none>
65+
! CHECK-DAG: %[[y_conv:.*]] = fir.convert %[[y]] : (!fir.box<!fir.array<?xi64>>) -> !fir.box<none>
66+
! CHECK-DAG: %[[res:.*]] = fir.call @_FortranADotProductInteger8(%[[x_conv]], %[[y_conv]], %{{[0-9]+}}, %{{.*}}) : (!fir.box<none>, !fir.box<none>, !fir.ref<i8>, i32) -> i64
67+
z = dot_product(x,y)
68+
end subroutine
69+
70+
! CHECK-LABEL: dot_prod_int_kind_16
71+
! CHECK-SAME: %[[x:arg0]]: !fir.box<!fir.array<?xi128>>
72+
! CHECK-SAME: %[[y:arg1]]: !fir.box<!fir.array<?xi128>>
73+
! CHECK-SAME: %[[z:arg2]]: !fir.box<!fir.array<?xi128>>
74+
subroutine dot_prod_int_kind_16 (x, y, z)
75+
integer(kind=16), dimension(1:) :: x,y
76+
integer(kind=16), dimension(1:) :: z
77+
! CHECK-DAG: %[[x_conv:.*]] = fir.convert %[[x]] : (!fir.box<!fir.array<?xi128>>) -> !fir.box<none>
78+
! CHECK-DAG: %[[y_conv:.*]] = fir.convert %[[y]] : (!fir.box<!fir.array<?xi128>>) -> !fir.box<none>
79+
! CHECK-DAG: %[[res:.*]] = fir.call @_FortranADotProductInteger16(%[[x_conv]], %[[y_conv]], %{{[0-9]+}}, %{{.*}}) : (!fir.box<none>, !fir.box<none>, !fir.ref<i8>, i32) -> i128
80+
z = dot_product(x,y)
81+
end subroutine
82+
83+
! CHECK-LABEL: dot_prod_real_kind_default
84+
! CHECK-SAME: %[[x:arg0]]: !fir.box<!fir.array<?xf32>>
85+
! CHECK-SAME: %[[y:arg1]]: !fir.box<!fir.array<?xf32>>
86+
! CHECK-SAME: %[[z:arg2]]: !fir.box<!fir.array<?xf32>>
87+
subroutine dot_prod_real_kind_default (x, y, z)
88+
real, dimension(1:) :: x,y
89+
real, dimension(1:) :: z
90+
! CHECK-DAG: %[[x_conv:.*]] = fir.convert %[[x]] : (!fir.box<!fir.array<?xf32>>) -> !fir.box<none>
91+
! CHECK-DAG: %[[y_conv:.*]] = fir.convert %[[y]] : (!fir.box<!fir.array<?xf32>>) -> !fir.box<none>
92+
! CHECK-DAG: %[[res:.*]] = fir.call @_FortranADotProductReal4(%[[x_conv]], %[[y_conv]], %{{[0-9]+}}, %{{.*}}) : (!fir.box<none>, !fir.box<none>, !fir.ref<i8>, i32) -> f32
93+
z = dot_product(x,y)
94+
end subroutine
95+
96+
! CHECK-LABEL: dot_prod_real_kind_4
97+
! CHECK-SAME: %[[x:arg0]]: !fir.box<!fir.array<?xf32>>
98+
! CHECK-SAME: %[[y:arg1]]: !fir.box<!fir.array<?xf32>>
99+
! CHECK-SAME: %[[z:arg2]]: !fir.box<!fir.array<?xf32>>
100+
subroutine dot_prod_real_kind_4 (x, y, z)
101+
real(kind=4), dimension(1:) :: x,y
102+
real(kind=4), dimension(1:) :: z
103+
! CHECK-DAG: %[[x_conv:.*]] = fir.convert %[[x]] : (!fir.box<!fir.array<?xf32>>) -> !fir.box<none>
104+
! CHECK-DAG: %[[y_conv:.*]] = fir.convert %[[y]] : (!fir.box<!fir.array<?xf32>>) -> !fir.box<none>
105+
! CHECK-DAG: %[[res:.*]] = fir.call @_FortranADotProductReal4(%[[x_conv]], %[[y_conv]], %{{[0-9]+}}, %{{.*}}) : (!fir.box<none>, !fir.box<none>, !fir.ref<i8>, i32) -> f32
106+
z = dot_product(x,y)
107+
end subroutine
108+
109+
! CHECK-LABEL: dot_prod_real_kind_8
110+
! CHECK-SAME: %[[x:arg0]]: !fir.box<!fir.array<?xf64>>
111+
! CHECK-SAME: %[[y:arg1]]: !fir.box<!fir.array<?xf64>>
112+
! CHECK-SAME: %[[z:arg2]]: !fir.box<!fir.array<?xf64>>
113+
subroutine dot_prod_real_kind_8 (x, y, z)
114+
real(kind=8), dimension(1:) :: x,y
115+
real(kind=8), dimension(1:) :: z
116+
! CHECK-DAG: %[[x_conv:.*]] = fir.convert %[[x]] : (!fir.box<!fir.array<?xf64>>) -> !fir.box<none>
117+
! CHECK-DAG: %[[y_conv:.*]] = fir.convert %[[y]] : (!fir.box<!fir.array<?xf64>>) -> !fir.box<none>
118+
! CHECK-DAG: %[[res:.*]] = fir.call @_FortranADotProductReal8(%[[x_conv]], %[[y_conv]], %{{[0-9]+}}, %{{.*}}) : (!fir.box<none>, !fir.box<none>, !fir.ref<i8>, i32) -> f64
119+
z = dot_product(x,y)
120+
end subroutine
121+
122+
! CHECK-LABEL: dot_prod_real_kind_10
123+
! CHECK-SAME: %[[x:arg0]]: !fir.box<!fir.array<?xf80>>
124+
! CHECK-SAME: %[[y:arg1]]: !fir.box<!fir.array<?xf80>>
125+
! CHECK-SAME: %[[z:arg2]]: !fir.box<!fir.array<?xf80>>
126+
subroutine dot_prod_real_kind_10 (x, y, z)
127+
real(kind=10), dimension(1:) :: x,y
128+
real(kind=10), dimension(1:) :: z
129+
! CHECK-DAG: %[[x_conv:.*]] = fir.convert %[[x]] : (!fir.box<!fir.array<?xf80>>) -> !fir.box<none>
130+
! CHECK-DAG: %[[y_conv:.*]] = fir.convert %[[y]] : (!fir.box<!fir.array<?xf80>>) -> !fir.box<none>
131+
! CHECK-DAG: %[[res:.*]] = fir.call @_FortranADotProductReal10(%[[x_conv]], %[[y_conv]], %{{[0-9]+}}, %{{.*}}) : (!fir.box<none>, !fir.box<none>, !fir.ref<i8>, i32) -> f80
132+
z = dot_product(x,y)
133+
end subroutine
134+
135+
! CHECK-LABEL: dot_prod_real_kind_16
136+
! CHECK-SAME: %[[x:arg0]]: !fir.box<!fir.array<?xf128>>
137+
! CHECK-SAME: %[[y:arg1]]: !fir.box<!fir.array<?xf128>>
138+
! CHECK-SAME: %[[z:arg2]]: !fir.box<!fir.array<?xf128>>
139+
subroutine dot_prod_real_kind_16 (x, y, z)
140+
real(kind=16), dimension(1:) :: x,y
141+
real(kind=16), dimension(1:) :: z
142+
! CHECK-DAG: %[[x_conv:.*]] = fir.convert %[[x]] : (!fir.box<!fir.array<?xf128>>) -> !fir.box<none>
143+
! CHECK-DAG: %[[y_conv:.*]] = fir.convert %[[y]] : (!fir.box<!fir.array<?xf128>>) -> !fir.box<none>
144+
! CHECK-DAG: %[[res:.*]] = fir.call @_FortranADotProductReal16(%[[x_conv]], %[[y_conv]], %{{[0-9]+}}, %{{.*}}) : (!fir.box<none>, !fir.box<none>, !fir.ref<i8>, i32) -> f128
145+
z = dot_product(x,y)
146+
end subroutine
147+
148+
! CHECK-LABEL: dot_prod_double_default
149+
! CHECK-SAME: %[[x:arg0]]: !fir.box<!fir.array<?xf64>>
150+
! CHECK-SAME: %[[y:arg1]]: !fir.box<!fir.array<?xf64>>
151+
! CHECK-SAME: %[[z:arg2]]: !fir.box<!fir.array<?xf64>>
152+
subroutine dot_prod_double_default (x, y, z)
153+
double precision, dimension(1:) :: x,y
154+
double precision, dimension(1:) :: z
155+
! CHECK-DAG: %[[x_conv:.*]] = fir.convert %[[x]] : (!fir.box<!fir.array<?xf64>>) -> !fir.box<none>
156+
! CHECK-DAG: %[[y_conv:.*]] = fir.convert %[[y]] : (!fir.box<!fir.array<?xf64>>) -> !fir.box<none>
157+
! CHECK-DAG: %[[res:.*]] = fir.call @_FortranADotProductReal8(%[[x_conv]], %[[y_conv]], %{{[0-9]+}}, %{{.*}}) : (!fir.box<none>, !fir.box<none>, !fir.ref<i8>, i32) -> f64
158+
z = dot_product(x,y)
159+
end subroutine
160+
161+
! CHECK-LABEL: dot_prod_complex_default
162+
! CHECK-SAME: %[[x:arg0]]: !fir.box<!fir.array<?x!fir.complex<4>>>
163+
! CHECK-SAME: %[[y:arg1]]: !fir.box<!fir.array<?x!fir.complex<4>>>
164+
! CHECK-SAME: %[[z:arg2]]: !fir.box<!fir.array<?x!fir.complex<4>>>
165+
subroutine dot_prod_complex_default (x, y, z)
166+
complex, dimension(1:) :: x,y
167+
complex, dimension(1:) :: z
168+
! CHECK-DAG: %0 = fir.alloca !fir.complex<4>
169+
! CHECK-DAG: %[[res_conv:[0-9]+]] = fir.convert %0 : (!fir.ref<!fir.complex<4>>) -> !fir.ref<complex<f32>>
170+
! CHECK-DAG: %[[x_conv:.*]] = fir.convert %[[x]] : (!fir.box<!fir.array<?x!fir.complex<4>>>) -> !fir.box<none>
171+
! CHECK-DAG: %[[y_conv:.*]] = fir.convert %[[y]] : (!fir.box<!fir.array<?x!fir.complex<4>>>) -> !fir.box<none>
172+
! CHECK-DAG: fir.call @_FortranACppDotProductComplex4(%[[res_conv]], %[[x_conv]], %[[y_conv]], %{{[0-9]+}}, %{{.*}}) : (!fir.ref<complex<f32>>, !fir.box<none>, !fir.box<none>, !fir.ref<i8>, i32) -> none
173+
z = dot_product(x,y)
174+
end subroutine
175+
176+
! CHECK-LABEL: dot_prod_complex_kind_4
177+
! CHECK-SAME: %[[x:arg0]]: !fir.box<!fir.array<?x!fir.complex<4>>>
178+
! CHECK-SAME: %[[y:arg1]]: !fir.box<!fir.array<?x!fir.complex<4>>>
179+
! CHECK-SAME: %[[z:arg2]]: !fir.box<!fir.array<?x!fir.complex<4>>>
180+
subroutine dot_prod_complex_kind_4 (x, y, z)
181+
complex(kind=4), dimension(1:) :: x,y
182+
complex(kind=4), dimension(1:) :: z
183+
! CHECK-DAG: %0 = fir.alloca !fir.complex<4>
184+
! CHECK-DAG: %[[res_conv:[0-9]+]] = fir.convert %0 : (!fir.ref<!fir.complex<4>>) -> !fir.ref<complex<f32>>
185+
! CHECK-DAG: %[[x_conv:.*]] = fir.convert %[[x]] : (!fir.box<!fir.array<?x!fir.complex<4>>>) -> !fir.box<none>
186+
! CHECK-DAG: %[[y_conv:.*]] = fir.convert %[[y]] : (!fir.box<!fir.array<?x!fir.complex<4>>>) -> !fir.box<none>
187+
! CHECK-DAG: fir.call @_FortranACppDotProductComplex4(%[[res_conv]], %[[x_conv]], %[[y_conv]], %{{[0-9]+}}, %{{.*}}) : (!fir.ref<complex<f32>>, !fir.box<none>, !fir.box<none>, !fir.ref<i8>, i32) -> none
188+
z = dot_product(x,y)
189+
end subroutine
190+
191+
! CHECK-LABEL: dot_prod_complex_kind_8
192+
! CHECK-SAME: %[[x:arg0]]: !fir.box<!fir.array<?x!fir.complex<8>>>
193+
! CHECK-SAME: %[[y:arg1]]: !fir.box<!fir.array<?x!fir.complex<8>>>
194+
! CHECK-SAME: %[[z:arg2]]: !fir.box<!fir.array<?x!fir.complex<8>>>
195+
subroutine dot_prod_complex_kind_8 (x, y, z)
196+
complex(kind=8), dimension(1:) :: x,y
197+
complex(kind=8), dimension(1:) :: z
198+
! CHECK-DAG: %0 = fir.alloca !fir.complex<8>
199+
! CHECK-DAG: %[[res_conv:[0-9]+]] = fir.convert %0 : (!fir.ref<!fir.complex<8>>) -> !fir.ref<complex<f64>>
200+
! CHECK-DAG: %[[x_conv:.*]] = fir.convert %[[x]] : (!fir.box<!fir.array<?x!fir.complex<8>>>) -> !fir.box<none>
201+
! CHECK-DAG: %[[y_conv:.*]] = fir.convert %[[y]] : (!fir.box<!fir.array<?x!fir.complex<8>>>) -> !fir.box<none>
202+
! CHECK-DAG: fir.call @_FortranACppDotProductComplex8(%[[res_conv]], %[[x_conv]], %[[y_conv]], %{{[0-9]+}}, %{{.*}}) : (!fir.ref<complex<f64>>, !fir.box<none>, !fir.box<none>, !fir.ref<i8>, i32) -> none
203+
z = dot_product(x,y)
204+
end subroutine
205+
206+
! CHECK-LABEL: dot_prod_complex_kind_10
207+
! CHECK-SAME: %[[x:arg0]]: !fir.box<!fir.array<?x!fir.complex<10>>>
208+
! CHECK-SAME: %[[y:arg1]]: !fir.box<!fir.array<?x!fir.complex<10>>>
209+
! CHECK-SAME: %[[z:arg2]]: !fir.box<!fir.array<?x!fir.complex<10>>>
210+
subroutine dot_prod_complex_kind_10 (x, y, z)
211+
complex(kind=10), dimension(1:) :: x,y
212+
complex(kind=10), dimension(1:) :: z
213+
! CHECK-DAG: %0 = fir.alloca !fir.complex<10>
214+
! CHECK-DAG: %[[res_conv:[0-9]+]] = fir.convert %0 : (!fir.ref<!fir.complex<10>>) -> !fir.ref<complex<f80>>
215+
! CHECK-DAG: %[[x_conv:.*]] = fir.convert %[[x]] : (!fir.box<!fir.array<?x!fir.complex<10>>>) -> !fir.box<none>
216+
! CHECK-DAG: %[[y_conv:.*]] = fir.convert %[[y]] : (!fir.box<!fir.array<?x!fir.complex<10>>>) -> !fir.box<none>
217+
! CHECK-DAG: fir.call @_FortranACppDotProductComplex10(%[[res_conv]], %[[x_conv]], %[[y_conv]], %{{[0-9]+}}, %{{.*}}) : (!fir.ref<complex<f80>>, !fir.box<none>, !fir.box<none>, !fir.ref<i8>, i32) -> ()
218+
z = dot_product(x,y)
219+
end subroutine
220+
221+
! CHECK-LABEL: dot_prod_complex_kind_16
222+
! CHECK-SAME: %[[x:arg0]]: !fir.box<!fir.array<?x!fir.complex<16>>>
223+
! CHECK-SAME: %[[y:arg1]]: !fir.box<!fir.array<?x!fir.complex<16>>>
224+
! CHECK-SAME: %[[z:arg2]]: !fir.box<!fir.array<?x!fir.complex<16>>>
225+
subroutine dot_prod_complex_kind_16 (x, y, z)
226+
complex(kind=16), dimension(1:) :: x,y
227+
complex(kind=16), dimension(1:) :: z
228+
! CHECK-DAG: %0 = fir.alloca !fir.complex<16>
229+
! CHECK-DAG: %[[res_conv:[0-9]+]] = fir.convert %0 : (!fir.ref<!fir.complex<16>>) -> !fir.ref<complex<f128>>
230+
! CHECK-DAG: %[[x_conv:.*]] = fir.convert %[[x]] : (!fir.box<!fir.array<?x!fir.complex<16>>>) -> !fir.box<none>
231+
! CHECK-DAG: %[[y_conv:.*]] = fir.convert %[[y]] : (!fir.box<!fir.array<?x!fir.complex<16>>>) -> !fir.box<none>
232+
! CHECK-DAG: fir.call @_FortranACppDotProductComplex16(%[[res_conv]], %[[x_conv]], %[[y_conv]], %{{[0-9]+}}, %{{.*}}) : (!fir.ref<complex<f128>>, !fir.box<none>, !fir.box<none>, !fir.ref<i8>, i32) -> ()
233+
z = dot_product(x,y)
234+
end subroutine
235+
236+
! CHECK-LABEL: dot_prod_logical
237+
! CHECK-SAME: %[[x:arg0]]: !fir.box<!fir.array<?x!fir.logical<4>>>
238+
! CHECK-SAME: %[[y:arg1]]: !fir.box<!fir.array<?x!fir.logical<4>>>
239+
! CHECK-SAME: %[[z:arg2]]: !fir.box<!fir.array<?x!fir.logical<4>>>
240+
subroutine dot_prod_logical (x, y, z)
241+
logical, dimension(1:) :: x,y
242+
logical, dimension(1:) :: z
243+
! CHECK-DAG: %[[x_conv:.*]] = fir.convert %[[x]] : (!fir.box<!fir.array<?x!fir.logical<4>>>) -> !fir.box<none>
244+
! CHECK-DAG: %[[y_conv:.*]] = fir.convert %[[y]] : (!fir.box<!fir.array<?x!fir.logical<4>>>) -> !fir.box<none>
245+
! CHECK-DAG: %[[res:.*]] = fir.call @_FortranADotProductLogical(%[[x_conv]], %[[y_conv]], %{{[0-9]+}}, %{{.*}}) : (!fir.box<none>, !fir.box<none>, !fir.ref<i8>, i32) -> i1
246+
z = dot_product(x,y)
247+
end subroutine

0 commit comments

Comments
 (0)