[flang-commits] [flang] [flang][NFC] Converted five tests from old lowering to new lowering (part 39) (PR #188386)
Eugene Epshteyn via flang-commits
flang-commits at lists.llvm.org
Mon Mar 30 05:00:12 PDT 2026
https://github.com/eugeneepshteyn updated https://github.com/llvm/llvm-project/pull/188386
>From 4bccd2df580acc07176ee6b857f45ec8b3398627 Mon Sep 17 00:00:00 2001
From: Eugene Epshteyn <eepshteyn at nvidia.com>
Date: Tue, 24 Mar 2026 20:26:54 -0400
Subject: [PATCH 1/5] [flang][NFC] Converted five tests from old lowering to
new lowering (part 39)
Tests converted from test/Lower/Intrinsics: product.f90, random.f90, real.f90, repeat.f90, reshape.f90
---
flang/test/Lower/Intrinsics/product.f90 | 90 +++++++++----------------
flang/test/Lower/Intrinsics/random.f90 | 60 +++++++----------
flang/test/Lower/Intrinsics/real.f90 | 10 +--
flang/test/Lower/Intrinsics/repeat.f90 | 14 ++--
flang/test/Lower/Intrinsics/reshape.f90 | 84 +++++++++--------------
5 files changed, 102 insertions(+), 156 deletions(-)
diff --git a/flang/test/Lower/Intrinsics/product.f90 b/flang/test/Lower/Intrinsics/product.f90
index c64982e435f07..0561cf7cda153 100644
--- a/flang/test/Lower/Intrinsics/product.f90
+++ b/flang/test/Lower/Intrinsics/product.f90
@@ -1,17 +1,12 @@
-! REQUIRES: x86-registered-target
-! RUN: bbc -target x86_64-unknown-linux-gnu --use-desc-for-alloc=false -emit-fir -hlfir=false %s -o - | FileCheck %s
+! RUN: %flang_fc1 -emit-hlfir %s -o - | FileCheck %s
! CHECK-LABEL: func @_QPproduct_test(
! CHECK-SAME: %[[arg0:.*]]: !fir.box<!fir.array<?xi32>>{{.*}}) -> i32
integer function product_test(a)
integer :: a(:)
-! CHECK-DAG: %[[c0:.*]] = arith.constant 0 : index
-! CHECK-DAG: %[[a1:.*]] = fir.absent !fir.box<i1>
-! CHECK-DAG: %[[a3:.*]] = fir.convert %[[arg0]] : (!fir.box<!fir.array<?xi32>>) -> !fir.box<none>
-! CHECK-DAG: %[[a5:.*]] = fir.convert %[[c0]] : (index) -> i32
-! CHECK-DAG: %[[a6:.*]] = fir.convert %[[a1]] : (!fir.box<i1>) -> !fir.box<none>
+! CHECK: hlfir.declare %[[arg0]]
product_test = product(a)
-! CHECK: %{{.*}} = fir.call @_FortranAProductInteger4(%[[a3]], %{{.*}}, %{{.*}}, %[[a5]], %[[a6]]) {{.*}}: (!fir.box<none>, !fir.ref<i8>, i32, i32, !fir.box<none>) -> i32
+! CHECK: hlfir.product {{.*}} : (!fir.box<!fir.array<?xi32>>) -> i32
end function
! CHECK-LABEL: func @_QPproduct_test2(
@@ -19,45 +14,27 @@ integer function product_test(a)
subroutine product_test2(a,r)
integer :: a(:,:)
integer :: r(:)
-! CHECK-DAG: %[[c2_i32:.*]] = arith.constant 2 : i32
-! CHECK-DAG: %[[a0:.*]] = fir.alloca !fir.box<!fir.heap<!fir.array<?xi32>>>
-! CHECK-DAG: %[[a1:.*]] = fir.absent !fir.box<i1>
-! CHECK-DAG: %[[a6:.*]] = fir.convert %[[a0]] : (!fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>>) -> !fir.ref<!fir.box<none>>
-! CHECK-DAG: %[[a7:.*]] = fir.convert %[[arg0]] : (!fir.box<!fir.array<?x?xi32>>) -> !fir.box<none>
-! CHECK-DAG: %[[a9:.*]] = fir.convert %[[a1]] : (!fir.box<i1>) -> !fir.box<none>
+! CHECK-DAG: %[[c2_i32:.*]] = arith.constant 2 : i32
+! CHECK-DAG: %[[aDecl:.*]]:2 = hlfir.declare %[[arg0]]
+! CHECK-DAG: %[[rDecl:.*]]:2 = hlfir.declare %[[arg1]]
r = product(a,dim=2)
-! CHECK: fir.call @_FortranAProductDim(%[[a6]], %[[a7]], %[[c2_i32]], %{{.*}}, %{{.*}}, %[[a9]]) {{.*}}: (!fir.ref<!fir.box<none>>, !fir.box<none>, i32, !fir.ref<i8>, i32, !fir.box<none>) -> ()
-! CHECK-DAG: %[[a11:.*]] = fir.load %[[a0]] : !fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>>
-! CHECK-DAG: %[[a13:.*]] = fir.box_addr %[[a11]] : (!fir.box<!fir.heap<!fir.array<?xi32>>>) -> !fir.heap<!fir.array<?xi32>>
-! CHECK-DAG: fir.freemem %[[a13]]
+! CHECK: hlfir.product %[[aDecl]]#0 dim %[[c2_i32]] {{.*}} : (!fir.box<!fir.array<?x?xi32>>, i32) -> !hlfir.expr<?xi32>
end subroutine
! CHECK-LABEL: func @_QPproduct_test3(
! CHECK-SAME: %[[arg0:.*]]: !fir.box<!fir.array<?xcomplex<f32>>>{{.*}}) -> complex<f32>
complex function product_test3(a)
complex :: a(:)
-! CHECK-DAG: %[[c0:.*]] = arith.constant 0 : index
-! CHECK-DAG: %[[a0:.*]] = fir.alloca complex<f32>
-! CHECK-DAG: %[[a3:.*]] = fir.absent !fir.box<i1>
-! CHECK-DAG: %[[a6:.*]] = fir.convert %[[arg0]] : (!fir.box<!fir.array<?xcomplex<f32>>>) -> !fir.box<none>
-! CHECK-DAG: %[[a8:.*]] = fir.convert %[[c0]] : (index) -> i32
-! CHECK-DAG: %[[a9:.*]] = fir.convert %[[a3]] : (!fir.box<i1>) -> !fir.box<none>
product_test3 = product(a)
-! CHECK: fir.call @_FortranACppProductComplex4(%[[a0]], %[[a6]], %{{.*}}, %{{.*}}, %[[a8]], %[[a9]]) {{.*}}: (!fir.ref<complex<f32>>, !fir.box<none>, !fir.ref<i8>, i32, i32, !fir.box<none>) -> ()
+! CHECK: hlfir.product {{.*}} : (!fir.box<!fir.array<?xcomplex<f32>>>) -> complex<f32>
end function
! CHECK-LABEL: func @_QPproduct_test4(
! CHECK-SAME: %[[arg0:.*]]: !fir.box<!fir.array<?xcomplex<f80>>>{{.*}}) -> complex<f80>
complex(10) function product_test4(x)
complex(10):: x(:)
-! CHECK-DAG: %[[c0:.*]] = arith.constant 0 : index
-! CHECK-DAG: %[[a0:.*]] = fir.alloca complex<f80>
product_test4 = product(x)
-! CHECK-DAG: %[[a2:.*]] = fir.absent !fir.box<i1>
-! CHECK-DAG: %[[a5:.*]] = fir.convert %[[arg0]] : (!fir.box<!fir.array<?xcomplex<f80>>>) -> !fir.box<none>
-! CHECK-DAG: %[[a7:.*]] = fir.convert %[[c0]] : (index) -> i32
-! CHECK-DAG: %[[a8:.*]] = fir.convert %[[a2]] : (!fir.box<i1>) -> !fir.box<none>
-! CHECK: fir.call @_FortranACppProductComplex10(%[[a0]], %[[a5]], %{{.*}}, %{{.*}}, %[[a7]], %{{[0-9]+}}) {{.*}}: (!fir.ref<complex<f80>>, !fir.box<none>, !fir.ref<i8>, i32, i32, !fir.box<none>) -> ()
+! CHECK: hlfir.product {{.*}} : (!fir.box<!fir.array<?xcomplex<f80>>>) -> complex<f80>
end
! CHECK-LABEL: func @_QPproduct_test_optional(
@@ -66,8 +43,12 @@ real function product_test_optional(mask, x)
real :: x(:)
logical, optional :: mask(:)
product_test_optional = product(x, mask=mask)
-! CHECK: %[[VAL_9:.*]] = fir.convert %[[VAL_0]] : (!fir.box<!fir.array<?x!fir.logical<4>>>) -> !fir.box<none>
-! CHECK: fir.call @_FortranAProductReal4(%{{.*}}, %{{.*}}, %{{.*}}, %{{.*}}, %[[VAL_9]]) {{.*}}: (!fir.box<none>, !fir.ref<i8>, i32, i32, !fir.box<none>) -> f32
+! CHECK-DAG: %[[maskDecl:.*]]:2 = hlfir.declare %[[VAL_0]] {{.*}}optional
+! CHECK-DAG: %[[xDecl:.*]]:2 = hlfir.declare %{{.*}} {{.*}}{uniq_name = "_QFproduct_test_optionalEx"}
+! CHECK: %[[isPresent:.*]] = fir.is_present %[[maskDecl]]#0
+! CHECK: %[[absent:.*]] = fir.absent !fir.box<!fir.array<?x!fir.logical<4>>>
+! CHECK: %[[opt:.*]] = arith.select %[[isPresent]], %[[maskDecl]]#1, %[[absent]]
+! CHECK: hlfir.product %[[xDecl]]#0 mask %[[opt]] {{.*}} : (!fir.box<!fir.array<?xf32>>, !fir.box<!fir.array<?x!fir.logical<4>>>) -> f32
end function
! CHECK-LABEL: func @_QPproduct_test_optional_2(
@@ -76,16 +57,16 @@ real function product_test_optional_2(mask, x)
real :: x(:)
logical, pointer :: mask(:)
product_test_optional = product(x, mask=mask)
-! CHECK: %[[VAL_4:.*]] = fir.load %[[VAL_0]] : !fir.ref<!fir.box<!fir.ptr<!fir.array<?x!fir.logical<4>>>>>
+! CHECK: %[[maskDecl:.*]]:2 = hlfir.declare %[[VAL_0]]
+! CHECK: %[[VAL_4:.*]] = fir.load %[[maskDecl]]#0 : !fir.ref<!fir.box<!fir.ptr<!fir.array<?x!fir.logical<4>>>>>
! CHECK: %[[VAL_5:.*]] = fir.box_addr %[[VAL_4]] : (!fir.box<!fir.ptr<!fir.array<?x!fir.logical<4>>>>) -> !fir.ptr<!fir.array<?x!fir.logical<4>>>
! CHECK: %[[VAL_6:.*]] = fir.convert %[[VAL_5]] : (!fir.ptr<!fir.array<?x!fir.logical<4>>>) -> i64
! CHECK: %[[VAL_7:.*]] = arith.constant 0 : i64
! CHECK: %[[VAL_8:.*]] = arith.cmpi ne, %[[VAL_6]], %[[VAL_7]] : i64
-! CHECK: %[[VAL_9:.*]] = fir.load %[[VAL_0]] : !fir.ref<!fir.box<!fir.ptr<!fir.array<?x!fir.logical<4>>>>>
+! CHECK: %[[VAL_9:.*]] = fir.load %[[maskDecl]]#0 : !fir.ref<!fir.box<!fir.ptr<!fir.array<?x!fir.logical<4>>>>>
! CHECK: %[[VAL_10:.*]] = fir.absent !fir.box<!fir.ptr<!fir.array<?x!fir.logical<4>>>>
! CHECK: %[[VAL_11:.*]] = arith.select %[[VAL_8]], %[[VAL_9]], %[[VAL_10]] : !fir.box<!fir.ptr<!fir.array<?x!fir.logical<4>>>>
-! CHECK: %[[VAL_18:.*]] = fir.convert %[[VAL_11]] : (!fir.box<!fir.ptr<!fir.array<?x!fir.logical<4>>>>) -> !fir.box<none>
-! CHECK: fir.call @_FortranAProductReal4(%{{.*}}, %{{.*}}, %{{.*}}, %{{.*}}, %[[VAL_18]]) {{.*}}: (!fir.box<none>, !fir.ref<i8>, i32, i32, !fir.box<none>) -> f32
+! CHECK: hlfir.product {{.*}} mask %[[VAL_11]] {{.*}} : (!fir.box<!fir.array<?xf32>>, !fir.box<!fir.ptr<!fir.array<?x!fir.logical<4>>>>) -> f32
end function
! CHECK-LABEL: func @_QPproduct_test_optional_3(
@@ -94,14 +75,13 @@ real function product_test_optional_3(mask, x)
real :: x(:)
logical, optional :: mask(10)
product_test_optional = product(x, mask=mask)
-! CHECK: %[[VAL_2:.*]] = arith.constant 10 : index
-! CHECK: %[[VAL_5:.*]] = fir.is_present %[[VAL_0]] : (!fir.ref<!fir.array<10x!fir.logical<4>>>) -> i1
-! CHECK: %[[VAL_6:.*]] = fir.shape %[[VAL_2]] : (index) -> !fir.shape<1>
-! CHECK: %[[VAL_7:.*]] = fir.embox %[[VAL_0]](%[[VAL_6]]) : (!fir.ref<!fir.array<10x!fir.logical<4>>>, !fir.shape<1>) -> !fir.box<!fir.array<10x!fir.logical<4>>>
+! CHECK: %[[maskDecl:.*]]:2 = hlfir.declare %[[VAL_0]]
+! CHECK: %[[VAL_5:.*]] = fir.is_present %[[maskDecl]]#0 : (!fir.ref<!fir.array<10x!fir.logical<4>>>) -> i1
+! CHECK: %[[VAL_6:.*]] = fir.shape
+! CHECK: %[[VAL_7:.*]] = fir.embox %[[maskDecl]]#0(%[[VAL_6]])
! CHECK: %[[VAL_8:.*]] = fir.absent !fir.box<!fir.array<10x!fir.logical<4>>>
! CHECK: %[[VAL_9:.*]] = arith.select %[[VAL_5]], %[[VAL_7]], %[[VAL_8]] : !fir.box<!fir.array<10x!fir.logical<4>>>
-! CHECK: %[[VAL_18:.*]] = fir.convert %[[VAL_9]] : (!fir.box<!fir.array<10x!fir.logical<4>>>) -> !fir.box<none>
-! CHECK: fir.call @_FortranAProductReal4(%{{.*}}, %{{.*}}, %{{.*}}, %{{.*}}, %[[VAL_18]]) {{.*}}: (!fir.box<none>, !fir.ref<i8>, i32, i32, !fir.box<none>) -> f32
+! CHECK: hlfir.product {{.*}} mask %[[VAL_9]] {{.*}} : (!fir.box<!fir.array<?xf32>>, !fir.box<!fir.array<10x!fir.logical<4>>>) -> f32
end function
! CHECK-LABEL: func @_QPproduct_test_optional_4(
@@ -117,17 +97,13 @@ real function product_test_optional_4(x, use_mask)
! CHECK: fir.call @_QPset_mask
end if
product_test_optional = product(x, mask=mask)
-! CHECK: %[[VAL_20:.*]] = fir.load %[[VAL_3:.*]] : !fir.ref<!fir.heap<!fir.array<?x!fir.logical<4>>>>
-! CHECK: %[[VAL_21:.*]] = fir.convert %[[VAL_20]] : (!fir.heap<!fir.array<?x!fir.logical<4>>>) -> i64
-! CHECK: %[[VAL_22:.*]] = arith.constant 0 : i64
-! CHECK: %[[VAL_23:.*]] = arith.cmpi ne, %[[VAL_21]], %[[VAL_22]] : i64
-! CHECK: %[[VAL_24:.*]] = fir.load %[[VAL_4:.*]] : !fir.ref<index>
-! CHECK: %[[VAL_25:.*]] = fir.load %[[VAL_5:.*]] : !fir.ref<index>
-! CHECK: %[[VAL_26:.*]] = fir.load %[[VAL_3]] : !fir.ref<!fir.heap<!fir.array<?x!fir.logical<4>>>>
-! CHECK: %[[VAL_27:.*]] = fir.shape_shift %[[VAL_24]], %[[VAL_25]] : (index, index) -> !fir.shapeshift<1>
-! CHECK: %[[VAL_28:.*]] = fir.embox %[[VAL_26]](%[[VAL_27]]) : (!fir.heap<!fir.array<?x!fir.logical<4>>>, !fir.shapeshift<1>) -> !fir.box<!fir.array<?x!fir.logical<4>>>
-! CHECK: %[[VAL_29:.*]] = fir.absent !fir.box<!fir.array<?x!fir.logical<4>>>
-! CHECK: %[[VAL_30:.*]] = arith.select %[[VAL_23]], %[[VAL_28]], %[[VAL_29]] : !fir.box<!fir.array<?x!fir.logical<4>>>
-! CHECK: %[[VAL_37:.*]] = fir.convert %[[VAL_30]] : (!fir.box<!fir.array<?x!fir.logical<4>>>) -> !fir.box<none>
-! CHECK: fir.call @_FortranAProductReal4(%{{.*}}, %{{.*}}, %{{.*}}, %{{.*}}, %[[VAL_37]]) {{.*}}: (!fir.box<none>, !fir.ref<i8>, i32, i32, !fir.box<none>) -> f32
+! CHECK: %[[VAL_20:.*]] = fir.load %[[maskBox:.*]] : !fir.ref<!fir.box<!fir.heap<!fir.array<?x!fir.logical<4>>>>>
+! CHECK: %[[VAL_21:.*]] = fir.box_addr %[[VAL_20]] : (!fir.box<!fir.heap<!fir.array<?x!fir.logical<4>>>>) -> !fir.heap<!fir.array<?x!fir.logical<4>>>
+! CHECK: %[[VAL_22:.*]] = fir.convert %[[VAL_21]] : (!fir.heap<!fir.array<?x!fir.logical<4>>>) -> i64
+! CHECK: %[[VAL_23:.*]] = arith.constant 0 : i64
+! CHECK: %[[VAL_24:.*]] = arith.cmpi ne, %[[VAL_22]], %[[VAL_23]] : i64
+! CHECK: %[[VAL_25:.*]] = fir.load %[[maskBox]] : !fir.ref<!fir.box<!fir.heap<!fir.array<?x!fir.logical<4>>>>>
+! CHECK: %[[VAL_26:.*]] = fir.absent !fir.box<!fir.heap<!fir.array<?x!fir.logical<4>>>>
+! CHECK: %[[VAL_27:.*]] = arith.select %[[VAL_24]], %[[VAL_25]], %[[VAL_26]] : !fir.box<!fir.heap<!fir.array<?x!fir.logical<4>>>>
+! CHECK: hlfir.product {{.*}} mask %[[VAL_27]] {{.*}} : (!fir.box<!fir.array<?xf32>>, !fir.box<!fir.heap<!fir.array<?x!fir.logical<4>>>>) -> f32
end function
diff --git a/flang/test/Lower/Intrinsics/random.f90 b/flang/test/Lower/Intrinsics/random.f90
index 5f7d6414e606d..fe5d6b319da24 100644
--- a/flang/test/Lower/Intrinsics/random.f90
+++ b/flang/test/Lower/Intrinsics/random.f90
@@ -1,40 +1,30 @@
-! RUN: bbc -emit-fir -hlfir=false %s -o - | FileCheck %s
+! RUN: %flang_fc1 -emit-hlfir %s -o - | FileCheck %s
! CHECK-LABEL: func @_QPrandom_test_1
subroutine random_test_1
- ! CHECK-DAG: [[ss:%[0-9]+]] = fir.alloca {{.*}}random_test_1Ess
- ! CHECK-DAG: [[vv:%[0-9]+]] = fir.alloca {{.*}}random_test_1Evv
+ ! CHECK-DAG: hlfir.declare {{.*}}random_test_1Ess
+ ! CHECK-DAG: hlfir.declare {{.*}}random_test_1Evv
integer ss, vv(40)
- ! CHECK-DAG: [[rr:%[0-9]+]] = fir.alloca {{.*}}random_test_1Err
- ! CHECK-DAG: [[aa:%[0-9]+]] = fir.alloca {{.*}}random_test_1Eaa
+ ! CHECK-DAG: hlfir.declare {{.*}}random_test_1Err
+ ! CHECK-DAG: hlfir.declare {{.*}}random_test_1Eaa
real rr, aa(5)
! CHECK: fir.call @_FortranARandomInit(%true{{.*}}, %false{{.*}}) {{.*}}: (i1, i1) -> ()
call random_init(.true., .false.)
- ! CHECK: [[box:%[0-9]+]] = fir.embox [[ss]]
- ! CHECK: [[argbox:%[0-9]+]] = fir.convert [[box]]
- ! CHECK: fir.call @_FortranARandomSeedSize([[argbox]]
+ ! CHECK: fir.call @_FortranARandomSeedSize(
call random_seed(size=ss)
print*, 'size: ', ss
! CHECK: fir.call @_FortranARandomSeedDefaultPut() {{.*}}: () -> ()
call random_seed()
- ! CHECK: [[box:%[0-9]+]] = fir.embox [[rr]]
- ! CHECK: [[argbox:%[0-9]+]] = fir.convert [[box]]
- ! CHECK: fir.call @_FortranARandomNumber([[argbox]]
+ ! CHECK: fir.call @_FortranARandomNumber(
call random_number(rr)
print*, rr
- ! CHECK: [[box:%[0-9]+]] = fir.embox [[vv]]
- ! CHECK: [[argbox:%[0-9]+]] = fir.convert [[box]]
- ! CHECK: fir.call @_FortranARandomSeedGet([[argbox]]
+ ! CHECK: fir.call @_FortranARandomSeedGet(
call random_seed(get=vv)
! print*, 'get: ', vv(1:ss)
- ! CHECK: [[box:%[0-9]+]] = fir.embox [[vv]]
- ! CHECK: [[argbox:%[0-9]+]] = fir.convert [[box]]
- ! CHECK: fir.call @_FortranARandomSeedPut([[argbox]]
+ ! CHECK: fir.call @_FortranARandomSeedPut(
call random_seed(put=vv)
print*, 'put: ', vv(1:ss)
- ! CHECK: [[box:%[0-9]+]] = fir.embox [[aa]]
- ! CHECK: [[argbox:%[0-9]+]] = fir.convert [[box]]
- ! CHECK: fir.call @_FortranARandomNumber([[argbox]]
+ ! CHECK: fir.call @_FortranARandomNumber(
call random_number(aa)
print*, aa
end
@@ -47,21 +37,21 @@ subroutine random_test_2
contains
! CHECK-LABEL: func private @_QFrandom_test_2Pfoo
subroutine foo(size, put, get)
- ! CHECK: [[s1:%[0-9]+]] = fir.is_present %arg0
- ! CHECK: [[s2:%[0-9]+]] = fir.embox %arg0
+ integer, optional :: size
+ integer, optional :: put(5)
+ integer, optional :: get(5)
+ ! CHECK: [[s1:%[0-9]+]] = fir.is_present
+ ! CHECK: [[p1:%[0-9]+]] = fir.is_present
+ ! CHECK: [[g1:%[0-9]+]] = fir.is_present
+ ! CHECK: [[s2:%[0-9]+]] = fir.embox
! CHECK: [[s3:%[0-9]+]] = fir.absent !fir.box<i32>
! CHECK: [[s4:%[0-9]+]] = arith.select [[s1]], [[s2]], [[s3]] : !fir.box<i32>
- integer, optional :: size
- ! CHECK: [[p1:%[0-9]+]] = fir.is_present %arg1
- ! CHECK: [[p2:%[0-9]+]] = fir.embox %arg1
+ ! CHECK: [[p2:%[0-9]+]] = fir.embox
! CHECK: [[p3:%[0-9]+]] = fir.absent !fir.box<!fir.array<5xi32>>
! CHECK: [[p4:%[0-9]+]] = arith.select [[p1]], [[p2]], [[p3]] : !fir.box<!fir.array<5xi32>>
- integer, optional :: put(5)
- ! CHECK: [[g1:%[0-9]+]] = fir.is_present %arg2
- ! CHECK: [[g2:%[0-9]+]] = fir.embox %arg2
+ ! CHECK: [[g2:%[0-9]+]] = fir.embox
! CHECK: [[g3:%[0-9]+]] = fir.absent !fir.box<!fir.array<5xi32>>
! CHECK: [[g4:%[0-9]+]] = arith.select [[g1]], [[g2]], [[g3]] : !fir.box<!fir.array<5xi32>>
- integer, optional :: get(5)
! CHECK: [[s5:%[0-9]+]] = fir.convert [[s4]] : (!fir.box<i32>) -> !fir.box<none>
! CHECK: [[p5:%[0-9]+]] = fir.convert [[p4]] : (!fir.box<!fir.array<5xi32>>) -> !fir.box<none>
! CHECK: [[g5:%[0-9]+]] = fir.convert [[g4]] : (!fir.box<!fir.array<5xi32>>) -> !fir.box<none>
@@ -73,16 +63,16 @@ subroutine foo(size, put, get)
! CHECK-LABEL: func private @_QFrandom_test_2Pbar
subroutine bar(size, get, put)
integer, optional :: size
- ! CHECK: [[p1:%[0-9]+]] = fir.is_present %arg2
- ! CHECK: [[p2:%[0-9]+]] = fir.embox %arg2
+ integer, optional :: put(5)
+ integer, optional :: get(5)
+ ! CHECK: [[p1:%[0-9]+]] = fir.is_present
+ ! CHECK: [[g1:%[0-9]+]] = fir.is_present
+ ! CHECK: [[p2:%[0-9]+]] = fir.embox
! CHECK: [[p3:%[0-9]+]] = fir.absent !fir.box<!fir.array<5xi32>>
! CHECK: [[p4:%[0-9]+]] = arith.select [[p1]], [[p2]], [[p3]] : !fir.box<!fir.array<5xi32>>
- integer, optional :: put(5)
- ! CHECK: [[g1:%[0-9]+]] = fir.is_present %arg1
- ! CHECK: [[g2:%[0-9]+]] = fir.embox %arg1
+ ! CHECK: [[g2:%[0-9]+]] = fir.embox
! CHECK: [[g3:%[0-9]+]] = fir.absent !fir.box<!fir.array<5xi32>>
! CHECK: [[g4:%[0-9]+]] = arith.select [[g1]], [[g2]], [[g3]] : !fir.box<!fir.array<5xi32>>
- integer, optional :: get(5)
! CHECK: [[s1:%[0-9]+]] = fir.absent !fir.box<none>
! CHECK: [[p5:%[0-9]+]] = fir.convert [[p4]] : (!fir.box<!fir.array<5xi32>>) -> !fir.box<none>
! CHECK: [[g5:%[0-9]+]] = fir.convert [[g4]] : (!fir.box<!fir.array<5xi32>>) -> !fir.box<none>
diff --git a/flang/test/Lower/Intrinsics/real.f90 b/flang/test/Lower/Intrinsics/real.f90
index f1f728e1a203f..b822d43cf1a74 100644
--- a/flang/test/Lower/Intrinsics/real.f90
+++ b/flang/test/Lower/Intrinsics/real.f90
@@ -1,4 +1,4 @@
-! RUN: bbc -emit-fir -hlfir=false %s -o - | FileCheck %s
+! RUN: %flang_fc1 -emit-hlfir %s -o - | FileCheck %s
! Tests REAL lowering
subroutine test_real()
@@ -12,9 +12,11 @@ subroutine test_real()
! CHECK-LABEL: func @_QPtest_real() {
! CHECK: %[[VAL_0:.*]] = fir.alloca f32 {bindc_name = "r4", uniq_name = "_QFtest_realEr4"}
-! CHECK: %[[VAL_1:.*]] = fir.alloca f64 {bindc_name = "r8", uniq_name = "_QFtest_realEr8"}
+! CHECK: %[[VAL_1:.*]]:2 = hlfir.declare %[[VAL_0]] {uniq_name = "_QFtest_realEr4"} : (!fir.ref<f32>) -> (!fir.ref<f32>, !fir.ref<f32>)
+! CHECK: %[[VAL_2:.*]] = fir.alloca f64 {bindc_name = "r8", uniq_name = "_QFtest_realEr8"}
+! CHECK: %[[VAL_3:.*]]:2 = hlfir.declare %[[VAL_2]] {uniq_name = "_QFtest_realEr8"} : (!fir.ref<f64>) -> (!fir.ref<f64>, !fir.ref<f64>)
! CHECK: %[[CST_0:.*]] = arith.constant 8.968310e-44 : f32
-! CHECK: fir.store %[[CST_0]] to %[[VAL_0]] : !fir.ref<f32>
+! CHECK: hlfir.assign %[[CST_0]] to %[[VAL_1]]#0 : f32, !fir.ref<f32>
! CHECK: %[[CST_1:.*]] = arith.constant 3.162020e-322 : f64
-! CHECK: fir.store %[[CST_1]] to %[[VAL_1]] : !fir.ref<f64>
+! CHECK: hlfir.assign %[[CST_1]] to %[[VAL_3]]#0 : f64, !fir.ref<f64>
! CHECK: return
diff --git a/flang/test/Lower/Intrinsics/repeat.f90 b/flang/test/Lower/Intrinsics/repeat.f90
index e95221405b664..c21b416942f45 100644
--- a/flang/test/Lower/Intrinsics/repeat.f90
+++ b/flang/test/Lower/Intrinsics/repeat.f90
@@ -1,24 +1,22 @@
-! RUN: bbc -emit-fir -hlfir=false %s -o - | FileCheck %s
-! RUN: %flang_fc1 -emit-fir -flang-deprecated-no-hlfir %s -o - | FileCheck %s
+! RUN: %flang_fc1 -emit-hlfir %s -o - | FileCheck %s
! CHECK-LABEL: func @_QPrepeat_test(
! CHECK-SAME: %[[arg0:.*]]: !fir.boxchar<1>{{.*}}, %[[arg1:.*]]: !fir.ref<i32>{{.*}}) {
subroutine repeat_test(c, n)
character(*) :: c
integer :: n
- ! CHECK: %[[tmpBox:.*]] = fir.alloca !fir.box<!fir.heap<!fir.char<1,?>>>
+ ! CHECK-DAG: %[[tmpBox:.*]] = fir.alloca !fir.box<!fir.heap<!fir.char<1,?>>>
! CHECK-DAG: %[[c:.*]]:2 = fir.unboxchar %[[arg0]] : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
- ! CHECK-DAG: %[[ni32:.*]] = fir.load %[[arg1]] : !fir.ref<i32>
+ ! CHECK-DAG: %[[cDecl:.*]]:2 = hlfir.declare %[[c]]#0 typeparams %[[c]]#1
+ ! CHECK-DAG: %[[nDecl:.*]]:2 = hlfir.declare %[[arg1]]
+ ! CHECK-DAG: %[[ni32:.*]] = fir.load %[[nDecl]]#0 : !fir.ref<i32>
! CHECK-DAG: %[[n:.*]] = fir.convert %[[ni32]] : (i32) -> i64
- ! CHECK-DAG: %[[cBox:.*]] = fir.embox %[[c]]#0 typeparams %[[c]]#1 : (!fir.ref<!fir.char<1,?>>, index) -> !fir.box<!fir.char<1,?>>
+ ! CHECK-DAG: %[[cBox:.*]] = fir.embox %[[cDecl]]#1 typeparams %[[c]]#1 : (!fir.ref<!fir.char<1,?>>, index) -> !fir.box<!fir.char<1,?>>
! CHECK-DAG: %[[cBoxNone:.*]] = fir.convert %[[cBox]] : (!fir.box<!fir.char<1,?>>) -> !fir.box<none>
! CHECK-DAG: %[[resBox:.*]] = fir.convert %[[tmpBox]] : (!fir.ref<!fir.box<!fir.heap<!fir.char<1,?>>>>) -> !fir.ref<!fir.box<none>>
! CHECK: fir.call @{{.*}}Repeat(%[[resBox]], %[[cBoxNone]], %[[n]], {{.*}}, {{.*}}) {{.*}}: (!fir.ref<!fir.box<none>>, !fir.box<none>, i64, !fir.ref<i8>, i32) -> ()
- ! CHECK-DAG: %[[tmpAddr:.*]] = fir.box_addr
- ! CHECK-DAG: fir.box_elesize
! CHECK: fir.call @{{.*}}bar_repeat_test
call bar_repeat_test(repeat(c,n))
- ! CHECK: fir.freemem %[[tmpAddr]] : !fir.heap<!fir.char<1,?>>
return
end subroutine
diff --git a/flang/test/Lower/Intrinsics/reshape.f90 b/flang/test/Lower/Intrinsics/reshape.f90
index b960a3e380786..63a788c5eaa7f 100644
--- a/flang/test/Lower/Intrinsics/reshape.f90
+++ b/flang/test/Lower/Intrinsics/reshape.f90
@@ -1,4 +1,4 @@
-! RUN: bbc -emit-fir -hlfir=false %s -o - | FileCheck %s
+! RUN: %flang_fc1 -emit-hlfir %s -o - | FileCheck %s
! CHECK-LABEL: func @_QPreshape_test(
! CHECK-SAME: %[[arg0:.*]]: !fir.box<!fir.array<?x?xi32>>{{.*}}, %[[arg1:[^:]+]]: !fir.box<!fir.array<?x?x?xi32>>{{.*}}, %[[arg2:[^:]+]]: !fir.box<!fir.array<?x?x?xi32>>{{.*}}, %[[arg3:.*]]: !fir.ref<!fir.array<2xi32>>{{.*}}, %[[arg4:.*]]: !fir.ref<!fir.array<2xi32>>{{.*}}) {
@@ -8,21 +8,15 @@ subroutine reshape_test(x, source, pd, sh, ord)
integer :: pd(:,:,:)
integer :: sh(2)
integer :: ord(2)
- ! CHECK-DAG: %[[c2:.*]] = arith.constant 2 : index
- ! CHECK-DAG: %[[a0:.*]] = fir.alloca !fir.box<!fir.heap<!fir.array<?x?xi32>>>
- ! CHECK-DAG: %[[a1:.*]] = fir.shape %[[c2]] : (index) -> !fir.shape<1>
- ! CHECK-DAG: %[[a2:.*]] = fir.embox %[[arg3]](%{{.*}}) : (!fir.ref<!fir.array<2xi32>>, !fir.shape<1>) -> !fir.box<!fir.array<2xi32>>
- ! CHECK-DAG: %[[a3:.*]] = fir.embox %[[arg4]](%{{.*}}) : (!fir.ref<!fir.array<2xi32>>, !fir.shape<1>) -> !fir.box<!fir.array<2xi32>>
- ! CHECK-DAG: %[[a8:.*]] = fir.convert %[[a0]] : (!fir.ref<!fir.box<!fir.heap<!fir.array<?x?xi32>>>>) -> !fir.ref<!fir.box<none>>
- ! CHECK-DAG: %[[a9:.*]] = fir.convert %[[arg1]] : (!fir.box<!fir.array<?x?x?xi32>>) -> !fir.box<none>
- ! CHECK-DAG: %[[a10:.*]] = fir.convert %[[a2]] : (!fir.box<!fir.array<2xi32>>) -> !fir.box<none>
- ! CHECK-DAG: %[[a11:.*]] = fir.convert %[[arg2]] : (!fir.box<!fir.array<?x?x?xi32>>) -> !fir.box<none>
- ! CHECK-DAG: %[[a12:.*]] = fir.convert %[[a3]] : (!fir.box<!fir.array<2xi32>>) -> !fir.box<none>
+ ! CHECK-DAG: %[[ordDecl:.*]]:2 = hlfir.declare %[[arg4]]
+ ! CHECK-DAG: %[[pdDecl:.*]]:2 = hlfir.declare %[[arg2]]
+ ! CHECK-DAG: %[[shDecl:.*]]:2 = hlfir.declare %[[arg3]]
+ ! CHECK-DAG: %[[srcDecl:.*]]:2 = hlfir.declare %[[arg1]]
+ ! CHECK-DAG: %[[xDecl:.*]]:2 = hlfir.declare %[[arg0]]
+ ! CHECK: %[[res:.*]] = hlfir.reshape %[[srcDecl]]#0 %[[shDecl]]#0 pad %[[pdDecl]]#0 order %[[ordDecl]]#0
+ ! CHECK: hlfir.assign %[[res]] to %[[xDecl]]#0
+ ! CHECK: hlfir.destroy %[[res]]
x = reshape(source, sh, pd, ord)
- ! CHECK: fir.call @_FortranAReshape(%[[a8]], %[[a9]], %[[a10]], %[[a11]], %[[a12]], %{{.*}}, %{{.*}}) {{.*}}: (!fir.ref<!fir.box<none>>, !fir.box<none>, !fir.box<none>, !fir.box<none>, !fir.box<none>, !fir.ref<i8>, i32) -> ()
- ! CHECK-DAG: %[[a15:.*]] = fir.load %[[a0]] : !fir.ref<!fir.box<!fir.heap<!fir.array<?x?xi32>>>>
- ! CHECK-DAG: %[[a18:.*]] = fir.box_addr %[[a15]] : (!fir.box<!fir.heap<!fir.array<?x?xi32>>>) -> !fir.heap<!fir.array<?x?xi32>>
- ! CHECK-DAG: fir.freemem %[[a18]]
end subroutine
! CHECK-LABEL: func @_QPtest_reshape_optional(
@@ -34,49 +28,35 @@ subroutine test_reshape_optional(pad, order, source, shape)
real :: source(:, :, :)
integer :: shape(4)
print *, reshape(source=source, shape=shape, pad=pad, order=order)
- ! CHECK: %[[VAL_13:.*]] = fir.load %[[VAL_0]] : !fir.ref<!fir.box<!fir.ptr<!fir.array<?x?xf32>>>>
- ! CHECK: %[[VAL_14:.*]] = fir.box_addr %[[VAL_13]] : (!fir.box<!fir.ptr<!fir.array<?x?xf32>>>) -> !fir.ptr<!fir.array<?x?xf32>>
- ! CHECK: %[[VAL_15:.*]] = fir.convert %[[VAL_14]] : (!fir.ptr<!fir.array<?x?xf32>>) -> i64
- ! CHECK: %[[VAL_16:.*]] = arith.constant 0 : i64
- ! CHECK: %[[VAL_17:.*]] = arith.cmpi ne, %[[VAL_15]], %[[VAL_16]] : i64
- ! CHECK: %[[VAL_18:.*]] = fir.load %[[VAL_0]] : !fir.ref<!fir.box<!fir.ptr<!fir.array<?x?xf32>>>>
- ! CHECK: %[[VAL_19:.*]] = fir.absent !fir.box<!fir.ptr<!fir.array<?x?xf32>>>
- ! CHECK: %[[VAL_20:.*]] = arith.select %[[VAL_17]], %[[VAL_18]], %[[VAL_19]] : !fir.box<!fir.ptr<!fir.array<?x?xf32>>>
- ! CHECK: %[[VAL_21:.*]] = fir.load %[[VAL_1]] : !fir.ref<!fir.box<!fir.ptr<!fir.array<?xi32>>>>
- ! CHECK: %[[VAL_22:.*]] = fir.box_addr %[[VAL_21]] : (!fir.box<!fir.ptr<!fir.array<?xi32>>>) -> !fir.ptr<!fir.array<?xi32>>
- ! CHECK: %[[VAL_23:.*]] = fir.convert %[[VAL_22]] : (!fir.ptr<!fir.array<?xi32>>) -> i64
- ! CHECK: %[[VAL_24:.*]] = arith.constant 0 : i64
- ! CHECK: %[[VAL_25:.*]] = arith.cmpi ne, %[[VAL_23]], %[[VAL_24]] : i64
- ! CHECK: %[[VAL_26:.*]] = fir.load %[[VAL_1]] : !fir.ref<!fir.box<!fir.ptr<!fir.array<?xi32>>>>
- ! CHECK: %[[VAL_27:.*]] = fir.absent !fir.box<!fir.ptr<!fir.array<?xi32>>>
- ! CHECK: %[[VAL_28:.*]] = arith.select %[[VAL_25]], %[[VAL_26]], %[[VAL_27]] : !fir.box<!fir.ptr<!fir.array<?xi32>>>
- ! CHECK: %[[VAL_38:.*]] = fir.convert %[[VAL_20]] : (!fir.box<!fir.ptr<!fir.array<?x?xf32>>>) -> !fir.box<none>
- ! CHECK: %[[VAL_39:.*]] = fir.convert %[[VAL_28]] : (!fir.box<!fir.ptr<!fir.array<?xi32>>>) -> !fir.box<none>
- ! CHECK: fir.call @_FortranAReshape({{.*}}, {{.*}}, %{{.*}}, %[[VAL_38]], %[[VAL_39]], %{{.*}}, %{{.*}}) {{.*}}: (!fir.ref<!fir.box<none>>, !fir.box<none>, !fir.box<none>, !fir.box<none>, !fir.box<none>, !fir.ref<i8>, i32) -> ()
+ ! CHECK-DAG: %[[padDecl:.*]]:2 = hlfir.declare %[[VAL_0]] {{.*}}pad
+ ! CHECK-DAG: %[[orderDecl:.*]]:2 = hlfir.declare %[[VAL_1]] {{.*}}order
+ ! CHECK: %[[padLoad1:.*]] = fir.load %[[padDecl]]#0 : !fir.ref<!fir.box<!fir.ptr<!fir.array<?x?xf32>>>>
+ ! CHECK: %[[padAddr:.*]] = fir.box_addr %[[padLoad1]] : (!fir.box<!fir.ptr<!fir.array<?x?xf32>>>) -> !fir.ptr<!fir.array<?x?xf32>>
+ ! CHECK: %[[padI64:.*]] = fir.convert %[[padAddr]] : (!fir.ptr<!fir.array<?x?xf32>>) -> i64
+ ! CHECK: %[[c0:.*]] = arith.constant 0 : i64
+ ! CHECK: %[[padNonNull:.*]] = arith.cmpi ne, %[[padI64]], %[[c0]] : i64
+ ! CHECK: %[[orderLoad1:.*]] = fir.load %[[orderDecl]]#0 : !fir.ref<!fir.box<!fir.ptr<!fir.array<?xi32>>>>
+ ! CHECK: %[[orderAddr:.*]] = fir.box_addr %[[orderLoad1]] : (!fir.box<!fir.ptr<!fir.array<?xi32>>>) -> !fir.ptr<!fir.array<?xi32>>
+ ! CHECK: %[[orderI64:.*]] = fir.convert %[[orderAddr]] : (!fir.ptr<!fir.array<?xi32>>) -> i64
+ ! CHECK: %[[c0_2:.*]] = arith.constant 0 : i64
+ ! CHECK: %[[orderNonNull:.*]] = arith.cmpi ne, %[[orderI64]], %[[c0_2]] : i64
+ ! CHECK: %[[padLoad2:.*]] = fir.load %[[padDecl]]#0 : !fir.ref<!fir.box<!fir.ptr<!fir.array<?x?xf32>>>>
+ ! CHECK: %[[padAbsent:.*]] = fir.absent !fir.box<!fir.ptr<!fir.array<?x?xf32>>>
+ ! CHECK: %[[padOpt:.*]] = arith.select %[[padNonNull]], %[[padLoad2]], %[[padAbsent]] : !fir.box<!fir.ptr<!fir.array<?x?xf32>>>
+ ! CHECK: %[[orderLoad2:.*]] = fir.load %[[orderDecl]]#0 : !fir.ref<!fir.box<!fir.ptr<!fir.array<?xi32>>>>
+ ! CHECK: %[[orderAbsent:.*]] = fir.absent !fir.box<!fir.ptr<!fir.array<?xi32>>>
+ ! CHECK: %[[orderOpt:.*]] = arith.select %[[orderNonNull]], %[[orderLoad2]], %[[orderAbsent]] : !fir.box<!fir.ptr<!fir.array<?xi32>>>
+ ! CHECK: hlfir.reshape {{.*}} pad %[[padOpt]] order %[[orderOpt]]
end subroutine
! CHECK-LABEL: func.func @_QPtest_reshape_shape_slice() {
-! CHECK: %[[VAL_1:.*]] = fir.address_of(@_QFtest_reshape_shape_sliceEdims) : !fir.ref<!fir.array<4xi32>>
-! CHECK: %[[VAL_2:.*]] = arith.constant 4 : index
-! CHECK: %[[VAL_3:.*]] = fir.address_of(@_QFtest_reshape_shape_sliceEtmp) : !fir.ref<!fir.array<4xf32>>
-! CHECK: %[[VAL_4:.*]] = arith.constant 4 : index
-! CHECK: %[[VAL_5:.*]] = fir.shape %[[VAL_4]] : (index) -> !fir.shape<1>
-! CHECK: %[[VAL_6:.*]] = fir.embox %[[VAL_3]](%[[VAL_5]]) : (!fir.ref<!fir.array<4xf32>>, !fir.shape<1>) -> !fir.box<!fir.array<4xf32>>
-! CHECK: %[[VAL_7:.*]] = arith.constant 1 : i64
-! CHECK: %[[VAL_8:.*]] = fir.convert %[[VAL_7]] : (i64) -> index
-! CHECK: %[[VAL_9:.*]] = arith.constant 1 : i64
-! CHECK: %[[VAL_10:.*]] = fir.convert %[[VAL_9]] : (i64) -> index
-! CHECK: %[[VAL_11:.*]] = arith.constant 2 : i64
-! CHECK: %[[VAL_12:.*]] = fir.convert %[[VAL_11]] : (i64) -> index
-! CHECK: %[[VAL_13:.*]] = fir.shape %[[VAL_2]] : (index) -> !fir.shape<1>
-! CHECK: %[[VAL_14:.*]] = fir.slice %[[VAL_8]], %[[VAL_12]], %[[VAL_10]] : (index, index, index) -> !fir.slice<1>
-! CHECK: %[[VAL_15:.*]] = fir.embox %[[VAL_1]](%[[VAL_13]]) [%[[VAL_14]]] : (!fir.ref<!fir.array<4xi32>>, !fir.shape<1>, !fir.slice<1>) -> !fir.box<!fir.array<2xi32>>
-! CHECK: %[[VAL_25:.*]] = fir.convert %[[VAL_6]] : (!fir.box<!fir.array<4xf32>>) -> !fir.box<none>
-! CHECK: %[[VAL_26:.*]] = fir.convert %[[VAL_15]] : (!fir.box<!fir.array<2xi32>>) -> !fir.box<none>
-! CHECK: fir.call @_FortranAReshape(%{{.*}}, %[[VAL_25]], %[[VAL_26]], %{{.*}}, %{{.*}}, %{{.*}}, %{{.*}}) {{.*}}: (!fir.ref<!fir.box<none>>, !fir.box<none>, !fir.box<none>, !fir.box<none>, !fir.box<none>, !fir.ref<i8>, i32) -> ()
subroutine test_reshape_shape_slice()
integer, parameter :: i = 1
real :: tmp(4) = [1,2,3,4]
integer :: dims(4) = [2,2,2,2]
+ ! CHECK: %[[dimsDecl:.*]]:2 = hlfir.declare {{.*}}{uniq_name = "_QFtest_reshape_shape_sliceEdims"}
+ ! CHECK: %[[tmpDecl:.*]]:2 = hlfir.declare {{.*}}{uniq_name = "_QFtest_reshape_shape_sliceEtmp"}
+ ! CHECK: %[[sliceRef:.*]] = hlfir.designate %[[dimsDecl]]#0 ({{.*}}:{{.*}}:{{.*}})
+ ! CHECK: hlfir.reshape %[[tmpDecl]]#0 %[[sliceRef]]
call some_proc(reshape(tmp, dims(i:2)))
end
>From 107a0cadb8fa9260c760f38dc488ab0f9c163173 Mon Sep 17 00:00:00 2001
From: Eugene Epshteyn <eepshteyn at nvidia.com>
Date: Sun, 29 Mar 2026 22:54:02 -0400
Subject: [PATCH 2/5] Moved kind 10 functionality from product.f90 to its own
file product-kind-10.f90
---
flang/test/Lower/Intrinsics/product-kind-10.f90 | 13 +++++++++++++
flang/test/Lower/Intrinsics/product.f90 | 8 --------
2 files changed, 13 insertions(+), 8 deletions(-)
create mode 100644 flang/test/Lower/Intrinsics/product-kind-10.f90
diff --git a/flang/test/Lower/Intrinsics/product-kind-10.f90 b/flang/test/Lower/Intrinsics/product-kind-10.f90
new file mode 100644
index 0000000000000..7c4b76b5e413b
--- /dev/null
+++ b/flang/test/Lower/Intrinsics/product-kind-10.f90
@@ -0,0 +1,13 @@
+! REQUIRES: x86-registered-target
+! RUN: %flang_fc1 -emit-hlfir %s -o - | FileCheck %s
+
+! This test was extracted from product.f90, since most tests in product.f90 didn't
+! require types specific to x86 platform.
+
+! CHECK-LABEL: func @_QPproduct_test4(
+! CHECK-SAME: %[[arg0:.*]]: !fir.box<!fir.array<?xcomplex<f80>>>{{.*}}) -> complex<f80>
+complex(10) function product_test4(x)
+complex(10):: x(:)
+product_test4 = product(x)
+! CHECK: hlfir.product {{.*}} : (!fir.box<!fir.array<?xcomplex<f80>>>) -> complex<f80>
+end
diff --git a/flang/test/Lower/Intrinsics/product.f90 b/flang/test/Lower/Intrinsics/product.f90
index 0561cf7cda153..88443cfeea298 100644
--- a/flang/test/Lower/Intrinsics/product.f90
+++ b/flang/test/Lower/Intrinsics/product.f90
@@ -29,14 +29,6 @@ subroutine product_test2(a,r)
! CHECK: hlfir.product {{.*}} : (!fir.box<!fir.array<?xcomplex<f32>>>) -> complex<f32>
end function
-! CHECK-LABEL: func @_QPproduct_test4(
-! CHECK-SAME: %[[arg0:.*]]: !fir.box<!fir.array<?xcomplex<f80>>>{{.*}}) -> complex<f80>
-complex(10) function product_test4(x)
-complex(10):: x(:)
-product_test4 = product(x)
-! CHECK: hlfir.product {{.*}} : (!fir.box<!fir.array<?xcomplex<f80>>>) -> complex<f80>
-end
-
! CHECK-LABEL: func @_QPproduct_test_optional(
! CHECK-SAME: %[[VAL_0:.*]]: !fir.box<!fir.array<?x!fir.logical<4>>>
real function product_test_optional(mask, x)
>From 66f0209170a98b9b41d0082cb52720d64850c97e Mon Sep 17 00:00:00 2001
From: Eugene Epshteyn <eepshteyn at nvidia.com>
Date: Sun, 29 Mar 2026 23:11:29 -0400
Subject: [PATCH 3/5] Fix comment typo in product-kind-10.f90
---
flang/test/Lower/Intrinsics/product-kind-10.f90 | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/flang/test/Lower/Intrinsics/product-kind-10.f90 b/flang/test/Lower/Intrinsics/product-kind-10.f90
index 7c4b76b5e413b..28a82e183e9ad 100644
--- a/flang/test/Lower/Intrinsics/product-kind-10.f90
+++ b/flang/test/Lower/Intrinsics/product-kind-10.f90
@@ -2,7 +2,7 @@
! RUN: %flang_fc1 -emit-hlfir %s -o - | FileCheck %s
! This test was extracted from product.f90, since most tests in product.f90 didn't
-! require types specific to x86 platform.
+! need types specific to x86 platform.
! CHECK-LABEL: func @_QPproduct_test4(
! CHECK-SAME: %[[arg0:.*]]: !fir.box<!fir.array<?xcomplex<f80>>>{{.*}}) -> complex<f80>
>From 1631c2ef1b89f34b2700842c8f0063e91d057795 Mon Sep 17 00:00:00 2001
From: Eugene Epshteyn <eepshteyn at nvidia.com>
Date: Mon, 30 Mar 2026 06:40:43 -0400
Subject: [PATCH 4/5] A better fix for product-kind-10.f90 not to fail on ARM
buildbots
---
.../test/Lower/Intrinsics/product-kind-10.f90 | 25 +++++++++++++------
1 file changed, 17 insertions(+), 8 deletions(-)
diff --git a/flang/test/Lower/Intrinsics/product-kind-10.f90 b/flang/test/Lower/Intrinsics/product-kind-10.f90
index 28a82e183e9ad..edad3a01515b6 100644
--- a/flang/test/Lower/Intrinsics/product-kind-10.f90
+++ b/flang/test/Lower/Intrinsics/product-kind-10.f90
@@ -1,13 +1,22 @@
-! REQUIRES: x86-registered-target
-! RUN: %flang_fc1 -emit-hlfir %s -o - | FileCheck %s
+! RUN: %flang_fc1 -emit-hlfir %s -o - | FileCheck %s --check-prefixes=CHECK%if target=x86_64{{.*}} %{,CHECK-KIND10%}
! This test was extracted from product.f90, since most tests in product.f90 didn't
! need types specific to x86 platform.
+! Note: originally, the test used 'REQUIRES: x86-registered-target' to try to
+! avoid running on platforms that don't support kind 10. Unfortunately, this
+! checks if the x86 backend was compiled into LLVM, not whether the host is x86.
+! On ARM CI machines with multi-target LLVM builds, this feature is set to true,
+! so the test runs — but COMPLEX(KIND=10) (f80) is unsupported on ARM, causing
+! a semantic error. For that reason, change this test to support CHECK-KIND10
+! mechanism. The same mechanism is used by nearest.f90 and sum.f90, for example.
+
! CHECK-LABEL: func @_QPproduct_test4(
-! CHECK-SAME: %[[arg0:.*]]: !fir.box<!fir.array<?xcomplex<f80>>>{{.*}}) -> complex<f80>
-complex(10) function product_test4(x)
-complex(10):: x(:)
-product_test4 = product(x)
-! CHECK: hlfir.product {{.*}} : (!fir.box<!fir.array<?xcomplex<f80>>>) -> complex<f80>
-end
+! CHECK-KIND10-SAME: %[[arg0:.*]]: !fir.box<!fir.array<?xcomplex<f80>>>{{.*}}) -> complex<f80>
+function product_test4(x)
+ integer, parameter :: kind10 = merge(10, 4, selected_real_kind(p=18).eq.10)
+ complex(kind10) :: product_test4
+ complex(kind10):: x(:)
+ product_test4 = product(x)
+! CHECK-KIND10: hlfir.product {{.*}} : (!fir.box<!fir.array<?xcomplex<f80>>>) -> complex<f80>
+end function
>From fe321eef5a88033afb31421d62b3b7a06dfbffec Mon Sep 17 00:00:00 2001
From: Eugene Epshteyn <eepshteyn at nvidia.com>
Date: Mon, 30 Mar 2026 07:59:56 -0400
Subject: [PATCH 5/5] Remove 'REQUIRES:' from the middle of the comments,
because it's checked by LIT even there!
---
flang/test/Lower/Intrinsics/product-kind-10.f90 | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/flang/test/Lower/Intrinsics/product-kind-10.f90 b/flang/test/Lower/Intrinsics/product-kind-10.f90
index edad3a01515b6..5a98a0900f464 100644
--- a/flang/test/Lower/Intrinsics/product-kind-10.f90
+++ b/flang/test/Lower/Intrinsics/product-kind-10.f90
@@ -3,13 +3,14 @@
! This test was extracted from product.f90, since most tests in product.f90 didn't
! need types specific to x86 platform.
-! Note: originally, the test used 'REQUIRES: x86-registered-target' to try to
-! avoid running on platforms that don't support kind 10. Unfortunately, this
-! checks if the x86 backend was compiled into LLVM, not whether the host is x86.
-! On ARM CI machines with multi-target LLVM builds, this feature is set to true,
-! so the test runs — but COMPLEX(KIND=10) (f80) is unsupported on ARM, causing
-! a semantic error. For that reason, change this test to support CHECK-KIND10
-! mechanism. The same mechanism is used by nearest.f90 and sum.f90, for example.
+! Note: originally, the test used 'REQUIRES' directive for
+! x86-registered-target' to try to avoid running on platforms that don't
+! support kind 10. Unfortunately, this checks if the x86 backend was compiled
+! into LLVM, not whether the host is x86. On ARM CI machines with multi-target
+! LLVM builds, this feature is set to true, so the test runs. With
+! COMPLEX(KIND=10) (f80) not unsupported on ARM, this caused a semantic error.
+! For this reason, change this test to support CHECK-KIND10 mechanism. (The
+! same mechanism is used by nearest.f90 and sum.f90 tests.)
! CHECK-LABEL: func @_QPproduct_test4(
! CHECK-KIND10-SAME: %[[arg0:.*]]: !fir.box<!fir.array<?xcomplex<f80>>>{{.*}}) -> complex<f80>
More information about the flang-commits
mailing list