-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[flang][NFC] do not hard code KIND 10 and 16 in lowering tests #124966
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
KIND 10 and 16 are platform dependent and it will soon be a hard error to use them when not available. Update some tests that used them to use SELECTED_REAL_KIND + lit conditional checks to make the tests usable on all platform. Also update all those tests to use HFLIR lowering while modifying them.
@llvm/pr-subscribers-flang-openmp @llvm/pr-subscribers-flang-fir-hlfir Author: None (jeanPerier) ChangesKIND 10 and 16 are platform dependent and it will soon be a hard error to use them when not available (#124655) Update some tests that used them to use SELECTED_REAL_KIND + lit conditional checks to make the tests usable on all platform. Also update all those tests to use HFLIR lowering while modifying them since the goal is to remove the legacy lowering at some point. Patch is 136.21 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/124966.diff 23 Files Affected:
diff --git a/flang/test/Lower/Intrinsics/aint.f90 b/flang/test/Lower/Intrinsics/aint.f90
index fb459953a06c3f..da5e6fde8fffc4 100644
--- a/flang/test/Lower/Intrinsics/aint.f90
+++ b/flang/test/Lower/Intrinsics/aint.f90
@@ -1,41 +1,31 @@
-! RUN: bbc -emit-fir -hlfir=false %s -o - | FileCheck %s
+! RUN: bbc -emit-hlfir %s -o - | FileCheck %s --check-prefixes=CHECK%if target=x86_64{{.*}} %{,CHECK-KIND10%}
! CHECK-LABEL: func @_QPaint_test(
-! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<f32>{{.*}}, %[[VAL_1:.*]]: !fir.ref<f32>{{.*}}) {
+! CHECK-SAME: %[[VAL_0_b:.*]]: !fir.ref<f32>{{.*}}, %[[VAL_1_b:.*]]: !fir.ref<f32>{{.*}}) {
subroutine aint_test(a, b)
-! CHECK: %[[VAL_2:.*]] = fir.load %[[VAL_0]] : !fir.ref<f32>
+! CHECK: %[[VAL_0:.*]]:2 = hlfir.declare %[[VAL_0_b]]
+! CHECK: %[[VAL_1:.*]]:2 = hlfir.declare %[[VAL_1_b]]
+! CHECK: %[[VAL_2:.*]] = fir.load %[[VAL_0]]#0 : !fir.ref<f32>
! CHECK: %[[VAL_3:.*]] = fir.call @llvm.trunc.f32(%[[VAL_2]]) {{.*}}: (f32) -> f32
-! CHECK: fir.store %[[VAL_3]] to %[[VAL_1]] : !fir.ref<f32>
+! CHECK: hlfir.assign %[[VAL_3]] to %[[VAL_1]]#0 : f32, !fir.ref<f32>
! CHECK: return
real :: a, b
b = aint(a)
end subroutine
! CHECK-LABEL: func.func @_QPaint_test_real8(
-! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<f64> {fir.bindc_name = "a"},
-! CHECK-SAME: %[[VAL_1:.*]]: !fir.ref<f64> {fir.bindc_name = "b"}) {
-! CHECK: %[[VAL_2:.*]] = fir.load %[[VAL_0]] : !fir.ref<f64>
-! CHECK: %[[VAL_3:.*]] = fir.call @llvm.trunc.f64(%[[VAL_2]]) {{.*}}: (f64) -> f64
-! CHECK: fir.store %[[VAL_3]] to %[[VAL_1]] : !fir.ref<f64>
-! CHECK: return
-! CHECK: }
+! CHECK: fir.call @llvm.trunc.f64({{.*}}) {{.*}}: (f64) -> f64
subroutine aint_test_real8(a, b)
real(8) :: a, b
b = aint(a)
end subroutine
-! CHECK-LABEL: func.func @_QPaint_test_real10(
-! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<f80> {fir.bindc_name = "a"},
-! CHECK-SAME: %[[VAL_1:.*]]: !fir.ref<f80> {fir.bindc_name = "b"}) {
-! CHECK: %[[VAL_2:.*]] = fir.load %[[VAL_0]] : !fir.ref<f80>
-! CHECK: %[[VAL_3:.*]] = fir.call @llvm.trunc.f80(%[[VAL_2]]) {{.*}}: (f80) -> f80
-! CHECK: fir.store %[[VAL_3]] to %[[VAL_1]] : !fir.ref<f80>
-! CHECK: return
-! CHECK: }
-
+! CHECK-KIND10-LABEL: func.func @_QPaint_test_real10(
+! CHECK-KIND10: fir.call @llvm.trunc.f64({{.*}}) {{.*}}: (f80) -> f80
subroutine aint_test_real10(a, b)
- real(10) :: a, b
+ integer, parameter :: kind10 = merge(10, 4, selected_real_kind(p=18).eq.10)
+ real(kind10) :: a, b
b = aint(a)
end subroutine
diff --git a/flang/test/Lower/Intrinsics/anint.f90 b/flang/test/Lower/Intrinsics/anint.f90
index 4148d18f15b30d..a7b24648ca0b6e 100644
--- a/flang/test/Lower/Intrinsics/anint.f90
+++ b/flang/test/Lower/Intrinsics/anint.f90
@@ -1,11 +1,13 @@
-! RUN: bbc -emit-fir -hlfir=false %s -o - | FileCheck %s
+! RUN: bbc -emit-hlfir %s -o - | FileCheck %s --check-prefixes=CHECK%if target=x86_64{{.*}} %{,CHECK-KIND10%}
! CHECK-LABEL: func.func @_QPanint_test(
-! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<f32> {fir.bindc_name = "a"},
-! CHECK-SAME: %[[VAL_1:.*]]: !fir.ref<f32> {fir.bindc_name = "b"}) {
-! CHECK: %[[VAL_2:.*]] = fir.load %[[VAL_0]] : !fir.ref<f32>
+! CHECK-SAME: %[[VAL_0_b:.*]]: !fir.ref<f32> {fir.bindc_name = "a"},
+! CHECK-SAME: %[[VAL_1_b:.*]]: !fir.ref<f32> {fir.bindc_name = "b"}) {
+! CHECK: %[[VAL_0:.*]]:2 = hlfir.declare %[[VAL_0_b]]
+! CHECK: %[[VAL_1:.*]]:2 = hlfir.declare %[[VAL_1_b]]
+! CHECK: %[[VAL_2:.*]] = fir.load %[[VAL_0]]#0 : !fir.ref<f32>
! CHECK: %[[VAL_3:.*]] = llvm.intr.round(%[[VAL_2]]) : (f32) -> f32
-! CHECK: fir.store %[[VAL_3]] to %[[VAL_1]] : !fir.ref<f32>
+! CHECK: hlfir.assign %[[VAL_3]] to %[[VAL_1]]#0 : f32, !fir.ref<f32>
! CHECK: return
! CHECK: }
@@ -15,30 +17,19 @@ subroutine anint_test(a, b)
end subroutine
! CHECK-LABEL: func.func @_QPanint_test_real8(
-! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<f64> {fir.bindc_name = "a"},
-! CHECK-SAME: %[[VAL_1:.*]]: !fir.ref<f64> {fir.bindc_name = "b"}) {
-! CHECK: %[[VAL_2:.*]] = fir.load %[[VAL_0]] : !fir.ref<f64>
-! CHECK: %[[VAL_3:.*]] = llvm.intr.round(%[[VAL_2]]) : (f64) -> f64
-! CHECK: fir.store %[[VAL_3]] to %[[VAL_1]] : !fir.ref<f64>
-! CHECK: return
-! CHECK: }
+! CHECK: llvm.intr.round(%{{.*}}) : (f64) -> f64
subroutine anint_test_real8(a, b)
real(8) :: a, b
b = anint(a)
end subroutine
-! CHECK-LABEL: func.func @_QPanint_test_real10(
-! CHECK-SAME: %[[VAL_0:.*]]: !fir.ref<f80> {fir.bindc_name = "a"},
-! CHECK-SAME: %[[VAL_1:.*]]: !fir.ref<f80> {fir.bindc_name = "b"}) {
-! CHECK: %[[VAL_2:.*]] = fir.load %[[VAL_0]] : !fir.ref<f80>
-! CHECK: %[[VAL_3:.*]] = llvm.intr.round(%[[VAL_2]]) : (f80) -> f80
-! CHECK: fir.store %[[VAL_3]] to %[[VAL_1]] : !fir.ref<f80>
-! CHECK: return
-! CHECK: }
+! CHECK-KIND10-LABEL: func.func @_QPanint_test_real10(
+! CHECK-KIND10: llvm.intr.round(%{{.*}}) : (f80) -> f80
subroutine anint_test_real10(a, b)
- real(10) :: a, b
+ integer, parameter :: kind10 = merge(10, 4, selected_real_kind(p=18).eq.10)
+ real(kind10) :: a, b
b = anint(a)
end subroutine
diff --git a/flang/test/Lower/Intrinsics/dot_product.f90 b/flang/test/Lower/Intrinsics/dot_product.f90
index 9a825c4b9acf19..62694a70555df5 100644
--- a/flang/test/Lower/Intrinsics/dot_product.f90
+++ b/flang/test/Lower/Intrinsics/dot_product.f90
@@ -1,14 +1,16 @@
-! 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-fir -O0 %s -o - | FileCheck %s --check-prefixes=CHECK%if target=x86_64{{.*}} %{,CHECK-KIND10%}%if flang-supports-f128-math %{,CHECK-KIND16%}
! DOT_PROD
! CHECK-LABEL: dot_prod_int_default
-! CHECK-SAME: %[[x:arg0]]: !fir.box<!fir.array<?xi32>>
-! CHECK-SAME: %[[y:arg1]]: !fir.box<!fir.array<?xi32>>
-! CHECK-SAME: %[[z:arg2]]: !fir.box<!fir.array<?xi32>>
subroutine dot_prod_int_default (x, y, z)
integer, dimension(1:) :: x,y
integer, dimension(1:) :: z
+ ! CHECK: %[[x1:.*]] = fir.declare{{.*}}x"
+ ! CHECK: %[[x:.*]] = fir.rebox %[[x1]]{{.*}}
+ ! CHECK: %[[y1:.*]] = fir.declare{{.*}}y"
+ ! CHECK: %[[y:.*]] = fir.rebox %[[y1]]{{.*}}
+ ! CHECK: %[[z1:.*]] = fir.declare{{.*}}z"
+ ! CHECK: %[[z:.*]] = fir.rebox %[[z1]]{{.*}}
! CHECK-DAG: %[[x_conv:.*]] = fir.convert %[[x]] : (!fir.box<!fir.array<?xi32>>) -> !fir.box<none>
! CHECK-DAG: %[[y_conv:.*]] = fir.convert %[[y]] : (!fir.box<!fir.array<?xi32>>) -> !fir.box<none>
! CHECK-DAG: %[[res:.*]] = fir.call @_FortranADotProductInteger4(%[[x_conv]], %[[y_conv]], %{{[0-9]+}}, %{{.*}}) {{.*}}: (!fir.box<none>, !fir.box<none>, !fir.ref<i8>, i32) -> i32
@@ -16,268 +18,172 @@ subroutine dot_prod_int_default (x, y, z)
end subroutine
! CHECK-LABEL: dot_prod_int_kind_1
-! CHECK-SAME: %[[x:arg0]]: !fir.box<!fir.array<?xi8>>
-! CHECK-SAME: %[[y:arg1]]: !fir.box<!fir.array<?xi8>>
-! CHECK-SAME: %[[z:arg2]]: !fir.box<!fir.array<?xi8>>
subroutine dot_prod_int_kind_1 (x, y, z)
integer(kind=1), dimension(1:) :: x,y
integer(kind=1), dimension(1:) :: z
- ! CHECK-DAG: %[[x_conv:.*]] = fir.convert %[[x]] : (!fir.box<!fir.array<?xi8>>) -> !fir.box<none>
- ! CHECK-DAG: %[[y_conv:.*]] = fir.convert %[[y]] : (!fir.box<!fir.array<?xi8>>) -> !fir.box<none>
- ! CHECK-DAG: %[[res:.*]] = fir.call @_FortranADotProductInteger1(%[[x_conv]], %[[y_conv]], %{{[0-9]+}}, %{{.*}}) {{.*}}: (!fir.box<none>, !fir.box<none>, !fir.ref<i8>, i32) -> i8
+ ! CHECK: fir.call @_FortranADotProductInteger1(%{{.*}}, %{{.*}}, %{{[0-9]+}}, %{{.*}}) {{.*}}: (!fir.box<none>, !fir.box<none>, !fir.ref<i8>, i32) -> i8
z = dot_product(x,y)
end subroutine
! CHECK-LABEL: dot_prod_int_kind_2
-! CHECK-SAME: %[[x:arg0]]: !fir.box<!fir.array<?xi16>>
-! CHECK-SAME: %[[y:arg1]]: !fir.box<!fir.array<?xi16>>
-! CHECK-SAME: %[[z:arg2]]: !fir.box<!fir.array<?xi16>>
subroutine dot_prod_int_kind_2 (x, y, z)
integer(kind=2), dimension(1:) :: x,y
integer(kind=2), dimension(1:) :: z
- ! CHECK-DAG: %[[x_conv:.*]] = fir.convert %[[x]] : (!fir.box<!fir.array<?xi16>>) -> !fir.box<none>
- ! CHECK-DAG: %[[y_conv:.*]] = fir.convert %[[y]] : (!fir.box<!fir.array<?xi16>>) -> !fir.box<none>
- ! CHECK-DAG: %[[res:.*]] = fir.call @_FortranADotProductInteger2(%[[x_conv]], %[[y_conv]], %{{[0-9]+}}, %{{.*}}) {{.*}}: (!fir.box<none>, !fir.box<none>, !fir.ref<i8>, i32) -> i16
+ ! CHECK: fir.call @_FortranADotProductInteger2(%{{.*}}, %{{.*}}, %{{[0-9]+}}, %{{.*}}) {{.*}}: (!fir.box<none>, !fir.box<none>, !fir.ref<i8>, i32) -> i16
z = dot_product(x,y)
end subroutine
! CHECK-LABEL: dot_prod_int_kind_4
-! CHECK-SAME: %[[x:arg0]]: !fir.box<!fir.array<?xi32>>
-! CHECK-SAME: %[[y:arg1]]: !fir.box<!fir.array<?xi32>>
-! CHECK-SAME: %[[z:arg2]]: !fir.box<!fir.array<?xi32>>
subroutine dot_prod_int_kind_4 (x, y, z)
integer(kind=4), dimension(1:) :: x,y
integer(kind=4), dimension(1:) :: z
- ! CHECK-DAG: %[[x_conv:.*]] = fir.convert %[[x]] : (!fir.box<!fir.array<?xi32>>) -> !fir.box<none>
- ! CHECK-DAG: %[[y_conv:.*]] = fir.convert %[[y]] : (!fir.box<!fir.array<?xi32>>) -> !fir.box<none>
- ! CHECK-DAG: %[[res:.*]] = fir.call @_FortranADotProductInteger4(%[[x_conv]], %[[y_conv]], %{{[0-9]+}}, %{{.*}}) {{.*}}: (!fir.box<none>, !fir.box<none>, !fir.ref<i8>, i32) -> i32
+ ! CHECK: fir.call @_FortranADotProductInteger4(%{{.*}}, %{{.*}}, %{{[0-9]+}}, %{{.*}}) {{.*}}: (!fir.box<none>, !fir.box<none>, !fir.ref<i8>, i32) -> i32
z = dot_product(x,y)
end subroutine
! CHECK-LABEL: dot_prod_int_kind_8
-! CHECK-SAME: %[[x:arg0]]: !fir.box<!fir.array<?xi64>>
-! CHECK-SAME: %[[y:arg1]]: !fir.box<!fir.array<?xi64>>
-! CHECK-SAME: %[[z:arg2]]: !fir.box<!fir.array<?xi64>>
subroutine dot_prod_int_kind_8 (x, y, z)
integer(kind=8), dimension(1:) :: x,y
integer(kind=8), dimension(1:) :: z
- ! CHECK-DAG: %[[x_conv:.*]] = fir.convert %[[x]] : (!fir.box<!fir.array<?xi64>>) -> !fir.box<none>
- ! CHECK-DAG: %[[y_conv:.*]] = fir.convert %[[y]] : (!fir.box<!fir.array<?xi64>>) -> !fir.box<none>
- ! CHECK-DAG: %[[res:.*]] = fir.call @_FortranADotProductInteger8(%[[x_conv]], %[[y_conv]], %{{[0-9]+}}, %{{.*}}) {{.*}}: (!fir.box<none>, !fir.box<none>, !fir.ref<i8>, i32) -> i64
+ ! CHECK: fir.call @_FortranADotProductInteger8(%{{.*}}, %{{.*}}, %{{[0-9]+}}, %{{.*}}) {{.*}}: (!fir.box<none>, !fir.box<none>, !fir.ref<i8>, i32) -> i64
z = dot_product(x,y)
end subroutine
! CHECK-LABEL: dot_prod_int_kind_16
-! CHECK-SAME: %[[x:arg0]]: !fir.box<!fir.array<?xi128>>
-! CHECK-SAME: %[[y:arg1]]: !fir.box<!fir.array<?xi128>>
-! CHECK-SAME: %[[z:arg2]]: !fir.box<!fir.array<?xi128>>
subroutine dot_prod_int_kind_16 (x, y, z)
integer(kind=16), dimension(1:) :: x,y
integer(kind=16), dimension(1:) :: z
- ! CHECK-DAG: %[[x_conv:.*]] = fir.convert %[[x]] : (!fir.box<!fir.array<?xi128>>) -> !fir.box<none>
- ! CHECK-DAG: %[[y_conv:.*]] = fir.convert %[[y]] : (!fir.box<!fir.array<?xi128>>) -> !fir.box<none>
- ! CHECK-DAG: %[[res:.*]] = fir.call @_FortranADotProductInteger16(%[[x_conv]], %[[y_conv]], %{{[0-9]+}}, %{{.*}}) {{.*}}: (!fir.box<none>, !fir.box<none>, !fir.ref<i8>, i32) -> i128
+ ! CHECK: fir.call @_FortranADotProductInteger16(%{{.*}}, %{{.*}}, %{{[0-9]+}}, %{{.*}}) {{.*}}: (!fir.box<none>, !fir.box<none>, !fir.ref<i8>, i32) -> i128
z = dot_product(x,y)
end subroutine
! CHECK-LABEL: dot_prod_real_kind_default
-! CHECK-SAME: %[[x:arg0]]: !fir.box<!fir.array<?xf32>>
-! CHECK-SAME: %[[y:arg1]]: !fir.box<!fir.array<?xf32>>
-! CHECK-SAME: %[[z:arg2]]: !fir.box<!fir.array<?xf32>>
subroutine dot_prod_real_kind_default (x, y, z)
real, dimension(1:) :: x,y
real, dimension(1:) :: z
- ! CHECK-DAG: %[[x_conv:.*]] = fir.convert %[[x]] : (!fir.box<!fir.array<?xf32>>) -> !fir.box<none>
- ! CHECK-DAG: %[[y_conv:.*]] = fir.convert %[[y]] : (!fir.box<!fir.array<?xf32>>) -> !fir.box<none>
- ! CHECK-DAG: %[[res:.*]] = fir.call @_FortranADotProductReal4(%[[x_conv]], %[[y_conv]], %{{[0-9]+}}, %{{.*}}) {{.*}}: (!fir.box<none>, !fir.box<none>, !fir.ref<i8>, i32) -> f32
+ ! CHECK: fir.call @_FortranADotProductReal4(%{{.*}}, %{{.*}}, %{{[0-9]+}}, %{{.*}}) {{.*}}: (!fir.box<none>, !fir.box<none>, !fir.ref<i8>, i32) -> f32
z = dot_product(x,y)
end subroutine
! CHECK-LABEL: dot_prod_real_kind_4
-! CHECK-SAME: %[[x:arg0]]: !fir.box<!fir.array<?xf32>>
-! CHECK-SAME: %[[y:arg1]]: !fir.box<!fir.array<?xf32>>
-! CHECK-SAME: %[[z:arg2]]: !fir.box<!fir.array<?xf32>>
subroutine dot_prod_real_kind_4 (x, y, z)
real(kind=4), dimension(1:) :: x,y
real(kind=4), dimension(1:) :: z
- ! CHECK-DAG: %[[x_conv:.*]] = fir.convert %[[x]] : (!fir.box<!fir.array<?xf32>>) -> !fir.box<none>
- ! CHECK-DAG: %[[y_conv:.*]] = fir.convert %[[y]] : (!fir.box<!fir.array<?xf32>>) -> !fir.box<none>
- ! CHECK-DAG: %[[res:.*]] = fir.call @_FortranADotProductReal4(%[[x_conv]], %[[y_conv]], %{{[0-9]+}}, %{{.*}}) {{.*}}: (!fir.box<none>, !fir.box<none>, !fir.ref<i8>, i32) -> f32
+ ! CHECK: fir.call @_FortranADotProductReal4(%{{.*}}, %{{.*}}, %{{[0-9]+}}, %{{.*}}) {{.*}}: (!fir.box<none>, !fir.box<none>, !fir.ref<i8>, i32) -> f32
z = dot_product(x,y)
end subroutine
! CHECK-LABEL: dot_prod_real_kind_8
-! CHECK-SAME: %[[x:arg0]]: !fir.box<!fir.array<?xf64>>
-! CHECK-SAME: %[[y:arg1]]: !fir.box<!fir.array<?xf64>>
-! CHECK-SAME: %[[z:arg2]]: !fir.box<!fir.array<?xf64>>
subroutine dot_prod_real_kind_8 (x, y, z)
real(kind=8), dimension(1:) :: x,y
real(kind=8), dimension(1:) :: z
- ! CHECK-DAG: %[[x_conv:.*]] = fir.convert %[[x]] : (!fir.box<!fir.array<?xf64>>) -> !fir.box<none>
- ! CHECK-DAG: %[[y_conv:.*]] = fir.convert %[[y]] : (!fir.box<!fir.array<?xf64>>) -> !fir.box<none>
- ! CHECK-DAG: %[[res:.*]] = fir.call @_FortranADotProductReal8(%[[x_conv]], %[[y_conv]], %{{[0-9]+}}, %{{.*}}) {{.*}}: (!fir.box<none>, !fir.box<none>, !fir.ref<i8>, i32) -> f64
+ ! CHECK: fir.call @_FortranADotProductReal8(%{{.*}}, %{{.*}}, %{{[0-9]+}}, %{{.*}}) {{.*}}: (!fir.box<none>, !fir.box<none>, !fir.ref<i8>, i32) -> f64
z = dot_product(x,y)
end subroutine
-! CHECK-LABEL: dot_prod_real_kind_10
-! CHECK-SAME: %[[x:arg0]]: !fir.box<!fir.array<?xf80>>
-! CHECK-SAME: %[[y:arg1]]: !fir.box<!fir.array<?xf80>>
-! CHECK-SAME: %[[z:arg2]]: !fir.box<!fir.array<?xf80>>
+! CHECK-KIND10-LABEL: dot_prod_real_kind_10
subroutine dot_prod_real_kind_10 (x, y, z)
- real(kind=10), dimension(1:) :: x,y
- real(kind=10), dimension(1:) :: z
- ! CHECK-DAG: %[[x_conv:.*]] = fir.convert %[[x]] : (!fir.box<!fir.array<?xf80>>) -> !fir.box<none>
- ! CHECK-DAG: %[[y_conv:.*]] = fir.convert %[[y]] : (!fir.box<!fir.array<?xf80>>) -> !fir.box<none>
- ! CHECK-DAG: %[[res:.*]] = fir.call @_FortranADotProductReal10(%[[x_conv]], %[[y_conv]], %{{[0-9]+}}, %{{.*}}) {{.*}}: (!fir.box<none>, !fir.box<none>, !fir.ref<i8>, i32) -> f80
+ integer, parameter :: kind10 = merge(10, 4, selected_real_kind(p=18).eq.10)
+ real(kind=kind10), dimension(1:) :: x,y
+ real(kind=kind10), dimension(1:) :: z
+ ! CHECK-KIND10: fir.call @_FortranADotProductReal10(%{{.*}}, %{{.*}}, %{{[0-9]+}}, %{{.*}}) {{.*}}: (!fir.box<none>, !fir.box<none>, !fir.ref<i8>, i32) -> f80
z = dot_product(x,y)
end subroutine
-! CHECK-LABEL: dot_prod_real_kind_16
-! CHECK-SAME: %[[x:arg0]]: !fir.box<!fir.array<?xf128>>
-! CHECK-SAME: %[[y:arg1]]: !fir.box<!fir.array<?xf128>>
-! CHECK-SAME: %[[z:arg2]]: !fir.box<!fir.array<?xf128>>
+! CHECK-KIND16-LABEL: dot_prod_real_kind_16
subroutine dot_prod_real_kind_16 (x, y, z)
- real(kind=16), dimension(1:) :: x,y
- real(kind=16), dimension(1:) :: z
- ! CHECK-DAG: %[[x_conv:.*]] = fir.convert %[[x]] : (!fir.box<!fir.array<?xf128>>) -> !fir.box<none>
- ! CHECK-DAG: %[[y_conv:.*]] = fir.convert %[[y]] : (!fir.box<!fir.array<?xf128>>) -> !fir.box<none>
- ! CHECK-DAG: %[[res:.*]] = fir.call @_FortranADotProductReal16(%[[x_conv]], %[[y_conv]], %{{[0-9]+}}, %{{.*}}) {{.*}}: (!fir.box<none>, !fir.box<none>, !fir.ref<i8>, i32) -> f128
+ integer, parameter :: kind16 = merge(16, 4, selected_real_kind(p=33).eq.16)
+ real(kind=kind16), dimension(1:) :: x,y
+ real(kind=kind16), dimension(1:) :: z
+ ! CHECK-KIND16: fir.call @_FortranADotProductReal16(%{{.*}}, %{{.*}}, %{{[0-9]+}}, %{{.*}}) {{.*}}: (!fir.box<none>, !fir.box<none>, !fir.ref<i8>, i32) -> f128
z = dot_product(x,y)
end subroutine
! CHECK-LABEL: dot_prod_double_default
-! CHECK-SAME: %[[x:arg0]]: !fir.box<!fir.array<?xf64>>
-! CHECK-SAME: %[[y:arg1]]: !fir.box<!fir.array<?xf64>>
-! CHECK-SAME: %[[z:arg2]]: !fir.box<!fir.array<?xf64>>
subroutine dot_prod_double_default (x, y, z)
double precision, dimension(1:) :: x,y
double precision, dimension(1:) :: z
- ! CHECK-DAG: %[[x_conv:.*]] = fir.convert %[[x]] : (!fir.box<!fir.array<?xf64>>) -> !fir.box<none>
- ! CHECK-DAG: %[[y_conv:.*]] = fir.convert %[[y]] : (!fir.box<!fir.array<?xf64>>) -> !fir.box<none>
- ! CHECK-DAG: %[[res:.*]] = fir.call @_FortranADotProductReal8(%[[x_conv]], %[[y_conv]], %{{[0-9]+}}, %{{.*}}) {{.*}}: (!fir.box<none>, !fir.box<none>, !fir.ref<i8>, i32) -> f64
+ ! CHECK: fir.call @_FortranADotProductReal8(%{{.*}}, %{{.*}}, %{{[0-9]+}}, %{{.*}}) {{.*}}: (!fir.box<none>, !fir.box<none>, !fir.ref<i8>, i32) -> f64
z = dot_product(x,y)
end subroutine
! CHECK-LABEL: dot_prod_complex_default
-! CHECK-SAME: %[[x:arg0]]: !fir.box<!fir.array<?xcomplex<f32>>>
-! CHECK-SAME: %[[y:arg1]]: !fir.box<!fir.array<?xcomplex<f32>>>
-! CHECK-SAME: %[[z:arg2]]: !fir.box<!fir.array<?xcomplex<f32>>>
subroutine dot_prod_complex_default (x, y, z)
complex, dimension(1:) :: x,y
complex, dimension(1:) :: z
- ! CHECK-DAG: %[[res:.*]] = fir.alloca complex<f32>
- ! CHECK-DAG: %[[x_conv:.*]] = fir.convert %[[x]] : (!fir.box<!fir.array<?xcomplex<f32>>>) -> !fir.box<none>
- ! CHECK-DAG: %[[y_conv:.*]] = fir.convert %[[y]] : (!fir.box<!fir.array<?xcomplex<f32>>>) -> !fir.box<none>
- ! CHECK-DAG: fir.call @_FortranACppDotProductComplex4(%[[res]], %[[x_conv]], %[[y_conv]], %{{[0-9]+}}, %{{.*}}) {{.*}}: (!fir.ref<complex<f32>>, !fir.box<none>, !fir.box<none>, !fir.ref<i8>, i32) -> ()
+ ! CHECK: %[[res:.*]] = fir.alloca complex<f32>
+ ! CHECK: fir.call @_FortranACppDotProductComplex4(%[[res]], %{{.*}}, %{{.*}}, %{{[0-9]+}}, %{{.*}}) {{.*}}: (!fir.ref<complex<f32>>, !fir.box<none>, !fir.box<none>, !fir.ref<i8>, i32) -> ()
z = dot_product(x,y)
end subroutine
! CHECK-LABEL: dot_prod_complex_kind_4
-! CHECK-SAME: %[[x:arg0]]: !fir.box<!fir.array<?xcomplex<f32>>>
-! CHECK-SAME: %[[y:arg1]]: !fir.box<!fir.array<?xcomplex<f32>>>
-! CHECK-SAME: %[[z:arg2]]: !fir.box<!fir.array<?xcomplex<f32>>>
subroutine dot_prod_complex_kind_4 (x, y, z)
complex(kind=4), dimension(1:) :: x,y
complex(kind=4), dimension(1:) :: z
- ! CHECK-DAG: %[[res:.*]] = fir.alloca complex<f32>
- ! CHECK-DAG: %[[x_conv:.*]] = fir.convert %[[x]] : (!fir.box<!fir.array<?xcomplex<f32>>>) -> !fir.box<none>
- ! CHECK-DAG: %[[y_conv:.*]] = fir.convert %[[y]] : (!fir.box<!fir.array<?xcomplex<f32>>>) -> !fir.box<none>
- ! CHECK-DAG: fir.call @_FortranACppDotProductComplex4(%[[res]], %[[x_conv]], %[[y_conv]], %{{[0-9]+}}, %{{.*}}) {{.*}}: (!fir.ref<complex<f32>>, !fir.box<none>, !fir.box<none>, !fir.ref<i8>, i32) -> ()
+ ! CHECK: %[[res:.*]] = fir.alloca complex<f32>
+ ! CHECK: fir.call @_FortranACppDotProductComplex4(%[[res]], %{{.*}}, %{{.*}}, %{{[0-9]+}}, %{{.*}}) {{.*}}: (!fir.ref<complex<f32>>, !fir.box<none>, !fir.box<none>, !fir.ref<i8>, i32) -> ()
z = dot_product(x,y)
end subroutine
! CHECK-LABEL: dot_prod_complex_kind_8
-! CHECK-SAME: %[[x:arg0]]: !fir.box<!fir.array<?xcomplex<f64>>>
-! CHECK-SAME: %[[y:arg1]]: !fir.box<!fir.array<?xcomplex<f64>>>
-! CHECK-SAME: %[[z:arg2]]: !fir.box<!fir.array<?xcomplex<f64>>>
subroutine dot_prod_complex_kind_8 (x, y, z)
complex(kind=8), dimension(1:) :: x,y
complex(kind=8), dimension(1:) :: z
- ! CHECK-DAG: %[[res:.*]] = fir.alloca complex<f64>
- ! CHECK-DAG: %[[x_conv:.*]] = fir.convert %[[x]] : (!fir.box<!fir.array<?xcomplex<f64>>>) -> !fir.box<none>
- ! CHECK-DAG: %[[y_conv:...
[truncated]
|
I tested on ppc64le-*-linux and found a failure.
|
subroutine aint_test_real10(a, b) | ||
real(10) :: a, b | ||
integer, parameter :: kind10 = merge(10, 4, selected_real_kind(p=18).eq.10) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oooh, that's clever!
I do have a question: why use minimal kind as 4 and not 8? Kind 10 was a special kind for fp80, right? So fp64 seems to be closer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The goal is just to get some KIND that will compile so that the rest of the tests in the files work, the kind does not really matter (the IR is not tested when 10 is not selected). I took 4 because that is our default kind.
I could also have used ifdefs, but that requires preprocessing and is less portable (and for kind16, I was not sure how to pick an ifdef).
Thanks for testing @kkwli! I refactored the test for easier lit testing and this should be fixed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for taking the time to fix all of these tests.
I had a few test failures on aarch64. I suggested the fixes that worked for me locally (hopefully I didn't misstype anything when transcribing to github)
flang/test/Lower/OpenMP/parallel-firstprivate-clause-scalar.f90
Outdated
Show resolved
Hide resolved
Co-authored-by: Tom Eccles <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Passes for me on aarch64. LGTM
Thanks a lot for testing and fixing the patch Tom! |
C++ function call argument evaluation order is unspecified. When piping functions that generates IR, this creates indeterminism in the IR generated by flang (e.g., depend which C++ compiler compiled flang). While it has interesting fuzzing property for flang (Initially, most of expression lowering used that pattern for binary operation where Fortran also does not specify any order, and we did found bugs exposed by some of the IR version and not the other), it is not ideal for lit tests (I found this because of a CI failure when not properly adding `-DAG` [in test updates](#124966)), and many people also really value bit to bit reproducibility from compilers.
…c (#125055) C++ function call argument evaluation order is unspecified. When piping functions that generates IR, this creates indeterminism in the IR generated by flang (e.g., depend which C++ compiler compiled flang). While it has interesting fuzzing property for flang (Initially, most of expression lowering used that pattern for binary operation where Fortran also does not specify any order, and we did found bugs exposed by some of the IR version and not the other), it is not ideal for lit tests (I found this because of a CI failure when not properly adding `-DAG` [in test updates](llvm/llvm-project#124966)), and many people also really value bit to bit reproducibility from compilers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It works on ppc64le-*-linux
and powerpc*-*-aix
. Thanks.
KIND 10 and 16 are platform dependent and it will soon be a hard error to use them when not available (#124655)
Update some tests that used them to use SELECTED_REAL_KIND + lit conditional checks to make the tests usable on all platform.
Also update all those tests to use HFLIR lowering while modifying them since the goal is to remove the legacy lowering at some point.