aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite')
-rw-r--r--gcc/testsuite/ChangeLog9
-rw-r--r--gcc/testsuite/gcc.target/aarch64/sve2/pr121599.c4
-rw-r--r--gcc/testsuite/gcc.target/loongarch/lasx-reduc-1.c17
-rw-r--r--gcc/testsuite/gfortran.dg/is_contiguous_5.f90126
-rw-r--r--gcc/testsuite/gfortran.dg/pdt_60.f0365
-rw-r--r--gcc/testsuite/gnat.dg/machine_attr3.adb7
-rw-r--r--gcc/testsuite/gnat.dg/machine_attr3.ads10
7 files changed, 236 insertions, 2 deletions
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 4b9bd57..d6a2cf4 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,12 @@
+2025-10-25 Harald Anlauf <anlauf@gmx.de>
+
+ PR fortran/114023
+ * gfortran.dg/is_contiguous_5.f90: New test.
+
+2025-10-25 Jiahao Xu <xujiahao@loongson.cn>
+
+ * gcc.target/loongarch/lasx-reduc-1.c: New test.
+
2025-10-24 Andrew MacLeod <amacleod@redhat.com>
* gcc.dg/pr110405.c: New.
diff --git a/gcc/testsuite/gcc.target/aarch64/sve2/pr121599.c b/gcc/testsuite/gcc.target/aarch64/sve2/pr121599.c
index 90c5ac9..da4b7aa 100644
--- a/gcc/testsuite/gcc.target/aarch64/sve2/pr121599.c
+++ b/gcc/testsuite/gcc.target/aarch64/sve2/pr121599.c
@@ -7,7 +7,7 @@
/*
** foo:
-** movi d([0-9]+), #0
+** movi? [vdz]([0-9]+)\.?b?, #0
** movprfx z0\.b, p0/z, z0\.b
** usqadd z0\.b, p0/m, z0\.b, z\1\.b
** ret
@@ -19,7 +19,7 @@ svuint8_t foo (svbool_t pg, svuint8_t op1)
/*
** bar:
-** movi d([0-9]+), #0
+** movi? [vdz]([0-9]+)\.?b?, #0
** movprfx z0\.b, p0/z, z0\.b
** suqadd z0\.b, p0/m, z0\.b, z\1\.b
** ret
diff --git a/gcc/testsuite/gcc.target/loongarch/lasx-reduc-1.c b/gcc/testsuite/gcc.target/loongarch/lasx-reduc-1.c
new file mode 100644
index 0000000..e449259
--- /dev/null
+++ b/gcc/testsuite/gcc.target/loongarch/lasx-reduc-1.c
@@ -0,0 +1,17 @@
+/* { dg-do compile } */
+/* { dg-options "-O3 -funsafe-math-optimizations -mlasx -fno-unroll-loops -fdump-tree-optimized" } */
+/* { dg-final { scan-tree-dump-times "\.REDUC_PLUS" 4 "optimized" } } */
+
+#define DEFINE_SUM_FUNCTION(T, FUNC_NAME, SIZE) \
+T FUNC_NAME(const T arr[]) { \
+ arr = __builtin_assume_aligned(arr, 64); \
+ T sum = 0; \
+ for (int i = 0; i < SIZE; i++) \
+ sum += arr[i]; \
+ return sum; \
+}
+
+DEFINE_SUM_FUNCTION (int, sum_int_1040, 1028)
+DEFINE_SUM_FUNCTION (float, sum_float_1040, 1028)
+DEFINE_SUM_FUNCTION (long, sum_long_1040, 1026)
+DEFINE_SUM_FUNCTION (double, sum_double_1040, 1026)
diff --git a/gcc/testsuite/gfortran.dg/is_contiguous_5.f90 b/gcc/testsuite/gfortran.dg/is_contiguous_5.f90
new file mode 100644
index 0000000..091e43b5
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/is_contiguous_5.f90
@@ -0,0 +1,126 @@
+! { dg-do run }
+! PR fortran/114023 - IS_CONTIGUOUS and pointers to non-contiguous targets
+!
+! Based on testcase by Federico Perini
+
+program main
+ implicit none
+ complex, parameter :: cvals(*) = [(1,-1),(2,-2),(3,-3)]
+ complex , target :: cref(size(cvals)) = cvals ! Reference
+ complex, allocatable, target :: carr(:) ! Test
+
+ type cx
+ real :: re, im
+ end type cx
+ type(cx), parameter :: tvals(*) = [cx(1,-1),cx(2,-2),cx(3,-3)]
+ real, parameter :: expect(*) = tvals% re
+ type(cx) , target :: tref(size(cvals)) = tvals ! Reference
+ type(cx), allocatable, target :: tarr(:)
+
+ real, pointer :: rr1(:), rr2(:), rr3(:), rr4(:)
+ class(*), pointer :: cp1(:), cp2(:), cp3(:), cp4(:)
+
+ carr = cvals
+ tarr = tvals
+
+ if (any (expect /= [1,2,3])) error stop 90
+
+ ! REAL pointer to non-contiguous effective target
+ rr1(1:3) => cref%re
+ rr2 => cref%re
+ rr3(1:3) => carr%re
+ rr4 => carr%re
+
+ if (is_contiguous (rr1)) stop 1
+ if (my_contiguous_real (rr1)) stop 2
+ if (is_contiguous (cref(1:3)%re)) stop 3
+! if (my_contiguous_real (cref(1:3)%re)) stop 4 ! pr122397
+
+ if (is_contiguous (rr3)) stop 6
+ if (my_contiguous_real (rr3)) stop 7
+ if (is_contiguous (carr(1:3)%re)) stop 8
+! if (my_contiguous_real (carr(1:3)%re)) stop 9
+
+ if (is_contiguous (rr2)) stop 11
+ if (my_contiguous_real (rr2)) stop 12
+ if (is_contiguous (cref%re)) stop 13
+! if (my_contiguous_real (cref%re)) stop 14
+
+ if (is_contiguous (rr4)) stop 16
+ if (my_contiguous_real (rr4)) stop 17
+ if (is_contiguous (carr%re)) stop 18
+! if (my_contiguous_real (carr%re)) stop 19
+
+ rr1(1:3) => tref%re
+ rr2 => tref%re
+ rr3(1:3) => tarr%re
+ rr4 => tarr%re
+
+ if (is_contiguous (rr1)) stop 21
+ if (my_contiguous_real (rr1)) stop 22
+ if (is_contiguous (tref(1:3)%re)) stop 23
+! if (my_contiguous_real (tref(1:3)%re)) stop 24
+
+ if (is_contiguous (rr3)) stop 26
+ if (my_contiguous_real (rr3)) stop 27
+ if (is_contiguous (tarr(1:3)%re)) stop 28
+! if (my_contiguous_real (tarr(1:3)%re)) stop 29
+
+ if (is_contiguous (rr2)) stop 31
+ if (my_contiguous_real (rr2)) stop 32
+ if (is_contiguous (tref%re)) stop 33
+! if (my_contiguous_real (tref%re)) stop 34
+
+ if (is_contiguous (rr4)) stop 36
+ if (my_contiguous_real (rr4)) stop 37
+ if (is_contiguous (tarr%re)) stop 38
+! if (my_contiguous_real (tarr%re)) stop 39
+
+ ! Unlimited polymorphic pointer to non-contiguous effective target
+ cp1(1:3) => cref%re
+ cp2 => cref%re
+ cp3(1:3) => carr%re
+ cp4 => carr%re
+
+ if (is_contiguous (cp1)) stop 41
+ if (my_contiguous_poly (cp1)) stop 42
+ if (is_contiguous (cp2)) stop 43
+ if (my_contiguous_poly (cp2)) stop 44
+ if (is_contiguous (cp3)) stop 45
+ if (my_contiguous_poly (cp3)) stop 46
+ if (is_contiguous (cp4)) stop 47
+ if (my_contiguous_poly (cp4)) stop 48
+
+ cp1(1:3) => tref%re
+ cp2 => tref%re
+ cp3(1:3) => tarr%re
+ cp4 => tarr%re
+
+ if (is_contiguous (cp1)) stop 51
+ if (my_contiguous_poly (cp1)) stop 52
+ if (is_contiguous (cp2)) stop 53
+ if (my_contiguous_poly (cp2)) stop 54
+ if (is_contiguous (cp3)) stop 55
+ if (my_contiguous_poly (cp3)) stop 56
+ if (is_contiguous (cp4)) stop 57
+ if (my_contiguous_poly (cp4)) stop 58
+
+ deallocate (carr, tarr)
+contains
+ pure logical function my_contiguous_real (x) result (res)
+ real, pointer, intent(in) :: x(:)
+ res = is_contiguous (x)
+ if (any (x /= expect)) error stop 97
+ end function my_contiguous_real
+
+ pure logical function my_contiguous_poly (x) result (res)
+ class(*), pointer, intent(in) :: x(:)
+ res = is_contiguous (x)
+ select type (x)
+ type is (real)
+ if (any (x /= expect)) error stop 98
+ class default
+ error stop 99
+ end select
+ end function my_contiguous_poly
+end
diff --git a/gcc/testsuite/gfortran.dg/pdt_60.f03 b/gcc/testsuite/gfortran.dg/pdt_60.f03
new file mode 100644
index 0000000..dc9f7f2
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pdt_60.f03
@@ -0,0 +1,65 @@
+! { dg-do compile }
+! { dg-options "-fdump-tree-original" }
+!
+! Test the fix for PR122290.
+!
+! Contributed by Damian Rouson <damian@archaeologic.codes>
+!
+module hyperparameters_m
+ implicit none
+
+ type hyperparameters_t(k)
+ integer, kind :: k = kind(1.)
+ real(k) :: learning_rate_ = real(1.5,k) ! Gave "Invalid kind for REAL"
+ contains
+ generic :: operator(==) => default_real_equals, real8_equals ! Gave "Entity ‘default_real_equals’ at (1)
+ ! is already present in the interface"
+ generic :: g => default_real_equals, real8_equals ! Make sure that ordinary generic is OK
+ procedure default_real_equals
+ procedure real8_equals
+ end type
+
+ interface
+ logical module function default_real_equals(lhs, rhs)
+ implicit none
+ class(hyperparameters_t), intent(in) :: lhs, rhs
+ end function
+ logical module function real8_equals(lhs, rhs)
+ implicit none
+ class(hyperparameters_t(kind(1d0))), intent(in) :: lhs, rhs
+ end function
+ end interface
+end module
+
+! Added to test generic procedures are the correct ones.
+submodule(hyperparameters_m) hyperparameters_s
+contains
+ logical module function default_real_equals(lhs, rhs)
+ implicit none
+ class(hyperparameters_t), intent(in) :: lhs, rhs
+ default_real_equals = (lhs%learning_rate_ == rhs%learning_rate_)
+ end function
+ logical module function real8_equals(lhs, rhs)
+ implicit none
+ class(hyperparameters_t(kind(1d0))), intent(in) :: lhs, rhs
+ real8_equals = (lhs%learning_rate_ == rhs%learning_rate_)
+ end function
+end submodule
+
+ use hyperparameters_m
+ type (hyperparameters_t) :: a, b
+ type (hyperparameters_t(kind(1d0))) :: c, d
+ if (.not.(a == b)) stop 1
+ if (.not.a%g(b)) stop 2
+ a%learning_rate_ = real(2.5,a%k)
+ if (a == b) stop 3
+ if (a%g(b)) stop 4
+
+ if (.not.(c == d)) stop 5
+ if (.not.c%g(d)) stop 6
+ c%learning_rate_ = real(2.5,c%k)
+ if (c == d) stop 7
+ if (c%g(d)) stop 8
+end
+! { dg-final { scan-tree-dump-times "default_real_equals" 8 "original" } }
+! { dg-final { scan-tree-dump-times "real8_equals" 8 "original" } }
diff --git a/gcc/testsuite/gnat.dg/machine_attr3.adb b/gcc/testsuite/gnat.dg/machine_attr3.adb
new file mode 100644
index 0000000..68a9c77
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/machine_attr3.adb
@@ -0,0 +1,7 @@
+-- { dg-do compile }
+
+package body Machine_Attr3 is
+
+ procedure Proc is null;
+
+end Machine_Attr3;
diff --git a/gcc/testsuite/gnat.dg/machine_attr3.ads b/gcc/testsuite/gnat.dg/machine_attr3.ads
new file mode 100644
index 0000000..edb7b7d
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/machine_attr3.ads
@@ -0,0 +1,10 @@
+package Machine_Attr3 is
+
+ procedure Proc;
+
+private
+
+ Attr : constant String := "nothrow";
+ pragma Machine_Attribute (Proc, Attr);
+
+end Machine_Attr3;