aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite')
-rw-r--r--gcc/testsuite/g++.dg/ipa/pr120146.C12
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr120043.c10
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr120122-1.c51
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/phi-opt-40.c7
-rw-r--r--gcc/testsuite/gcc.dg/tree-ssa/phi-opt-41.c4
-rw-r--r--gcc/testsuite/gfortran.dg/pr120152_1.f9052
-rw-r--r--gcc/testsuite/gfortran.dg/pr120152_2.f9080
-rw-r--r--gcc/testsuite/gfortran.dg/pr120153.f9036
-rw-r--r--gcc/testsuite/gfortran.dg/pr120158.f9015
9 files changed, 262 insertions, 5 deletions
diff --git a/gcc/testsuite/g++.dg/ipa/pr120146.C b/gcc/testsuite/g++.dg/ipa/pr120146.C
new file mode 100644
index 0000000..33644b4
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ipa/pr120146.C
@@ -0,0 +1,12 @@
+// { dg-do compile }
+// { dg-options "-O -fipa-pta" }
+
+struct basic_ios {
+ ~basic_ios();
+};
+struct basic_istream : virtual basic_ios {};
+template <typename> struct basic_ifstream : basic_istream {
+ template <typename _Path> basic_ifstream(_Path, int);
+};
+extern template class basic_ifstream<char>;
+void CompareFiles_path2() { basic_ifstream<char>(CompareFiles_path2, 0); }
diff --git a/gcc/testsuite/gcc.dg/torture/pr120043.c b/gcc/testsuite/gcc.dg/torture/pr120043.c
new file mode 100644
index 0000000..ae27468
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr120043.c
@@ -0,0 +1,10 @@
+/* { dg-do run } */
+/* { dg-additional-options "-fallow-store-data-races" } */
+
+const int a;
+int *b;
+int main()
+{
+ &a != b || (*b = 1);
+ return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr120122-1.c b/gcc/testsuite/gcc.dg/torture/pr120122-1.c
new file mode 100644
index 0000000..dde41d8
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr120122-1.c
@@ -0,0 +1,51 @@
+/* { dg-do run } */
+/* PR tree-optimization/120122 */
+
+#include <stdbool.h>
+
+struct Value {
+ int type;
+ union {
+ bool boolean;
+ long long t;
+ };
+};
+
+static struct Value s_item_mem;
+
+/* truthy was being miscompiled for the value.type==2 case,
+ because we would have a VCE from unsigned char to bool
+ that went from being conditional in the value.type==1 case
+ to unconditional when `value.type!=0`.
+ The move of the VCE from conditional to unconditional,
+ needs to changed into a convert (NOP_EXPR). */
+static bool truthy(void) __attribute__((noipa));
+static bool
+truthy(void)
+{
+ bool tt = false;
+ for(int i = 0; i < 10; i++)
+ {
+ struct Value value = s_item_mem;
+ if (value.type == 0)
+ tt = tt | 0;
+ else if (value.type == 1)
+ tt = tt | value.boolean;
+ else
+ tt = tt | 1;
+ }
+ return tt;
+}
+
+int
+main(void)
+{
+ s_item_mem.type = 2;
+ s_item_mem.t = -1;
+ bool b1 = !truthy();
+ s_item_mem.type = 1;
+ s_item_mem.boolean = b1;
+ bool b = truthy();
+ if (b1 != b) __builtin_abort();
+ if (b) __builtin_abort();
+}
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-40.c b/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-40.c
index a9011ce..7062916 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-40.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-40.c
@@ -20,6 +20,7 @@ int f1(int x)
/* { dg-final { scan-tree-dump-times "if " 1 "phiopt1" } } */
/* { dg-final { scan-tree-dump-not "if " "phiopt2" } } */
-/* { dg-final { scan-tree-dump-times "ABS_EXPR <" 2 "phiopt1" } } */
-/* { dg-final { scan-tree-dump-times "ABS_EXPR <" 1 "phiopt2" } } */
-/* { dg-final { scan-tree-dump-times "ABSU_EXPR <" 1 "phiopt2" } } */
+/* The ABS_EXPR in f gets rewritten to ABSU_EXPR as phiopt can't prove it was not undefined when moving it. */
+/* { dg-final { scan-tree-dump-times "ABS_EXPR <" 1 "phiopt1" } } */
+/* { dg-final { scan-tree-dump-times "ABSU_EXPR <" 1 "phiopt1" } } */
+/* { dg-final { scan-tree-dump-times "ABSU_EXPR <" 2 "phiopt2" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-41.c b/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-41.c
index 9774e28..817d4fe 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-41.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/phi-opt-41.c
@@ -29,6 +29,6 @@ int fge(int a, unsigned char b)
return a > 0 ? a : -a;
}
-
+/* The ABS_EXPR gets rewritten to ABSU_EXPR as phiopt can't prove it was not undefined when moving it. */
/* { dg-final { scan-tree-dump-not "if " "phiopt1" } } */
-/* { dg-final { scan-tree-dump-times "ABS_EXPR <" 4 "phiopt1" } } */
+/* { dg-final { scan-tree-dump-times "ABSU_EXPR <" 4 "phiopt1" } } */
diff --git a/gcc/testsuite/gfortran.dg/pr120152_1.f90 b/gcc/testsuite/gfortran.dg/pr120152_1.f90
new file mode 100644
index 0000000..c49197d
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr120152_1.f90
@@ -0,0 +1,52 @@
+! PR libfortran/120152
+! { dg-do run }
+
+subroutine f1
+ integer(kind=8) :: a (10, 10, 10), b (10, 10)
+ logical :: c (10, 10, 10)
+ a = 0
+ c = .true.
+ b = maxloc (a, 2, c, 8, .true.)
+end
+subroutine f2
+ integer(kind=8) :: a (10, 10, 10)
+ integer(kind=4) :: b (10, 10)
+ logical :: c (10, 10, 10)
+ a = 0
+ c = .true.
+ b = maxloc (a, 2, c, 4, .true.)
+end
+subroutine f3
+ integer(kind=8) :: a (10, 10, 10), b (10, 10)
+ a = 0
+ b = maxloc (a, 2, kind=8, back=.true.)
+end
+subroutine f4
+ integer(kind=8) :: a (10, 10, 10)
+ integer(kind=4) :: b (10, 10)
+ a = 0
+ b = maxloc (a, 2, kind=4, back=.true.)
+end
+subroutine f5
+ integer(kind=8) :: a (10, 10, 10), b (10, 10)
+ logical :: c
+ a = 0
+ c = .false.
+ b = maxloc (a, 2, c, 8, .true.)
+end
+subroutine f6
+ integer(kind=8) :: a (10, 10, 10)
+ integer(kind=4) :: b (10, 10)
+ logical :: c
+ a = 0
+ c = .false.
+ b = maxloc (a, 2, c, 4, .true.)
+end
+program pr120152
+ call f1
+ call f2
+ call f3
+ call f4
+ call f5
+ call f6
+end
diff --git a/gcc/testsuite/gfortran.dg/pr120152_2.f90 b/gcc/testsuite/gfortran.dg/pr120152_2.f90
new file mode 100644
index 0000000..39cfb28
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr120152_2.f90
@@ -0,0 +1,80 @@
+! PR libfortran/120152
+! { dg-do run { target fortran_large_int } }
+
+subroutine f1
+ integer(kind=16) :: a (10, 10, 10)
+ integer(kind=8) :: b (10, 10)
+ logical :: c (10, 10, 10)
+ a = 0
+ c = .true.
+ b = maxloc (a, 2, c, 8, .true.)
+end
+subroutine f2
+ integer(kind=16) :: a (10, 10, 10)
+ integer(kind=4) :: b (10, 10)
+ logical :: c (10, 10, 10)
+ a = 0
+ c = .true.
+ b = maxloc (a, 2, c, 4, .true.)
+end
+subroutine f3
+ integer(kind=16) :: a (10, 10, 10)
+ integer(kind=8) :: b (10, 10)
+ a = 0
+ b = maxloc (a, 2, kind=8, back=.true.)
+end
+subroutine f4
+ integer(kind=16) :: a (10, 10, 10)
+ integer(kind=4) :: b (10, 10)
+ a = 0
+ b = maxloc (a, 2, kind=4, back=.true.)
+end
+subroutine f5
+ integer(kind=16) :: a (10, 10, 10)
+ integer(kind=8) :: b (10, 10)
+ logical :: c
+ a = 0
+ c = .false.
+ b = maxloc (a, 2, c, 8, .true.)
+end
+subroutine f6
+ integer(kind=16) :: a (10, 10, 10)
+ integer(kind=4) :: b (10, 10)
+ logical :: c
+ a = 0
+ c = .false.
+ b = maxloc (a, 2, c, 4, .true.)
+end
+subroutine f7
+ integer(kind=8) :: a (10, 10, 10)
+ integer(kind=16) :: b (10, 10)
+ logical :: c (10, 10, 10)
+ a = 0
+ c = .true.
+ b = maxloc (a, 2, c, 16, .true.)
+end
+subroutine f8
+ integer(kind=8) :: a (10, 10, 10)
+ integer(kind=16) :: b (10, 10)
+ a = 0
+ b = maxloc (a, 2, kind=16, back=.true.)
+end
+subroutine f9
+ integer(kind=8) :: a (10, 10, 10)
+ integer(kind=16) :: b (10, 10)
+ logical :: c
+ a = 0
+ c = .false.
+ b = maxloc (a, 2, c, 16, .true.)
+end
+program pr120152
+ call f1
+ call f2
+ call f3
+ call f4
+ call f5
+ call f6
+ call f7
+ call f8
+ call f9
+end
diff --git a/gcc/testsuite/gfortran.dg/pr120153.f90 b/gcc/testsuite/gfortran.dg/pr120153.f90
new file mode 100644
index 0000000..22a7849
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr120153.f90
@@ -0,0 +1,36 @@
+! PR libfortran/120153
+! { dg-do run { target fortran_large_int } }
+! { dg-additional-options "-funsigned" }
+
+subroutine f1
+ unsigned(kind=16) :: a (10, 10, 10)
+ integer(kind=16) :: b (10, 10)
+ logical :: c (10, 10, 10)
+ a = 0u_16
+ c = .true.
+ b = maxloc (a, 2, c, 16, .true.)
+end
+subroutine f2
+ unsigned(kind=16) :: a (10, 10, 10)
+ integer(kind=16) :: b (10, 10)
+ a = 0u_16
+ b = maxloc (a, 2, kind=16, back=.true.)
+end
+subroutine f3
+ unsigned(kind=16) :: a (10, 10, 10)
+ integer(kind=8) :: b (10, 10)
+ logical :: c
+ a = 0u_16
+ c = .false.
+ b = maxloc (a, 2, c, 16, .true.)
+end
+subroutine f4
+ unsigned(kind=16) :: a (5, 5, 5)
+ call random_number (a)
+end
+program pr120153
+ call f1
+ call f2
+ call f3
+ call f4
+end
diff --git a/gcc/testsuite/gfortran.dg/pr120158.f90 b/gcc/testsuite/gfortran.dg/pr120158.f90
new file mode 100644
index 0000000..593f4bc
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr120158.f90
@@ -0,0 +1,15 @@
+! PR libfortran/120158
+! { dg-do run { target fortran_large_int } }
+! { dg-additional-options "-funsigned" }
+
+ unsigned(kind=8) :: a(10, 10, 10), b(10, 10)
+ integer(kind=8) :: c(10, 10), d(10, 10)
+ a = 0u_8
+ if (maxval (a) .ne. 0u_8) stop 1
+ b = maxval (a, 1)
+ if (any (b .ne. 0u_8)) stop 2
+ c = maxloc (a, 1)
+ d = maxloc (a, 2, back=.true.)
+ if (any (c .ne. 1)) stop 3
+ if (any (d .ne. 10)) stop 4
+end