commit a94e627488d8d0786a4d40292122e1af9d4dbb12
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Tue Jun 28 12:12:21 2022 +0200

    Bump BASE-VER.
    
    2022-06-28  Jakub Jelinek  <jakub@redhat.com>
    
            * BASE-VER: Set to 10.4.1.

diff --git a/gcc/BASE-VER b/gcc/BASE-VER
index 816c0711afb..da772b97257 100644
--- a/gcc/BASE-VER
+++ b/gcc/BASE-VER
@@ -1 +1 @@
-10.4.0
+10.4.1

commit 652e52ef1fd97b0c297526f97f7d566c102f274e
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Wed Jun 29 00:17:49 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 73287f27b0a..f15a0aa76a8 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20220628
+20220629

commit 7471cc92b7c7907a0e5499b49fecb3e1a8e2c926
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Thu Jun 30 00:17:37 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index f15a0aa76a8..b03df3b8b85 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20220629
+20220630

commit bedcdedfad671198365a7ce77c28040c2aa6e2e7
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Fri Jul 1 00:17:35 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index b03df3b8b85..6b7f92b2f90 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20220630
+20220701

commit 1214ebb39cd250fda678ec89c785fcea86888a89
Author: Harald Anlauf <anlauf@gmx.de>
Date:   Fri Jun 24 22:21:39 2022 +0200

    Fortran: fix checking of arguments to UNPACK when MASK is a variable [PR105813]
    
    gcc/fortran/ChangeLog:
    
            PR fortran/105813
            * check.c (gfc_check_unpack): Try to simplify MASK argument to
            UNPACK so that checking of the VECTOR argument can work when MASK
            is a variable.
    
    gcc/testsuite/ChangeLog:
    
            PR fortran/105813
            * gfortran.dg/unpack_vector_1.f90: New test.
    
    (cherry picked from commit f21f17f95c0237f4f987a5fa9f1fa9c7e0db3c40)

diff --git a/gcc/fortran/check.c b/gcc/fortran/check.c
index 44e2da65a4c..488c9aff94b 100644
--- a/gcc/fortran/check.c
+++ b/gcc/fortran/check.c
@@ -6329,6 +6329,8 @@ gfc_check_unpack (gfc_expr *vector, gfc_expr *mask, gfc_expr *field)
   if (!same_type_check (vector, 0, field, 2))
     return false;
 
+  gfc_simplify_expr (mask, 0);
+
   if (mask->expr_type == EXPR_ARRAY
       && gfc_array_size (vector, &vector_size))
     {
diff --git a/gcc/testsuite/gfortran.dg/unpack_vector_1.f90 b/gcc/testsuite/gfortran.dg/unpack_vector_1.f90
new file mode 100644
index 00000000000..5347c111e8f
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/unpack_vector_1.f90
@@ -0,0 +1,12 @@
+! { dg-do compile }
+! PR fortran/105813
+! Fix checking of VECTOR argument to UNPACK when MASK is a variable.
+! Contributed by G.Steinmetz
+
+program p
+  logical, parameter :: mask(2,2) = reshape ([.true.,  .true.,  &
+                                              .false., .true.], &
+                                              shape (mask))
+  print *, unpack ([1,2,3], mask, 0) ! OK
+  print *, unpack ([1,2],   mask, 0) ! { dg-error "must provide at least" }
+end

commit e6db08d9183b80b0ada5122fae79412544279f56
Author: Harald Anlauf <anlauf@gmx.de>
Date:   Tue Jun 21 23:20:18 2022 +0200

    Fortran: fix simplification of INDEX(str1,str2) [PR105691]
    
    gcc/fortran/ChangeLog:
    
            PR fortran/105691
            * simplify.c (gfc_simplify_index): Replace old simplification
            code by the equivalent of the runtime library implementation.  Use
            HOST_WIDE_INT instead of int for string index, length variables.
    
    gcc/testsuite/ChangeLog:
    
            PR fortran/105691
            * gfortran.dg/index_6.f90: New test.
    
    (cherry picked from commit ff35dbc02092fbcd3d814fcd9fe8e871c3f741fd)

diff --git a/gcc/fortran/simplify.c b/gcc/fortran/simplify.c
index f0f322c1caf..a4e014a746f 100644
--- a/gcc/fortran/simplify.c
+++ b/gcc/fortran/simplify.c
@@ -3470,17 +3470,15 @@ gfc_expr *
 gfc_simplify_index (gfc_expr *x, gfc_expr *y, gfc_expr *b, gfc_expr *kind)
 {
   gfc_expr *result;
-  int back, len, lensub;
-  int i, j, k, count, index = 0, start;
+  bool back;
+  HOST_WIDE_INT len, lensub, start, last, i, index = 0;
+  int k, delta;
 
   if (x->expr_type != EXPR_CONSTANT || y->expr_type != EXPR_CONSTANT
       || ( b != NULL && b->expr_type !=  EXPR_CONSTANT))
     return NULL;
 
-  if (b != NULL && b->value.logical != 0)
-    back = 1;
-  else
-    back = 0;
+  back = (b != NULL && b->value.logical != 0);
 
   k = get_kind (BT_INTEGER, kind, "INDEX", gfc_default_integer_kind);
   if (k == -1)
@@ -3497,111 +3495,40 @@ gfc_simplify_index (gfc_expr *x, gfc_expr *y, gfc_expr *b, gfc_expr *kind)
       return result;
     }
 
-  if (back == 0)
+  if (lensub == 0)
     {
-      if (lensub == 0)
-	{
-	  mpz_set_si (result->value.integer, 1);
-	  return result;
-	}
-      else if (lensub == 1)
-	{
-	  for (i = 0; i < len; i++)
-	    {
-	      for (j = 0; j < lensub; j++)
-		{
-		  if (y->value.character.string[j]
-		      == x->value.character.string[i])
-		    {
-		      index = i + 1;
-		      goto done;
-		    }
-		}
-	    }
-	}
+      if (back)
+	index = len + 1;
       else
-	{
-	  for (i = 0; i < len; i++)
-	    {
-	      for (j = 0; j < lensub; j++)
-		{
-		  if (y->value.character.string[j]
-		      == x->value.character.string[i])
-		    {
-		      start = i;
-		      count = 0;
-
-		      for (k = 0; k < lensub; k++)
-			{
-			  if (y->value.character.string[k]
-			      == x->value.character.string[k + start])
-			    count++;
-			}
-
-		      if (count == lensub)
-			{
-			  index = start + 1;
-			  goto done;
-			}
-		    }
-		}
-	    }
-	}
+	index = 1;
+      goto done;
+    }
 
+  if (!back)
+    {
+      last = len + 1 - lensub;
+      start = 0;
+      delta = 1;
     }
   else
     {
-      if (lensub == 0)
-	{
-	  mpz_set_si (result->value.integer, len + 1);
-	  return result;
-	}
-      else if (lensub == 1)
+      last = -1;
+      start = len - lensub;
+      delta = -1;
+    }
+
+  for (; start != last; start += delta)
+    {
+      for (i = 0; i < lensub; i++)
 	{
-	  for (i = 0; i < len; i++)
-	    {
-	      for (j = 0; j < lensub; j++)
-		{
-		  if (y->value.character.string[j]
-		      == x->value.character.string[len - i])
-		    {
-		      index = len - i + 1;
-		      goto done;
-		    }
-		}
-	    }
+	  if (x->value.character.string[start + i]
+	      != y->value.character.string[i])
+	    break;
 	}
-      else
+      if (i == lensub)
 	{
-	  for (i = 0; i < len; i++)
-	    {
-	      for (j = 0; j < lensub; j++)
-		{
-		  if (y->value.character.string[j]
-		      == x->value.character.string[len - i])
-		    {
-		      start = len - i;
-		      if (start <= len - lensub)
-			{
-			  count = 0;
-			  for (k = 0; k < lensub; k++)
-			    if (y->value.character.string[k]
-			        == x->value.character.string[k + start])
-			      count++;
-
-			  if (count == lensub)
-			    {
-			      index = start + 1;
-			      goto done;
-			    }
-			}
-		      else
-			{
-			  continue;
-			}
-		    }
-		}
-	    }
+	  index = start + 1;
+	  goto done;
 	}
     }
 
diff --git a/gcc/testsuite/gfortran.dg/index_6.f90 b/gcc/testsuite/gfortran.dg/index_6.f90
new file mode 100644
index 00000000000..61d492985ad
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/index_6.f90
@@ -0,0 +1,31 @@
+! { dg-do compile }
+! { dg-options "-fdump-tree-original" }
+! PR fortran/105691 - Incorrect calculation of INDEX(str1,str2) at compile time
+
+program main
+  implicit none
+  integer :: i
+  character(*), parameter :: s1 = "fortran.f90"
+  character(*), parameter :: s2 = "fortran"
+  character(*), parameter :: s3 = s2 // "*"
+  integer, parameter :: i0    = index(s1, s2)
+  integer, parameter :: i1    = index(s1, s2, back= .true.)
+  integer, parameter :: i2(*) = index(s1, s2, back=[.true.,.false.])
+  integer, parameter :: i3(*) = index(s1, s2, back=[(i==1, i=1,2)] )
+  integer, parameter :: i4    = index(s1, s3)
+  integer, parameter :: i5    = index(s1, s3, back= .true.)
+  integer, parameter :: i6(*) = index(s1, s3, back=[.true.,.false.])
+  integer, parameter :: i7(*) = index(s1, s3, back=[(i==1, i=1,2)] )
+  integer, parameter :: i8    = index(s1, "f", back= .true.)
+  if (     i0 /= 1 ) stop 1
+  if (     i1 /= 1 ) stop 2
+  if (any (i2 /= 1)) stop 3
+  if (any (i3 /= 1)) stop 4
+  if (     i4 /= 0 ) stop 5
+  if (     i5 /= 0 ) stop 6
+  if (any (i6 /= 0)) stop 7
+  if (any (i7 /= 0)) stop 8
+  if (i8 /= len(s1)-2) stop 9
+end program
+
+! { dg-final { scan-tree-dump-not "_gfortran_stop_numeric" "original" } }

commit bac42273343bb9a198704900e2118ed4e84cb23a
Author: Harald Anlauf <anlauf@gmx.de>
Date:   Mon Jun 20 20:59:55 2022 +0200

    Fortran: handle explicit-shape specs with constant bounds [PR105954]
    
    gcc/fortran/ChangeLog:
    
            PR fortran/105954
            * decl.c (variable_decl): Adjust upper bounds for explicit-shape
            specs with constant bound expressions to ensure non-negative
            extents.
    
    gcc/testsuite/ChangeLog:
    
            PR fortran/105954
            * gfortran.dg/pr105954.f90: New test.
    
    (cherry picked from commit a312407bd715647f7c11b67e0a52effc94d0f15d)

diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c
index 2ad9fb63399..a007bb15333 100644
--- a/gcc/fortran/decl.c
+++ b/gcc/fortran/decl.c
@@ -2685,6 +2685,18 @@ variable_decl (int elem)
 		  else
 		    gfc_free_expr (n);
 		}
+	      /* For an explicit-shape spec with constant bounds, ensure
+		 that the effective upper bound is not lower than the
+		 respective lower bound minus one.  Otherwise adjust it so
+		 that the extent is trivially derived to be zero.  */
+	      if (as->lower[i]->expr_type == EXPR_CONSTANT
+		  && as->upper[i]->expr_type == EXPR_CONSTANT
+		  && as->lower[i]->ts.type == BT_INTEGER
+		  && as->upper[i]->ts.type == BT_INTEGER
+		  && mpz_cmp (as->upper[i]->value.integer,
+			      as->lower[i]->value.integer) < 0)
+		mpz_sub_ui (as->upper[i]->value.integer,
+			    as->lower[i]->value.integer, 1);
 	    }
 	}
     }
diff --git a/gcc/testsuite/gfortran.dg/pr105954.f90 b/gcc/testsuite/gfortran.dg/pr105954.f90
new file mode 100644
index 00000000000..89004bf9aa7
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr105954.f90
@@ -0,0 +1,26 @@
+! { dg-do compile }
+! { dg-options "-fdump-tree-original" }
+! PR fortran/105954 - ICE in gfc_element_size, at fortran/target-memory.cc:132
+! Contributed by G.Steinmetz
+
+program p
+  use iso_c_binding, only: c_float, c_sizeof
+  implicit none
+  integer, parameter :: n = -99
+  type t
+     real :: b(3,7:n)
+  end type
+  type, bind(c) :: u
+     real(c_float) :: b(3,7:n)
+  end type
+  type(t) :: d
+  type(u) :: e
+  integer, parameter :: k = storage_size(d)
+  integer, parameter :: m = sizeof(d)
+  integer, parameter :: l = c_sizeof(e)
+  if (k /= 0) stop 1
+  if (m /= 0) stop 2
+  if (l /= 0) stop 3
+end
+
+! { dg-final { scan-tree-dump-not "_gfortran_stop_numeric" "original" } }

commit 69b1e3e7ddeb5ea36b98c90b3c9fb016791156a4
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sat Jul 2 00:17:34 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 6b7f92b2f90..eb05de3bc0c 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20220701
+20220702
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 8edae9380d4..c863c8e9833 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,33 @@
+2022-07-01  Harald Anlauf  <anlauf@gmx.de>
+
+	Backported from master:
+	2022-06-26  Harald Anlauf  <anlauf@gmx.de>
+
+	PR fortran/105954
+	* decl.c (variable_decl): Adjust upper bounds for explicit-shape
+	specs with constant bound expressions to ensure non-negative
+	extents.
+
+2022-07-01  Harald Anlauf  <anlauf@gmx.de>
+
+	Backported from master:
+	2022-06-26  Harald Anlauf  <anlauf@gmx.de>
+
+	PR fortran/105691
+	* simplify.c (gfc_simplify_index): Replace old simplification
+	code by the equivalent of the runtime library implementation.  Use
+	HOST_WIDE_INT instead of int for string index, length variables.
+
+2022-07-01  Harald Anlauf  <anlauf@gmx.de>
+
+	Backported from master:
+	2022-06-24  Harald Anlauf  <anlauf@gmx.de>
+
+	PR fortran/105813
+	* check.c (gfc_check_unpack): Try to simplify MASK argument to
+	UNPACK so that checking of the VECTOR argument can work when MASK
+	is a variable.
+
 2022-06-28  Release Manager
 
 	* GCC 10.4.0 released.
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index a032b35be83..c37b678571e 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,27 @@
+2022-07-01  Harald Anlauf  <anlauf@gmx.de>
+
+	Backported from master:
+	2022-06-26  Harald Anlauf  <anlauf@gmx.de>
+
+	PR fortran/105954
+	* gfortran.dg/pr105954.f90: New test.
+
+2022-07-01  Harald Anlauf  <anlauf@gmx.de>
+
+	Backported from master:
+	2022-06-26  Harald Anlauf  <anlauf@gmx.de>
+
+	PR fortran/105691
+	* gfortran.dg/index_6.f90: New test.
+
+2022-07-01  Harald Anlauf  <anlauf@gmx.de>
+
+	Backported from master:
+	2022-06-24  Harald Anlauf  <anlauf@gmx.de>
+
+	PR fortran/105813
+	* gfortran.dg/unpack_vector_1.f90: New test.
+
 2022-06-28  Release Manager
 
 	* GCC 10.4.0 released.

commit 061f6d2ef7aa6abf98dc3fad85976494aa2738f8
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sun Jul 3 00:17:28 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index eb05de3bc0c..758f2bf605e 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20220702
+20220703

commit 8bb7567f5a3e67ab91614d4538eb3a14a5a76274
Author: Harald Anlauf <anlauf@gmx.de>
Date:   Tue Jun 28 22:29:28 2022 +0200

    Fortran: improve error recovery for EXTENDS_TYPE_OF() [PR106121]
    
    gcc/fortran/ChangeLog:
    
            PR fortran/106121
            * simplify.c (gfc_simplify_extends_type_of): Do not attempt to
            simplify when one of the arguments is a CLASS variable that was
            not properly declared.
    
    gcc/testsuite/ChangeLog:
    
            PR fortran/106121
            * gfortran.dg/extends_type_of_4.f90: New test.
    
    Co-authored-by: Steven G. Kargl <kargl@gcc.gnu.org>
    (cherry picked from commit b8f284d3673004dffae714b56ed663467c2a52a7)

diff --git a/gcc/fortran/simplify.c b/gcc/fortran/simplify.c
index a4e014a746f..29d4c695302 100644
--- a/gcc/fortran/simplify.c
+++ b/gcc/fortran/simplify.c
@@ -3060,6 +3060,10 @@ gfc_simplify_extends_type_of (gfc_expr *a, gfc_expr *mold)
   if (UNLIMITED_POLY (a) || UNLIMITED_POLY (mold))
     return NULL;
 
+  if ((a->ts.type == BT_CLASS && !gfc_expr_attr (a).class_ok)
+      || (mold->ts.type == BT_CLASS && !gfc_expr_attr (mold).class_ok))
+    return NULL;
+
   /* Return .false. if the dynamic type can never be an extension.  */
   if ((a->ts.type == BT_CLASS && mold->ts.type == BT_CLASS
        && !gfc_type_is_extension_of
diff --git a/gcc/testsuite/gfortran.dg/extends_type_of_4.f90 b/gcc/testsuite/gfortran.dg/extends_type_of_4.f90
new file mode 100644
index 00000000000..64373322387
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/extends_type_of_4.f90
@@ -0,0 +1,20 @@
+! { dg-do compile }
+! PR fortran/106121 - ICE in gfc_simplify_extends_type_of
+! Contributed by G.Steinmetz
+
+program p
+   type t
+   end type
+   type(t)  :: x
+   class(t) :: y               ! { dg-error "dummy, allocatable or pointer" }
+   print *, extends_type_of (x, y)
+end
+
+subroutine s
+   type t
+      integer :: i
+   end type
+   type(t)  :: x
+   class(t) :: y               ! { dg-error "dummy, allocatable or pointer" }
+   stop extends_type_of (x, y) ! { dg-error "STOP code" }
+end

commit 290147c4c8e3d9d1f13297b511d3a0afb5e952d4
Author: Harald Anlauf <anlauf@gmx.de>
Date:   Wed Jun 29 21:36:17 2022 +0200

    Fortran: error recovery on invalid CLASS(), PARAMETER declarations [PR105243]
    
    gcc/fortran/ChangeLog:
    
            PR fortran/103137
            PR fortran/103138
            PR fortran/103693
            PR fortran/105243
            * decl.c (gfc_match_data_decl): Reject CLASS entity declaration
            when it is given the PARAMETER attribute.
    
    gcc/testsuite/ChangeLog:
    
            PR fortran/103137
            PR fortran/103138
            PR fortran/103693
            PR fortran/105243
            * gfortran.dg/class_58.f90: Fix test.
            * gfortran.dg/class_73.f90: New test.
    
    Co-authored-by: Steven G. Kargl <kargl@gcc.gnu.org>
    (cherry picked from commit 4c233cabbe388a6b8957c1507e129090e9267ceb)

diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c
index a007bb15333..e7b745b0cdb 100644
--- a/gcc/fortran/decl.c
+++ b/gcc/fortran/decl.c
@@ -6181,6 +6181,14 @@ gfc_match_data_decl (void)
       goto cleanup;
     }
 
+  /* F2018:C708.  */
+  if (current_ts.type == BT_CLASS && current_attr.flavor == FL_PARAMETER)
+    {
+      gfc_error ("CLASS entity at %C cannot have the PARAMETER attribute");
+      m = MATCH_ERROR;
+      goto cleanup;
+    }
+
   if (current_ts.type == BT_CLASS
 	&& current_ts.u.derived->attr.unlimited_polymorphic)
     goto ok;
diff --git a/gcc/testsuite/gfortran.dg/class_58.f90 b/gcc/testsuite/gfortran.dg/class_58.f90
index 20b601a2f51..fceb575432d 100644
--- a/gcc/testsuite/gfortran.dg/class_58.f90
+++ b/gcc/testsuite/gfortran.dg/class_58.f90
@@ -9,5 +9,5 @@ subroutine s
   end type
   class(t), parameter :: x = t()  ! { dg-error "cannot have the PARAMETER attribute" }
   class(t), parameter :: y = x    ! { dg-error "cannot have the PARAMETER attribute" }
-  class(t) :: z = x               ! { dg-error "must be dummy, allocatable or pointer" }
+  class(t) :: z = t()             ! { dg-error "must be dummy, allocatable or pointer" }
 end
diff --git a/gcc/testsuite/gfortran.dg/class_73.f90 b/gcc/testsuite/gfortran.dg/class_73.f90
new file mode 100644
index 00000000000..c11ee38c086
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/class_73.f90
@@ -0,0 +1,17 @@
+! { dg-do compile }
+! Error recovery on invalid CLASS(), PARAMETER declarations
+! PR fortran/103137
+! PR fortran/103138
+! PR fortran/103693
+! PR fortran/105243
+! Contributed by G.Steinmetz
+
+program p
+  type t
+     character(3) :: c = '(a)'
+  end type
+  class(t), parameter :: x = 1.  ! { dg-error "PARAMETER attribute" }
+  class(*), parameter :: y = t() ! { dg-error "PARAMETER attribute" }
+  class(*), parameter :: z = 1   ! { dg-error "PARAMETER attribute" }
+  print x%c                      ! { dg-error "Syntax error" }
+end

commit 395fc5b23d4fa110b2eb5e83b74b081cdceecfaf
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Mon Jul 4 00:17:14 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 758f2bf605e..d9297661e68 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20220703
+20220704
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index c863c8e9833..8fbe8cbf081 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,27 @@
+2022-07-03  Harald Anlauf  <anlauf@gmx.de>
+
+	Backported from master:
+	2022-06-30  Harald Anlauf  <anlauf@gmx.de>
+		    Steven G. Kargl  <kargl@gcc.gnu.org>
+
+	PR fortran/103137
+	PR fortran/103138
+	PR fortran/103693
+	PR fortran/105243
+	* decl.c (gfc_match_data_decl): Reject CLASS entity declaration
+	when it is given the PARAMETER attribute.
+
+2022-07-03  Harald Anlauf  <anlauf@gmx.de>
+
+	Backported from master:
+	2022-06-29  Harald Anlauf  <anlauf@gmx.de>
+		    Steven G. Kargl  <kargl@gcc.gnu.org>
+
+	PR fortran/106121
+	* simplify.c (gfc_simplify_extends_type_of): Do not attempt to
+	simplify when one of the arguments is a CLASS variable that was
+	not properly declared.
+
 2022-07-01  Harald Anlauf  <anlauf@gmx.de>
 
 	Backported from master:
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index c37b678571e..17eb57c7863 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,25 @@
+2022-07-03  Harald Anlauf  <anlauf@gmx.de>
+
+	Backported from master:
+	2022-06-30  Harald Anlauf  <anlauf@gmx.de>
+		    Steven G. Kargl  <kargl@gcc.gnu.org>
+
+	PR fortran/103137
+	PR fortran/103138
+	PR fortran/103693
+	PR fortran/105243
+	* gfortran.dg/class_58.f90: Fix test.
+	* gfortran.dg/class_73.f90: New test.
+
+2022-07-03  Harald Anlauf  <anlauf@gmx.de>
+
+	Backported from master:
+	2022-06-29  Harald Anlauf  <anlauf@gmx.de>
+		    Steven G. Kargl  <kargl@gcc.gnu.org>
+
+	PR fortran/106121
+	* gfortran.dg/extends_type_of_4.f90: New test.
+
 2022-07-01  Harald Anlauf  <anlauf@gmx.de>
 
 	Backported from master:

commit ea15c0f193d3590c6581a400badbd2d6faec9132
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Tue Jul 5 00:17:43 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index d9297661e68..7111af089e5 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20220704
+20220705

commit 0b909ae026e5aaf2ce42ef5c33128dbc06d29803
Author: Iain Buclaw <ibuclaw@gdcproject.org>
Date:   Wed Jun 29 21:52:39 2022 +0200

    d: Fix error: aggregate value used where floating point was expected
    
    Casting from vector to static array is permitted, and the frontend
    generates a reinterpret cast, but casting back the other way resulted in
    an error.  This has been fixed to be properly handled in the code
    generation pass of VectorExp, and the conversion for lvalue and rvalue
    handling done in convert_expr and convert_for_rvalue respectively.
    
            PR d/106139
    
    gcc/d/ChangeLog:
    
            * d-convert.cc (convert_expr): Handle casting from array to vector.
            (convert_for_rvalue): Rewrite vector to array casts of the same
            element type into a constructor.
            (convert_for_assignment): Return calling convert_for_rvalue.
            * dmd/expressionsem.c (ExpressionSemanticVisitor::visit): Run semantic
            on vector expression after lowering.
            * expr.cc (ExprVisitor::visit (VectorExp *)): Handle generating a
            vector expression from a static array.
    
    gcc/testsuite/ChangeLog:
    
            * gdc.dg/pr106139a.d: New test.
            * gdc.dg/pr106139b.d: New test.
            * gdc.dg/pr106139c.d: New test.
            * gdc.dg/pr106139d.d: New test.
            * gdc.test/fail_compilation/ice20264.d: New test.
    
    (cherry picked from commit 488759b7ea16972c4dfbb62926cd71996b1f77a7)

diff --git a/gcc/d/d-convert.cc b/gcc/d/d-convert.cc
index 87062513c33..2cfc2c8cc19 100644
--- a/gcc/d/d-convert.cc
+++ b/gcc/d/d-convert.cc
@@ -502,6 +502,15 @@ convert_expr (tree exp, Type *etype, Type *totype)
 	  gcc_assert (totype->size () == etype->size ());
 	  result = build_vconvert (build_ctype (totype), exp);
 	}
+      else if (tbtype->ty == Tvector && tbtype->size () == ebtype->size ())
+	{
+	  /* Allow casting from array to vector as if its an unaligned load.  */
+	  tree type = build_ctype (totype);
+	  tree unaligned_type = build_variant_type_copy (type);
+	  SET_TYPE_ALIGN (unaligned_type, 1 * BITS_PER_UNIT);
+	  TYPE_USER_ALIGN (unaligned_type) = 1;
+	  result = convert (type, build_vconvert (unaligned_type, exp));
+	}
       else
 	{
 	  error ("cannot cast expression of type %qs to type %qs",
@@ -634,6 +643,39 @@ convert_for_rvalue (tree expr, Type *etype, Type *totype)
       break;
     }
 
+  if (tbtype->ty == Tsarray
+      && ebtype->ty == Tsarray
+      && tbtype->nextOf ()->ty == ebtype->nextOf ()->ty
+      && INDIRECT_REF_P (expr)
+      && CONVERT_EXPR_CODE_P (TREE_CODE (TREE_OPERAND (expr, 0)))
+      && TREE_CODE (TREE_OPERAND (TREE_OPERAND (expr, 0), 0)) == ADDR_EXPR)
+    {
+      /* If expression is a vector that was casted to an array either by
+	 explicit type cast or by taking the vector's `.array' value, strip the
+	 reinterpret cast and build a constructor instead.  */
+      tree ptr = TREE_OPERAND (TREE_OPERAND (expr, 0), 0);
+
+      if (VECTOR_TYPE_P (TREE_TYPE (TREE_TYPE (ptr))))
+	{
+	  /* Rewrite: `*(Array *)&vector'
+		into: `{ vector[0], vector[1], ... }'  */
+	  tree array = d_save_expr (TREE_OPERAND (ptr, 0));
+	  array = build1 (VIEW_CONVERT_EXPR, TREE_TYPE (expr), array);
+
+	  uinteger_t dim = ((TypeSArray *)tbtype)->dim->toUInteger ();
+	  vec <constructor_elt, va_gc> *elms = NULL;
+	  for (uinteger_t i = 0; i < dim; i++)
+	    {
+	      tree index = size_int (i);
+	      tree value = build4 (ARRAY_REF, TREE_TYPE (TREE_TYPE (array)),
+				   array, index, NULL_TREE, NULL_TREE);
+	      CONSTRUCTOR_APPEND_ELT (elms, index, value);
+	    }
+
+	  return build_constructor (build_ctype (totype), elms);
+	}
+    }
+
   return result ? result : convert_expr (expr, etype, totype);
 }
 
@@ -694,7 +736,7 @@ convert_for_assignment (tree expr, Type *etype, Type *totype)
       return expr;
     }
 
-  return convert_expr (expr, etype, totype);
+  return convert_for_rvalue (expr, etype, totype);
 }
 
 /* Return a TREE representation of EXPR converted to represent
diff --git a/gcc/d/dmd/expressionsem.c b/gcc/d/dmd/expressionsem.c
index 5096754e55f..3c199bf1b57 100644
--- a/gcc/d/dmd/expressionsem.c
+++ b/gcc/d/dmd/expressionsem.c
@@ -4309,6 +4309,7 @@ public:
         if (tob->ty == Tvector && t1b->ty != Tvector)
         {
             result = new VectorExp(exp->loc, exp->e1, exp->to);
+            result = semantic(result, sc);
             return;
         }
 
diff --git a/gcc/d/expr.cc b/gcc/d/expr.cc
index a579356104e..aca767cc93b 100644
--- a/gcc/d/expr.cc
+++ b/gcc/d/expr.cc
@@ -2993,21 +2993,20 @@ public:
 
   void visit (VectorExp *e)
   {
-    tree type = build_ctype (e->type);
-    tree etype = TREE_TYPE (type);
-
     /* First handle array literal expressions.  */
     if (e->e1->op == TOKarrayliteral)
       {
 	ArrayLiteralExp *ale = ((ArrayLiteralExp *) e->e1);
 	vec<constructor_elt, va_gc> *elms = NULL;
 	bool constant_p = true;
+	tree type = build_ctype (e->type);
 
 	vec_safe_reserve (elms, ale->elements->dim);
 	for (size_t i = 0; i < ale->elements->dim; i++)
 	  {
 	    Expression *expr = ale->getElement (i);
-	    tree value = d_convert (etype, build_expr (expr, this->constp_));
+	    tree value = d_convert (TREE_TYPE (type),
+				    build_expr (expr, this->constp_));
 	    if (!CONSTANT_CLASS_P (value))
 	      constant_p = false;
 
@@ -3020,10 +3019,18 @@ public:
 	else
 	  this->result_ = build_constructor (type, elms);
       }
+    else if (e->e1->type->toBasetype ()->ty == Tsarray)
+      {
+	/* Build a vector representation from a static array.  */
+	this->result_ = convert_expr (build_expr (e->e1, this->constp_),
+				      e->e1->type, e->type);
+      }
     else
       {
 	/* Build constructor from single value.  */
-	tree val = d_convert (etype, build_expr (e->e1, this->constp_));
+	tree type = build_ctype (e->type);
+	tree val = d_convert (TREE_TYPE (type),
+			      build_expr (e->e1, this->constp_));
 	this->result_ = build_vector_from_val (type, val);
       }
   }
diff --git a/gcc/testsuite/gdc.dg/pr106139a.d b/gcc/testsuite/gdc.dg/pr106139a.d
new file mode 100644
index 00000000000..f635eabc745
--- /dev/null
+++ b/gcc/testsuite/gdc.dg/pr106139a.d
@@ -0,0 +1,36 @@
+// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106139
+// { dg-do compile }
+
+alias A = int[4];
+
+static if (__traits(compiles, __vector(A))):
+
+A vector2array(__vector(A) v)
+{
+    return cast(A)v;
+}
+
+void vector2array(ref A a, __vector(A) v)
+{
+    a = cast(A)v;
+}
+
+__vector(A) array2vector(A a)
+{
+    return cast(__vector(A)) a;
+}
+
+void array2vector(ref __vector(A) v, A a)
+{
+    v = cast(__vector(A))a;
+}
+
+A vector2array_array(__vector(A) v)
+{
+    return v.array;
+}
+
+void vector2array_array(ref A a, __vector(A) v)
+{
+    a = v.array;
+}
diff --git a/gcc/testsuite/gdc.dg/pr106139b.d b/gcc/testsuite/gdc.dg/pr106139b.d
new file mode 100644
index 00000000000..f9caf026f86
--- /dev/null
+++ b/gcc/testsuite/gdc.dg/pr106139b.d
@@ -0,0 +1,36 @@
+// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106139
+// { dg-do compile }
+
+alias A = float[4];
+
+static if (__traits(compiles, __vector(A))):
+
+A vector2array(__vector(A) v)
+{
+    return cast(A)v;
+}
+
+void vector2array(ref A a, __vector(A) v)
+{
+    a = cast(A)v;
+}
+
+__vector(A) array2vector(A a)
+{
+    return cast(__vector(A)) a;
+}
+
+void array2vector(ref __vector(A) v, A a)
+{
+    v = cast(__vector(A))a;
+}
+
+A vector2array_array(__vector(A) v)
+{
+    return v.array;
+}
+
+void vector2array_array(ref A a, __vector(A) v)
+{
+    a = v.array;
+}
diff --git a/gcc/testsuite/gdc.dg/pr106139c.d b/gcc/testsuite/gdc.dg/pr106139c.d
new file mode 100644
index 00000000000..3b6b7a83341
--- /dev/null
+++ b/gcc/testsuite/gdc.dg/pr106139c.d
@@ -0,0 +1,27 @@
+// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106139
+// { dg-do compile }
+
+alias V = int[4];
+alias A = float[4];
+
+static if (__traits(compiles, __vector(V))):
+
+A vector2array(__vector(V) v)
+{
+    return cast(A)v;
+}
+
+void vector2array(ref A a, __vector(V) v)
+{
+    a = cast(A)v;
+}
+
+__vector(V) array2vector(A a)
+{
+    return cast(__vector(V)) a;
+}
+
+void array2vector(ref __vector(V) v, A a)
+{
+    v = cast(__vector(V))a;
+}
diff --git a/gcc/testsuite/gdc.dg/pr106139d.d b/gcc/testsuite/gdc.dg/pr106139d.d
new file mode 100644
index 00000000000..4c6f0ef3a3a
--- /dev/null
+++ b/gcc/testsuite/gdc.dg/pr106139d.d
@@ -0,0 +1,27 @@
+// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106139
+// { dg-do compile }
+
+alias V = float[4];
+alias A = int[4];
+
+static if (__traits(compiles, __vector(V))):
+
+A vector2array(__vector(V) v)
+{
+    return cast(A)v;
+}
+
+void vector2array(ref A a, __vector(V) v)
+{
+    a = cast(A)v;
+}
+
+__vector(V) array2vector(A a)
+{
+    return cast(__vector(V)) a;
+}
+
+void array2vector(ref __vector(V) v, A a)
+{
+    v = cast(__vector(V))a;
+}
diff --git a/gcc/testsuite/gdc.test/fail_compilation/ice20264.d b/gcc/testsuite/gdc.test/fail_compilation/ice20264.d
new file mode 100644
index 00000000000..0d697e22c9f
--- /dev/null
+++ b/gcc/testsuite/gdc.test/fail_compilation/ice20264.d
@@ -0,0 +1,13 @@
+/*
+DISABLED: freebsd32 linux32 osx32 win32
+TEST_OUTPUT:
+---
+fail_compilation/ice20264.d(12): Error: `cast(__vector(float[4]))a` is not an lvalue and cannot be modified
+---
+*/
+
+void foo(float *a)
+{
+    alias float4 = __vector(float[4]);
+    cast(float4)(a) = 1.0f;
+}

commit 0c4298386cfdc759ac13d9614b7add715acf8155
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Wed Jul 6 00:17:32 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 7111af089e5..ebfebbb1842 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20220705
+20220706
diff --git a/gcc/d/ChangeLog b/gcc/d/ChangeLog
index fcbe06a1d8e..b5c1b2297a4 100644
--- a/gcc/d/ChangeLog
+++ b/gcc/d/ChangeLog
@@ -1,3 +1,18 @@
+2022-07-05  Iain Buclaw  <ibuclaw@gdcproject.org>
+
+	Backported from master:
+	2022-07-04  Iain Buclaw  <ibuclaw@gdcproject.org>
+
+	PR d/106139
+	* d-convert.cc (convert_expr): Handle casting from array to vector.
+	(convert_for_rvalue): Rewrite vector to array casts of the same
+	element type into a constructor.
+	(convert_for_assignment): Return calling convert_for_rvalue.
+	* dmd/expressionsem.c (ExpressionSemanticVisitor::visit): Run semantic
+	on vector expression after lowering.
+	* expr.cc (ExprVisitor::visit (VectorExp *)): Handle generating a
+	vector expression from a static array.
+
 2022-06-28  Release Manager
 
 	* GCC 10.4.0 released.
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 17eb57c7863..c21639a2b06 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,15 @@
+2022-07-05  Iain Buclaw  <ibuclaw@gdcproject.org>
+
+	Backported from master:
+	2022-07-04  Iain Buclaw  <ibuclaw@gdcproject.org>
+
+	PR d/106139
+	* gdc.dg/pr106139a.d: New test.
+	* gdc.dg/pr106139b.d: New test.
+	* gdc.dg/pr106139c.d: New test.
+	* gdc.dg/pr106139d.d: New test.
+	* gdc.test/fail_compilation/ice20264.d: New test.
+
 2022-07-03  Harald Anlauf  <anlauf@gmx.de>
 
 	Backported from master:

commit 86a2cc7b71ddc296bdd69fcf6638db031893249f
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Thu Jul 7 00:17:32 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index ebfebbb1842..56ceb7f4c69 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20220706
+20220707

commit 1d6edb7865fa56ce347063bdd123c34924335a91
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Fri Jul 8 00:17:24 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 56ceb7f4c69..aa8fe3c8911 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20220707
+20220708

commit 558c3a96e0503d98e4f1cec200ea3672a80180e8
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sat Jul 9 00:17:48 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index aa8fe3c8911..2f349b0ec04 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20220708
+20220709

commit cfacfd452cb7cb973ab9df556137761b6027b67a
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sun Jul 10 00:17:34 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 2f349b0ec04..6de1e01bae4 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20220709
+20220710

commit e026b23a14440113ac6d9994895d2a7c81843bef
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Mon Jul 11 00:17:42 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 6de1e01bae4..691f2ec33d6 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20220710
+20220711

commit a96788c5db290b2ea4b83c4ecaf8cc2abf06ad1b
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Tue Jul 12 00:17:32 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 691f2ec33d6..40dba6d5aa0 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20220711
+20220712

commit daf99eafaec7c043d85f53cc4f15f737fe9897f0
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Wed Jul 13 00:17:37 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 40dba6d5aa0..e8fa68bf91e 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20220712
+20220713

commit 2691107f973770bafc84b9e8aae7c791053f411e
Author: Martin Jambor <mjambor@suse.cz>
Date:   Wed Jul 13 13:17:25 2022 +0200

    tree-sra: Fix union handling in build_reconstructed_reference
    
    As the testcase in PR 105860 shows, the code that tries to re-use the
    handled_component chains in SRA can be horribly confused by unions,
    where it thinks it has found a compatible structure under which it can
    chain the references, but in fact it found the type it was looking
    for elsewhere in a union and generated a write to a completely wrong
    part of an aggregate.
    
    I don't remember whether the plan was to support unions at all in
    build_reconstructed_reference but it can work, to an extent, if we
    make sure that we start the search only outside the outermost union,
    which is what the patch does (and the extra testcase verifies).
    
    Additionally, this commit also contains sqashed in it a backport of
    b984b84cbe4bf026edef2ba37685f3958a1dc1cf which fixes the testcase
    gcc.dg/tree-ssa/alias-access-path-13.c for many 32-bit targets.
    
    gcc/ChangeLog:
    
    2022-07-01  Martin Jambor  <mjambor@suse.cz>
    
            PR tree-optimization/105860
            * tree-sra.c (build_reconstructed_reference): Start expr
            traversal only just below the outermost union.
    
    gcc/testsuite/ChangeLog:
    
    2022-07-01  Martin Jambor  <mjambor@suse.cz>
    
            PR tree-optimization/105860
            * gcc.dg/tree-ssa/alias-access-path-13.c: New test.
            * gcc.dg/tree-ssa/pr105860.c: Likewise.
    
    (cherry picked from commit b110e5283e368b5377e04766e4ff82cd52634208)

diff --git a/gcc/testsuite/gcc.dg/tree-ssa/alias-access-path-13.c b/gcc/testsuite/gcc.dg/tree-ssa/alias-access-path-13.c
new file mode 100644
index 00000000000..87a94f5bf31
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/alias-access-path-13.c
@@ -0,0 +1,36 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-fre1" } */
+
+struct inn
+{
+  int val;
+};
+
+struct biggerstruct
+{
+  int a, b;
+};
+
+union foo
+{
+  struct inn inn;
+  struct biggerstruct baz;
+} *fooptr;
+
+struct bar
+{
+  union foo foo;
+  int val2;
+} *barptr;
+
+int
+test ()
+{
+  union foo foo;
+  foo.inn.val = 0;
+  barptr->val2 = 123;
+  *fooptr = foo;
+  return barptr->val2;
+}
+
+/* { dg-final { scan-tree-dump-times "return 123" 1 "fre1"} } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr105860.c b/gcc/testsuite/gcc.dg/tree-ssa/pr105860.c
new file mode 100644
index 00000000000..77bcb4a6739
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr105860.c
@@ -0,0 +1,63 @@
+/* { dg-do run } */
+/* { dg-options "-O1" } */
+
+struct S1  {
+        unsigned int _0;
+        unsigned int _1;
+} ;
+struct S2  {
+        struct S1 _s1;
+        unsigned long _x2;
+} ;
+
+struct ufld_type1  {
+        unsigned int _u1t;
+        struct S2 _s2;
+} ;
+
+struct ufld_type2  {
+        unsigned int _u2t;
+        struct S1 _s1;
+} ;
+struct parm_type {
+        union {
+                struct ufld_type1 var_1;
+                struct ufld_type2 var_2;
+        } U;
+};
+
+struct parm_type  bad_function( struct parm_type arg0 )
+{
+        struct parm_type rv;
+        struct S2 var4;
+        switch( arg0.U.var_2._u2t ) {
+        case 4294967041:
+                var4._s1 = arg0.U.var_1._s2._s1;
+                rv.U.var_1._u1t = 4294967041;
+                rv.U.var_1._s2 = var4;
+                break;
+        case 4294967043:
+                rv.U.var_2._u2t = 4294967043;
+                rv.U.var_2._s1 = arg0.U.var_2._s1;
+                break;
+        default:
+                break;
+        }
+        return rv;
+}
+
+int main() {
+        struct parm_type val;
+        struct parm_type out;
+        val.U.var_2._u2t = 4294967043;
+        val.U.var_2._s1._0 = 0x01010101;
+        val.U.var_2._s1._1 = 0x02020202;
+        out = bad_function(val);
+	if (val.U.var_2._u2t != 4294967043)
+	  __builtin_abort ();
+        if (out.U.var_2._s1._0 != 0x01010101)
+	  __builtin_abort ();
+        if (val.U.var_2._s1._1 != 0x02020202 )
+	  __builtin_abort ();
+	return 0;
+}
diff --git a/gcc/tree-sra.c b/gcc/tree-sra.c
index 09d951a261b..420329f63f6 100644
--- a/gcc/tree-sra.c
+++ b/gcc/tree-sra.c
@@ -1647,7 +1647,18 @@ build_ref_for_offset (location_t loc, tree base, poly_int64 offset,
 static tree
 build_reconstructed_reference (location_t, tree base, struct access *model)
 {
-  tree expr = model->expr, prev_expr = NULL;
+  tree expr = model->expr;
+  /* We have to make sure to start just below the outermost union.  */
+  tree start_expr = expr;
+  while (handled_component_p (expr))
+    {
+      if (TREE_CODE (TREE_TYPE (TREE_OPERAND (expr, 0))) == UNION_TYPE)
+	start_expr = expr;
+      expr = TREE_OPERAND (expr, 0);
+    }
+
+  expr = start_expr;
+  tree prev_expr = NULL_TREE;
   while (!types_compatible_p (TREE_TYPE (expr), TREE_TYPE (base)))
     {
       if (!handled_component_p (expr))

commit b0bb0a8d75295b7d36c5f0a979dea77adb307579
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Thu Jul 14 00:17:34 2022 +0000

    Daily bump.

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 1cfbda8124e..beeead03e21 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,12 @@
+2022-07-13  Martin Jambor  <mjambor@suse.cz>
+
+	Backported from master:
+	2022-07-04  Martin Jambor  <mjambor@suse.cz>
+
+	PR tree-optimization/105860
+	* tree-sra.c (build_reconstructed_reference): Start expr
+	traversal only just below the outermost union.
+
 2022-06-28  Release Manager
 
 	* GCC 10.4.0 released.
diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index e8fa68bf91e..56754ca716d 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20220713
+20220714
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index c21639a2b06..5e031d964d9 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,12 @@
+2022-07-13  Martin Jambor  <mjambor@suse.cz>
+
+	Backported from master:
+	2022-07-04  Martin Jambor  <mjambor@suse.cz>
+
+	PR tree-optimization/105860
+	* gcc.dg/tree-ssa/alias-access-path-13.c: New test.
+	* gcc.dg/tree-ssa/pr105860.c: Likewise.
+
 2022-07-05  Iain Buclaw  <ibuclaw@gdcproject.org>
 
 	Backported from master:

commit 50b5bd99365ba80836b2bc19c460af7a6a7d975a
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Fri Jul 15 00:17:42 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 56754ca716d..5d08726610c 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20220714
+20220715

commit f9b5db872559dd59443c989c31b6caef0ce70e68
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sat Jul 16 00:17:36 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 5d08726610c..cedfb434cc2 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20220715
+20220716

commit 168a1ae79bb86bdfe482c7c80ea742d40cc414c5
Author: Steve Kargl <kargl@gcc.gnu.org>
Date:   Fri Jul 15 22:07:15 2022 +0200

    Fortran: do not generate conflicting results under -ff2c [PR104313]
    
    gcc/fortran/ChangeLog:
    
            PR fortran/104313
            * trans-decl.c (gfc_generate_return): Do not generate conflicting
            fake results for functions with no result variable under -ff2c.
    
    gcc/testsuite/ChangeLog:
    
            PR fortran/104313
            * gfortran.dg/pr104313.f: New test.
    
    (cherry picked from commit 517fb1a78102df43f052c6934c27dd51d786aff7)

diff --git a/gcc/fortran/trans-decl.c b/gcc/fortran/trans-decl.c
index 8aa71ede989..765c492520c 100644
--- a/gcc/fortran/trans-decl.c
+++ b/gcc/fortran/trans-decl.c
@@ -6545,7 +6545,7 @@ gfc_generate_return (void)
 	     NULL_TREE, and a 'return' is generated without a variable.
 	     The following generates a 'return __result_XXX' where XXX is
 	     the function name.  */
-	  if (sym == sym->result && sym->attr.function)
+	  if (sym == sym->result && sym->attr.function && !flag_f2c)
 	    {
 	      result = gfc_get_fake_result_decl (sym, 0);
 	      result = fold_build2_loc (input_location, MODIFY_EXPR,
diff --git a/gcc/testsuite/gfortran.dg/pr104313.f b/gcc/testsuite/gfortran.dg/pr104313.f
new file mode 100644
index 00000000000..89c8947cb0a
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr104313.f
@@ -0,0 +1,11 @@
+! { dg-do compile }
+! { dg-additional-options "-ff2c -fdump-tree-original" }
+!
+! PR fortran/104313 - ICE verify_gimple failed with -ff2c
+! Contributed by G.Steinmetz
+
+      function f(a)
+      return
+      end
+
+! { dg-final { scan-tree-dump-times "return" 1 "original" } }

commit 6b994278f9932daf08ab8d1d93459ee8af2179ac
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sun Jul 17 00:17:36 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index cedfb434cc2..19c3fb767e6 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20220716
+20220717
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 8fbe8cbf081..d563e4ec851 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,12 @@
+2022-07-16  Steve Kargl  <kargl@gcc.gnu.org>
+
+	Backported from master:
+	2022-07-15  Steve Kargl  <kargl@gcc.gnu.org>
+
+	PR fortran/104313
+	* trans-decl.c (gfc_generate_return): Do not generate conflicting
+	fake results for functions with no result variable under -ff2c.
+
 2022-07-03  Harald Anlauf  <anlauf@gmx.de>
 
 	Backported from master:
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 5e031d964d9..77effd479a3 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,11 @@
+2022-07-16  Steve Kargl  <kargl@gcc.gnu.org>
+
+	Backported from master:
+	2022-07-15  Steve Kargl  <kargl@gcc.gnu.org>
+
+	PR fortran/104313
+	* gfortran.dg/pr104313.f: New test.
+
 2022-07-13  Martin Jambor  <mjambor@suse.cz>
 
 	Backported from master:

commit 142b66f30d1ef9b7fbaf7833e5bf3e14bbccd0d3
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Mon Jul 18 00:17:35 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 19c3fb767e6..2ac54796c00 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20220717
+20220718

commit d6304c1c15eb21c01223bfe71eb61e3b15dee84c
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Tue Jul 19 00:17:46 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 2ac54796c00..a394c7af9b5 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20220718
+20220719

commit 0970568b510d467df640f1ba4483e6682d5466e3
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Wed Jul 20 00:17:39 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index a394c7af9b5..964c55ac941 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20220719
+20220720

commit 72f9b806504aec49915a437be206682fac9638ed
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Thu Jul 21 00:17:41 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 964c55ac941..ace4919765e 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20220720
+20220721

commit 6bd956e31b2fb6fe1eee4eb1bf309247dcd19b23
Author: Martin Liska <mliska@suse.cz>
Date:   Mon Jul 11 22:03:14 2022 +0200

    libsanitizer: cherry-pick 9cf13067cb5088626ba7 from upstream
    
    9cf13067cb5088626ba7ee1ec4c42ec59c7995a0 [sanitizer] Remove #include <linux/fs.h> to resolve fsconfig_command/mount_attr conflict with glibc 2.36
    
    (cherry picked from commit 2701442d0cf6292f6624443c15813d6d1a3562fe)

diff --git a/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cpp b/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cpp
index badf6a401cc..670c2f20653 100644
--- a/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cpp
+++ b/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cpp
@@ -72,7 +72,9 @@
 #include <sys/vt.h>
 #include <linux/cdrom.h>
 #include <linux/fd.h>
+#if SANITIZER_ANDROID
 #include <linux/fs.h>
+#endif
 #include <linux/hdreg.h>
 #include <linux/input.h>
 #include <linux/ioctl.h>
@@ -822,10 +824,10 @@ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr);
   unsigned IOCTL_EVIOCGPROP = IOCTL_NOT_PRESENT;
   unsigned IOCTL_EVIOCSKEYCODE_V2 = IOCTL_NOT_PRESENT;
 #endif
-  unsigned IOCTL_FS_IOC_GETFLAGS = FS_IOC_GETFLAGS;
-  unsigned IOCTL_FS_IOC_GETVERSION = FS_IOC_GETVERSION;
-  unsigned IOCTL_FS_IOC_SETFLAGS = FS_IOC_SETFLAGS;
-  unsigned IOCTL_FS_IOC_SETVERSION = FS_IOC_SETVERSION;
+  unsigned IOCTL_FS_IOC_GETFLAGS = _IOR('f', 1, long);
+  unsigned IOCTL_FS_IOC_GETVERSION = _IOR('v', 1, long);
+  unsigned IOCTL_FS_IOC_SETFLAGS = _IOW('f', 2, long);
+  unsigned IOCTL_FS_IOC_SETVERSION = _IOW('v', 2, long);
   unsigned IOCTL_GIO_CMAP = GIO_CMAP;
   unsigned IOCTL_GIO_FONT = GIO_FONT;
   unsigned IOCTL_GIO_UNIMAP = GIO_UNIMAP;

commit 8c3238510ce63c75024c0288eade5c933f6d322e
Author: Ian Lance Taylor <iant@golang.org>
Date:   Tue Jul 12 19:42:43 2022 -0700

    libgo: don't include <linux/fs.h> when building gen-sysinfo.go
    
    Removing this doesn't change anything at least with glibc 2.33.
    The include was added in https://go.dev/cl/6100049 but it's not
    clear why.
    
    Fixes PR go/106266
    
    Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/417294
    (cherry picked from commit f35d65517a59565758107c5b1a51a5fa382f8d1a)

diff --git a/libgo/sysinfo.c b/libgo/sysinfo.c
index 0692fd41eb7..1825387c710 100644
--- a/libgo/sysinfo.c
+++ b/libgo/sysinfo.c
@@ -150,9 +150,6 @@
 #if defined(HAVE_LINUX_ETHER_H)
 #include <linux/ether.h>
 #endif
-#if defined(HAVE_LINUX_FS_H)
-#include <linux/fs.h>
-#endif
 #if defined(HAVE_LINUX_REBOOT_H)
 #include <linux/reboot.h>
 #endif

commit 5b737e03204666ca3b3f9c8c56af8a7409acca4f
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Fri Jul 22 00:17:28 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index ace4919765e..7bdcd4fa865 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20220721
+20220722

commit 2753c7d0cd95a3db9d97c5ee674917ad11de5246
Author: Surya Kumari Jangala <jskumari@linux.vnet.ibm.com>
Date:   Fri Jun 10 19:52:57 2022 +0530

    regrename: Fix -fcompare-debug issue in check_new_reg_p [PR105041]
    
    In check_new_reg_p, the nregs of a du chain is computed by obtaining the
    MODE of the first element in the chain, and then calling
    hard_regno_nregs() with the MODE. But the first element of the chain can
    be a DEBUG_INSN whose mode need not be the same as the rest of the
    elements in the du chain. This was resulting in fcompare-debug failure
    as check_new_reg_p was returning a different result with -g for the same
    candidate register. We can instead obtain nregs from the du chain
    itself.
    
    2022-06-10  Surya Kumari Jangala  <jskumari@linux.ibm.com>
    
    gcc/
            PR rtl-optimization/105041
            * regrename.c (check_new_reg_p): Use nregs value from du chain.
    
    gcc/testsuite/
            PR rtl-optimization/105041
            * gcc.target/powerpc/pr105041.c: New test.
    
    (cherry picked from commit 3e16b4359e86b36676ed01219e6deafa95f3c16b)

diff --git a/gcc/regrename.c b/gcc/regrename.c
index 669a6ead705..5ec46b45610 100644
--- a/gcc/regrename.c
+++ b/gcc/regrename.c
@@ -324,8 +324,7 @@ static bool
 check_new_reg_p (int reg ATTRIBUTE_UNUSED, int new_reg,
 		 class du_head *this_head, HARD_REG_SET this_unavailable)
 {
-  machine_mode mode = GET_MODE (*this_head->first->loc);
-  int nregs = hard_regno_nregs (new_reg, mode);
+  int nregs = this_head->nregs;
   int i;
   struct du_chain *tmp;
 
diff --git a/gcc/testsuite/gcc.target/powerpc/pr105041.c b/gcc/testsuite/gcc.target/powerpc/pr105041.c
new file mode 100644
index 00000000000..c52b7a5ef30
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/pr105041.c
@@ -0,0 +1,22 @@
+/* { dg-options "-mdejagnu-cpu=power4 -O2 -fcompare-debug -frename-registers" } */
+
+double m;
+int n;
+
+unsigned int
+foo (unsigned int x, int y)
+{
+  long long int a = y, b = !a;
+  int c = 0;
+
+  if (b != x)
+    while ((int) m == a)
+      {
+        c = a;
+        a = 0;
+      }
+
+  n = b = y;
+
+  return x + c;
+}

commit 2cad5c5c2de819b7a5177aa87e5e2fd088357b01
Author: Patrick Palka <ppalka@redhat.com>
Date:   Fri Jul 22 12:52:03 2022 -0400

    libstdc++: Fix backward compatibility of P2325R3 backport [PR106320]
    
    The 11 and 10 partial backports of P2325R3, r11-9555-g92d612cccc1eec and
    r10-10808-g22b86cdc4d7fdd, unnecessarily preserved some changes from the
    paper that made certain view specializations no longer default
    constructible, changes which aren't required to reap the overall benefits
    of the paper and which are backward incompatible with pre-P2325R3 code in
    practice.
    
    This patch reverts the problematic changes, specifically it relaxes the
    constraints on various views' default constructors added by the paper
    so that we keep only the constraints that were already implicitly
    imposed by the NSDMIs of the view.  Thus for example this patch retains
    the default_initializable<_Vp> constraint on transform_view's default
    constructor since its '_Vp _M_base = _Vp()' NSDMI already requires this
    constraint, and it removes the default_initializable<_Fp> constraint
    since the corresponding member '__detail::__box<_Fp> _M_fun' doesn't
    require default constructibility (specializations of __box are always
    default constructible).
    
    After reverting these changes, all static_asserts from p2325.cc that
    verify lack of default constructibility now fail as expected, matching
    the pre-P2325R3 behavior.
    
            PR libstdc++/106320
    
    libstdc++-v3/ChangeLog:
    
            * include/std/ranges (single_view): Relax constraints on
            default constructor so as to preserve pre-P2325R3 behavior.
            (filter_view): Likewise.
            (transform_view): Likewise.
            (take_while_view): Likewise.
            (drop_while_view): Likewise.
            * testsuite/std/ranges/adaptors/join.cc (test13): New test.
            * testsuite/std/ranges/p2325.cc: Fix S to be only non default
            constructible and not also non copy constructible.  XFAIL the
            tests that verify a non default constructible functor makes a
            view non default constructible (lines 94, 97 and 98).  XFAIL
            the test that effectively verifies a non default constructible
            element type makes single_view non default constructible (line
            114).
    
    (cherry picked from commit 36dd51bf87e1c533bf33ad3b16fd3fe06c356746)

diff --git a/libstdc++-v3/include/std/ranges b/libstdc++-v3/include/std/ranges
index 17018a5616c..faa55ebceb7 100644
--- a/libstdc++-v3/include/std/ranges
+++ b/libstdc++-v3/include/std/ranges
@@ -518,7 +518,7 @@ namespace ranges
     class single_view : public view_interface<single_view<_Tp>>
     {
     public:
-      single_view() requires default_initializable<_Tp> = default;
+      single_view() = default;
 
       constexpr explicit
       single_view(const _Tp& __t)
@@ -1592,9 +1592,7 @@ namespace views
       [[no_unique_address]] __detail::_CachedPosition<_Vp> _M_cached_begin;
 
     public:
-      filter_view() requires (default_initializable<_Vp>
-			      && default_initializable<_Pred>)
-	= default;
+      filter_view() requires default_initializable<_Vp> = default;
 
       constexpr
       filter_view(_Vp __base, _Pred __pred)
@@ -1940,9 +1938,7 @@ namespace views
       __detail::__box<_Fp> _M_fun;
 
     public:
-      transform_view() requires (default_initializable<_Vp>
-				 && default_initializable<_Fp>)
-	= default;
+      transform_view() requires default_initializable<_Vp> = default;
 
       constexpr
       transform_view(_Vp __base, _Fp __fun)
@@ -2220,9 +2216,7 @@ namespace views
       __detail::__box<_Pred> _M_pred;
 
     public:
-      take_while_view() requires (default_initializable<_Vp>
-				  && default_initializable<_Pred>)
-	= default;
+      take_while_view() requires default_initializable<_Vp> = default;
 
       constexpr
       take_while_view(_Vp base, _Pred __pred)
@@ -2389,9 +2383,7 @@ namespace views
       [[no_unique_address]] __detail::_CachedPosition<_Vp> _M_cached_begin;
 
     public:
-      drop_while_view() requires (default_initializable<_Vp>
-				  && default_initializable<_Pred>)
-	= default;
+      drop_while_view() requires default_initializable<_Vp> = default;
 
       constexpr
       drop_while_view(_Vp __base, _Pred __pred)
diff --git a/libstdc++-v3/testsuite/std/ranges/adaptors/join.cc b/libstdc++-v3/testsuite/std/ranges/adaptors/join.cc
index 9c0231b704b..c75fb8142cc 100644
--- a/libstdc++-v3/testsuite/std/ranges/adaptors/join.cc
+++ b/libstdc++-v3/testsuite/std/ranges/adaptors/join.cc
@@ -159,6 +159,21 @@ test10()
   VERIFY( ranges::next(v.begin()) == v.end() );
 }
 
+
+void
+test13()
+{
+  // PR libstdc++/106320
+  auto l = std::views::transform([](auto x) {
+    return x | std::views::transform([x=0](auto y) {
+      return y;
+    });
+  });
+  static_assert(!std::default_initializable<decltype(l)>);
+  std::vector<std::vector<int>> v{{5, 6, 7}};
+  v | l | std::views::join;
+}
+
 int
 main()
 {
@@ -171,4 +186,5 @@ main()
   test07();
   test08();
   test10();
+  test13();
 }
diff --git a/libstdc++-v3/testsuite/std/ranges/p2325.cc b/libstdc++-v3/testsuite/std/ranges/p2325.cc
index aff3bd6ca28..8dbce6d6db8 100644
--- a/libstdc++-v3/testsuite/std/ranges/p2325.cc
+++ b/libstdc++-v3/testsuite/std/ranges/p2325.cc
@@ -5,8 +5,8 @@
 // Parts of P2325R3 are deliberately omitted in libstdc++ 10, in particular the
 // removal of default ctors for back_/front_insert_iterator, ostream_iterator,
 // ref_view and basic_istream_view/::iterator, so as to maximize backward
-// compatibility with pre-P2325R3 code.  So most static_asserts in this test fail,
-// see the xfails at the end of this file.
+// compatibility with pre-P2325R3 code.  Namely all asserts that verify lack of
+// default constructibility fail; see the xfails at the end of this file.
 
 #include <ranges>
 #include <iterator>
@@ -93,7 +93,7 @@ test06()
   static_assert(default_initializable<decltype(views::single(0) | adaptor(f1))>);
   static_assert(!default_initializable<decltype(views::single(0) | adaptor(f2))>);
 
-  struct S { S() = delete; };
+  struct S { S() = delete; S(const S&) = default; S(S&&) = default; };
   static_assert(!default_initializable<decltype(views::single(declval<S>()) | adaptor(f1))>);
   static_assert(!default_initializable<decltype(views::single(declval<S>()) | adaptor(f2))>);
 }
@@ -109,7 +109,7 @@ void
 test07()
 {
   // Verify join_view is conditionally default constructible.
-  struct S { S() = delete; };
+  struct S { S() = delete; S(const S&) = default; S(S&&) = default; };
   using type1 = ranges::join_view<ranges::single_view<ranges::single_view<S>>>;
   static_assert(!default_initializable<type1>);
   using type2 = ranges::join_view<ranges::single_view<ranges::single_view<int>>>;
@@ -173,6 +173,10 @@ test11()
 // { dg-bogus "static assertion failed" "" { xfail *-*-* } 76 }
 // { dg-bogus "static assertion failed" "" { xfail *-*-* } 77 }
 // { dg-bogus "static assertion failed" "" { xfail *-*-* } 84 }
+// { dg-bogus "static assertion failed" "" { xfail *-*-* } 94 }
+// { dg-bogus "static assertion failed" "" { xfail *-*-* } 97 }
+// { dg-bogus "static assertion failed" "" { xfail *-*-* } 98 }
+// { dg-bogus "static assertion failed" "" { xfail *-*-* } 114 }
 // { dg-bogus "static assertion failed" "" { xfail *-*-* } 124 }
 // { dg-bogus "static assertion failed" "" { xfail *-*-* } 126 }
 // { dg-bogus "static assertion failed" "" { xfail *-*-* } 128 }

commit 4182b95aa61b5bb97058b1f11ed3ffe97eb0c3df
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sat Jul 23 00:17:24 2022 +0000

    Daily bump.

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index beeead03e21..14449e03428 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,11 @@
+2022-07-22  Surya Kumari Jangala  <jskumari@linux.vnet.ibm.com>
+
+	Backported from master:
+	2022-06-14  Surya Kumari Jangala  <jskumari@linux.ibm.com>
+
+	PR rtl-optimization/105041
+	* regrename.c (check_new_reg_p): Use nregs value from du chain.
+
 2022-07-13  Martin Jambor  <mjambor@suse.cz>
 
 	Backported from master:
diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 7bdcd4fa865..ef960813d5e 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20220722
+20220723
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 77effd479a3..a890b7a3548 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,11 @@
+2022-07-22  Surya Kumari Jangala  <jskumari@linux.vnet.ibm.com>
+
+	Backported from master:
+	2022-06-14  Surya Kumari Jangala  <jskumari@linux.ibm.com>
+
+	PR rtl-optimization/105041
+	* gcc.target/powerpc/pr105041.c: New test.
+
 2022-07-16  Steve Kargl  <kargl@gcc.gnu.org>
 
 	Backported from master:
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index ad0c46e655a..ab2d0a9883f 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,24 @@
+2022-07-22  Patrick Palka  <ppalka@redhat.com>
+
+	Backported from master:
+	2022-07-22  Patrick Palka  <ppalka@redhat.com>
+
+	PR libstdc++/106320
+	* include/std/ranges (single_view): Relax constraints on
+	default constructor so as to preserve pre-P2325R3 behavior.
+	(filter_view): Likewise.
+	(transform_view): Likewise.
+	(take_while_view): Likewise.
+	(drop_while_view): Likewise.
+	* testsuite/std/ranges/adaptors/join.cc (test13): New test.
+	* testsuite/std/ranges/p2325.cc: Fix S to be only non default
+	constructible and not also non copy constructible.  XFAIL the
+	tests that verify a non default constructible functor makes a
+	view non default constructible (lines 94, 97 and 98).  XFAIL
+	the test that effectively verifies a non default constructible
+	element type makes single_view non default constructible (line
+	114).
+
 2022-06-28  Release Manager
 
 	* GCC 10.4.0 released.

commit 32bbf76e4345a7961445b86a7cfccffa8a287fc1
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Fri Nov 5 21:42:20 2021 +0000

    libstdc++: Fix inconsistent noexcept-specific for valarray begin/end
    
    These declarations should be noexcept after I added it to the
    definitions in <valarray>.
    
    libstdc++-v3/ChangeLog:
    
            * include/bits/range_access.h (begin(valarray), end(valarray)):
            Add noexcept.
    
    (cherry picked from commit 2b2d97fc545635a0f6aa9c9ee3b017394bc494bf)

diff --git a/libstdc++-v3/include/bits/range_access.h b/libstdc++-v3/include/bits/range_access.h
index aee72c3fae4..98c81a153f3 100644
--- a/libstdc++-v3/include/bits/range_access.h
+++ b/libstdc++-v3/include/bits/range_access.h
@@ -104,10 +104,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
   template<typename _Tp> class valarray;
   // These overloads must be declared for cbegin and cend to use them.
-  template<typename _Tp> _Tp* begin(valarray<_Tp>&);
-  template<typename _Tp> const _Tp* begin(const valarray<_Tp>&);
-  template<typename _Tp> _Tp* end(valarray<_Tp>&);
-  template<typename _Tp> const _Tp* end(const valarray<_Tp>&);
+  template<typename _Tp> _Tp* begin(valarray<_Tp>&) noexcept;
+  template<typename _Tp> const _Tp* begin(const valarray<_Tp>&) noexcept;
+  template<typename _Tp> _Tp* end(valarray<_Tp>&) noexcept;
+  template<typename _Tp> const _Tp* end(const valarray<_Tp>&) noexcept;
 
   /**
    *  @brief  Return an iterator pointing to the first element of

commit 01c25003d2a21d199df22548c2c8a8110e755dc7
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Fri Jul 1 22:23:43 2022 +0100

    libstdc++: Add missing prerequisite to generated header [PR106162]
    
    The ${host_builddir}/largefile-config.h header can't be written until
    its parent directory has been created, so it needs to have the creation
    of that directory as a prerequisite.
    
    libstdc++-v3/ChangeLog:
    
            PR libstdc++/106162
            * include/Makefile.am (largefile-config.h): Add
            stamp-${host_alias} prerequisite.
            * include/Makefile.in: Regenerate.
    
    (cherry picked from commit 8a6ee426c2be3bd4359520e02c00ec60cac2fece)

diff --git a/libstdc++-v3/include/Makefile.am b/libstdc++-v3/include/Makefile.am
index fad5c683824..ffac9427434 100644
--- a/libstdc++-v3/include/Makefile.am
+++ b/libstdc++-v3/include/Makefile.am
@@ -1248,7 +1248,7 @@ stamp-float128:
 endif
 
 # This header is not installed, it's only used to build libstdc++ itself.
-${host_builddir}/largefile-config.h: ${CONFIG_HEADER}
+${host_builddir}/largefile-config.h: ${CONFIG_HEADER} stamp-${host_alias}
 	@rm -f $@.tmp
 	@-grep 'define _DARWIN_USE_64_BIT_INODE' ${CONFIG_HEADER} >> $@.tmp
 	@-grep 'define _FILE_OFFSET_BITS' ${CONFIG_HEADER} >> $@.tmp
diff --git a/libstdc++-v3/include/Makefile.in b/libstdc++-v3/include/Makefile.in
index 1ca4b7be55e..32e3c8e1f37 100644
--- a/libstdc++-v3/include/Makefile.in
+++ b/libstdc++-v3/include/Makefile.in
@@ -1729,7 +1729,7 @@ stamp-host: ${host_headers} ${bits_host_headers} ${ext_host_headers} ${host_head
 @ENABLE_FLOAT128_FALSE@	echo 'undef _GLIBCXX_USE_FLOAT128' > stamp-float128
 
 # This header is not installed, it's only used to build libstdc++ itself.
-${host_builddir}/largefile-config.h: ${CONFIG_HEADER}
+${host_builddir}/largefile-config.h: ${CONFIG_HEADER} stamp-${host_alias}
 	@rm -f $@.tmp
 	@-grep 'define _DARWIN_USE_64_BIT_INODE' ${CONFIG_HEADER} >> $@.tmp
 	@-grep 'define _FILE_OFFSET_BITS' ${CONFIG_HEADER} >> $@.tmp

commit 3f070b3561fe456e4158c44809ee7515dd755b7c
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sun Jul 24 00:17:24 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index ef960813d5e..a7decbb2bdb 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20220723
+20220724
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index ab2d0a9883f..c8b67bdb58b 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,21 @@
+2022-07-23  Jonathan Wakely  <jwakely@redhat.com>
+
+	Backported from master:
+	2022-07-01  Jonathan Wakely  <jwakely@redhat.com>
+
+	PR libstdc++/106162
+	* include/Makefile.am (largefile-config.h): Add
+	stamp-${host_alias} prerequisite.
+	* include/Makefile.in: Regenerate.
+
+2022-07-23  Jonathan Wakely  <jwakely@redhat.com>
+
+	Backported from master:
+	2021-11-05  Jonathan Wakely  <jwakely@redhat.com>
+
+	* include/bits/range_access.h (begin(valarray), end(valarray)):
+	Add noexcept.
+
 2022-07-22  Patrick Palka  <ppalka@redhat.com>
 
 	Backported from master:

commit 85c14be4041b017cbb807923ad81d39a6aadb0ab
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Mon Jul 25 00:17:35 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index a7decbb2bdb..c35b552d477 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20220724
+20220725

commit ea169d4d863a8273d4bd44b3dd472d6dfecdbd92
Author: Sebastian Huber <sebastian.huber@embedded-brains.de>
Date:   Fri Jul 22 14:09:20 2022 +0200

    RTEMS: Do not define _GNU_SOURCE by default
    
    gcc/ChangeLog:
    
            * config/rs6000/rtems.h (CPLUSPLUS_CPP_SPEC): Undef.
    
    (cherry picked from commit 556b816b820f6749910784cbaca8bb0bb822a970)

diff --git a/gcc/config/rs6000/rtems.h b/gcc/config/rs6000/rtems.h
index 40db6606f17..bd9057914c8 100644
--- a/gcc/config/rs6000/rtems.h
+++ b/gcc/config/rs6000/rtems.h
@@ -23,6 +23,9 @@
    see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
    <http://www.gnu.org/licenses/>.  */
 
+/* Undef gnu-user.h macro we don't want.  */
+#undef CPLUSPLUS_CPP_SPEC
+
 /* Copy and paste from linux64.h and freebsd64.h */
 #ifdef IN_LIBGCC2
 #undef TARGET_64BIT

commit 42b5f416262b32df863488a8f821dc8dfd95b276
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Tue Jul 26 00:17:43 2022 +0000

    Daily bump.

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 14449e03428..5de78c4c500 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,10 @@
+2022-07-25  Sebastian Huber  <sebastian.huber@embedded-brains.de>
+
+	Backported from master:
+	2022-07-25  Sebastian Huber  <sebastian.huber@embedded-brains.de>
+
+	* config/rs6000/rtems.h (CPLUSPLUS_CPP_SPEC): Undef.
+
 2022-07-22  Surya Kumari Jangala  <jskumari@linux.vnet.ibm.com>
 
 	Backported from master:
diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index c35b552d477..5d984816bfe 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20220725
+20220726

commit a872c617293cf9f6dfae7ed889bbca34884f145c
Author: Harald Anlauf <anlauf@gmx.de>
Date:   Mon Jul 25 22:29:50 2022 +0200

    Fortran: error recovery from calculation of storage size of a symbol [PR103504]
    
    gcc/fortran/ChangeLog:
    
            PR fortran/103504
            * interface.c (get_sym_storage_size): Array bounds and character
            length can only be of integer type.
    
    gcc/testsuite/ChangeLog:
    
            PR fortran/103504
            * gfortran.dg/pr103504.f90: New test.
    
    (cherry picked from commit 600956c81c784f4a0cc9d10f6e03e01847afd961)

diff --git a/gcc/fortran/interface.c b/gcc/fortran/interface.c
index a09a09c925e..a8a88f19908 100644
--- a/gcc/fortran/interface.c
+++ b/gcc/fortran/interface.c
@@ -2759,7 +2759,8 @@ get_sym_storage_size (gfc_symbol *sym)
   if (sym->ts.type == BT_CHARACTER)
     {
       if (sym->ts.u.cl && sym->ts.u.cl->length
-          && sym->ts.u.cl->length->expr_type == EXPR_CONSTANT)
+	  && sym->ts.u.cl->length->expr_type == EXPR_CONSTANT
+	  && sym->ts.u.cl->length->ts.type == BT_INTEGER)
 	strlen = mpz_get_ui (sym->ts.u.cl->length->value.integer);
       else
 	return 0;
@@ -2776,7 +2777,9 @@ get_sym_storage_size (gfc_symbol *sym)
   for (i = 0; i < sym->as->rank; i++)
     {
       if (sym->as->upper[i]->expr_type != EXPR_CONSTANT
-	  || sym->as->lower[i]->expr_type != EXPR_CONSTANT)
+	  || sym->as->lower[i]->expr_type != EXPR_CONSTANT
+	  || sym->as->upper[i]->ts.type != BT_INTEGER
+	  || sym->as->lower[i]->ts.type != BT_INTEGER)
 	return 0;
 
       elements *= mpz_get_si (sym->as->upper[i]->value.integer)
diff --git a/gcc/testsuite/gfortran.dg/pr103504.f90 b/gcc/testsuite/gfortran.dg/pr103504.f90
new file mode 100644
index 00000000000..607d1c6c8cc
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr103504.f90
@@ -0,0 +1,28 @@
+! { dg-do compile }
+! PR fortran/103504 - ICE in get_sym_storage_size, at fortran/interface.c:2800
+! Contributed by G.Steinmetz
+
+program p
+  implicit none
+  real      :: y(1)
+  character :: b
+  call s(y)
+  call t(y)
+  call u(y)
+  call c(b)
+contains
+  subroutine s(x)
+    real :: x(abs(1.):1)        ! { dg-error "must be of INTEGER type" }
+  end
+  subroutine t(x)
+    real :: x(abs(1.):1)        ! { dg-error "must be of INTEGER type" }
+  end
+  subroutine u(x)
+    real :: x(1:abs(1.))        ! { dg-error "must be of INTEGER type" }
+  end
+  subroutine c(z)
+    character(len=abs(1.)) :: z ! { dg-error "must be of INTEGER type" }
+  end subroutine c
+end
+
+! { dg-prune-output "must be of INTEGER type" }

commit 41488e4bb672569c961f23debc2f7b357491f3a6
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Wed Jul 27 00:17:50 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 5d984816bfe..b7375eb6cba 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20220726
+20220727
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index d563e4ec851..0f27acdb552 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,12 @@
+2022-07-26  Harald Anlauf  <anlauf@gmx.de>
+
+	Backported from master:
+	2022-07-26  Harald Anlauf  <anlauf@gmx.de>
+
+	PR fortran/103504
+	* interface.c (get_sym_storage_size): Array bounds and character
+	length can only be of integer type.
+
 2022-07-16  Steve Kargl  <kargl@gcc.gnu.org>
 
 	Backported from master:
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index a890b7a3548..f862e4d01c4 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,11 @@
+2022-07-26  Harald Anlauf  <anlauf@gmx.de>
+
+	Backported from master:
+	2022-07-26  Harald Anlauf  <anlauf@gmx.de>
+
+	PR fortran/103504
+	* gfortran.dg/pr103504.f90: New test.
+
 2022-07-22  Surya Kumari Jangala  <jskumari@linux.vnet.ibm.com>
 
 	Backported from master:

commit 4c7bb975fa2deb346c3b7bb7f9784c4ece47230a
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Thu Jul 28 00:17:25 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index b7375eb6cba..12a06716f5a 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20220727
+20220728

commit 24b0d9b4a3fea8cd3e29c633da0979022b1ad4d1
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Fri Jul 29 00:17:33 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 12a06716f5a..87ee4964bb0 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20220728
+20220729

commit e4d7b0d72335fda8041bb2fcc4937e98c459527e
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sat Jul 30 00:17:19 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 87ee4964bb0..3d4df682b7f 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20220729
+20220730

commit 42de1e05cb30a22df5dc32d81779a89c9e3ead38
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sun Jul 31 00:17:29 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 3d4df682b7f..a519ff332ef 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20220730
+20220731

commit 02fc0616866945668a9531a6dde3d9219c7f1b9b
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Mon Aug 1 00:17:43 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index a519ff332ef..ed14e56feeb 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20220731
+20220801

commit 8df6262fa045644473f4420be0d2efac8b758314
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Tue Aug 2 00:17:41 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index ed14e56feeb..dd67218a4ee 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20220801
+20220802

commit a2ead00af2731e5551b15523ebf8f3e68c4e2ecb
Author: Kewen Lin <linkw@linux.ibm.com>
Date:   Mon Jul 25 21:29:14 2022 -0500

    rs6000: Preserve REG_EH_REGION when replacing load/store [PR106091]
    
    As test case in PR106091 shows, rs6000 specific pass swaps
    doesn't preserve the reg_note REG_EH_REGION when replacing
    some load insn at the end of basic block, it causes the
    flow info verification to fail unexpectedly.  Since memory
    reference rtx may trap, this patch is to ensure we copy
    REG_EH_REGION reg_note while replacing swapped aligned load
    or store.
    
            PR target/106091
    
    gcc/ChangeLog:
    
            * config/rs6000/rs6000-p8swap.c (replace_swapped_aligned_store): Copy
            REG_EH_REGION when replacing one store insn having it.
            (replace_swapped_aligned_load): Likewise.
    
    gcc/testsuite/ChangeLog:
    
            * gcc.target/powerpc/pr106091.c: New test.
    
    (cherry picked from commit f4286601933406142b46693660f7f4b682cb50a5)

diff --git a/gcc/config/rs6000/rs6000-p8swap.c b/gcc/config/rs6000/rs6000-p8swap.c
index 4a358646830..02f99ba5df7 100644
--- a/gcc/config/rs6000/rs6000-p8swap.c
+++ b/gcc/config/rs6000/rs6000-p8swap.c
@@ -1668,7 +1668,15 @@ replace_swapped_aligned_store (swap_web_entry *insn_entry,
   gcc_assert ((GET_CODE (new_body) == SET)
 	      && MEM_P (SET_DEST (new_body)));
 
-  set_block_for_insn (new_insn, BLOCK_FOR_INSN (store_insn));
+  basic_block bb = BLOCK_FOR_INSN (store_insn);
+  set_block_for_insn (new_insn, bb);
+  /* Handle REG_EH_REGION note.  */
+  if (cfun->can_throw_non_call_exceptions && BB_END (bb) == store_insn)
+    {
+      rtx note = find_reg_note (store_insn, REG_EH_REGION, NULL_RTX);
+      if (note)
+	add_reg_note (new_insn, REG_EH_REGION, XEXP (note, 0));
+    }
   df_insn_rescan (new_insn);
 
   df_insn_delete (store_insn);
@@ -1761,7 +1769,15 @@ replace_swapped_aligned_load (swap_web_entry *insn_entry, rtx swap_insn)
   gcc_assert ((GET_CODE (new_body) == SET)
 	      && MEM_P (SET_SRC (new_body)));
 
-  set_block_for_insn (new_insn, BLOCK_FOR_INSN (def_insn));
+  basic_block bb = BLOCK_FOR_INSN (def_insn);
+  set_block_for_insn (new_insn, bb);
+  /* Handle REG_EH_REGION note.  */
+  if (cfun->can_throw_non_call_exceptions && BB_END (bb) == def_insn)
+    {
+      rtx note = find_reg_note (def_insn, REG_EH_REGION, NULL_RTX);
+      if (note)
+	add_reg_note (new_insn, REG_EH_REGION, XEXP (note, 0));
+    }
   df_insn_rescan (new_insn);
 
   df_insn_delete (def_insn);
diff --git a/gcc/testsuite/gcc.target/powerpc/pr106091.c b/gcc/testsuite/gcc.target/powerpc/pr106091.c
new file mode 100644
index 00000000000..61ce8cf4733
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/pr106091.c
@@ -0,0 +1,15 @@
+/* { dg-options "-O -fnon-call-exceptions -fno-tree-dce -fno-tree-forwprop -w" } */
+
+/* Verify there is no ICE.  */
+
+typedef short __attribute__ ((__vector_size__ (64))) V;
+V v, w;
+
+inline V foo (V a, V b);
+
+V
+foo (V a, V b)
+{
+  b &= v < b;
+  return (V){foo (b, w)[3], (V){}[3]};
+}

commit a221c4b8e581d89c311f58c7c2e64c9d1f16c642
Author: Peter Bergner <bergner@linux.ibm.com>
Date:   Mon Jul 25 00:51:44 2022 -0500

    rs6000: Adjust -mdejagnu-cpu to filter out -mtune [PR106345]
    
    As PR106345 shows, when configuring compiler with an explicit
    option --with-tune=<value>, it would cause some test cases to
    fail if their test points are sensitive to tune setting, such
    as: group_ending_nop, loop align etc.  It doesn't help that
    even to specify one explicit -mcpu=.
    
    This patch is to adjust the behavior of -mdejagnu-cpu by
    filtering out all -mcpu= and -mtune= options, then test cases
    would use <cpu> as tune as the one specified by -mdejagnu-cpu.
    
    2022-07-25  Peter Bergner  <bergner@linux.ibm.com>
                Kewen Lin  <linkw@linux.ibm.com>
    
            PR testsuite/106345
    
    gcc/ChangeLog:
    
            * config/rs6000/rs6000.h (DRIVER_SELF_SPECS): Adjust -mdejagnu-cpu
            to filter out all -mtune options.
    
    (cherry picked from commit 75d20d6c84c12bedd65a904e462f02f0b9eb3f77)

diff --git a/gcc/config/rs6000/rs6000.h b/gcc/config/rs6000/rs6000.h
index efd989c5d29..bb297a0a14d 100644
--- a/gcc/config/rs6000/rs6000.h
+++ b/gcc/config/rs6000/rs6000.h
@@ -81,12 +81,15 @@
 # define SUBTARGET_DRIVER_SELF_SPECS ""
 #endif
 
-/* Only for use in the testsuite: -mdejagnu-cpu= simply overrides -mcpu=.
+/* Only for use in the testsuite: -mdejagnu-cpu=<value> filters out all
+   -mcpu= as well as -mtune= options then simply adds -mcpu=<value>,
+   while -mdejagnu-tune=<value> filters out all -mtune= options then
+   simply adds -mtune=<value>.
    With older versions of Dejagnu the command line arguments you set in
-   RUNTESTFLAGS override those set in the testcases; with this option,
-   the testcase will always win.  Ditto for -mdejagnu-tune=.  */
+   RUNTESTFLAGS override those set in the testcases; with these options,
+   the testcase will always win.  */
 #define DRIVER_SELF_SPECS \
-  "%{mdejagnu-cpu=*: %<mcpu=* -mcpu=%*}", \
+  "%{mdejagnu-cpu=*: %<mcpu=* %<mtune=* -mcpu=%*}", \
   "%{mdejagnu-tune=*: %<mtune=* -mtune=%*}", \
   "%{mdejagnu-*: %<mdejagnu-*}", \
    SUBTARGET_DRIVER_SELF_SPECS

commit 8d783f0f6955e6aa7af218490b068004669b09e0
Author: Lewis Hyatt <lhyatt@gmail.com>
Date:   Sat Jul 9 16:12:21 2022 -0400

    c: Fix location for _Pragma tokens [PR97498]
    
    The handling of #pragma GCC diagnostic uses input_location, which is not always
    as precise as needed; in particular the relative location of some tokens and a
    _Pragma directive will crucially determine whether a given diagnostic is enabled
    or suppressed in the desired way. PR97498 shows how the C frontend ends up with
    input_location pointing to the beginning of the line containing a _Pragma()
    directive, resulting in the wrong behavior if the diagnostic to be modified
    pertains to some tokens found earlier on the same line. This patch fixes that by
    addressing two issues:
    
        a) libcpp was not assigning a valid location to the CPP_PRAGMA token
        generated by the _Pragma directive.
        b) C frontend was not setting input_location to something reasonable.
    
    With this change, the C frontend is able to change input_location to point to
    the _Pragma token as needed.
    
    This is just a two-line fix (one for each of a) and b)), the testsuite changes
    were needed only because the location on the tested warnings has been somewhat
    improved, so the tests need to look for the new locations.
    
    gcc/c/ChangeLog:
    
            PR preprocessor/97498
            * c-parser.c (c_parser_pragma): Set input_location to the
            location of the pragma, rather than the start of the line.
    
    libcpp/ChangeLog:
    
            PR preprocessor/97498
            * directives.c (destringize_and_run): Override the location of
            the CPP_PRAGMA token from a _Pragma directive to the location of
            the expansion point, as is done for the tokens lexed from it.
    
    gcc/testsuite/ChangeLog:
    
            PR preprocessor/97498
            * c-c++-common/pr97498.c: New test.
            * gcc.dg/pragma-message.c: Adapt for improved warning locations.
    
    (cherry picked from commit 0587cef3d7962a8b0f44779589ba2920dd3d71e5)

diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c
index 2d347ad927c..b2c7a74b464 100644
--- a/gcc/c/c-parser.c
+++ b/gcc/c/c-parser.c
@@ -12328,6 +12328,7 @@ c_parser_pragma (c_parser *parser, enum pragma_context context, bool *if_p)
   unsigned int id;
   const char *construct = NULL;
 
+  input_location = c_parser_peek_token (parser)->location;
   id = c_parser_peek_token (parser)->pragma_kind;
   gcc_assert (id != PRAGMA_NONE);
 
diff --git a/gcc/testsuite/c-c++-common/pr97498.c b/gcc/testsuite/c-c++-common/pr97498.c
new file mode 100644
index 00000000000..f5fa420415b
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/pr97498.c
@@ -0,0 +1,4 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-Wunused-function" } */
+#pragma GCC diagnostic ignored "-Wunused-function"
+static void f() {} _Pragma("GCC diagnostic error \"-Wunused-function\"") /* { dg-bogus "-Wunused-function" } */
diff --git a/gcc/testsuite/gcc.dg/pragma-message.c b/gcc/testsuite/gcc.dg/pragma-message.c
index 2f44b617710..1b7cf09de0a 100644
--- a/gcc/testsuite/gcc.dg/pragma-message.c
+++ b/gcc/testsuite/gcc.dg/pragma-message.c
@@ -42,9 +42,11 @@
 #pragma message ("Okay " THREE)  /* { dg-message "Okay 3" } */
 
 /* Create a TODO() that prints a message on compilation.  */
-#define DO_PRAGMA(x) _Pragma (#x)
-#define TODO(x) DO_PRAGMA(message ("TODO - " #x))
-TODO(Okay 4)                     /* { dg-message "TODO - Okay 4" } */
+#define DO_PRAGMA(x) _Pragma (#x) /* { dg-line pragma_loc1 } */
+#define TODO(x) DO_PRAGMA(message ("TODO - " #x)) /* { dg-line pragma_loc2 } */
+TODO(Okay 4) /* { dg-message "in expansion of macro 'TODO'" } */
+/* { dg-message "TODO - Okay 4" "test4.1" { target *-*-* } pragma_loc1 } */
+/* { dg-message "in expansion of macro 'DO_PRAGMA'" "test4.2" { target *-*-* } pragma_loc2 } */
 
 #if 0
 #pragma message ("Not printed")
diff --git a/libcpp/directives.c b/libcpp/directives.c
index cab9aad64d2..0d8545a7df9 100644
--- a/libcpp/directives.c
+++ b/libcpp/directives.c
@@ -1887,6 +1887,7 @@ destringize_and_run (cpp_reader *pfile, const cpp_string *in,
       maxcount = 50;
       toks = XNEWVEC (cpp_token, maxcount);
       toks[0] = pfile->directive_result;
+      toks[0].src_loc = expansion_loc;
 
       do
 	{

commit 9fa411d75967ba5bb44d1a0bd2669608c4327dd2
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Wed Aug 3 00:17:42 2022 +0000

    Daily bump.

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 5de78c4c500..2dd835c31c3 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,23 @@
+2022-08-02  Peter Bergner  <bergner@linux.ibm.com>
+
+	Backported from master:
+	2022-07-25  Peter Bergner  <bergner@linux.ibm.com>
+		    Kewen Lin  <linkw@linux.ibm.com>
+
+	PR testsuite/106345
+	* config/rs6000/rs6000.h (DRIVER_SELF_SPECS): Adjust -mdejagnu-cpu
+	to filter out all -mtune options.
+
+2022-08-02  Kewen Lin  <linkw@linux.ibm.com>
+
+	Backported from master:
+	2022-07-26  Kewen Lin  <linkw@linux.ibm.com>
+
+	PR target/106091
+	* config/rs6000/rs6000-p8swap.c (replace_swapped_aligned_store): Copy
+	REG_EH_REGION when replacing one store insn having it.
+	(replace_swapped_aligned_load): Likewise.
+
 2022-07-25  Sebastian Huber  <sebastian.huber@embedded-brains.de>
 
 	Backported from master:
diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index dd67218a4ee..53995aad097 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20220802
+20220803
diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog
index 47eb405ddce..61ad810c12e 100644
--- a/gcc/c/ChangeLog
+++ b/gcc/c/ChangeLog
@@ -1,3 +1,12 @@
+2022-08-02  Lewis Hyatt  <lhyatt@gmail.com>
+
+	Backported from master:
+	2022-07-10  Lewis Hyatt  <lhyatt@gmail.com>
+
+	PR preprocessor/97498
+	* c-parser.c (c_parser_pragma): Set input_location to the
+	location of the pragma, rather than the start of the line.
+
 2022-06-28  Release Manager
 
 	* GCC 10.4.0 released.
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index f862e4d01c4..aa35d4f7539 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,20 @@
+2022-08-02  Lewis Hyatt  <lhyatt@gmail.com>
+
+	Backported from master:
+	2022-07-10  Lewis Hyatt  <lhyatt@gmail.com>
+
+	PR preprocessor/97498
+	* c-c++-common/pr97498.c: New test.
+	* gcc.dg/pragma-message.c: Adapt for improved warning locations.
+
+2022-08-02  Kewen Lin  <linkw@linux.ibm.com>
+
+	Backported from master:
+	2022-07-26  Kewen Lin  <linkw@linux.ibm.com>
+
+	PR target/106091
+	* gcc.target/powerpc/pr106091.c: New test.
+
 2022-07-26  Harald Anlauf  <anlauf@gmx.de>
 
 	Backported from master:
diff --git a/libcpp/ChangeLog b/libcpp/ChangeLog
index 9a17c78ad6b..6c6dc95a731 100644
--- a/libcpp/ChangeLog
+++ b/libcpp/ChangeLog
@@ -1,3 +1,13 @@
+2022-08-02  Lewis Hyatt  <lhyatt@gmail.com>
+
+	Backported from master:
+	2022-07-10  Lewis Hyatt  <lhyatt@gmail.com>
+
+	PR preprocessor/97498
+	* directives.c (destringize_and_run): Override the location of
+	the CPP_PRAGMA token from a _Pragma directive to the location of
+	the expansion point, as is done for the tokens lexed from it.
+
 2022-06-28  Release Manager
 
 	* GCC 10.4.0 released.

commit 18eecb8c4a97716d4bc4890b05c91f172fadc7b3
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Tue Nov 9 23:45:36 2021 +0000

    libstdc++: Disable gthreads weak symbols for glibc 2.34 [PR103133]
    
    Since Glibc 2.34 all pthreads symbols are defined directly in libc not
    libpthread, and since Glibc 2.32 we have used __libc_single_threaded to
    avoid unnecessary locking in single-threaded programs. This means there
    is no reason to avoid linking to libpthread now, and so no reason to use
    weak symbols defined in gthr-posix.h for all the pthread_xxx functions.
    
    libstdc++-v3/ChangeLog:
    
            PR libstdc++/100748
            PR libstdc++/103133
            * config/os/gnu-linux/os_defines.h (_GLIBCXX_GTHREAD_USE_WEAK):
            Define for glibc 2.34 and later.
    
    (cherry picked from commit 80fe172ba9820199c2bbce5d0611ffca27823049)

diff --git a/libstdc++-v3/config/os/gnu-linux/os_defines.h b/libstdc++-v3/config/os/gnu-linux/os_defines.h
index 01bfa9ddd4f..cb842ea26aa 100644
--- a/libstdc++-v3/config/os/gnu-linux/os_defines.h
+++ b/libstdc++-v3/config/os/gnu-linux/os_defines.h
@@ -61,4 +61,10 @@
   (__gthread_active_p() ? __gthread_self() : (__gthread_t)1)
 #endif
 
+#if __GLIBC_PREREQ(2, 34)
+// Since glibc 2.34 all pthreads functions are usable without linking to
+// libpthread.
+# define _GLIBCXX_GTHREAD_USE_WEAK 0
+#endif
+
 #endif

commit 45a31caac6dce9c08fcbdb2436d8ec6dca4e5f3c
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Tue Jun 15 15:07:25 2021 +0100

    libstdc++: Remove precondition checks from ranges::subrange
    
    The assertion in the subrange constructor causes semantic changes,
    because the call to ranges::distance performs additional operations that
    are not part of the constructor's specification. That will fail to
    compile if the iterator is move-only, because the argument to
    ranges::distance is passed by value. It will modify the subrange if the
    iterator is not a forward iterator, because incrementing the copy also
    affects the _M_begin member. Those problems could be prevented by using
    if-constexpr to only do the assertion for copyable forward iterators,
    but the call to ranges::distance can also prevent the constructor being
    usable in constant expressions. If the member initializers are usable in
    constant expressions, but iterator increments of equality comparisons
    are not, then the checks done by __glibcxx_assert might
    make constant evaluation fail.
    
    This change removes the assertion.
    
    Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
    
    libstdc++-v3/ChangeLog:
    
            * include/std/ranges (subrange(i, s, n)): Remove assertion.
            * testsuite/std/ranges/subrange/constexpr.cc: New test.
    
    (cherry picked from commit a88fc03ba7e52d9a072f25d42bb9619fedb7892e)

diff --git a/libstdc++-v3/include/std/ranges b/libstdc++-v3/include/std/ranges
index faa55ebceb7..2ff8dbd53ed 100644
--- a/libstdc++-v3/include/std/ranges
+++ b/libstdc++-v3/include/std/ranges
@@ -264,8 +264,6 @@ namespace ranges
 	requires (_Kind == subrange_kind::sized)
       : _M_begin(std::move(__i)), _M_end(__s)
       {
-	using __detail::__to_unsigned_like;
-	__glibcxx_assert(__n == __to_unsigned_like(ranges::distance(__i, __s)));
 	if constexpr (_S_store_size)
 	  _M_size._M_size = __n;
       }
diff --git a/libstdc++-v3/testsuite/std/ranges/subrange/constexpr.cc b/libstdc++-v3/testsuite/std/ranges/subrange/constexpr.cc
new file mode 100644
index 00000000000..f5bc52bef84
--- /dev/null
+++ b/libstdc++-v3/testsuite/std/ranges/subrange/constexpr.cc
@@ -0,0 +1,26 @@
+// { dg-options "-std=gnu++20" }
+// { dg-do compile { target c++20 } }
+
+#include <ranges>
+
+struct iterator
+{
+  using difference_type = int;
+
+  int i;
+
+  int operator*() const { return i; }
+
+  // These are intentionally not constexpr:
+  iterator& operator++() { ++i; return *this; }
+  iterator operator++(int) { return {i++}; }
+  bool operator==(const iterator& it) const { return i == it.i; }
+};
+
+constexpr iterator begin(1), end(2);
+
+using std::ranges::subrange;
+using std::ranges::subrange_kind;
+
+// This used to fail due to using operator++ and operator== in an assertion:
+constexpr subrange<iterator, iterator, subrange_kind::sized> s(begin, end, 1);

commit d1b51c15312940779b1288b59973d88b9592dd23
Author: Tim Adye <Tim.Adye@cern.ch>
Date:   Fri Jun 4 15:59:38 2021 +0100

    libstdc++: Optimize std::any_cast by replacing indirect call
    
    This significantly improves the performance of std::any_cast, by
    avoiding an indirect call to the _S_manage function through a function
    pointer. Before we make that indirect call we've already established
    that the contained value has the expected type, which means we also know
    the manager type, and so can call one of its members directly.
    
    We also know the precise type in the any::emplace functions, because
    we've just constructed that type, so we can use the new member there
    too. That doesn't seem to affect performance, but we might as well use
    the new _S_access function anyway.
    
    Signed-off-by: Tim Adye <Tim.Adye@cern.ch>
    Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
    
    libstdc++-v3/ChangeLog:
    
            * include/std/any (any::_Manager::_S_access): New static
            function to access the contained value.
            (any::emplace, __any_caster): Use _S_access member of the
            manager type.
    
    (cherry picked from commit f6bb145c0bff19767931d37733be11c8acc6fa00)

diff --git a/libstdc++-v3/include/std/any b/libstdc++-v3/include/std/any
index 1428858d600..de9569b6d40 100644
--- a/libstdc++-v3/include/std/any
+++ b/libstdc++-v3/include/std/any
@@ -263,9 +263,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       {
 	using _VTp = decay_t<_Tp>;
 	__do_emplace<_VTp>(std::forward<_Args>(__args)...);
-	any::_Arg __arg;
-	this->_M_manager(any::_Op_access, this, &__arg);
-	return *static_cast<_VTp*>(__arg._M_obj);
+	return *any::_Manager<_VTp>::_S_access(_M_storage);
       }
 
     /// Emplace with an object created from @p __il and @p __args as
@@ -276,9 +274,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       {
 	using _VTp = decay_t<_Tp>;
 	__do_emplace<_VTp, _Up>(__il, std::forward<_Args>(__args)...);
-	any::_Arg __arg;
-	this->_M_manager(any::_Op_access, this, &__arg);
-	return *static_cast<_VTp*>(__arg._M_obj);
+	return *any::_Manager<_VTp>::_S_access(_M_storage);
       }
 
     // modifiers
@@ -384,6 +380,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	    void* __addr = &__storage._M_buffer;
 	    ::new (__addr) _Tp(std::forward<_Args>(__args)...);
 	  }
+
+	static _Tp*
+	_S_access(const _Storage& __storage)
+	{
+	  // The contained object is in __storage._M_buffer
+	  const void* __addr = &__storage._M_buffer;
+	  return static_cast<_Tp*>(const_cast<void*>(__addr));
+	}
       };
 
     // Manage external contained object.
@@ -405,6 +409,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	  {
 	    __storage._M_ptr = new _Tp(std::forward<_Args>(__args)...);
 	  }
+	static _Tp*
+	_S_access(const _Storage& __storage)
+	{
+	  // The contained object is in *__storage._M_ptr
+	  return static_cast<_Tp*>(__storage._M_ptr);
+	}
       };
   };
 
@@ -516,9 +526,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 #endif
 	  )
 	{
-	  any::_Arg __arg;
-	  __any->_M_manager(any::_Op_access, __any, &__arg);
-	  return __arg._M_obj;
+	  return any::_Manager<_Up>::_S_access(__any->_M_storage);
 	}
       return nullptr;
     }

commit f05b125a8d788a84dc7361b52f54af6169ad8b32
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Wed Sep 29 20:46:55 2021 +0100

    libstdc++: Avoid try-catch and O(N) size in std::list::merge for old ABI
    
    The current std::list::merge code calls size() before starting to merge
    any elements, so that the _M_size members can be updated after the merge
    finishes. The work is done in a try-block so that the sizes can still be
    updated in an exception handler if any element comparison throws.
    
    The _M_size members only exist for the cxx11 ABI, so the initial call to
    size() and the try-catch are only needed for that ABI. For the old ABI
    the size() call performs an O(N) list traversal to get a value that
    isn't even used, and catching exceptions just to rethrow them isn't
    needed either.
    
    In r11-10123 this code was refactored to use an RAII guard type, but for
    the gcc-10 branch a less invasive change using preprocessor conditionals
    seems more appropriate.
    
    libstdc++-v3/ChangeLog:
    
            * include/bits/list.tcc (list::merge) [!USE_CXX11_ABI]: Remove
            call to size() and try-catch block.

diff --git a/libstdc++-v3/include/bits/list.tcc b/libstdc++-v3/include/bits/list.tcc
index ce9e983c539..1f27d8b786a 100644
--- a/libstdc++-v3/include/bits/list.tcc
+++ b/libstdc++-v3/include/bits/list.tcc
@@ -406,8 +406,10 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
 	  iterator __last1 = end();
 	  iterator __first2 = __x.begin();
 	  iterator __last2 = __x.end();
+#if _GLIBCXX_USE_CXX11_ABI
 	  const size_t __orig_size = __x.size();
 	  __try {
+#endif
 	    while (__first1 != __last1 && __first2 != __last2)
 	      if (*__first2 < *__first1)
 		{
@@ -422,6 +424,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
 
 	    this->_M_inc_size(__x._M_get_size());
 	    __x._M_set_size(0);
+#if _GLIBCXX_USE_CXX11_ABI
 	  }
 	  __catch(...)
 	    {
@@ -430,6 +433,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
 	      __x._M_set_size(__dist);
 	      __throw_exception_again;
 	    }
+#endif
 	}
     }
 

commit de802e4736613a585dcfd508acf73033f18aa4da
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Tue Aug 31 17:34:51 2021 +0100

    libstdc++: Add valid range checks to std::span constructors [PR98421]
    
    Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
    
    libstdc++-v3/ChangeLog:
    
            PR libstdc++/98421
            * include/std/span (span(Iter, size_type), span(Iter, Iter)):
            Add valid range checks.
            * testsuite/23_containers/span/cons_1_assert_neg.cc: New test.
            * testsuite/23_containers/span/cons_2_assert_neg.cc: New test.
    
    (cherry picked from commit ef7becc9c8a48804d3fd9dac032f7b33e561a612)

diff --git a/libstdc++-v3/include/std/span b/libstdc++-v3/include/std/span
index 35df1a64c0e..b2a1ea3f0a2 100644
--- a/libstdc++-v3/include/std/span
+++ b/libstdc++-v3/include/std/span
@@ -165,6 +165,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	    {
 	      __glibcxx_assert(__count == _Extent);
 	    }
+	  __glibcxx_requires_valid_range(__first, __first + __count);
 	}
 
       template<contiguous_iterator _It, sized_sentinel_for<_It> _End>
@@ -180,6 +181,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	    {
 	      __glibcxx_assert((__last - __first) == _Extent);
 	    }
+	  __glibcxx_requires_valid_range(__first, __last);
 	}
 
       template<size_t _ArrayExtent>
diff --git a/libstdc++-v3/testsuite/23_containers/span/cons_1_assert_neg.cc b/libstdc++-v3/testsuite/23_containers/span/cons_1_assert_neg.cc
new file mode 100644
index 00000000000..2f555125453
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/span/cons_1_assert_neg.cc
@@ -0,0 +1,14 @@
+// { dg-options "-std=gnu++2a" }
+// { dg-do run { xfail *-*-* } }
+// { dg-require-effective-target c++2a }
+
+#undef _GLIBCXX_DEBUG
+#define _GLIBCXX_DEBUG
+#include <span>
+#include <vector>
+
+int main()
+{
+  std::vector<int> v(2);
+  std::span<int, std::dynamic_extent> s(v.begin(), 3);
+}
diff --git a/libstdc++-v3/testsuite/23_containers/span/cons_2_assert_neg.cc b/libstdc++-v3/testsuite/23_containers/span/cons_2_assert_neg.cc
new file mode 100644
index 00000000000..efef0e608ba
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/span/cons_2_assert_neg.cc
@@ -0,0 +1,14 @@
+// { dg-options "-std=gnu++2a" }
+// { dg-do run { xfail *-*-* } }
+// { dg-require-effective-target c++2a }
+
+#undef _GLIBCXX_DEBUG
+#define _GLIBCXX_DEBUG
+#include <span>
+#include <vector>
+
+int main()
+{
+  std::vector<int> v(2), w(1);
+  std::span<int, std::dynamic_extent> s(v.begin(), w.end());
+}

commit 087ec7142375429481c00e6842ee4c8ee5df3c4a
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Thu Aug 4 00:17:49 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 53995aad097..711b645efbb 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20220803
+20220804
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index c8b67bdb58b..20629202323 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,47 @@
+2022-08-03  Jonathan Wakely  <jwakely@redhat.com>
+
+	Backported from master:
+	2021-08-31  Jonathan Wakely  <jwakely@redhat.com>
+
+	PR libstdc++/98421
+	* include/std/span (span(Iter, size_type), span(Iter, Iter)):
+	Add valid range checks.
+	* testsuite/23_containers/span/cons_1_assert_neg.cc: New test.
+	* testsuite/23_containers/span/cons_2_assert_neg.cc: New test.
+
+2022-08-03  Jonathan Wakely  <jwakely@redhat.com>
+
+	* include/bits/list.tcc (list::merge) [!USE_CXX11_ABI]: Remove
+	call to size() and try-catch block.
+
+2022-08-03  Tim Adye  <Tim.Adye@cern.ch>
+
+	Backported from master:
+	2021-06-04  Tim Adye  <Tim.Adye@cern.ch>
+
+	* include/std/any (any::_Manager::_S_access): New static
+	function to access the contained value.
+	(any::emplace, __any_caster): Use _S_access member of the
+	manager type.
+
+2022-08-03  Jonathan Wakely  <jwakely@redhat.com>
+
+	Backported from master:
+	2021-06-15  Jonathan Wakely  <jwakely@redhat.com>
+
+	* include/std/ranges (subrange(i, s, n)): Remove assertion.
+	* testsuite/std/ranges/subrange/constexpr.cc: New test.
+
+2022-08-03  Jonathan Wakely  <jwakely@redhat.com>
+
+	Backported from master:
+	2021-11-10  Jonathan Wakely  <jwakely@redhat.com>
+
+	PR libstdc++/100748
+	PR libstdc++/103133
+	* config/os/gnu-linux/os_defines.h (_GLIBCXX_GTHREAD_USE_WEAK):
+	Define for glibc 2.34 and later.
+
 2022-07-23  Jonathan Wakely  <jwakely@redhat.com>
 
 	Backported from master:

commit 0158831c81659427d44474040dbce455e06d583e
Author: Peter Bergner <bergner@linux.ibm.com>
Date:   Fri Mar 25 17:59:07 2022 -0500

    rs6000: Update testsuite to use -mdejagnu-cpu= and -mdejagnu-tune= options
    
    This patch updates the POWER testsuite test cases using -mcpu= and -mtune=
    to use the preferred -mdejagnu-cpu= and -mdejagnu-tune= options.  This also
    obviates the need for the dg-skip-if directive, since the user cannot
    override the -mcpu= value being used to compile the test case.
    
    2022-03-25  Peter Bergner  <bergner@linux.ibm.com>
    
    gcc/testsuite/
    
            * g++.dg/pr65240-1.C: Use -mdejagnu-cpu=.  Remove dg-skip-if.
            * g++.dg/pr65240-2.C: Likewise.
            * g++.dg/pr65240-3.C: Likewise.
            * g++.dg/pr65240-4.C: Likewise.
            * g++.dg/pr65242.C: Likewise.
            * g++.dg/pr67211.C: Likewise.
            * g++.dg/pr69667.C: Likewise.
            * g++.dg/pr71294.C: Likewise.
            * g++.dg/pr84279.C: Likewise.
            * g++.dg/torture/ppc-ldst-array.C: Likewise.
            * gfortran.dg/nint_p7.f90: Likewise.
            * gfortran.dg/pr102860.f90: Likewise.
            * gcc.target/powerpc/fusion.c: Use -mdejagnu-cpu= and -mdejagnu-tune=.
            * gcc.target/powerpc/fusion2.c: Likewise.
            * gcc.target/powerpc/test_mffsl.c: Likewise.
            * gfortran.dg/pr47614.f: Likewise.
            * gfortran.dg/pr58968.f: Likewise.
    
    (cherry picked from commit 81faedaa8e2819fc0ffda4ce0a888065a6d7a535)

diff --git a/gcc/testsuite/g++.dg/pr65240-1.C b/gcc/testsuite/g++.dg/pr65240-1.C
index d2e25b65fca..ff8910df6a1 100644
--- a/gcc/testsuite/g++.dg/pr65240-1.C
+++ b/gcc/testsuite/g++.dg/pr65240-1.C
@@ -1,8 +1,7 @@
 /* { dg-do compile { target { powerpc*-*-* && lp64 } } } */
 /* { dg-skip-if "" { powerpc*-*-darwin* } } */
 /* { dg-require-effective-target powerpc_p8vector_ok } */
-/* { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power8" } } */
-/* { dg-options "-mcpu=power8 -O3 -ffast-math -mcmodel=small -mno-fp-in-toc -Wno-return-type" } */
+/* { dg-options "-mdejagnu-cpu=power8 -O3 -ffast-math -mcmodel=small -mno-fp-in-toc -Wno-return-type" } */
 
 /* target/65240, compiler got a 'insn does not satisfy its constraints' error.  */
 
diff --git a/gcc/testsuite/g++.dg/pr65240-2.C b/gcc/testsuite/g++.dg/pr65240-2.C
index 38d5020bd19..bdb7a62d73d 100644
--- a/gcc/testsuite/g++.dg/pr65240-2.C
+++ b/gcc/testsuite/g++.dg/pr65240-2.C
@@ -1,8 +1,7 @@
 /* { dg-do compile { target { powerpc*-*-* && lp64 } } } */
 /* { dg-skip-if "" { powerpc*-*-darwin* } } */
 /* { dg-require-effective-target powerpc_p8vector_ok } */
-/* { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power8" } } */
-/* { dg-options "-mcpu=power8 -O3 -ffast-math -mcmodel=small -mfp-in-toc -Wno-return-type" } */
+/* { dg-options "-mdejagnu-cpu=power8 -O3 -ffast-math -mcmodel=small -mfp-in-toc -Wno-return-type" } */
 
 /* target/65240, compiler got a 'insn does not satisfy its constraints' error.  */
 
diff --git a/gcc/testsuite/g++.dg/pr65240-3.C b/gcc/testsuite/g++.dg/pr65240-3.C
index e8463c91494..f37db9025d1 100644
--- a/gcc/testsuite/g++.dg/pr65240-3.C
+++ b/gcc/testsuite/g++.dg/pr65240-3.C
@@ -1,8 +1,7 @@
 /* { dg-do compile { target { powerpc*-*-* && lp64 } } } */
 /* { dg-skip-if "" { powerpc*-*-darwin* } } */
 /* { dg-require-effective-target powerpc_p8vector_ok } */
-/* { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power8" } } */
-/* { dg-options "-mcpu=power8 -O3 -ffast-math -mcmodel=medium -Wno-return-type" } */
+/* { dg-options "-mdejagnu-cpu=power8 -O3 -ffast-math -mcmodel=medium -Wno-return-type" } */
 
 /* target/65240, compiler got a 'insn does not satisfy its constraints' error.  */
 
diff --git a/gcc/testsuite/g++.dg/pr65240-4.C b/gcc/testsuite/g++.dg/pr65240-4.C
index a119752d18e..efb6a6c06e7 100644
--- a/gcc/testsuite/g++.dg/pr65240-4.C
+++ b/gcc/testsuite/g++.dg/pr65240-4.C
@@ -1,8 +1,7 @@
 /* { dg-do compile { target { powerpc*-*-* && lp64 } } } */
 /* { dg-skip-if "" { powerpc*-*-darwin* } } */
 /* { dg-require-effective-target powerpc_vsx_ok } */
-/* { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power7" } } */
-/* { dg-options "-mcpu=power7 -O3 -ffast-math -Wno-return-type" } */
+/* { dg-options "-mdejagnu-cpu=power7 -O3 -ffast-math -Wno-return-type" } */
 
 /* target/65240, compiler got a 'insn does not satisfy its constraints' error.  */
 
diff --git a/gcc/testsuite/g++.dg/pr65242.C b/gcc/testsuite/g++.dg/pr65242.C
index be2ddaa85b2..662f375015f 100644
--- a/gcc/testsuite/g++.dg/pr65242.C
+++ b/gcc/testsuite/g++.dg/pr65242.C
@@ -1,8 +1,7 @@
 /* { dg-do compile { target { powerpc*-*-* && lp64 } } } */
 /* { dg-skip-if "" { powerpc*-*-darwin* } } */
 /* { dg-require-effective-target powerpc_p8vector_ok } */
-/* { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power8" } } */
-/* { dg-options "-mcpu=power8 -O3" } */
+/* { dg-options "-mdejagnu-cpu=power8 -O3" } */
 
 class A {
 public:
diff --git a/gcc/testsuite/g++.dg/pr67211.C b/gcc/testsuite/g++.dg/pr67211.C
index cb3d342c122..ac241818ab5 100644
--- a/gcc/testsuite/g++.dg/pr67211.C
+++ b/gcc/testsuite/g++.dg/pr67211.C
@@ -1,8 +1,7 @@
 /* { dg-do compile { target { powerpc*-*-* && lp64 } } } */
 /* { dg-skip-if "" { powerpc*-*-darwin* } } */
 /* { dg-require-effective-target powerpc_p8vector_ok } */
-/* { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power7" } } */
-/* { dg-options "-mcpu=power7 -mtune=power8 -O3 -w" } */
+/* { dg-options "-mdejagnu-cpu=power7 -mdejagnu-tune=power8 -O3 -w" } */
 
 /* target/67211, compiler got a 'insn does not satisfy its constraints' error.  */
 
diff --git a/gcc/testsuite/g++.dg/pr69667.C b/gcc/testsuite/g++.dg/pr69667.C
index 76f7cb3d40b..422116dd599 100644
--- a/gcc/testsuite/g++.dg/pr69667.C
+++ b/gcc/testsuite/g++.dg/pr69667.C
@@ -1,8 +1,7 @@
 /* { dg-do compile { target { powerpc*-*-* && lp64 } } } */
 /* { dg-skip-if "" { powerpc*-*-darwin* } } */
 /* { dg-require-effective-target powerpc_p8vector_ok } */
-/* { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power7" } } */
-/* { dg-options "-mcpu=power8 -w -std=c++14" } */
+/* { dg-options "-mdejagnu-cpu=power8 -w -std=c++14" } */
 
 /* target/69667, compiler got
    internal compiler error: Max. number of generated reload insns per insn is achieved (90)  */
diff --git a/gcc/testsuite/g++.dg/pr71294.C b/gcc/testsuite/g++.dg/pr71294.C
index 67675dd7e30..716fa0d44b2 100644
--- a/gcc/testsuite/g++.dg/pr71294.C
+++ b/gcc/testsuite/g++.dg/pr71294.C
@@ -1,7 +1,6 @@
 // { dg-do compile { target { powerpc64*-*-* && lp64 } } }
 // { dg-require-effective-target powerpc_p8vector_ok } */
-// { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power8" } }
-// { dg-options "-mcpu=power8 -O3 -fstack-protector" }
+// { dg-options "-mdejagnu-cpu=power8 -O3 -fstack-protector" }
 
 // PAR target/71294 failed because RELOAD could not figure how create a V2DI
 // vector that auto vectorization created with each element being the same
diff --git a/gcc/testsuite/g++.dg/pr84279.C b/gcc/testsuite/g++.dg/pr84279.C
index a88d3fb8470..e78201c30db 100644
--- a/gcc/testsuite/g++.dg/pr84279.C
+++ b/gcc/testsuite/g++.dg/pr84279.C
@@ -1,8 +1,8 @@
 /* { dg-do compile { target { powerpc*-*-* } } } */
 /* { dg-skip-if "" { powerpc*-*-darwin* } } */
 /* { dg-require-effective-target powerpc_p8vector_ok } */
-/* { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power8" } } */
-/* { dg-options "-O3 -mcpu=power8 -g -fPIC -fvisibility=hidden -fstack-protector-strong" } */
+/* { dg-require-effective-target fpic } */
+/* { dg-options "-O3 -mdejagnu-cpu=power8 -g -fPIC -fvisibility=hidden -fstack-protector-strong" } */
 
 template <typename, typename T> struct E { T e; };
 struct J {
diff --git a/gcc/testsuite/g++.dg/torture/ppc-ldst-array.C b/gcc/testsuite/g++.dg/torture/ppc-ldst-array.C
index 75862e2b5be..fef69e7cf09 100644
--- a/gcc/testsuite/g++.dg/torture/ppc-ldst-array.C
+++ b/gcc/testsuite/g++.dg/torture/ppc-ldst-array.C
@@ -1,6 +1,5 @@
 /* { dg-do compile { target { powerpc64*-*-* } } } */
-/* { dg-skip-if "do not override mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power8" } } */
-/* { dg-options "-mcpu=power8" } */
+/* { dg-options "-mdejagnu-cpu=power8" } */
 
 /* When compiled with C++, this code was breaking because of different
    tree representations of arrays between C and C++.  */
diff --git a/gcc/testsuite/gcc.target/powerpc/fusion.c b/gcc/testsuite/gcc.target/powerpc/fusion.c
index 876b9f54d5a..2a115580439 100644
--- a/gcc/testsuite/gcc.target/powerpc/fusion.c
+++ b/gcc/testsuite/gcc.target/powerpc/fusion.c
@@ -1,7 +1,7 @@
 /* { dg-do compile { target { powerpc*-*-* } } } */
 /* { dg-skip-if "" { powerpc*-*-darwin* } } */
 /* { dg-require-effective-target powerpc_p8vector_ok } */
-/* { dg-options "-mdejagnu-cpu=power7 -mtune=power8 -O3 -dp" } */
+/* { dg-options "-mdejagnu-cpu=power7 -mdejagnu-tune=power8 -O3 -dp" } */
 
 #define LARGE 0x12345
 
diff --git a/gcc/testsuite/gcc.target/powerpc/fusion2.c b/gcc/testsuite/gcc.target/powerpc/fusion2.c
index b3f457a28e2..40ca00a7405 100644
--- a/gcc/testsuite/gcc.target/powerpc/fusion2.c
+++ b/gcc/testsuite/gcc.target/powerpc/fusion2.c
@@ -2,7 +2,7 @@
 /* { dg-skip-if "" { powerpc*-*-darwin* } } */
 /* { dg-skip-if "" { powerpc*le-*-* } } */
 /* { dg-require-effective-target powerpc_p8vector_ok } */
-/* { dg-options "-mdejagnu-cpu=power7 -mtune=power8 -O3" } */
+/* { dg-options "-mdejagnu-cpu=power7 -mdejagnu-tune=power8 -O3" } */
 
 vector double fusion_vector (vector double *p) { return p[2]; }
 
diff --git a/gcc/testsuite/gcc.target/powerpc/test_mffsl.c b/gcc/testsuite/gcc.target/powerpc/test_mffsl.c
index 41377efba1a..045d0bfa349 100644
--- a/gcc/testsuite/gcc.target/powerpc/test_mffsl.c
+++ b/gcc/testsuite/gcc.target/powerpc/test_mffsl.c
@@ -1,5 +1,6 @@
 /* { dg-do run { target { powerpc*-*-* } } } */
-/* { dg-options "-O2 -std=c99" } */
+/* { dg-options "-O2 -std=c99 -mdejagnu-cpu=power9" } */
+/* { dg-require-effective-target p9vector_hw } */
 
 #ifdef DEBUG
 #include <stdio.h>
diff --git a/gcc/testsuite/gfortran.dg/nint_p7.f90 b/gcc/testsuite/gfortran.dg/nint_p7.f90
index 8f3552293c5..2239824a7fb 100644
--- a/gcc/testsuite/gfortran.dg/nint_p7.f90
+++ b/gcc/testsuite/gfortran.dg/nint_p7.f90
@@ -1,8 +1,7 @@
 ! Fortran
 ! { dg-do compile { target { powerpc*-*-* } } }
 ! { dg-require-effective-target powerpc_vsx_ok } 
-! { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power7" } } 
-! { dg-options "-O2 -mcpu=power7 -ffast-math" } 
+! { dg-options "-O2 -mdejagnu-cpu=power7 -ffast-math" } 
 ! { dg-final { scan-assembler-times "xsrdpi" 2 } } 
 
 	subroutine test_nint(x4,x8)
diff --git a/gcc/testsuite/gfortran.dg/pr102860.f90 b/gcc/testsuite/gfortran.dg/pr102860.f90
index d0a7356c0f5..6b1feaa9d79 100644
--- a/gcc/testsuite/gfortran.dg/pr102860.f90
+++ b/gcc/testsuite/gfortran.dg/pr102860.f90
@@ -1,8 +1,7 @@
 ! PR middle-end/102860
 ! { dg-do compile { target { powerpc*-*-* } } }
 ! { dg-require-effective-target powerpc_vsx_ok } 
-! { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power10" } } 
-! { dg-options "-O2 -mcpu=power10" } 
+! { dg-options "-O2 -mdejagnu-cpu=power10" } 
 
 function foo(a)
   integer(kind=4) :: a(1024)
diff --git a/gcc/testsuite/gfortran.dg/pr47614.f b/gcc/testsuite/gfortran.dg/pr47614.f
index 500d210a2a4..d772eef257f 100644
--- a/gcc/testsuite/gfortran.dg/pr47614.f
+++ b/gcc/testsuite/gfortran.dg/pr47614.f
@@ -1,6 +1,7 @@
 ! { dg-do run { target { powerpc*-*-* } } }
 ! { dg-skip-if "" { powerpc*-*-darwin* } }
-! { dg-options "-O3 -funroll-loops -ffast-math -mcpu=power4" }
+! { dg-options "-O3 -funroll-loops -ffast-math -mdejagnu-cpu=power4" }
+! { dg-options "-O3 -funroll-loops -ffast-math" { target powerpc64le*-*-linux* } }
 
 
       SUBROUTINE SFCPAR(ZET,NZ,ZMH,TSL,TMES)
diff --git a/gcc/testsuite/gfortran.dg/pr58968.f b/gcc/testsuite/gfortran.dg/pr58968.f
index b6ea17f4ae2..a7f1e1e710b 100644
--- a/gcc/testsuite/gfortran.dg/pr58968.f
+++ b/gcc/testsuite/gfortran.dg/pr58968.f
@@ -1,6 +1,6 @@
 C PR rtl-optimization/58968.f
 C { dg-do compile { target powerpc*-*-* } }
-C { dg-options "-mcpu=power7 -O3 -w -ffast-math  -funroll-loops" }
+C { dg-options "-mdejagnu-cpu=power7 -O3 -w -ffast-math  -funroll-loops" }
       SUBROUTINE MAKTABS(IW,SOME,LBOX1,LBOX2,LBOX3,NSPACE,NA,NB,
      *            LBST,X,
      *            NX,IAMA,IAMI,IBMA,IBMI,MNUM,IDIM,MSTA,IBO,

commit eab75725cb7c0eeb28a2e212ae33e1fa71d0cddf
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Fri Aug 5 00:17:34 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 711b645efbb..9f7125e822a 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20220804
+20220805
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index aa35d4f7539..2d39eef77d6 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,26 @@
+2022-08-04  Peter Bergner  <bergner@linux.ibm.com>
+
+	Backported from master:
+	2022-03-25  Peter Bergner  <bergner@linux.ibm.com>
+
+	* g++.dg/pr65240-1.C: Use -mdejagnu-cpu=.  Remove dg-skip-if.
+	* g++.dg/pr65240-2.C: Likewise.
+	* g++.dg/pr65240-3.C: Likewise.
+	* g++.dg/pr65240-4.C: Likewise.
+	* g++.dg/pr65242.C: Likewise.
+	* g++.dg/pr67211.C: Likewise.
+	* g++.dg/pr69667.C: Likewise.
+	* g++.dg/pr71294.C: Likewise.
+	* g++.dg/pr84279.C: Likewise.
+	* g++.dg/torture/ppc-ldst-array.C: Likewise.
+	* gfortran.dg/nint_p7.f90: Likewise.
+	* gfortran.dg/pr102860.f90: Likewise.
+	* gcc.target/powerpc/fusion.c: Use -mdejagnu-cpu= and -mdejagnu-tune=.
+	* gcc.target/powerpc/fusion2.c: Likewise.
+	* gcc.target/powerpc/test_mffsl.c: Likewise.
+	* gfortran.dg/pr47614.f: Likewise.
+	* gfortran.dg/pr58968.f: Likewise.
+
 2022-08-02  Lewis Hyatt  <lhyatt@gmail.com>
 
 	Backported from master:

commit a5f248dbdea6c4234f9602788ad012bbd93f7881
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sat Aug 6 00:17:45 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 9f7125e822a..6f474c62c62 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20220805
+20220806

commit fc63785f0c54dd8ca4bb21ea8de3df3dd2335429
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sun Aug 7 00:17:40 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 6f474c62c62..53b844c683e 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20220806
+20220807

commit a3c2870e2f35598913f076a20adb1679271a081d
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Mon Aug 8 00:17:32 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 53b844c683e..00f22f5b8c8 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20220807
+20220808

commit 5cf731430416084c96819590dd3b4b7dce548f8c
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Tue Aug 9 00:17:43 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 00f22f5b8c8..8bd1173be90 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20220808
+20220809

commit ca41e5425722fd2b38f7c860abb8d47aa4ef5dba
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Wed Aug 10 00:17:50 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 8bd1173be90..9049af15948 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20220809
+20220810

commit 60580e350c1a20459dd4726284fef848dd512d08
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Thu Aug 11 00:17:49 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 9049af15948..015f4ab35a3 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20220810
+20220811

commit f8e5a1d577ed7612d2f46d52c86b1cb1c30b2655
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Fri Aug 12 00:17:59 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 015f4ab35a3..1c5d419104a 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20220811
+20220812

commit 567f5ac7821dc006ddd408a78dd7b469ddb01927
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sat Aug 13 00:17:48 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 1c5d419104a..763830cfe05 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20220812
+20220813

commit 2b6f4ec6b9a1b8ccecb672ab231469b8e7814fe5
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sun Aug 14 00:17:58 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 763830cfe05..f7f051dde4b 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20220813
+20220814

commit e3e13ab42b8ee653a69799095314ee4e3855ba11
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Mon Aug 15 00:17:32 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index f7f051dde4b..ecae40e2e0e 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20220814
+20220815

commit 69016721ad240723ad61874a130ef6d199596c71
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Tue Aug 16 00:19:21 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index ecae40e2e0e..9e916febf47 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20220815
+20220816

commit b4ecafb9acd8a7e7eb3da92ac973cb07f0f39d40
Author: Iain Buclaw <ibuclaw@gdcproject.org>
Date:   Tue Aug 16 12:22:10 2022 +0200

    d: Update DIP links in gdc documentation to point at upstream repository
    
    The wiki links probably worked at some point in the distant past, but
    now the official location of tracking all D Improvement Proposals is on
    the upstream dlang/DIPs GitHub repository.
    
            PR d/106638
    
    gcc/d/ChangeLog:
    
            * gdc.texi: Update DIP links to point at upstream dlang/DIPs
            repository.
    
    (cherry picked from commit e56b695aa3aed3c0c80616bba569bbeb4a06b5e5)

diff --git a/gcc/d/gdc.texi b/gcc/d/gdc.texi
index 2ce560f3cae..45e76727764 100644
--- a/gcc/d/gdc.texi
+++ b/gcc/d/gdc.texi
@@ -633,9 +633,11 @@ Give deprecation messages about @option{-ftransition=import} anomalies.
 @item complex
 List all usages of complex or imaginary types.
 @item dip1000
-Implements @uref{http://wiki.dlang.org/DIP1000} (experimental).
+Implements @uref{https://github.com/dlang/DIPs/blob/master/DIPs/other/DIP1000.md}
+(Scoped pointers).
 @item dip25
-Implements @uref{http://wiki.dlang.org/DIP25} (experimental).
+Implements @uref{https://github.com/dlang/DIPs/blob/master/DIPs/archive/DIP25.md}
+(Sealed references).
 @item field
 List all non-mutable fields which occupy an object instance.
 @item import

commit d99d74d8b1b517784e3b05b271b977eb6603121f
Author: Segher Boessenkool <segher@kernel.crashing.org>
Date:   Sun Jan 2 14:08:35 2022 +0000

    rs6000: Disparage lfiwzx and similar
    
    RA now chooses GEN_OR_VSX_REGS in most cases.  This is great in most
    cases, but we often (or always?) use {l,st}{f,xs}iwzx now, which is
    problematic because the integer load and store insns can use cheaper
    addressing modes.  We can fix that by putting a small penalty on the
    instruction alternatives for those.
    
    2022-04-21  Segher Boessenkool  <segher@kernel.crashing.org>
    
            PR target/103197
            PR target/102146
            * config/rs6000/rs6000.md (zero_extendqi<mode>2 for EXTQI): Disparage
            the "Z" alternatives in {l,st}{f,xs}iwzx.
            (zero_extendhi<mode>2 for EXTHI): Ditto.
            (zero_extendsi<mode>2 for EXTSI): Ditto.
            (*movsi_internal1): Ditto.
            (*mov<mode>_internal1 for QHI): Ditto.
            (movsd_hardfloat): Ditto.
    
    (cherry picked from commit 26fa464f42622c60d6929720dd37143a21054ede)

diff --git a/gcc/config/rs6000/rs6000.md b/gcc/config/rs6000/rs6000.md
index 61a14fb5b9f..129b87bbc12 100644
--- a/gcc/config/rs6000/rs6000.md
+++ b/gcc/config/rs6000/rs6000.md
@@ -782,8 +782,8 @@
 ;; complex forms.  Basic data transfer is done later.
 
 (define_insn "zero_extendqi<mode>2"
-  [(set (match_operand:EXTQI 0 "gpc_reg_operand" "=r,r,^wa,^v")
-	(zero_extend:EXTQI (match_operand:QI 1 "reg_or_mem_operand" "m,r,Z,v")))]
+  [(set (match_operand:EXTQI 0 "gpc_reg_operand" "=r,r,wa,^v")
+	(zero_extend:EXTQI (match_operand:QI 1 "reg_or_mem_operand" "m,r,?Z,v")))]
   ""
   "@
    lbz%U1%X1 %0,%1
@@ -836,8 +836,8 @@
 
 
 (define_insn "zero_extendhi<mode>2"
-  [(set (match_operand:EXTHI 0 "gpc_reg_operand" "=r,r,^wa,^v")
-	(zero_extend:EXTHI (match_operand:HI 1 "reg_or_mem_operand" "m,r,Z,v")))]
+  [(set (match_operand:EXTHI 0 "gpc_reg_operand" "=r,r,wa,^v")
+	(zero_extend:EXTHI (match_operand:HI 1 "reg_or_mem_operand" "m,r,?Z,v")))]
   ""
   "@
    lhz%U1%X1 %0,%1
@@ -891,7 +891,7 @@
 
 (define_insn "zero_extendsi<mode>2"
   [(set (match_operand:EXTSI 0 "gpc_reg_operand" "=r,r,d,wa,wa,r,wa")
-	(zero_extend:EXTSI (match_operand:SI 1 "reg_or_mem_operand" "m,r,Z,Z,r,wa,wa")))]
+	(zero_extend:EXTSI (match_operand:SI 1 "reg_or_mem_operand" "m,r,?Z,?Z,r,wa,wa")))]
   ""
   "@
    lwz%U1%X1 %0,%1
@@ -6941,7 +6941,7 @@
   [(set (match_operand:SI 0 "nonimmediate_operand"
 	  "=r,         r,
 	   r,          d,          v,
-	   m,          Z,          Z,
+	   m,          ?Z,         ?Z,
 	   r,          r,          r,          r,
 	   wa,         wa,         wa,         v,
 	   wa,         v,          v,
@@ -6949,7 +6949,7 @@
 	   r,          *h,         *h")
 	(match_operand:SI 1 "input_operand"
 	  "r,          U,
-	   m,          Z,          Z,
+	   m,          ?Z,         ?Z,
 	   r,          d,          v,
 	   I,          L,          eI,         n,
 	   wa,         O,          wM,         wB,
@@ -7230,11 +7230,11 @@
 ;;		MTVSRWZ     MF%1       MT%1       NOP
 (define_insn "*mov<mode>_internal"
   [(set (match_operand:QHI 0 "nonimmediate_operand"
-		"=r,        r,         wa,        m,         Z,         r,
+		"=r,        r,         wa,        m,         ?Z,        r,
 		 wa,        wa,        wa,        v,         ?v,        r,
 		 wa,        r,         *c*l,      *h")
 	(match_operand:QHI 1 "input_operand"
-		"r,         m,         Z,         r,         wa,        i,
+		"r,         m,         ?Z,        r,         wa,        i,
 		 wa,        O,         wM,        wB,        wS,        wa,
 		 r,         *h,        r,         0"))]
   "gpc_reg_operand (operands[0], <MODE>mode)
@@ -7413,10 +7413,10 @@
 ;;	FMR          MR         MT%0       MF%1       NOP
 (define_insn "movsd_hardfloat"
   [(set (match_operand:SD 0 "nonimmediate_operand"
-	 "=!r,       d,         m,         Z,         ?d,        ?r,
+	 "=!r,       d,         m,         ?Z,        ?d,        ?r,
 	  f,         !r,        *c*l,      !r,        *h")
 	(match_operand:SD 1 "input_operand"
-	 "m,         Z,         r,         wx,        r,         d,
+	 "m,         ?Z,        r,         wx,        r,         d,
 	  f,         r,         r,         *h,        0"))]
   "(register_operand (operands[0], SDmode)
    || register_operand (operands[1], SDmode))

commit 5f12bad1a122b31c5540b38cad8e7be1799629b8
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Wed Aug 17 00:18:56 2022 +0000

    Daily bump.

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 2dd835c31c3..d6aeabb9bf4 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,18 @@
+2022-08-16  Segher Boessenkool  <segher@kernel.crashing.org>
+
+	Backported from master:
+	2022-04-21  Segher Boessenkool  <segher@kernel.crashing.org>
+
+	PR target/103197
+	PR target/102146
+	* config/rs6000/rs6000.md (zero_extendqi<mode>2 for EXTQI): Disparage
+	the "Z" alternatives in {l,st}{f,xs}iwzx.
+	(zero_extendhi<mode>2 for EXTHI): Ditto.
+	(zero_extendsi<mode>2 for EXTSI): Ditto.
+	(*movsi_internal1): Ditto.
+	(*mov<mode>_internal1 for QHI): Ditto.
+	(movsd_hardfloat): Ditto.
+
 2022-08-02  Peter Bergner  <bergner@linux.ibm.com>
 
 	Backported from master:
diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 9e916febf47..3016a0c44cb 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20220816
+20220817
diff --git a/gcc/d/ChangeLog b/gcc/d/ChangeLog
index b5c1b2297a4..84ea6930951 100644
--- a/gcc/d/ChangeLog
+++ b/gcc/d/ChangeLog
@@ -1,3 +1,12 @@
+2022-08-16  Iain Buclaw  <ibuclaw@gdcproject.org>
+
+	Backported from master:
+	2022-08-16  Iain Buclaw  <ibuclaw@gdcproject.org>
+
+	PR d/106638
+	* gdc.texi: Update DIP links to point at upstream dlang/DIPs
+	repository.
+
 2022-07-05  Iain Buclaw  <ibuclaw@gdcproject.org>
 
 	Backported from master:

commit 3b2d3aabb45784191833b3db76a163ea94e7774a
Author: Segher Boessenkool <segher@kernel.crashing.org>
Date:   Thu Apr 21 18:32:48 2022 +0000

    rs6000: Add effective target has_arch_ppc64
    
    This is true if we have -mpowerpc64.
    
    2022-04-21  Segher Boessenkool  <segher@kernel.crashing.org>
    
    gcc/testsuite/
            * lib/target-supports.exp (check_effective_target_has_arch_ppc64): New.
    
    (cherry picked from commit fc9deca632c2eb246c54cfd13cb616bf3fcbd21a)

diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp
index 1aa64a5a6bd..138138c6584 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -5912,6 +5912,16 @@ proc check_effective_target_has_arch_pwr9 { } {
 	}]
 }
 
+proc check_effective_target_has_arch_ppc64 { } {
+	return [check_no_compiler_messages arch_ppc64 assembly {
+		#ifndef _ARCH_PPC64
+		#error does not have ppc64 support.
+		#else
+		/* "has ppc64 support" */
+		#endif
+	}]
+}
+
 # Return 1 if this is a PowerPC target supporting -mcpu=power10.
 # Limit this to 64-bit linux systems for now until other targets support
 # power10.

commit cebbbc1596001e86c3c4d5f2223ddac50e5e0bb8
Author: Segher Boessenkool <segher@kernel.crashing.org>
Date:   Tue Apr 26 11:26:09 2022 +0000

    rs6000: Make the has_arch target selectors actually work
    
    2022-04-26  Segher Boessenkoool  <segher@kernel.crashing.org>
    
    gcc/testsuite/
            PR target/105349
            * lib/target-supports.exp (check_effective_target_has_arch_pwr5): Use
            the specified dg-options.
            (check_effective_target_has_arch_pwr6): Ditto.
            (check_effective_target_has_arch_pwr7): Ditto.
            (check_effective_target_has_arch_pwr8): Ditto.
            (check_effective_target_has_arch_pwr9): Ditto.
            (check_effective_target_has_arch_ppc64): Ditto.
    
    (cherry picked from commit ad56a60f58c1ed662deaf60d5736c332ec2caabb)

diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp
index 138138c6584..31a531c7c6b 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -5863,63 +5863,63 @@ proc check_effective_target_powerpc_p9modulo_ok { } {
 # return 1 if our compiler returns the ARCH_PWR defines with the options
 # as provided by the test.
 proc check_effective_target_has_arch_pwr5 { } {
-	return [check_no_compiler_messages arch_pwr5 assembly {
+	return [check_no_compiler_messages_nocache arch_pwr5 assembly {
 		#ifndef _ARCH_PWR5
 		#error does not have power5 support.
 		#else
 		/* "has power5 support" */
 		#endif
-	}]
+	} [current_compiler_flags]]
 }
 
 proc check_effective_target_has_arch_pwr6 { } {
-	return [check_no_compiler_messages arch_pwr6 assembly {
+	return [check_no_compiler_messages_nocache arch_pwr6 assembly {
 		#ifndef _ARCH_PWR6
 		#error does not have power6 support.
 		#else
 		/* "has power6 support" */
 		#endif
-	}]
+	} [current_compiler_flags]]
 }
 
 proc check_effective_target_has_arch_pwr7 { } {
-	return [check_no_compiler_messages arch_pwr7 assembly {
+	return [check_no_compiler_messages_nocache arch_pwr7 assembly {
 		#ifndef _ARCH_PWR7
 		#error does not have power7 support.
 		#else
 		/* "has power7 support" */
 		#endif
-	}]
+	} [current_compiler_flags]]
 }
 
 proc check_effective_target_has_arch_pwr8 { } {
-	return [check_no_compiler_messages arch_pwr8 assembly {
+	return [check_no_compiler_messages_nocache arch_pwr8 assembly {
 		#ifndef _ARCH_PWR8
 		#error does not have power8 support.
 		#else
 		/* "has power8 support" */
 		#endif
-	}]
+	} [current_compiler_flags]]
 }
 
 proc check_effective_target_has_arch_pwr9 { } {
-	return [check_no_compiler_messages arch_pwr9 assembly {
+	return [check_no_compiler_messages_nocache arch_pwr9 assembly {
 		#ifndef _ARCH_PWR9
 		#error does not have power9 support.
 		#else
 		/* "has power9 support" */
 		#endif
-	}]
+	} [current_compiler_flags]]
 }
 
 proc check_effective_target_has_arch_ppc64 { } {
-	return [check_no_compiler_messages arch_ppc64 assembly {
+	return [check_no_compiler_messages_nocache arch_ppc64 assembly {
 		#ifndef _ARCH_PPC64
 		#error does not have ppc64 support.
 		#else
 		/* "has ppc64 support" */
 		#endif
-	}]
+	} [current_compiler_flags]]
 }
 
 # Return 1 if this is a PowerPC target supporting -mcpu=power10.

commit fcafb592988ceb342c134d62f0adcbffe628f862
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Thu Aug 18 00:18:25 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 3016a0c44cb..17147d2840a 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20220817
+20220818
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 2d39eef77d6..cbb1f32646e 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,24 @@
+2022-08-17  Segher Boessenkool  <segher@kernel.crashing.org>
+
+	Backported from master:
+	2022-04-26  Segher Boessenkoool  <segher@kernel.crashing.org>
+
+	PR target/105349
+	* lib/target-supports.exp (check_effective_target_has_arch_pwr5): Use
+	the specified dg-options.
+	(check_effective_target_has_arch_pwr6): Ditto.
+	(check_effective_target_has_arch_pwr7): Ditto.
+	(check_effective_target_has_arch_pwr8): Ditto.
+	(check_effective_target_has_arch_pwr9): Ditto.
+	(check_effective_target_has_arch_ppc64): Ditto.
+
+2022-08-17  Segher Boessenkool  <segher@kernel.crashing.org>
+
+	Backported from master:
+	2022-04-21  Segher Boessenkool  <segher@kernel.crashing.org>
+
+	* lib/target-supports.exp (check_effective_target_has_arch_ppc64): New.
+
 2022-08-04  Peter Bergner  <bergner@linux.ibm.com>
 
 	Backported from master:

commit 5ef8c5bfc4a00bd97303cf2427de40cac9fe2416
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Fri Aug 19 00:18:05 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 17147d2840a..918be360b57 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20220818
+20220819

commit afa83fc3fe2d3b36f54337b134eaac8b03a99c59
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sat Aug 20 00:17:43 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 918be360b57..0b12197627e 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20220819
+20220820

commit cea7078d031428f052190a981485f5bb05a43987
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sun Aug 21 00:22:06 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 0b12197627e..f89c07b21f5 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20220820
+20220821

commit df087da3e4e6b168327aa7a34fff41ec57ca9cba
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Mon Aug 22 00:17:47 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index f89c07b21f5..f223ce3bfa8 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20220821
+20220822

commit ae8daf74e741c71921fb01a84ae1c347de18adcd
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Tue Aug 23 00:17:43 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index f223ce3bfa8..5d5b4de7ffd 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20220822
+20220823

commit 9b72dfbcc08bc5ecb7fecb6750a07cdb90658cce
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Wed Aug 24 00:17:41 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 5d5b4de7ffd..a8087bc572d 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20220823
+20220824

commit 501fba663052b0b4a1eb6a42c32b74c254cbedbc
Author: Kewen Lin <linkw@linux.ibm.com>
Date:   Tue Aug 23 03:31:17 2022 -0500

    rs6000: Adjust mov optabs for opaque modes [PR103353]
    
    As PR103353 shows, we may want to continue to expand built-in
    function __builtin_vsx_lxvp, even if we have already emitted
    error messages about some missing required conditions.  As
    shown in that PR, without one explicit mov optab on OOmode
    provided, it would call emit_move_insn recursively.
    
    So this patch is to allow the mov pattern to be generated during
    expanding phase if compiler has already seen errors.
    
            PR target/103353
    
    gcc/ChangeLog:
    
            * config/rs6000/mma.md (define_expand movpoi): Move TARGET_MMA condition
            check to preparation statements and add handlings for !TARGET_MMA.
            (define_expand movpxi): Likewise.
    
    gcc/testsuite/ChangeLog:
    
            * gcc.target/powerpc/pr103353.c: New test.
    
    (cherry picked from commit 9367e3a65f874dffc8f8a3b6760e77fd9ed67117)

diff --git a/gcc/config/rs6000/mma.md b/gcc/config/rs6000/mma.md
index 27f64d2cb7c..c6e07e5dd78 100644
--- a/gcc/config/rs6000/mma.md
+++ b/gcc/config/rs6000/mma.md
@@ -283,10 +283,25 @@
 (define_expand "movpoi"
   [(set (match_operand:POI 0 "nonimmediate_operand")
 	(match_operand:POI 1 "input_operand"))]
-  "TARGET_MMA"
+  ""
 {
-  rs6000_emit_move (operands[0], operands[1], POImode);
-  DONE;
+  if (TARGET_MMA)
+    {
+      rs6000_emit_move (operands[0], operands[1], POImode);
+      DONE;
+    }
+  else if (currently_expanding_to_rtl && seen_error ())
+    {
+      /* PR103353 shows we may want to continue to expand the __builtin_vsx_lxvp
+	 built-in function, even if we have already emitted error messages about
+	 some missing required conditions.  As shown in that PR, without one
+	 explicit mov optab on POImode provided, it would call emit_move_insn
+	 recursively.  So we allow this pattern to be generated when we are
+	 expanding to RTL and have seen errors.  It would not cause further ICEs
+	 as the compilation would stop soon after expanding.  */
+    }
+  else
+    gcc_unreachable ();
 })
 
 (define_insn_and_split "*movpoi"
@@ -323,10 +338,22 @@
 (define_expand "movpxi"
   [(set (match_operand:PXI 0 "nonimmediate_operand")
 	(match_operand:PXI 1 "input_operand"))]
-  "TARGET_MMA"
+  ""
 {
-  rs6000_emit_move (operands[0], operands[1], PXImode);
-  DONE;
+  if (TARGET_MMA)
+    {
+      rs6000_emit_move (operands[0], operands[1], PXImode);
+      DONE;
+    }
+  else if (currently_expanding_to_rtl && seen_error ())
+    {
+      /* PR103353 shows we may want to continue to expand the __builtin_vsx_lxvp
+	 built-in function, even if we have already emitted error messages about
+	 some missing required conditions.  So do the same handlings for PXImode
+	 as POImode here.  */
+    }
+  else
+    gcc_unreachable ();
 })
 
 (define_insn_and_split "*movpxi"
diff --git a/gcc/testsuite/gcc.target/powerpc/pr103353.c b/gcc/testsuite/gcc.target/powerpc/pr103353.c
new file mode 100644
index 00000000000..5d519fb1b7b
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/pr103353.c
@@ -0,0 +1,22 @@
+/* { dg-require-effective-target powerpc_altivec_ok } */
+/* If the default cpu type is power10 or later, MMA is enabled by default.
+   To keep the test point available all the time, this case specifies
+   -mdejagnu-cpu=power6 to make it be tested without MMA.  */
+/* { dg-options "-maltivec -mdejagnu-cpu=power6" } */
+
+/* Verify there is no ICE and don't check the error messages on MMA
+   requirement since they could be fragile and are not test points
+   of this case.  */
+/* { dg-excess-errors "pr103353" } */
+
+void
+foo (__vector_pair *dst, double *x)
+{
+  dst[0] = __builtin_vsx_lxvp (0, (__vector_pair *)(void *)x);
+}
+
+void
+bar (__vector_pair *src, double *x)
+{
+  __builtin_vsx_stxvp (src[0], 0, (__vector_pair *)(void *)x);
+}

commit cc40dcf4229f80d4b1b04ad3cf862ed90f46dac8
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Thu Aug 25 00:17:42 2022 +0000

    Daily bump.

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index d6aeabb9bf4..4bbadc51d41 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,13 @@
+2022-08-24  Kewen Lin  <linkw@linux.ibm.com>
+
+	Backported from master:
+	2022-08-16  Kewen Lin  <linkw@linux.ibm.com>
+
+	PR target/103353
+	* config/rs6000/mma.md (define_expand movpoi): Move TARGET_MMA condition
+	check to preparation statements and add handlings for !TARGET_MMA.
+	(define_expand movpxi): Likewise.
+
 2022-08-16  Segher Boessenkool  <segher@kernel.crashing.org>
 
 	Backported from master:
diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index a8087bc572d..359f4ea53a5 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20220824
+20220825
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index cbb1f32646e..11d58f419ea 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,11 @@
+2022-08-24  Kewen Lin  <linkw@linux.ibm.com>
+
+	Backported from master:
+	2022-08-16  Kewen Lin  <linkw@linux.ibm.com>
+
+	PR target/103353
+	* gcc.target/powerpc/pr103353.c: New test.
+
 2022-08-17  Segher Boessenkool  <segher@kernel.crashing.org>
 
 	Backported from master:

commit 2600735755d77dc133769543ae6b01fdb469a0b3
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Fri Aug 26 00:17:34 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 359f4ea53a5..d51496b47e3 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20220825
+20220826

commit 9b10b7ae6f3ddaa31e6f42490c7bc156553e92b2
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sat Aug 27 00:17:56 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index d51496b47e3..bdd286f5e87 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20220826
+20220827

commit bcb1f04130c2dd1ed8b6b7c57d407b4ac53e04ce
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sun Aug 28 00:17:39 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index bdd286f5e87..027f7dfa509 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20220827
+20220828

commit 0d76edf9eb3712238c2216578b9b0aa7f01638d0
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Mon Aug 29 00:17:43 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 027f7dfa509..85ed11f60d3 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20220828
+20220829

commit b541e149ab653e54545df6eda4154bfb16d4409c
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Tue Aug 30 00:18:08 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 85ed11f60d3..41f0d849079 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20220829
+20220830

commit 3927bd9f9150576f2905c8930732c419f1850fca
Author: Peter Bergner <bergner@linux.ibm.com>
Date:   Sat Aug 27 19:44:16 2022 -0500

    rs6000: Allow conversions of MMA pointer types [PR106017]
    
    GCC incorrectly disables conversions between MMA pointer types, which
    are allowed with clang.  The original intent was to disable conversions
    between MMA types and other other types, but pointer conversions should
    have been allowed.  The fix is to just remove the MMA pointer conversion
    handling code altogether.
    
    gcc/
            PR target/106017
            * config/rs6000/rs6000.c (rs6000_invalid_conversion): Remove handling
            of MMA pointer conversions.
    
    gcc/testsuite/
            PR target/106017
            * gcc.target/powerpc/pr106017.c: New test.
    
    (cherry picked from commit 1ae1325f24cea1698b56e4299d95446a1f7b90a2)

diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index 24696edfb8c..d6be8b7fb6b 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -26888,28 +26888,6 @@ rs6000_invalid_conversion (const_tree fromtype, const_tree totype)
       if (tomode == POImode)
 	return N_("invalid conversion to type %<__vector_pair%>");
     }
-  else if (POINTER_TYPE_P (fromtype) && POINTER_TYPE_P (totype))
-    {
-      /* We really care about the modes of the base types.  */
-      frommode = TYPE_MODE (TREE_TYPE (fromtype));
-      tomode = TYPE_MODE (TREE_TYPE (totype));
-
-      /* Do not allow conversions to/from PXImode and POImode pointer
-	 types, except to/from void pointers.  */
-      if (frommode != tomode
-	  && frommode != VOIDmode
-	  && tomode != VOIDmode)
-	{
-	  if (frommode == PXImode)
-	    return N_("invalid conversion from type %<* __vector_quad%>");
-	  if (tomode == PXImode)
-	    return N_("invalid conversion to type %<* __vector_quad%>");
-	  if (frommode == POImode)
-	    return N_("invalid conversion from type %<* __vector_pair%>");
-	  if (tomode == POImode)
-	    return N_("invalid conversion to type %<* __vector_pair%>");
-	}
-    }
 
   /* Conversion allowed.  */
   return NULL;
diff --git a/gcc/testsuite/gcc.target/powerpc/pr106017.c b/gcc/testsuite/gcc.target/powerpc/pr106017.c
new file mode 100644
index 00000000000..46d6c7a4a33
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/pr106017.c
@@ -0,0 +1,19 @@
+/* PR target/106017 */
+/* { dg-options "-O1 -mdejagnu-cpu=power10" } */
+/* { dg-require-effective-target power10_ok } */
+
+/* Make sure we do not flag any errors on the following test cases.  */
+
+void takeacc(__vector_quad *);
+void
+foo (void)
+{
+  __vector_quad arr[4];
+  takeacc (arr);
+}
+
+unsigned char *
+bar (__vector_quad *a)
+{
+  return (unsigned char *)a;
+}

commit ceba71aa6d1e715c77bb610dfbf618b041fed9b4
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Wed Aug 31 00:17:42 2022 +0000

    Daily bump.

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 4bbadc51d41..f6d64cd896e 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,12 @@
+2022-08-30  Peter Bergner  <bergner@linux.ibm.com>
+
+	Backported from master:
+	2022-08-28  Peter Bergner  <bergner@linux.ibm.com>
+
+	PR target/106017
+	* config/rs6000/rs6000.c (rs6000_invalid_conversion): Remove handling
+	of MMA pointer conversions.
+
 2022-08-24  Kewen Lin  <linkw@linux.ibm.com>
 
 	Backported from master:
diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 41f0d849079..d8a65227e83 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20220830
+20220831
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 11d58f419ea..2467f0a4dcf 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,11 @@
+2022-08-30  Peter Bergner  <bergner@linux.ibm.com>
+
+	Backported from master:
+	2022-08-28  Peter Bergner  <bergner@linux.ibm.com>
+
+	PR target/106017
+	* gcc.target/powerpc/pr106017.c: New test.
+
 2022-08-24  Kewen Lin  <linkw@linux.ibm.com>
 
 	Backported from master:

commit bd71b8b7b08852c5b4b8cb7189b00199af6017de
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Thu Sep 1 00:18:39 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index d8a65227e83..9ba0bbef705 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20220831
+20220901

commit 922bf0c726f6165722f099ac2e17e54501b29ce1
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Fri Sep 2 00:17:55 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 9ba0bbef705..9dafb9722d0 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20220901
+20220902

commit b8655fdd1b3cdc900b7ef128d2521965d66e1783
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sat Sep 3 00:18:39 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 9dafb9722d0..e15744dd99e 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20220902
+20220903

commit e9c06ac9a412254d45a91843aef3a5318fa14f87
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sun Sep 4 00:18:43 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index e15744dd99e..999da9a9e8d 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20220903
+20220904

commit d67e1207523e55edc5d90f5e9090387134acfa6c
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Mon Sep 5 00:18:24 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 999da9a9e8d..6f5f7110f57 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20220904
+20220905

commit f43fef392bbf4ab0cc41de73cc13a77c2f41900f
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Tue Sep 6 00:18:24 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 6f5f7110f57..80e4d819fed 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20220905
+20220906

commit c9f65890432b6657acca9fb4327c1e2e0fb8e6f4
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Wed Sep 7 00:19:12 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 80e4d819fed..a4aec9eaaa2 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20220906
+20220907

commit b454c41f894e2b175f8f683a31a091ffb1a0b7f0
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Thu Sep 8 00:19:55 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index a4aec9eaaa2..2e552cf7ab7 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20220907
+20220908

commit 66787009571353f0da110d356ece94f363a24d73
Author: Sebastian Huber <sebastian.huber@embedded-brains.de>
Date:   Thu Sep 1 10:22:47 2022 +0200

    RTEMS: Add -mvrsave multilibs
    
    gcc/ChangeLog:
    
            * config/rs6000/rtems.h (CPP_OS_DEFAULT_SPEC): Define __PPC_VRSAVE__ if
            -mvrsave is present.
            * config/rs6000/t-rtems: Add -mvrsave multilib variants for
            -mcpu=e6500.

diff --git a/gcc/config/rs6000/rtems.h b/gcc/config/rs6000/rtems.h
index bd9057914c8..c5d4037551d 100644
--- a/gcc/config/rs6000/rtems.h
+++ b/gcc/config/rs6000/rtems.h
@@ -255,7 +255,8 @@
 %{mcpu=821:  %{!Dppc*: %{!Dmpc*: -Dmpc821}  } } \
 %{mcpu=860:  %{!Dppc*: %{!Dmpc*: -Dmpc860}  } } \
 %{mcpu=8540: %{!Dppc*: %{!Dmpc*: -Dppc8540}  } } \
-%{mcpu=e6500: -D__PPC_CPU_E6500__}"
+%{mcpu=e6500: -D__PPC_CPU_E6500__} \
+%{mvrsave: -D__PPC_VRSAVE__}"
 
 #undef	ASM_SPEC
 #define	ASM_SPEC "%{!m64:%(asm_spec32)}%{m64:%(asm_spec64)} %(asm_spec_common)"
diff --git a/gcc/config/rs6000/t-rtems b/gcc/config/rs6000/t-rtems
index 8065a0976ab..f2d72d11f1e 100644
--- a/gcc/config/rs6000/t-rtems
+++ b/gcc/config/rs6000/t-rtems
@@ -36,6 +36,9 @@ MULTILIB_DIRNAMES += nof
 MULTILIB_OPTIONS += mno-altivec
 MULTILIB_DIRNAMES += noaltivec
 
+MULTILIB_OPTIONS += mvrsave
+MULTILIB_DIRNAMES += vrsave
+
 MULTILIB_MATCHES  	+= ${MULTILIB_MATCHES_ENDIAN}
 MULTILIB_MATCHES	+= ${MULTILIB_MATCHES_SYSV}
 # Map 405 to 403
@@ -70,5 +73,7 @@ MULTILIB_REQUIRED += mcpu=7400/msoft-float
 MULTILIB_REQUIRED += mcpu=8540/msoft-float
 MULTILIB_REQUIRED += mcpu=860
 MULTILIB_REQUIRED += mcpu=e6500/m32
+MULTILIB_REQUIRED += mcpu=e6500/m32/mvrsave
 MULTILIB_REQUIRED += mcpu=e6500/m32/msoft-float/mno-altivec
 MULTILIB_REQUIRED += mcpu=e6500/m64
+MULTILIB_REQUIRED += mcpu=e6500/m64/mvrsave

commit 106404001f9cfcddc681a90df9fc3f1cf116a665
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Fri Sep 9 00:19:41 2022 +0000

    Daily bump.

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index f6d64cd896e..7e2d8799b6d 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,10 @@
+2022-09-08  Sebastian Huber  <sebastian.huber@embedded-brains.de>
+
+	* config/rs6000/rtems.h (CPP_OS_DEFAULT_SPEC): Define __PPC_VRSAVE__ if
+	-mvrsave is present.
+	* config/rs6000/t-rtems: Add -mvrsave multilib variants for
+	-mcpu=e6500.
+
 2022-08-30  Peter Bergner  <bergner@linux.ibm.com>
 
 	Backported from master:
diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 2e552cf7ab7..56639c30a8b 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20220908
+20220909

commit a3bb5ebf12c0731e6d315545d4005343db057f90
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sat Sep 10 00:19:12 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 56639c30a8b..9f94e785b02 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20220909
+20220910

commit 91f1a138d0e1eb2eedefa157ac091d94fcd6d21b
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sun Sep 11 00:18:58 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 9f94e785b02..b56ada5674a 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20220910
+20220911

commit 01e0bfa4d224d020ab2a1ea8414fb3b72f9f797f
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Mon Sep 12 00:19:16 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index b56ada5674a..eaf59824aca 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20220911
+20220912

commit 4892cd3483e35a73f6df8df92cec0dfeff0749bb
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Tue Sep 13 00:19:51 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index eaf59824aca..3ab9ae22f92 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20220912
+20220913

commit 12d28957b613d8c9b74e7841d73945025a7f0ccb
Author: Kewen Lin <linkw@linux.ibm.com>
Date:   Tue Sep 6 20:37:57 2022 -0500

    rs6000/test: Fix empty TU in some cases of effective targets [PR106345]
    
    As the failure of test case gcc.target/powerpc/pr92398.p9-.c in
    PR106345 shows, some test sources for some powerpc effective
    targets use empty translation unit wrongly.  The test sources
    could go with options like "-ansi -pedantic-errors", then those
    effective target checkings will fail unexpectedly with the
    error messages like:
    
      error: ISO C forbids an empty translation unit [-Wpedantic]
    
    This patch is to fix empty TUs with one dummy function definition
    accordingly.
    
            PR testsuite/106345
    
    gcc/testsuite/ChangeLog:
    
            * lib/target-supports.exp (check_effective_target_has_arch_pwr5): Add
            a function definition to avoid pedwarn about empty translation unit.
            (check_effective_target_has_arch_pwr6): Likewise.
            (check_effective_target_has_arch_pwr7): Likewise.
            (check_effective_target_has_arch_pwr8): Likewise.
            (check_effective_target_has_arch_pwr9): Likewise.
            (check_effective_target_has_arch_ppc64): Likewise.
            (check_effective_target_ppc_float128): Likewise.
            (check_effective_target_ppc_float128_insns): Likewise.
            (check_effective_target_powerpc_vsx): Likewise.
    
    (cherry picked from commit 7a43e52a48b6403a99d3e8ab3105869b4b3c081e)

diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp
index 31a531c7c6b..2e6cf66e2a4 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -5864,61 +5864,79 @@ proc check_effective_target_powerpc_p9modulo_ok { } {
 # as provided by the test.
 proc check_effective_target_has_arch_pwr5 { } {
 	return [check_no_compiler_messages_nocache arch_pwr5 assembly {
+		void test (void)
+		{
 		#ifndef _ARCH_PWR5
 		#error does not have power5 support.
 		#else
 		/* "has power5 support" */
 		#endif
+		}
 	} [current_compiler_flags]]
 }
 
 proc check_effective_target_has_arch_pwr6 { } {
 	return [check_no_compiler_messages_nocache arch_pwr6 assembly {
+		void test (void)
+		{
 		#ifndef _ARCH_PWR6
 		#error does not have power6 support.
 		#else
 		/* "has power6 support" */
 		#endif
+		}
 	} [current_compiler_flags]]
 }
 
 proc check_effective_target_has_arch_pwr7 { } {
 	return [check_no_compiler_messages_nocache arch_pwr7 assembly {
+		void test (void)
+		{
 		#ifndef _ARCH_PWR7
 		#error does not have power7 support.
 		#else
 		/* "has power7 support" */
 		#endif
+		}
 	} [current_compiler_flags]]
 }
 
 proc check_effective_target_has_arch_pwr8 { } {
 	return [check_no_compiler_messages_nocache arch_pwr8 assembly {
+		void test (void)
+		{
 		#ifndef _ARCH_PWR8
 		#error does not have power8 support.
 		#else
 		/* "has power8 support" */
 		#endif
+		}
 	} [current_compiler_flags]]
 }
 
 proc check_effective_target_has_arch_pwr9 { } {
 	return [check_no_compiler_messages_nocache arch_pwr9 assembly {
+		void test (void)
+		{
 		#ifndef _ARCH_PWR9
 		#error does not have power9 support.
 		#else
 		/* "has power9 support" */
 		#endif
+		}
 	} [current_compiler_flags]]
 }
 
 proc check_effective_target_has_arch_ppc64 { } {
 	return [check_no_compiler_messages_nocache arch_ppc64 assembly {
+		void test (void)
+		{
 		#ifndef _ARCH_PPC64
 		#error does not have ppc64 support.
 		#else
 		/* "has ppc64 support" */
 		#endif
+		}
 	} [current_compiler_flags]]
 }
 
@@ -6005,9 +6023,12 @@ proc check_effective_target_powerpc_float128_hw_ok { } {
 
 proc check_effective_target_ppc_float128 { } {
     return [check_no_compiler_messages_nocache ppc_float128 object {
+	void test (void)
+	{
 	#ifndef __FLOAT128__
 	  nope no good
 	#endif
+	}
     }]
 }
 
@@ -6015,9 +6036,12 @@ proc check_effective_target_ppc_float128 { } {
 
 proc check_effective_target_ppc_float128_insns { } {
     return [check_no_compiler_messages_nocache ppc_float128 object {
+	void test (void)
+	{
 	#ifndef __FLOAT128_HARDWARE__
 	  nope no good
 	#endif
+	}
     }]
 }
 
@@ -6025,9 +6049,12 @@ proc check_effective_target_ppc_float128_insns { } {
 
 proc check_effective_target_powerpc_vsx { } {
     return [check_no_compiler_messages_nocache powerpc_vsx object {
+	void test (void)
+	{
 	#ifndef __VSX__
 	  nope no vsx
 	#endif
+	}
     }]
 }
 

commit 8301b8e84d833467b435b33592e0aa599d2db582
Author: Peter Bergner <bergner@linux.ibm.com>
Date:   Wed Aug 31 21:14:36 2022 -0500

    rs6000: Don't ICE when we disassemble an MMA variable [PR101322]
    
    When we expand an MMA disassemble built-in with C++ using a pointer that
    is cast to a valid MMA type, the type isn't passed down to the expand
    machinery and we end up using the base type of the pointer which leads to
    an ICE.  This patch enforces we always use the correct MMA type regardless
    of the pointer type being used.
    
    2022-08-31  Peter Bergner  <bergner@linux.ibm.com>
    
    gcc/
            PR target/101322
            * config/rs6000/rs6000-call.c (rs6000_gimple_fold_mma_builtin):
            Enforce the use of a valid MMA pointer type.
    
    gcc/testsuite/
            PR target/101322
            * g++.target/powerpc/pr101322.C: New test.
    
    (cherry picked from commit 2985049049f12b0aa3366ca244d387820385b9e8)

diff --git a/gcc/config/rs6000/rs6000-call.c b/gcc/config/rs6000/rs6000-call.c
index 6a47389d564..c910ee5c71a 100644
--- a/gcc/config/rs6000/rs6000-call.c
+++ b/gcc/config/rs6000/rs6000-call.c
@@ -10855,7 +10855,12 @@ rs6000_gimple_fold_mma_builtin (gimple_stmt_iterator *gsi)
       push_gimplify_context (true);
       tree dst_ptr = gimple_call_arg (stmt, 0);
       tree src_ptr = gimple_call_arg (stmt, 1);
-      tree src_type = TREE_TYPE (src_ptr);
+      tree src_type = (fncode == MMA_BUILTIN_DISASSEMBLE_ACC)
+		      ? build_pointer_type (vector_quad_type_node)
+		      : build_pointer_type (vector_pair_type_node);
+      if (TREE_TYPE (src_ptr) != src_type)
+	src_ptr = build1 (NOP_EXPR, src_type, src_ptr);
+
       tree src = create_tmp_reg_or_ssa_name (TREE_TYPE (src_type));
       gimplify_assign (src, build_simple_mem_ref (src_ptr), &new_seq);
 
diff --git a/gcc/testsuite/g++.target/powerpc/pr101322.C b/gcc/testsuite/g++.target/powerpc/pr101322.C
new file mode 100644
index 00000000000..43eaf3afcd4
--- /dev/null
+++ b/gcc/testsuite/g++.target/powerpc/pr101322.C
@@ -0,0 +1,17 @@
+/* PR target/101322 */
+/* { dg-require-effective-target power10_ok } */
+/* { dg-options "-O2 -mdejagnu-cpu=power10" } */
+
+/* Verify we don't ICE on the following test cases.  */
+
+void
+foo (char *resp, char *vpp)
+{
+  __builtin_vsx_disassemble_pair (resp, (__vector_pair *) vpp);
+}
+
+void
+bar (char *resp, char *vpp)
+{
+  __builtin_mma_disassemble_acc (resp, (__vector_quad *)vpp);
+}

commit b7b63c85dc0d56a440d35503a7363bb6c09a8d0f
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Wed Sep 14 00:19:43 2022 +0000

    Daily bump.

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 7e2d8799b6d..bfb9419ac71 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,12 @@
+2022-09-13  Peter Bergner  <bergner@linux.ibm.com>
+
+	Backported from master:
+	2022-09-01  Peter Bergner  <bergner@linux.ibm.com>
+
+	PR target/101322
+	* config/rs6000/rs6000-call.c (rs6000_gimple_fold_mma_builtin):
+	Enforce the use of a valid MMA pointer type.
+
 2022-09-08  Sebastian Huber  <sebastian.huber@embedded-brains.de>
 
 	* config/rs6000/rtems.h (CPP_OS_DEFAULT_SPEC): Define __PPC_VRSAVE__ if
diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 3ab9ae22f92..21befd25789 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20220913
+20220914
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 2467f0a4dcf..a97ae4dad05 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,28 @@
+2022-09-13  Peter Bergner  <bergner@linux.ibm.com>
+
+	Backported from master:
+	2022-09-01  Peter Bergner  <bergner@linux.ibm.com>
+
+	PR target/101322
+	* g++.target/powerpc/pr101322.C: New test.
+
+2022-09-13  Kewen Lin  <linkw@linux.ibm.com>
+
+	Backported from master:
+	2022-09-07  Kewen Lin  <linkw@linux.ibm.com>
+
+	PR testsuite/106345
+	* lib/target-supports.exp (check_effective_target_has_arch_pwr5): Add
+	a function definition to avoid pedwarn about empty translation unit.
+	(check_effective_target_has_arch_pwr6): Likewise.
+	(check_effective_target_has_arch_pwr7): Likewise.
+	(check_effective_target_has_arch_pwr8): Likewise.
+	(check_effective_target_has_arch_pwr9): Likewise.
+	(check_effective_target_has_arch_ppc64): Likewise.
+	(check_effective_target_ppc_float128): Likewise.
+	(check_effective_target_ppc_float128_insns): Likewise.
+	(check_effective_target_powerpc_vsx): Likewise.
+
 2022-08-30  Peter Bergner  <bergner@linux.ibm.com>
 
 	Backported from master:

commit ddeca5944408edfac28b3d90b02b2d0b4cfe73d1
Author: Thomas Schwinge <thomas@codesourcery.com>
Date:   Tue Sep 13 17:26:33 2022 +0200

    nvptx: Define (dummy) 'TARGET_PTX_6_0'
    
    'TARGET_PTX_*' not applicable before GCC 12, but makes it easier to cherry-pick
    patches.
    
            gcc/
            * config/nvptx/nvptx.h (TARGET_PTX_6_0): '#define' to 'false'.

diff --git a/gcc/config/nvptx/nvptx.h b/gcc/config/nvptx/nvptx.h
index 6ebcc760771..ca1aa11d852 100644
--- a/gcc/config/nvptx/nvptx.h
+++ b/gcc/config/nvptx/nvptx.h
@@ -95,6 +95,9 @@
 
 #define TARGET_SM35 (ptx_isa_option >= PTX_ISA_SM35)
 
+/* 'TARGET_PTX_*' not applicable before GCC 12.  */
+#define TARGET_PTX_6_0 false
+
 /* Registers.  Since ptx is a virtual target, we just define a few
    hard registers for special purposes and leave pseudos unallocated.
    We have to have some available hard registers, to keep gcc setup

commit 50d326b90572d3e25a468f38603a6a971ecda938
Author: Tom de Vries <tdevries@suse.de>
Date:   Thu Jan 27 15:03:59 2022 +0100

    [nvptx] Add bar.warp.sync
    
    On a GT 1030 (sm_61), with driver version 470.94 I run into:
    ...
    FAIL: libgomp.oacc-c/../libgomp.oacc-c-c++-common/parallel-dims.c \
      -DACC_DEVICE_TYPE_nvidia=1 -DACC_MEM_SHARED=0 -foffload=nvptx-none \
      -O2 execution test
    ...
    which minimizes to the same test-case as listed in commit "[nvptx] Update
    default ptx isa to 6.3".
    
    The first divergent branch looks like:
    ...
      {
        .reg .u32 %x;
        mov.u32 %x,%tid.x;
        setp.ne.u32 %r59,%x,0;
      }
      @ %r59 bra $L15;
      mov.u64 %r48,%ar0;
      mov.u32 %r22,2;
      ld.u64 %r53,[%r48];
      mov.u32 %r55,%r22;
      mov.u32 %r54,1;
     $L15:
    ...
    and when inspecting the generated SASS, the branch is not setup as a divergent
    branch, but instead as a regular branch.
    
    This causes us to execute a shfl.sync insn in divergent mode, which is likely
    to cause trouble given a remark in the ptx isa version 6.3, which mentions
    that for .target sm_6x or below, all threads must excute the same
    shfl.sync instruction in convergence.
    
    Fix this by placing a "bar.warp.sync 0xffffffff" at the desired convergence
    point (in the example above, after $L15).
    
    Tested on x86_64 with nvptx accelerator.
    
    gcc/ChangeLog:
    
    2022-01-31  Tom de Vries  <tdevries@suse.de>
    
            * config/nvptx/nvptx.c (nvptx_single): Use nvptx_warpsync.
            * config/nvptx/nvptx.md (define_c_enum "unspecv"): Add
            UNSPECV_WARPSYNC.
            (define_insn "nvptx_warpsync"): New define_insn.
    
    (cherry picked from commit bba61d403d05202deb698b352a4faef3feb1f04d)

diff --git a/gcc/config/nvptx/nvptx.c b/gcc/config/nvptx/nvptx.c
index 243bf9da51a..eec07fc3d13 100644
--- a/gcc/config/nvptx/nvptx.c
+++ b/gcc/config/nvptx/nvptx.c
@@ -4392,6 +4392,7 @@ nvptx_single (unsigned mask, basic_block from, basic_block to)
   rtx_insn *neuter_start = NULL;
   rtx_insn *worker_label = NULL, *vector_label = NULL;
   rtx_insn *worker_jump = NULL, *vector_jump = NULL;
+  rtx_insn *warp_sync = NULL;
   for (mode = GOMP_DIM_WORKER; mode <= GOMP_DIM_VECTOR; mode++)
     if (GOMP_DIM_MASK (mode) & skip_mask)
       {
@@ -4424,11 +4425,15 @@ nvptx_single (unsigned mask, basic_block from, basic_block to)
 	if (tail_branch)
 	  {
 	    label_insn = emit_label_before (label, before);
+	    if (TARGET_PTX_6_0 && mode == GOMP_DIM_VECTOR)
+	      warp_sync = emit_insn_after (gen_nvptx_warpsync (), label_insn);
 	    before = label_insn;
 	  }
 	else
 	  {
 	    label_insn = emit_label_after (label, tail);
+	    if (TARGET_PTX_6_0 && mode == GOMP_DIM_VECTOR)
+	      warp_sync = emit_insn_after (gen_nvptx_warpsync (), label_insn);
 	    if ((mode == GOMP_DIM_VECTOR || mode == GOMP_DIM_WORKER)
 		&& CALL_P (tail) && find_reg_note (tail, REG_NORETURN, NULL))
 	      emit_insn_after (gen_exit (), label_insn);
@@ -4496,6 +4501,8 @@ nvptx_single (unsigned mask, basic_block from, basic_block to)
 		 setp.ne.u32 %rcond,%rcondu32,0;
 	  */
 	  rtx_insn *label = PREV_INSN (tail);
+	  if (label == warp_sync)
+	    label = PREV_INSN (label);
 	  gcc_assert (label && LABEL_P (label));
 	  rtx tmp = gen_reg_rtx (BImode);
 	  emit_insn_before (gen_movbi (tmp, const0_rtx),
diff --git a/gcc/config/nvptx/nvptx.md b/gcc/config/nvptx/nvptx.md
index 089cdf04f2e..b2350ab0d2d 100644
--- a/gcc/config/nvptx/nvptx.md
+++ b/gcc/config/nvptx/nvptx.md
@@ -55,6 +55,7 @@
    UNSPECV_CAS
    UNSPECV_XCHG
    UNSPECV_BARSYNC
+   UNSPECV_WARPSYNC
    UNSPECV_MEMBAR
    UNSPECV_MEMBAR_CTA
    UNSPECV_DIM_POS
@@ -1476,6 +1477,12 @@
   }
   [(set_attr "predicable" "false")])
 
+(define_insn "nvptx_warpsync"
+  [(unspec_volatile [(const_int 0)] UNSPECV_WARPSYNC)]
+  "TARGET_PTX_6_0"
+  "\\tbar.warp.sync\\t0xffffffff;"
+  [(set_attr "predicable" "false")])
+
 (define_expand "memory_barrier"
   [(set (match_dup 0)
 	(unspec_volatile:BLK [(match_dup 0)] UNSPECV_MEMBAR))]

commit 3875b025a97ae667523bebf9f4cf157a8f5854ce
Author: Tom de Vries <tdevries@suse.de>
Date:   Fri Jan 28 10:28:59 2022 +0100

    [nvptx] Add uniform_warp_check insn
    
    On a GT 1030, with driver version 470.94 and -mptx=3.1 I run into:
    ...
    FAIL: libgomp.oacc-c/../libgomp.oacc-c-c++-common/parallel-dims.c \
      -DACC_DEVICE_TYPE_nvidia=1 -DACC_MEM_SHARED=0 -foffload=nvptx-none \
      -O2 execution test
    ...
    which minimizes to the same test-case as listed in commit "[nvptx]
    Update default ptx isa to 6.3".
    
    The problem is again that the first diverging branch is not handled as such in
    SASS, which causes problems with a subsequent shfl insn, but given that we
    have -mptx=3.1 we can't use the bar.warp.sync insn.
    
    Given that the default is now -mptx=6.3, and consequently -mptx=3.1 is of a
    lesser importance, implement the next best thing: abort when detecting
    non-convergence using this insn:
    ...
      { .reg.b32 act;
        vote.ballot.b32 act,1;
        .reg.pred uni;
        setp.eq.b32 uni,act,0xffffffff;
        @ !uni trap;
        @ !uni exit;
      }
    ...
    
    Interestingly, the effect of this is that rather than aborting, the test-case
    now passes.
    
    Tested on x86_64 with nvptx accelerator.
    
    gcc/ChangeLog:
    
    2022-01-31  Tom de Vries  <tdevries@suse.de>
    
            * config/nvptx/nvptx.c (nvptx_single): Use nvptx_uniform_warp_check.
            * config/nvptx/nvptx.md (define_c_enum "unspecv"): Add
            UNSPECV_UNIFORM_WARP_CHECK.
            (define_insn "nvptx_uniform_warp_check"): New define_insn.
    
    (cherry picked from commit f32f74c2e8cef5fe37af6d4e8d7e8f6b4c8ae9a8)

diff --git a/gcc/config/nvptx/nvptx.c b/gcc/config/nvptx/nvptx.c
index eec07fc3d13..0b67d544e48 100644
--- a/gcc/config/nvptx/nvptx.c
+++ b/gcc/config/nvptx/nvptx.c
@@ -4425,15 +4425,29 @@ nvptx_single (unsigned mask, basic_block from, basic_block to)
 	if (tail_branch)
 	  {
 	    label_insn = emit_label_before (label, before);
-	    if (TARGET_PTX_6_0 && mode == GOMP_DIM_VECTOR)
-	      warp_sync = emit_insn_after (gen_nvptx_warpsync (), label_insn);
+	    if (mode == GOMP_DIM_VECTOR)
+	      {
+		if (TARGET_PTX_6_0)
+		  warp_sync = emit_insn_after (gen_nvptx_warpsync (),
+					       label_insn);
+		else
+		  warp_sync = emit_insn_after (gen_nvptx_uniform_warp_check (),
+					       label_insn);
+	      }
 	    before = label_insn;
 	  }
 	else
 	  {
 	    label_insn = emit_label_after (label, tail);
-	    if (TARGET_PTX_6_0 && mode == GOMP_DIM_VECTOR)
-	      warp_sync = emit_insn_after (gen_nvptx_warpsync (), label_insn);
+	    if (mode == GOMP_DIM_VECTOR)
+	      {
+		if (TARGET_PTX_6_0)
+		  warp_sync = emit_insn_after (gen_nvptx_warpsync (),
+					       label_insn);
+		else
+		  warp_sync = emit_insn_after (gen_nvptx_uniform_warp_check (),
+					       label_insn);
+	      }
 	    if ((mode == GOMP_DIM_VECTOR || mode == GOMP_DIM_WORKER)
 		&& CALL_P (tail) && find_reg_note (tail, REG_NORETURN, NULL))
 	      emit_insn_after (gen_exit (), label_insn);
diff --git a/gcc/config/nvptx/nvptx.md b/gcc/config/nvptx/nvptx.md
index b2350ab0d2d..34062027312 100644
--- a/gcc/config/nvptx/nvptx.md
+++ b/gcc/config/nvptx/nvptx.md
@@ -56,6 +56,7 @@
    UNSPECV_XCHG
    UNSPECV_BARSYNC
    UNSPECV_WARPSYNC
+   UNSPECV_UNIFORM_WARP_CHECK
    UNSPECV_MEMBAR
    UNSPECV_MEMBAR_CTA
    UNSPECV_DIM_POS
@@ -1483,6 +1484,23 @@
   "\\tbar.warp.sync\\t0xffffffff;"
   [(set_attr "predicable" "false")])
 
+(define_insn "nvptx_uniform_warp_check"
+  [(unspec_volatile [(const_int 0)] UNSPECV_UNIFORM_WARP_CHECK)]
+  ""
+  {
+    output_asm_insn ("{", NULL);
+    output_asm_insn ("\\t"	 ".reg.b32"	   "\\t" "act;", NULL);
+    output_asm_insn ("\\t"	 "vote.ballot.b32" "\\t" "act,1;", NULL);
+    output_asm_insn ("\\t"	 ".reg.pred"	   "\\t" "uni;", NULL);
+    output_asm_insn ("\\t"	 "setp.eq.b32"	   "\\t" "uni,act,0xffffffff;",
+		     NULL);
+    output_asm_insn ("@ !uni\\t" "trap;", NULL);
+    output_asm_insn ("@ !uni\\t" "exit;", NULL);
+    output_asm_insn ("}", NULL);
+    return "";
+  }
+  [(set_attr "predicable" "false")])
+
 (define_expand "memory_barrier"
   [(set (match_dup 0)
 	(unspec_volatile:BLK [(match_dup 0)] UNSPECV_MEMBAR))]

commit 43a1ee7e137634ce6ad066b93ab2b0872e576357
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Thu Sep 15 00:20:34 2022 +0000

    Daily bump.

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index bfb9419ac71..413ff84e61a 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,27 @@
+2022-09-14  Tom de Vries  <tdevries@suse.de>
+
+	Backported from master:
+	2022-02-01  Tom de Vries  <tdevries@suse.de>
+
+	* config/nvptx/nvptx.c (nvptx_single): Use nvptx_uniform_warp_check.
+	* config/nvptx/nvptx.md (define_c_enum "unspecv"): Add
+	UNSPECV_UNIFORM_WARP_CHECK.
+	(define_insn "nvptx_uniform_warp_check"): New define_insn.
+
+2022-09-14  Tom de Vries  <tdevries@suse.de>
+
+	Backported from master:
+	2022-02-01  Tom de Vries  <tdevries@suse.de>
+
+	* config/nvptx/nvptx.c (nvptx_single): Use nvptx_warpsync.
+	* config/nvptx/nvptx.md (define_c_enum "unspecv"): Add
+	UNSPECV_WARPSYNC.
+	(define_insn "nvptx_warpsync"): New define_insn.
+
+2022-09-14  Thomas Schwinge  <thomas@codesourcery.com>
+
+	* config/nvptx/nvptx.h (TARGET_PTX_6_0): '#define' to 'false'.
+
 2022-09-13  Peter Bergner  <bergner@linux.ibm.com>
 
 	Backported from master:
diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 21befd25789..437b57288fa 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20220914
+20220915

commit eef250952a53cf50cf4e9b1f5c6f937912a4c60a
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Fri Sep 16 00:18:34 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 437b57288fa..e22a65d8c12 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20220915
+20220916

commit cf928a336a6c811adc08863d606b59ffba37640a
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sat Sep 17 00:19:54 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index e22a65d8c12..c5a8cbf7428 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20220916
+20220917

commit d6dbe277dcbe78cf6b1db6491a774c0647e81706
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sun Sep 18 00:18:54 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index c5a8cbf7428..f6dd415e2b5 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20220917
+20220918

commit 3165a3879c80a997fc3efba3e997ca8fd401fe35
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Mon Sep 19 00:19:39 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index f6dd415e2b5..98dc1b51fa6 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20220918
+20220919

commit 848ddecfe14446947fe7697cdfafe0031c3c54c5
Author: Georg-Johann Lay <avr@gjlay.de>
Date:   Mon Sep 19 09:46:58 2022 +0200

    Fix PR target/99184: Wrong cast from double to 16-bit and 32-bit ints
    
    this patch fixed PR target/99184 which incorrectly rounded during 64-bit
    (long) double to 16-bit and 32-bit integers.
    
    The patch just removes the respective roundings from
    libf7-asm.sx::to_integer and ::to_unsigned.  Luckily, LibF7 does nowhere
    use respective functions internally, the only user is in libf7.c::f7_exp
    
    which reads
    
       f7_round (qq, qq);
       int16_t q = f7_get_s16 (qq);
    
    so that f7_get_s16() operates on an already rounded value, and therefore
    this code works unaltered with or without rounding in to_integer.
    
            PR target/99184
    libgcc/config/avr/libf7/
            * libf7-asm.sx (to_integer, to_unsigned): Don't round 16-bit
            and 32-bit integers.
    
    (cherry picked from commit 0b5b8ac5cb7fe92dd17ae8bd7de84640daa59e84)

diff --git a/libgcc/config/avr/libf7/libf7-asm.sx b/libgcc/config/avr/libf7/libf7-asm.sx
index 7972557d31c..8df4756ef1b 100644
--- a/libgcc/config/avr/libf7/libf7-asm.sx
+++ b/libgcc/config/avr/libf7/libf7-asm.sx
@@ -601,9 +601,6 @@ DEFUN to_integer
     tst     C6
     brmi    .Lsaturate.T    ;   > INTxx_MAX  =>  saturate
 
-    rcall   .Lround
-    brmi    .Lsaturate.T    ;   > INTxx_MAX  =>  saturate
-
     brtc 9f                 ;   >= 0         =>  return
     sbrc    Mask,   5
     .global __negdi2
@@ -658,30 +655,6 @@ DEFUN to_integer
     .global __clr_8
     XJMP    __clr_8
 
-.Lround:
-    ;; C6.7 is known to be 0 here.
-    ;; Return N = 1 iff we have to saturate.
-    cpi     Mask,   0xf
-    breq .Lround16
-    cpi     Mask,   0x1f
-    breq .Lround32
-
-    ;; For now, no rounding in the 64-bit case.  This rounding
-    ;; would have to be integrated into the right-shift.
-    cln
-    ret
-
-.Lround32:
-    rol     C2
-    adc     C3,     ZERO
-    adc     C4,     ZERO
-    rjmp 2f
-
-.Lround16:
-    rol     C4
-2:  adc     C5,     ZERO
-    adc     C6,     ZERO
-    ret
 ENDF to_integer
 #endif /* F7MOD_to_integer_ */
 
@@ -725,29 +698,6 @@ DEFUN to_unsigned
     clr     CA
     F7call  lshrdi3
     POP     r16
-
-    ;; Rounding
-    ;; ??? C6.7 is known to be 0 here.
-    cpi     Mask,   0xf
-    breq .Lround16
-    cpi     Mask,   0x1f
-    breq .Lround32
-
-    ;; For now, no rounding in the 64-bit case.  This rounding
-    ;; would have to be integrated into the right-shift.
-    ret
-
-.Lround32:
-    rol     C2
-    adc     C3,     ZERO
-    adc     C4,     ZERO
-    rjmp 2f
-
-.Lround16:
-    rol     C4
-2:  adc     C5,     ZERO
-    adc     C6,     ZERO
-    brcs    .Lset_0xffff    ; Rounding overflow  =>  saturate
     ret
 
 .Lset_0xffff:

commit 18d3492ff18f2fff1a85b701dab88b5fd48f5304
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Tue Sep 20 00:19:30 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 98dc1b51fa6..54f97aaa2e6 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20220919
+20220920
diff --git a/libgcc/config/avr/libf7/ChangeLog b/libgcc/config/avr/libf7/ChangeLog
index 7d85d86f63c..88e90a8dfaa 100644
--- a/libgcc/config/avr/libf7/ChangeLog
+++ b/libgcc/config/avr/libf7/ChangeLog
@@ -1,3 +1,12 @@
+2022-09-19  Georg-Johann Lay  <avr@gjlay.de>
+
+	Backported from master:
+	2022-09-19  Georg-Johann Lay  <avr@gjlay.de>
+
+	PR target/99184
+	* libf7-asm.sx (to_integer, to_unsigned): Don't round 16-bit
+	and 32-bit integers.
+
 2022-06-28  Release Manager
 
 	* GCC 10.4.0 released.

commit fa60d4e103095e99aba1dd8f1186a359ab4f8ec5
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Wed Sep 21 00:20:50 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 54f97aaa2e6..2407ee3feb4 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20220920
+20220921

commit c3fda946dedbb08df8eb46bb0120938c08f09742
Author: Richard Sandiford <richard.sandiford@arm.com>
Date:   Wed Sep 21 14:17:43 2022 +0100

    aarch64: Fix GTY markup for arm_sve.h [PR106491]
    
    It turns out that GTY(()) markers in definitions like:
    
      GTY(()) tree scalar_types[NUM_VECTOR_TYPES];
    
    are not effective and are silently ignored.  The GTY(()) has
    to come after an extern or static.
    
    The externs associated with the SVE ACLE GTY variables are in
    aarch64-sve-builtins.h.  This file is not in tm_include_list because
    we don't want every target-facing file to include it.  It therefore
    isn't in the list of GC header files either.
    
    In this case that's a blessing in disguise, since the variables
    belong to a namespace and gengtype doesn't understand namespaces.
    I think the fix is instead to add an extra extern before each
    variable declaration, similarly to varasm.cc and vtable-verify.cc.
    (This works due to a "using namespace" at the end of the file.)
    
    gcc/
            PR target/106491
            * config/aarch64/aarch64-sve-builtins.cc (scalar_types)
            (acle_vector_types, acle_svpattern, acle_svprfop): Add GTY
            markup to (new) extern declarations instead of to the main
            definition.
    
    (cherry picked from commit 6bf5a704d36243c4c04b17a9408ebe881beb0051)

diff --git a/gcc/config/aarch64/aarch64-sve-builtins.cc b/gcc/config/aarch64/aarch64-sve-builtins.cc
index 336a1db662b..cb4564c821c 100644
--- a/gcc/config/aarch64/aarch64-sve-builtins.cc
+++ b/gcc/config/aarch64/aarch64-sve-builtins.cc
@@ -530,7 +530,8 @@ static CONSTEXPR const function_group_info function_groups[] = {
 };
 
 /* The scalar type associated with each vector type.  */
-GTY(()) tree scalar_types[NUM_VECTOR_TYPES];
+extern GTY(()) tree scalar_types[NUM_VECTOR_TYPES];
+tree scalar_types[NUM_VECTOR_TYPES];
 
 /* The single-predicate and single-vector types, with their built-in
    "__SV..._t" name.  Allow an index of NUM_VECTOR_TYPES, which always
@@ -538,13 +539,16 @@ GTY(()) tree scalar_types[NUM_VECTOR_TYPES];
 static GTY(()) tree abi_vector_types[NUM_VECTOR_TYPES + 1];
 
 /* Same, but with the arm_sve.h "sv..._t" name.  */
-GTY(()) tree acle_vector_types[MAX_TUPLE_SIZE][NUM_VECTOR_TYPES + 1];
+extern GTY(()) tree acle_vector_types[MAX_TUPLE_SIZE][NUM_VECTOR_TYPES + 1];
+tree acle_vector_types[MAX_TUPLE_SIZE][NUM_VECTOR_TYPES + 1];
 
 /* The svpattern enum type.  */
-GTY(()) tree acle_svpattern;
+extern GTY(()) tree acle_svpattern;
+tree acle_svpattern;
 
 /* The svprfop enum type.  */
-GTY(()) tree acle_svprfop;
+extern GTY(()) tree acle_svprfop;
+tree acle_svprfop;
 
 /* The list of all registered function decls, indexed by code.  */
 static GTY(()) vec<registered_function *, va_gc> *registered_functions;

commit d83b6e042c74e941622ca9f093839331171d610f
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Thu Sep 22 00:20:45 2022 +0000

    Daily bump.

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 413ff84e61a..846570b2d35 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,14 @@
+2022-09-21  Richard Sandiford  <richard.sandiford@arm.com>
+
+	Backported from master:
+	2022-09-20  Richard Sandiford  <richard.sandiford@arm.com>
+
+	PR target/106491
+	* config/aarch64/aarch64-sve-builtins.cc (scalar_types)
+	(acle_vector_types, acle_svpattern, acle_svprfop): Add GTY
+	markup to (new) extern declarations instead of to the main
+	definition.
+
 2022-09-14  Tom de Vries  <tdevries@suse.de>
 
 	Backported from master:
diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 2407ee3feb4..6fbb09fe858 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20220921
+20220922

commit cf172d0cdf355042223a3b1ebc04b472386a954e
Author: Harald Anlauf <anlauf@gmx.de>
Date:   Thu Sep 15 22:39:24 2022 +0200

    Fortran: catch NULL pointer dereferences while simplifying PACK [PR106857]
    
    gcc/fortran/ChangeLog:
    
            PR fortran/106857
            * simplify.c (gfc_simplify_pack): Check for NULL pointer dereferences
            while walking through constructors (error recovery).
    
    gcc/testsuite/ChangeLog:
    
            PR fortran/106857
            * gfortran.dg/pr106857.f90: New test.
    
    (cherry picked from commit 2b75d5f533b9d6b39f4055949aff64ed0d22dd24)

diff --git a/gcc/fortran/simplify.c b/gcc/fortran/simplify.c
index 29d4c695302..b3d73935771 100644
--- a/gcc/fortran/simplify.c
+++ b/gcc/fortran/simplify.c
@@ -6293,7 +6293,7 @@ gfc_simplify_pack (gfc_expr *array, gfc_expr *mask, gfc_expr *vector)
       /* Copy only those elements of ARRAY to RESULT whose
 	 MASK equals .TRUE..  */
       mask_ctor = gfc_constructor_first (mask->value.constructor);
-      while (mask_ctor)
+      while (mask_ctor && array_ctor)
 	{
 	  if (mask_ctor->expr->value.logical)
 	    {
diff --git a/gcc/testsuite/gfortran.dg/pr106857.f90 b/gcc/testsuite/gfortran.dg/pr106857.f90
new file mode 100644
index 00000000000..4b0f86a75a6
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr106857.f90
@@ -0,0 +1,12 @@
+! { dg-do compile }
+! PR fortran/106857 - ICE in gfc_simplify_pack
+! Contributed by G.Steinmetz
+
+program p
+  type t
+     integer :: n
+  end type
+  type(t), parameter :: a(2,2) = t(1)
+  type(t), parameter :: b(4) = reshape(a, [2])                          ! { dg-error "Different shape" }
+  type(t), parameter :: c(2) = pack(b, [.false.,.true.,.false.,.true.]) ! { dg-error "Different shape" }
+end

commit ea29884ccea48b54f490ec619597fcdbc87ccc5d
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Fri Sep 23 00:19:44 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 6fbb09fe858..44f77519800 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20220922
+20220923
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 0f27acdb552..0ac0056381d 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,12 @@
+2022-09-22  Harald Anlauf  <anlauf@gmx.de>
+
+	Backported from master:
+	2022-09-15  Harald Anlauf  <anlauf@gmx.de>
+
+	PR fortran/106857
+	* simplify.c (gfc_simplify_pack): Check for NULL pointer dereferences
+	while walking through constructors (error recovery).
+
 2022-07-26  Harald Anlauf  <anlauf@gmx.de>
 
 	Backported from master:
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index a97ae4dad05..b807b652674 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,11 @@
+2022-09-22  Harald Anlauf  <anlauf@gmx.de>
+
+	Backported from master:
+	2022-09-15  Harald Anlauf  <anlauf@gmx.de>
+
+	PR fortran/106857
+	* gfortran.dg/pr106857.f90: New test.
+
 2022-09-13  Peter Bergner  <bergner@linux.ibm.com>
 
 	Backported from master:

commit f744c9fb0b120aefc8d7b08e1306527d96d2768d
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sat Sep 24 00:18:06 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 44f77519800..c0c32de0371 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20220923
+20220924

commit 2e33da576bc08e78020bbb6642b70eccb108192b
Author: José Rui Faustino de Sousa <jrfsousa@gmail.com>
Date:   Fri Sep 2 21:35:22 2022 +0200

    Fortran: Fix ICE with automatic reallocation [PR100245]
    
    gcc/fortran/ChangeLog:
    
            PR fortran/100245
            * trans-expr.c (trans_class_assignment): Add if clause to handle
            derived type in the LHS.
    
    gcc/testsuite/ChangeLog:
    
            PR fortran/100245
            * gfortran.dg/PR100245.f90: New test.
    
    (cherry picked from commit 504424f33771be0405454e7845219d5df1bb88bb)

diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c
index 5f4a464b0f9..82341f65e28 100644
--- a/gcc/fortran/trans-expr.c
+++ b/gcc/fortran/trans-expr.c
@@ -10904,6 +10904,9 @@ trans_class_assignment (stmtblock_t *block, gfc_expr *lhs, gfc_expr *rhs,
       class_han = GFC_CLASS_TYPE_P (TREE_TYPE (lse->expr))
 	  ? gfc_class_data_get (lse->expr) : lse->expr;
 
+      if (!POINTER_TYPE_P (TREE_TYPE (class_han)))
+	class_han = gfc_build_addr_expr (NULL_TREE, class_han);
+
       /* Allocate block.  */
       gfc_init_block (&alloc);
       gfc_allocate_using_malloc (&alloc, class_han, size, NULL_TREE);
diff --git a/gcc/testsuite/gfortran.dg/PR100245.f90 b/gcc/testsuite/gfortran.dg/PR100245.f90
new file mode 100644
index 00000000000..07c1f7b3a1c
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/PR100245.f90
@@ -0,0 +1,28 @@
+! { dg-do run }
+!
+! Test the fix for PR100245
+!
+
+program main_p
+
+  implicit none
+
+  type :: foo_t
+    integer :: a
+  end type foo_t
+
+  integer, parameter :: a = 42
+
+  class(foo_t), allocatable :: val
+  class(foo_t), allocatable :: rs1
+  type(foo_t),  allocatable :: rs2
+
+  allocate(val, source=foo_t(42))
+  if (val%a/=a) stop 1
+  rs1 = val
+  if (rs1%a/=a) stop 2
+  rs2 = val
+  if (rs2%a/=a) stop 3
+  deallocate(val, rs1, rs2)
+
+end program main_p

commit a6e98433b778a63ca2a808dfcd8a801d239a7a83
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sun Sep 25 00:18:54 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index c0c32de0371..38f463d03a1 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20220924
+20220925
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 0ac0056381d..c838e5d66ab 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,12 @@
+2022-09-24  José Rui Faustino de Sousa  <jrfsousa@gmail.com>
+
+	Backported from master:
+	2022-09-03  José Rui Faustino de Sousa  <jrfsousa@gmail.com>
+
+	PR fortran/100245
+	* trans-expr.c (trans_class_assignment): Add if clause to handle
+	derived type in the LHS.
+
 2022-09-22  Harald Anlauf  <anlauf@gmx.de>
 
 	Backported from master:
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index b807b652674..a1328f0656d 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,11 @@
+2022-09-24  José Rui Faustino de Sousa  <jrfsousa@gmail.com>
+
+	Backported from master:
+	2022-09-03  José Rui Faustino de Sousa  <jrfsousa@gmail.com>
+
+	PR fortran/100245
+	* gfortran.dg/PR100245.f90: New test.
+
 2022-09-22  Harald Anlauf  <anlauf@gmx.de>
 
 	Backported from master:

commit fa9c1efcd031c9845fb34165bab3177ca762730c
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Mon Sep 26 00:19:05 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 38f463d03a1..7764f7ed0a8 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20220925
+20220926

commit f5840677c146e4317d7fd53697dda60c616d3e58
Author: Harald Anlauf <anlauf@gmx.de>
Date:   Tue Sep 20 22:41:48 2022 +0200

    Fortran: error recovery on invalid ARRAY argument to FINDLOC [PR106986]
    
    gcc/fortran/ChangeLog:
    
            PR fortran/106986
            * simplify.c (gfc_simplify_findloc): Do not try to simplify
            intrinsic FINDLOC when the ARRAY argument has a NULL shape.
    
    gcc/testsuite/ChangeLog:
    
            PR fortran/106986
            * gfortran.dg/pr106986.f90: New test.
    
    (cherry picked from commit 5976fbf9d5dd9542fcb82eebb2185886fd52d000)

diff --git a/gcc/fortran/simplify.c b/gcc/fortran/simplify.c
index b3d73935771..149353ef784 100644
--- a/gcc/fortran/simplify.c
+++ b/gcc/fortran/simplify.c
@@ -5757,6 +5757,7 @@ gfc_simplify_findloc (gfc_expr *array, gfc_expr *value, gfc_expr *dim,
   bool back_val = false;
 
   if (!is_constant_array_expr (array)
+      || array->shape == NULL
       || !gfc_is_constant_expr (dim))
     return NULL;
 
diff --git a/gcc/testsuite/gfortran.dg/pr106986.f90 b/gcc/testsuite/gfortran.dg/pr106986.f90
new file mode 100644
index 00000000000..a309b25d181
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr106986.f90
@@ -0,0 +1,8 @@
+! { dg-do compile }
+! PR fortran/106986 - ICE in simplify_findloc_nodim
+! Contributed by G.Steinmetz
+
+program p
+  integer, parameter :: a(:) = [1] ! { dg-error "deferred shape" }
+  print *, findloc (a, 1)
+end

commit 24564dd20af0844e4284e20a9d6758ab9b6d1b4d
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Tue Sep 27 00:18:55 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 7764f7ed0a8..38c805d4b6a 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20220926
+20220927
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index c838e5d66ab..2e8b844eb0d 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,12 @@
+2022-09-26  Harald Anlauf  <anlauf@gmx.de>
+
+	Backported from master:
+	2022-09-20  Harald Anlauf  <anlauf@gmx.de>
+
+	PR fortran/106986
+	* simplify.c (gfc_simplify_findloc): Do not try to simplify
+	intrinsic FINDLOC when the ARRAY argument has a NULL shape.
+
 2022-09-24  José Rui Faustino de Sousa  <jrfsousa@gmail.com>
 
 	Backported from master:
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index a1328f0656d..6debda40f89 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,11 @@
+2022-09-26  Harald Anlauf  <anlauf@gmx.de>
+
+	Backported from master:
+	2022-09-20  Harald Anlauf  <anlauf@gmx.de>
+
+	PR fortran/106986
+	* gfortran.dg/pr106986.f90: New test.
+
 2022-09-24  José Rui Faustino de Sousa  <jrfsousa@gmail.com>
 
 	Backported from master:

commit dad797c11ccf56e1594fe3ab3120a5c2d2784e54
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Wed Sep 28 00:18:52 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 38c805d4b6a..8830fa8da31 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20220927
+20220928

commit 9a8e82d5f6f7b1ab53886ecf2fe32e36f49a7678
Author: Kyrylo Tkachov <kyrylo.tkachov@arm.com>
Date:   Wed Sep 28 16:48:14 2022 +0100

    aarch64: Add support for -mcpu=neoverse-v2
    
    This is a GCC 10 version of https://gcc.gnu.org/pipermail/gcc-patches/2022-September/602105.html
    There are no tuning structures to rename so the patch is (even) smaller than the GCC 12 and trunk
    versions.
    
    Bootstrapped and tested on aarch64-none-linux-gnu.
    
    gcc/ChangeLog:
    
            * config/aarch64/aarch64-cores.def (neoverse-v2): New entry.
            * config/aarch64/aarch64-tune.md: Regenerate.
            * doc/invoke.texi (AArch64 Options): Document neoverse-v2.

diff --git a/gcc/config/aarch64/aarch64-cores.def b/gcc/config/aarch64/aarch64-cores.def
index fc60e2ae1ac..6b817c61efe 100644
--- a/gcc/config/aarch64/aarch64-cores.def
+++ b/gcc/config/aarch64/aarch64-cores.def
@@ -142,6 +142,7 @@ AARCH64_CORE("saphira",     saphira,    saphira,    8_4A,  AARCH64_FL_FOR_ARCH8_
 
 /* Armv8.5-A Architecture Processors.  */
 AARCH64_CORE("neoverse-n2", neoversen2, cortexa57, 8_5A, AARCH64_FL_FOR_ARCH8_5 | AARCH64_FL_I8MM | AARCH64_FL_BF16 | AARCH64_FL_F16 | AARCH64_FL_SVE | AARCH64_FL_SVE2 | AARCH64_FL_SVE2_BITPERM | AARCH64_FL_RNG | AARCH64_FL_MEMTAG, neoversen2, 0x41, 0xd49, -1)
+AARCH64_CORE("neoverse-v2", neoversev2, cortexa57, 8_5A, AARCH64_FL_FOR_ARCH8_5 | AARCH64_FL_I8MM | AARCH64_FL_BF16 | AARCH64_FL_F16 | AARCH64_FL_SVE | AARCH64_FL_SVE2 | AARCH64_FL_SVE2_BITPERM | AARCH64_FL_RNG | AARCH64_FL_MEMTAG, neoversev1, 0x41, 0xd4f, -1)
 
 /* ARMv8-A big.LITTLE implementations.  */
 
diff --git a/gcc/config/aarch64/aarch64-tune.md b/gcc/config/aarch64/aarch64-tune.md
index aa68d67bdf4..d116b0e5e97 100644
--- a/gcc/config/aarch64/aarch64-tune.md
+++ b/gcc/config/aarch64/aarch64-tune.md
@@ -1,5 +1,5 @@
 ;; -*- buffer-read-only: t -*-
 ;; Generated automatically by gentune.sh from aarch64-cores.def
 (define_attr "tune"
-	"cortexa34,cortexa35,cortexa53,cortexa57,cortexa72,cortexa73,thunderx,thunderxt88p1,thunderxt88,octeontx,octeontxt81,octeontxt83,thunderxt81,thunderxt83,emag,xgene1,falkor,qdf24xx,exynosm1,phecda,thunderx2t99p1,vulcan,thunderx2t99,cortexa55,cortexa75,cortexa76,cortexa76ae,cortexa77,cortexa65,cortexa65ae,ares,neoversen1,neoversee1,octeontx2,octeontx2t98,octeontx2t96,octeontx2t93,octeontx2f95,octeontx2f95n,octeontx2f95mm,a64fx,tsv110,thunderx3t110,zeus,neoversev1,neoverse512tvb,saphira,neoversen2,cortexa57cortexa53,cortexa72cortexa53,cortexa73cortexa35,cortexa73cortexa53,cortexa75cortexa55,cortexa76cortexa55"
+	"cortexa34,cortexa35,cortexa53,cortexa57,cortexa72,cortexa73,thunderx,thunderxt88p1,thunderxt88,octeontx,octeontxt81,octeontxt83,thunderxt81,thunderxt83,emag,xgene1,falkor,qdf24xx,exynosm1,phecda,thunderx2t99p1,vulcan,thunderx2t99,cortexa55,cortexa75,cortexa76,cortexa76ae,cortexa77,cortexa65,cortexa65ae,ares,neoversen1,neoversee1,octeontx2,octeontx2t98,octeontx2t96,octeontx2t93,octeontx2f95,octeontx2f95n,octeontx2f95mm,a64fx,tsv110,thunderx3t110,zeus,neoversev1,neoverse512tvb,saphira,neoversen2,neoversev2,cortexa57cortexa53,cortexa72cortexa53,cortexa73cortexa35,cortexa73cortexa53,cortexa75cortexa55,cortexa76cortexa55"
 	(const (symbol_ref "((enum attr_tune) aarch64_tune)")))
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index d7c787af226..4f399d3eeac 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -16999,7 +16999,7 @@ performance of the code.  Permissible values for this option are:
 @samp{cortex-a65}, @samp{cortex-a65ae}, @samp{cortex-a34},
 @samp{ares}, @samp{exynos-m1}, @samp{emag}, @samp{falkor},
 @samp{neoverse-e1}, @samp{neoverse-n1}, @samp{neoverse-n2},
-@samp{neoverse-v1}, @samp{neoverse-512tvb}, @samp{qdf24xx},
+@samp{neoverse-v1}, @samp{neoverse-v2}, @samp{neoverse-512tvb}, @samp{qdf24xx},
 @samp{saphira}, @samp{phecda}, @samp{xgene1}, @samp{vulcan}, @samp{octeontx},
 @samp{octeontx81},  @samp{octeontx83},
 @samp{octeontx2}, @samp{octeontx2t98}, @samp{octeontx2t96}

commit 4e80bbbf45352e5894fbebb7f33e984ada47aff4
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Thu Sep 29 00:18:23 2022 +0000

    Daily bump.

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 846570b2d35..fabb51e5db5 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2022-09-28  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>
+
+	* config/aarch64/aarch64-cores.def (neoverse-v2): New entry.
+	* config/aarch64/aarch64-tune.md: Regenerate.
+	* doc/invoke.texi (AArch64 Options): Document neoverse-v2.
+
 2022-09-21  Richard Sandiford  <richard.sandiford@arm.com>
 
 	Backported from master:
diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 8830fa8da31..ea4b4d1bd3b 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20220928
+20220929

commit a0009aba8ed71a7f4b3a1065b6c7a9ab18f7ff76
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Fri Sep 30 00:18:36 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index ea4b4d1bd3b..47b36b023d0 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20220929
+20220930

commit c59d1e73a617277fea13e785bb0e3f8c1df6ffc4
Author: Harald Anlauf <anlauf@gmx.de>
Date:   Tue Aug 23 22:16:14 2022 +0200

    Fortran: improve error recovery while simplifying size of bad array [PR103694]
    
    gcc/fortran/ChangeLog:
    
            PR fortran/103694
            * simplify.c (simplify_size): The size expression of an array cannot
            be simplified if an error occurs while resolving the array spec.
    
    gcc/testsuite/ChangeLog:
    
            PR fortran/103694
            * gfortran.dg/pr103694.f90: New test.
    
    (cherry picked from commit 55d8c5409325001c89c35c3d04d425dec9127146)

diff --git a/gcc/fortran/simplify.c b/gcc/fortran/simplify.c
index 149353ef784..a265748efd0 100644
--- a/gcc/fortran/simplify.c
+++ b/gcc/fortran/simplify.c
@@ -7387,8 +7387,9 @@ simplify_size (gfc_expr *array, gfc_expr *dim, int k)
     }
 
   for (ref = array->ref; ref; ref = ref->next)
-    if (ref->type == REF_ARRAY && ref->u.ar.as)
-      gfc_resolve_array_spec (ref->u.ar.as, 0);
+    if (ref->type == REF_ARRAY && ref->u.ar.as
+	&& !gfc_resolve_array_spec (ref->u.ar.as, 0))
+      return NULL;
 
   if (dim == NULL)
     {
diff --git a/gcc/testsuite/gfortran.dg/pr103694.f90 b/gcc/testsuite/gfortran.dg/pr103694.f90
new file mode 100644
index 00000000000..3ed8b2088da
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr103694.f90
@@ -0,0 +1,11 @@
+! { dg-do compile }
+! PR fortran/103694 - ICE in gfc_conv_expr_op
+! Contributed by G.Steinmetz
+
+subroutine s
+  type t
+     integer :: a(2)
+  end type
+  type(t) :: x((0.)/0)
+  integer :: n = size(x(1)%a) ! { dg-error "does not reduce to a constant expression" }
+end

commit 12cd4a7c465b1a0874f5bc4419bd19d8041a8e2a
Author: Harald Anlauf <anlauf@gmx.de>
Date:   Tue Sep 20 22:23:43 2022 +0200

    Fortran: NULL pointer dereference in invalid simplification [PR106985]
    
    gcc/fortran/ChangeLog:
    
            PR fortran/106985
            * expr.c (gfc_simplify_expr): Avoid NULL pointer dereference.
    
    gcc/testsuite/ChangeLog:
    
            PR fortran/106985
            * gfortran.dg/pr106985.f90: New test.
    
    (cherry picked from commit 8dbb15bc2d019488240c1e69d93121b0347ac092)

diff --git a/gcc/fortran/expr.c b/gcc/fortran/expr.c
index 6d95120be50..1129f5f3302 100644
--- a/gcc/fortran/expr.c
+++ b/gcc/fortran/expr.c
@@ -2277,7 +2277,8 @@ gfc_simplify_expr (gfc_expr *p, int type)
 	 initialization expression, or we want a subsection.  */
       if (p->symtree->n.sym->attr.flavor == FL_PARAMETER
 	  && (gfc_init_expr_flag || p->ref
-	      || p->symtree->n.sym->value->expr_type != EXPR_ARRAY))
+	      || (p->symtree->n.sym->value
+		  && p->symtree->n.sym->value->expr_type != EXPR_ARRAY)))
 	{
 	  if (!simplify_parameter_variable (p, type))
 	    return false;
diff --git a/gcc/testsuite/gfortran.dg/pr106985.f90 b/gcc/testsuite/gfortran.dg/pr106985.f90
new file mode 100644
index 00000000000..f4ed92577a3
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr106985.f90
@@ -0,0 +1,8 @@
+! { dg-do compile }
+! PR fortran/106985 - ICE in gfc_simplify_expr
+! Contributed by G.Steinmetz
+
+program p
+  integer, parameter :: a(2) = 1
+  integer, parameter :: b = a(2) + b ! { dg-error "before its definition is complete" }
+end

commit f2509f6195869fd01aec02714af2d0c3346fa917
Author: Harald Anlauf <anlauf@gmx.de>
Date:   Wed Sep 21 19:55:30 2022 +0200

    Fortran: fix ICE in generate_coarray_sym_init [PR82868]
    
    gcc/fortran/ChangeLog:
    
            PR fortran/82868
            * trans-decl.c (generate_coarray_sym_init): Skip symbol
            if attr.associate_var.
    
    gcc/testsuite/ChangeLog:
    
            PR fortran/82868
            * gfortran.dg/associate_26a.f90: New test.
    
    (cherry picked from commit bc71318a91286b5f00e88f07aab818ac82510692)

diff --git a/gcc/fortran/trans-decl.c b/gcc/fortran/trans-decl.c
index 765c492520c..bb72eb6731d 100644
--- a/gcc/fortran/trans-decl.c
+++ b/gcc/fortran/trans-decl.c
@@ -5605,6 +5605,7 @@ generate_coarray_sym_init (gfc_symbol *sym)
 
   if (sym->attr.dummy || sym->attr.allocatable || !sym->attr.codimension
       || sym->attr.use_assoc || !sym->attr.referenced
+      || sym->attr.associate_var
       || sym->attr.select_type_temporary)
     return;
 
diff --git a/gcc/testsuite/gfortran.dg/associate_26a.f90 b/gcc/testsuite/gfortran.dg/associate_26a.f90
new file mode 100644
index 00000000000..85aebebd4d8
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/associate_26a.f90
@@ -0,0 +1,15 @@
+! { dg-do compile }
+! { dg-options "-fcoarray=lib" }
+!
+! Test the fix for PR78152 and the followup in PR82868
+!
+! Contributed by <physiker@toast2.net>
+!
+program co_assoc
+  implicit none
+  integer, parameter :: p = 5
+  real, allocatable :: a(:,:)[:,:]
+  allocate (a(p,p)[2,*])
+  associate (i => a(1:p, 1:p))
+  end associate
+end program co_assoc

commit b2bd7622721c3a35a9884135e719ae6b0fdc3e2d
Author: Harald Anlauf <anlauf@gmx.de>
Date:   Tue Sep 27 20:54:28 2022 +0200

    Fortran: error recovery while simplifying intrinsic UNPACK [PR107054]
    
    gcc/fortran/ChangeLog:
    
            PR fortran/107054
            * simplify.c (gfc_simplify_unpack): Replace assert by condition
            that terminates simplification when there are not enough elements
            in the constructor of argument VECTOR.
    
    gcc/testsuite/ChangeLog:
    
            PR fortran/107054
            * gfortran.dg/pr107054.f90: New test.
    
    (cherry picked from commit 78bc6497fc61bbdacfb416ee0246a775360d9af6)

diff --git a/gcc/fortran/simplify.c b/gcc/fortran/simplify.c
index a265748efd0..c1db8650b0d 100644
--- a/gcc/fortran/simplify.c
+++ b/gcc/fortran/simplify.c
@@ -8308,9 +8308,16 @@ gfc_simplify_unpack (gfc_expr *vector, gfc_expr *mask, gfc_expr *field)
     {
       if (mask_ctor->expr->value.logical)
 	{
-	  gcc_assert (vector_ctor);
-	  e = gfc_copy_expr (vector_ctor->expr);
-	  vector_ctor = gfc_constructor_next (vector_ctor);
+	  if (vector_ctor)
+	    {
+	      e = gfc_copy_expr (vector_ctor->expr);
+	      vector_ctor = gfc_constructor_next (vector_ctor);
+	    }
+	  else
+	    {
+	      gfc_free_expr (result);
+	      return NULL;
+	    }
 	}
       else if (field->expr_type == EXPR_ARRAY)
 	e = gfc_copy_expr (field_ctor->expr);
diff --git a/gcc/testsuite/gfortran.dg/pr107054.f90 b/gcc/testsuite/gfortran.dg/pr107054.f90
new file mode 100644
index 00000000000..bbfe646beba
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr107054.f90
@@ -0,0 +1,13 @@
+! { dg-do compile }
+! PR fortran/107054 - ICE in gfc_simplify_unpack
+! Contributed by G.Steinmetz
+
+program p
+  type t
+     integer :: n = 0
+  end type
+  type(t), parameter :: a(4) = t(2)
+  type(t), parameter :: b(4) = reshape(a,[2]) ! { dg-error "Different shape" }
+  type(t), parameter :: c(2) = pack(b,[.false.,.true.,.false.,.true.]) ! { dg-error "Different shape" }
+  type(t), parameter :: d(4) = unpack(c,[.false.,.true.,.false.,.true.],a)
+end

commit b17648c7d5f9bab852cc420054ca4cc2880edb2a
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sat Oct 1 00:19:22 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 47b36b023d0..5e34ca4ca85 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20220930
+20221001
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 2e8b844eb0d..4b0c932b715 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,39 @@
+2022-09-30  Harald Anlauf  <anlauf@gmx.de>
+
+	Backported from master:
+	2022-09-27  Harald Anlauf  <anlauf@gmx.de>
+
+	PR fortran/107054
+	* simplify.c (gfc_simplify_unpack): Replace assert by condition
+	that terminates simplification when there are not enough elements
+	in the constructor of argument VECTOR.
+
+2022-09-30  Harald Anlauf  <anlauf@gmx.de>
+
+	Backported from master:
+	2022-09-22  Harald Anlauf  <anlauf@gmx.de>
+
+	PR fortran/82868
+	* trans-decl.c (generate_coarray_sym_init): Skip symbol
+	if attr.associate_var.
+
+2022-09-30  Harald Anlauf  <anlauf@gmx.de>
+
+	Backported from master:
+	2022-09-20  Harald Anlauf  <anlauf@gmx.de>
+
+	PR fortran/106985
+	* expr.c (gfc_simplify_expr): Avoid NULL pointer dereference.
+
+2022-09-30  Harald Anlauf  <anlauf@gmx.de>
+
+	Backported from master:
+	2022-08-24  Harald Anlauf  <anlauf@gmx.de>
+
+	PR fortran/103694
+	* simplify.c (simplify_size): The size expression of an array cannot
+	be simplified if an error occurs while resolving the array spec.
+
 2022-09-26  Harald Anlauf  <anlauf@gmx.de>
 
 	Backported from master:
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 6debda40f89..a726cb3285b 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,35 @@
+2022-09-30  Harald Anlauf  <anlauf@gmx.de>
+
+	Backported from master:
+	2022-09-27  Harald Anlauf  <anlauf@gmx.de>
+
+	PR fortran/107054
+	* gfortran.dg/pr107054.f90: New test.
+
+2022-09-30  Harald Anlauf  <anlauf@gmx.de>
+
+	Backported from master:
+	2022-09-22  Harald Anlauf  <anlauf@gmx.de>
+
+	PR fortran/82868
+	* gfortran.dg/associate_26a.f90: New test.
+
+2022-09-30  Harald Anlauf  <anlauf@gmx.de>
+
+	Backported from master:
+	2022-09-20  Harald Anlauf  <anlauf@gmx.de>
+
+	PR fortran/106985
+	* gfortran.dg/pr106985.f90: New test.
+
+2022-09-30  Harald Anlauf  <anlauf@gmx.de>
+
+	Backported from master:
+	2022-08-24  Harald Anlauf  <anlauf@gmx.de>
+
+	PR fortran/103694
+	* gfortran.dg/pr103694.f90: New test.
+
 2022-09-26  Harald Anlauf  <anlauf@gmx.de>
 
 	Backported from master:

commit 8c583871e70f5530907d22a21b0f1d1e7b90e224
Author: José Rui Faustino de Sousa <jrfsousa@gmail.com>
Date:   Mon Sep 19 22:00:45 2022 +0200

    Fortran: Fix function attributes [PR100132]
    
    gcc/fortran/ChangeLog:
    
            PR fortran/100132
            * trans-types.c (create_fn_spec): Fix function attributes when
            passing polymorphic pointers.
    
    gcc/testsuite/ChangeLog:
    
            PR fortran/100132
            * gfortran.dg/PR100132.f90: New test.
    
    (cherry picked from commit be60aa5b608b5f09fadfeff852a46589ac311a42)

diff --git a/gcc/fortran/trans-types.c b/gcc/fortran/trans-types.c
index d9f54d85338..d9f3dae22ec 100644
--- a/gcc/fortran/trans-types.c
+++ b/gcc/fortran/trans-types.c
@@ -2954,12 +2954,23 @@ create_fn_spec (gfc_symbol *sym, tree fntype)
   for (f = gfc_sym_get_dummy_args (sym); f; f = f->next)
     if (spec_len < sizeof (spec))
       {
-	if (!f->sym || f->sym->attr.pointer || f->sym->attr.target
+	bool is_class = false;
+	bool is_pointer = false;
+
+	if (f->sym)
+	  {
+	    is_class = f->sym->ts.type == BT_CLASS && CLASS_DATA (f->sym)
+	      && f->sym->attr.class_ok;
+	    is_pointer = is_class ? CLASS_DATA (f->sym)->attr.class_pointer
+				  : f->sym->attr.pointer;
+	  }
+
+	if (f->sym == NULL || is_pointer || f->sym->attr.target
 	    || f->sym->attr.external || f->sym->attr.cray_pointer
 	    || (f->sym->ts.type == BT_DERIVED
 		&& (f->sym->ts.u.derived->attr.proc_pointer_comp
 		    || f->sym->ts.u.derived->attr.pointer_comp))
-	    || (f->sym->ts.type == BT_CLASS
+	    || (is_class
 		&& (CLASS_DATA (f->sym)->ts.u.derived->attr.proc_pointer_comp
 		    || CLASS_DATA (f->sym)->ts.u.derived->attr.pointer_comp))
 	    || (f->sym->ts.type == BT_INTEGER && f->sym->ts.is_c_interop))
diff --git a/gcc/testsuite/gfortran.dg/PR100132.f90 b/gcc/testsuite/gfortran.dg/PR100132.f90
new file mode 100644
index 00000000000..78ae6702810
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/PR100132.f90
@@ -0,0 +1,75 @@
+! { dg-do run }
+!
+! Test the fix for PR100132
+!
+
+module main_m
+  implicit none
+
+  private
+
+  public :: &
+    foo_t
+
+  public :: &
+    set,    &
+    get
+
+  type :: foo_t
+    integer :: i
+  end type foo_t
+
+  type(foo_t), save, pointer :: data => null()
+
+contains
+
+  subroutine set(this)
+    class(foo_t), pointer, intent(in) :: this
+
+    if(associated(data)) stop 1
+    data => this
+  end subroutine set
+
+  subroutine get(this)
+    type(foo_t), pointer, intent(out) :: this
+
+    if(.not.associated(data)) stop 4
+    this => data
+    nullify(data)
+  end subroutine get
+
+end module main_m
+
+program main_p
+
+  use :: main_m, only: &
+    foo_t, set, get
+
+  implicit none
+
+  integer, parameter :: n = 1000
+
+  type(foo_t), pointer :: ps
+  type(foo_t),  target :: s
+  integer              :: i, j, yay, nay
+
+  yay = 0
+  nay = 0
+  do i = 1, n
+    s%i = i
+    call set(s)
+    call get(ps)
+    if(.not.associated(ps)) stop 13
+    j = ps%i
+    if(i/=j) stop 14
+    if(i/=s%i) stop 15
+    if(ps%i/=s%i) stop 16
+    if(associated(ps, s))then
+      yay = yay + 1
+    else
+      nay = nay + 1
+    end if
+  end do
+  if((yay/=n).or.(nay/=0)) stop 17
+
+end program main_p

commit 3300c9566c7f127ef5efede9d3165bb5d541648c
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sun Oct 2 00:19:14 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 5e34ca4ca85..9bab13a3255 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20221001
+20221002
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 4b0c932b715..141f47f85ad 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,12 @@
+2022-10-01  José Rui Faustino de Sousa  <jrfsousa@gmail.com>
+
+	Backported from master:
+	2022-09-20  José Rui Faustino de Sousa  <jrfsousa@gmail.com>
+
+	PR fortran/100132
+	* trans-types.c (create_fn_spec): Fix function attributes when
+	passing polymorphic pointers.
+
 2022-09-30  Harald Anlauf  <anlauf@gmx.de>
 
 	Backported from master:
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index a726cb3285b..00746b6c5a5 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,11 @@
+2022-10-01  José Rui Faustino de Sousa  <jrfsousa@gmail.com>
+
+	Backported from master:
+	2022-09-20  José Rui Faustino de Sousa  <jrfsousa@gmail.com>
+
+	PR fortran/100132
+	* gfortran.dg/PR100132.f90: New test.
+
 2022-09-30  Harald Anlauf  <anlauf@gmx.de>
 
 	Backported from master:

commit f8b05f96b0c22e978033fc058d185372a97cf346
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Mon Oct 3 00:18:56 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 9bab13a3255..f30574676b3 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20221002
+20221003

commit 4c5dcb2dee23af26288d76bf0b7fc7adc0186f28
Author: Sergei Trofimovich <siarheit@google.com>
Date:   Fri Sep 16 18:33:11 2022 +0100

    gcc/config/t-i386: add build dependencies on i386-builtin-types.inc
    
    i386-builtin-types.inc is included indirectly via i386-builtins.h
    into 4 files: i386.cc i386-builtins.cc i386-expand.cc i386-features.cc
    
    Only i386.cc dependency was present in gcc/config/t-i386 makefile.
    
    As a result parallel builds occasionally fail as:
    
        g++ ... -o i386-builtins.o ... ../../gcc-13-20220911/gcc/config/i386/i386-builtins.cc
        In file included from ../../gcc-13-20220911/gcc/config/i386/i386-builtins.cc:92:
        ../../gcc-13-20220911/gcc/config/i386/i386-builtins.h:25:10:
         fatal error: i386-builtin-types.inc: No such file or directory
           25 | #include "i386-builtin-types.inc"
              |          ^~~~~~~~~~~~~~~~~~~~~~~~
        compilation terminated.
        make[3]: *** [../../gcc-13-20220911/gcc/config/i386/t-i386:54: i386-builtins.o]
          Error 1 shuffle=1663349189
    
    gcc/
            PR target/107064
            * config/i386/t-i386: Add build-time dependencies against
            i386-builtin-types.inc to i386-builtins.o, i386-expand.o,
            i386-features.o.
    
    (cherry picked from commit ef3165736d9daafba88adb2db65b2e8ebf0024ca)

diff --git a/gcc/config/i386/t-i386 b/gcc/config/i386/t-i386
index e5fb0618fe6..bcb19f891f2 100644
--- a/gcc/config/i386/t-i386
+++ b/gcc/config/i386/t-i386
@@ -61,7 +61,12 @@ i386-features.o: $(srcdir)/config/i386/i386-features.c
 	$(COMPILE) $<
 	$(POSTCOMPILE)
 
+# i386-builtin-types.inc is included into i386-builtins.h.
+# Below are direct users of i386-builtins.h:
 i386.o: i386-builtin-types.inc
+i386-builtins.o: i386-builtin-types.inc
+i386-expand.o: i386-builtin-types.inc
+i386-features.o: i386-builtin-types.inc
 
 i386-builtin-types.inc: s-i386-bt ; @true
 s-i386-bt: $(srcdir)/config/i386/i386-builtin-types.awk \

commit 5a304edf8f9aa4813075c3029b17e902a90d1d14
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Tue Oct 4 00:19:37 2022 +0000

    Daily bump.

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index fabb51e5db5..87466f49785 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,13 @@
+2022-10-03  Sergei Trofimovich  <siarheit@google.com>
+
+	Backported from master:
+	2022-10-03  Sergei Trofimovich  <siarheit@google.com>
+
+	PR target/107064
+	* config/i386/t-i386: Add build-time dependencies against
+	i386-builtin-types.inc to i386-builtins.o, i386-expand.o,
+	i386-features.o.
+
 2022-09-28  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>
 
 	* config/aarch64/aarch64-cores.def (neoverse-v2): New entry.
diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index f30574676b3..59c7fe23e2a 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20221003
+20221004

commit bfc4cec904e88f391924d1b8399f39bcd2e61457
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Wed Oct 5 00:19:10 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 59c7fe23e2a..7759c903eed 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20221004
+20221005

commit cdf087477294ee82db00bf1e67636b92dd754345
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Thu Oct 6 09:15:08 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 7759c903eed..5ba2bc5284f 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20221005
+20221006

commit 78104f78cd9eca4ef377539e67f4687b9308f4e8
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Fri Oct 7 00:18:51 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 5ba2bc5284f..12abceb7baa 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20221006
+20221007

commit db6d642edd24313581c9f92abb6c79cad0b49559
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sat Oct 8 00:20:01 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 12abceb7baa..ab0c096551c 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20221007
+20221008

commit a880f9a44ecad385d4273f96f76c5c900d716941
Author: José Rui Faustino de Sousa <jrfsousa@gmail.com>
Date:   Sun Sep 25 22:48:55 2022 +0200

    Fortran: Fix ICE and wrong code for assumed-rank arrays [PR100029, PR100040]
    
    gcc/fortran/ChangeLog:
    
            PR fortran/100040
            PR fortran/100029
            * trans-expr.c (gfc_conv_class_to_class): Add code to have
            assumed-rank arrays recognized as full arrays and fix the type
            of the array assignment.
            (gfc_conv_procedure_call): Change order of code blocks such that
            the free of ALLOCATABLE dummy arguments with INTENT(OUT) occurs
            first.
    
    gcc/testsuite/ChangeLog:
    
            PR fortran/100029
            * gfortran.dg/PR100029.f90: New test.
    
            PR fortran/100040
            * gfortran.dg/PR100040.f90: New test.
    
    (cherry picked from commit 5299155bb80e90df822e1eebc9f9a0c8e4505a46)

diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c
index 82341f65e28..49089ebf1a5 100644
--- a/gcc/fortran/trans-expr.c
+++ b/gcc/fortran/trans-expr.c
@@ -1084,8 +1084,10 @@ gfc_conv_class_to_class (gfc_se *parmse, gfc_expr *e, gfc_typespec class_ts,
     return;
 
   /* Test for FULL_ARRAY.  */
-  if (e->rank == 0 && gfc_expr_attr (e).codimension
-      && gfc_expr_attr (e).dimension)
+  if (e->rank == 0
+      && ((gfc_expr_attr (e).codimension && gfc_expr_attr (e).dimension)
+	  || (class_ts.u.derived->components->as
+	      && class_ts.u.derived->components->as->type == AS_ASSUMED_RANK)))
     full_array = true;
   else
     gfc_is_class_array_ref (e, &full_array);
@@ -1133,8 +1135,12 @@ gfc_conv_class_to_class (gfc_se *parmse, gfc_expr *e, gfc_typespec class_ts,
 	  && e->rank != class_ts.u.derived->components->as->rank)
 	{
 	  if (e->rank == 0)
-	    gfc_add_modify (&parmse->post, gfc_class_data_get (parmse->expr),
-			    gfc_conv_descriptor_data_get (ctree));
+	    {
+	      tmp = gfc_class_data_get (parmse->expr);
+	      gfc_add_modify (&parmse->post, tmp,
+			      fold_convert (TREE_TYPE (tmp),
+					 gfc_conv_descriptor_data_get (ctree)));
+	    }
 	  else
 	    class_array_data_assign (&parmse->post, parmse->expr, ctree, true);
 	}
@@ -6096,23 +6102,6 @@ gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym,
 		    base_object = build_fold_indirect_ref_loc (input_location,
 							       parmse.expr);
 
-		  /* A class array element needs converting back to be a
-		     class object, if the formal argument is a class object.  */
-		  if (fsym && fsym->ts.type == BT_CLASS
-			&& e->ts.type == BT_CLASS
-			&& ((CLASS_DATA (fsym)->as
-			     && CLASS_DATA (fsym)->as->type == AS_ASSUMED_RANK)
-			    || CLASS_DATA (e)->attr.dimension))
-		    gfc_conv_class_to_class (&parmse, e, fsym->ts, false,
-				     fsym->attr.intent != INTENT_IN
-				     && (CLASS_DATA (fsym)->attr.class_pointer
-					 || CLASS_DATA (fsym)->attr.allocatable),
-				     fsym->attr.optional
-				     && e->expr_type == EXPR_VARIABLE
-				     && e->symtree->n.sym->attr.optional,
-				     CLASS_DATA (fsym)->attr.class_pointer
-				     || CLASS_DATA (fsym)->attr.allocatable);
-
 		  /* If an ALLOCATABLE dummy argument has INTENT(OUT) and is
 		     allocated on entry, it must be deallocated.  */
 		  if (fsym && fsym->attr.intent == INTENT_OUT
@@ -6172,6 +6161,23 @@ gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym,
 		      gfc_add_expr_to_block (&se->pre, tmp);
 		    }
 
+		  /* A class array element needs converting back to be a
+		     class object, if the formal argument is a class object.  */
+		  if (fsym && fsym->ts.type == BT_CLASS
+			&& e->ts.type == BT_CLASS
+			&& ((CLASS_DATA (fsym)->as
+			     && CLASS_DATA (fsym)->as->type == AS_ASSUMED_RANK)
+			    || CLASS_DATA (e)->attr.dimension))
+		    gfc_conv_class_to_class (&parmse, e, fsym->ts, false,
+				     fsym->attr.intent != INTENT_IN
+				     && (CLASS_DATA (fsym)->attr.class_pointer
+					 || CLASS_DATA (fsym)->attr.allocatable),
+				     fsym->attr.optional
+				     && e->expr_type == EXPR_VARIABLE
+				     && e->symtree->n.sym->attr.optional,
+				     CLASS_DATA (fsym)->attr.class_pointer
+				     || CLASS_DATA (fsym)->attr.allocatable);
+
 		  if (fsym && (fsym->ts.type == BT_DERIVED
 			       || fsym->ts.type == BT_ASSUMED)
 		      && e->ts.type == BT_CLASS
diff --git a/gcc/testsuite/gfortran.dg/PR100029.f90 b/gcc/testsuite/gfortran.dg/PR100029.f90
new file mode 100644
index 00000000000..fd7e4c46032
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/PR100029.f90
@@ -0,0 +1,22 @@
+! { dg-do run }
+!
+! Test the fix for PR100029
+!
+
+program foo_p
+  implicit none
+
+  type :: foo_t
+  end type foo_t
+  
+  class(foo_t), allocatable :: pout
+
+  call foo_s(pout)
+
+contains
+
+  subroutine foo_s(that)
+    class(foo_t), allocatable, intent(out) :: that(..)
+  end subroutine foo_s
+
+end program foo_p
diff --git a/gcc/testsuite/gfortran.dg/PR100040.f90 b/gcc/testsuite/gfortran.dg/PR100040.f90
new file mode 100644
index 00000000000..0a135ff30a3
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/PR100040.f90
@@ -0,0 +1,36 @@
+! { dg-do run }
+!
+! Test the fix for PR100040
+!
+
+program foo_p
+  implicit none
+
+  integer, parameter :: n = 11
+
+  type :: foo_t
+    integer :: i
+  end type foo_t
+  
+  type(foo_t), parameter :: a = foo_t(n)
+  
+  class(foo_t), allocatable :: pout
+
+  call foo_s(pout)
+  if(.not.allocated(pout)) stop 1
+  if(pout%i/=n) stop 2
+
+contains
+
+  subroutine foo_s(that)
+    class(foo_t), allocatable, intent(out) :: that(..)
+
+    select rank(that)
+    rank(0)
+      that = a
+    rank default
+      stop 3
+    end select
+  end subroutine foo_s
+
+end program foo_p

commit d193a84380e447cb4e7ee6fd6cbfb248ff39e247
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sun Oct 9 00:19:20 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index ab0c096551c..15f928cb50e 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20221008
+20221009
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 141f47f85ad..bd5eecb1579 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,17 @@
+2022-10-08  José Rui Faustino de Sousa  <jrfsousa@gmail.com>
+
+	Backported from master:
+	2022-10-01  José Rui Faustino de Sousa  <jrfsousa@gmail.com>
+
+	PR fortran/100040
+	PR fortran/100029
+	* trans-expr.c (gfc_conv_class_to_class): Add code to have
+	assumed-rank arrays recognized as full arrays and fix the type
+	of the array assignment.
+	(gfc_conv_procedure_call): Change order of code blocks such that
+	the free of ALLOCATABLE dummy arguments with INTENT(OUT) occurs
+	first.
+
 2022-10-01  José Rui Faustino de Sousa  <jrfsousa@gmail.com>
 
 	Backported from master:
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 00746b6c5a5..dc025527891 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,13 @@
+2022-10-08  José Rui Faustino de Sousa  <jrfsousa@gmail.com>
+
+	Backported from master:
+	2022-10-01  José Rui Faustino de Sousa  <jrfsousa@gmail.com>
+
+	PR fortran/100029
+	PR fortran/100040
+	* gfortran.dg/PR100029.f90: New test.
+	* gfortran.dg/PR100040.f90: New test.
+
 2022-10-01  José Rui Faustino de Sousa  <jrfsousa@gmail.com>
 
 	Backported from master:

commit f26500cb18f2010a4fc245d0271f332091a7b6e0
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Mon Oct 10 00:18:01 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 15f928cb50e..836fdacb295 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20221009
+20221010

commit 4578aa1030d525de9392b129adc93c42fe5babb9
Author: Mikael Morin <mikael@gcc.gnu.org>
Date:   Wed Aug 31 11:00:45 2022 +0200

    fortran: Move the clobber generation code
    
    This change inlines the clobber generation code from
    gfc_conv_expr_reference to the single caller from where the add_clobber
    flag can be true, and removes the add_clobber argument.
    
    What motivates this is the standard making the procedure call a cause
    for a variable to become undefined, which translates to a clobber
    generation, so clobber generation should be closely related to procedure
    call generation, whereas it is rather orthogonal to variable reference
    generation.  Thus the generation of the clobber feels more appropriate
    in gfc_conv_procedure_call than in gfc_conv_expr_reference.
    
    Behaviour remains unchanged.
    
    gcc/fortran/ChangeLog:
    
            * trans.h (gfc_conv_expr_reference): Remove add_clobber
            argument.
            * trans-expr.c (gfc_conv_expr_reference): Ditto. Inline code
            depending on add_clobber and conditions controlling it ...
            (gfc_conv_procedure_call): ... to here.
    
    (cherry picked from commit 2b393f6f83903cb836676bbd042c1b99a6e7e6f7)

diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c
index 49089ebf1a5..2592c280a3c 100644
--- a/gcc/fortran/trans-expr.c
+++ b/gcc/fortran/trans-expr.c
@@ -5971,7 +5971,7 @@ gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym,
 				&& e->symtree->n.sym->attr.pointer))
 			&& fsym && fsym->attr.target)
 		/* Make sure the function only gets called once.  */
-		gfc_conv_expr_reference (&parmse, e, false);
+		gfc_conv_expr_reference (&parmse, e);
 	      else if (e->expr_type == EXPR_FUNCTION
 		       && e->symtree->n.sym->result
 		       && e->symtree->n.sym->result != e->symtree->n.sym
@@ -6078,22 +6078,36 @@ gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym,
 		    }
 		  else
 		    {
-		      bool add_clobber;
-		      add_clobber = fsym && fsym->attr.intent == INTENT_OUT
-			&& !fsym->attr.allocatable && !fsym->attr.pointer
-			&& e->symtree && e->symtree->n.sym
-			&& !e->symtree->n.sym->attr.dimension
-			&& !e->symtree->n.sym->attr.pointer
-			&& !e->symtree->n.sym->attr.allocatable
-			/* See PR 41453.  */
-			&& !e->symtree->n.sym->attr.dummy
-			/* FIXME - PR 87395 and PR 41453  */
-			&& e->symtree->n.sym->attr.save == SAVE_NONE
-			&& !e->symtree->n.sym->attr.associate_var
-			&& e->ts.type != BT_CHARACTER && e->ts.type != BT_DERIVED
-			&& e->ts.type != BT_CLASS && !sym->attr.elemental;
-
-		      gfc_conv_expr_reference (&parmse, e, add_clobber);
+		      gfc_conv_expr_reference (&parmse, e);
+
+		      if (fsym
+			  && fsym->attr.intent == INTENT_OUT
+			  && !fsym->attr.allocatable
+			  && !fsym->attr.pointer
+			  && e->expr_type == EXPR_VARIABLE
+			  && e->ref == NULL
+			  && e->symtree
+			  && e->symtree->n.sym
+			  && !e->symtree->n.sym->attr.dimension
+			  && !e->symtree->n.sym->attr.pointer
+			  && !e->symtree->n.sym->attr.allocatable
+			  /* See PR 41453.  */
+			  && !e->symtree->n.sym->attr.dummy
+			  /* FIXME - PR 87395 and PR 41453  */
+			  && e->symtree->n.sym->attr.save == SAVE_NONE
+			  && !e->symtree->n.sym->attr.associate_var
+			  && e->ts.type != BT_CHARACTER
+			  && e->ts.type != BT_DERIVED
+			  && e->ts.type != BT_CLASS
+			  && !sym->attr.elemental)
+			{
+			  tree var;
+			  /* FIXME: This fails if var is passed by reference, see PR
+			     41453.  */
+			  var = e->symtree->n.sym->backend_decl;
+			  tree clobber = build_clobber (TREE_TYPE (var));
+			  gfc_add_modify (&se->pre, var, clobber);
+			}
 		    }
 		  /* Catch base objects that are not variables.  */
 		  if (e->ts.type == BT_CLASS
@@ -8954,7 +8968,7 @@ gfc_conv_expr_type (gfc_se * se, gfc_expr * expr, tree type)
    values only.  */
 
 void
-gfc_conv_expr_reference (gfc_se * se, gfc_expr * expr, bool add_clobber)
+gfc_conv_expr_reference (gfc_se * se, gfc_expr * expr)
 {
   gfc_ss *ss;
   tree var;
@@ -8994,16 +9008,6 @@ gfc_conv_expr_reference (gfc_se * se, gfc_expr * expr, bool add_clobber)
 	  gfc_add_block_to_block (&se->pre, &se->post);
 	  se->expr = var;
 	}
-      else if (add_clobber && expr->ref == NULL)
-	{
-	  tree clobber;
-	  tree var;
-	  /* FIXME: This fails if var is passed by reference, see PR
-	     41453.  */
-	  var = expr->symtree->n.sym->backend_decl;
-	  clobber = build_clobber (TREE_TYPE (var));
-	  gfc_add_modify (&se->pre, var, clobber);
-	}
       return;
     }
 
diff --git a/gcc/fortran/trans.h b/gcc/fortran/trans.h
index 408d9ad1cc9..11a0941aa60 100644
--- a/gcc/fortran/trans.h
+++ b/gcc/fortran/trans.h
@@ -499,8 +499,7 @@ tree gfc_build_compare_string (tree, tree, tree, tree, int, enum tree_code);
 void gfc_conv_expr (gfc_se * se, gfc_expr * expr);
 void gfc_conv_expr_val (gfc_se * se, gfc_expr * expr);
 void gfc_conv_expr_lhs (gfc_se * se, gfc_expr * expr);
-void gfc_conv_expr_reference (gfc_se * se, gfc_expr * expr,
-			      bool add_clobber = false);
+void gfc_conv_expr_reference (gfc_se * se, gfc_expr * expr);
 void gfc_conv_expr_type (gfc_se * se, gfc_expr *, tree);
 
 

commit 9d18ff4606dabadc5bda11e6cdadc4383ec2f4e5
Author: Mikael Morin <mikael@gcc.gnu.org>
Date:   Mon Aug 29 11:19:29 2022 +0200

    fortran: Fix invalid function decl clobber ICE [PR105012]
    
    The fortran frontend, as result symbol for a function without
    declared result symbol, uses the function symbol itself.  This caused
    an invalid clobber of a function decl to be emitted, leading to an
    ICE, whereas the intended behaviour was to clobber the function result
    variable.  This change fixes the problem by getting the decl from the
    just-retrieved variable reference after the call to
    gfc_conv_expr_reference, instead of copying it from the frontend symbol.
    
            PR fortran/105012
    
    gcc/fortran/ChangeLog:
    
            * trans-expr.c (gfc_conv_procedure_call): Retrieve variable
            from the just calculated variable reference.
    
    gcc/testsuite/ChangeLog:
    
            * gfortran.dg/intent_out_15.f90: New test.
    
    (cherry picked from commit edaf1e005c90b311c39b46d85cea17befbece112)

diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c
index 2592c280a3c..6823379e41a 100644
--- a/gcc/fortran/trans-expr.c
+++ b/gcc/fortran/trans-expr.c
@@ -6104,7 +6104,8 @@ gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym,
 			  tree var;
 			  /* FIXME: This fails if var is passed by reference, see PR
 			     41453.  */
-			  var = e->symtree->n.sym->backend_decl;
+			  var = build_fold_indirect_ref_loc (input_location,
+							     parmse.expr);
 			  tree clobber = build_clobber (TREE_TYPE (var));
 			  gfc_add_modify (&se->pre, var, clobber);
 			}
diff --git a/gcc/testsuite/gfortran.dg/intent_out_15.f90 b/gcc/testsuite/gfortran.dg/intent_out_15.f90
new file mode 100644
index 00000000000..64334e6f038
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/intent_out_15.f90
@@ -0,0 +1,27 @@
+! { dg-do compile }
+! { dg-additional-options "-fdump-tree-original" }
+!
+! PR fortran/105012
+! The following case was triggering an ICE because of a clobber
+! on the DERFC function decl instead of its result.
+
+module error_function
+integer, parameter :: r8 = selected_real_kind(12) ! 8 byte real
+contains
+SUBROUTINE CALERF_r8(ARG, RESULT, JINT)
+   integer, parameter :: rk = r8
+   real(rk), intent(in)  :: arg
+   real(rk), intent(out) :: result
+   IF (Y .LE. THRESH) THEN
+   END IF
+end SUBROUTINE CALERF_r8
+FUNCTION DERFC(X)
+   integer, parameter :: rk = r8 ! 8 byte real
+   real(rk), intent(in) :: X
+   real(rk) :: DERFC
+   CALL CALERF_r8(X, DERFC, JINT)
+END FUNCTION DERFC
+end module error_function
+
+! { dg-final { scan-tree-dump-times "CLOBBER" 1 "original" } }
+! { dg-final { scan-tree-dump "__result_derfc = {CLOBBER};" "original" } }

commit b394ebd90e1f9c125216c70beedf97d6d8739773
Author: Mikael Morin <mikael@gcc.gnu.org>
Date:   Sat Sep 3 11:58:47 2022 +0200

    fortran: Move clobbers after evaluation of all arguments [PR106817]
    
    For actual arguments whose dummy is INTENT(OUT), we used to generate
    clobbers on them at the same time we generated the argument reference
    for the function call.  This was wrong if for an argument coming
    later, the value expression was depending on the value of the just-
    clobbered argument, and we passed an undefined value in that case.
    
    With this change, clobbers are collected separatedly and appended
    to the procedure call preliminary code after all the arguments have been
    evaluated.
    
            PR fortran/106817
    
    gcc/fortran/ChangeLog:
    
            * trans-expr.c (gfc_conv_procedure_call): Collect all clobbers
            to their own separate block.  Append the block of clobbers to
            the procedure preliminary block after the argument evaluation
            codes for all the arguments.
    
    gcc/testsuite/ChangeLog:
    
            * gfortran.dg/intent_optimize_4.f90: New test.
    
    (cherry picked from commit 29919bf3b6449bafd02e795abbb1966e3990c1fc)

diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c
index 6823379e41a..602df7debe6 100644
--- a/gcc/fortran/trans-expr.c
+++ b/gcc/fortran/trans-expr.c
@@ -5592,7 +5592,6 @@ gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym,
   gfc_charlen cl;
   gfc_expr *e;
   gfc_symbol *fsym;
-  stmtblock_t post;
   enum {MISSING = 0, ELEMENTAL, SCALAR, SCALAR_POINTER, ARRAY};
   gfc_component *comp = NULL;
   int arglen;
@@ -5636,7 +5635,9 @@ gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym,
   else
     info = NULL;
 
+  stmtblock_t post, clobbers;
   gfc_init_block (&post);
+  gfc_init_block (&clobbers);
   gfc_init_interface_mapping (&mapping);
   if (!comp)
     {
@@ -6107,7 +6108,7 @@ gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym,
 			  var = build_fold_indirect_ref_loc (input_location,
 							     parmse.expr);
 			  tree clobber = build_clobber (TREE_TYPE (var));
-			  gfc_add_modify (&se->pre, var, clobber);
+			  gfc_add_modify (&clobbers, var, clobber);
 			}
 		    }
 		  /* Catch base objects that are not variables.  */
@@ -6876,6 +6877,7 @@ gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym,
 
       vec_safe_push (arglist, parmse.expr);
     }
+  gfc_add_block_to_block (&se->pre, &clobbers);
   gfc_finish_interface_mapping (&mapping, &se->pre, &se->post);
 
   if (comp)
diff --git a/gcc/testsuite/gfortran.dg/intent_optimize_4.f90 b/gcc/testsuite/gfortran.dg/intent_optimize_4.f90
new file mode 100644
index 00000000000..effbaa12a2d
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/intent_optimize_4.f90
@@ -0,0 +1,43 @@
+! { dg-do run }
+! { dg-additional-options "-fdump-tree-original" }
+! { dg-final { scan-tree-dump-times "CLOBBER" 2 "original" } }
+!
+! PR fortran/106817
+! Check that for an actual argument whose dummy is INTENT(OUT),
+! the clobber that is emitted in the caller before a procedure call
+! happens after any expression depending on the argument value has been
+! evaluated.
+! 
+
+module m
+  implicit none
+contains
+  subroutine copy1(out, in)
+    integer, intent(in) :: in
+    integer, intent(out) :: out
+    out = in
+  end subroutine copy1
+  subroutine copy2(in, out)
+    integer, intent(in) :: in
+    integer, intent(out) :: out
+    out = in
+  end subroutine copy2
+end module m
+
+program p
+  use m
+  implicit none
+  integer :: a, b
+
+  ! Clobbering of a should happen after a+1 has been evaluated.
+  a = 3
+  call copy1(a, a+1)
+  if (a /= 4) stop 1
+
+  ! Clobbering order does not depend on the order of arguments.
+  ! It should also come last with reversed arguments.
+  b = 12
+  call copy2(b+1, b)
+  if (b /= 13) stop 2
+
+end program p

commit 2437a3a23e738a4099c93909db2ce5cdc3884e4e
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Tue Oct 11 00:18:04 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 836fdacb295..ee52440e2ce 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20221010
+20221011
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index bd5eecb1579..491c0c2cbd5 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,34 @@
+2022-10-10  Mikael Morin  <mikael@gcc.gnu.org>
+
+	Backported from master:
+	2022-09-25  Mikael Morin  <mikael@gcc.gnu.org>
+
+	PR fortran/106817
+	* trans-expr.c (gfc_conv_procedure_call): Collect all clobbers
+	to their own separate block.  Append the block of clobbers to
+	the procedure preliminary block after the argument evaluation
+	codes for all the arguments.
+
+2022-10-10  Mikael Morin  <mikael@gcc.gnu.org>
+
+	Backported from master:
+	2022-09-25  Mikael Morin  <mikael@gcc.gnu.org>
+
+	PR fortran/105012
+	* trans-expr.c (gfc_conv_procedure_call): Retrieve variable
+	from the just calculated variable reference.
+
+2022-10-10  Mikael Morin  <mikael@gcc.gnu.org>
+
+	Backported from master:
+	2022-09-25  Mikael Morin  <mikael@gcc.gnu.org>
+
+	* trans.h (gfc_conv_expr_reference): Remove add_clobber
+	argument.
+	* trans-expr.c (gfc_conv_expr_reference): Ditto. Inline code
+	depending on add_clobber and conditions controlling it ...
+	(gfc_conv_procedure_call): ... to here.
+
 2022-10-08  José Rui Faustino de Sousa  <jrfsousa@gmail.com>
 
 	Backported from master:
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index dc025527891..ca6d7a08d3e 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,19 @@
+2022-10-10  Mikael Morin  <mikael@gcc.gnu.org>
+
+	Backported from master:
+	2022-09-25  Mikael Morin  <mikael@gcc.gnu.org>
+
+	PR fortran/106817
+	* gfortran.dg/intent_optimize_4.f90: New test.
+
+2022-10-10  Mikael Morin  <mikael@gcc.gnu.org>
+
+	Backported from master:
+	2022-09-25  Mikael Morin  <mikael@gcc.gnu.org>
+
+	PR fortran/105012
+	* gfortran.dg/intent_out_15.f90: New test.
+
 2022-10-08  José Rui Faustino de Sousa  <jrfsousa@gmail.com>
 
 	Backported from master:

commit bb298a979aca875c44476c6385934aa569859334
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Wed Oct 12 00:18:30 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index ee52440e2ce..6f50c16be9c 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20221011
+20221012

commit 21f6023b3b4acc620914e399a1285ca6df65e2d3
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Thu Oct 13 00:20:35 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 6f50c16be9c..0c497e6052e 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20221012
+20221013

commit c672a7604f023bb25004bcdafbc3ea1579920965
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Fri Oct 14 00:18:34 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 0c497e6052e..66947c0b32d 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20221013
+20221014

commit d0ef37c35b7ff7324b4567652380f32079d46088
Author: Eric Botcazou <ebotcazou@adacore.com>
Date:   Fri Oct 14 11:52:04 2022 +0200

    Fix PR target/107248
    
    This is the infamous PR rtl-optimization/38644 rearing its ugly head for
    leaf functions on SPARC more than a decade later...  Richard E.'s generic
    solution has never been implemented so let's do as other RISC back-ends did.
    
    gcc/
            PR target/107248
            * config/sparc/sparc.c (sparc_expand_prologue): Emit a frame
            blockage for leaf functions.
            (sparc_flat_expand_prologue): Emit frame instead of full blockage.
            (sparc_expand_epilogue): Emit a frame blockage for leaf functions.
            (sparc_flat_expand_epilogue): Emit frame instead of full blockage.

diff --git a/gcc/config/sparc/sparc.c b/gcc/config/sparc/sparc.c
index 7cfa9f80676..d643c3e618d 100644
--- a/gcc/config/sparc/sparc.c
+++ b/gcc/config/sparc/sparc.c
@@ -6118,6 +6118,9 @@ sparc_expand_prologue (void)
 	}
 
       RTX_FRAME_RELATED_P (insn) = 1;
+
+      /* Ensure no memory access is done before the frame is established.  */
+      emit_insn (gen_frame_blockage ());
     }
   else
     {
@@ -6132,13 +6135,7 @@ sparc_expand_prologue (void)
 	  /* %sp is not the CFA register anymore.  */
 	  emit_insn (gen_stack_pointer_inc (GEN_INT (4096 - size)));
 
-	  /* Make sure no %fp-based store is issued until after the frame is
-	     established.  The offset between the frame pointer and the stack
-	     pointer is calculated relative to the value of the stack pointer
-	     at the end of the function prologue, and moving instructions that
-	     access the stack via the frame pointer between the instructions
-	     that decrement the stack pointer could result in accessing the
-	     register window save area, which is volatile.  */
+	  /* Likewise.  */
 	  emit_insn (gen_frame_blockage ());
 	}
       else
@@ -6234,8 +6231,8 @@ sparc_flat_expand_prologue (void)
 	}
       RTX_FRAME_RELATED_P (insn) = 1;
 
-      /* Ensure nothing is scheduled until after the frame is established.  */
-      emit_insn (gen_blockage ());
+      /* Ensure no memory access is done before the frame is established.  */
+      emit_insn (gen_frame_blockage ());
 
       if (frame_pointer_needed)
 	{
@@ -6322,6 +6319,9 @@ sparc_expand_epilogue (bool for_eh)
     ; /* do nothing.  */
   else if (sparc_leaf_function_p)
     {
+      /* Ensure no memory access is done after the frame is destroyed.  */
+      emit_insn (gen_frame_blockage ());
+
       if (size <= 4096)
 	emit_insn (gen_stack_pointer_inc (GEN_INT (size)));
       else if (size <= 8192)
@@ -6372,15 +6372,15 @@ sparc_flat_expand_epilogue (bool for_eh)
     ; /* do nothing.  */
   else if (frame_pointer_needed)
     {
-      /* Make sure the frame is destroyed after everything else is done.  */
-      emit_insn (gen_blockage ());
+      /* Ensure no memory access is done after the frame is destroyed.  */
+      emit_insn (gen_frame_blockage ());
 
       emit_move_insn (stack_pointer_rtx, gen_rtx_REG (Pmode, 1));
     }
   else
     {
       /* Likewise.  */
-      emit_insn (gen_blockage ());
+      emit_insn (gen_frame_blockage ());
 
       if (size <= 4096)
 	emit_insn (gen_stack_pointer_inc (GEN_INT (size)));

commit 983d87530d8efbae6b5f4973c52edd1071d26add
Author: Richard Biener <rguenther@suse.de>
Date:   Tue Jun 28 13:57:29 2022 +0200

    tree-optimization/106112 - fix CSE from wider operation
    
    The following fixes a mistake in looking up an extended operand
    in the CSE of a truncated operation.
    
    2022-06-28  Richard Biener  <rguenther@suse.de>
    
            PR tree-optimization/106112
            * tree-ssa-sccvn.c (valueized_wider_op): Properly extend
            a constant operand according to its type.
    
            * gcc.dg/torture/pr106112.c: New testcase.
    
    (cherry picked from commit 2dbb45d6dc0d20dc159b3d8e27ebb6825074827a)

diff --git a/gcc/testsuite/gcc.dg/torture/pr106112.c b/gcc/testsuite/gcc.dg/torture/pr106112.c
new file mode 100644
index 00000000000..bd7f63c0935
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr106112.c
@@ -0,0 +1,16 @@
+/* { dg-do run } */
+
+__INT32_TYPE__ a = 5, b, c, d;
+__UINT64_TYPE__ e = 20862985922;
+int main()
+{
+  __UINT32_TYPE__ f = 4294967292;
+  e = e | f;
+  c = -1 % ((~f ^ 4294967292) - (e - d));
+  b = ~-~e % ~-d;
+  if (b)
+    a = 0;
+  if (a < 1)
+    __builtin_abort();
+  return 0;
+}
diff --git a/gcc/tree-ssa-sccvn.c b/gcc/tree-ssa-sccvn.c
index e0cde2359cd..6df0617254c 100644
--- a/gcc/tree-ssa-sccvn.c
+++ b/gcc/tree-ssa-sccvn.c
@@ -4758,7 +4758,7 @@ valueized_wider_op (tree wide_type, tree op, bool allow_truncate)
 
   /* For constants simply extend it.  */
   if (TREE_CODE (op) == INTEGER_CST)
-    return wide_int_to_tree (wide_type, wi::to_wide (op));
+    return wide_int_to_tree (wide_type, wi::to_widest (op));
 
   return NULL_TREE;
 }

commit a8abbf6d15fefe5ac27aa7c21201883b66cc9b01
Author: Richard Biener <rguenther@suse.de>
Date:   Thu Jun 30 10:33:40 2022 +0200

    tree-optimization/106131 - wrong code with FRE rewriting
    
    The following makes sure to not use the original TBAA type for
    looking up a value across an aggregate copy when we had to offset
    the read.
    
    2022-06-30  Richard Biener  <rguenther@suse.de>
    
            PR tree-optimization/106131
            * tree-ssa-sccvn.c (vn_reference_lookup_3): Force alias-set
            zero when offsetting the read looking through an aggregate
            copy.
    
            * g++.dg/torture/pr106131.C: New testcase.
    
    (cherry picked from commit 9701432ff79926a5dd3303be3417e0bd0c24140b)

diff --git a/gcc/testsuite/g++.dg/torture/pr106131.C b/gcc/testsuite/g++.dg/torture/pr106131.C
new file mode 100644
index 00000000000..e110f4a8fe6
--- /dev/null
+++ b/gcc/testsuite/g++.dg/torture/pr106131.C
@@ -0,0 +1,34 @@
+// { dg-do run { target c++11 } }
+
+struct Pair {
+    int a, b;
+    Pair(const Pair &) = default;
+    Pair(int _a, int _b) : a(_a), b(_b) {}
+    Pair &operator=(const Pair &z) {
+	a = z.a;
+	b = z.b;
+	return *this;
+    }
+};
+
+const int &max(const int &a, const int &b)
+{
+  return a < b ? b : a;
+}
+
+int foo(Pair x, Pair y)
+{
+  return max(x.b, y.b);
+}
+
+int main()
+{
+  auto f = new Pair[3] {{0, -11}, {0, -8}, {0, 2}};
+  for (int i = 0; i < 1; i++) {
+      f[i] = f[0];
+      if(i == 0)
+	f[i] = f[2];
+      if (foo(f[i], f[1]) != 2)
+	__builtin_abort();
+  }
+}
diff --git a/gcc/tree-ssa-sccvn.c b/gcc/tree-ssa-sccvn.c
index 6df0617254c..18263bd8c9a 100644
--- a/gcc/tree-ssa-sccvn.c
+++ b/gcc/tree-ssa-sccvn.c
@@ -3136,12 +3136,12 @@ vn_reference_lookup_3 (ao_ref *ref, tree vuse, void *data_,
       poly_int64 extra_off = 0;
       if (j == 0 && i >= 0
 	  && lhs_ops[0].opcode == MEM_REF
-	  && maybe_ne (lhs_ops[0].off, -1))
+	  && known_ne (lhs_ops[0].off, -1))
 	{
 	  if (known_eq (lhs_ops[0].off, vr->operands[i].off))
 	    i--, j--;
 	  else if (vr->operands[i].opcode == MEM_REF
-		   && maybe_ne (vr->operands[i].off, -1))
+		   && known_ne (vr->operands[i].off, -1))
 	    {
 	      extra_off = vr->operands[i].off - lhs_ops[0].off;
 	      i--, j--;
@@ -3168,6 +3168,7 @@ vn_reference_lookup_3 (ao_ref *ref, tree vuse, void *data_,
       copy_reference_ops_from_ref (rhs1, &rhs);
 
       /* Apply an extra offset to the inner MEM_REF of the RHS.  */
+      bool force_no_tbaa = false;
       if (maybe_ne (extra_off, 0))
 	{
 	  if (rhs.length () < 2)
@@ -3180,6 +3181,10 @@ vn_reference_lookup_3 (ao_ref *ref, tree vuse, void *data_,
 	  rhs[ix].op0 = int_const_binop (PLUS_EXPR, rhs[ix].op0,
 					 build_int_cst (TREE_TYPE (rhs[ix].op0),
 							extra_off));
+	  /* When we have offsetted the RHS, reading only parts of it,
+	     we can no longer use the original TBAA type, force alias-set
+	     zero.  */
+	  force_no_tbaa = true;
 	}
 
       /* Save the operands since we need to use the original ones for
@@ -3232,8 +3237,11 @@ vn_reference_lookup_3 (ao_ref *ref, tree vuse, void *data_,
       /* Adjust *ref from the new operands.  */
       ao_ref rhs1_ref;
       ao_ref_init (&rhs1_ref, rhs1);
-      if (!ao_ref_init_from_vn_reference (&r, ao_ref_alias_set (&rhs1_ref),
-					  ao_ref_base_alias_set (&rhs1_ref),
+      if (!ao_ref_init_from_vn_reference (&r,
+					  force_no_tbaa ? 0
+					  : ao_ref_alias_set (&rhs1_ref),
+					  force_no_tbaa ? 0
+					  : ao_ref_base_alias_set (&rhs1_ref),
 					  vr->type, vr->operands))
 	return (void *)-1;
       /* This can happen with bitfields.  */

commit cf404eb3b55a3711134bddee98d6d8d881be8a69
Author: Richard Biener <rguenther@suse.de>
Date:   Tue Jul 19 09:57:22 2022 +0200

    middle-end/106331 - fix mem attributes for string op arguments
    
    get_memory_rtx tries hard to come up with a MEM_EXPR to record
    in the memory attributes but in the last fallback fails to properly
    account for an unknown offset and thus, as visible in this testcase,
    incorrect alignment computed from set_mem_attributes.  The following
    rectifies both parts.
    
            PR middle-end/106331
            * builtins.c (get_memory_rtx): Compute alignment from
            the original address and set MEM_OFFSET to unknown when
            we create a MEM_EXPR from the base object of the address.
    
            * gfortran.dg/pr106331.f90: New testcase.
    
    (cherry picked from commit e4ff11a8f2e80adb8ada69bf35ee6a1ab18a9c85)

diff --git a/gcc/builtins.c b/gcc/builtins.c
index d89ce37c496..978909815de 100644
--- a/gcc/builtins.c
+++ b/gcc/builtins.c
@@ -1471,7 +1471,7 @@ expand_builtin_prefetch (tree exp)
 static rtx
 get_memory_rtx (tree exp, tree len)
 {
-  tree orig_exp = exp;
+  tree orig_exp = exp, base;
   rtx addr, mem;
 
   /* When EXP is not resolved SAVE_EXPR, MEM_ATTRS can be still derived
@@ -1502,10 +1502,11 @@ get_memory_rtx (tree exp, tree len)
   if (is_gimple_mem_ref_addr (TREE_OPERAND (exp, 0)))
     set_mem_attributes (mem, exp, 0);
   else if (TREE_CODE (TREE_OPERAND (exp, 0)) == ADDR_EXPR
-	   && (exp = get_base_address (TREE_OPERAND (TREE_OPERAND (exp, 0),
-						     0))))
+	   && (base = get_base_address (TREE_OPERAND (TREE_OPERAND (exp, 0),
+						      0))))
     {
-      exp = build_fold_addr_expr (exp);
+      unsigned int align = get_pointer_alignment (TREE_OPERAND (exp, 0));
+      exp = build_fold_addr_expr (base);
       exp = fold_build2 (MEM_REF,
 			 build_array_type (char_type_node,
 					   build_range_type (sizetype,
@@ -1513,6 +1514,10 @@ get_memory_rtx (tree exp, tree len)
 							     NULL)),
 			 exp, build_int_cst (ptr_type_node, 0));
       set_mem_attributes (mem, exp, 0);
+      /* Since we stripped parts make sure the offset is unknown and the
+	 alignment is computed from the original address.  */
+      clear_mem_offset (mem);
+      set_mem_align (mem, align);
     }
   set_mem_alias_set (mem, 0);
   return mem;
diff --git a/gcc/testsuite/gfortran.dg/pr106331.f90 b/gcc/testsuite/gfortran.dg/pr106331.f90
new file mode 100644
index 00000000000..3873863be48
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr106331.f90
@@ -0,0 +1,7 @@
+! { dg-do run }
+! { dg-options "-Og" }
+
+PROGRAM main
+  CHARACTER(LEN=24) :: a(2)
+  a = ''
+END PROGRAM

commit 29ad829c93d530e75dee88d2550350c14fcaf8f6
Author: Richard Biener <rguenther@suse.de>
Date:   Wed Aug 10 15:45:22 2022 +0200

    tree-optimization/106513 - fix mistake in bswap symbolic number shifts
    
    This fixes a mistake in typing a local variable in the symbolic
    shift routine.
    
            PR tree-optimization/106513
            * gimple-ssa-store-merging.c (do_shift_rotate): Use uint64_t
            for head_marker.
    
            * gcc.dg/torture/pr106513.c: New testcase.
    
    (cherry picked from commit f675afa4eeac9910a2c085a95aa04d6d9f2fd8d6)

diff --git a/gcc/gimple-ssa-store-merging.c b/gcc/gimple-ssa-store-merging.c
index 96f46b706be..3eeb73ffc9e 100644
--- a/gcc/gimple-ssa-store-merging.c
+++ b/gcc/gimple-ssa-store-merging.c
@@ -263,7 +263,7 @@ do_shift_rotate (enum tree_code code,
 		 int count)
 {
   int i, size = TYPE_PRECISION (n->type) / BITS_PER_UNIT;
-  unsigned head_marker;
+  uint64_t head_marker;
 
   if (count < 0
       || count >= TYPE_PRECISION (n->type)
diff --git a/gcc/testsuite/gcc.dg/torture/pr106513.c b/gcc/testsuite/gcc.dg/torture/pr106513.c
new file mode 100644
index 00000000000..aa4f4d513d7
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr106513.c
@@ -0,0 +1,26 @@
+/* { dg-do run } */
+
+typedef __INT64_TYPE__ int64_t;
+
+__attribute__((noinline)) int64_t
+swap64 (int64_t n)
+{
+  return (((n & (((int64_t) 0xff) )) << 56) |
+          ((n & (((int64_t) 0xff) << 8)) << 40) |
+          ((n & (((int64_t) 0xff) << 16)) << 24) |
+          ((n & (((int64_t) 0xff) << 24)) << 8) |
+          ((n & (((int64_t) 0xff) << 32)) >> 8) |
+          ((n & (((int64_t) 0xff) << 40)) >> 24) |
+          ((n & (((int64_t) 0xff) << 48)) >> 40) |
+          ((n & ((int64_t)(0xffull << 56))) >> 56));
+}
+
+int main (void)
+{
+  volatile int64_t n = 0x8000000000000000ll;
+
+  if (swap64(n) != 0xffffffffffffff80ll)
+    __builtin_abort ();
+
+  return 0;
+}

commit d2fa5521282cc7b5510e1e2c431a56d12693d74f
Author: Richard Biener <rguenther@suse.de>
Date:   Mon Aug 8 09:07:23 2022 +0200

    lto/106540 - fix LTO tree input wrt dwarf2out_register_external_die
    
    I've revisited the earlier two workarounds for dwarf2out_register_external_die
    getting duplicate entries.  It turns out that r11-525-g03d90a20a1afcb
    added dref_queue pruning to lto_input_tree but decl reading uses that
    to stream in DECL_INITIAL even when in the middle of SCC streaming.
    When that SCC then gets thrown away we can end up with debug nodes
    registered which isn't supposed to happen.  The following adjusts
    the DECL_INITIAL streaming to go the in-SCC way, using lto_input_tree_1,
    since no SCCs are expected at this point, just refs.
    
            PR lto/106540
            PR lto/106334
            * lto-streamer-in.c (lto_read_tree_1): Use lto_input_tree_1
            to input DECL_INITIAL, avoiding to commit drefs.
    
    (cherry picked from commit 4769ac6c5dfde2810a0266fe388211edc644e623)

diff --git a/gcc/lto-streamer-in.c b/gcc/lto-streamer-in.c
index d5f581439fb..b0f8407a1d7 100644
--- a/gcc/lto-streamer-in.c
+++ b/gcc/lto-streamer-in.c
@@ -1689,11 +1689,14 @@ lto_read_tree_1 (class lto_input_block *ib, class data_in *data_in, tree expr)
   /* Read all the pointer fields in EXPR.  */
   streamer_read_tree_body (ib, data_in, expr);
 
-  /* Read any LTO-specific data not read by the tree streamer.  */
+  /* Read any LTO-specific data not read by the tree streamer.  Do not use
+     stream_read_tree here since that flushes the dref_queue in mids of
+     SCC reading.  */
   if (DECL_P (expr)
       && TREE_CODE (expr) != FUNCTION_DECL
       && TREE_CODE (expr) != TRANSLATION_UNIT_DECL)
-    DECL_INITIAL (expr) = stream_read_tree (ib, data_in);
+    DECL_INITIAL (expr)
+      = lto_input_tree_1 (ib, data_in, streamer_read_record_start (ib), 0);
 
   /* Stream references to early generated DIEs.  Keep in sync with the
      trees handled in dwarf2out_register_external_die.  */

commit f4f21a4a536d95489844f58381e8c06f153474ad
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sat Oct 15 00:19:24 2022 +0000

    Daily bump.

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 87466f49785..289fc05eeec 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,60 @@
+2022-10-14  Richard Biener  <rguenther@suse.de>
+
+	Backported from master:
+	2022-08-10  Richard Biener  <rguenther@suse.de>
+
+	PR lto/106540
+	PR lto/106334
+	* lto-streamer-in.c (lto_read_tree_1): Use lto_input_tree_1
+	to input DECL_INITIAL, avoiding to commit drefs.
+
+2022-10-14  Richard Biener  <rguenther@suse.de>
+
+	Backported from master:
+	2022-08-10  Richard Biener  <rguenther@suse.de>
+
+	PR tree-optimization/106513
+	* gimple-ssa-store-merging.c (do_shift_rotate): Use uint64_t
+	for head_marker.
+
+2022-10-14  Richard Biener  <rguenther@suse.de>
+
+	Backported from master:
+	2022-07-19  Richard Biener  <rguenther@suse.de>
+
+	PR middle-end/106331
+	* builtins.c (get_memory_rtx): Compute alignment from
+	the original address and set MEM_OFFSET to unknown when
+	we create a MEM_EXPR from the base object of the address.
+
+2022-10-14  Richard Biener  <rguenther@suse.de>
+
+	Backported from master:
+	2022-07-01  Richard Biener  <rguenther@suse.de>
+
+	PR tree-optimization/106131
+	* tree-ssa-sccvn.c (vn_reference_lookup_3): Force alias-set
+	zero when offsetting the read looking through an aggregate
+	copy.
+
+2022-10-14  Richard Biener  <rguenther@suse.de>
+
+	Backported from master:
+	2022-06-29  Richard Biener  <rguenther@suse.de>
+
+	PR tree-optimization/106112
+	* tree-ssa-sccvn.c (valueized_wider_op): Properly extend
+	a constant operand according to its type.
+
+2022-10-14  Eric Botcazou  <ebotcazou@adacore.com>
+
+	PR target/107248
+	* config/sparc/sparc.c (sparc_expand_prologue): Emit a frame
+	blockage for leaf functions.
+	(sparc_flat_expand_prologue): Emit frame instead of full blockage.
+	(sparc_expand_epilogue): Emit a frame blockage for leaf functions.
+	(sparc_flat_expand_epilogue): Emit frame instead of full blockage.
+
 2022-10-03  Sergei Trofimovich  <siarheit@google.com>
 
 	Backported from master:
diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 66947c0b32d..88e8f3fec27 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20221014
+20221015
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index ca6d7a08d3e..fe2da634ac5 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,35 @@
+2022-10-14  Richard Biener  <rguenther@suse.de>
+
+	Backported from master:
+	2022-08-10  Richard Biener  <rguenther@suse.de>
+
+	PR tree-optimization/106513
+	* gcc.dg/torture/pr106513.c: New testcase.
+
+2022-10-14  Richard Biener  <rguenther@suse.de>
+
+	Backported from master:
+	2022-07-19  Richard Biener  <rguenther@suse.de>
+
+	PR middle-end/106331
+	* gfortran.dg/pr106331.f90: New testcase.
+
+2022-10-14  Richard Biener  <rguenther@suse.de>
+
+	Backported from master:
+	2022-07-01  Richard Biener  <rguenther@suse.de>
+
+	PR tree-optimization/106131
+	* g++.dg/torture/pr106131.C: New testcase.
+
+2022-10-14  Richard Biener  <rguenther@suse.de>
+
+	Backported from master:
+	2022-06-29  Richard Biener  <rguenther@suse.de>
+
+	PR tree-optimization/106112
+	* gcc.dg/torture/pr106112.c: New testcase.
+
 2022-10-10  Mikael Morin  <mikael@gcc.gnu.org>
 
 	Backported from master:

commit e535fa00a0354a36943cdc087ef1afb62a2d8309
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sun Oct 16 00:17:48 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 88e8f3fec27..f791a3c954e 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20221015
+20221016

commit 6e9812a08a22ec3b03490c4ba827ec4eb0d7123d
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Mon Oct 17 00:18:18 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index f791a3c954e..856b00bc5d5 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20221016
+20221017

commit 7af52b39059b4496b17337d0efc7575f17febb26
Author: Pat Haugen <pthaugen@linux.ibm.com>
Date:   Mon Oct 17 14:53:11 2022 -0500

        Fix register count when not splitting Complex IEEE 128-bit args.
    
        For ABI_V4, we do not split complex args. This created a problem because
        even though an arg would be passed in two VSX regs, we were only advancing the
        function arg counter by one VSX register. Fixed with this patch.
    
        (backported commit 2ee68beee709e48fce85b8892ff9985acc6a91a8)
    
    gcc/
            PR target/99685
            * config/rs6000/rs6000-call.c (rs6000_function_arg_advance_1): Bump
            register count when not splitting IEEE 128-bit Complex.

diff --git a/gcc/config/rs6000/rs6000-call.c b/gcc/config/rs6000/rs6000-call.c
index c910ee5c71a..4e55cbaab55 100644
--- a/gcc/config/rs6000/rs6000-call.c
+++ b/gcc/config/rs6000/rs6000-call.c
@@ -6534,6 +6534,12 @@ rs6000_function_arg_advance_1 (CUMULATIVE_ARGS *cum, machine_mode mode,
 	{
 	  cum->vregno += n_elts;
 
+	  /* If we are not splitting Complex IEEE128 args then account for the
+	     fact that they are passed in 2 VSX regs. */
+	  if (!targetm.calls.split_complex_arg && type
+	      && TREE_CODE (type) == COMPLEX_TYPE && elt_mode == KCmode)
+	    cum->vregno++;
+
 	  if (!TARGET_ALTIVEC)
 	    error ("cannot pass argument in vector register because"
 		   " altivec instructions are disabled, use %qs"

commit 24529d16ba972f71bb96deb26217df8d987c495e
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Tue Oct 18 00:19:02 2022 +0000

    Daily bump.

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 289fc05eeec..41998460e75 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2022-10-17  Pat Haugen  <pthaugen@linux.ibm.com>
+
+	PR target/99685
+	* config/rs6000/rs6000-call.c (rs6000_function_arg_advance_1): Bump
+	register count when not splitting IEEE 128-bit Complex.
+
 2022-10-14  Richard Biener  <rguenther@suse.de>
 
 	Backported from master:
diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 856b00bc5d5..e1b70eb75bf 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20221017
+20221018

commit bcfec255ce3176b71b42d2537088db47bf63484f
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Wed Oct 19 00:20:43 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index e1b70eb75bf..268d1b47e9d 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20221018
+20221019

commit b7289ec1f4b9cf089792e9bed966072dbf19d72e
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Thu Oct 20 00:19:30 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 268d1b47e9d..8b08eddd863 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20221019
+20221020

commit fa38c8b46eec550aee7e561c5b4b7c01a4ef42e3
Author: Kewen Lin <linkw@linux.ibm.com>
Date:   Mon Sep 26 00:33:18 2022 -0500

    rs6000: Fix the condition with frame_pointer_needed_indeed [PR96072]
    
    As PR96072 shows, the code adding REG_CFA_DEF_CFA reg note
    makes one assumption that we have emitted one insn which
    restores the frame pointer previously.  That part of code
    was guarded with flag frame_pointer_needed before, it was
    consistent, but it was replaced with flag
    frame_pointer_needed_indeed since commit r10-7981.  It
    caused ICE due to unexpected NULL insn.
    
            PR target/96072
    
    gcc/ChangeLog:
    
            * config/rs6000/rs6000-logue.c (rs6000_emit_epilogue): Update the
            condition for adding REG_CFA_DEF_CFA reg note with
            frame_pointer_needed_indeed.
    
    gcc/testsuite/ChangeLog:
    
            * gcc.target/powerpc/pr96072.c: New test.
    
    (cherry picked from commit 5be0950d22209f5ba69d244387228e12389a8470)

diff --git a/gcc/config/rs6000/rs6000-logue.c b/gcc/config/rs6000/rs6000-logue.c
index fbde3b62f48..ebfc3ff868f 100644
--- a/gcc/config/rs6000/rs6000-logue.c
+++ b/gcc/config/rs6000/rs6000-logue.c
@@ -4885,7 +4885,7 @@ rs6000_emit_epilogue (enum epilogue_type epilogue_type)
 	 a REG_CFA_DEF_CFA note, but that's OK;  A duplicate is
 	 discarded by dwarf2cfi.c/dwarf2out.c, and in any case would
 	 be harmless if emitted.  */
-      if (frame_pointer_needed)
+      if (frame_pointer_needed_indeed)
 	{
 	  insn = get_last_insn ();
 	  add_reg_note (insn, REG_CFA_DEF_CFA,
diff --git a/gcc/testsuite/gcc.target/powerpc/pr96072.c b/gcc/testsuite/gcc.target/powerpc/pr96072.c
new file mode 100644
index 00000000000..10341c91d2f
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/pr96072.c
@@ -0,0 +1,14 @@
+/* { dg-options "-O2" } */
+
+/* This used to ICE with the SYSV ABI (PR96072).  */
+
+void
+he (int jn)
+{
+  {
+    int bh[jn];
+    if (jn != 0)
+      goto wa;
+  }
+wa:;
+}

commit da6b16d3ec808828e54218f26a9654c3b0c63228
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Fri Oct 21 00:19:16 2022 +0000

    Daily bump.

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 41998460e75..43c15288d7c 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,13 @@
+2022-10-20  Kewen Lin  <linkw@linux.ibm.com>
+
+	Backported from master:
+	2022-09-26  Kewen Lin  <linkw@linux.ibm.com>
+
+	PR target/96072
+	* config/rs6000/rs6000-logue.c (rs6000_emit_epilogue): Update the
+	condition for adding REG_CFA_DEF_CFA reg note with
+	frame_pointer_needed_indeed.
+
 2022-10-17  Pat Haugen  <pthaugen@linux.ibm.com>
 
 	PR target/99685
diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 8b08eddd863..0f7d77c700e 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20221020
+20221021
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index fe2da634ac5..a1062409152 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,11 @@
+2022-10-20  Kewen Lin  <linkw@linux.ibm.com>
+
+	Backported from master:
+	2022-09-26  Kewen Lin  <linkw@linux.ibm.com>
+
+	PR target/96072
+	* gcc.target/powerpc/pr96072.c: New test.
+
 2022-10-14  Richard Biener  <rguenther@suse.de>
 
 	Backported from master:

commit e9dd88bd3027597c7702a7851aeffc4ce287ca64
Author: Richard Sandiford <richard.sandiford@arm.com>
Date:   Fri Oct 21 10:06:13 2022 +0100

    aarch64: Define __ARM_FEATURE_RCPC
    
    https://github.com/ARM-software/acle/pull/199 adds a new feature
    macro for RCPC, for use in things like inline assembly.  This patch
    adds the associated support to GCC.
    
    Also, RCPC is required for Armv8.3-A and later, but the armv8.3-a
    entry didn't include it.  This was probably harmless in practice
    since GCC simply ignored the extension until now.  (The GAS
    definition is OK.)
    
    gcc/
            * config/aarch64/aarch64.h (AARCH64_FL_FOR_ARCH8_3): Add
            AARCH64_FL_RCPC.
            (AARCH64_ISA_RCPC): New macro.
            * config/aarch64/aarch64-cores.def (thunderx3t110, zeus, neoverse-v1)
            (neoverse-512tvb, saphira): Remove RCPC from these Armv8.3-A+ cores.
            * config/aarch64/aarch64-c.c (aarch64_update_cpp_builtins): Define
            __ARM_FEATURE_RCPC when appropriate.
    
    gcc/testsuite/
            * gcc.target/aarch64/pragma_cpp_predefs_1.c: Add RCPC tests.

diff --git a/gcc/config/aarch64/aarch64-c.c b/gcc/config/aarch64/aarch64-c.c
index fd08be47570..244b42c3c3c 100644
--- a/gcc/config/aarch64/aarch64-c.c
+++ b/gcc/config/aarch64/aarch64-c.c
@@ -199,6 +199,7 @@ aarch64_update_cpp_builtins (cpp_reader *pfile)
 			"__ARM_FEATURE_BF16_VECTOR_ARITHMETIC", pfile);
   aarch64_def_or_undef (TARGET_BF16_FP,
 			"__ARM_FEATURE_BF16_SCALAR_ARITHMETIC", pfile);
+  aarch64_def_or_undef (AARCH64_ISA_RCPC, "__ARM_FEATURE_RCPC", pfile);
 
   /* Not for ACLE, but required to keep "float.h" correct if we switch
      target between implementations that do or do not support ARMv8.2-A
diff --git a/gcc/config/aarch64/aarch64-cores.def b/gcc/config/aarch64/aarch64-cores.def
index 6b817c61efe..197f88d5be2 100644
--- a/gcc/config/aarch64/aarch64-cores.def
+++ b/gcc/config/aarch64/aarch64-cores.def
@@ -128,17 +128,17 @@ AARCH64_CORE("tsv110",  tsv110, tsv110, 8_2A,  AARCH64_FL_FOR_ARCH8_2 | AARCH64_
 /* ARMv8.3-A Architecture Processors.  */
 
 /* Marvell cores (TX3). */
-AARCH64_CORE("thunderx3t110",  thunderx3t110,  thunderx3t110, 8_3A,  AARCH64_FL_FOR_ARCH8_3 | AARCH64_FL_CRYPTO | AARCH64_FL_RCPC | AARCH64_FL_SM4 | AARCH64_FL_SHA3 | AARCH64_FL_F16FML | AARCH64_FL_RCPC8_4, thunderx3t110, 0x43, 0x0b8, 0x0a)
+AARCH64_CORE("thunderx3t110",  thunderx3t110,  thunderx3t110, 8_3A,  AARCH64_FL_FOR_ARCH8_3 | AARCH64_FL_CRYPTO | AARCH64_FL_SM4 | AARCH64_FL_SHA3 | AARCH64_FL_F16FML | AARCH64_FL_RCPC8_4, thunderx3t110, 0x43, 0x0b8, 0x0a)
 
 /* ARMv8.4-A Architecture Processors.  */
 
 /* Arm ('A') cores.  */
-AARCH64_CORE("zeus", zeus, cortexa57, 8_4A,  AARCH64_FL_FOR_ARCH8_4 | AARCH64_FL_SVE | AARCH64_FL_RCPC | AARCH64_FL_I8MM | AARCH64_FL_BF16 | AARCH64_FL_F16 | AARCH64_FL_PROFILE | AARCH64_FL_SSBS | AARCH64_FL_RNG, neoversev1, 0x41, 0xd40, -1)
-AARCH64_CORE("neoverse-v1", neoversev1, cortexa57, 8_4A,  AARCH64_FL_FOR_ARCH8_4 | AARCH64_FL_SVE | AARCH64_FL_RCPC | AARCH64_FL_I8MM | AARCH64_FL_BF16 | AARCH64_FL_F16 | AARCH64_FL_PROFILE | AARCH64_FL_SSBS | AARCH64_FL_RNG, neoversev1, 0x41, 0xd40, -1)
-AARCH64_CORE("neoverse-512tvb", neoverse512tvb, cortexa57, 8_4A,  AARCH64_FL_FOR_ARCH8_4 | AARCH64_FL_SVE | AARCH64_FL_RCPC | AARCH64_FL_I8MM | AARCH64_FL_BF16 | AARCH64_FL_F16 | AARCH64_FL_PROFILE | AARCH64_FL_SSBS | AARCH64_FL_RNG, neoversev1, INVALID_IMP, INVALID_CORE, -1)
+AARCH64_CORE("zeus", zeus, cortexa57, 8_4A,  AARCH64_FL_FOR_ARCH8_4 | AARCH64_FL_SVE | AARCH64_FL_I8MM | AARCH64_FL_BF16 | AARCH64_FL_F16 | AARCH64_FL_PROFILE | AARCH64_FL_SSBS | AARCH64_FL_RNG, neoversev1, 0x41, 0xd40, -1)
+AARCH64_CORE("neoverse-v1", neoversev1, cortexa57, 8_4A,  AARCH64_FL_FOR_ARCH8_4 | AARCH64_FL_SVE | AARCH64_FL_I8MM | AARCH64_FL_BF16 | AARCH64_FL_F16 | AARCH64_FL_PROFILE | AARCH64_FL_SSBS | AARCH64_FL_RNG, neoversev1, 0x41, 0xd40, -1)
+AARCH64_CORE("neoverse-512tvb", neoverse512tvb, cortexa57, 8_4A,  AARCH64_FL_FOR_ARCH8_4 | AARCH64_FL_SVE | AARCH64_FL_I8MM | AARCH64_FL_BF16 | AARCH64_FL_F16 | AARCH64_FL_PROFILE | AARCH64_FL_SSBS | AARCH64_FL_RNG, neoversev1, INVALID_IMP, INVALID_CORE, -1)
 
 /* Qualcomm ('Q') cores. */
-AARCH64_CORE("saphira",     saphira,    saphira,    8_4A,  AARCH64_FL_FOR_ARCH8_4 | AARCH64_FL_CRYPTO | AARCH64_FL_RCPC, saphira,   0x51, 0xC01, -1)
+AARCH64_CORE("saphira",     saphira,    saphira,    8_4A,  AARCH64_FL_FOR_ARCH8_4 | AARCH64_FL_CRYPTO, saphira,   0x51, 0xC01, -1)
 
 /* Armv8.5-A Architecture Processors.  */
 AARCH64_CORE("neoverse-n2", neoversen2, cortexa57, 8_5A, AARCH64_FL_FOR_ARCH8_5 | AARCH64_FL_I8MM | AARCH64_FL_BF16 | AARCH64_FL_F16 | AARCH64_FL_SVE | AARCH64_FL_SVE2 | AARCH64_FL_SVE2_BITPERM | AARCH64_FL_RNG | AARCH64_FL_MEMTAG, neoversen2, 0x41, 0xd49, -1)
diff --git a/gcc/config/aarch64/aarch64.h b/gcc/config/aarch64/aarch64.h
index 51148846345..9be4ec3d280 100644
--- a/gcc/config/aarch64/aarch64.h
+++ b/gcc/config/aarch64/aarch64.h
@@ -236,7 +236,7 @@ extern unsigned aarch64_architecture_version;
 #define AARCH64_FL_FOR_ARCH8_2			\
   (AARCH64_FL_FOR_ARCH8_1 | AARCH64_FL_V8_2)
 #define AARCH64_FL_FOR_ARCH8_3			\
-  (AARCH64_FL_FOR_ARCH8_2 | AARCH64_FL_V8_3)
+  (AARCH64_FL_FOR_ARCH8_2 | AARCH64_FL_V8_3 | AARCH64_FL_RCPC)
 #define AARCH64_FL_FOR_ARCH8_4			\
   (AARCH64_FL_FOR_ARCH8_3 | AARCH64_FL_V8_4 | AARCH64_FL_F16FML \
    | AARCH64_FL_DOTPROD | AARCH64_FL_RCPC8_4)
@@ -271,6 +271,7 @@ extern unsigned aarch64_architecture_version;
 #define AARCH64_ISA_SM4	           (aarch64_isa_flags & AARCH64_FL_SM4)
 #define AARCH64_ISA_SHA3	   (aarch64_isa_flags & AARCH64_FL_SHA3)
 #define AARCH64_ISA_F16FML	   (aarch64_isa_flags & AARCH64_FL_F16FML)
+#define AARCH64_ISA_RCPC	   (aarch64_isa_flags & AARCH64_FL_RCPC)
 #define AARCH64_ISA_RCPC8_4	   (aarch64_isa_flags & AARCH64_FL_RCPC8_4)
 #define AARCH64_ISA_RNG		   (aarch64_isa_flags & AARCH64_FL_RNG)
 #define AARCH64_ISA_V8_5	   (aarch64_isa_flags & AARCH64_FL_V8_5)
diff --git a/gcc/testsuite/gcc.target/aarch64/pragma_cpp_predefs_1.c b/gcc/testsuite/gcc.target/aarch64/pragma_cpp_predefs_1.c
index bfb044f5d14..307fa3d67da 100644
--- a/gcc/testsuite/gcc.target/aarch64/pragma_cpp_predefs_1.c
+++ b/gcc/testsuite/gcc.target/aarch64/pragma_cpp_predefs_1.c
@@ -248,6 +248,26 @@
 #error "__ARM_FEATURE_CRC32 is not defined but should be!"
 #endif
 
+#pragma GCC target ("arch=armv8.2-a")
+#ifdef __ARM_FEATURE_RCPC
+#error "__ARM_FEATURE_RCPC is defined but should not be!"
+#endif
+
+#pragma GCC target ("arch=armv8.2-a+rcpc")
+#ifndef __ARM_FEATURE_RCPC
+#error "__ARM_FEATURE_RCPC is not defined but should be!"
+#endif
+
+#pragma GCC target ("+norcpc")
+#ifdef __ARM_FEATURE_RCPC
+#error "__ARM_FEATURE_RCPC is defined but should not be!"
+#endif
+
+#pragma GCC target ("arch=armv8.3-a")
+#ifndef __ARM_FEATURE_RCPC
+#error "__ARM_FEATURE_RCPC is not defined but should be!"
+#endif
+
 int
 foo (int a)
 {

commit 813cf5d170843dac18124c07e7746068c6f22a00
Author: Richard Sandiford <richard.sandiford@arm.com>
Date:   Fri Oct 21 10:06:13 2022 +0100

    aarch64: Fix matching of BRKNS
    
    Unlike other flag-setting SVE instructions, BRKNS sets the flags
    based on an all-true governing predicate, rather than the GP operand.
    
    gcc/
            * config/aarch64/iterators.md (SVE_BRKP): New iterator.
            * config/aarch64/aarch64-sve.md (*aarch64_brkn_cc): New pattern.
            (*aarch64_brkn_ptest): Likewise.
            (*aarch64_brk<brk_op>_cc): Restrict to SVE_BRKP.
            (*aarch64_brk<brk_op>_ptest): Likewise.
    
    gcc/testsuite/
            * gcc.target/aarch64/sve/acle/general/brkn_1.c: Expect separate
            PTEST instructions.
            * gcc.target/aarch64/sve/acle/general/brkn_2.c: New test.
    
    (cherry picked from commit 6bec66640597e2604f51fc1642c7d279164cd442)

diff --git a/gcc/config/aarch64/aarch64-sve.md b/gcc/config/aarch64/aarch64-sve.md
index bd51323e57d..b9af570003f 100644
--- a/gcc/config/aarch64/aarch64-sve.md
+++ b/gcc/config/aarch64/aarch64-sve.md
@@ -9293,7 +9293,61 @@
   "brk<brk_op>\t%0.b, %1/z, %2.b, %<brk_reg_opno>.b"
 )
 
-;; Same, but also producing a flags result.
+;; BRKN, producing both a predicate and a flags result.  Unlike other
+;; flag-setting instructions, these flags are always set wrt a ptrue.
+(define_insn_and_rewrite "*aarch64_brkn_cc"
+  [(set (reg:CC_NZC CC_REGNUM)
+	(unspec:CC_NZC
+	  [(match_operand:VNx16BI 4)
+	   (match_operand:VNx16BI 5)
+	   (const_int SVE_KNOWN_PTRUE)
+	   (unspec:VNx16BI
+	     [(match_operand:VNx16BI 1 "register_operand" "Upa")
+	      (match_operand:VNx16BI 2 "register_operand" "Upa")
+	      (match_operand:VNx16BI 3 "register_operand" "0")]
+	     UNSPEC_BRKN)]
+	  UNSPEC_PTEST))
+   (set (match_operand:VNx16BI 0 "register_operand" "=Upa")
+	(unspec:VNx16BI
+	  [(match_dup 1)
+	   (match_dup 2)
+	   (match_dup 3)]
+	  UNSPEC_BRKN))]
+  "TARGET_SVE"
+  "brkns\t%0.b, %1/z, %2.b, %0.b"
+  "&& (operands[4] != CONST0_RTX (VNx16BImode)
+       || operands[5] != CONST0_RTX (VNx16BImode))"
+  {
+    operands[4] = CONST0_RTX (VNx16BImode);
+    operands[5] = CONST0_RTX (VNx16BImode);
+  }
+)
+
+;; Same, but with only the flags result being interesting.
+(define_insn_and_rewrite "*aarch64_brkn_ptest"
+  [(set (reg:CC_NZC CC_REGNUM)
+	(unspec:CC_NZC
+	  [(match_operand:VNx16BI 4)
+	   (match_operand:VNx16BI 5)
+	   (const_int SVE_KNOWN_PTRUE)
+	   (unspec:VNx16BI
+	     [(match_operand:VNx16BI 1 "register_operand" "Upa")
+	      (match_operand:VNx16BI 2 "register_operand" "Upa")
+	      (match_operand:VNx16BI 3 "register_operand" "0")]
+	     UNSPEC_BRKN)]
+	  UNSPEC_PTEST))
+   (clobber (match_scratch:VNx16BI 0 "=Upa"))]
+  "TARGET_SVE"
+  "brkns\t%0.b, %1/z, %2.b, %0.b"
+  "&& (operands[4] != CONST0_RTX (VNx16BImode)
+       || operands[5] != CONST0_RTX (VNx16BImode))"
+  {
+    operands[4] = CONST0_RTX (VNx16BImode);
+    operands[5] = CONST0_RTX (VNx16BImode);
+  }
+)
+
+;; BRKPA and BRKPB, producing both a predicate and a flags result.
 (define_insn "*aarch64_brk<brk_op>_cc"
   [(set (reg:CC_NZC CC_REGNUM)
 	(unspec:CC_NZC
@@ -9303,17 +9357,17 @@
 	   (unspec:VNx16BI
 	     [(match_dup 1)
 	      (match_operand:VNx16BI 2 "register_operand" "Upa")
-	      (match_operand:VNx16BI 3 "register_operand" "<brk_reg_con>")]
-	     SVE_BRK_BINARY)]
+	      (match_operand:VNx16BI 3 "register_operand" "Upa")]
+	     SVE_BRKP)]
 	  UNSPEC_PTEST))
    (set (match_operand:VNx16BI 0 "register_operand" "=Upa")
 	(unspec:VNx16BI
 	  [(match_dup 1)
 	   (match_dup 2)
 	   (match_dup 3)]
-	  SVE_BRK_BINARY))]
+	  SVE_BRKP))]
   "TARGET_SVE"
-  "brk<brk_op>s\t%0.b, %1/z, %2.b, %<brk_reg_opno>.b"
+  "brk<brk_op>s\t%0.b, %1/z, %2.b, %3.b"
 )
 
 ;; Same, but with only the flags result being interesting.
@@ -9326,12 +9380,12 @@
 	   (unspec:VNx16BI
 	     [(match_dup 1)
 	      (match_operand:VNx16BI 2 "register_operand" "Upa")
-	      (match_operand:VNx16BI 3 "register_operand" "<brk_reg_con>")]
-	     SVE_BRK_BINARY)]
+	      (match_operand:VNx16BI 3 "register_operand" "Upa")]
+	     SVE_BRKP)]
 	  UNSPEC_PTEST))
    (clobber (match_scratch:VNx16BI 0 "=Upa"))]
   "TARGET_SVE"
-  "brk<brk_op>s\t%0.b, %1/z, %2.b, %<brk_reg_opno>.b"
+  "brk<brk_op>s\t%0.b, %1/z, %2.b, %3.b"
 )
 
 ;; -------------------------------------------------------------------------
diff --git a/gcc/config/aarch64/iterators.md b/gcc/config/aarch64/iterators.md
index ff5b23d71b1..20933b35079 100644
--- a/gcc/config/aarch64/iterators.md
+++ b/gcc/config/aarch64/iterators.md
@@ -2660,6 +2660,8 @@
 
 (define_int_iterator SVE_BRK_UNARY [UNSPEC_BRKA UNSPEC_BRKB])
 
+(define_int_iterator SVE_BRKP [UNSPEC_BRKPA UNSPEC_BRKPB])
+
 (define_int_iterator SVE_BRK_BINARY [UNSPEC_BRKN UNSPEC_BRKPA UNSPEC_BRKPB])
 
 (define_int_iterator SVE_PITER [UNSPEC_PFIRST UNSPEC_PNEXT])
diff --git a/gcc/testsuite/gcc.target/aarch64/sve/acle/general/brkn_1.c b/gcc/testsuite/gcc.target/aarch64/sve/acle/general/brkn_1.c
index 7fd9318c13f..c548810f169 100644
--- a/gcc/testsuite/gcc.target/aarch64/sve/acle/general/brkn_1.c
+++ b/gcc/testsuite/gcc.target/aarch64/sve/acle/general/brkn_1.c
@@ -18,5 +18,6 @@ test2 (svbool_t pg, svbool_t x, svbool_t y, int *any)
   return svptest_any (pg, res);
 }
 
-/* { dg-final { scan-assembler-times {\tbrkns\t} 2 } } */
-/* { dg-final { scan-assembler-not {\tbrkn\t} } } */
+/* { dg-final { scan-assembler-times {\tbrkn\t} 2 } } */
+/* { dg-final { scan-assembler-times {\tptest\t} 2 } } */
+/* { dg-final { scan-assembler-not {\tbrkns\t} } } */
diff --git a/gcc/testsuite/gcc.target/aarch64/sve/acle/general/brkn_2.c b/gcc/testsuite/gcc.target/aarch64/sve/acle/general/brkn_2.c
new file mode 100644
index 00000000000..74b6927410a
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/sve/acle/general/brkn_2.c
@@ -0,0 +1,23 @@
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+#include <arm_sve.h>
+
+void
+test1 (svbool_t pg, svbool_t x, svbool_t y, int *any, svbool_t *ptr)
+{
+  svbool_t res = svbrkn_z (pg, x, y);
+  *any = svptest_any (svptrue_b8 (), res);
+  *ptr = res;
+}
+
+int
+test2 (svbool_t pg, svbool_t x, svbool_t y, int *any)
+{
+  svbool_t res = svbrkn_z (pg, x, y);
+  return svptest_any (svptrue_b8 (), res);
+}
+
+/* { dg-final { scan-assembler-times {\tbrkns\t} 2 } } */
+/* { dg-final { scan-assembler-not {\tbrkn\t} } } */
+/* { dg-final { scan-assembler-not {\tptest\t} } } */

commit 382201fea8d422108b2b038716fb6469c2c020f9
Author: Richard Sandiford <richard.sandiford@arm.com>
Date:   Fri Oct 21 10:06:13 2022 +0100

    aarch64: Prevent generation of /M BRKAS and BRKBS
    
    Bit of a brown-paper-bag bug, but: GCC was generating
    non-existent merging forms of BRKAS and BRKBS.  Those
    instructions only support zero predication (although
    BRKA and BRKB support both).
    
    gcc/
            * config/aarch64/aarch64-sve.md (*aarch64_brk<brk_op>_cc): Remove
            merging alternative.
            (*aarch64_brk<brk_op>_ptest): Likewise.
    
    gcc/testsuite/
            * gcc.target/aarch64/sve/acle/general/brka_1.c: Expect a separate
            PTEST instruction.
            * gcc.target/aarch64/sve/acle/general/brkb_1.c: Likewise.
    
    (cherry picked from commit 57675c7f92a3bd3ca8dae1faac7f2f51d40e0f9e)

diff --git a/gcc/config/aarch64/aarch64-sve.md b/gcc/config/aarch64/aarch64-sve.md
index b9af570003f..d77194892f3 100644
--- a/gcc/config/aarch64/aarch64-sve.md
+++ b/gcc/config/aarch64/aarch64-sve.md
@@ -9228,45 +9228,41 @@
 (define_insn "*aarch64_brk<brk_op>_cc"
   [(set (reg:CC_NZC CC_REGNUM)
 	(unspec:CC_NZC
-	  [(match_operand:VNx16BI 1 "register_operand" "Upa, Upa")
+	  [(match_operand:VNx16BI 1 "register_operand" "Upa")
 	   (match_dup 1)
 	   (match_operand:SI 4 "aarch64_sve_ptrue_flag")
 	   (unspec:VNx16BI
 	     [(match_dup 1)
-	      (match_operand:VNx16BI 2 "register_operand" "Upa, Upa")
-	      (match_operand:VNx16BI 3 "aarch64_simd_reg_or_zero" "Dz, 0")]
+	      (match_operand:VNx16BI 2 "register_operand" "Upa")
+	      (match_operand:VNx16BI 3 "aarch64_simd_imm_zero")]
 	     SVE_BRK_UNARY)]
 	  UNSPEC_PTEST))
-   (set (match_operand:VNx16BI 0 "register_operand" "=Upa, Upa")
+   (set (match_operand:VNx16BI 0 "register_operand" "=Upa")
 	(unspec:VNx16BI
 	  [(match_dup 1)
 	   (match_dup 2)
 	   (match_dup 3)]
 	  SVE_BRK_UNARY))]
   "TARGET_SVE"
-  "@
-   brk<brk_op>s\t%0.b, %1/z, %2.b
-   brk<brk_op>s\t%0.b, %1/m, %2.b"
+  "brk<brk_op>s\t%0.b, %1/z, %2.b"
 )
 
 ;; Same, but with only the flags result being interesting.
 (define_insn "*aarch64_brk<brk_op>_ptest"
   [(set (reg:CC_NZC CC_REGNUM)
 	(unspec:CC_NZC
-	  [(match_operand:VNx16BI 1 "register_operand" "Upa, Upa")
+	  [(match_operand:VNx16BI 1 "register_operand" "Upa")
 	   (match_dup 1)
 	   (match_operand:SI 4 "aarch64_sve_ptrue_flag")
 	   (unspec:VNx16BI
 	     [(match_dup 1)
-	      (match_operand:VNx16BI 2 "register_operand" "Upa, Upa")
-	      (match_operand:VNx16BI 3 "aarch64_simd_reg_or_zero" "Dz, 0")]
+	      (match_operand:VNx16BI 2 "register_operand" "Upa")
+	      (match_operand:VNx16BI 3 "aarch64_simd_imm_zero")]
 	     SVE_BRK_UNARY)]
 	  UNSPEC_PTEST))
-   (clobber (match_scratch:VNx16BI 0 "=Upa, Upa"))]
+   (clobber (match_scratch:VNx16BI 0 "=Upa"))]
   "TARGET_SVE"
-  "@
-   brk<brk_op>s\t%0.b, %1/z, %2.b
-   brk<brk_op>s\t%0.b, %1/m, %2.b"
+  "brk<brk_op>s\t%0.b, %1/z, %2.b"
 )
 
 ;; -------------------------------------------------------------------------
diff --git a/gcc/testsuite/gcc.target/aarch64/sve/acle/general/brka_1.c b/gcc/testsuite/gcc.target/aarch64/sve/acle/general/brka_1.c
index 24aa8f317c4..6146ef82849 100644
--- a/gcc/testsuite/gcc.target/aarch64/sve/acle/general/brka_1.c
+++ b/gcc/testsuite/gcc.target/aarch64/sve/acle/general/brka_1.c
@@ -18,5 +18,6 @@ test2 (svbool_t pg, svbool_t x, svbool_t y, int *any)
   return svptest_any (pg, res);
 }
 
-/* { dg-final { scan-assembler-times {\tbrkas\tp[0-9]+\.b, p[0-9]+/m,} 2 } } */
-/* { dg-final { scan-assembler-not {\tbrka\t} } } */
+/* { dg-final { scan-assembler-times {\tbrka\t} 2 } } */
+/* { dg-final { scan-assembler-times {\tptest\t} 2 } } */
+/* { dg-final { scan-assembler-not {\tbrkas\t} } } */
diff --git a/gcc/testsuite/gcc.target/aarch64/sve/acle/general/brkb_1.c b/gcc/testsuite/gcc.target/aarch64/sve/acle/general/brkb_1.c
index 07e3622ed6a..7f1c75837de 100644
--- a/gcc/testsuite/gcc.target/aarch64/sve/acle/general/brkb_1.c
+++ b/gcc/testsuite/gcc.target/aarch64/sve/acle/general/brkb_1.c
@@ -18,5 +18,6 @@ test2 (svbool_t pg, svbool_t x, svbool_t y, int *any)
   return svptest_any (pg, res);
 }
 
-/* { dg-final { scan-assembler-times {\tbrkbs\tp[0-9]+\.b, p[0-9]+/m,} 2 } } */
-/* { dg-final { scan-assembler-not {\tbrkb\t} } } */
+/* { dg-final { scan-assembler-times {\tbrkb\t} 2 } } */
+/* { dg-final { scan-assembler-times {\tptest\t} 2 } } */
+/* { dg-final { scan-assembler-not {\tbrkbs\t} } } */

commit 5076eefe23b96279e34351a2a044858bae3251ae
Author: Eric Botcazou <ebotcazou@adacore.com>
Date:   Fri Oct 21 15:46:37 2022 +0200

    Fix VCOND expansion
    
    Instead of only allowing the signed optab to provide EQ/NE compares, we
    allow both here since there seems to be no documented canonicalization.
    
    gcc/
            PR target/107336
            * optabs.c (expand_vec_cond_expr): Query both VCOND and VCONDU for
            EQ and NE.

diff --git a/gcc/optabs.c b/gcc/optabs.c
index 64f23d2c293..93f99423727 100644
--- a/gcc/optabs.c
+++ b/gcc/optabs.c
@@ -5902,6 +5902,14 @@ expand_vec_cond_expr (tree vec_cond_type, tree op0, tree op1, tree op2,
 			   GET_MODE_NUNITS (cmp_op_mode)));
 
   icode = get_vcond_icode (mode, cmp_op_mode, unsignedp);
+  /* Some targets do not have vcondeq and only vcond with NE/EQ
+     but not vcondu, so make sure to also try vcond here as
+     vcond_icode_p would canonicalize the optab query to.  */
+  if (icode == CODE_FOR_nothing
+      && (tcode == NE_EXPR || tcode == EQ_EXPR)
+      && ((icode = get_vcond_icode (mode, cmp_op_mode, !unsignedp))
+	  != CODE_FOR_nothing))
+    unsignedp = !unsignedp;
   if (icode == CODE_FOR_nothing)
     {
       if (tcode == LT_EXPR

commit 52a6c8da6f837747f96589b25a75e780785725c0
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sat Oct 22 00:18:51 2022 +0000

    Daily bump.

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 43c15288d7c..d2aed6b9a43 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,39 @@
+2022-10-21  Eric Botcazou  <ebotcazou@adacore.com>
+
+	PR target/107336
+	* optabs.c (expand_vec_cond_expr): Query both VCOND and VCONDU for
+	EQ and NE.
+
+2022-10-21  Richard Sandiford  <richard.sandiford@arm.com>
+
+	Backported from master:
+	2022-10-20  Richard Sandiford  <richard.sandiford@arm.com>
+
+	* config/aarch64/aarch64-sve.md (*aarch64_brk<brk_op>_cc): Remove
+	merging alternative.
+	(*aarch64_brk<brk_op>_ptest): Likewise.
+
+2022-10-21  Richard Sandiford  <richard.sandiford@arm.com>
+
+	Backported from master:
+	2022-10-20  Richard Sandiford  <richard.sandiford@arm.com>
+
+	* config/aarch64/iterators.md (SVE_BRKP): New iterator.
+	* config/aarch64/aarch64-sve.md (*aarch64_brkn_cc): New pattern.
+	(*aarch64_brkn_ptest): Likewise.
+	(*aarch64_brk<brk_op>_cc): Restrict to SVE_BRKP.
+	(*aarch64_brk<brk_op>_ptest): Likewise.
+
+2022-10-21  Richard Sandiford  <richard.sandiford@arm.com>
+
+	* config/aarch64/aarch64.h (AARCH64_FL_FOR_ARCH8_3): Add
+	AARCH64_FL_RCPC.
+	(AARCH64_ISA_RCPC): New macro.
+	* config/aarch64/aarch64-cores.def (thunderx3t110, zeus, neoverse-v1)
+	(neoverse-512tvb, saphira): Remove RCPC from these Armv8.3-A+ cores.
+	* config/aarch64/aarch64-c.c (aarch64_update_cpp_builtins): Define
+	__ARM_FEATURE_RCPC when appropriate.
+
 2022-10-20  Kewen Lin  <linkw@linux.ibm.com>
 
 	Backported from master:
diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 0f7d77c700e..8d5e5406b70 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20221021
+20221022
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index a1062409152..4294c75417a 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,25 @@
+2022-10-21  Richard Sandiford  <richard.sandiford@arm.com>
+
+	Backported from master:
+	2022-10-20  Richard Sandiford  <richard.sandiford@arm.com>
+
+	* gcc.target/aarch64/sve/acle/general/brka_1.c: Expect a separate
+	PTEST instruction.
+	* gcc.target/aarch64/sve/acle/general/brkb_1.c: Likewise.
+
+2022-10-21  Richard Sandiford  <richard.sandiford@arm.com>
+
+	Backported from master:
+	2022-10-20  Richard Sandiford  <richard.sandiford@arm.com>
+
+	* gcc.target/aarch64/sve/acle/general/brkn_1.c: Expect separate
+	PTEST instructions.
+	* gcc.target/aarch64/sve/acle/general/brkn_2.c: New test.
+
+2022-10-21  Richard Sandiford  <richard.sandiford@arm.com>
+
+	* gcc.target/aarch64/pragma_cpp_predefs_1.c: Add RCPC tests.
+
 2022-10-20  Kewen Lin  <linkw@linux.ibm.com>
 
 	Backported from master:

commit ee737e5611e7e7aa7997daef2cc6c327b599d213
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sun Oct 23 00:18:50 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 8d5e5406b70..e09d253a0d6 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20221022
+20221023

commit 910156619c93ff988587762b446542c4dfbb00a2
Author: Harald Anlauf <anlauf@gmx.de>
Date:   Wed Oct 19 22:37:56 2022 +0200

    Fortran: error recovery with references of bad array constructors [PR105633]
    
    gcc/fortran/ChangeLog:
    
            PR fortran/105633
            * expr.c (find_array_section): Move check for NULL pointers so
            that both subscript triplets and vector subscripts are covered.
    
    gcc/testsuite/ChangeLog:
    
            PR fortran/105633
            * gfortran.dg/pr105633.f90: New test.
    
    Co-authored-by: Steven G. Kargl <kargl@gcc.gnu.org>
    (cherry picked from commit ecb20df4fa6d99daa635c7fb662dc0554610777e)

diff --git a/gcc/fortran/expr.c b/gcc/fortran/expr.c
index 1129f5f3302..b65fc764fb8 100644
--- a/gcc/fortran/expr.c
+++ b/gcc/fortran/expr.c
@@ -1549,6 +1549,12 @@ find_array_section (gfc_expr *expr, gfc_ref *ref)
       lower = ref->u.ar.as->lower[d];
       upper = ref->u.ar.as->upper[d];
 
+      if (!lower || !upper)
+	{
+	  t = false;
+	  goto cleanup;
+	}
+
       if (ref->u.ar.dimen_type[d] == DIMEN_VECTOR)  /* Vector subscript.  */
 	{
 	  gfc_constructor *ci;
@@ -1591,9 +1597,7 @@ find_array_section (gfc_expr *expr, gfc_ref *ref)
 	{
 	  if ((begin && begin->expr_type != EXPR_CONSTANT)
 	      || (finish && finish->expr_type != EXPR_CONSTANT)
-	      || (step && step->expr_type != EXPR_CONSTANT)
-	      || !lower
-	      || !upper)
+	      || (step && step->expr_type != EXPR_CONSTANT))
 	    {
 	      t = false;
 	      goto cleanup;
diff --git a/gcc/testsuite/gfortran.dg/pr105633.f90 b/gcc/testsuite/gfortran.dg/pr105633.f90
new file mode 100644
index 00000000000..f2dbc5e742a
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr105633.f90
@@ -0,0 +1,8 @@
+! { dg-do compile }
+! PR fortran/105633 - ICE in find_array_section
+! Contributed by G.Steinmetz
+
+program p
+  integer, parameter :: a(:) = [1,2] ! { dg-error "deferred shape" }
+  print *, [a([1,2])]
+end

commit 968bc227856e3a71c1fdc132a91c1c94c18f171c
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Mon Oct 24 00:18:27 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index e09d253a0d6..9c3fc6cabad 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20221023
+20221024
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 491c0c2cbd5..032b92fa687 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,13 @@
+2022-10-23  Harald Anlauf  <anlauf@gmx.de>
+
+	Backported from master:
+	2022-10-20  Harald Anlauf  <anlauf@gmx.de>
+		    Steven G. Kargl  <kargl@gcc.gnu.org>
+
+	PR fortran/105633
+	* expr.c (find_array_section): Move check for NULL pointers so
+	that both subscript triplets and vector subscripts are covered.
+
 2022-10-10  Mikael Morin  <mikael@gcc.gnu.org>
 
 	Backported from master:
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 4294c75417a..db5e5ee60f6 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,12 @@
+2022-10-23  Harald Anlauf  <anlauf@gmx.de>
+
+	Backported from master:
+	2022-10-20  Harald Anlauf  <anlauf@gmx.de>
+		    Steven G. Kargl  <kargl@gcc.gnu.org>
+
+	PR fortran/105633
+	* gfortran.dg/pr105633.f90: New test.
+
 2022-10-21  Richard Sandiford  <richard.sandiford@arm.com>
 
 	Backported from master:

commit 530129ed35dedef171616e39ef5425e4631167ed
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Tue Oct 25 00:19:44 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 9c3fc6cabad..c75820ce08e 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20221024
+20221025

commit 7cee6ad35eb0fd9f79100e5fa7b6560b8ea7fe10
Author: Martin Liska <mliska@suse.cz>
Date:   Mon Oct 24 15:34:39 2022 +0200

    x86: fix VENDOR_MAX enum value
    
            PR target/107364
    
    gcc/ChangeLog:
    
            * common/config/i386/i386-cpuinfo.h (enum processor_vendor):
              Reorder enum values as BUILTIN_VENDOR_MAX should not point
              in the middle of the valid enum values.
    
    (cherry picked from commit f751bf4c5d1aaa1aacfcbdec62881c5ea1175dfb)

diff --git a/gcc/common/config/i386/i386-cpuinfo.h b/gcc/common/config/i386/i386-cpuinfo.h
index 19f54862711..e0d64ac435f 100644
--- a/gcc/common/config/i386/i386-cpuinfo.h
+++ b/gcc/common/config/i386/i386-cpuinfo.h
@@ -30,8 +30,10 @@ enum processor_vendor
   VENDOR_INTEL = 1,
   VENDOR_AMD,
   VENDOR_OTHER,
-  BUILTIN_VENDOR_MAX = VENDOR_OTHER,
-  VENDOR_MAX
+
+  /* Maximum values must be at the end of this enum.  */
+  VENDOR_MAX,
+  BUILTIN_VENDOR_MAX = VENDOR_OTHER
 };
 
 /* Any new types or subtypes have to be inserted at the end. */

commit 97509e98d9199ff43916250fc0a20f3d1838d067
Author: Stefan Schulze Frielinghaus <stefansf@linux.ibm.com>
Date:   Tue Oct 25 10:38:23 2022 +0200

    IBM zSystems: Fix function_ok_for_sibcall [PR106355]
    
    For a parameter with BLKmode we cannot use REG_NREGS in order to
    determine the number of consecutive registers.  Streamlined this with
    the implementation of s390_function_arg.
    
    Fix some indentation whitespace, too.
    
    gcc/ChangeLog:
    
            PR target/106355
            * config/s390/s390.c (s390_call_saved_register_used): For a
            parameter with BLKmode fix determining number of consecutive
            registers.
    
    gcc/testsuite/ChangeLog:
    
            * gcc.target/s390/pr106355.h: Common code for new tests.
            * gcc.target/s390/pr106355-1.c: New test.
            * gcc.target/s390/pr106355-2.c: New test.
            * gcc.target/s390/pr106355-3.c: New test.
    
    (cherry picked from commit cb994acc08b67f26a54e7c5dc1f4995a2ce24d98)

diff --git a/gcc/config/s390/s390.c b/gcc/config/s390/s390.c
index dee32f11e67..200fd0298ed 100644
--- a/gcc/config/s390/s390.c
+++ b/gcc/config/s390/s390.c
@@ -13465,36 +13465,37 @@ s390_call_saved_register_used (tree call_expr)
       function_arg_info arg (TREE_TYPE (parameter), /*named=*/true);
       apply_pass_by_reference_rules (&cum_v, arg);
 
-       parm_rtx = s390_function_arg (cum, arg);
+      parm_rtx = s390_function_arg (cum, arg);
 
-       s390_function_arg_advance (cum, arg);
+      s390_function_arg_advance (cum, arg);
 
-       if (!parm_rtx)
-	 continue;
-
-       if (REG_P (parm_rtx))
-	 {
-	   for (reg = 0; reg < REG_NREGS (parm_rtx); reg++)
-	     if (!call_used_or_fixed_reg_p (reg + REGNO (parm_rtx)))
-	       return true;
-	 }
+      if (!parm_rtx)
+	continue;
 
-       if (GET_CODE (parm_rtx) == PARALLEL)
-	 {
-	   int i;
+      if (REG_P (parm_rtx))
+	{
+	  int size = s390_function_arg_size (arg.mode, arg.type);
+	  int nregs = (size + UNITS_PER_LONG - 1) / UNITS_PER_LONG;
 
-	   for (i = 0; i < XVECLEN (parm_rtx, 0); i++)
-	     {
-	       rtx r = XEXP (XVECEXP (parm_rtx, 0, i), 0);
+	  for (reg = 0; reg < nregs; reg++)
+	    if (!call_used_or_fixed_reg_p (reg + REGNO (parm_rtx)))
+	      return true;
+	}
+      else if (GET_CODE (parm_rtx) == PARALLEL)
+	{
+	  int i;
 
-	       gcc_assert (REG_P (r));
+	  for (i = 0; i < XVECLEN (parm_rtx, 0); i++)
+	    {
+	      rtx r = XEXP (XVECEXP (parm_rtx, 0, i), 0);
 
-	       for (reg = 0; reg < REG_NREGS (r); reg++)
-		 if (!call_used_or_fixed_reg_p (reg + REGNO (r)))
-		   return true;
-	     }
-	 }
+	      gcc_assert (REG_P (r));
+	      gcc_assert (REG_NREGS (r) == 1);
 
+	      if (!call_used_or_fixed_reg_p (REGNO (r)))
+		return true;
+	    }
+	}
     }
   return false;
 }
diff --git a/gcc/testsuite/gcc.target/s390/pr106355-1.c b/gcc/testsuite/gcc.target/s390/pr106355-1.c
new file mode 100644
index 00000000000..1ec0f6b25ac
--- /dev/null
+++ b/gcc/testsuite/gcc.target/s390/pr106355-1.c
@@ -0,0 +1,42 @@
+/* { dg-do compile } */
+/* { dg-options "-foptimize-sibling-calls" } */
+/* { dg-final { scan-assembler {brasl\t%r\d+,bar4} } } */
+/* { dg-final { scan-assembler {brasl\t%r\d+,bar8} } } */
+
+/* Parameter E is passed in GPR 6 which is call-saved which prohibits
+   sibling call optimization.  This must hold true also if the mode of the
+   parameter is BLKmode.  */
+
+/* 4 byte */
+
+typedef struct
+{
+  char x;
+  char y[3];
+} t4;
+
+extern t4 e4;
+
+extern void bar4 (int a, int b, int c, int d, t4 e4);
+
+void foo4 (int a, int b, int c, int d)
+{
+  bar4 (a, b, c, d, e4);
+}
+
+/* 8 byte */
+
+typedef struct
+{
+  short x;
+  char y[6];
+} t8;
+
+extern t8 e8;
+
+extern void bar8 (int a, int b, int c, int d, t8 e8);
+
+void foo8 (int a, int b, int c, int d)
+{
+  bar8 (a, b, c, d, e8);
+}
diff --git a/gcc/testsuite/gcc.target/s390/pr106355-2.c b/gcc/testsuite/gcc.target/s390/pr106355-2.c
new file mode 100644
index 00000000000..ddbdba5d278
--- /dev/null
+++ b/gcc/testsuite/gcc.target/s390/pr106355-2.c
@@ -0,0 +1,8 @@
+/* { dg-do compile { target { s390-*-* } } } */
+/* { dg-options "-foptimize-sibling-calls -mzarch" } */
+/* { dg-final { scan-assembler {brasl\t%r\d+,bar} } } */
+
+/* This tests function s390_call_saved_register_used where
+   GET_CODE (parm_rtx) == PARALLEL holds.  */
+
+#include "pr106355.h"
diff --git a/gcc/testsuite/gcc.target/s390/pr106355-3.c b/gcc/testsuite/gcc.target/s390/pr106355-3.c
new file mode 100644
index 00000000000..39daea44fc4
--- /dev/null
+++ b/gcc/testsuite/gcc.target/s390/pr106355-3.c
@@ -0,0 +1,8 @@
+/* { dg-do compile { target { s390-*-* } } } */
+/* { dg-options "-foptimize-sibling-calls -mesa" } */
+/* { dg-final { scan-assembler {brasl\t%r\d+,bar} } } */
+
+/* This tests function s390_call_saved_register_used where
+   REG_P (parm_rtx) and nregs == 2 holds.  */
+
+#include "pr106355.h"
diff --git a/gcc/testsuite/gcc.target/s390/pr106355.h b/gcc/testsuite/gcc.target/s390/pr106355.h
new file mode 100644
index 00000000000..362908e5913
--- /dev/null
+++ b/gcc/testsuite/gcc.target/s390/pr106355.h
@@ -0,0 +1,18 @@
+/* For the S/390 ABI parameter D is passed in GPR 5 and 6 and the latter is
+   call-saved which prohibits sibling call optimization.  This must hold true
+   also if the mode of the parameter is BLKmode.  */
+
+typedef struct
+{
+  short x;
+  char y[6];
+} t;
+
+extern t d;
+
+extern void bar (int a, int b, int c, t d);
+
+void foo (int a, int b, int c)
+{
+  bar (a, b, c, d);
+}

commit 5f3fd19c5efdc737d3be2c413a88bc66173aa0ee
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Wed Oct 26 00:19:10 2022 +0000

    Daily bump.

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index d2aed6b9a43..04095703fc2 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,23 @@
+2022-10-25  Stefan Schulze Frielinghaus  <stefansf@linux.ibm.com>
+
+	Backported from master:
+	2022-10-19  Stefan Schulze Frielinghaus  <stefansf@linux.ibm.com>
+
+	PR target/106355
+	* config/s390/s390.c (s390_call_saved_register_used): For a
+	parameter with BLKmode fix determining number of consecutive
+	registers.
+
+2022-10-25  Martin Liska  <mliska@suse.cz>
+
+	Backported from master:
+	2022-10-24  Martin Liska  <mliska@suse.cz>
+
+	PR target/107364
+	* common/config/i386/i386-cpuinfo.h (enum processor_vendor):
+	  Reorder enum values as BUILTIN_VENDOR_MAX should not point
+	  in the middle of the valid enum values.
+
 2022-10-21  Eric Botcazou  <ebotcazou@adacore.com>
 
 	PR target/107336
diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index c75820ce08e..03e9228fa2a 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20221025
+20221026
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index db5e5ee60f6..03d0d3e6482 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,13 @@
+2022-10-25  Stefan Schulze Frielinghaus  <stefansf@linux.ibm.com>
+
+	Backported from master:
+	2022-10-19  Stefan Schulze Frielinghaus  <stefansf@linux.ibm.com>
+
+	* gcc.target/s390/pr106355.h: Common code for new tests.
+	* gcc.target/s390/pr106355-1.c: New test.
+	* gcc.target/s390/pr106355-2.c: New test.
+	* gcc.target/s390/pr106355-3.c: New test.
+
 2022-10-23  Harald Anlauf  <anlauf@gmx.de>
 
 	Backported from master:

commit df6696f369f60f9c038d545bf0fd7bbd930c9504
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Thu Oct 27 00:20:32 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 03e9228fa2a..494f34d4962 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20221026
+20221027

commit 0586159b57426ed7d235b42f38681213c3183892
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Fri Oct 28 00:20:30 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 494f34d4962..7109ae30352 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20221027
+20221028

commit 3b4c9e0658b13b8db6c7f38242ed270cdb8fc932
Author: Harald Anlauf <anlauf@gmx.de>
Date:   Wed Oct 26 21:00:44 2022 +0200

    Fortran: BOZ literal constants are not compatible to any type [PR103413]
    
    gcc/fortran/ChangeLog:
    
            PR fortran/103413
            * symbol.c (gfc_type_compatible): A boz-literal-constant has no type
            and thus is not considered compatible to any type.
    
    gcc/testsuite/ChangeLog:
    
            PR fortran/103413
            * gfortran.dg/illegal_boz_arg_4.f90: New test.
    
    (cherry picked from commit f7d28818179247685f3c101f9f2f16366f56309b)

diff --git a/gcc/fortran/symbol.c b/gcc/fortran/symbol.c
index 96e4cee3040..dff4b7f1659 100644
--- a/gcc/fortran/symbol.c
+++ b/gcc/fortran/symbol.c
@@ -5123,6 +5123,10 @@ gfc_type_compatible (gfc_typespec *ts1, gfc_typespec *ts2)
   bool is_union1 = (ts1->type == BT_UNION);
   bool is_union2 = (ts2->type == BT_UNION);
 
+  /* A boz-literal-constant has no type.  */
+  if (ts1->type == BT_BOZ || ts2->type == BT_BOZ)
+    return false;
+
   if (is_class1
       && ts1->u.derived->components
       && ((ts1->u.derived->attr.is_class
diff --git a/gcc/testsuite/gfortran.dg/illegal_boz_arg_4.f90 b/gcc/testsuite/gfortran.dg/illegal_boz_arg_4.f90
new file mode 100644
index 00000000000..856cfa9211f
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/illegal_boz_arg_4.f90
@@ -0,0 +1,13 @@
+! { dg-do compile }
+! { dg-options "-std=f2018" }
+! PR fortran/103413
+! Contributed by G.Steinmetz
+
+program p
+  type t
+     class(*), allocatable :: a
+  end type
+  type(t) :: x
+  allocate (x%a, source=z'1') ! { dg-error "type incompatible" }
+  allocate (x%a, mold=z'1')   ! { dg-error "type incompatible" }
+end

commit 99e8cc81e36cfab5940daac4cdff1cd3272f22a9
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sat Oct 29 00:18:42 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 7109ae30352..06511cc68c5 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20221028
+20221029
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 032b92fa687..7bc801b0686 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,12 @@
+2022-10-28  Harald Anlauf  <anlauf@gmx.de>
+
+	Backported from master:
+	2022-10-26  Harald Anlauf  <anlauf@gmx.de>
+
+	PR fortran/103413
+	* symbol.c (gfc_type_compatible): A boz-literal-constant has no type
+	and thus is not considered compatible to any type.
+
 2022-10-23  Harald Anlauf  <anlauf@gmx.de>
 
 	Backported from master:
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 03d0d3e6482..4c1872e0bc2 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,11 @@
+2022-10-28  Harald Anlauf  <anlauf@gmx.de>
+
+	Backported from master:
+	2022-10-26  Harald Anlauf  <anlauf@gmx.de>
+
+	PR fortran/103413
+	* gfortran.dg/illegal_boz_arg_4.f90: New test.
+
 2022-10-25  Stefan Schulze Frielinghaus  <stefansf@linux.ibm.com>
 
 	Backported from master:

commit 6d4ef34b455d2813f8f674878d7552f086ffcd3a
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sun Oct 30 00:17:56 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 06511cc68c5..1440bc55c69 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20221029
+20221030

commit 96762f32bc985a05c21df42129d84ea2264452d6
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Mon Oct 31 00:19:08 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 1440bc55c69..bed449ab430 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20221030
+20221031

commit d8c89f603ae8b52a9c23f789cbde27f3c53eed0c
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Tue Nov 1 00:20:13 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index bed449ab430..39502537bfa 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20221031
+20221101

commit 464a2a6deb02abcddc85a9582dc978d88c34473f
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Wed Nov 2 00:18:29 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 39502537bfa..a8fe89b316a 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20221101
+20221102

commit ad30cedebe3cabb9ac12a9834f231ff9fbc8c242
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Thu Nov 3 00:18:22 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index a8fe89b316a..99ca02330bd 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20221102
+20221103

commit e6fc0223c6582a03c862c3e46fd116a9a8c0ea36
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Fri Nov 4 00:18:51 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 99ca02330bd..c96f2246e01 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20221103
+20221104

commit 87b0935ed43d971a6eeebca963fb673628f138dd
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Fri Nov 4 12:10:32 2022 +0000

    doc: Document correct -fwide-exec-charset defaults [PR41041]
    
    As shown in the PR, the default is not UTF-32 but rather UTF-32BE or
    UTF-32LE, avoiding the need for a byte order mark in literals.
    
    gcc/ChangeLog:
    
            PR c/41041
            * doc/cppopts.texi: Document -fwide-exec-charset defaults
            correctly.
    
    (cherry picked from commit e50ea3a42f058c14ee29327d5277ab0435e3d36b)

diff --git a/gcc/doc/cppopts.texi b/gcc/doc/cppopts.texi
index 7f1849d841f..b02c26638ea 100644
--- a/gcc/doc/cppopts.texi
+++ b/gcc/doc/cppopts.texi
@@ -314,9 +314,10 @@ supported by the system's @code{iconv} library routine.
 @opindex fwide-exec-charset
 @cindex character set, wide execution
 Set the wide execution character set, used for wide string and
-character constants.  The default is UTF-32 or UTF-16, whichever
-corresponds to the width of @code{wchar_t}.  As with
-@option{-fexec-charset}, @var{charset} can be any encoding supported
+character constants.  The default is one of UTF-32BE, UTF-32LE, UTF-16BE,
+or UTF-16LE, whichever corresponds to the width of @code{wchar_t} and the
+big-endian or little-endian byte order being used for code generation.  As
+with @option{-fexec-charset}, @var{charset} can be any encoding supported
 by the system's @code{iconv} library routine; however, you will have
 problems with encodings that do not fit exactly in @code{wchar_t}.
 

commit 6382ef4cd06a09caef19e555418665b833f99ce1
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sun Nov 6 11:06:56 2022 +0000

    Daily bump.

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 04095703fc2..775d4654682 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,12 @@
+2022-11-05  Jonathan Wakely  <jwakely@redhat.com>
+
+	Backported from master:
+	2022-11-05  Jonathan Wakely  <jwakely@redhat.com>
+
+	PR c/41041
+	* doc/cppopts.texi: Document -fwide-exec-charset defaults
+	correctly.
+
 2022-10-25  Stefan Schulze Frielinghaus  <stefansf@linux.ibm.com>
 
 	Backported from master:
diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index c96f2246e01..a9017fbbe6b 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20221104
+20221106

commit 0f144c6e14feb64266d7be78fcc493cca88b914c
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Mon Nov 7 00:18:41 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index a9017fbbe6b..0503ed97af3 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20221106
+20221107

commit 4958e0b69a367e45443b66da04fafcf1f454f74e
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Tue Nov 8 00:19:38 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 0503ed97af3..f47121e1a89 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20221107
+20221108

commit 15dfc5f929e838eefc435a47ef8e72eb51790c67
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Mon Nov 7 22:27:08 2022 +0000

    libstdc++: Remove empty <author> elements in manual
    
    This fixes a spurious comma before the list of authors in the PDF
    version of the libstdc++ manual.
    
    Also fix the commented-out examples which should show <personblurb> not
    <authorblurb>.
    
    libstdc++-v3/ChangeLog:
    
            * doc/xml/authors.xml: Remove empty author element.
            * doc/xml/manual/spine.xml: Likewise.
            * doc/html/*: Regenerate.
    
    (cherry picked from commit 4596339d9fabdcbd66b5a7430fa56544f75ecef1)

diff --git a/libstdc++-v3/doc/html/bk02.html b/libstdc++-v3/doc/html/bk02.html
index 7c47759f223..182c94b59a6 100644
--- a/libstdc++-v3/doc/html/bk02.html
+++ b/libstdc++-v3/doc/html/bk02.html
@@ -1,2 +1,2 @@
 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title></title><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><meta name="keywords" content="ISO C++, runtime, library" /><link rel="home" href="index.html" title="The GNU C++ Library" /><link rel="up" href="index.html" title="The GNU C++ Library" /><link rel="prev" href="manual/backwards.html" title="Backwards Compatibility" /><link rel="next" href="api.html" title="The GNU C++ Library API Reference" /></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center"></th></tr><tr><td width="20%" align="left"><a accesskey="p" href="manual/backwards.html">Prev</a> </td><th width="60%" align="center"> </th><td width="20%" align="right"> <a accesskey="n" href="api.html">Next</a></td></tr></table><hr /></div><div class="book"><div class="titlepage"><hr /></div><div class="toc"><p><strong>Table of Contents</strong></p><dl class="toc"><dt><span class="article"><a href="api.html">The GNU C++ Library API Reference</a></span></dt></dl></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="manual/backwards.html">Prev</a> </td><td width="20%" align="center"> </td><td width="40%" align="right"> <a accesskey="n" href="api.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Backwards Compatibility </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> The GNU C++ Library API Reference</td></tr></table></div></body></html>
\ No newline at end of file
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title></title><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><meta name="keywords" content="ISO C++, runtime, library" /><link rel="home" href="index.html" title="The GNU C++ Library" /><link rel="up" href="index.html" title="The GNU C++ Library" /><link rel="prev" href="manual/appendix_gfdl.html" title="Appendix E. GNU Free Documentation License" /><link rel="next" href="api.html" title="The GNU C++ Library API Reference" /></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center"></th></tr><tr><td width="20%" align="left"><a accesskey="p" href="manual/appendix_gfdl.html">Prev</a> </td><th width="60%" align="center"> </th><td width="20%" align="right"> <a accesskey="n" href="api.html">Next</a></td></tr></table><hr /></div><div class="book"><div class="titlepage"><hr /></div><div class="toc"><p><strong>Table of Contents</strong></p><dl class="toc"><dt><span class="article"><a href="api.html">The GNU C++ Library API Reference</a></span></dt></dl></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="manual/appendix_gfdl.html">Prev</a> </td><td width="20%" align="center"> </td><td width="40%" align="right"> <a accesskey="n" href="api.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Appendix E. GNU Free Documentation License </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> The GNU C++ Library API Reference</td></tr></table></div></body></html>
\ No newline at end of file
diff --git a/libstdc++-v3/doc/html/manual/extensions.html b/libstdc++-v3/doc/html/manual/extensions.html
index e5836efa85d..1c697413d8d 100644
--- a/libstdc++-v3/doc/html/manual/extensions.html
+++ b/libstdc++-v3/doc/html/manual/extensions.html
@@ -1,8 +1,8 @@
 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>Part III.  Extensions</title><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><meta name="keywords" content="ISO C++, library" /><meta name="keywords" content="ISO C++, runtime, library" /><link rel="home" href="../index.html" title="The GNU C++ Library" /><link rel="up" href="index.html" title="The GNU C++ Library Manual" /><link rel="prev" href="io_and_c.html" title="Interacting with C" /><link rel="next" href="ext_preface.html" title="" /></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Part III. 
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>Part III.  Extensions</title><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><meta name="keywords" content="ISO C++, library" /><meta name="keywords" content="ISO C++, runtime, library" /><link rel="home" href="../index.html" title="The GNU C++ Library" /><link rel="up" href="index.html" title="The GNU C++ Library Manual" /><link rel="prev" href="concurrency.html" title="Chapter 15.  Concurrency" /><link rel="next" href="ext_preface.html" title="" /></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Part III. 
   Extensions
   
-</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="io_and_c.html">Prev</a> </td><th width="60%" align="center">The GNU C++ Library Manual</th><td width="20%" align="right"> <a accesskey="n" href="ext_preface.html">Next</a></td></tr></table><hr /></div><div class="part"><div class="titlepage"><div><div><h1 class="title"><a id="manual.ext"></a>Part III. 
+</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="concurrency.html">Prev</a> </td><th width="60%" align="center">The GNU C++ Library Manual</th><td width="20%" align="right"> <a accesskey="n" href="ext_preface.html">Next</a></td></tr></table><hr /></div><div class="part"><div class="titlepage"><div><div><h1 class="title"><a id="manual.ext"></a>Part III. 
   Extensions
   <a id="id-1.3.5.1.1.1" class="indexterm"></a>
 </h1></div></div></div><div class="toc"><p><strong>Table of Contents</strong></p><dl class="toc"><dt><span class="preface"><a href="ext_preface.html"></a></span></dt><dt><span class="chapter"><a href="ext_compile_checks.html">16. Compile Time Checks</a></span></dt><dt><span class="chapter"><a href="debug_mode.html">17. Debug Mode</a></span></dt><dd><dl><dt><span class="section"><a href="debug_mode.html#manual.ext.debug_mode.intro">Intro</a></span></dt><dt><span class="section"><a href="debug_mode_semantics.html">Semantics</a></span></dt><dt><span class="section"><a href="debug_mode_using.html">Using</a></span></dt><dd><dl><dt><span class="section"><a href="debug_mode_using.html#debug_mode.using.mode">Using the Debug Mode</a></span></dt><dt><span class="section"><a href="debug_mode_using.html#debug_mode.using.specific">Using a Specific Debug Container</a></span></dt></dl></dd><dt><span class="section"><a href="debug_mode_design.html">Design</a></span></dt><dd><dl><dt><span class="section"><a href="debug_mode_design.html#debug_mode.design.goals">Goals</a></span></dt><dt><span class="section"><a href="debug_mode_design.html#debug_mode.design.methods">Methods</a></span></dt><dd><dl><dt><span class="section"><a href="debug_mode_design.html#debug_mode.design.methods.wrappers">The Wrapper Model</a></span></dt><dd><dl><dt><span class="section"><a href="debug_mode_design.html#debug_mode.design.methods.safe_iter">Safe Iterators</a></span></dt><dt><span class="section"><a href="debug_mode_design.html#debug_mode.design.methods.safe_seq">Safe Sequences (Containers)</a></span></dt></dl></dd><dt><span class="section"><a href="debug_mode_design.html#debug_mode.design.methods.precond">Precondition Checking</a></span></dt><dt><span class="section"><a href="debug_mode_design.html#debug_mode.design.methods.coexistence">Release- and debug-mode coexistence</a></span></dt><dd><dl><dt><span class="section"><a href="debug_mode_design.html#methods.coexistence.compile">Compile-time coexistence of release- and debug-mode components</a></span></dt><dt><span class="section"><a href="debug_mode_design.html#methods.coexistence.link">Link- and run-time coexistence of release- and
@@ -68,4 +68,7 @@
 	  Text <code class="function">modify</code> Up
 	</a></span></dt><dt><span class="section"><a href="policy_based_data_structures_test.html#performance.priority_queue.text_modify_down">
 	  Text <code class="function">modify</code> Down
-	</a></span></dt></dl></dd><dt><span class="section"><a href="policy_based_data_structures_test.html#pbds.test.performance.observations">Observations</a></span></dt><dd><dl><dt><span class="section"><a href="policy_based_data_structures_test.html#observations.associative">Associative</a></span></dt><dt><span class="section"><a href="policy_based_data_structures_test.html#observations.priority_queue">Priority_Queue</a></span></dt></dl></dd></dl></dd></dl></dd><dt><span class="section"><a href="policy_data_structures_ack.html">Acknowledgments</a></span></dt><dt><span class="bibliography"><a href="policy_data_structures.html#pbds.biblio">Bibliography</a></span></dt></dl></dd><dt><span class="chapter"><a href="ext_containers.html">22. HP/SGI Extensions</a></span></dt><dd><dl><dt><span class="section"><a href="ext_containers.html#manual.ext.containers.sgi">Backwards Compatibility</a></span></dt><dt><span class="section"><a href="ext_sgi.html">Deprecated</a></span></dt></dl></dd><dt><span class="chapter"><a href="ext_utilities.html">23. Utilities</a></span></dt><dt><span class="chapter"><a href="ext_algorithms.html">24. Algorithms</a></span></dt><dt><span class="chapter"><a href="ext_numerics.html">25. Numerics</a></span></dt><dt><span class="chapter"><a href="ext_iterators.html">26. Iterators</a></span></dt><dt><span class="chapter"><a href="ext_io.html">27. Input and Output</a></span></dt><dd><dl><dt><span class="section"><a href="ext_io.html#manual.ext.io.filebuf_derived">Derived filebufs</a></span></dt></dl></dd><dt><span class="chapter"><a href="ext_demangling.html">28. Demangling</a></span></dt><dt><span class="chapter"><a href="ext_concurrency.html">29. Concurrency</a></span></dt><dd><dl><dt><span class="section"><a href="ext_concurrency.html#manual.ext.concurrency.design">Design</a></span></dt><dd><dl><dt><span class="section"><a href="ext_concurrency.html#manual.ext.concurrency.design.threads">Interface to Locks and Mutexes</a></span></dt><dt><span class="section"><a href="ext_concurrency.html#manual.ext.concurrency.design.atomics">Interface to Atomic Functions</a></span></dt></dl></dd><dt><span class="section"><a href="ext_concurrency_impl.html">Implementation</a></span></dt><dd><dl><dt><span class="section"><a href="ext_concurrency_impl.html#manual.ext.concurrency.impl.atomic_fallbacks">Using Built-in Atomic Functions</a></span></dt><dt><span class="section"><a href="ext_concurrency_impl.html#manual.ext.concurrency.impl.thread">Thread Abstraction</a></span></dt></dl></dd><dt><span class="section"><a href="ext_concurrency_use.html">Use</a></span></dt></dl></dd></dl></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="io_and_c.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="index.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="ext_preface.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Interacting with C </td><td width="20%" align="center"><a accesskey="h" href="../index.html">Home</a></td><td width="40%" align="right" valign="top"> </td></tr></table></div></body></html>
\ No newline at end of file
+	</a></span></dt></dl></dd><dt><span class="section"><a href="policy_based_data_structures_test.html#pbds.test.performance.observations">Observations</a></span></dt><dd><dl><dt><span class="section"><a href="policy_based_data_structures_test.html#observations.associative">Associative</a></span></dt><dt><span class="section"><a href="policy_based_data_structures_test.html#observations.priority_queue">Priority_Queue</a></span></dt></dl></dd></dl></dd></dl></dd><dt><span class="section"><a href="policy_data_structures_ack.html">Acknowledgments</a></span></dt><dt><span class="bibliography"><a href="policy_data_structures.html#pbds.biblio">Bibliography</a></span></dt></dl></dd><dt><span class="chapter"><a href="ext_containers.html">22. HP/SGI Extensions</a></span></dt><dd><dl><dt><span class="section"><a href="ext_containers.html#manual.ext.containers.sgi">Backwards Compatibility</a></span></dt><dt><span class="section"><a href="ext_sgi.html">Deprecated</a></span></dt></dl></dd><dt><span class="chapter"><a href="ext_utilities.html">23. Utilities</a></span></dt><dt><span class="chapter"><a href="ext_algorithms.html">24. Algorithms</a></span></dt><dt><span class="chapter"><a href="ext_numerics.html">25. Numerics</a></span></dt><dt><span class="chapter"><a href="ext_iterators.html">26. Iterators</a></span></dt><dt><span class="chapter"><a href="ext_io.html">27. Input and Output</a></span></dt><dd><dl><dt><span class="section"><a href="ext_io.html#manual.ext.io.filebuf_derived">Derived filebufs</a></span></dt></dl></dd><dt><span class="chapter"><a href="ext_demangling.html">28. Demangling</a></span></dt><dt><span class="chapter"><a href="ext_concurrency.html">29. Concurrency</a></span></dt><dd><dl><dt><span class="section"><a href="ext_concurrency.html#manual.ext.concurrency.design">Design</a></span></dt><dd><dl><dt><span class="section"><a href="ext_concurrency.html#manual.ext.concurrency.design.threads">Interface to Locks and Mutexes</a></span></dt><dt><span class="section"><a href="ext_concurrency.html#manual.ext.concurrency.design.atomics">Interface to Atomic Functions</a></span></dt></dl></dd><dt><span class="section"><a href="ext_concurrency_impl.html">Implementation</a></span></dt><dd><dl><dt><span class="section"><a href="ext_concurrency_impl.html#manual.ext.concurrency.impl.atomic_fallbacks">Using Built-in Atomic Functions</a></span></dt><dt><span class="section"><a href="ext_concurrency_impl.html#manual.ext.concurrency.impl.thread">Thread Abstraction</a></span></dt></dl></dd><dt><span class="section"><a href="ext_concurrency_use.html">Use</a></span></dt></dl></dd></dl></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="concurrency.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="index.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="ext_preface.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Chapter 15. 
+  Concurrency
+  
+ </td><td width="20%" align="center"><a accesskey="h" href="../index.html">Home</a></td><td width="40%" align="right" valign="top"> </td></tr></table></div></body></html>
\ No newline at end of file
diff --git a/libstdc++-v3/doc/html/manual/index.html b/libstdc++-v3/doc/html/manual/index.html
index d0063af3a3a..d9971bfc6d9 100644
--- a/libstdc++-v3/doc/html/manual/index.html
+++ b/libstdc++-v3/doc/html/manual/index.html
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>The GNU C++ Library Manual</title><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><meta name="keywords" content="ISO C++, runtime, library" /><link rel="home" href="../index.html" title="The GNU C++ Library" /><link rel="up" href="../index.html" title="The GNU C++ Library" /><link rel="prev" href="../index.html" title="The GNU C++ Library" /><link rel="next" href="intro.html" title="Part I.  Introduction" /></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">The GNU C++ Library Manual</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="../index.html">Prev</a> </td><th width="60%" align="center"> </th><td width="20%" align="right"> <a accesskey="n" href="intro.html">Next</a></td></tr></table><hr /></div><div class="book"><div class="titlepage"><div><div><h1 class="title"><a id="manual"></a>The GNU C++ Library Manual</h1></div><div><div class="authorgroup"><div class="author"><h3 class="author"><span class="firstname"></span> <span class="surname"></span></h3></div><div class="author"><h3 class="author"><span class="firstname">Paolo</span> <span class="surname">Carlini</span></h3></div><div class="author"><h3 class="author"><span class="firstname">Phil</span> <span class="surname">Edwards</span></h3></div><div class="author"><h3 class="author"><span class="firstname">Doug</span> <span class="surname">Gregor</span></h3></div><div class="author"><h3 class="author"><span class="firstname">Benjamin</span> <span class="surname">Kosnik</span></h3></div><div class="author"><h3 class="author"><span class="firstname">Dhruv</span> <span class="surname">Matani</span></h3></div><div class="author"><h3 class="author"><span class="firstname">Jason</span> <span class="surname">Merrill</span></h3></div><div class="author"><h3 class="author"><span class="firstname">Mark</span> <span class="surname">Mitchell</span></h3></div><div class="author"><h3 class="author"><span class="firstname">Nathan</span> <span class="surname">Myers</span></h3></div><div class="author"><h3 class="author"><span class="firstname">Felix</span> <span class="surname">Natter</span></h3></div><div class="author"><h3 class="author"><span class="firstname">Stefan</span> <span class="surname">Olsson</span></h3></div><div class="author"><h3 class="author"><span class="firstname">Johannes</span> <span class="surname">Singler</span></h3></div><div class="author"><h3 class="author"><span class="firstname">Ami</span> <span class="surname">Tavory</span></h3></div><div class="author"><h3 class="author"><span class="firstname">Jonathan</span> <span class="surname">Wakely</span></h3></div></div></div><div><p class="copyright">Copyright © 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>The GNU C++ Library Manual</title><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><meta name="keywords" content="ISO C++, runtime, library" /><link rel="home" href="../index.html" title="The GNU C++ Library" /><link rel="up" href="../index.html" title="The GNU C++ Library" /><link rel="prev" href="../index.html" title="The GNU C++ Library" /><link rel="next" href="intro.html" title="Part I.  Introduction" /></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">The GNU C++ Library Manual</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="../index.html">Prev</a> </td><th width="60%" align="center"> </th><td width="20%" align="right"> <a accesskey="n" href="intro.html">Next</a></td></tr></table><hr /></div><div class="book"><div class="titlepage"><div><div><h1 class="title"><a id="manual"></a>The GNU C++ Library Manual</h1></div><div><div class="authorgroup"><div class="author"><h3 class="author"><span class="firstname">Paolo</span> <span class="surname">Carlini</span></h3></div><div class="author"><h3 class="author"><span class="firstname">Phil</span> <span class="surname">Edwards</span></h3></div><div class="author"><h3 class="author"><span class="firstname">Doug</span> <span class="surname">Gregor</span></h3></div><div class="author"><h3 class="author"><span class="firstname">Benjamin</span> <span class="surname">Kosnik</span></h3></div><div class="author"><h3 class="author"><span class="firstname">Dhruv</span> <span class="surname">Matani</span></h3></div><div class="author"><h3 class="author"><span class="firstname">Jason</span> <span class="surname">Merrill</span></h3></div><div class="author"><h3 class="author"><span class="firstname">Mark</span> <span class="surname">Mitchell</span></h3></div><div class="author"><h3 class="author"><span class="firstname">Nathan</span> <span class="surname">Myers</span></h3></div><div class="author"><h3 class="author"><span class="firstname">Felix</span> <span class="surname">Natter</span></h3></div><div class="author"><h3 class="author"><span class="firstname">Stefan</span> <span class="surname">Olsson</span></h3></div><div class="author"><h3 class="author"><span class="firstname">Johannes</span> <span class="surname">Singler</span></h3></div><div class="author"><h3 class="author"><span class="firstname">Ami</span> <span class="surname">Tavory</span></h3></div><div class="author"><h3 class="author"><span class="firstname">Jonathan</span> <span class="surname">Wakely</span></h3></div></div></div><div><p class="copyright">Copyright © 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 
       <a class="link" href="https://www.fsf.org" target="_top">FSF</a>
     </p></div></div><hr /></div><div class="toc"><p><strong>Table of Contents</strong></p><dl class="toc"><dt><span class="part"><a href="intro.html">I. 
   Introduction
diff --git a/libstdc++-v3/doc/xml/authors.xml b/libstdc++-v3/doc/xml/authors.xml
index 0a120b508e9..95626d46cba 100644
--- a/libstdc++-v3/doc/xml/authors.xml
+++ b/libstdc++-v3/doc/xml/authors.xml
@@ -13,18 +13,13 @@
       </address>
     </affiliation>
 
-    <authorblurb>
+    <personblurb>
       <para>
       </para>
-    </authorblurb>
+    </personblurb>
   </author>
 -->
 
-  <author><personname><firstname/><surname/></personname><personblurb>
-      <para>
-      </para>
-    </personblurb></author>
-
   <author><personname><firstname>Paolo</firstname><surname>Carlini</surname></personname><personblurb>
       <para>
 	TR1, LWG Active, Closed, Defects lists.
diff --git a/libstdc++-v3/doc/xml/manual/spine.xml b/libstdc++-v3/doc/xml/manual/spine.xml
index 4db3037ac4d..78a33fe603b 100644
--- a/libstdc++-v3/doc/xml/manual/spine.xml
+++ b/libstdc++-v3/doc/xml/manual/spine.xml
@@ -48,18 +48,13 @@
       </address>
     </affiliation>
 
-    <authorblurb>
+    <personblurb>
       <para>
       </para>
-    </authorblurb>
+    </personblurb>
   </author>
 -->
 
-  <author><personname><firstname/><surname/></personname><personblurb>
-      <para>
-      </para>
-    </personblurb></author>
-
   <author><personname><firstname>Paolo</firstname><surname>Carlini</surname></personname><personblurb>
       <para>
 	TR1, LWG Active, Closed, Defects lists.

commit bb08940b30bd50c6e860bb8ac72d6f2ce7c1b25d
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Wed Oct 19 12:53:35 2022 -0700

    Always use TYPE_MODE instead of DECL_MODE for vector field
    
    e034c5c8957 re PR target/78643 (ICE in convert_move, at expr.c:230)
    
    fixed the case where DECL_MODE of a vector field is BLKmode and its
    TYPE_MODE is a vector mode because of target attribute.  Remove the
    BLKmode check for the case where DECL_MODE of a vector field is a vector
    mode and its TYPE_MODE isn't a vector mode because of target attribute.
    
    gcc/
    
            PR target/107304
            * expr.c (get_inner_reference): Always use TYPE_MODE for vector
            field with vector raw mode.
    
    gcc/testsuite/
    
            PR target/107304
            * gcc.target/i386/pr107304.c: New test.
    
    (cherry picked from commit 1c64aba8cdf6509533f554ad86640f274cdbe37f)

diff --git a/gcc/expr.c b/gcc/expr.c
index 10f0b816dd1..dabee814240 100644
--- a/gcc/expr.c
+++ b/gcc/expr.c
@@ -7282,8 +7282,7 @@ get_inner_reference (tree exp, poly_int64_pod *pbitsize,
 	  /* For vector fields re-check the target flags, as DECL_MODE
 	     could have been set with different target flags than
 	     the current function has.  */
-	  if (mode == BLKmode
-	      && VECTOR_TYPE_P (TREE_TYPE (field))
+	  if (VECTOR_TYPE_P (TREE_TYPE (field))
 	      && VECTOR_MODE_P (TYPE_MODE_RAW (TREE_TYPE (field))))
 	    mode = TYPE_MODE (TREE_TYPE (field));
 	}
diff --git a/gcc/testsuite/gcc.target/i386/pr107304.c b/gcc/testsuite/gcc.target/i386/pr107304.c
new file mode 100644
index 00000000000..80badc11682
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr107304.c
@@ -0,0 +1,39 @@
+/* { dg-do compile } */
+/* { dg-options "-O0 -march=tigerlake" } */
+
+#include <stdint.h>
+
+typedef union {
+  uint8_t v __attribute__((aligned(256))) __attribute__ ((vector_size(64 * sizeof(uint8_t))));
+  uint8_t i[64] __attribute__((aligned(256)));
+} stress_vec_u8_64_t;
+
+typedef struct {
+ struct {
+  stress_vec_u8_64_t s;
+  stress_vec_u8_64_t o;
+  stress_vec_u8_64_t mask1;
+  stress_vec_u8_64_t mask2;
+ } u8_64;
+} stress_vec_data_t;
+
+__attribute__((target_clones("arch=skylake", "default"))) 
+void
+stress_vecshuf_u8_64(stress_vec_data_t *data)
+{
+  stress_vec_u8_64_t *__restrict s;
+  stress_vec_u8_64_t *__restrict mask1;
+  stress_vec_u8_64_t *__restrict mask2;
+  register int i;
+
+  s = &data->u8_64.s;
+  mask1 = &data->u8_64.mask1;
+  mask2 = &data->u8_64.mask2;
+
+  for (i = 0; i < 256; i++) {	/* was i < 65536 */
+      stress_vec_u8_64_t tmp;
+
+      tmp.v = __builtin_shuffle(s->v, mask1->v);
+      s->v = __builtin_shuffle(tmp.v, mask2->v);
+  }
+}

commit fdfef7b8bc245069f4fa7a8eba03ee2e4b5e5e6b
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Wed Nov 9 00:21:21 2022 +0000

    Daily bump.

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 775d4654682..0db61c4043c 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,12 @@
+2022-11-08  H.J. Lu  <hjl.tools@gmail.com>
+
+	Backported from master:
+	2022-10-25  H.J. Lu  <hjl.tools@gmail.com>
+
+	PR target/107304
+	* expr.c (get_inner_reference): Always use TYPE_MODE for vector
+	field with vector raw mode.
+
 2022-11-05  Jonathan Wakely  <jwakely@redhat.com>
 
 	Backported from master:
diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index f47121e1a89..c240fbb06eb 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20221108
+20221109
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 4c1872e0bc2..71d8bbd3216 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,11 @@
+2022-11-08  H.J. Lu  <hjl.tools@gmail.com>
+
+	Backported from master:
+	2022-10-25  H.J. Lu  <hjl.tools@gmail.com>
+
+	PR target/107304
+	* gcc.target/i386/pr107304.c: New test.
+
 2022-10-28  Harald Anlauf  <anlauf@gmx.de>
 
 	Backported from master:
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 20629202323..77cbdb22e32 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,12 @@
+2022-11-08  Jonathan Wakely  <jwakely@redhat.com>
+
+	Backported from master:
+	2022-11-08  Jonathan Wakely  <jwakely@redhat.com>
+
+	* doc/xml/authors.xml: Remove empty author element.
+	* doc/xml/manual/spine.xml: Likewise.
+	* doc/html/*: Regenerate.
+
 2022-08-03  Jonathan Wakely  <jwakely@redhat.com>
 
 	Backported from master:

commit db180454d210561a60e4621cdc99997814ab5bcd
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Thu Nov 10 00:19:46 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index c240fbb06eb..2a7f865a5c1 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20221109
+20221110

commit 3158361cda498b753b55c499d48faca7f4e2336a
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Fri Nov 11 00:18:30 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 2a7f865a5c1..361ef5a71d9 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20221110
+20221111

commit 8adba3e857872ade3b4ac181435c8b11cb98bd4b
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sat Nov 12 00:19:00 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 361ef5a71d9..0e48d446545 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20221111
+20221112

commit c2feb1bbcc7114405da146c7dd64eb3209717c7e
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sun Nov 13 00:19:01 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 0e48d446545..f9634730802 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20221112
+20221113

commit 298e3cba816eed684483a37aa0027a342b2a26b4
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Mon Nov 14 00:19:05 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index f9634730802..9da330f584e 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20221113
+20221114

commit c17873d83aaeed037fb5d039df2e6303d4b6a553
Author: Richard Biener <rguenther@suse.de>
Date:   Mon Nov 14 17:19:20 2022 +0100

    tree-optimization/107485 - fix non-call exception ICE with inlining
    
    Inlining performs a wrong non-call exception fixup for VEC_COND_EXPRs
    which on the branch fail to properly have the condition split out in
    the first place.
    
            PR tree-optimization/107485
            * tree-inline.c (remap_gimple_stmt): Use correct type for
            split out condition of [VEC_]COND_EXPRs.

diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c
index c20c25ceb50..658b09c07d2 100644
--- a/gcc/tree-inline.c
+++ b/gcc/tree-inline.c
@@ -1979,11 +1979,10 @@ remap_gimple_stmt (gimple *stmt, copy_body_data *id)
 	     || gimple_assign_rhs_code (ass) == VEC_COND_EXPR)
 	    && gimple_could_trap_p (ass))
 	  {
-	    gassign *cmp
-	      = gimple_build_assign (make_ssa_name (boolean_type_node),
-				     gimple_assign_rhs1 (ass));
+	    tree def = make_ssa_name (TREE_TYPE (gimple_assign_rhs1 (ass)));
+	    gassign *cmp = gimple_build_assign (def, gimple_assign_rhs1 (ass));
 	    gimple_seq_add_stmt (&stmts, cmp);
-	    gimple_assign_set_rhs1 (ass, gimple_assign_lhs (cmp));
+	    gimple_assign_set_rhs1 (ass, def);
 	  }
     }
 

commit 2d355c6d1c560fcf6475929e4c584991c7c71b1c
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Tue Nov 15 00:18:36 2022 +0000

    Daily bump.

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 0db61c4043c..958ad90871b 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2022-11-14  Richard Biener  <rguenther@suse.de>
+
+	PR tree-optimization/107485
+	* tree-inline.c (remap_gimple_stmt): Use correct type for
+	split out condition of [VEC_]COND_EXPRs.
+
 2022-11-08  H.J. Lu  <hjl.tools@gmail.com>
 
 	Backported from master:
diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 9da330f584e..22ce612e636 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20221114
+20221115

commit c9a202bb5478a2523fde05cb5e8bfe1fb5986aa6
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Wed Nov 16 00:18:00 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 22ce612e636..c559bd9ee8e 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20221115
+20221116

commit 280d1001bf2de0e4ffae639c8def866ebf3f9d05
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Thu Nov 17 00:17:46 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index c559bd9ee8e..3204c3c9c61 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20221116
+20221117

commit b9b78b4de3c7dcc6868c4af831b2d213fda21b04
Author: Marek Polacek <polacek@redhat.com>
Date:   Thu Nov 17 11:59:29 2022 -0500

    c++: constinit on pointer to function [PR104066]
    
    [dcl.constinit]: "The constinit specifier shall be applied only to
    a declaration of a variable with static or thread storage duration."
    
    Thus, this ought to be OK:
    
      constinit void (*p)() = nullptr;
    
    but the error message I introduced when implementing constinit was
    not looking at funcdecl_p, so the code above was rejected.
    
    Fixed thus.  I'm checking constinit_p first because I think that's
    far more likely to be false than funcdecl_p.
    
            PR c++/104066
    
    gcc/cp/ChangeLog:
    
            * decl.c (grokdeclarator): Check funcdecl_p before complaining
            about constinit.
    
    gcc/testsuite/ChangeLog:
    
            * g++.dg/cpp2a/constinit18.C: New test.
    
    (cherry picked from commit 7b3b2f50953c5143d4b14b59d322d8a793f411dd)

diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 38003a5a70f..6af7a97a7b9 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -12275,7 +12275,7 @@ grokdeclarator (const cp_declarator *declarator,
 			  "an array", name);
 		return error_mark_node;
 	      }
-	    if (constinit_p)
+	    if (constinit_p && funcdecl_p)
 	      {
 		error_at (declspecs->locations[ds_constinit],
 			  "%<constinit%> on function return type is not "
diff --git a/gcc/testsuite/g++.dg/cpp2a/constinit18.C b/gcc/testsuite/g++.dg/cpp2a/constinit18.C
new file mode 100644
index 00000000000..51b4f0273be
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp2a/constinit18.C
@@ -0,0 +1,12 @@
+// PR c++/104066
+// { dg-do compile { target c++20 } }
+
+constinit void (*p)() = nullptr;
+constinit void (*pp)() = nullptr;
+void fn();
+constinit void (&r)() = fn;
+
+extern constinit long (* const syscall_reexported) (long, ...);
+
+constinit void bad (); // { dg-error ".constinit. on function return type is not allowed" }
+constinit void bad () { } // { dg-error ".constinit. on function return type is not allowed" }

commit 1bfdef41ed7ae507823047663fb4305c57b1717b
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Fri Nov 18 18:10:08 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 3204c3c9c61..578404781e6 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20221117
+20221118
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index e524d767550..688c4e14f03 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,12 @@
+2022-11-18  Marek Polacek  <polacek@redhat.com>
+
+	Backported from master:
+	2022-11-18  Marek Polacek  <polacek@redhat.com>
+
+	PR c++/104066
+	* decl.c (grokdeclarator): Check funcdecl_p before complaining
+	about constinit.
+
 2022-06-28  Release Manager
 
 	* GCC 10.4.0 released.
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 71d8bbd3216..e13ba84e410 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,11 @@
+2022-11-18  Marek Polacek  <polacek@redhat.com>
+
+	Backported from master:
+	2022-11-18  Marek Polacek  <polacek@redhat.com>
+
+	PR c++/104066
+	* g++.dg/cpp2a/constinit18.C: New test.
+
 2022-11-08  H.J. Lu  <hjl.tools@gmail.com>
 
 	Backported from master:

commit 3180cd7383af2fa4188c59da289bbddb095177c2
Author: Thomas Schwinge <thomas@codesourcery.com>
Date:   Fri Nov 18 23:57:52 2022 +0100

    nvptx: In 'STARTFILE_SPEC', fix 'crt0.o' for '-mmainkernel'
    
    A recent nvptx-tools change: commit 886a95faf66bf66a82fc0fe7d2a9fd9e9fec2820
    "ld: Don't search for input files in '-L'directories" (of
    <https://github.com/MentorEmbedded/nvptx-tools/pull/38>
    "Match standard 'ld' "search" behavior") in GCC/nvptx target testing
    generally causes linking to fail with:
    
        error opening crt0.o
        collect2: error: ld returned 1 exit status
        compiler exited with status 1
    
    Indeed per GCC '-v' output, there is an undecorated 'crt0.o' on the linker
    ('collect2') command line:
    
         [...]/build-gcc/./gcc/collect2 -o [...] crt0.o [...]
    
    This is due to:
    
        gcc/config/nvptx/nvptx.h:#define STARTFILE_SPEC "%{mmainkernel:crt0.o}"
    
    ..., and the fix, as used by numerous other GCC targets, is to instead use
    'crt0.o%s'; for '%s' means, per 'gcc/gcc.cc', "The Specs Language":
    
         %s     current argument is the name of a library or startup file of some sort.
                Search for that file in a standard list of directories
                and substitute the full name found.
    
    With that, we get the expected path to 'crt0.o'.
    
            gcc/
            * config/nvptx/nvptx.h (STARTFILE_SPEC): Fix 'crt0.o' for
            '-mmainkernel'.
    
    (cherry picked from commit dda43e1ef0c9f6c32ad022d3a08ce7651e42a129)

diff --git a/gcc/config/nvptx/nvptx.h b/gcc/config/nvptx/nvptx.h
index ca1aa11d852..95ef0422a35 100644
--- a/gcc/config/nvptx/nvptx.h
+++ b/gcc/config/nvptx/nvptx.h
@@ -27,7 +27,7 @@
 
 /* Run-time Target.  */
 
-#define STARTFILE_SPEC "%{mmainkernel:crt0.o}"
+#define STARTFILE_SPEC "%{mmainkernel:crt0.o%s}"
 
 #define ASM_SPEC "%{misa=*:-m %*}"
 

commit 219af135a164df2e8d40cf323405bdde7a46dcd3
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Mon Nov 21 00:18:38 2022 +0000

    Daily bump.

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 958ad90871b..8ec025af871 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,11 @@
+2022-11-19  Thomas Schwinge  <thomas@codesourcery.com>
+
+	Backported from master:
+	2022-11-19  Thomas Schwinge  <thomas@codesourcery.com>
+
+	* config/nvptx/nvptx.h (STARTFILE_SPEC): Fix 'crt0.o' for
+	'-mmainkernel'.
+
 2022-11-14  Richard Biener  <rguenther@suse.de>
 
 	PR tree-optimization/107485
diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 578404781e6..b4f44f494dc 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20221118
+20221121

commit f375e2ff70949797ebcc181791335de4cb18752a
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Tue Nov 22 00:19:23 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index b4f44f494dc..00ec7aeeb71 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20221121
+20221122

commit 9ac62320d46036c19bc1d54eb54d5ef839d9ae74
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Wed Nov 23 00:18:56 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 00ec7aeeb71..e3e7816b4ea 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20221122
+20221123

commit 187c235b65c3c23bbbcef6ece4343dc924c5d60c
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Thu Nov 24 00:19:27 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index e3e7816b4ea..059dd7f104c 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20221123
+20221124

commit ac5044574cc4edbd43aacb09461bbaa0cedc684b
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Fri Nov 25 10:04:59 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 059dd7f104c..9fb04058de4 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20221124
+20221125

commit b3b48f883d31910f2672640de2f5ff59e765488c
Author: Harald Anlauf <anlauf@gmx.de>
Date:   Thu Nov 17 21:36:49 2022 +0100

    Fortran: reject NULL actual argument without explicit interface [PR107576]
    
    gcc/fortran/ChangeLog:
    
            PR fortran/107576
            * interface.c (gfc_procedure_use): Reject NULL as actual argument
            when there is no explicit procedure interface.
    
    gcc/testsuite/ChangeLog:
    
            PR fortran/107576
            * gfortran.dg/null_actual_3.f90: New test.
    
    (cherry picked from commit 820c25c83561085f54268bd536f9d216d03c3e18)

diff --git a/gcc/fortran/interface.c b/gcc/fortran/interface.c
index a8a88f19908..19ba7fd65dc 100644
--- a/gcc/fortran/interface.c
+++ b/gcc/fortran/interface.c
@@ -3968,6 +3968,14 @@ gfc_procedure_use (gfc_symbol *sym, gfc_actual_arglist **ap, locus *where)
 	      return false;
 	    }
 
+	  if (a->expr && a->expr->expr_type == EXPR_NULL)
+	    {
+	      gfc_error ("Passing intrinsic NULL as actual argument at %L "
+			 "requires an explicit interface", &a->expr->where);
+	      a->expr->error = 1;
+	      return false;
+	    }
+
 	  /* TS 29113, C407b.  */
 	  if (a->expr && a->expr->expr_type == EXPR_VARIABLE
 	      && symbol_rank (a->expr->symtree->n.sym) == -1)
diff --git a/gcc/testsuite/gfortran.dg/null_actual_3.f90 b/gcc/testsuite/gfortran.dg/null_actual_3.f90
new file mode 100644
index 00000000000..ea49f9630c9
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/null_actual_3.f90
@@ -0,0 +1,18 @@
+! { dg-do compile }
+! { dg-options "-fallow-argument-mismatch -w" }
+! PR fortran/107576
+! Contributed by G.Steinmetz
+
+program p
+  implicit none
+  interface
+     subroutine r(y)
+       integer, pointer :: y(:)
+     end subroutine r
+  end interface
+  integer, pointer :: z(:) => null()
+  call r(z)
+  call s(z)
+  call r(null(z))
+  call s(null(z)) ! { dg-error "requires an explicit interface" }
+end

commit 4262d03754e3adee5ebad736f55bd4348f2a561e
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sat Nov 26 00:18:45 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 9fb04058de4..ba378581096 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20221125
+20221126
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 7bc801b0686..545420f2fba 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,12 @@
+2022-11-25  Harald Anlauf  <anlauf@gmx.de>
+
+	Backported from master:
+	2022-11-18  Harald Anlauf  <anlauf@gmx.de>
+
+	PR fortran/107576
+	* interface.c (gfc_procedure_use): Reject NULL as actual argument
+	when there is no explicit procedure interface.
+
 2022-10-28  Harald Anlauf  <anlauf@gmx.de>
 
 	Backported from master:
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index e13ba84e410..a231fedd48b 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,11 @@
+2022-11-25  Harald Anlauf  <anlauf@gmx.de>
+
+	Backported from master:
+	2022-11-18  Harald Anlauf  <anlauf@gmx.de>
+
+	PR fortran/107576
+	* gfortran.dg/null_actual_3.f90: New test.
+
 2022-11-18  Marek Polacek  <polacek@redhat.com>
 
 	Backported from master:

commit 329bba0da96d54882ada76e378a39a3eca1675a9
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sun Nov 27 00:18:23 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index ba378581096..251ffaa5998 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20221126
+20221127

commit ab94bf7258929121c2c598551b8471ed1175698a
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Mon Nov 28 00:18:35 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 251ffaa5998..bca26078d6e 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20221127
+20221128

commit c1422db9eb131cb4239e72255ec96781ec783eef
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Tue Nov 29 00:19:49 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index bca26078d6e..7063790611d 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20221128
+20221129

commit bd6963543042ce713d290c23e098de84865a287f
Author: Max Filippov <jcmvbkbc@gmail.com>
Date:   Mon Nov 7 13:58:49 2022 -0800

    gcc: fix PR rtl-optimization/107482
    
    gcc/
            PR rtl-optimization/107482
            * ira-color.c (assign_hard_reg): Only call
            update_costs_from_copies when retry_p is false.
    
    (cherry picked from commit e581490f0cfa80c58d2b648d71a44a597fbe3008)

diff --git a/gcc/ira-color.c b/gcc/ira-color.c
index b0fc159a849..c02af1f7181 100644
--- a/gcc/ira-color.c
+++ b/gcc/ira-color.c
@@ -1956,8 +1956,8 @@ assign_hard_reg (ira_allocno_t a, bool retry_p)
     restore_costs_from_copies (a);
   ALLOCNO_HARD_REGNO (a) = best_hard_regno;
   ALLOCNO_ASSIGNED_P (a) = true;
-  if (best_hard_regno >= 0)
-    update_costs_from_copies (a, true, ! retry_p);
+  if (best_hard_regno >= 0 && !retry_p)
+    update_costs_from_copies (a, true, true);
   ira_assert (ALLOCNO_CLASS (a) == aclass);
   /* We don't need updated costs anymore.  */
   ira_free_allocno_updated_costs (a);

commit ef70237843c7da4e45b0fe7c3cb81aceb9cd081e
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Wed Nov 30 00:19:15 2022 +0000

    Daily bump.

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 8ec025af871..2772999896b 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,12 @@
+2022-11-29  Max Filippov  <jcmvbkbc@gmail.com>
+
+	Backported from master:
+	2022-11-08  Max Filippov  <jcmvbkbc@gmail.com>
+
+	PR rtl-optimization/107482
+	* ira-color.c (assign_hard_reg): Only call
+	update_costs_from_copies when retry_p is false.
+
 2022-11-19  Thomas Schwinge  <thomas@codesourcery.com>
 
 	Backported from master:
diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 7063790611d..e6a7597e85b 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20221129
+20221130

commit 2391ea007f291b12c6602b7fd71bb92b7c945752
Author: John David Anglin <danglin@gcc.gnu.org>
Date:   Wed Nov 30 18:40:10 2022 +0000

    Fix addvdi3 and subvdi3 patterns
    
    While most PA 2.0 instructions support both 32 and 64-bit traps
    and conditions, the addi and subi instructions only support 32-bit
    traps and conditions. Thus, we need to force immediate operands
    to register operands on the 64-bit target and use the add/sub
    instructions which can trap on 64-bit signed overflow.
    
    2022-11-30  John David Anglin  <danglin@gcc.gnu.org>
    
    gcc/ChangeLog:
    
            * config/pa/pa.md (addvdi3): Force operand 2 to a register.
            Remove "addi,tsv,*" instruction from unamed pattern.
            (subvdi3): Force operand 1 to a register.
            Remove "subi,tsv" instruction from from unamed pattern.

diff --git a/gcc/config/pa/pa.md b/gcc/config/pa/pa.md
index 1803c66cd21..770befc908b 100644
--- a/gcc/config/pa/pa.md
+++ b/gcc/config/pa/pa.md
@@ -5071,23 +5071,25 @@
 						    (match_dup 2))))
 		       (const_int 0))])]
   ""
-  "")
+  "
+{
+  if (TARGET_64BIT)
+    operands[2] = force_reg (DImode, operands[2]);
+}")
 
 (define_insn ""
-  [(set (match_operand:DI 0 "register_operand" "=r,r")
-	(plus:DI (match_operand:DI 1 "reg_or_0_operand" "%rM,rM")
-		 (match_operand:DI 2 "arith11_operand" "r,I")))
+  [(set (match_operand:DI 0 "register_operand" "=r")
+	(plus:DI (match_operand:DI 1 "reg_or_0_operand" "%rM")
+		 (match_operand:DI 2 "register_operand" "r")))
    (trap_if (ne (plus:TI (sign_extend:TI (match_dup 1))
 			 (sign_extend:TI (match_dup 2)))
 		(sign_extend:TI (plus:DI (match_dup 1)
 					 (match_dup 2))))
 	    (const_int 0))]
   "TARGET_64BIT"
-  "@
-  add,tsv,* %2,%1,%0
-  addi,tsv,* %2,%1,%0"
-  [(set_attr "type" "binary,binary")
-   (set_attr "length" "4,4")])
+  "add,tsv,* %2,%1,%0"
+  [(set_attr "type" "binary")
+   (set_attr "length" "4")])
 
 (define_insn ""
   [(set (match_operand:DI 0 "register_operand" "=r")
@@ -5262,23 +5264,25 @@
 						     (match_dup 2))))
 		       (const_int 0))])]
   ""
-  "")
+  "
+{
+  if (TARGET_64BIT)
+    operands[1] = force_reg (DImode, operands[1]);
+}")
 
 (define_insn ""
-  [(set (match_operand:DI 0 "register_operand" "=r,r")
-	(minus:DI (match_operand:DI 1 "arith11_operand" "r,I")
-		  (match_operand:DI 2 "reg_or_0_operand" "rM,rM")))
+  [(set (match_operand:DI 0 "register_operand" "=r")
+	(minus:DI (match_operand:DI 1 "register_operand" "r")
+		  (match_operand:DI 2 "reg_or_0_operand" "rM")))
    (trap_if (ne (minus:TI (sign_extend:TI (match_dup 1))
 			  (sign_extend:TI (match_dup 2)))
 		(sign_extend:TI (minus:DI (match_dup 1)
 					  (match_dup 2))))
 	    (const_int 0))]
   "TARGET_64BIT"
-  "@
-  {subo|sub,tsv} %1,%2,%0
-  {subio|subi,tsv} %1,%2,%0"
-  [(set_attr "type" "binary,binary")
-   (set_attr "length" "4,4")])
+  "sub,tsv,* %1,%2,%0"
+  [(set_attr "type" "binary")
+   (set_attr "length" "4")])
 
 (define_insn ""
   [(set (match_operand:DI 0 "register_operand" "=r,&r")

commit f3cfcde3d69e2e8d305c4d4d662a26cd25e8398c
Author: Iain Buclaw <ibuclaw@gdcproject.org>
Date:   Sat Nov 12 00:54:47 2022 +0100

    d: Fix ICE on named continue label in an unrolled loop [PR107592]
    
    Continue labels in an unrolled loop require a unique label per
    iteration.  Previously this used the Statement body node for each
    unrolled iteration to generate a new entry in the label hash table.
    This does not work when the continue label has an identifier, as said
    named label is pointing to the outer UnrolledLoopStatement node.
    
    What would happen is that during the lowering of `continue label', an
    automatic label associated with the unrolled loop would be generated,
    and a jump to that label inserted, but because it was never pushed by
    the visitor for the loop itself, it subsequently never gets emitted.
    
    To fix, correctly use the UnrolledLoopStatement as the key to look up
    and store the break/continue label pair, but remove the continue label
    from the value entry after every loop to force a new label to be
    generated by the next call to `push_continue_label'
    
            PR d/107592
    
    gcc/d/ChangeLog:
    
            * toir.cc (IRVisitor::push_unrolled_continue_label): New method.
            (IRVisitor::pop_unrolled_continue_label): New method.
            (IRVisitor::visit (UnrolledLoopStatement *)): Use them instead of
            push_continue_label and pop_continue_label.
    
    gcc/testsuite/ChangeLog:
    
            * gdc.dg/pr107592.d: New test.
    
    (cherry picked from commit 031d3f095520f0e1ee03e29b7ad5067c2a3f96e0)

diff --git a/gcc/d/toir.cc b/gcc/d/toir.cc
index 074cde0e0da..559f79da6c2 100644
--- a/gcc/d/toir.cc
+++ b/gcc/d/toir.cc
@@ -540,6 +540,28 @@ public:
     this->do_label (label);
   }
 
+  /* Generate and set a new continue label for the current unrolled loop.  */
+
+  void push_unrolled_continue_label (UnrolledLoopStatement *s)
+  {
+    this->push_continue_label (s);
+  }
+
+  /* Finish with the continue label for the unrolled loop.  */
+
+  void pop_unrolled_continue_label (UnrolledLoopStatement *s)
+  {
+    Statement *stmt = s->getRelatedLabeled ();
+    d_label_entry *ent = d_function_chain->labels->get (stmt);
+    gcc_assert (ent != NULL && ent->bc_label == true);
+
+    this->pop_continue_label (TREE_VEC_ELT (ent->label, bc_continue));
+
+    /* Remove the continue label from the label htab, as a new one must be
+       inserted at the end of every unrolled loop.  */
+    ent->label = TREE_VEC_ELT (ent->label, bc_break);
+  }
+
   /* Visitor interfaces.  */
 
 
@@ -1076,9 +1098,9 @@ public:
 
 	if (statement != NULL)
 	  {
-	    tree lcontinue = this->push_continue_label (statement);
+	    this->push_unrolled_continue_label (s);
 	    this->build_stmt (statement);
-	    this->pop_continue_label (lcontinue);
+	    this->pop_unrolled_continue_label (s);
 	  }
       }
 
diff --git a/gcc/testsuite/gdc.dg/pr107592.d b/gcc/testsuite/gdc.dg/pr107592.d
new file mode 100644
index 00000000000..59f34477356
--- /dev/null
+++ b/gcc/testsuite/gdc.dg/pr107592.d
@@ -0,0 +1,13 @@
+// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107592
+// { dg-do compile }
+
+void test107592(Things...)(Things things)
+{
+    label:
+    foreach (thing; things)
+    {
+        continue label;
+    }
+}
+
+alias a107592 = test107592!(string);

commit e73b8e2a42a17ae62507eeb0e4aa10682ed195ea
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Thu Dec 1 00:19:21 2022 +0000

    Daily bump.

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 2772999896b..61d8fb32bd2 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,10 @@
+2022-11-30  John David Anglin  <danglin@gcc.gnu.org>
+
+	* config/pa/pa.md (addvdi3): Force operand 2 to a register.
+	Remove "addi,tsv,*" instruction from unamed pattern.
+	(subvdi3): Force operand 1 to a register.
+	Remove "subi,tsv" instruction from from unamed pattern.
+
 2022-11-29  Max Filippov  <jcmvbkbc@gmail.com>
 
 	Backported from master:
diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index e6a7597e85b..f0a26d37c16 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20221130
+20221201
diff --git a/gcc/d/ChangeLog b/gcc/d/ChangeLog
index 84ea6930951..912c7f54114 100644
--- a/gcc/d/ChangeLog
+++ b/gcc/d/ChangeLog
@@ -1,3 +1,14 @@
+2022-11-30  Iain Buclaw  <ibuclaw@gdcproject.org>
+
+	Backported from master:
+	2022-11-30  Iain Buclaw  <ibuclaw@gdcproject.org>
+
+	PR d/107592
+	* toir.cc (IRVisitor::push_unrolled_continue_label): New method.
+	(IRVisitor::pop_unrolled_continue_label): New method.
+	(IRVisitor::visit (UnrolledLoopStatement *)): Use them instead of
+	push_continue_label and pop_continue_label.
+
 2022-08-16  Iain Buclaw  <ibuclaw@gdcproject.org>
 
 	Backported from master:
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index a231fedd48b..8becfa9a7df 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,11 @@
+2022-11-30  Iain Buclaw  <ibuclaw@gdcproject.org>
+
+	Backported from master:
+	2022-11-30  Iain Buclaw  <ibuclaw@gdcproject.org>
+
+	PR d/107592
+	* gdc.dg/pr107592.d: New test.
+
 2022-11-25  Harald Anlauf  <anlauf@gmx.de>
 
 	Backported from master:

commit ac30c91a1002ae4049a4773d07d5da41e7bd3138
Author: liuhongt <hongtao.liu@intel.com>
Date:   Mon Nov 28 09:59:47 2022 +0800

    Fix unrecognizable insn due to illegal immediate_operand (const_int 255) of QImode.
    
    For __builtin_ia32_vec_set_v16qi (a, -1, 2) with
    !flag_signed_char. it's transformed to
    __builtin_ia32_vec_set_v16qi (_4, 255, 2) in the gimple,
    and expanded to (const_int 255) in the rtl. But for immediate_operand,
    it expects (const_int 255) to be signed extended to
    (const_int -1). The mismatch caused an unrecognizable insn error.
    
    The patch converts (const_int 255) to (const_int -1) in the backend
    expander.
    
    gcc/ChangeLog:
    
            PR target/107863
            * config/i386/i386-expand.c (ix86_expand_vec_set_builtin):
            Convert op1 to target mode whenever mode mismatch.
    
    gcc/testsuite/ChangeLog:
    
            * gcc.target/i386/pr107863.c: New test.

diff --git a/gcc/config/i386/i386-expand.c b/gcc/config/i386/i386-expand.c
index 6075532b8c9..15ea243503a 100644
--- a/gcc/config/i386/i386-expand.c
+++ b/gcc/config/i386/i386-expand.c
@@ -10955,7 +10955,7 @@ ix86_expand_vec_set_builtin (tree exp)
   op1 = expand_expr (arg1, NULL_RTX, mode1, EXPAND_NORMAL);
   elt = get_element_number (TREE_TYPE (arg0), arg2);
 
-  if (GET_MODE (op1) != mode1 && GET_MODE (op1) != VOIDmode)
+  if (GET_MODE (op1) != mode1)
     op1 = convert_modes (mode1, GET_MODE (op1), op1, true);
 
   op0 = force_reg (tmode, op0);
diff --git a/gcc/testsuite/gcc.target/i386/pr107863.c b/gcc/testsuite/gcc.target/i386/pr107863.c
new file mode 100644
index 00000000000..99fd85d9765
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr107863.c
@@ -0,0 +1,8 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx2 -O" } */
+
+typedef char v16qi __attribute__((vector_size(16)));
+
+v16qi foo(v16qi a){
+  return __builtin_ia32_vec_set_v16qi (a, -1, 2);
+}

commit 157506f599608570aec23aa1c8f994de294d2cf0
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Fri Dec 2 00:19:40 2022 +0000

    Daily bump.

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 61d8fb32bd2..d6558fe2775 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2022-12-01  liuhongt  <hongtao.liu@intel.com>
+
+	PR target/107863
+	* config/i386/i386-expand.c (ix86_expand_vec_set_builtin):
+	Convert op1 to target mode whenever mode mismatch.
+
 2022-11-30  John David Anglin  <danglin@gcc.gnu.org>
 
 	* config/pa/pa.md (addvdi3): Force operand 2 to a register.
diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index f0a26d37c16..c7106babaa0 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20221201
+20221202
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 8becfa9a7df..5e106d555c0 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2022-12-01  liuhongt  <hongtao.liu@intel.com>
+
+	* gcc.target/i386/pr107863.c: New test.
+
 2022-11-30  Iain Buclaw  <ibuclaw@gdcproject.org>
 
 	Backported from master:

commit b6dd9fe312cd982b17cc804521cc32c1ccc35597
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sat Dec 3 00:19:14 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index c7106babaa0..7a1b14a57f3 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20221202
+20221203

commit c46d69edc1f4690a48de5c21ab462b073b0fe6c3
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sun Dec 4 00:18:46 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 7a1b14a57f3..1638a1245b8 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20221203
+20221204

commit 6a5fff5c8872853b70a14ecec2480531a739c5c0
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Mon Dec 5 00:19:42 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 1638a1245b8..fac0e17b9fa 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20221204
+20221205

commit 461e74b0c52522ca7be9c0b71057b808d9165970
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Tue Dec 6 00:19:24 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index fac0e17b9fa..b55757e1766 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20221205
+20221206

commit de173b049ac05dac16bac18fcf8bfa0b80cf7ae0
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Wed Dec 7 00:20:17 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index b55757e1766..ec18fda0770 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20221206
+20221207

commit 76365279b6a76f6c9459409ed71737629db90cb2
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Thu Dec 8 00:19:24 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index ec18fda0770..1e6c6156d44 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20221207
+20221208

commit bd0033309c90a4f278d19dacf1343e5c9f3723be
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Fri Dec 9 00:20:37 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 1e6c6156d44..6f787fd296d 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20221208
+20221209

commit c89e7f8a7110fe041e426005a3e13beecfc97f02
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sat Dec 10 00:19:35 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 6f787fd296d..039ae27f009 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20221209
+20221210

commit e5aeaae1018be412eb460374d0b54d312a4db05a
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sun Dec 11 00:19:25 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 039ae27f009..0706710bce8 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20221210
+20221211

commit 9d18a4b98d9b6bff4ba8b215f1e66e51ffba9638
Author: Iain Buclaw <ibuclaw@gdcproject.org>
Date:   Sat Dec 10 19:12:43 2022 +0100

    d: Fix internal compiler error: in visit, at d/imports.cc:72 (PR108050)
    
    The visitor for lowering IMPORTED_DECLs did not have an override for
    dealing with importing OverloadSet symbols.  This has now been
    implemented in the code generator.
    
            PR d/108050
    
    gcc/d/ChangeLog:
    
            * decl.cc (DeclVisitor::visit (Import *)): Handle build_import_decl
            returning a TREE_LIST.
            * imports.cc (ImportVisitor::visit (OverloadSet *)): New override.
    
    gcc/testsuite/ChangeLog:
    
            * gdc.dg/imports/pr108050/mod1.d: New.
            * gdc.dg/imports/pr108050/mod2.d: New.
            * gdc.dg/imports/pr108050/package.d: New.
            * gdc.dg/pr108050.d: New test.
    
    (cherry picked from commit d9d8c9674ad3ad3aa38419d24b1aaaffe31f5d3f)

diff --git a/gcc/d/decl.cc b/gcc/d/decl.cc
index 94f941f65a3..b9078b235c7 100644
--- a/gcc/d/decl.cc
+++ b/gcc/d/decl.cc
@@ -181,8 +181,16 @@ public:
 	    tree name = (alias != NULL)
 	      ? get_identifier (alias->toChars ()) : NULL_TREE;
 
-	    debug_hooks->imported_module_or_decl (decl, name, context,
-						  false, false);
+	    if (TREE_CODE (decl) != TREE_LIST)
+	      debug_hooks->imported_module_or_decl (decl, name, context,
+						    false, false);
+	    else
+	      {
+		/* Overload sets return a list of imported decls.  */
+		for (; decl != NULL_TREE; decl = TREE_CHAIN (decl))
+		  debug_hooks->imported_module_or_decl (TREE_VALUE (decl), name,
+							context, false, false);
+	      }
 	  }
       }
     else
diff --git a/gcc/d/imports.cc b/gcc/d/imports.cc
index 2e3eb7408b7..e72f1ea00ac 100644
--- a/gcc/d/imports.cc
+++ b/gcc/d/imports.cc
@@ -157,6 +157,20 @@ public:
       }
   }
 
+  /* Build IMPORTED_DECLs for all overloads in a set.  */
+  void visit (OverloadSet *d)
+  {
+    vec<tree, va_gc> *tset = NULL;
+
+    vec_alloc (tset, d->a.dim);
+
+    for (size_t i = 0; i < d->a.dim; i++)
+      vec_safe_push (tset, build_import_decl (d->a[i]));
+
+    d->isym = build_tree_list_vec (tset);
+    tset->truncate (0);
+  }
+
   /* Function aliases are the same as alias symbols.  */
   void visit (FuncAliasDeclaration *d)
   {
diff --git a/gcc/testsuite/gdc.dg/imports/pr108050/mod1.d b/gcc/testsuite/gdc.dg/imports/pr108050/mod1.d
new file mode 100644
index 00000000000..f27a13dc051
--- /dev/null
+++ b/gcc/testsuite/gdc.dg/imports/pr108050/mod1.d
@@ -0,0 +1,2 @@
+module imports.pr108050.mod1;
+string[] split() { return null; }
diff --git a/gcc/testsuite/gdc.dg/imports/pr108050/mod2.d b/gcc/testsuite/gdc.dg/imports/pr108050/mod2.d
new file mode 100644
index 00000000000..29d8aa8f53e
--- /dev/null
+++ b/gcc/testsuite/gdc.dg/imports/pr108050/mod2.d
@@ -0,0 +1,2 @@
+module imports.pr108050.mod2;
+string[] split() { return null; }
diff --git a/gcc/testsuite/gdc.dg/imports/pr108050/package.d b/gcc/testsuite/gdc.dg/imports/pr108050/package.d
new file mode 100644
index 00000000000..b8b03b832af
--- /dev/null
+++ b/gcc/testsuite/gdc.dg/imports/pr108050/package.d
@@ -0,0 +1,2 @@
+module imports.pr108050;
+public import imports.pr108050.mod1, imports.pr108050.mod2;
diff --git a/gcc/testsuite/gdc.dg/pr108050.d b/gcc/testsuite/gdc.dg/pr108050.d
new file mode 100644
index 00000000000..69134e73137
--- /dev/null
+++ b/gcc/testsuite/gdc.dg/pr108050.d
@@ -0,0 +1,4 @@
+// { dg-do compile }
+// { dg-additional-sources "imports/pr108050/package.d imports/pr108050/mod1.d imports/pr108050/mod2.d" }
+// { dg-options "-g" }
+import imports.pr108050 : split;

commit 14d625453bfd16f276a3b1bbd636120c0f823892
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Mon Dec 12 00:25:08 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 0706710bce8..a8efd513898 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20221211
+20221212
diff --git a/gcc/d/ChangeLog b/gcc/d/ChangeLog
index 912c7f54114..2174a569bf8 100644
--- a/gcc/d/ChangeLog
+++ b/gcc/d/ChangeLog
@@ -1,3 +1,13 @@
+2022-12-11  Iain Buclaw  <ibuclaw@gdcproject.org>
+
+	Backported from master:
+	2022-12-11  Iain Buclaw  <ibuclaw@gdcproject.org>
+
+	PR d/108050
+	* decl.cc (DeclVisitor::visit (Import *)): Handle build_import_decl
+	returning a TREE_LIST.
+	* imports.cc (ImportVisitor::visit (OverloadSet *)): New override.
+
 2022-11-30  Iain Buclaw  <ibuclaw@gdcproject.org>
 
 	Backported from master:
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 5e106d555c0..559b868795c 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,14 @@
+2022-12-11  Iain Buclaw  <ibuclaw@gdcproject.org>
+
+	Backported from master:
+	2022-12-11  Iain Buclaw  <ibuclaw@gdcproject.org>
+
+	PR d/108050
+	* gdc.dg/imports/pr108050/mod1.d: New.
+	* gdc.dg/imports/pr108050/mod2.d: New.
+	* gdc.dg/imports/pr108050/package.d: New.
+	* gdc.dg/pr108050.d: New test.
+
 2022-12-01  liuhongt  <hongtao.liu@intel.com>
 
 	* gcc.target/i386/pr107863.c: New test.

commit d6e258859f7346a0d91cfa7fdd32cdc7abc268e7
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Tue Dec 13 00:19:31 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index a8efd513898..349ad3e1070 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20221212
+20221213

commit 6ac6008ad52d44b3090967ca2f8d0b4e4d9bf549
Author: Iain Buclaw <ibuclaw@gdcproject.org>
Date:   Tue Dec 13 23:54:22 2022 +0100

    libphobos: Fix std.path.expandTilde raising onOutOfMemory
    
    Fixes std.path.expandTilde erroneously raising onOutOfMemory after
    failed call to `getpwnam_r()'.
    
    libphobos/ChangeLog:
    
            * src/std/path.d (expandTilde): Handle more errno codes that could be
            left set by getpwnam_r.

diff --git a/libphobos/src/std/path.d b/libphobos/src/std/path.d
index 4a435efba6c..d250953ee1c 100644
--- a/libphobos/src/std/path.d
+++ b/libphobos/src/std/path.d
@@ -3850,7 +3850,7 @@ string expandTilde(string inputPath) nothrow
     version (Posix)
     {
         import core.exception : onOutOfMemoryError;
-        import core.stdc.errno : errno, ERANGE;
+        import core.stdc.errno : errno, EBADF, ENOENT, EPERM, ERANGE, ESRCH;
         import core.stdc.stdlib : malloc, free, realloc;
 
         /*  Joins a path from a C string to the remainder of path.
@@ -3950,7 +3950,7 @@ string expandTilde(string inputPath) nothrow
                 scope(exit) free(extra_memory);
 
                 passwd result;
-                while (1)
+                loop: while (1)
                 {
                     extra_memory = cast(char*) realloc(extra_memory, extra_memory_size * char.sizeof);
                     if (extra_memory == null)
@@ -3969,10 +3969,23 @@ string expandTilde(string inputPath) nothrow
                         break;
                     }
 
-                    if (errno != ERANGE &&
+                    switch (errno)
+                    {
+                        case ERANGE:
                         // On BSD and OSX, errno can be left at 0 instead of set to ERANGE
-                        errno != 0)
-                        onOutOfMemoryError();
+                        case 0:
+                            break;
+
+                        case ENOENT:
+                        case ESRCH:
+                        case EBADF:
+                        case EPERM:
+                            // The given name or uid was not found.
+                            break loop;
+
+                        default:
+                            onOutOfMemoryError();
+                    }
 
                     // extra_memory isn't large enough
                     import core.checkedint : mulu;

commit 98224a2fb7a48ac1924e93105b44d03f64dd8547
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Wed Dec 14 00:20:21 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 349ad3e1070..fb5d5da64c6 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20221213
+20221214
diff --git a/libphobos/ChangeLog b/libphobos/ChangeLog
index 267655ac5e3..39a298cd374 100644
--- a/libphobos/ChangeLog
+++ b/libphobos/ChangeLog
@@ -1,3 +1,8 @@
+2022-12-13  Iain Buclaw  <ibuclaw@gdcproject.org>
+
+	* src/std/path.d (expandTilde): Handle more errno codes that could be
+	left set by getpwnam_r.
+
 2022-06-28  Release Manager
 
 	* GCC 10.4.0 released.

commit b0ca8c23ebc478b602d3f4e011f440e2e28f307a
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Thu Dec 15 00:18:30 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index fb5d5da64c6..414c306c21c 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20221214
+20221215

commit 59bba6f9dc6dcfefe96e6fad677614f39928564e
Author: Sebastian Pop <spop@amazon.com>
Date:   Wed Nov 30 19:45:24 2022 +0000

    AArch64: Add UNSPECV_PATCHABLE_AREA [PR98776]
    
    Currently patchable area is at the wrong place on AArch64.  It is placed
    immediately after function label, before .cfi_startproc.  This patch
    adds UNSPECV_PATCHABLE_AREA for pseudo patchable area instruction and
    modifies aarch64_print_patchable_function_entry to avoid placing
    patchable area before .cfi_startproc.
    
    gcc/
            PR target/98776
            * config/aarch64/aarch64-protos.h (aarch64_output_patchable_area):
            Declared.
            * config/aarch64/aarch64.c (aarch64_print_patchable_function_entry):
            Emit an UNSPECV_PATCHABLE_AREA pseudo instruction.
            (aarch64_output_patchable_area): New.
            * config/aarch64/aarch64.md (UNSPECV_PATCHABLE_AREA): New.
            (patchable_area): Define.
    
    gcc/testsuite/
            PR target/98776
            * gcc.target/aarch64/pr98776.c: New.
            * gcc.target/aarch64/pr92424-2.c: Adjust pattern.
            * gcc.target/aarch64/pr92424-3.c: Adjust pattern.

diff --git a/gcc/config/aarch64/aarch64-protos.h b/gcc/config/aarch64/aarch64-protos.h
index 61e2ad54f88..ef24c48fc14 100644
--- a/gcc/config/aarch64/aarch64-protos.h
+++ b/gcc/config/aarch64/aarch64-protos.h
@@ -805,4 +805,6 @@ const char *aarch64_indirect_call_asm (rtx);
 extern bool aarch64_harden_sls_retbr_p (void);
 extern bool aarch64_harden_sls_blr_p (void);
 
+extern void aarch64_output_patchable_area (unsigned int, bool);
+
 #endif /* GCC_AARCH64_PROTOS_H */
diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
index 67c2f1123b4..dd9a3832b5a 100644
--- a/gcc/config/aarch64/aarch64.c
+++ b/gcc/config/aarch64/aarch64.c
@@ -19498,30 +19498,56 @@ aarch64_declare_function_name (FILE *stream, const char* name,
   cfun->machine->label_is_assembled = true;
 }
 
-/* Implement PRINT_PATCHABLE_FUNCTION_ENTRY.  Check if the patch area is after
-   the function label and emit a BTI if necessary.  */
+/* Implement PRINT_PATCHABLE_FUNCTION_ENTRY.  */
 
 void
 aarch64_print_patchable_function_entry (FILE *file,
 					unsigned HOST_WIDE_INT patch_area_size,
 					bool record_p)
 {
-  if (cfun->machine->label_is_assembled
-      && aarch64_bti_enabled ()
-      && !cgraph_node::get (cfun->decl)->only_called_directly_p ())
+  if (!cfun->machine->label_is_assembled)
     {
-      /* Remove the BTI that follows the patch area and insert a new BTI
-	 before the patch area right after the function label.  */
-      rtx_insn *insn = next_real_nondebug_insn (get_insns ());
-      if (insn
-	  && INSN_P (insn)
-	  && GET_CODE (PATTERN (insn)) == UNSPEC_VOLATILE
-	  && XINT (PATTERN (insn), 1) == UNSPECV_BTI_C)
-	delete_insn (insn);
-      asm_fprintf (file, "\thint\t34 // bti c\n");
+      /* Emit the patching area before the entry label, if any.  */
+      default_print_patchable_function_entry (file, patch_area_size,
+					      record_p);
+      return;
+    }
+
+  rtx pa = gen_patchable_area (GEN_INT (patch_area_size),
+			       GEN_INT (record_p));
+  basic_block bb = ENTRY_BLOCK_PTR_FOR_FN (cfun)->next_bb;
+
+  if (!aarch64_bti_enabled ()
+      || cgraph_node::get (cfun->decl)->only_called_directly_p ())
+    {
+      /* Emit the patchable_area at the beginning of the function.  */
+      rtx_insn *insn = emit_insn_before (pa, BB_HEAD (bb));
+      INSN_ADDRESSES_NEW (insn, -1);
+      return;
+    }
+
+  rtx_insn *insn = next_real_nondebug_insn (get_insns ());
+  if (!insn
+      || !INSN_P (insn)
+      || GET_CODE (PATTERN (insn)) != UNSPEC_VOLATILE
+      || XINT (PATTERN (insn), 1) != UNSPECV_BTI_C)
+    {
+      /* Emit a BTI_C.  */
+      insn = emit_insn_before (gen_bti_c (), BB_HEAD (bb));
     }
 
-  default_print_patchable_function_entry (file, patch_area_size, record_p);
+  /* Emit the patchable_area after BTI_C.  */
+  insn = emit_insn_after (pa, insn);
+  INSN_ADDRESSES_NEW (insn, -1);
+}
+
+/* Output patchable area.  */
+
+void
+aarch64_output_patchable_area (unsigned int patch_area_size, bool record_p)
+{
+  default_print_patchable_function_entry (asm_out_file, patch_area_size,
+					  record_p);
 }
 
 /* Implement ASM_OUTPUT_DEF_FROM_DECLS.  Output .variant_pcs for aliases.  */
diff --git a/gcc/config/aarch64/aarch64.md b/gcc/config/aarch64/aarch64.md
index 552aed3ce89..96e72bc6c06 100644
--- a/gcc/config/aarch64/aarch64.md
+++ b/gcc/config/aarch64/aarch64.md
@@ -282,6 +282,7 @@
     UNSPEC_TAG_SPACE		; Translate address to MTE tag address space.
     UNSPEC_LD1RO
     UNSPEC_SALT_ADDR
+    UNSPECV_PATCHABLE_AREA
 ])
 
 (define_c_enum "unspecv" [
@@ -7606,6 +7607,19 @@
   [(set_attr "type" "memtag")]
 )
 
+(define_insn "patchable_area"
+  [(unspec_volatile [(match_operand 0 "const_int_operand")
+		     (match_operand 1 "const_int_operand")]
+		    UNSPECV_PATCHABLE_AREA)]
+  ""
+{
+  aarch64_output_patchable_area (INTVAL (operands[0]),
+			         INTVAL (operands[1]) != 0);
+  return "";
+}
+  [(set (attr "length") (symbol_ref "INTVAL (operands[0])"))]
+)
+
 ;; AdvSIMD Stuff
 (include "aarch64-simd.md")
 
diff --git a/gcc/testsuite/gcc.target/aarch64/pr92424-2.c b/gcc/testsuite/gcc.target/aarch64/pr92424-2.c
index 0e75657a153..86bb92e6f32 100644
--- a/gcc/testsuite/gcc.target/aarch64/pr92424-2.c
+++ b/gcc/testsuite/gcc.target/aarch64/pr92424-2.c
@@ -9,4 +9,4 @@ __attribute__ ((target("branch-protection=bti"),
 f10_bti ()
 {
 }
-/* { dg-final { scan-assembler "f10_bti:\n\thint\t34 // bti c\n.*\.LPFE1:\n\tnop\n.*\tret\n" } } */
+/* { dg-final { scan-assembler "hint\t34 // bti c\n.*\.LPFE1:\n\tnop\n.*\tret\n" } } */
diff --git a/gcc/testsuite/gcc.target/aarch64/pr92424-3.c b/gcc/testsuite/gcc.target/aarch64/pr92424-3.c
index 0a1f74d4096..daac2faf18e 100644
--- a/gcc/testsuite/gcc.target/aarch64/pr92424-3.c
+++ b/gcc/testsuite/gcc.target/aarch64/pr92424-3.c
@@ -9,4 +9,4 @@ __attribute__ ((target("branch-protection=bti+pac-ret+leaf"),
 f10_pac ()
 {
 }
-/* { dg-final { scan-assembler "f10_pac:\n\thint\t34 // bti c\n.*\.LPFE1:\n\tnop\n.*\thint\t25 // paciasp\n.*\thint\t29 // autiasp\n.*\tret\n" } } */
+/* { dg-final { scan-assembler "hint\t34 // bti c\n.*\.LPFE1:\n\tnop\n.*\thint\t25 // paciasp\n.*\thint\t29 // autiasp\n.*\tret\n" } } */
diff --git a/gcc/testsuite/gcc.target/aarch64/pr98776.c b/gcc/testsuite/gcc.target/aarch64/pr98776.c
new file mode 100644
index 00000000000..d193df8e66d
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/pr98776.c
@@ -0,0 +1,11 @@
+/* { dg-do "compile" } */
+/* { dg-options "-O1 -fpatchable-function-entry=1 -fasynchronous-unwind-tables" } */
+
+/* Test the placement of the .LPFE1 label.  */
+
+void
+foo (void)
+{
+}
+
+/* { dg-final { scan-assembler "\t\.cfi_startproc\n.*\.LPFE1:\n\tnop\n\tret\n" } } */

commit 8325cc7cfabd767a7d1c3390db6ce696c89c8562
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Fri Dec 16 00:18:46 2022 +0000

    Daily bump.

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index d6558fe2775..0493e97dba2 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,14 @@
+2022-12-15  Sebastian Pop  <spop@amazon.com>
+
+	PR target/98776
+	* config/aarch64/aarch64-protos.h (aarch64_output_patchable_area):
+	Declared.
+	* config/aarch64/aarch64.c (aarch64_print_patchable_function_entry):
+	Emit an UNSPECV_PATCHABLE_AREA pseudo instruction.
+	(aarch64_output_patchable_area): New.
+	* config/aarch64/aarch64.md (UNSPECV_PATCHABLE_AREA): New.
+	(patchable_area): Define.
+
 2022-12-01  liuhongt  <hongtao.liu@intel.com>
 
 	PR target/107863
diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 414c306c21c..0891de734e9 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20221215
+20221216
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 559b868795c..43d2839ebac 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,10 @@
+2022-12-15  Sebastian Pop  <spop@amazon.com>
+
+	PR target/98776
+	* gcc.target/aarch64/pr98776.c: New.
+	* gcc.target/aarch64/pr92424-2.c: Adjust pattern.
+	* gcc.target/aarch64/pr92424-3.c: Adjust pattern.
+
 2022-12-11  Iain Buclaw  <ibuclaw@gdcproject.org>
 
 	Backported from master:

commit 16605ad9b1e1a6c5aab2c98b5b0f995285584f81
Author: Patrick Palka <ppalka@redhat.com>
Date:   Thu Oct 28 10:05:14 2021 -0400

    c++: quadratic constexpr behavior for left-assoc logical exprs [PR102780]
    
    In the testcase below the two left fold expressions each expand into a
    constant logical expression with 1024 terms, for which potential_const_expr
    takes more than a minute to return true.  This happens because p_c_e_1
    performs trial evaluation of the first operand of a &&/|| in order to
    determine whether to consider the potentiality of the second operand.
    And because the expanded expression is left-associated, this trial
    evaluation causes p_c_e_1 to be quadratic in the number of terms of the
    expression.
    
    This patch fixes this quadratic behavior by making p_c_e_1 preemptively
    compute potentiality of the second operand of a &&/||, and perform trial
    evaluation of the first operand only if the second operand isn't
    potentially constant.  We must be careful to avoid emitting bogus
    diagnostics during the preemptive computation; to that end, we perform
    this shortcut only when tf_error is cleared, and when tf_error is set we
    now first check potentiality of the whole expression quietly and replay
    the check noisily for diagnostics.
    
    Apart from fixing the quadraticness for left-associated logical exprs,
    this change also reduces compile time for the libstdc++ testcase
    20_util/variant/87619.cc by about 15% even though our <variant> uses
    right folds instead of left folds.  Likewise for the testcase in the PR,
    for which compile time is reduced by 30%.  The reason for these speedups
    is that p_c_e_1 no longer performs expensive trial evaluation of each term
    of large constant logical expressions when determining their potentiality.
    
            PR c++/102780
            PR c++/108138
    
    gcc/cp/ChangeLog:
    
            * constexpr.c (potential_constant_expression_1) <case TRUTH_*_EXPR>:
            When tf_error isn't set, preemptively check potentiality of the
            second operand before performing trial evaluation of the first
            operand.
            (potential_constant_expression_1): When tf_error is set, first check
            potentiality quietly and return true if successful, otherwise
            proceed noisily to give errors.
    
    gcc/testsuite/ChangeLog:
    
            * g++.dg/cpp1z/fold13.C: New test.
    
    (cherry picked from commit 9927ecbb42d5be48fa933adc26f8601fab5007ca)

diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c
index 40066a3330f..369920eda90 100644
--- a/gcc/cp/constexpr.c
+++ b/gcc/cp/constexpr.c
@@ -8425,13 +8425,18 @@ potential_constant_expression_1 (tree t, bool want_rval, bool strict, bool now,
       tmp = boolean_false_node;
     truth:
       {
-	tree op = TREE_OPERAND (t, 0);
-	if (!RECUR (op, rval))
+	tree op0 = TREE_OPERAND (t, 0);
+	tree op1 = TREE_OPERAND (t, 1);
+	if (!RECUR (op0, rval))
 	  return false;
+	if (!(flags & tf_error) && RECUR (op1, rval))
+	  /* When quiet, try to avoid expensive trial evaluation by first
+	     checking potentiality of the second operand.  */
+	  return true;
 	if (!processing_template_decl)
-	  op = cxx_eval_outermost_constant_expr (op, true);
-	if (tree_int_cst_equal (op, tmp))
-	  return RECUR (TREE_OPERAND (t, 1), rval);
+	  op0 = cxx_eval_outermost_constant_expr (op0, true);
+	if (tree_int_cst_equal (op0, tmp))
+	  return (flags & tf_error) ? RECUR (op1, rval) : false;
 	else
 	  return true;
       }
@@ -8611,6 +8616,17 @@ bool
 potential_constant_expression_1 (tree t, bool want_rval, bool strict, bool now,
 				 tsubst_flags_t flags)
 {
+  if (flags & tf_error)
+    {
+      /* Check potentiality quietly first, as that could be performed more
+	 efficiently in some cases (currently only for TRUTH_*_EXPR).  If
+	 that fails, replay the check noisily to give errors.  */
+      flags &= ~tf_error;
+      if (potential_constant_expression_1 (t, want_rval, strict, now, flags))
+	return true;
+      flags |= tf_error;
+    }
+
   tree target = NULL_TREE;
   return potential_constant_expression_1 (t, want_rval, strict, now,
 					  flags, &target);
diff --git a/gcc/testsuite/g++.dg/cpp1z/fold13.C b/gcc/testsuite/g++.dg/cpp1z/fold13.C
new file mode 100644
index 00000000000..9d7554f8999
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1z/fold13.C
@@ -0,0 +1,29 @@
+// { dg-do compile { target c++17 } }
+// Verify constexpr evaluation of a large left fold logical expression
+// isn't quadratic in the size of the expanded expression.
+
+template<int> struct S { static constexpr bool value = true; };
+
+template<class T, T...> struct integer_sequence { };
+
+template<class T, T N>
+using make_integer_sequence
+#if __has_builtin(__make_integer_seq)
+  = __make_integer_seq<integer_sequence, T, N>;
+#else
+  = integer_sequence<T, __integer_pack(N)...>;
+#endif
+
+template<int... Is>
+constexpr bool f_impl(integer_sequence<int, Is...>) {
+  return (... && S<Is>::value);
+}
+
+static_assert(f_impl(make_integer_sequence<int, 1024>()));
+
+template<int... Is>
+constexpr bool g_impl(integer_sequence<int, Is...>) {
+  return (... || !S<Is>::value);
+}
+
+static_assert(!g_impl(make_integer_sequence<int, 1024>()));

commit d4f398224f07fe01a5951d98ffdd3ee6243d5a19
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sat Dec 17 00:18:55 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 0891de734e9..ee0b6666b54 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20221216
+20221217
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 688c4e14f03..1c57627714a 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,18 @@
+2022-12-16  Patrick Palka  <ppalka@redhat.com>
+
+	Backported from master:
+	2021-10-28  Patrick Palka  <ppalka@redhat.com>
+
+	PR c++/102780
+	PR c++/108138
+	* constexpr.c (potential_constant_expression_1) <case TRUTH_*_EXPR>:
+	When tf_error isn't set, preemptively check potentiality of the
+	second operand before performing trial evaluation of the first
+	operand.
+	(potential_constant_expression_1): When tf_error is set, first check
+	potentiality quietly and return true if successful, otherwise
+	proceed noisily to give errors.
+
 2022-11-18  Marek Polacek  <polacek@redhat.com>
 
 	Backported from master:
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 43d2839ebac..3c034c8bf89 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,12 @@
+2022-12-16  Patrick Palka  <ppalka@redhat.com>
+
+	Backported from master:
+	2021-10-28  Patrick Palka  <ppalka@redhat.com>
+
+	PR c++/102780
+	PR c++/108138
+	* g++.dg/cpp1z/fold13.C: New test.
+
 2022-12-15  Sebastian Pop  <spop@amazon.com>
 
 	PR target/98776

commit e85a0a23873c09acb039973b27c573ec62ad5b77
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sun Dec 18 00:18:20 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index ee0b6666b54..8b45390a1dd 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20221217
+20221218

commit 6f2f588377e6437ae23fb83aa2c85e03e1f41678
Author: Paul Thomas <pault@gcc.gnu.org>
Date:   Fri Dec 9 22:13:45 2022 +0100

    Fortran: ICE on recursive derived types with allocatable components [PR107872]
    
    gcc/fortran/ChangeLog:
    
            PR fortran/107872
            * resolve.c (derived_inaccessible): Skip over allocatable components
            to prevent an infinite loop.
    
    gcc/testsuite/ChangeLog:
    
            PR fortran/107872
            * gfortran.dg/pr107872.f90: New test.
    
    (cherry picked from commit 01254aa2eb766c7584fd047568d7277d4d65d067)

diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c
index 15c88b23927..591d3b88227 100644
--- a/gcc/fortran/resolve.c
+++ b/gcc/fortran/resolve.c
@@ -7440,7 +7440,8 @@ derived_inaccessible (gfc_symbol *sym)
   for (c = sym->components; c; c = c->next)
     {
 	/* Prevent an infinite loop through this function.  */
-	if (c->ts.type == BT_DERIVED && c->attr.pointer
+	if (c->ts.type == BT_DERIVED
+	    && (c->attr.pointer || c->attr.allocatable)
 	    && sym == c->ts.u.derived)
 	  continue;
 
diff --git a/gcc/testsuite/gfortran.dg/pr107872.f90 b/gcc/testsuite/gfortran.dg/pr107872.f90
new file mode 100644
index 00000000000..09838479e92
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr107872.f90
@@ -0,0 +1,40 @@
+! { dg-do run }
+!
+! Test the fix for PR107872, where an ICE occurred in
+! resolve.cc(derived_inaccessible) because derived types with
+! recursive allocatable components were not catered for.
+!
+module mod1
+  type t
+     integer :: data
+     type(t), allocatable :: next
+   contains
+     procedure, private :: write_t
+     generic :: write(formatted) => write_t
+  end type
+contains
+  recursive subroutine write_t(this, unit, iotype, v_list, iostat, iomsg)
+    class(t), intent(in) :: this
+    integer, intent(in) :: unit
+    character(*), intent(in) :: iotype
+    integer, intent(in) :: v_list(:)
+    integer, intent(out) :: iostat
+    character(*), intent(inout) :: iomsg
+    if (ALLOCATED(this%next)) &
+         write (unit, '(dt)') this%next
+    write (unit, '(i2)') this%data
+  end subroutine
+end module
+
+  use mod1
+  type(t) :: a
+  character (8) :: buffer
+  a%data = 1
+  allocate (a%next)
+  a%next%data = 2
+  allocate (a%next%next)
+  a%next%next%data = 3
+  write (buffer, '(dt)')a
+  deallocate (a%next)
+  if (trim (buffer) .ne. ' 3 2 1') stop 1
+end

commit 1b00f6e75a8411cb4eacd0387648d297717c6c2e
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Mon Dec 19 00:19:04 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 8b45390a1dd..11fabd49cf9 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20221218
+20221219
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 545420f2fba..afc41fbe6a8 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,12 @@
+2022-12-18  Paul Thomas  <pault@gcc.gnu.org>
+
+	Backported from master:
+	2022-12-09  Paul Thomas  <pault@gcc.gnu.org>
+
+	PR fortran/107872
+	* resolve.c (derived_inaccessible): Skip over allocatable components
+	to prevent an infinite loop.
+
 2022-11-25  Harald Anlauf  <anlauf@gmx.de>
 
 	Backported from master:
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 3c034c8bf89..e3701cfde8e 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,11 @@
+2022-12-18  Paul Thomas  <pault@gcc.gnu.org>
+
+	Backported from master:
+	2022-12-09  Paul Thomas  <pault@gcc.gnu.org>
+
+	PR fortran/107872
+	* gfortran.dg/pr107872.f90: New test.
+
 2022-12-16  Patrick Palka  <ppalka@redhat.com>
 
 	Backported from master:

commit f8e22308f23ae570b574bb7f9fa512a8177e3a64
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Tue Dec 20 00:18:14 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 11fabd49cf9..142f05d4354 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20221219
+20221220

commit 8d215417945ebac3be8268531685b9553eed7cca
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Wed Dec 21 00:18:10 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 142f05d4354..1bcb133d5ce 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20221220
+20221221

commit 2d596c6d04ec9595178abb97709633b4e1d12ead
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Thu Dec 22 00:18:24 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 1bcb133d5ce..4bbb3ed7e34 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20221221
+20221222

commit f543f71c54be74256fb4ff7ab0142ffee55e999c
Author: Martin Liska <mliska@suse.cz>
Date:   Tue Aug 9 13:59:32 2022 +0200

    Factor out jobserver_active_p.
    
    gcc/ChangeLog:
    
            * gcc.c (driver::detect_jobserver): Remove and move to
            jobserver.h.
            * lto-wrapper.c (jobserver_active_p): Likewise.
            (run_gcc): Likewise.
            * opts-jobserver.h: New file.
            * opts-common.c (jobserver_info::jobserver_info): New function.
    
    (cherry picked from commit 1270ccda70ca09f7d4fe76b5156dca8992bd77a6)

diff --git a/gcc/gcc.c b/gcc/gcc.c
index 6d0f8570ab5..ed7099c2a6d 100644
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -27,6 +27,7 @@ CC recognizes how to compile each input file by suffixes in the file names.
 Once it knows which kind of compilation to perform, the procedure for
 compilation is specified by a string called a "spec".  */
 
+#define INCLUDE_STRING
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
@@ -43,6 +44,7 @@ compilation is specified by a string called a "spec".  */
 #include "opts.h"
 #include "filenames.h"
 #include "spellcheck.h"
+#include "opts-jobserver.h"
 
 
 
@@ -8399,38 +8401,9 @@ driver::final_actions () const
 void
 driver::detect_jobserver () const
 {
-  /* Detect jobserver and drop it if it's not working.  */
-  const char *makeflags = env.get ("MAKEFLAGS");
-  if (makeflags != NULL)
-    {
-      const char *needle = "--jobserver-auth=";
-      const char *n = strstr (makeflags, needle);
-      if (n != NULL)
-	{
-	  int rfd = -1;
-	  int wfd = -1;
-
-	  bool jobserver
-	    = (sscanf (n + strlen (needle), "%d,%d", &rfd, &wfd) == 2
-	       && rfd > 0
-	       && wfd > 0
-	       && is_valid_fd (rfd)
-	       && is_valid_fd (wfd));
-
-	  /* Drop the jobserver if it's not working now.  */
-	  if (!jobserver)
-	    {
-	      unsigned offset = n - makeflags;
-	      char *dup = xstrdup (makeflags);
-	      dup[offset] = '\0';
-
-	      const char *space = strchr (makeflags + offset, ' ');
-	      if (space != NULL)
-		strcpy (dup + offset, space);
-	      xputenv (concat ("MAKEFLAGS=", dup, NULL));
-	    }
-	}
-    }
+  jobserver_info jinfo;
+  if (!jinfo.is_active && !jinfo.skipped_makeflags.empty ())
+    xputenv (jinfo.skipped_makeflags.c_str ());
 }
 
 /* Determine what the exit code of the driver should be.  */
diff --git a/gcc/lto-wrapper.c b/gcc/lto-wrapper.c
index e01d1eada6c..f558b0eddb4 100644
--- a/gcc/lto-wrapper.c
+++ b/gcc/lto-wrapper.c
@@ -37,6 +37,7 @@ along with GCC; see the file COPYING3.  If not see
    ./ccCJuXGv.lto.ltrans.o
 */
 
+#define INCLUDE_STRING
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
@@ -48,6 +49,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "simple-object.h"
 #include "lto-section-names.h"
 #include "collect-utils.h"
+#include "opts-jobserver.h"
 
 /* Environment variable, used for passing the names of offload targets from GCC
    driver to lto-wrapper.  */
@@ -1295,32 +1297,6 @@ init_num_threads (void)
 #endif
 }
 
-/* FIXME: once using -std=c++11, we can use std::thread::hardware_concurrency.  */
-
-/* Return true when a jobserver is running and can accept a job.  */
-
-static bool
-jobserver_active_p (void)
-{
-  const char *makeflags = getenv ("MAKEFLAGS");
-  if (makeflags == NULL)
-    return false;
-
-  const char *needle = "--jobserver-auth=";
-  const char *n = strstr (makeflags, needle);
-  if (n == NULL)
-    return false;
-
-  int rfd = -1;
-  int wfd = -1;
-
-  return (sscanf (n + strlen (needle), "%d,%d", &rfd, &wfd) == 2
-	  && rfd > 0
-	  && wfd > 0
-	  && is_valid_fd (rfd)
-	  && is_valid_fd (wfd));
-}
-
 /* Execute gcc. ARGC is the number of arguments. ARGV contains the arguments. */
 
 static void
@@ -1535,10 +1511,20 @@ run_gcc (unsigned argc, char *argv[])
       auto_parallel = 0;
       parallel = 0;
     }
-  else if (!jobserver && jobserver_active_p ())
+  else
     {
-      parallel = 1;
-      jobserver = 1;
+      jobserver_info jinfo;
+      if (jobserver && !jinfo.is_active)
+	{
+	  warning (0, jinfo.error_msg.c_str ());
+	  parallel = 0;
+	  jobserver = 0;
+	}
+      else if (!jobserver && jinfo.is_active)
+	{
+	  parallel = 1;
+	  jobserver = 1;
+	}
     }
 
   if (linker_output)
@@ -1861,6 +1847,15 @@ cont:
       maybe_unlink (ltrans_output_file);
       ltrans_output_file = NULL;
 
+      if (nr > 1)
+	{
+	  jobserver_info jinfo;
+	  if (jobserver && !jinfo.is_active)
+	    warning (0, jinfo.error_msg.c_str ());
+	  else if (parallel == 0)
+	    warning (0, "using serial compilation of %d LTRANS jobs", nr);
+	}
+
       if (parallel)
 	{
 	  makefile = make_temp_file (".mk");
diff --git a/gcc/opts-common.c b/gcc/opts-common.c
index de9510abd64..04ae8d37a4d 100644
--- a/gcc/opts-common.c
+++ b/gcc/opts-common.c
@@ -17,6 +17,7 @@ You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING3.  If not see
 <http://www.gnu.org/licenses/>.  */
 
+#define INCLUDE_STRING
 #include "config.h"
 #include "system.h"
 #include "intl.h"
@@ -25,6 +26,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "options.h"
 #include "diagnostic.h"
 #include "spellcheck.h"
+#include "opts-jobserver.h"
 
 static void prune_options (struct cl_decoded_option **, unsigned int *);
 
@@ -1805,3 +1807,42 @@ void prepend_xassembler_to_collect_as_options (const char *collect_as_options,
       obstack_1grow (o, '\'');
     }
 }
+
+jobserver_info::jobserver_info ()
+{
+  /* Detect jobserver and drop it if it's not working.  */
+  string js_needle = "--jobserver-auth=";
+
+  const char *envval = getenv ("MAKEFLAGS");
+  if (envval != NULL)
+    {
+      string makeflags = envval;
+      size_t n = makeflags.rfind (js_needle);
+      if (n != string::npos)
+	{
+	  if (sscanf (makeflags.c_str () + n + js_needle.size (),
+		      "%d,%d", &rfd, &wfd) == 2
+	      && rfd > 0
+	      && wfd > 0
+	      && is_valid_fd (rfd)
+	      && is_valid_fd (wfd))
+	    is_active = true;
+	  else
+	    {
+	      string dup = makeflags.substr (0, n);
+	      size_t pos = makeflags.find (' ', n);
+	      if (pos != string::npos)
+		dup += makeflags.substr (pos);
+	      skipped_makeflags = "MAKEFLAGS=" + dup;
+	      error_msg
+		= "cannot access %<" + js_needle + "%> file descriptors";
+	    }
+	}
+      error_msg = "%<" + js_needle + "%> is not present in %<MAKEFLAGS%>";
+    }
+  else
+    error_msg = "%<MAKEFLAGS%> environment variable is unset";
+
+  if (!error_msg.empty ())
+    error_msg = "jobserver is not available: " + error_msg;
+}
diff --git a/gcc/opts-jobserver.h b/gcc/opts-jobserver.h
new file mode 100644
index 00000000000..68ce188b84a
--- /dev/null
+++ b/gcc/opts-jobserver.h
@@ -0,0 +1,44 @@
+/* GNU make's jobserver related functionality.
+   Copyright (C) 2022 Free Software Foundation, Inc.
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 3, or (at your option) any later
+version.
+
+GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING3.  If not see
+<http://www.gnu.org/licenses/>.
+
+See dbgcnt.def for usage information.  */
+
+#ifndef GCC_JOBSERVER_H
+#define GCC_JOBSERVER_H
+
+using namespace std;
+
+struct jobserver_info
+{
+  /* Default constructor.  */
+  jobserver_info ();
+
+  /* Error message if there is a problem.  */
+  string error_msg = "";
+  /* Skipped MAKEFLAGS where --jobserver-auth is skipped.  */
+  string skipped_makeflags = "";
+  /* File descriptor for reading used for jobserver communication.  */
+  int rfd = -1;
+  /* File descriptor for writing used for jobserver communication.  */
+  int wfd = -1;
+  /* Return true if jobserver is active.  */
+  bool is_active = false;
+};
+
+#endif /* GCC_JOBSERVER_H */

commit 51e819e99f3e800d2fb1cb22b4648e6d0558e35b
Author: Martin Liska <mliska@suse.cz>
Date:   Tue Aug 9 13:59:36 2022 +0200

    lto: support --jobserver-style=fifo for recent GNU make
    
    gcc/ChangeLog:
    
            * opts-jobserver.h: Add one member.
            * opts-common.c (jobserver_info::jobserver_info): Parse FIFO
            format of --jobserver-auth.
    
    (cherry picked from commit 53e3b2bf16a486c15c20991c6095f7be09012b55)

diff --git a/gcc/opts-common.c b/gcc/opts-common.c
index 04ae8d37a4d..e5d08047b52 100644
--- a/gcc/opts-common.c
+++ b/gcc/opts-common.c
@@ -1810,8 +1810,14 @@ void prepend_xassembler_to_collect_as_options (const char *collect_as_options,
 
 jobserver_info::jobserver_info ()
 {
+  /* Traditionally, GNU make uses opened pipes for jobserver-auth,
+    e.g. --jobserver-auth=3,4.
+    Starting with GNU make 4.4, one can use --jobserver-style=fifo
+    and then named pipe is used: --jobserver-auth=fifo:/tmp/hcsparta.  */
+
   /* Detect jobserver and drop it if it's not working.  */
   string js_needle = "--jobserver-auth=";
+  string fifo_prefix = "fifo:";
 
   const char *envval = getenv ("MAKEFLAGS");
   if (envval != NULL)
@@ -1820,8 +1826,15 @@ jobserver_info::jobserver_info ()
       size_t n = makeflags.rfind (js_needle);
       if (n != string::npos)
 	{
-	  if (sscanf (makeflags.c_str () + n + js_needle.size (),
-		      "%d,%d", &rfd, &wfd) == 2
+	  string ending = makeflags.substr (n + js_needle.size ());
+	  if (ending.find (fifo_prefix) == 0)
+	    {
+	      ending = ending.substr (fifo_prefix.size ());
+	      pipe_path = ending.substr (0, ending.find (' '));
+	      is_active = true;
+	    }
+	  else if (sscanf (makeflags.c_str () + n + js_needle.size (),
+			   "%d,%d", &rfd, &wfd) == 2
 	      && rfd > 0
 	      && wfd > 0
 	      && is_valid_fd (rfd)
diff --git a/gcc/opts-jobserver.h b/gcc/opts-jobserver.h
index 68ce188b84a..98ea2579962 100644
--- a/gcc/opts-jobserver.h
+++ b/gcc/opts-jobserver.h
@@ -37,6 +37,8 @@ struct jobserver_info
   int rfd = -1;
   /* File descriptor for writing used for jobserver communication.  */
   int wfd = -1;
+  /* Named pipe path.  */
+  string pipe_path = "";
   /* Return true if jobserver is active.  */
   bool is_active = false;
 };

commit 650de79894d895e96f129b94f7da8fbfbc3a5285
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Fri Dec 23 00:20:05 2022 +0000

    Daily bump.

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 0493e97dba2..f773d40cb77 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,24 @@
+2022-12-22  Martin Liska  <mliska@suse.cz>
+
+	Backported from master:
+	2022-08-10  Martin Liska  <mliska@suse.cz>
+
+	* opts-jobserver.h: Add one member.
+	* opts-common.c (jobserver_info::jobserver_info): Parse FIFO
+	format of --jobserver-auth.
+
+2022-12-22  Martin Liska  <mliska@suse.cz>
+
+	Backported from master:
+	2022-08-10  Martin Liska  <mliska@suse.cz>
+
+	* gcc.c (driver::detect_jobserver): Remove and move to
+	jobserver.h.
+	* lto-wrapper.c (jobserver_active_p): Likewise.
+	(run_gcc): Likewise.
+	* opts-jobserver.h: New file.
+	* opts-common.c (jobserver_info::jobserver_info): New function.
+
 2022-12-15  Sebastian Pop  <spop@amazon.com>
 
 	PR target/98776
diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 4bbb3ed7e34..7a58b9c62eb 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20221222
+20221223

commit 64905bc6821d4e0e42e10404e397033bd5c2c1be
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sat Dec 24 00:18:23 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 7a58b9c62eb..84446d7ccd5 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20221223
+20221224

commit 03410fc53d82a4ffa9543896d6b884c71e58acf4
Author: John David Anglin <danglin@gcc.gnu.org>
Date:   Sun Nov 13 17:04:44 2022 +0000

    Skip guality tests on hppa-hpux.
    
    The guality check command hangs. This causes TCL errors in
    other tests and slows testsuite execution.
    
    2022-11-13  John David Anglin  <danglin@gcc.gnu.org>
    
    gcc/testsuite/ChangeLog:
    
            * g++.dg/guality/guality.exp: Skip on hppa*-*-hpux*.
            * gcc.dg/guality/guality.exp: Likewise.
            * gfortran.dg/guality/guality.exp: Likewise.

diff --git a/gcc/testsuite/g++.dg/guality/guality.exp b/gcc/testsuite/g++.dg/guality/guality.exp
index 33571f1f28f..512ed0338f3 100644
--- a/gcc/testsuite/g++.dg/guality/guality.exp
+++ b/gcc/testsuite/g++.dg/guality/guality.exp
@@ -8,6 +8,10 @@ if { [istarget *-*-darwin*] } {
     return
 }
 
+if { [istarget hppa*-*-hpux*] } {
+    return
+}
+
 if { [istarget "powerpc-ibm-aix*"] } {
     set torture_execute_xfail "powerpc-ibm-aix*"
     return
diff --git a/gcc/testsuite/gcc.dg/guality/guality.exp b/gcc/testsuite/gcc.dg/guality/guality.exp
index 89cd896d05c..288a58c8fa5 100644
--- a/gcc/testsuite/gcc.dg/guality/guality.exp
+++ b/gcc/testsuite/gcc.dg/guality/guality.exp
@@ -8,6 +8,10 @@ if { [istarget *-*-darwin*] } {
     return
 }
 
+if { [istarget hppa*-*-hpux*] } {
+    return
+}
+
 if { [istarget "powerpc-ibm-aix*"] } {
     set torture_execute_xfail "powerpc-ibm-aix*"
     return
diff --git a/gcc/testsuite/gfortran.dg/guality/guality.exp b/gcc/testsuite/gfortran.dg/guality/guality.exp
index eaa7ae770d6..9385569960f 100644
--- a/gcc/testsuite/gfortran.dg/guality/guality.exp
+++ b/gcc/testsuite/gfortran.dg/guality/guality.exp
@@ -8,6 +8,10 @@ if { [istarget *-*-darwin*] } {
   return
 }
 
+if { [istarget hppa*-*-hpux*] } {
+    return
+}
+
 if { [istarget "powerpc-ibm-aix*"] } {
     set torture_execute_xfail "powerpc-ibm-aix*"
     return

commit 0f22c061ca1438ac41d4e4103041c53ae3232038
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sun Dec 25 00:18:00 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 84446d7ccd5..afa39b22a00 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20221224
+20221225
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index e3701cfde8e..8772e3f23ec 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2022-12-24  John David Anglin  <danglin@gcc.gnu.org>
+
+	* g++.dg/guality/guality.exp: Skip on hppa*-*-hpux*.
+	* gcc.dg/guality/guality.exp: Likewise.
+	* gfortran.dg/guality/guality.exp: Likewise.
+
 2022-12-18  Paul Thomas  <pault@gcc.gnu.org>
 
 	Backported from master:

commit 3eb2eacc9fda9ca8c166e2d383ca9ad9911d1a8c
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Mon Dec 26 00:18:28 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index afa39b22a00..6c91a6094a4 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20221225
+20221226

commit eaf387d4191100ea25571370f8f5bbe886a24be6
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Tue Dec 27 00:18:21 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 6c91a6094a4..154fbb15dde 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20221226
+20221227

commit ba5669543e7371ea0d507826f5e2bd071fef41cb
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Wed Dec 28 00:18:16 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 154fbb15dde..e65d79fa1d5 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20221227
+20221228

commit 3d51d241b322ea606b5adc9d617d700485d13be9
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Thu Dec 29 00:18:38 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index e65d79fa1d5..cf083afb247 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20221228
+20221229

commit 3738e89b387cd79d0307431932bbaa45611ef3d6
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Fri Dec 30 00:18:16 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index cf083afb247..13c8be464ab 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20221229
+20221230

commit f9a0b4daac2bee02b5bce305c849971f3c63d8ed
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sat Dec 31 00:18:22 2022 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 13c8be464ab..e1dea3478c0 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20221230
+20221231

commit 9b3a23b31afdfb73ecd3efb43fdd0b195f186ad2
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sun Jan 1 00:18:37 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index e1dea3478c0..e44b4fefa68 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20221231
+20230101

commit 835b7595722f47654cba4402cf1fe6a02492f933
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Mon Jan 2 00:18:01 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index e44b4fefa68..c316b2c3af3 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230101
+20230102

commit 397100c85a444e23e78f24708c54627a2be437e6
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Tue Jan 3 00:18:22 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index c316b2c3af3..42a6b8e6344 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230102
+20230103

commit 1b706294678e27b02b389379fd59e776dad23520
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Wed Jan 4 00:18:13 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 42a6b8e6344..488992842fa 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230103
+20230104

commit ad7b3d44bea74f6a7d277553ace3beda7ed13d14
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Thu Jan 5 00:18:43 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 488992842fa..9d39ee8c855 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230104
+20230105

commit 32a5510d5f419db88a0e14f3c6e4f708c0bc776d
Author: Kewen Lin <linkw@linux.ibm.com>
Date:   Wed Jan 4 23:32:42 2023 -0600

    rs6000: Raise error for __vector_{quad,pair} uses without MMA enabled [PR106736]
    
    As PR106736 shows, it's unexpected to use __vector_quad and
    __vector_pair types without MMA support, it would cause ICE
    when expanding the corresponding assignment.  We can't guard
    these built-in types registering under MMA support as Peter
    pointed out in that PR, because the registering is global,
    it doesn't work for target pragma/attribute support with MMA
    enabled.  The existing verify_type_context mentioned in [2]
    can help to make the diagnostics invalid built-in type uses
    better, but as Richard pointed out in [4], it can't deal with
    all cases.  As the discussions in [1][3], this patch is to
    check the invalid use of built-in types __vector_quad and
    __vector_pair in mov pattern of OOmode and XOmode, on the
    currently being expanded gimple assignment statement.  It
    still puts an assertion in else arm rather than just makes
    it go through, it's to ensure we can catch any other possible
    unexpected cases in time if there are.
    
    [1] https://gcc.gnu.org/pipermail/gcc/2022-December/240218.html
    [2] https://gcc.gnu.org/pipermail/gcc/2022-December/240220.html
    [3] https://gcc.gnu.org/pipermail/gcc/2022-December/240223.html
    [4] https://gcc.gnu.org/pipermail/gcc-patches/2022-December/608083.html
    
            PR target/106736
    
    gcc/ChangeLog:
    
            * config/rs6000/mma.md (define_expand movoo): Call function
            rs6000_opaque_type_invalid_use_p to check and emit error message for
            the invalid use of opaque type.
            (define_expand movxo): Likewise.
            * config/rs6000/rs6000-protos.h
            (rs6000_opaque_type_invalid_use_p): New function declaration.
            (currently_expanding_gimple_stmt): New extern declaration.
            * config/rs6000/rs6000.c (rs6000_opaque_type_invalid_use_p): New
            function.
    
    gcc/testsuite/ChangeLog:
    
            * gcc.target/powerpc/pr106736-1.c: New test.
            * gcc.target/powerpc/pr106736-2.c: Likewise.
            * gcc.target/powerpc/pr106736-3.c: Likewise.
            * gcc.target/powerpc/pr106736-4.c: Likewise.
            * gcc.target/powerpc/pr106736-5.c: Likewise.

diff --git a/gcc/config/rs6000/mma.md b/gcc/config/rs6000/mma.md
index c6e07e5dd78..cea5d972663 100644
--- a/gcc/config/rs6000/mma.md
+++ b/gcc/config/rs6000/mma.md
@@ -300,8 +300,11 @@
 	 expanding to RTL and have seen errors.  It would not cause further ICEs
 	 as the compilation would stop soon after expanding.  */
     }
+  else if (rs6000_opaque_type_invalid_use_p (currently_expanding_gimple_stmt))
+    ;
   else
-    gcc_unreachable ();
+    /* Catch unexpected cases.  */
+    gcc_assert (false);
 })
 
 (define_insn_and_split "*movpoi"
@@ -352,8 +355,11 @@
 	 some missing required conditions.  So do the same handlings for PXImode
 	 as POImode here.  */
     }
+  else if (rs6000_opaque_type_invalid_use_p (currently_expanding_gimple_stmt))
+    ;
   else
-    gcc_unreachable ();
+    /* Catch unexpected cases.  */
+    gcc_assert (false);
 })
 
 (define_insn_and_split "*movpxi"
diff --git a/gcc/config/rs6000/rs6000-protos.h b/gcc/config/rs6000/rs6000-protos.h
index 5508484ba19..75e9e6d3bb5 100644
--- a/gcc/config/rs6000/rs6000-protos.h
+++ b/gcc/config/rs6000/rs6000-protos.h
@@ -309,4 +309,6 @@ extern bool rs6000_quadword_masked_address_p (const_rtx exp);
 extern rtx rs6000_gen_lvx (enum machine_mode, rtx, rtx);
 extern rtx rs6000_gen_stvx (enum machine_mode, rtx, rtx);
 
+extern gimple *currently_expanding_gimple_stmt;
+extern bool rs6000_opaque_type_invalid_use_p (gimple *);
 #endif  /* rs6000-protos.h */
diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index d6be8b7fb6b..d2ac6c21069 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -26893,6 +26893,44 @@ rs6000_invalid_conversion (const_tree fromtype, const_tree totype)
   return NULL;
 }
 
+/* Now we have only two opaque types, they are __vector_quad and
+   __vector_pair built-in types.  They are target specific and
+   only available when MMA is supported.  With MMA supported, it
+   simply returns true, otherwise it checks if the given gimple
+   STMT is an assignment stmt and uses either of these two opaque
+   types unexpectedly, if yes, it would raise an error message
+   and returns true, otherwise it returns false.  */
+
+bool
+rs6000_opaque_type_invalid_use_p (gimple *stmt)
+{
+  if (TARGET_MMA)
+    return false;
+
+  if (stmt)
+    {
+      /* The usage of MMA opaque types is very limited for now,
+	 to check with gassign is enough so far.  */
+      if (gassign *ga = dyn_cast<gassign *> (stmt))
+	{
+	  tree lhs = gimple_assign_lhs (ga);
+	  tree type = TREE_TYPE (lhs);
+	  if (type == vector_quad_type_node)
+	    {
+	      error ("type %<__vector_quad%> requires the %qs option", "-mmma");
+	      return true;
+	    }
+	  else if (type == vector_pair_type_node)
+	    {
+	      error ("type %<__vector_pair%> requires the %qs option", "-mmma");
+	      return true;
+	    }
+	}
+    }
+
+  return false;
+}
+
 struct gcc_target targetm = TARGET_INITIALIZER;
 
 #include "gt-rs6000.h"
diff --git a/gcc/testsuite/gcc.target/powerpc/pr106736-1.c b/gcc/testsuite/gcc.target/powerpc/pr106736-1.c
new file mode 100644
index 00000000000..65bd79d3dce
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/pr106736-1.c
@@ -0,0 +1,20 @@
+/* { dg-require-effective-target powerpc_p9modulo_ok } */
+/* If the default cpu type is power10 or later, type __vector_quad is
+   supported.  To keep the test point available all the time, this case
+   specifies -mdejagnu-cpu=power9 here.  */
+/* { dg-options "-mdejagnu-cpu=power9" } */
+
+/* Verify there is no ICE and don't check the error messages on unsupported
+   type since they could be fragile and are not test points of this case.  */
+
+/* { dg-excess-errors "pr106736-1" } */
+
+extern void bar (__vector_quad *);
+
+void
+foo (__vector_quad *a, __vector_quad *b)
+{
+  __vector_quad arr[2] = {*a, *b};
+  bar (&arr[0]);
+}
+
diff --git a/gcc/testsuite/gcc.target/powerpc/pr106736-2.c b/gcc/testsuite/gcc.target/powerpc/pr106736-2.c
new file mode 100644
index 00000000000..12ad936fccc
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/pr106736-2.c
@@ -0,0 +1,17 @@
+/* { dg-require-effective-target powerpc_p9modulo_ok } */
+/* If the default cpu type is power10 or later, type __vector_pair is
+   supported.  To keep the test point available all the time, this case
+   specifies -mdejagnu-cpu=power9 here.  */
+/* { dg-options "-mdejagnu-cpu=power9" } */
+
+/* Verify there is no ICE and don't check the error messages on unsupported
+   type since they could be fragile and are not test points of this case.  */
+
+/* { dg-excess-errors "pr106736-2" } */
+
+void
+foo (__vector_pair *a, __vector_pair *b)
+{
+  *a = *b;
+}
+
diff --git a/gcc/testsuite/gcc.target/powerpc/pr106736-3.c b/gcc/testsuite/gcc.target/powerpc/pr106736-3.c
new file mode 100644
index 00000000000..4fb368b8fb5
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/pr106736-3.c
@@ -0,0 +1,18 @@
+/* { dg-require-effective-target powerpc_p9modulo_ok } */
+/* If the default cpu type is power10 or later, type __vector_quad is
+   supported.  To keep the test point available all the time, this case
+   specifies -mdejagnu-cpu=power9 here.  */
+/* { dg-options "-mdejagnu-cpu=power9" } */
+
+/* Verify there is no ICE and don't check the error messages on unsupported
+   type since they could be fragile and are not test points of this case.  */
+
+/* { dg-excess-errors "pr106736-3" } */
+
+__vector_quad ga;
+void
+foo (__vector_quad *a)
+{
+  ga = *a;
+}
+
diff --git a/gcc/testsuite/gcc.target/powerpc/pr106736-4.c b/gcc/testsuite/gcc.target/powerpc/pr106736-4.c
new file mode 100644
index 00000000000..4b366416b0a
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/pr106736-4.c
@@ -0,0 +1,19 @@
+/* { dg-require-effective-target powerpc_p9modulo_ok } */
+/* If the default cpu type is power10 or later, type __vector_quad is
+   supported.  To keep the test point available all the time, this case
+   specifies -mdejagnu-cpu=power9 here.  */
+/* { dg-options "-mdejagnu-cpu=power9" } */
+
+/* Verify there is no ICE and don't check the error messages on unsupported
+   type since they could be fragile and are not test points of this case.  */
+
+/* { dg-excess-errors "pr106736-4" } */
+
+__vector_quad ga;
+__vector_quad gb;
+void
+foo ()
+{
+  gb = ga;
+}
+
diff --git a/gcc/testsuite/gcc.target/powerpc/pr106736-5.c b/gcc/testsuite/gcc.target/powerpc/pr106736-5.c
new file mode 100644
index 00000000000..d7370b81e81
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/pr106736-5.c
@@ -0,0 +1,18 @@
+/* { dg-require-effective-target powerpc_p9modulo_ok } */
+/* If the default cpu type is power10 or later, type __vector_pair is
+   supported.  To keep the test point available all the time, this case
+   specifies -mdejagnu-cpu=power9 here.  */
+/* { dg-options "-mdejagnu-cpu=power9" } */
+
+/* Verify there is no ICE and don't check the error messages on unsupported
+   type since they could be fragile and are not test points of this case.  */
+
+/* { dg-excess-errors "pr106736-5" } */
+
+__vector_pair ga;
+void
+foo (__vector_pair *a)
+{
+  *a = ga;
+}
+

commit df8d2c4a626ce84ab1debc1d933dccea5022730a
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Fri Jan 6 00:18:36 2023 +0000

    Daily bump.

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index f773d40cb77..053dccc6dc9 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,16 @@
+2023-01-05  Kewen Lin  <linkw@linux.ibm.com>
+
+	PR target/106736
+	* config/rs6000/mma.md (define_expand movoo): Call function
+	rs6000_opaque_type_invalid_use_p to check and emit error message for
+	the invalid use of opaque type.
+	(define_expand movxo): Likewise.
+	* config/rs6000/rs6000-protos.h
+	(rs6000_opaque_type_invalid_use_p): New function declaration.
+	(currently_expanding_gimple_stmt): New extern declaration.
+	* config/rs6000/rs6000.c (rs6000_opaque_type_invalid_use_p): New
+	function.
+
 2022-12-22  Martin Liska  <mliska@suse.cz>
 
 	Backported from master:
diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 9d39ee8c855..5cf4a378549 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230105
+20230106
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 8772e3f23ec..38209f39fee 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,12 @@
+2023-01-05  Kewen Lin  <linkw@linux.ibm.com>
+
+	PR target/106736
+	* gcc.target/powerpc/pr106736-1.c: New test.
+	* gcc.target/powerpc/pr106736-2.c: Likewise.
+	* gcc.target/powerpc/pr106736-3.c: Likewise.
+	* gcc.target/powerpc/pr106736-4.c: Likewise.
+	* gcc.target/powerpc/pr106736-5.c: Likewise.
+
 2022-12-24  John David Anglin  <danglin@gcc.gnu.org>
 
 	* g++.dg/guality/guality.exp: Skip on hppa*-*-hpux*.

commit 504545cea1938bcbffb5fc4f827eb52bbbae1941
Author: Martin Liska <mliska@suse.cz>
Date:   Wed May 12 14:03:36 2021 +0200

    lto-wrapper: silent warnings in tests
    
    Silents the following warning:
    lto-wrapper: warning: using serial compilation of 2 LTRANS jobs
    
    gcc/testsuite/ChangeLog:
    
            * lib/lto.exp: When running tests without jobserver, one can see
            the following warning for tests that use 1to1 partitioning.
    
    (cherry picked from commit fc186594e3ee86a57841442e96306dddfd8eb85d)

diff --git a/gcc/testsuite/lib/lto.exp b/gcc/testsuite/lib/lto.exp
index b2fa7ec8cec..da4456e3aa1 100644
--- a/gcc/testsuite/lib/lto.exp
+++ b/gcc/testsuite/lib/lto.exp
@@ -159,6 +159,9 @@ proc lto_prune_warns { text } {
     regsub -all "(^|\n)\[ \t\]*\[\(\]file \[^\n\]* value=\[^\n\]*; file \[^\n\]* value=\[^\n\]*\[)\];" $text "" text
     regsub -all "(^|\n)\[ \t\]*\[^\n\]* definition taken" $text "" text
 
+    # Ignore missing jobserver for tests that do more than 1 LTRANS unit
+    regsub -all "(^|\n)\[^\n\]*: warning: using serial compilation of \[^\n\]*" $text "" text
+
     # Ignore informational notes.
     regsub -all "(^|\n)\[^\n\]*: note: \[^\n\]*" $text "" text
 

commit 7097d2aafcae4b1cb89c28ff4fd4af18df9a2cef
Author: Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
Date:   Mon Dec 27 01:13:59 2021 +0100

    LTO: Prune some warnings in the testsuite
    
    Warnings like:
    
        warning: using serial compilation of 2 LTRANS jobs
        warning: visibility attribute not supported in this configuration; ignored\[^\n\]*" $text "" text
    
    are pruned by lto.exp, but not for LTO testcases when run in other parts
    of the testsuite. They will be, now.
    
    gcc/testsuite/ChangeLog:
    
            PR testsuite/47334
            PR testsuite/103823
            * lib/prune.exp: Prune some warnings related to LTO and
            visibility.
    
    (cherry picked from commit 05edf6c470ae0ab50d42f16e78e476dbcc774842)

diff --git a/gcc/testsuite/lib/prune.exp b/gcc/testsuite/lib/prune.exp
index a5d09c78106..f11f008373c 100644
--- a/gcc/testsuite/lib/prune.exp
+++ b/gcc/testsuite/lib/prune.exp
@@ -82,6 +82,13 @@ proc prune_gcc_output { text } {
     # Ignore dsymutil warning (tool bug is actually linker)
     regsub -all "(^|\n)\[^\n\]*could not find object file symbol for symbol\[^\n\]*" $text "" text
 
+    # Ignore missing lto jobserver for tests that do more than 1 LTRANS unit
+    regsub -all "(^|\n)\[^\n\]*lto\[^\n\]*: warning: using serial compilation of \[^\n\]*" $text "" text
+    regsub -all "(^|\n)\[^\n\]*lto\[^\n\]*: note: see the \[^\n\]*'-flto' option documentation\[^\n\]* for more information" $text "" text
+
+    # Many tests that use visibility will still pass on platforms that don't support it.
+    regsub -all "(^|\n)\[^\n\]*lto1: warning: visibility attribute not supported in this configuration; ignored\[^\n\]*" $text "" text
+
     # If dg-enable-nn-line-numbers was provided, then obscure source-margin
     # line numbers by converting them to "NN" form.
     set text [maybe-handle-nn-line-numbers $text]

commit 1a121f0ef5e76efa61660173b19acf03be010ca8
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sat Jan 7 00:19:29 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 5cf4a378549..1178712294c 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230106
+20230107
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 38209f39fee..33c1eb29374 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,21 @@
+2023-01-06  Francois-Xavier Coudert  <fxcoudert@gcc.gnu.org>
+
+	Backported from master:
+	2021-12-29  Francois-Xavier Coudert  <fxcoudert@gcc.gnu.org>
+
+	PR testsuite/47334
+	PR testsuite/103823
+	* lib/prune.exp: Prune some warnings related to LTO and
+	visibility.
+
+2023-01-06  Martin Liska  <mliska@suse.cz>
+
+	Backported from master:
+	2021-05-12  Martin Liska  <mliska@suse.cz>
+
+	* lib/lto.exp: When running tests without jobserver, one can see
+	the following warning for tests that use 1to1 partitioning.
+
 2023-01-05  Kewen Lin  <linkw@linux.ibm.com>
 
 	PR target/106736

commit 8bbdc1984bd37dd01e75af29d27624433dc204ea
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sun Jan 8 00:18:51 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 1178712294c..bcc46c04f3c 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230107
+20230108

commit ba5012875bc6f7910be3b5cce03e000aa9322c1f
Author: Harald Anlauf <anlauf@gmx.de>
Date:   Sat Dec 17 22:04:32 2022 +0100

    Fortran: incorrect array bounds when bound intrinsic used in decl [PR108131]
    
    gcc/fortran/ChangeLog:
    
            PR fortran/108131
            * array.c (match_array_element_spec): Avoid too early simplification
            of matched array element specs that can lead to a misinterpretation
            when used as array bounds in array declarations.
    
    gcc/testsuite/ChangeLog:
    
            PR fortran/108131
            * gfortran.dg/pr103505.f90: Adjust expected patterns.
            * gfortran.dg/pr108131.f90: New test.
    
    (cherry picked from commit 6a95f0e0a06d78d94138d4c3dd64d41591197281)

diff --git a/gcc/fortran/array.c b/gcc/fortran/array.c
index e7a14e9106d..55012da37f0 100644
--- a/gcc/fortran/array.c
+++ b/gcc/fortran/array.c
@@ -492,8 +492,6 @@ match_array_element_spec (gfc_array_spec *as)
   if (!gfc_expr_check_typed (*upper, gfc_current_ns, false))
     return AS_UNKNOWN;
 
-  gfc_try_simplify_expr (*upper, 0);
-
   if (((*upper)->expr_type == EXPR_CONSTANT
 	&& (*upper)->ts.type != BT_INTEGER) ||
       ((*upper)->expr_type == EXPR_FUNCTION
@@ -526,8 +524,6 @@ match_array_element_spec (gfc_array_spec *as)
   if (!gfc_expr_check_typed (*upper, gfc_current_ns, false))
     return AS_UNKNOWN;
 
-  gfc_try_simplify_expr (*upper, 0);
-
   if (((*upper)->expr_type == EXPR_CONSTANT
 	&& (*upper)->ts.type != BT_INTEGER) ||
       ((*upper)->expr_type == EXPR_FUNCTION
diff --git a/gcc/testsuite/gfortran.dg/pr103505.f90 b/gcc/testsuite/gfortran.dg/pr103505.f90
index 522e53efcb2..01308019b2c 100644
--- a/gcc/testsuite/gfortran.dg/pr103505.f90
+++ b/gcc/testsuite/gfortran.dg/pr103505.f90
@@ -3,7 +3,9 @@
 ! Testcase by G.Steinmetz
 
 program p
-  integer, parameter :: a((2.))   = [4,8] ! { dg-error "scalar INTEGER" }
-  integer, parameter :: z(1:(2.)) = [4,8] ! { dg-error "scalar INTEGER" }
-  print *, a(1:1)                         ! { dg-error "Syntax error" }
+  integer, parameter :: a((2.))   = [4,8] ! { dg-error "INTEGER type" }
+  integer, parameter :: z(1:(2.)) = [4,8] ! { dg-error "INTEGER type" }
+  print *, a(1:1)
 end
+
+! { dg-prune-output "Parameter array" }
diff --git a/gcc/testsuite/gfortran.dg/pr108131.f90 b/gcc/testsuite/gfortran.dg/pr108131.f90
new file mode 100644
index 00000000000..8bf36d361ba
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr108131.f90
@@ -0,0 +1,25 @@
+! { dg-do run }
+! { dg-additional-options "-fdump-tree-original" }
+! PR fortran/108131
+!
+! Incorrect array bounds when bound intrinsic used in declaration
+
+program test
+  implicit none
+  integer, parameter :: mg(7:10)                 = 0
+  integer, parameter :: u =   ubound(mg, dim=1)
+  integer, parameter :: cx(-1:ubound(mg, dim=1)) = 1
+  integer, parameter :: dx(lbound(mg, dim=1):ubound(cx, dim=1)) = 2
+
+  write(*,*) ubound(mg, dim=1)
+  write(*,*) ubound(cx, dim=1)
+  if (u /= 10) stop 1
+  if (ubound(mg, dim=1) /= 10) stop 2
+  if (ubound(cx, dim=1) /= 10) stop 3
+  if (ubound(dx, dim=1) /= 10) stop 4
+  if (lbound(mg, dim=1) /=  7) stop 5
+  if (lbound(cx, dim=1) /= -1) stop 6
+  if (lbound(dx, dim=1) /=  7) stop 7
+end program test
+
+! { dg-final { scan-tree-dump-not "_gfortran_stop_numeric" "original" } }

commit 3dc30af6c2479cdf4e4170de97567d2b506cc299
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Mon Jan 9 00:19:31 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index bcc46c04f3c..6a739acb152 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230108
+20230109
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index afc41fbe6a8..64a638dff83 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,13 @@
+2023-01-08  Harald Anlauf  <anlauf@gmx.de>
+
+	Backported from master:
+	2022-12-23  Harald Anlauf  <anlauf@gmx.de>
+
+	PR fortran/108131
+	* array.c (match_array_element_spec): Avoid too early simplification
+	of matched array element specs that can lead to a misinterpretation
+	when used as array bounds in array declarations.
+
 2022-12-18  Paul Thomas  <pault@gcc.gnu.org>
 
 	Backported from master:
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 33c1eb29374..f4121e18043 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,12 @@
+2023-01-08  Harald Anlauf  <anlauf@gmx.de>
+
+	Backported from master:
+	2022-12-23  Harald Anlauf  <anlauf@gmx.de>
+
+	PR fortran/108131
+	* gfortran.dg/pr103505.f90: Adjust expected patterns.
+	* gfortran.dg/pr108131.f90: New test.
+
 2023-01-06  Francois-Xavier Coudert  <fxcoudert@gcc.gnu.org>
 
 	Backported from master:

commit e3e673dd18327ef86af94ba0e1a341f904898134
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Tue Jan 10 00:19:51 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 6a739acb152..3437f90b0b3 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230109
+20230110

commit d37501c85fe213cf8ec1f388997ec7030a30e977
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Wed Jan 11 00:19:35 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 3437f90b0b3..35defd81c7a 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230110
+20230111

commit b9d05556774dfc29b091d426e69c9171d9e0fc1f
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Thu Jan 12 00:20:01 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 35defd81c7a..02b5c084d5f 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230111
+20230112

commit a917e5e5378cffbf4592f6300633a100b5ee763e
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Fri Jan 13 00:18:40 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 02b5c084d5f..e47d85a2bca 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230112
+20230113

commit be9fa5e66cf2bb1395090d59a5f4bcf40686338d
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sat Jan 14 00:18:30 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index e47d85a2bca..7ed2c4ba61e 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230113
+20230114

commit 88e4bd878cd24c429ed004e47161b84ff2a26d1f
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sun Jan 15 00:18:43 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 7ed2c4ba61e..dbdecdf7fc7 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230114
+20230115

commit a41f31831f0c1c129be4872d0413cfd5e06e88d7
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Mon Jan 16 00:18:41 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index dbdecdf7fc7..748a3e00583 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230115
+20230116

commit fc368ee23999b57295d2f9281b26502808435515
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Tue Jan 17 00:19:16 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 748a3e00583..9081c2e74e5 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230116
+20230117

commit 4e7d3061366cbd62a789bda2b3e021e5d1d2ff6c
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Wed Jan 18 00:19:01 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 9081c2e74e5..5943f2b395d 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230117
+20230118

commit 18bc39a4c83f8d59175061a58637de9f4b2a54d4
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Thu Jan 19 00:19:12 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 5943f2b395d..847dee113d4 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230118
+20230119

commit 4216c3fb165c74df92c71028e7f8b126c6f90d34
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Fri Jan 20 00:19:00 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 847dee113d4..c8519a7a377 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230119
+20230120

commit 104c11b6bf9435052c0f87a80c234f2dac3e81f3
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sat Jan 21 00:18:40 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index c8519a7a377..583ce61ca83 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230120
+20230121

commit c15eab75487b85cb6fb4480184d154dc992feb61
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sun Jan 22 00:19:23 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 583ce61ca83..39523e2052c 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230121
+20230122

commit 14a46151260c3b56710aa0423babbaba2e4c9957
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Mon Jan 23 00:18:59 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 39523e2052c..3426cc88910 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230122
+20230123

commit 1187b3b582e0c925d277022718b93cc12754de4c
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Tue Jan 24 00:19:36 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 3426cc88910..9ed1bcf7f8f 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230123
+20230124

commit 6ced00d53d91ea429948b34e6600b4633f962030
Author: Sergei Trofimovich <siarheit@google.com>
Date:   Tue Aug 16 12:35:07 2022 +0100

    driver: fix environ corruption after putenv() [PR106624]
    
    The bug appeared afte r13-2010-g1270ccda70ca09 "Factor out
    jobserver_active_p" slightly changed `putenv()` use from allocating
    to non-allocating:
    
        -xputenv (concat ("MAKEFLAGS=", dup, NULL));
        +xputenv (jinfo.skipped_makeflags.c_str ());
    
    `xputenv()` (and `putenv()`) don't copy strings and only store the
    pointer in the `environ` global table. As a result `environ` got
    corrupted as soon as `jinfo.skipped_makeflags` store got deallocated.
    
    This started causing bootstrap crashes in `execv()` calls:
    
        xgcc: fatal error: cannot execute '/build/build/./prev-gcc/collect2': execv: Bad address
    
    The change restores memory allocation for `xputenv()` argument.
    
    gcc/
    
            PR driver/106624
            * gcc.c (driver::detect_jobserver): Allocate storage xputenv()
            argument using xstrdup().
    
    (cherry picked from commit 2b403297b111c990c331b5bbb6165b061ad2259b)

diff --git a/gcc/gcc.c b/gcc/gcc.c
index ed7099c2a6d..6517d9935dc 100644
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -8403,7 +8403,7 @@ driver::detect_jobserver () const
 {
   jobserver_info jinfo;
   if (!jinfo.is_active && !jinfo.skipped_makeflags.empty ())
-    xputenv (jinfo.skipped_makeflags.c_str ());
+    xputenv (xstrdup (jinfo.skipped_makeflags.c_str ()));
 }
 
 /* Determine what the exit code of the driver should be.  */

commit 286cc95e4901f72616b7b5563b75e5d426d8cb63
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Wed Jan 25 00:19:59 2023 +0000

    Daily bump.

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 053dccc6dc9..ef3629c0281 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,12 @@
+2023-01-24  Sergei Trofimovich  <siarheit@google.com>
+
+	Backported from master:
+	2022-08-16  Sergei Trofimovich  <siarheit@google.com>
+
+	PR driver/106624
+	* gcc.c (driver::detect_jobserver): Allocate storage xputenv()
+	argument using xstrdup().
+
 2023-01-05  Kewen Lin  <linkw@linux.ibm.com>
 
 	PR target/106736
diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 9ed1bcf7f8f..e26ffa6a16c 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230124
+20230125

commit fea013065580084578b1b78d8f727c0323f2a9a0
Author: Christophe Lyon <christophe.lyon@arm.com>
Date:   Tue Jan 24 09:46:30 2023 +0000

    [PATCH] aarch64: fix warning emission for ABI break since GCC 9.1
    
    While looking at PR 105549, which is about fixing the ABI break
    introduced in GCC 9.1 in parameter alignment with bit-fields, we
    noticed that the GCC 9.1 warning is not emitted in all the cases where
    it should be.  This patch fixes that and the next patch in the series
    fixes the GCC 9.1 break.
    
    We split this into two patches since patch #2 introduces a new ABI
    break starting with GCC 13.1.  This way, patch #1 can be back-ported
    to release branches if needed to fix the GCC 9.1 warning issue.
    
    The main idea is to add a new global boolean that indicates whether
    we're expanding the start of a function, so that aarch64_layout_arg
    can emit warnings for callees as well as callers.  This removes the
    need for aarch64_function_arg_boundary to warn (with its incomplete
    information).  However, in the first patch there are still cases where
    we emit warnings were we should not; this is fixed in patch #2 where
    we can distinguish between GCC 9.1 and GCC.13.1 ABI breaks properly.
    
    The fix in aarch64_function_arg_boundary (replacing & with &&) looks
    like an oversight of a previous commit in this area which changed
    'abi_break' from a boolean to an integer.
    
    We also take the opportunity to fix the comment above
    aarch64_function_arg_alignment since the value of the abi_break
    parameter was changed in a previous commit, no longer matching the
    description.
    
    2022-11-28  Christophe Lyon  <christophe.lyon@arm.com>
                Richard Sandiford  <richard.sandiford@arm.com>
    
    gcc/ChangeLog:
    
            * config/aarch64/aarch64.c (aarch64_function_arg_alignment): Fix
            comment.
            (aarch64_layout_arg): Factorize warning conditions.
            (aarch64_function_arg_boundary): Fix typo.
            * function.c (currently_expanding_function_start): New variable.
            (expand_function_start): Handle
            currently_expanding_function_start.
            * function.h (currently_expanding_function_start): Declare.
    
    gcc/testsuite/ChangeLog:
    
            * gcc.target/aarch64/bitfield-abi-warning-align16-O2.c: New test.
            * gcc.target/aarch64/bitfield-abi-warning-align16-O2-extra.c: New
            test.
            * gcc.target/aarch64/bitfield-abi-warning-align32-O2.c: New test.
            * gcc.target/aarch64/bitfield-abi-warning-align32-O2-extra.c: New
            test.
            * gcc.target/aarch64/bitfield-abi-warning-align8-O2.c: New test.
            * gcc.target/aarch64/bitfield-abi-warning.h: New test.
            * g++.target/aarch64/bitfield-abi-warning-align16-O2.C: New test.
            * g++.target/aarch64/bitfield-abi-warning-align16-O2-extra.C: New
            test.
            * g++.target/aarch64/bitfield-abi-warning-align32-O2.C: New test.
            * g++.target/aarch64/bitfield-abi-warning-align32-O2-extra.C: New
            test.
            * g++.target/aarch64/bitfield-abi-warning-align8-O2.C: New test.
            * g++.target/aarch64/bitfield-abi-warning.h: New test.
    
    (cherry picked from commit 3df1a115be22caeab3ffe7afb12e71adb54ff132)

diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
index dd9a3832b5a..92c2f0dae6f 100644
--- a/gcc/config/aarch64/aarch64.c
+++ b/gcc/config/aarch64/aarch64.c
@@ -5914,9 +5914,9 @@ aarch64_vfp_is_call_candidate (cumulative_args_t pcum_v, machine_mode mode,
 /* Given MODE and TYPE of a function argument, return the alignment in
    bits.  The idea is to suppress any stronger alignment requested by
    the user and opt for the natural alignment (specified in AAPCS64 \S
-   4.1).  ABI_BREAK is set to true if the alignment was incorrectly
-   calculated in versions of GCC prior to GCC-9.  This is a helper
-   function for local use only.  */
+   4.1).  ABI_BREAK is set to the old alignment if the alignment was
+   incorrectly calculated in versions of GCC prior to GCC-9.  This is
+   a helper function for local use only.  */
 
 static unsigned int
 aarch64_function_arg_alignment (machine_mode mode, const_tree type,
@@ -5992,11 +5992,24 @@ aarch64_layout_arg (cumulative_args_t pcum_v, const function_arg_info &arg)
   if (pcum->aapcs_arg_processed)
     return;
 
+  bool warn_pcs_change
+    = (warn_psabi
+       && !pcum->silent_p
+       && (currently_expanding_function_start
+	   || currently_expanding_gimple_stmt));
+
+  unsigned int alignment
+    = aarch64_function_arg_alignment (mode, type, &abi_break);
+  gcc_assert (!alignment || abi_break < alignment);
+
   pcum->aapcs_arg_processed = true;
 
   pure_scalable_type_info pst_info;
   if (type && pst_info.analyze_registers (type))
     {
+      /* aarch64_function_arg_alignment has never had an effect on
+	 this case.  */
+
       /* The PCS says that it is invalid to pass an SVE value to an
 	 unprototyped function.  There is no ABI-defined location we
 	 can return in this case, so we have no real choice but to raise
@@ -6067,6 +6080,8 @@ aarch64_layout_arg (cumulative_args_t pcum_v, const function_arg_info &arg)
      and homogenous short-vector aggregates (HVA).  */
   if (allocate_nvrn)
     {
+      /* aarch64_function_arg_alignment has never had an effect on
+	 this case.  */
       if (!pcum->silent_p && !TARGET_FLOAT)
 	aarch64_err_no_fpadvsimd (mode);
 
@@ -6125,7 +6140,7 @@ aarch64_layout_arg (cumulative_args_t pcum_v, const function_arg_info &arg)
 	  && (aarch64_function_arg_alignment (mode, type, &abi_break)
 	      == 16 * BITS_PER_UNIT))
 	{
-	  if (abi_break && warn_psabi && currently_expanding_gimple_stmt)
+	  if (warn_pcs_change && abi_break)
 	    inform (input_location, "parameter passing for argument of type "
 		    "%qT changed in GCC 9.1", type);
 	  ++ncrn;
@@ -6188,7 +6203,7 @@ on_stack:
       int new_size = ROUND_UP (pcum->aapcs_stack_size, 16 / UNITS_PER_WORD);
       if (pcum->aapcs_stack_size != new_size)
 	{
-	  if (abi_break && warn_psabi && currently_expanding_gimple_stmt)
+	  if (warn_pcs_change && abi_break)
 	    inform (input_location, "parameter passing for argument of type "
 		    "%qT changed in GCC 9.1", type);
 	  pcum->aapcs_stack_size = new_size;
@@ -6308,7 +6323,7 @@ aarch64_function_arg_boundary (machine_mode mode, const_tree type)
   bool abi_break;
   unsigned int alignment = aarch64_function_arg_alignment (mode, type,
 							   &abi_break);
-  if (abi_break & warn_psabi)
+  if (abi_break && warn_psabi)
     inform (input_location, "parameter passing for argument of type "
 	    "%qT changed in GCC 9.1", type);
 
diff --git a/gcc/function.c b/gcc/function.c
index ca7d48cdd98..d26392a252c 100644
--- a/gcc/function.c
+++ b/gcc/function.c
@@ -5018,9 +5018,12 @@ stack_protect_epilogue (void)
    PARMS_HAVE_CLEANUPS is nonzero if there are cleanups associated with
    the function's parameters, which must be run at any return statement.  */
 
+bool currently_expanding_function_start;
 void
 expand_function_start (tree subr)
 {
+  currently_expanding_function_start = true;
+
   /* Make sure volatile mem refs aren't considered
      valid operands of arithmetic insns.  */
   init_recog_no_volatile ();
@@ -5213,6 +5216,8 @@ expand_function_start (tree subr)
   /* If we are doing generic stack checking, the probe should go here.  */
   if (flag_stack_check == GENERIC_STACK_CHECK)
     stack_check_probe_note = emit_note (NOTE_INSN_DELETED);
+
+  currently_expanding_function_start = false;
 }
 
 void
diff --git a/gcc/function.h b/gcc/function.h
index 1ee8ed3de53..7af1af496ea 100644
--- a/gcc/function.h
+++ b/gcc/function.h
@@ -702,4 +702,6 @@ extern const char *current_function_name (void);
 
 extern void used_types_insert (tree);
 
+extern bool currently_expanding_function_start;
+
 #endif  /* GCC_FUNCTION_H */
diff --git a/gcc/testsuite/g++.target/aarch64/bitfield-abi-warning-align16-O2-extra.C b/gcc/testsuite/g++.target/aarch64/bitfield-abi-warning-align16-O2-extra.C
new file mode 100644
index 00000000000..fb3194bd231
--- /dev/null
+++ b/gcc/testsuite/g++.target/aarch64/bitfield-abi-warning-align16-O2-extra.C
@@ -0,0 +1,86 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -save-temps -Wno-narrowing" } */
+
+#define ALIGN 16
+//#define EXTRA
+
+#include "bitfield-abi-warning.h"
+
+/* In f1, f2, f4, f8, f16, f16p (and stdarg versions):  */
+/* { dg-final { scan-assembler-times "and\tw0, w2, 1" 12 { xfail *-*-* } } } */
+/* In fp, f1p, f2p, f4p, f8p (and stdarg versions):  */
+/* { dg-final { scan-assembler-times "and\tw0, w1, 1" 10 { xfail *-*-* } } } */
+
+/* Bitfield parameter in registers.  */
+/* { dg-message {parameter passing for argument of type 'S1' changed in GCC 9.1} "" { target *-*-* } 47 } f1 */
+/* { dg-message {parameter passing for argument of type 'S2' changed in GCC 9.1} "" { target *-*-* } 48 } f2 */
+/* { dg-message {parameter passing for argument of type 'S4' changed in GCC 9.1} "" { target *-*-* } 49 } f4 */
+/* { dg-message {parameter passing for argument of type 'S8' changed in GCC 9.1} "" { target *-*-* } 50 } f8 */
+
+/* { dg-message {parameter passing for argument of type 'Sp' changed in GCC 9.1} "" { target *-*-* } 53 }  fp */
+/* { dg-message {parameter passing for argument of type 'S1p' changed in GCC 9.1} "" { target *-*-* } 54 } f1p */
+/* { dg-message {parameter passing for argument of type 'S2p' changed in GCC 9.1} "" { target *-*-* } 55 } f2p */
+/* { dg-message {parameter passing for argument of type 'S4p' changed in GCC 9.1} "" { target *-*-* } 56 } f4p */
+/* { dg-message {parameter passing for argument of type 'S8p' changed in GCC 9.1} "" { target *-*-* } 57 } f8p */
+
+/* Bitfield call argument in registers.  */
+/* { dg-message {parameter passing for argument of type 'S1' changed in GCC 9.1} ""  { target *-*-* } 60 } g1 */
+/* { dg-message {parameter passing for argument of type 'S2' changed in GCC 9.1} ""  { target *-*-* } 61 } g2 */
+/* { dg-message {parameter passing for argument of type 'S4' changed in GCC 9.1} ""  { target *-*-* } 62 } g4 */
+/* { dg-message {parameter passing for argument of type 'S8' changed in GCC 9.1} ""  { target *-*-* } 63 } g8 */
+
+/* { dg-message {parameter passing for argument of type 'Sp' changed in GCC 9.1} "" { target *-*-* } 66 }  gp */
+/* { dg-message {parameter passing for argument of type 'S1p' changed in GCC 9.1} "" { target *-*-* } 67 } g1p */
+/* { dg-message {parameter passing for argument of type 'S2p' changed in GCC 9.1} "" { target *-*-* } 68 } g2p */
+/* { dg-message {parameter passing for argument of type 'S4p' changed in GCC 9.1} "" { target *-*-* } 69 } g4p */
+/* { dg-message {parameter passing for argument of type 'S8p' changed in GCC 9.1} "" { target *-*-* } 70 } g8p */
+
+
+/* Bitfield parameter in stack.  */
+/* { dg-message {parameter passing for argument of type 'S1' changed in GCC 9.1} "" { target *-*-* } 74 } f1_stack */
+/* { dg-message {parameter passing for argument of type 'S2' changed in GCC 9.1} "" { target *-*-* } 75 } f2_stack */
+/* { dg-message {parameter passing for argument of type 'S4' changed in GCC 9.1} "" { target *-*-* } 76 } f4_stack */
+/* { dg-message {parameter passing for argument of type 'S8' changed in GCC 9.1} "" { target *-*-* } 77 } f8_stack */
+
+/* { dg-message {parameter passing for argument of type 'Sp' changed in GCC 9.1} "" { target *-*-* } 80 }  fp_stack */
+/* { dg-message {parameter passing for argument of type 'S1p' changed in GCC 9.1} "" { target *-*-* } 81 } f1p_stack */
+/* { dg-message {parameter passing for argument of type 'S2p' changed in GCC 9.1} "" { target *-*-* } 82 } f2p_stack */
+/* { dg-message {parameter passing for argument of type 'S4p' changed in GCC 9.1} "" { target *-*-* } 83 } f4p_stack */
+/* { dg-message {parameter passing for argument of type 'S8p' changed in GCC 9.1} "" { target *-*-* } 84 } f8p_stack */
+
+/* Bitfield call argument in stack.  */
+/* { dg-message {parameter passing for argument of type 'S1' changed in GCC 9.1} ""  { target *-*-* } 87 } g1_stack */
+/* { dg-message {parameter passing for argument of type 'S2' changed in GCC 9.1} ""  { target *-*-* } 88 } g2_stack */
+/* { dg-message {parameter passing for argument of type 'S4' changed in GCC 9.1} ""  { target *-*-* } 89 } g4_stack */
+/* { dg-message {parameter passing for argument of type 'S8' changed in GCC 9.1} ""  { target *-*-* } 90 } g8_stack */
+
+/* { dg-message {parameter passing for argument of type 'Sp' changed in GCC 9.1} "" { target *-*-* } 93 }  gp_stack */
+/* { dg-message {parameter passing for argument of type 'S1p' changed in GCC 9.1} "" { target *-*-* } 94 } g1p_stack */
+/* { dg-message {parameter passing for argument of type 'S2p' changed in GCC 9.1} "" { target *-*-* } 95 } g2p_stack */
+/* { dg-message {parameter passing for argument of type 'S4p' changed in GCC 9.1} "" { target *-*-* } 96 } g4p_stack */
+/* { dg-message {parameter passing for argument of type 'S8p' changed in GCC 9.1} "" { target *-*-* } 97 } g8p_stack */
+
+
+/* Bitfield parameter in stdarg.  */
+/* { dg-message {parameter passing for argument of type 'S1' changed in GCC 9.1} "" { target *-*-* } 101 } f1_stdarg */
+/* { dg-message {parameter passing for argument of type 'S2' changed in GCC 9.1} "" { target *-*-* } 102 } f2_stdarg */
+/* { dg-message {parameter passing for argument of type 'S4' changed in GCC 9.1} "" { target *-*-* } 103 } f4_stdarg */
+/* { dg-message {parameter passing for argument of type 'S8' changed in GCC 9.1} "" { target *-*-* } 104 } f8_stdarg */
+
+/* { dg-message {parameter passing for argument of type 'Sp' changed in GCC 9.1} "" { target *-*-* } 107 }  fp_stdarg */
+/* { dg-message {parameter passing for argument of type 'S1p' changed in GCC 9.1} "" { target *-*-* } 108 } f1p_stdarg */
+/* { dg-message {parameter passing for argument of type 'S2p' changed in GCC 9.1} "" { target *-*-* } 109 } f2p_stdarg */
+/* { dg-message {parameter passing for argument of type 'S4p' changed in GCC 9.1} "" { target *-*-* } 110 } f4p_stdarg */
+/* { dg-message {parameter passing for argument of type 'S8p' changed in GCC 9.1} "" { target *-*-* } 111 } f8p_stdarg */
+
+/* Bitfield call argument in stdarg.  */
+/* { dg-message {parameter passing for argument of type 'S1' changed in GCC 9.1} ""  { target *-*-* } 114 } g1_stdarg */
+/* { dg-message {parameter passing for argument of type 'S2' changed in GCC 9.1} ""  { target *-*-* } 115 } g2_stdarg */
+/* { dg-message {parameter passing for argument of type 'S4' changed in GCC 9.1} ""  { target *-*-* } 116 } g4_stdarg */
+/* { dg-message {parameter passing for argument of type 'S8' changed in GCC 9.1} ""  { target *-*-* } 117 } g8_stdarg */
+
+/* { dg-message {parameter passing for argument of type 'Sp' changed in GCC 9.1} "" { target *-*-* } 120 }  gp_stdarg */
+/* { dg-message {parameter passing for argument of type 'S1p' changed in GCC 9.1} "" { target *-*-* } 121 } g1p_stdarg */
+/* { dg-message {parameter passing for argument of type 'S2p' changed in GCC 9.1} "" { target *-*-* } 122 } g2p_stdarg */
+/* { dg-message {parameter passing for argument of type 'S4p' changed in GCC 9.1} "" { target *-*-* } 123 } g4p_stdarg */
+/* { dg-message {parameter passing for argument of type 'S8p' changed in GCC 9.1} "" { target *-*-* } 124 } g8p_stdarg */
diff --git a/gcc/testsuite/g++.target/aarch64/bitfield-abi-warning-align16-O2.C b/gcc/testsuite/g++.target/aarch64/bitfield-abi-warning-align16-O2.C
new file mode 100644
index 00000000000..edb02141dd5
--- /dev/null
+++ b/gcc/testsuite/g++.target/aarch64/bitfield-abi-warning-align16-O2.C
@@ -0,0 +1,87 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -save-temps -Wno-narrowing" } */
+
+#define ALIGN 16
+#define EXTRA
+
+#include "bitfield-abi-warning.h"
+
+/* In f1, f2, f4, f8, f16, f16p (and stdarg versions):  */
+/* { dg-final { scan-assembler-times "and\tw0, w2, 1" 12 { xfail *-*-* } } } */
+/* In fp, f1p, f2p, f4p, f8p (and stdarg versions):  */
+/* { dg-final { scan-assembler-times "and\tw0, w1, 1" 10 { xfail *-*-* } } } */
+
+/* Bitfield parameter in registers.  */
+/* { dg-message {parameter passing for argument of type 'S1' changed in GCC 9.1} "" { target *-*-* } 47 } f1 */
+/* { dg-message {parameter passing for argument of type 'S2' changed in GCC 9.1} "" { target *-*-* } 48 } f2 */
+/* { dg-message {parameter passing for argument of type 'S4' changed in GCC 9.1} "" { target *-*-* } 49 } f4 */
+/* { dg-message {parameter passing for argument of type 'S8' changed in GCC 9.1} "" { target *-*-* } 50 } f8 */
+
+/* No change in parameter passing in GCC 9.1 for lines 53-57 (fp, f1p, f2p,
+   f4p, f8p) (because the argument fits in a single register).  Should not
+   warn, but aarch64_function_arg_boundary would need to take the argument size
+   into account as well as whether it's passed via registers or the stack.  */
+/* { dg-message {parameter passing for argument of type 'Sp' changed in GCC 9.1} "" { target *-*-* } 53 }  fp */
+/* { dg-message {parameter passing for argument of type 'S1p' changed in GCC 9.1} "" { target *-*-* } 54 } f1p */
+/* { dg-message {parameter passing for argument of type 'S2p' changed in GCC 9.1} "" { target *-*-* } 55 } f2p */
+/* { dg-message {parameter passing for argument of type 'S4p' changed in GCC 9.1} "" { target *-*-* } 56 } f4p */
+/* { dg-message {parameter passing for argument of type 'S8p' changed in GCC 9.1} "" { target *-*-* } 57 } f8p */
+
+/* Bitfield call argument in registers.  */
+/* { dg-message {parameter passing for argument of type 'S1' changed in GCC 9.1} ""  { target *-*-* } 60 } g1 */
+/* { dg-message {parameter passing for argument of type 'S2' changed in GCC 9.1} ""  { target *-*-* } 61 } g2 */
+/* { dg-message {parameter passing for argument of type 'S4' changed in GCC 9.1} ""  { target *-*-* } 62 } g4 */
+/* { dg-message {parameter passing for argument of type 'S8' changed in GCC 9.1} ""  { target *-*-* } 63 } g8 */
+
+/* No change in parameter passing in GCC 9.1 for lines 66-70 (gp, g1p, g2p,
+   g4p, g8p), no warning expected.  */
+
+
+/* Bitfield parameter in stack.  */
+/* { dg-message {parameter passing for argument of type 'S1' changed in GCC 9.1} "" { target *-*-* } 74 } f1_stack */
+/* { dg-message {parameter passing for argument of type 'S2' changed in GCC 9.1} "" { target *-*-* } 75 } f2_stack */
+/* { dg-message {parameter passing for argument of type 'S4' changed in GCC 9.1} "" { target *-*-* } 76 } f4_stack */
+/* { dg-message {parameter passing for argument of type 'S8' changed in GCC 9.1} "" { target *-*-* } 77 } f8_stack */
+
+/* { dg-message {parameter passing for argument of type 'Sp' changed in GCC 9.1} "" { target *-*-* } 80 }  fp_stack */
+/* { dg-message {parameter passing for argument of type 'S1p' changed in GCC 9.1} "" { target *-*-* } 81 } f1p_stack */
+/* { dg-message {parameter passing for argument of type 'S2p' changed in GCC 9.1} "" { target *-*-* } 82 } f2p_stack */
+/* { dg-message {parameter passing for argument of type 'S4p' changed in GCC 9.1} "" { target *-*-* } 83 } f4p_stack */
+/* { dg-message {parameter passing for argument of type 'S8p' changed in GCC 9.1} "" { target *-*-* } 84 } f8p_stack */
+
+/* Bitfield call argument in stack.  */
+/* { dg-message {parameter passing for argument of type 'S1' changed in GCC 9.1} ""  { target *-*-* } 87 } g1_stack */
+/* { dg-message {parameter passing for argument of type 'S2' changed in GCC 9.1} ""  { target *-*-* } 88 } g2_stack */
+/* { dg-message {parameter passing for argument of type 'S4' changed in GCC 9.1} ""  { target *-*-* } 89 } g4_stack */
+/* { dg-message {parameter passing for argument of type 'S8' changed in GCC 9.1} ""  { target *-*-* } 90 } g8_stack */
+
+/* { dg-message {parameter passing for argument of type 'Sp' changed in GCC 9.1} "" { target *-*-* } 93 }  gp_stack */
+/* { dg-message {parameter passing for argument of type 'S1p' changed in GCC 9.1} "" { target *-*-* } 94 } g1p_stack */
+/* { dg-message {parameter passing for argument of type 'S2p' changed in GCC 9.1} "" { target *-*-* } 95 } g2p_stack */
+/* { dg-message {parameter passing for argument of type 'S4p' changed in GCC 9.1} "" { target *-*-* } 96 } g4p_stack */
+/* { dg-message {parameter passing for argument of type 'S8p' changed in GCC 9.1} "" { target *-*-* } 97 } g8p_stack */
+
+
+/* Bitfield parameter in stdarg.  */
+/* { dg-message {parameter passing for argument of type 'S1' changed in GCC 9.1} "" { target *-*-* } 101 } f1_stdarg */
+/* { dg-message {parameter passing for argument of type 'S2' changed in GCC 9.1} "" { target *-*-* } 102 } f2_stdarg */
+/* { dg-message {parameter passing for argument of type 'S4' changed in GCC 9.1} "" { target *-*-* } 103 } f4_stdarg */
+/* { dg-message {parameter passing for argument of type 'S8' changed in GCC 9.1} "" { target *-*-* } 104 } f8_stdarg */
+
+/* Parameter passing for these should not have changed in GCC 9.1 (PR 105549).
+   Fortunately we warn. Note the discrepancy with lines 120-124 below: we warn
+   in the callee, but not in the caller.  */
+/* { dg-message {parameter passing for argument of type 'Sp' changed in GCC 9.1} "" { target *-*-* } 107 }  fp_stdarg */
+/* { dg-message {parameter passing for argument of type 'S1p' changed in GCC 9.1} "" { target *-*-* } 108 } f1p_stdarg */
+/* { dg-message {parameter passing for argument of type 'S2p' changed in GCC 9.1} "" { target *-*-* } 109 } f2p_stdarg */
+/* { dg-message {parameter passing for argument of type 'S4p' changed in GCC 9.1} "" { target *-*-* } 110 } f4p_stdarg */
+/* { dg-message {parameter passing for argument of type 'S8p' changed in GCC 9.1} "" { target *-*-* } 111 } f8p_stdarg */
+
+/* Bitfield call argument in stdarg.  */
+/* { dg-message {parameter passing for argument of type 'S1' changed in GCC 9.1} ""  { target *-*-* } 114 } g1_stdarg */
+/* { dg-message {parameter passing for argument of type 'S2' changed in GCC 9.1} ""  { target *-*-* } 115 } g2_stdarg */
+/* { dg-message {parameter passing for argument of type 'S4' changed in GCC 9.1} ""  { target *-*-* } 116 } g4_stdarg */
+/* { dg-message {parameter passing for argument of type 'S8' changed in GCC 9.1} ""  { target *-*-* } 117 } g8_stdarg */
+
+/* No change in parameter passing in GCC 9.1 for lines 120-124 (gp_stdarg
+   g1p_stdarg, g2p_stdarg, g4p_stdarg, g8p_stdarg), no warning expected.  */
diff --git a/gcc/testsuite/g++.target/aarch64/bitfield-abi-warning-align32-O2-extra.C b/gcc/testsuite/g++.target/aarch64/bitfield-abi-warning-align32-O2-extra.C
new file mode 100644
index 00000000000..4b226cad7f7
--- /dev/null
+++ b/gcc/testsuite/g++.target/aarch64/bitfield-abi-warning-align32-O2-extra.C
@@ -0,0 +1,119 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -save-temps -Wno-narrowing" } */
+
+#define ALIGN 32
+//#define EXTRA
+
+#include "bitfield-abi-warning.h"
+
+
+/* In f1, f2, f4, f8, f16 (and stdarg versions):  */
+/* { dg-final { scan-assembler-times "ldr\tx0, \\\[x1\\\]" 10 } } */
+
+/* In fp, f1p, f2p, f4p, f8p (and stdarg versions):  */
+/* { dg-final { scan-assembler-times "and\tw0, w1, 1" 10 { xfail *-*-* } } } */
+
+/* In f16p (and stdarg version):  */
+/* { dg-final { scan-assembler-times "and\tw0, w2, 1" 2 { xfail *-*-* } } } */
+
+/* In f1_stack, f2_stack, f4_stack, f8_stack, f16_stack, f8p_stack:  */
+/* { dg-final { scan-assembler-times "ldr\tx\[0-9\]+, \\\[sp, 8\\\]" 6 { xfail *-*-* } } } */
+
+/* In fp_stack, f1p_stack:  */
+/* { dg-final { scan-assembler-times "ldrb\tw0, \\\[sp, 8\\\]" 2 { xfail *-*-* } } } */
+
+/* In f2p_stack:  */
+/* { dg-final { scan-assembler-times "ldrh\tw0, \\\[sp, 8\\\]" 1 { xfail *-*-* } } } */
+
+/* In f4p_stack:  */
+/* { dg-final { scan-assembler-times "ldr\tw0, \\\[sp, 8\\\]" 1 { xfail *-*-* } } } */
+
+/* In f16p_stack:  */
+/* { dg-final { scan-assembler-times "ldr\tx0, \\\[sp, 16\\\]" 1 { xfail *-*-* } } } */
+
+/* Bitfield parameter in registers.  */
+/* No change in parameter passing in GCC 9.1 for lines 47-51 (f1, f2, f4, f8, f16)
+   because the overall alignment is > 16.  No warning expected.  */
+
+/* No change in parameter passing in GCC 9.1 for lines 53-57 (fp, f1p, f2p,
+   f4p, f8p) because the argument fits in a single register.  Should not warn,
+   but aarch64_function_arg_boundary would need to take the argument size into
+   account as well as whether it's passed via registers or the stack.  */
+/* { dg-message {parameter passing for argument of type 'Sp' changed in GCC 9.1}  "" { target *-*-* } 53 } fp */
+/* { dg-message {parameter passing for argument of type 'S1p' changed in GCC 9.1} "" { target *-*-* } 54 } f1p */
+/* { dg-message {parameter passing for argument of type 'S2p' changed in GCC 9.1} "" { target *-*-* } 55 } f2p */
+/* { dg-message {parameter passing for argument of type 'S4p' changed in GCC 9.1} "" { target *-*-* } 56 } f4p */
+/* { dg-message {parameter passing for argument of type 'S8p' changed in GCC 9.1} "" { target *-*-* } 57 } f8p */
+
+/* Changed in GCC 9.1.  */
+/* { dg-message {parameter passing for argument of type 'S16p' changed in GCC 9.1} "" { target *-*-* } 58 } f16p */
+
+
+/* Bitfield call argument in registers.  */
+/* No change in parameter passing in GCC 9.1 for lines 60-64 (g1, g2, g4, g8, g16)
+   because the overall alignment is > 16.  No warning expected.  */
+
+/* No change in parameter passing in GCC 9.1 for lines 66-70 (gp, g1p, g2p,
+   g4p, g8p), no warning expected.  */
+
+/* Changed in GCC 9.1, but we fail to emit a warning.  */
+/* { dg-message {parameter passing for argument of type 'S16p' changed in GCC 9.1} "" { xfail *-*-* } 71 } g16p */
+
+
+/* Bitfield parameter in stack.  */
+/* No change in parameter passing in GCC 9.1 for lines 74-78 (f1_stack,
+   f2_stack, f4_stack, f8_stack, f16_stack) because the overall alignment is >
+   16.  No warning expected.  */
+
+/* Changed in GCC 9.1.  */
+/* { dg-message {parameter passing for argument of type 'Sp' changed in GCC 9.1}  "" { target *-*-* } 80 } fp_stack */
+/* { dg-message {parameter passing for argument of type 'S1p' changed in GCC 9.1} "" { target *-*-* } 81 } f1p_stack */
+/* { dg-message {parameter passing for argument of type 'S2p' changed in GCC 9.1} "" { target *-*-* } 82 } f2p_stack */
+/* { dg-message {parameter passing for argument of type 'S4p' changed in GCC 9.1} "" { target *-*-* } 83 } f4p_stack */
+/* { dg-message {parameter passing for argument of type 'S8p' changed in GCC 9.1} "" { target *-*-* } 84 } f8p_stack */
+
+/* No change in parameter passing in GCC 9.1 for line 85 (f16p_stack) because
+   the overall alignment is >= 16.  No warning expected.  */
+
+
+/* Bitfield call argument in stack.  */
+/* No change in parameter passing in GCC 9.1 for lines 87-91 (g1_stack,
+   g2_stack, g4_stack, g8_stack, g16_stack) because the overall alignment is >
+   16.  No warning expected.  */
+
+/* { dg-message {parameter passing for argument of type 'Sp' changed in GCC 9.1}  "" { target *-*-* } 93 } gp_stack */
+/* { dg-message {parameter passing for argument of type 'S1p' changed in GCC 9.1} "" { target *-*-* } 94 } g1p_stack */
+/* { dg-message {parameter passing for argument of type 'S2p' changed in GCC 9.1} "" { target *-*-* } 95 } g2p_stack */
+/* { dg-message {parameter passing for argument of type 'S4p' changed in GCC 9.1} "" { target *-*-* } 96 } g4p_stack */
+/* { dg-message {parameter passing for argument of type 'S8p' changed in GCC 9.1} "" { target *-*-* } 97 } g8p_stack */
+
+
+/* No change in parameter passing in GCC 9.1 for line 98 (g16p_stack).  No
+   warning expected.  */
+
+
+/* Bitfield parameter in stdarg.  */
+/* No change in parameter passing in GCC 9.1 for lines 101-105 (f1_stdarg,
+   f2_stdarg, f4_stdarg, f8_stdarg, f16_stdarg) because the overall alignment
+   is > 16.  No warning expected.  */
+
+/* { dg-message {parameter passing for argument of type 'Sp' changed in GCC 9.1}   "" { target *-*-* } 107 } fp_stdarg */
+/* { dg-message {parameter passing for argument of type 'S1p' changed in GCC 9.1}  "" { target *-*-* } 108 } f1p_stdarg */
+/* { dg-message {parameter passing for argument of type 'S2p' changed in GCC 9.1}  "" { target *-*-* } 109 } f2p_stdarg */
+/* { dg-message {parameter passing for argument of type 'S4p' changed in GCC 9.1}  "" { target *-*-* } 110 } f4p_stdarg */
+/* { dg-message {parameter passing for argument of type 'S8p' changed in GCC 9.1}  "" { target *-*-* } 111 } f8p_stdarg */
+
+/* No change in parameter passing in GCC 9.1 for line 112 (f16p_stdarg).
+   Should not warn.  */
+/* { dg-message {parameter passing for argument of type 'S16p' changed in GCC 9.1} "" { target *-*-* } 112 } f16p_stdarg */
+
+/* Bitfield call argument in stdarg.  */
+/* No change in parameter passing in GCC 9.1 for lines 114-118 (g1_stdarg,
+   g2_stdarg, g4_stdarg, g8_stdarg, g16_stdarg) because the overall alignment
+   is > 16.  No warning expected.  */
+
+/* No change in parameter passing in GCC 9.1 for lines 120-124 (gp_stdarg,
+   g1p_stdarg, g2p_stdarg, g4p_stdarg, g8p_stdarg), no warning expected.  */
+
+/* Changed in GCC 9.1, but we fail to emit a warning.  */
+/* { dg-message {parameter passing for argument of type 'S16p' changed in GCC 9.1} "" { xfail *-*-* } 125 } g16p_stdarg */
diff --git a/gcc/testsuite/g++.target/aarch64/bitfield-abi-warning-align32-O2.C b/gcc/testsuite/g++.target/aarch64/bitfield-abi-warning-align32-O2.C
new file mode 100644
index 00000000000..c5bbc90b958
--- /dev/null
+++ b/gcc/testsuite/g++.target/aarch64/bitfield-abi-warning-align32-O2.C
@@ -0,0 +1,119 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -save-temps -Wno-narrowing" } */
+
+#define ALIGN 32
+#define EXTRA
+
+#include "bitfield-abi-warning.h"
+
+/* In f1, f2, f4, f8, f16 (and stdarg versions):  */
+/* { dg-final { scan-assembler-times "ldr\tx0, \\\[x1\\\]" 10 } } */
+
+/* In fp, f1p, f2p, f4p, f8p (and stdarg versions):  */
+/* { dg-final { scan-assembler-times "and\tw0, w1, 1" 10 { xfail *-*-* } } } */
+
+/* In f16p (and stdarg version):  */
+/* { dg-final { scan-assembler-times "and\tw0, w2, 1" 2 { xfail *-*-* } } } */
+
+/* In f1_stack, f2_stack, f4_stack, f8_stack, f16_stack, f8p_stack:  */
+/* { dg-final { scan-assembler-times "ldr\tx\[0-9\]+, \\\[sp, 8\\\]" 6 { xfail *-*-* } } } */
+
+/* In fp_stack, f1p_stack:  */
+/* { dg-final { scan-assembler-times "ldrb\tw0, \\\[sp, 8\\\]" 2 { xfail *-*-* } } } */
+
+/* In f2p_stack:  */
+/* { dg-final { scan-assembler-times "ldrh\tw0, \\\[sp, 8\\\]" 1 { xfail *-*-* } } } */
+
+/* In f4p_stack:  */
+/* { dg-final { scan-assembler-times "ldr\tw0, \\\[sp, 8\\\]" 1 { xfail *-*-* } } } */
+
+/* In f16p_stack:  */
+/* { dg-final { scan-assembler-times "ldr\tx0, \\\[sp, 16\\\]" 1 { xfail *-*-* } } } */
+
+/* Bitfield parameter in registers.  */
+/* No change in parameter passing in GCC 9.1 for lines 47-51 (f1, f2, f4, f8, f16)
+   because the overall alignment is > 16.  No warning expected.  */
+
+/* No change in parameter passing in GCC 9.1 for lines 53-57 (fp, f1p, f2p,
+   f4p, f8p) because the argument fits in a single register.  Should not warn,
+   but aarch64_function_arg_boundary would need to take the argument size into
+   account as well as whether it's passed via registers or the stack.  */
+/* { dg-message {parameter passing for argument of type 'Sp' changed in GCC 9.1}  "" { target *-*-* } 53 } fp */
+/* { dg-message {parameter passing for argument of type 'S1p' changed in GCC 9.1} "" { target *-*-* } 54 } f1p */
+/* { dg-message {parameter passing for argument of type 'S2p' changed in GCC 9.1} "" { target *-*-* } 55 } f2p */
+/* { dg-message {parameter passing for argument of type 'S4p' changed in GCC 9.1} "" { target *-*-* } 56 } f4p */
+/* { dg-message {parameter passing for argument of type 'S8p' changed in GCC 9.1} "" { target *-*-* } 57 } f8p */
+
+/* Changed in GCC 9.1.  */
+/* { dg-message {parameter passing for argument of type 'S16p' changed in GCC 9.1} "" { target *-*-* } 58 } f16p */
+
+
+/* Bitfield call argument in registers.  */
+/* No change in parameter passing in GCC 9.1 for lines 60-64 (g1, g2, g4, g8, g16)
+   because the overall alignment is > 16.  No warning expected.  */
+
+/* No change in parameter passing in GCC 9.1 for lines 66-70 (gp, g1p, g2p,
+   g4p, g8p), no warning expected.  */
+
+/* Changed in GCC 9.1, but we fail to emit a warning.  */
+/* { dg-message {parameter passing for argument of type 'S16p' changed in GCC 9.1} "" { xfail *-*-* } 71 } g16p */
+
+
+/* Bitfield parameter in stack.  */
+/* No change in parameter passing in GCC 9.1 for lines 74-78 (f1_stack,
+   f2_stack, f4_stack, f8_stack, f16_stack) because the overall alignment is >
+   16.  No warning expected.  */
+
+/* { dg-message {parameter passing for argument of type 'Sp' changed in GCC 9.1}  "" { target *-*-* } 80 } fp_stack */
+/* { dg-message {parameter passing for argument of type 'S1p' changed in GCC 9.1} "" { target *-*-* } 81 } f1p_stack */
+/* { dg-message {parameter passing for argument of type 'S2p' changed in GCC 9.1} "" { target *-*-* } 82 } f2p_stack */
+/* { dg-message {parameter passing for argument of type 'S4p' changed in GCC 9.1} "" { target *-*-* } 83 } f4p_stack */
+/* { dg-message {parameter passing for argument of type 'S8p' changed in GCC 9.1} "" { target *-*-* } 84 } f8p_stack */
+
+/* No change in parameter passing in GCC 9.1 for line 85 (f16p_stack) because
+   the overall alignment is >= 16.  No warning expected.  */
+
+/* Bitfield call argument in stack.  */
+/* No change in parameter passing in GCC 9.1 for lines 87-91 (g1_stack,
+   g2_stack, g4_stack, g8_stack, g16_stack) because the overall alignment is >
+   16.  No warning expected.  */
+
+/* { dg-message {parameter passing for argument of type 'Sp' changed in GCC 9.1}  "" { target *-*-* } 93 } gp_stack */
+/* { dg-message {parameter passing for argument of type 'S1p' changed in GCC 9.1} "" { target *-*-* } 94 } g1p_stack */
+/* { dg-message {parameter passing for argument of type 'S2p' changed in GCC 9.1} "" { target *-*-* } 95 } g2p_stack */
+/* { dg-message {parameter passing for argument of type 'S4p' changed in GCC 9.1} "" { target *-*-* } 96 } g4p_stack */
+/* { dg-message {parameter passing for argument of type 'S8p' changed in GCC 9.1} "" { target *-*-* } 97 } g8p_stack */
+
+
+/* No change in parameter passing in GCC 9.1 for line 98 (g16p_stack).  No
+   warning expected.  */
+
+
+/* Bitfield parameter in stdarg.  */
+/* No change in parameter passing in GCC 9.1 for lines 101-105 (f1_stdarg,
+   f2_stdarg, f4_stdarg, f8_stdarg, f16_stdarg) because the overall alignment
+   is > 16.  No warning expected.  */
+
+/* Parameter passing for these should not have changed in GCC 9.1 (PR 105549).
+   Fortunately we warn. Note the discrepancy with lines 120-124 below: we warn
+   in the callee, but not in the caller.  */
+/* { dg-message {parameter passing for argument of type 'Sp' changed in GCC 9.1}   "" { target *-*-* } 107 } fp_stdarg */
+/* { dg-message {parameter passing for argument of type 'S1p' changed in GCC 9.1}  "" { target *-*-* } 108 } f1p_stdarg */
+/* { dg-message {parameter passing for argument of type 'S2p' changed in GCC 9.1}  "" { target *-*-* } 109 } f2p_stdarg */
+/* { dg-message {parameter passing for argument of type 'S4p' changed in GCC 9.1}  "" { target *-*-* } 110 } f4p_stdarg */
+/* { dg-message {parameter passing for argument of type 'S8p' changed in GCC 9.1}  "" { target *-*-* } 111 } f8p_stdarg */
+
+/* No change in parameter passing in GCC 9.1 for line 112 (f16p_stdarg).
+   Should not warn.  */
+/* { dg-message {parameter passing for argument of type 'S16p' changed in GCC 9.1} "" { target *-*-* } 112 } f16p_stdarg */
+
+/* Bitfield call argument in stdarg.  */
+/* No change in parameter passing in GCC 9.1 for lines 114-118 (g1_stdarg,
+   g2_stdarg, g4_stdarg, g8_stdarg, g16_stdarg) because the overall alignment
+   is > 16.  No warning expected.  */
+
+/* No change in parameter passing in GCC 9.1 for lines 120-124 (gp_stdarg,
+   g1p_stdarg, g2p_stdarg, g4p_stdarg, g8p_stdarg), no warning expected.  */
+
+/* Changed in GCC 9.1, but we fail to emit a warning.  */
+/* { dg-message {parameter passing for argument of type 'S16p' changed in GCC 9.1} "" { xfail *-*-* } 125 } g16p_stdarg */
diff --git a/gcc/testsuite/g++.target/aarch64/bitfield-abi-warning-align8-O2.C b/gcc/testsuite/g++.target/aarch64/bitfield-abi-warning-align8-O2.C
new file mode 100644
index 00000000000..b1764d97ea0
--- /dev/null
+++ b/gcc/testsuite/g++.target/aarch64/bitfield-abi-warning-align8-O2.C
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -save-temps -Wno-narrowing" } */
+
+#define ALIGN 8
+#define EXTRA
+
+#include "bitfield-abi-warning.h"
+
+/* In f1, f2, f4, f8, fp, f1p, f2p, f4p, f8p (and stdarg versions):  */
+/* { dg-final { scan-assembler-times "and\tw0, w1, 1" 18 } } */
+
+/* In f16, f16p (and stdarg versions):  */
+/* { dg-final { scan-assembler-times "and\tw0, w2, 1" 4 } } */
+
+/* In f1, f2, f4, f8, f16, fp, f1p, f2p, f4p, f8p, f16p stack versions:  */
+/* { dg-final { scan-assembler-times "and\tw0, w0, 1" 11 } } */
diff --git a/gcc/testsuite/g++.target/aarch64/bitfield-abi-warning.h b/gcc/testsuite/g++.target/aarch64/bitfield-abi-warning.h
new file mode 100644
index 00000000000..3940b714ef8
--- /dev/null
+++ b/gcc/testsuite/g++.target/aarch64/bitfield-abi-warning.h
@@ -0,0 +1,125 @@
+#include <stdarg.h>
+
+typedef unsigned long long ull __attribute__((aligned(ALIGN)));
+
+#ifndef EXTRA
+#define EXTRA unsigned long long x;
+#endif
+
+struct S1  { __attribute__((aligned(1))) ull i : 1; EXTRA };
+struct S2  { __attribute__((aligned(2))) ull i : 1; EXTRA };
+struct S4  { __attribute__((aligned(4))) ull i : 1; EXTRA };
+struct S8  { __attribute__((aligned(8))) ull i : 1; EXTRA };
+struct S16 { __attribute__((aligned(16))) ull i : 1; EXTRA };
+
+struct Sp   { ull i : 1; EXTRA }__attribute__((packed));
+struct S1p  { __attribute__((packed, aligned(1))) ull i : 1; EXTRA };
+struct S2p  { __attribute__((packed, aligned(2))) ull i : 1; EXTRA };
+struct S4p  { __attribute__((packed, aligned(4))) ull i : 1; EXTRA };
+struct S8p  { __attribute__((packed, aligned(8))) ull i : 1; EXTRA };
+struct S16p { __attribute__((packed, aligned(16))) ull i : 1; EXTRA };
+
+/* Bitfield in registers.  */
+#define PARAMS(xx) int a0, struct S##xx s, ull a1
+/* Bitfield passed by the stack.  */
+#define PARAMS_STACK(xx) int a0, ull a1, ull a2, ull a3, ull a4, ull a5, ull a6, ull a7, ull a8, struct S##xx t
+/* Bitfield passed via stdarg.  */
+#define PARAMS_STDARG(xx) int a0, ...
+
+#define CODE(xx)				\
+  return s.i;
+
+#define CODE_STACK(xx)				\
+  return t.i;
+
+#define CODE_STDARG(xx)				\
+  va_list ap;					\
+  struct S##xx arg;				\
+  __builtin_va_start(ap,a0);			\
+  arg = __builtin_va_arg(ap, struct S##xx);	\
+  return arg.i;
+
+#define ARGS(xx) x, (struct S##xx) { x }, x
+#define ARGS_STACK(xx) x, x, x, x, x, x, x, x, x, (struct S##xx) { x }
+#define ARGS_STDARG(xx) x, (struct S##xx) { x }
+
+/* Bitfield in registers.  */
+int __attribute__ ((noipa)) f1 (PARAMS(1))  { CODE(1) }
+int __attribute__ ((noipa)) f2 (PARAMS(2))  { CODE(2) }
+int __attribute__ ((noipa)) f4 (PARAMS(4))  { CODE(4) }
+int __attribute__ ((noipa)) f8 (PARAMS(8))  { CODE(8) }
+int __attribute__ ((noipa)) f16(PARAMS(16)) { CODE(16) }
+
+int __attribute__ ((noipa)) fp  (PARAMS(p))   { CODE(p) }
+int __attribute__ ((noipa)) f1p (PARAMS(1p))  { CODE(1p) }
+int __attribute__ ((noipa)) f2p (PARAMS(2p))  { CODE(2p) }
+int __attribute__ ((noipa)) f4p (PARAMS(4p))  { CODE(4p) }
+int __attribute__ ((noipa)) f8p (PARAMS(8p))  { CODE(8p) }
+int __attribute__ ((noipa)) f16p(PARAMS(16p)) { CODE(16p) }
+
+int g1 (int x) { return f1 (ARGS(1)); }
+int g2 (int x) { return f2 (ARGS(2)); }
+int g4 (int x) { return f4 (ARGS(4)); }
+int g8 (int x) { return f8 (ARGS(8)); }
+int g16(int x) { return f16 (ARGS(16)); }
+
+int gp  (int x) { return fp   (ARGS(p)); }
+int g1p (int x) { return f1p  (ARGS(1p)); }
+int g2p (int x) { return f2p  (ARGS(2p)); }
+int g4p (int x) { return f4p  (ARGS(4p)); }
+int g8p (int x) { return f8p  (ARGS(8p)); }
+int g16p(int x) { return f16p (ARGS(16p)); }
+
+/* Bitfield in the stack.  */
+int __attribute__ ((noipa)) f1_stack (PARAMS_STACK(1))  { CODE_STACK(1) }
+int __attribute__ ((noipa)) f2_stack (PARAMS_STACK(2))  { CODE_STACK(2) }
+int __attribute__ ((noipa)) f4_stack (PARAMS_STACK(4))  { CODE_STACK(4) }
+int __attribute__ ((noipa)) f8_stack (PARAMS_STACK(8))  { CODE_STACK(8) }
+int __attribute__ ((noipa)) f16_stack(PARAMS_STACK(16)) { CODE_STACK(16) }
+
+int __attribute__ ((noipa)) fp_stack  (PARAMS_STACK(p))   { CODE_STACK(p) }
+int __attribute__ ((noipa)) f1p_stack (PARAMS_STACK(1p))  { CODE_STACK(1p) }
+int __attribute__ ((noipa)) f2p_stack (PARAMS_STACK(2p))  { CODE_STACK(2p) }
+int __attribute__ ((noipa)) f4p_stack (PARAMS_STACK(4p))  { CODE_STACK(4p) }
+int __attribute__ ((noipa)) f8p_stack (PARAMS_STACK(8p))  { CODE_STACK(8p) }
+int __attribute__ ((noipa)) f16p_stack(PARAMS_STACK(16p)) { CODE_STACK(16p) }
+
+int g1_stack (int x) { return f1_stack (ARGS_STACK(1)); }
+int g2_stack (int x) { return f2_stack (ARGS_STACK(2)); }
+int g4_stack (int x) { return f4_stack (ARGS_STACK(4)); }
+int g8_stack (int x) { return f8_stack (ARGS_STACK(8)); }
+int g16_stack(int x) { return f16_stack (ARGS_STACK(16)); }
+
+int gp_stack  (int x) { return fp_stack (ARGS_STACK(p)); }
+int g1p_stack (int x) { return f1p_stack (ARGS_STACK(1p)); }
+int g2p_stack (int x) { return f2p_stack (ARGS_STACK(2p)); }
+int g4p_stack (int x) { return f4p_stack (ARGS_STACK(4p)); }
+int g8p_stack (int x) { return f8p_stack (ARGS_STACK(8p)); }
+int g16p_stack(int x) { return f16p_stack (ARGS_STACK(16p)); }
+
+/* Bitfield  via stdarg.  */
+int __attribute__ ((noipa)) f1_stdarg (PARAMS_STDARG(1))  { CODE_STDARG(1) }
+int __attribute__ ((noipa)) f2_stdarg (PARAMS_STDARG(2))  { CODE_STDARG(2) }
+int __attribute__ ((noipa)) f4_stdarg (PARAMS_STDARG(4))  { CODE_STDARG(4) }
+int __attribute__ ((noipa)) f8_stdarg (PARAMS_STDARG(8))  { CODE_STDARG(8) }
+int __attribute__ ((noipa)) f16_stdarg(PARAMS_STDARG(16)) { CODE_STDARG(16) }
+
+int __attribute__ ((noipa)) fp_stdarg  (PARAMS_STDARG(p))   { CODE_STDARG(p) }
+int __attribute__ ((noipa)) f1p_stdarg (PARAMS_STDARG(1p))  { CODE_STDARG(1p) }
+int __attribute__ ((noipa)) f2p_stdarg (PARAMS_STDARG(2p))  { CODE_STDARG(2p) }
+int __attribute__ ((noipa)) f4p_stdarg (PARAMS_STDARG(4p))  { CODE_STDARG(4p) }
+int __attribute__ ((noipa)) f8p_stdarg (PARAMS_STDARG(8p))  { CODE_STDARG(8p) }
+int __attribute__ ((noipa)) f16p_stdarg(PARAMS_STDARG(16p)) { CODE_STDARG(16p) }
+
+int g1_stdarg (int x) { return f1_stdarg (ARGS_STDARG(1)); }
+int g2_stdarg (int x) { return f2_stdarg (ARGS_STDARG(2)); }
+int g4_stdarg (int x) { return f4_stdarg (ARGS_STDARG(4)); }
+int g8_stdarg (int x) { return f8_stdarg (ARGS_STDARG(8)); }
+int g16_stdarg(int x) { return f16_stdarg (ARGS_STDARG(16)); }
+
+int gp_stdarg  (int x) { return fp_stdarg (ARGS_STDARG(p)); }
+int g1p_stdarg (int x) { return f1p_stdarg (ARGS_STDARG(1p)); }
+int g2p_stdarg (int x) { return f2p_stdarg (ARGS_STDARG(2p)); }
+int g4p_stdarg (int x) { return f4p_stdarg (ARGS_STDARG(4p)); }
+int g8p_stdarg (int x) { return f8p_stdarg (ARGS_STDARG(8p)); }
+int g16p_stdarg(int x) { return f16p_stdarg (ARGS_STDARG(16p)); }
diff --git a/gcc/testsuite/gcc.target/aarch64/bitfield-abi-warning-align16-O2-extra.c b/gcc/testsuite/gcc.target/aarch64/bitfield-abi-warning-align16-O2-extra.c
new file mode 100644
index 00000000000..56f056daa27
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/bitfield-abi-warning-align16-O2-extra.c
@@ -0,0 +1,86 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -save-temps" } */
+
+#define ALIGN 16
+//#define EXTRA
+
+#include "bitfield-abi-warning.h"
+
+/* In f1, f2, f4, f8, f16, f16p (and stdarg versions):  */
+/* { dg-final { scan-assembler-times "and\tw0, w2, 1" 12 { xfail *-*-* } } } */
+/* In fp, f1p, f2p, f4p, f8p (and stdarg versions):  */
+/* { dg-final { scan-assembler-times "and\tw0, w1, 1" 10 { xfail *-*-* } } } */
+
+/* Bitfield parameter in registers.  */
+/* { dg-message {parameter passing for argument of type 'struct S1' changed in GCC 9.1} "" { target *-*-* } 47 } f1 */
+/* { dg-message {parameter passing for argument of type 'struct S2' changed in GCC 9.1} "" { target *-*-* } 48 } f2 */
+/* { dg-message {parameter passing for argument of type 'struct S4' changed in GCC 9.1} "" { target *-*-* } 49 } f4 */
+/* { dg-message {parameter passing for argument of type 'struct S8' changed in GCC 9.1} "" { target *-*-* } 50 } f8 */
+
+/* { dg-message {parameter passing for argument of type 'struct Sp' changed in GCC 9.1} "" { target *-*-* } 53 }  fp */
+/* { dg-message {parameter passing for argument of type 'struct S1p' changed in GCC 9.1} "" { target *-*-* } 54 } f1p */
+/* { dg-message {parameter passing for argument of type 'struct S2p' changed in GCC 9.1} "" { target *-*-* } 55 } f2p */
+/* { dg-message {parameter passing for argument of type 'struct S4p' changed in GCC 9.1} "" { target *-*-* } 56 } f4p */
+/* { dg-message {parameter passing for argument of type 'struct S8p' changed in GCC 9.1} "" { target *-*-* } 57 } f8p */
+
+/* Bitfield call argument in registers.  */
+/* { dg-message {parameter passing for argument of type 'struct S1' changed in GCC 9.1} ""  { target *-*-* } 60 } g1 */
+/* { dg-message {parameter passing for argument of type 'struct S2' changed in GCC 9.1} ""  { target *-*-* } 61 } g2 */
+/* { dg-message {parameter passing for argument of type 'struct S4' changed in GCC 9.1} ""  { target *-*-* } 62 } g4 */
+/* { dg-message {parameter passing for argument of type 'struct S8' changed in GCC 9.1} ""  { target *-*-* } 63 } g8 */
+
+/* { dg-message {parameter passing for argument of type 'struct Sp' changed in GCC 9.1} "" { target *-*-* } 66 }  gp */
+/* { dg-message {parameter passing for argument of type 'struct S1p' changed in GCC 9.1} "" { target *-*-* } 67 } g1p */
+/* { dg-message {parameter passing for argument of type 'struct S2p' changed in GCC 9.1} "" { target *-*-* } 68 } g2p */
+/* { dg-message {parameter passing for argument of type 'struct S4p' changed in GCC 9.1} "" { target *-*-* } 69 } g4p */
+/* { dg-message {parameter passing for argument of type 'struct S8p' changed in GCC 9.1} "" { target *-*-* } 70 } g8p */
+
+
+/* Bitfield parameter in stack.  */
+/* { dg-message {parameter passing for argument of type 'struct S1' changed in GCC 9.1} "" { target *-*-* } 74 } f1_stack */
+/* { dg-message {parameter passing for argument of type 'struct S2' changed in GCC 9.1} "" { target *-*-* } 75 } f2_stack */
+/* { dg-message {parameter passing for argument of type 'struct S4' changed in GCC 9.1} "" { target *-*-* } 76 } f4_stack */
+/* { dg-message {parameter passing for argument of type 'struct S8' changed in GCC 9.1} "" { target *-*-* } 77 } f8_stack */
+
+/* { dg-message {parameter passing for argument of type 'struct Sp' changed in GCC 9.1} "" { target *-*-* } 80 }  fp_stack */
+/* { dg-message {parameter passing for argument of type 'struct S1p' changed in GCC 9.1} "" { target *-*-* } 81 } f1p_stack */
+/* { dg-message {parameter passing for argument of type 'struct S2p' changed in GCC 9.1} "" { target *-*-* } 82 } f2p_stack */
+/* { dg-message {parameter passing for argument of type 'struct S4p' changed in GCC 9.1} "" { target *-*-* } 83 } f4p_stack */
+/* { dg-message {parameter passing for argument of type 'struct S8p' changed in GCC 9.1} "" { target *-*-* } 84 } f8p_stack */
+
+/* Bitfield call argument in stack.  */
+/* { dg-message {parameter passing for argument of type 'struct S1' changed in GCC 9.1} ""  { target *-*-* } 87 } g1_stack */
+/* { dg-message {parameter passing for argument of type 'struct S2' changed in GCC 9.1} ""  { target *-*-* } 88 } g2_stack */
+/* { dg-message {parameter passing for argument of type 'struct S4' changed in GCC 9.1} ""  { target *-*-* } 89 } g4_stack */
+/* { dg-message {parameter passing for argument of type 'struct S8' changed in GCC 9.1} ""  { target *-*-* } 90 } g8_stack */
+
+/* { dg-message {parameter passing for argument of type 'struct Sp' changed in GCC 9.1} "" { target *-*-* } 93 }  gp_stack */
+/* { dg-message {parameter passing for argument of type 'struct S1p' changed in GCC 9.1} "" { target *-*-* } 94 } g1p_stack */
+/* { dg-message {parameter passing for argument of type 'struct S2p' changed in GCC 9.1} "" { target *-*-* } 95 } g2p_stack */
+/* { dg-message {parameter passing for argument of type 'struct S4p' changed in GCC 9.1} "" { target *-*-* } 96 } g4p_stack */
+/* { dg-message {parameter passing for argument of type 'struct S8p' changed in GCC 9.1} "" { target *-*-* } 97 } g8p_stack */
+
+
+/* Bitfield parameter in stdarg.  */
+/* { dg-message {parameter passing for argument of type 'struct S1' changed in GCC 9.1} "" { target *-*-* } 101 } f1_stdarg */
+/* { dg-message {parameter passing for argument of type 'struct S2' changed in GCC 9.1} "" { target *-*-* } 102 } f2_stdarg */
+/* { dg-message {parameter passing for argument of type 'struct S4' changed in GCC 9.1} "" { target *-*-* } 103 } f4_stdarg */
+/* { dg-message {parameter passing for argument of type 'struct S8' changed in GCC 9.1} "" { target *-*-* } 104 } f8_stdarg */
+
+/* { dg-message {parameter passing for argument of type 'struct Sp' changed in GCC 9.1} "" { target *-*-* } 107 }  fp_stdarg */
+/* { dg-message {parameter passing for argument of type 'struct S1p' changed in GCC 9.1} "" { target *-*-* } 108 } f1p_stdarg */
+/* { dg-message {parameter passing for argument of type 'struct S2p' changed in GCC 9.1} "" { target *-*-* } 109 } f2p_stdarg */
+/* { dg-message {parameter passing for argument of type 'struct S4p' changed in GCC 9.1} "" { target *-*-* } 110 } f4p_stdarg */
+/* { dg-message {parameter passing for argument of type 'struct S8p' changed in GCC 9.1} "" { target *-*-* } 111 } f8p_stdarg */
+
+/* Bitfield call argument in stdarg.  */
+/* { dg-message {parameter passing for argument of type 'struct S1' changed in GCC 9.1} ""  { target *-*-* } 114 } g1_stdarg */
+/* { dg-message {parameter passing for argument of type 'struct S2' changed in GCC 9.1} ""  { target *-*-* } 115 } g2_stdarg */
+/* { dg-message {parameter passing for argument of type 'struct S4' changed in GCC 9.1} ""  { target *-*-* } 116 } g4_stdarg */
+/* { dg-message {parameter passing for argument of type 'struct S8' changed in GCC 9.1} ""  { target *-*-* } 117 } g8_stdarg */
+
+/* { dg-message {parameter passing for argument of type 'struct Sp' changed in GCC 9.1} "" { target *-*-* } 120 }  gp_stdarg */
+/* { dg-message {parameter passing for argument of type 'struct S1p' changed in GCC 9.1} "" { target *-*-* } 121 } g1p_stdarg */
+/* { dg-message {parameter passing for argument of type 'struct S2p' changed in GCC 9.1} "" { target *-*-* } 122 } g2p_stdarg */
+/* { dg-message {parameter passing for argument of type 'struct S4p' changed in GCC 9.1} "" { target *-*-* } 123 } g4p_stdarg */
+/* { dg-message {parameter passing for argument of type 'struct S8p' changed in GCC 9.1} "" { target *-*-* } 124 } g8p_stdarg */
diff --git a/gcc/testsuite/gcc.target/aarch64/bitfield-abi-warning-align16-O2.c b/gcc/testsuite/gcc.target/aarch64/bitfield-abi-warning-align16-O2.c
new file mode 100644
index 00000000000..add33e479a6
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/bitfield-abi-warning-align16-O2.c
@@ -0,0 +1,87 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -save-temps" } */
+
+#define ALIGN 16
+#define EXTRA
+
+#include "bitfield-abi-warning.h"
+
+/* In f1, f2, f4, f8, f16, f16p (and stdarg versions):  */
+/* { dg-final { scan-assembler-times "and\tw0, w2, 1" 12 { xfail *-*-* } } } */
+/* In fp, f1p, f2p, f4p, f8p (and stdarg versions):  */
+/* { dg-final { scan-assembler-times "and\tw0, w1, 1" 10 { xfail *-*-* } } } */
+
+/* Bitfield parameter in registers.  */
+/* { dg-message {parameter passing for argument of type 'struct S1' changed in GCC 9.1} "" { target *-*-* } 47 } f1 */
+/* { dg-message {parameter passing for argument of type 'struct S2' changed in GCC 9.1} "" { target *-*-* } 48 } f2 */
+/* { dg-message {parameter passing for argument of type 'struct S4' changed in GCC 9.1} "" { target *-*-* } 49 } f4 */
+/* { dg-message {parameter passing for argument of type 'struct S8' changed in GCC 9.1} "" { target *-*-* } 50 } f8 */
+
+/* No change in parameter passing in GCC 9.1 for lines 53-57 (fp, f1p, f2p,
+   f4p, f8p) (because the argument fits in a single register).  Should not
+   warn, but aarch64_function_arg_boundary would need to take the argument size
+   into account as well as whether it's passed via registers or the stack.  */
+/* { dg-message {parameter passing for argument of type 'struct Sp' changed in GCC 9.1} "" { target *-*-* } 53 }  fp */
+/* { dg-message {parameter passing for argument of type 'struct S1p' changed in GCC 9.1} "" { target *-*-* } 54 } f1p */
+/* { dg-message {parameter passing for argument of type 'struct S2p' changed in GCC 9.1} "" { target *-*-* } 55 } f2p */
+/* { dg-message {parameter passing for argument of type 'struct S4p' changed in GCC 9.1} "" { target *-*-* } 56 } f4p */
+/* { dg-message {parameter passing for argument of type 'struct S8p' changed in GCC 9.1} "" { target *-*-* } 57 } f8p */
+
+/* Bitfield call argument in registers.  */
+/* { dg-message {parameter passing for argument of type 'struct S1' changed in GCC 9.1} ""  { target *-*-* } 60 } g1 */
+/* { dg-message {parameter passing for argument of type 'struct S2' changed in GCC 9.1} ""  { target *-*-* } 61 } g2 */
+/* { dg-message {parameter passing for argument of type 'struct S4' changed in GCC 9.1} ""  { target *-*-* } 62 } g4 */
+/* { dg-message {parameter passing for argument of type 'struct S8' changed in GCC 9.1} ""  { target *-*-* } 63 } g8 */
+
+/* No change in parameter passing in GCC 9.1 for lines 66-70 (gp, g1p, g2p,
+   g4p, g8p), no warning expected.  */
+
+
+/* Bitfield parameter in stack.  */
+/* { dg-message {parameter passing for argument of type 'struct S1' changed in GCC 9.1} "" { target *-*-* } 74 } f1_stack */
+/* { dg-message {parameter passing for argument of type 'struct S2' changed in GCC 9.1} "" { target *-*-* } 75 } f2_stack */
+/* { dg-message {parameter passing for argument of type 'struct S4' changed in GCC 9.1} "" { target *-*-* } 76 } f4_stack */
+/* { dg-message {parameter passing for argument of type 'struct S8' changed in GCC 9.1} "" { target *-*-* } 77 } f8_stack */
+
+/* { dg-message {parameter passing for argument of type 'struct Sp' changed in GCC 9.1} "" { target *-*-* } 80 }  fp_stack */
+/* { dg-message {parameter passing for argument of type 'struct S1p' changed in GCC 9.1} "" { target *-*-* } 81 } f1p_stack */
+/* { dg-message {parameter passing for argument of type 'struct S2p' changed in GCC 9.1} "" { target *-*-* } 82 } f2p_stack */
+/* { dg-message {parameter passing for argument of type 'struct S4p' changed in GCC 9.1} "" { target *-*-* } 83 } f4p_stack */
+/* { dg-message {parameter passing for argument of type 'struct S8p' changed in GCC 9.1} "" { target *-*-* } 84 } f8p_stack */
+
+/* Bitfield call argument in stack.  */
+/* { dg-message {parameter passing for argument of type 'struct S1' changed in GCC 9.1} ""  { target *-*-* } 87 } g1_stack */
+/* { dg-message {parameter passing for argument of type 'struct S2' changed in GCC 9.1} ""  { target *-*-* } 88 } g2_stack */
+/* { dg-message {parameter passing for argument of type 'struct S4' changed in GCC 9.1} ""  { target *-*-* } 89 } g4_stack */
+/* { dg-message {parameter passing for argument of type 'struct S8' changed in GCC 9.1} ""  { target *-*-* } 90 } g8_stack */
+
+/* { dg-message {parameter passing for argument of type 'struct Sp' changed in GCC 9.1} "" { target *-*-* } 93 }  gp_stack */
+/* { dg-message {parameter passing for argument of type 'struct S1p' changed in GCC 9.1} "" { target *-*-* } 94 } g1p_stack */
+/* { dg-message {parameter passing for argument of type 'struct S2p' changed in GCC 9.1} "" { target *-*-* } 95 } g2p_stack */
+/* { dg-message {parameter passing for argument of type 'struct S4p' changed in GCC 9.1} "" { target *-*-* } 96 } g4p_stack */
+/* { dg-message {parameter passing for argument of type 'struct S8p' changed in GCC 9.1} "" { target *-*-* } 97 } g8p_stack */
+
+
+/* Bitfield parameter in stdarg.  */
+/* { dg-message {parameter passing for argument of type 'struct S1' changed in GCC 9.1} "" { target *-*-* } 101 } f1_stdarg */
+/* { dg-message {parameter passing for argument of type 'struct S2' changed in GCC 9.1} "" { target *-*-* } 102 } f2_stdarg */
+/* { dg-message {parameter passing for argument of type 'struct S4' changed in GCC 9.1} "" { target *-*-* } 103 } f4_stdarg */
+/* { dg-message {parameter passing for argument of type 'struct S8' changed in GCC 9.1} "" { target *-*-* } 104 } f8_stdarg */
+
+/* Parameter passing for these should not have changed in GCC 9.1 (PR 105549).
+   Fortunately we warn. Note the discrepancy with lines 120-124 below: we warn
+   in the callee, but not in the caller.  */
+/* { dg-message {parameter passing for argument of type 'struct Sp' changed in GCC 9.1} "" { target *-*-* } 107 }  fp_stdarg */
+/* { dg-message {parameter passing for argument of type 'struct S1p' changed in GCC 9.1} "" { target *-*-* } 108 } f1p_stdarg */
+/* { dg-message {parameter passing for argument of type 'struct S2p' changed in GCC 9.1} "" { target *-*-* } 109 } f2p_stdarg */
+/* { dg-message {parameter passing for argument of type 'struct S4p' changed in GCC 9.1} "" { target *-*-* } 110 } f4p_stdarg */
+/* { dg-message {parameter passing for argument of type 'struct S8p' changed in GCC 9.1} "" { target *-*-* } 111 } f8p_stdarg */
+
+/* Bitfield call argument in stdarg.  */
+/* { dg-message {parameter passing for argument of type 'struct S1' changed in GCC 9.1} ""  { target *-*-* } 114 } g1_stdarg */
+/* { dg-message {parameter passing for argument of type 'struct S2' changed in GCC 9.1} ""  { target *-*-* } 115 } g2_stdarg */
+/* { dg-message {parameter passing for argument of type 'struct S4' changed in GCC 9.1} ""  { target *-*-* } 116 } g4_stdarg */
+/* { dg-message {parameter passing for argument of type 'struct S8' changed in GCC 9.1} ""  { target *-*-* } 117 } g8_stdarg */
+
+/* No change in parameter passing in GCC 9.1 for lines 120-124 (gp_stdarg
+   g1p_stdarg, g2p_stdarg, g4p_stdarg, g8p_stdarg), no warning expected.  */
diff --git a/gcc/testsuite/gcc.target/aarch64/bitfield-abi-warning-align32-O2-extra.c b/gcc/testsuite/gcc.target/aarch64/bitfield-abi-warning-align32-O2-extra.c
new file mode 100644
index 00000000000..f46e360000c
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/bitfield-abi-warning-align32-O2-extra.c
@@ -0,0 +1,119 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -save-temps" } */
+
+#define ALIGN 32
+//#define EXTRA
+
+#include "bitfield-abi-warning.h"
+
+
+/* In f1, f2, f4, f8, f16 (and stdarg versions):  */
+/* { dg-final { scan-assembler-times "ldr\tx0, \\\[x1\\\]" 10 } } */
+
+/* In fp, f1p, f2p, f4p, f8p (and stdarg versions):  */
+/* { dg-final { scan-assembler-times "and\tw0, w1, 1" 10 { xfail *-*-* } } } */
+
+/* In f16p (and stdarg version):  */
+/* { dg-final { scan-assembler-times "and\tw0, w2, 1" 2 { xfail *-*-* } } } */
+
+/* In f1_stack, f2_stack, f4_stack, f8_stack, f16_stack, f8p_stack:  */
+/* { dg-final { scan-assembler-times "ldr\tx\[0-9\]+, \\\[sp, 8\\\]" 6 { xfail *-*-* } } } */
+
+/* In fp_stack, f1p_stack:  */
+/* { dg-final { scan-assembler-times "ldrb\tw0, \\\[sp, 8\\\]" 2 { xfail *-*-* } } } */
+
+/* In f2p_stack:  */
+/* { dg-final { scan-assembler-times "ldrh\tw0, \\\[sp, 8\\\]" 1 { xfail *-*-* } } } */
+
+/* In f4p_stack:  */
+/* { dg-final { scan-assembler-times "ldr\tw0, \\\[sp, 8\\\]" 1 { xfail *-*-* } } } */
+
+/* In f16p_stack:  */
+/* { dg-final { scan-assembler-times "ldr\tx0, \\\[sp, 16\\\]" 1 { xfail *-*-* } } } */
+
+/* Bitfield parameter in registers.  */
+/* No change in parameter passing in GCC 9.1 for lines 47-51 (f1, f2, f4, f8, f16)
+   because the overall alignment is > 16.  No warning expected.  */
+
+/* No change in parameter passing in GCC 9.1 for lines 53-57 (fp, f1p, f2p,
+   f4p, f8p) because the argument fits in a single register.  Should not warn,
+   but aarch64_function_arg_boundary would need to take the argument size into
+   account as well as whether it's passed via registers or the stack.  */
+/* { dg-message {parameter passing for argument of type 'struct Sp' changed in GCC 9.1}  "" { target *-*-* } 53 } fp */
+/* { dg-message {parameter passing for argument of type 'struct S1p' changed in GCC 9.1} "" { target *-*-* } 54 } f1p */
+/* { dg-message {parameter passing for argument of type 'struct S2p' changed in GCC 9.1} "" { target *-*-* } 55 } f2p */
+/* { dg-message {parameter passing for argument of type 'struct S4p' changed in GCC 9.1} "" { target *-*-* } 56 } f4p */
+/* { dg-message {parameter passing for argument of type 'struct S8p' changed in GCC 9.1} "" { target *-*-* } 57 } f8p */
+
+/* Changed in GCC 9.1.  */
+/* { dg-message {parameter passing for argument of type 'struct S16p' changed in GCC 9.1} "" { target *-*-* } 58 } f16p */
+
+
+/* Bitfield call argument in registers.  */
+/* No change in parameter passing in GCC 9.1 for lines 60-64 (g1, g2, g4, g8, g16)
+   because the overall alignment is > 16.  No warning expected.  */
+
+/* No change in parameter passing in GCC 9.1 for lines 66-70 (gp, g1p, g2p,
+   g4p, g8p), no warning expected.  */
+
+/* Changed in GCC 9.1, but we fail to emit a warning.  */
+/* { dg-message {parameter passing for argument of type 'struct S16p' changed in GCC 9.1} "" { xfail *-*-* } 71 } g16p */
+
+
+/* Bitfield parameter in stack.  */
+/* No change in parameter passing in GCC 9.1 for lines 74-78 (f1_stack,
+   f2_stack, f4_stack, f8_stack, f16_stack) because the overall alignment is >
+   16.  No warning expected.  */
+
+/* Changed in GCC 9.1.  */
+/* { dg-message {parameter passing for argument of type 'struct Sp' changed in GCC 9.1}  "" { target *-*-* } 80 } fp_stack */
+/* { dg-message {parameter passing for argument of type 'struct S1p' changed in GCC 9.1} "" { target *-*-* } 81 } f1p_stack */
+/* { dg-message {parameter passing for argument of type 'struct S2p' changed in GCC 9.1} "" { target *-*-* } 82 } f2p_stack */
+/* { dg-message {parameter passing for argument of type 'struct S4p' changed in GCC 9.1} "" { target *-*-* } 83 } f4p_stack */
+/* { dg-message {parameter passing for argument of type 'struct S8p' changed in GCC 9.1} "" { target *-*-* } 84 } f8p_stack */
+
+/* No change in parameter passing in GCC 9.1 for line 85 (f16p_stack) because
+   the overall alignment is >= 16.  No warning expected.  */
+
+
+/* Bitfield call argument in stack.  */
+/* No change in parameter passing in GCC 9.1 for lines 87-91 (g1_stack,
+   g2_stack, g4_stack, g8_stack, g16_stack) because the overall alignment is >
+   16.  No warning expected.  */
+
+/* { dg-message {parameter passing for argument of type 'struct Sp' changed in GCC 9.1}  "" { target *-*-* } 93 } gp_stack */
+/* { dg-message {parameter passing for argument of type 'struct S1p' changed in GCC 9.1} "" { target *-*-* } 94 } g1p_stack */
+/* { dg-message {parameter passing for argument of type 'struct S2p' changed in GCC 9.1} "" { target *-*-* } 95 } g2p_stack */
+/* { dg-message {parameter passing for argument of type 'struct S4p' changed in GCC 9.1} "" { target *-*-* } 96 } g4p_stack */
+/* { dg-message {parameter passing for argument of type 'struct S8p' changed in GCC 9.1} "" { target *-*-* } 97 } g8p_stack */
+
+
+/* No change in parameter passing in GCC 9.1 for line 98 (g16p_stack).  No
+   warning expected.  */
+
+
+/* Bitfield parameter in stdarg.  */
+/* No change in parameter passing in GCC 9.1 for lines 101-105 (f1_stdarg,
+   f2_stdarg, f4_stdarg, f8_stdarg, f16_stdarg) because the overall alignment
+   is > 16.  No warning expected.  */
+
+/* { dg-message {parameter passing for argument of type 'struct Sp' changed in GCC 9.1}   "" { target *-*-* } 107 } fp_stdarg */
+/* { dg-message {parameter passing for argument of type 'struct S1p' changed in GCC 9.1}  "" { target *-*-* } 108 } f1p_stdarg */
+/* { dg-message {parameter passing for argument of type 'struct S2p' changed in GCC 9.1}  "" { target *-*-* } 109 } f2p_stdarg */
+/* { dg-message {parameter passing for argument of type 'struct S4p' changed in GCC 9.1}  "" { target *-*-* } 110 } f4p_stdarg */
+/* { dg-message {parameter passing for argument of type 'struct S8p' changed in GCC 9.1}  "" { target *-*-* } 111 } f8p_stdarg */
+
+/* No change in parameter passing in GCC 9.1 for line 112 (f16p_stdarg).
+   Should not warn.  */
+/* { dg-message {parameter passing for argument of type 'struct S16p' changed in GCC 9.1} "" { target *-*-* } 112 } f16p_stdarg */
+
+/* Bitfield call argument in stdarg.  */
+/* No change in parameter passing in GCC 9.1 for lines 114-118 (g1_stdarg,
+   g2_stdarg, g4_stdarg, g8_stdarg, g16_stdarg) because the overall alignment
+   is > 16.  No warning expected.  */
+
+/* No change in parameter passing in GCC 9.1 for lines 120-124 (gp_stdarg,
+   g1p_stdarg, g2p_stdarg, g4p_stdarg, g8p_stdarg), no warning expected.  */
+
+/* Changed in GCC 9.1, but we fail to emit a warning.  */
+/* { dg-message {parameter passing for argument of type 'struct S16p' changed in GCC 9.1} "" { xfail *-*-* } 125 } g16p_stdarg */
diff --git a/gcc/testsuite/gcc.target/aarch64/bitfield-abi-warning-align32-O2.c b/gcc/testsuite/gcc.target/aarch64/bitfield-abi-warning-align32-O2.c
new file mode 100644
index 00000000000..10ea456222f
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/bitfield-abi-warning-align32-O2.c
@@ -0,0 +1,119 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -save-temps" } */
+
+#define ALIGN 32
+#define EXTRA
+
+#include "bitfield-abi-warning.h"
+
+/* In f1, f2, f4, f8, f16 (and stdarg versions):  */
+/* { dg-final { scan-assembler-times "ldr\tx0, \\\[x1\\\]" 10 } } */
+
+/* In fp, f1p, f2p, f4p, f8p (and stdarg versions):  */
+/* { dg-final { scan-assembler-times "and\tw0, w1, 1" 10 { xfail *-*-* } } } */
+
+/* In f16p (and stdarg version):  */
+/* { dg-final { scan-assembler-times "and\tw0, w2, 1" 2 { xfail *-*-* } } } */
+
+/* In f1_stack, f2_stack, f4_stack, f8_stack, f16_stack, f8p_stack:  */
+/* { dg-final { scan-assembler-times "ldr\tx\[0-9\]+, \\\[sp, 8\\\]" 6 { xfail *-*-* } } } */
+
+/* In fp_stack, f1p_stack:  */
+/* { dg-final { scan-assembler-times "ldrb\tw0, \\\[sp, 8\\\]" 2 { xfail *-*-* } } } */
+
+/* In f2p_stack:  */
+/* { dg-final { scan-assembler-times "ldrh\tw0, \\\[sp, 8\\\]" 1 { xfail *-*-* } } } */
+
+/* In f4p_stack:  */
+/* { dg-final { scan-assembler-times "ldr\tw0, \\\[sp, 8\\\]" 1 { xfail *-*-* } } } */
+
+/* In f16p_stack:  */
+/* { dg-final { scan-assembler-times "ldr\tx0, \\\[sp, 16\\\]" 1 { xfail *-*-* } } } */
+
+/* Bitfield parameter in registers.  */
+/* No change in parameter passing in GCC 9.1 for lines 47-51 (f1, f2, f4, f8, f16)
+   because the overall alignment is > 16.  No warning expected.  */
+
+/* No change in parameter passing in GCC 9.1 for lines 53-57 (fp, f1p, f2p,
+   f4p, f8p) because the argument fits in a single register.  Should not warn,
+   but aarch64_function_arg_boundary would need to take the argument size into
+   account as well as whether it's passed via registers or the stack.  */
+/* { dg-message {parameter passing for argument of type 'struct Sp' changed in GCC 9.1}  "" { target *-*-* } 53 } fp */
+/* { dg-message {parameter passing for argument of type 'struct S1p' changed in GCC 9.1} "" { target *-*-* } 54 } f1p */
+/* { dg-message {parameter passing for argument of type 'struct S2p' changed in GCC 9.1} "" { target *-*-* } 55 } f2p */
+/* { dg-message {parameter passing for argument of type 'struct S4p' changed in GCC 9.1} "" { target *-*-* } 56 } f4p */
+/* { dg-message {parameter passing for argument of type 'struct S8p' changed in GCC 9.1} "" { target *-*-* } 57 } f8p */
+
+/* Changed in GCC 9.1.  */
+/* { dg-message {parameter passing for argument of type 'struct S16p' changed in GCC 9.1} "" { target *-*-* } 58 } f16p */
+
+
+/* Bitfield call argument in registers.  */
+/* No change in parameter passing in GCC 9.1 for lines 60-64 (g1, g2, g4, g8, g16)
+   because the overall alignment is > 16.  No warning expected.  */
+
+/* No change in parameter passing in GCC 9.1 for lines 66-70 (gp, g1p, g2p,
+   g4p, g8p), no warning expected.  */
+
+/* Changed in GCC 9.1, but we fail to emit a warning.  */
+/* { dg-message {parameter passing for argument of type 'struct S16p' changed in GCC 9.1} "" { xfail *-*-* } 71 } g16p */
+
+
+/* Bitfield parameter in stack.  */
+/* No change in parameter passing in GCC 9.1 for lines 74-78 (f1_stack,
+   f2_stack, f4_stack, f8_stack, f16_stack) because the overall alignment is >
+   16.  No warning expected.  */
+
+/* { dg-message {parameter passing for argument of type 'struct Sp' changed in GCC 9.1}  "" { target *-*-* } 80 } fp_stack */
+/* { dg-message {parameter passing for argument of type 'struct S1p' changed in GCC 9.1} "" { target *-*-* } 81 } f1p_stack */
+/* { dg-message {parameter passing for argument of type 'struct S2p' changed in GCC 9.1} "" { target *-*-* } 82 } f2p_stack */
+/* { dg-message {parameter passing for argument of type 'struct S4p' changed in GCC 9.1} "" { target *-*-* } 83 } f4p_stack */
+/* { dg-message {parameter passing for argument of type 'struct S8p' changed in GCC 9.1} "" { target *-*-* } 84 } f8p_stack */
+
+/* No change in parameter passing in GCC 9.1 for line 85 (f16p_stack) because
+   the overall alignment is >= 16.  No warning expected.  */
+
+/* Bitfield call argument in stack.  */
+/* No change in parameter passing in GCC 9.1 for lines 87-91 (g1_stack,
+   g2_stack, g4_stack, g8_stack, g16_stack) because the overall alignment is >
+   16.  No warning expected.  */
+
+/* { dg-message {parameter passing for argument of type 'struct Sp' changed in GCC 9.1}  "" { target *-*-* } 93 } gp_stack */
+/* { dg-message {parameter passing for argument of type 'struct S1p' changed in GCC 9.1} "" { target *-*-* } 94 } g1p_stack */
+/* { dg-message {parameter passing for argument of type 'struct S2p' changed in GCC 9.1} "" { target *-*-* } 95 } g2p_stack */
+/* { dg-message {parameter passing for argument of type 'struct S4p' changed in GCC 9.1} "" { target *-*-* } 96 } g4p_stack */
+/* { dg-message {parameter passing for argument of type 'struct S8p' changed in GCC 9.1} "" { target *-*-* } 97 } g8p_stack */
+
+
+/* No change in parameter passing in GCC 9.1 for line 98 (g16p_stack).  No
+   warning expected.  */
+
+
+/* Bitfield parameter in stdarg.  */
+/* No change in parameter passing in GCC 9.1 for lines 101-105 (f1_stdarg,
+   f2_stdarg, f4_stdarg, f8_stdarg, f16_stdarg) because the overall alignment
+   is > 16.  No warning expected.  */
+
+/* Parameter passing for these should not have changed in GCC 9.1 (PR 105549).
+   Fortunately we warn. Note the discrepancy with lines 120-124 below: we warn
+   in the callee, but not in the caller.  */
+/* { dg-message {parameter passing for argument of type 'struct Sp' changed in GCC 9.1}   "" { target *-*-* } 107 } fp_stdarg */
+/* { dg-message {parameter passing for argument of type 'struct S1p' changed in GCC 9.1}  "" { target *-*-* } 108 } f1p_stdarg */
+/* { dg-message {parameter passing for argument of type 'struct S2p' changed in GCC 9.1}  "" { target *-*-* } 109 } f2p_stdarg */
+/* { dg-message {parameter passing for argument of type 'struct S4p' changed in GCC 9.1}  "" { target *-*-* } 110 } f4p_stdarg */
+/* { dg-message {parameter passing for argument of type 'struct S8p' changed in GCC 9.1}  "" { target *-*-* } 111 } f8p_stdarg */
+
+/* No change in parameter passing in GCC 9.1 for line 112 (f16p_stdarg).
+   Should not warn.  */
+/* { dg-message {parameter passing for argument of type 'struct S16p' changed in GCC 9.1} "" { target *-*-* } 112 } f16p_stdarg */
+
+/* Bitfield call argument in stdarg.  */
+/* No change in parameter passing in GCC 9.1 for lines 114-118 (g1_stdarg,
+   g2_stdarg, g4_stdarg, g8_stdarg, g16_stdarg) because the overall alignment
+   is > 16.  No warning expected.  */
+
+/* No change in parameter passing in GCC 9.1 for lines 120-124 (gp_stdarg,
+   g1p_stdarg, g2p_stdarg, g4p_stdarg, g8p_stdarg), no warning expected.  */
+
+/* Changed in GCC 9.1, but we fail to emit a warning.  */
+/* { dg-message {parameter passing for argument of type 'struct S16p' changed in GCC 9.1} "" { xfail *-*-* } 125 } g16p_stdarg */
diff --git a/gcc/testsuite/gcc.target/aarch64/bitfield-abi-warning-align8-O2.c b/gcc/testsuite/gcc.target/aarch64/bitfield-abi-warning-align8-O2.c
new file mode 100644
index 00000000000..cb2a945a819
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/bitfield-abi-warning-align8-O2.c
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -save-temps" } */
+
+#define ALIGN 8
+#define EXTRA
+
+#include "bitfield-abi-warning.h"
+
+/* In f1, f2, f4, f8, fp, f1p, f2p, f4p, f8p (and stdarg versions):  */
+/* { dg-final { scan-assembler-times "and\tw0, w1, 1" 18 } } */
+
+/* In f16, f16p (and stdarg versions):  */
+/* { dg-final { scan-assembler-times "and\tw0, w2, 1" 4 } } */
+
+/* In f1, f2, f4, f8, f16, fp, f1p, f2p, f4p, f8p, f16p stack versions:  */
+/* { dg-final { scan-assembler-times "and\tw0, w0, 1" 11 } } */
diff --git a/gcc/testsuite/gcc.target/aarch64/bitfield-abi-warning.h b/gcc/testsuite/gcc.target/aarch64/bitfield-abi-warning.h
new file mode 100644
index 00000000000..3940b714ef8
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/bitfield-abi-warning.h
@@ -0,0 +1,125 @@
+#include <stdarg.h>
+
+typedef unsigned long long ull __attribute__((aligned(ALIGN)));
+
+#ifndef EXTRA
+#define EXTRA unsigned long long x;
+#endif
+
+struct S1  { __attribute__((aligned(1))) ull i : 1; EXTRA };
+struct S2  { __attribute__((aligned(2))) ull i : 1; EXTRA };
+struct S4  { __attribute__((aligned(4))) ull i : 1; EXTRA };
+struct S8  { __attribute__((aligned(8))) ull i : 1; EXTRA };
+struct S16 { __attribute__((aligned(16))) ull i : 1; EXTRA };
+
+struct Sp   { ull i : 1; EXTRA }__attribute__((packed));
+struct S1p  { __attribute__((packed, aligned(1))) ull i : 1; EXTRA };
+struct S2p  { __attribute__((packed, aligned(2))) ull i : 1; EXTRA };
+struct S4p  { __attribute__((packed, aligned(4))) ull i : 1; EXTRA };
+struct S8p  { __attribute__((packed, aligned(8))) ull i : 1; EXTRA };
+struct S16p { __attribute__((packed, aligned(16))) ull i : 1; EXTRA };
+
+/* Bitfield in registers.  */
+#define PARAMS(xx) int a0, struct S##xx s, ull a1
+/* Bitfield passed by the stack.  */
+#define PARAMS_STACK(xx) int a0, ull a1, ull a2, ull a3, ull a4, ull a5, ull a6, ull a7, ull a8, struct S##xx t
+/* Bitfield passed via stdarg.  */
+#define PARAMS_STDARG(xx) int a0, ...
+
+#define CODE(xx)				\
+  return s.i;
+
+#define CODE_STACK(xx)				\
+  return t.i;
+
+#define CODE_STDARG(xx)				\
+  va_list ap;					\
+  struct S##xx arg;				\
+  __builtin_va_start(ap,a0);			\
+  arg = __builtin_va_arg(ap, struct S##xx);	\
+  return arg.i;
+
+#define ARGS(xx) x, (struct S##xx) { x }, x
+#define ARGS_STACK(xx) x, x, x, x, x, x, x, x, x, (struct S##xx) { x }
+#define ARGS_STDARG(xx) x, (struct S##xx) { x }
+
+/* Bitfield in registers.  */
+int __attribute__ ((noipa)) f1 (PARAMS(1))  { CODE(1) }
+int __attribute__ ((noipa)) f2 (PARAMS(2))  { CODE(2) }
+int __attribute__ ((noipa)) f4 (PARAMS(4))  { CODE(4) }
+int __attribute__ ((noipa)) f8 (PARAMS(8))  { CODE(8) }
+int __attribute__ ((noipa)) f16(PARAMS(16)) { CODE(16) }
+
+int __attribute__ ((noipa)) fp  (PARAMS(p))   { CODE(p) }
+int __attribute__ ((noipa)) f1p (PARAMS(1p))  { CODE(1p) }
+int __attribute__ ((noipa)) f2p (PARAMS(2p))  { CODE(2p) }
+int __attribute__ ((noipa)) f4p (PARAMS(4p))  { CODE(4p) }
+int __attribute__ ((noipa)) f8p (PARAMS(8p))  { CODE(8p) }
+int __attribute__ ((noipa)) f16p(PARAMS(16p)) { CODE(16p) }
+
+int g1 (int x) { return f1 (ARGS(1)); }
+int g2 (int x) { return f2 (ARGS(2)); }
+int g4 (int x) { return f4 (ARGS(4)); }
+int g8 (int x) { return f8 (ARGS(8)); }
+int g16(int x) { return f16 (ARGS(16)); }
+
+int gp  (int x) { return fp   (ARGS(p)); }
+int g1p (int x) { return f1p  (ARGS(1p)); }
+int g2p (int x) { return f2p  (ARGS(2p)); }
+int g4p (int x) { return f4p  (ARGS(4p)); }
+int g8p (int x) { return f8p  (ARGS(8p)); }
+int g16p(int x) { return f16p (ARGS(16p)); }
+
+/* Bitfield in the stack.  */
+int __attribute__ ((noipa)) f1_stack (PARAMS_STACK(1))  { CODE_STACK(1) }
+int __attribute__ ((noipa)) f2_stack (PARAMS_STACK(2))  { CODE_STACK(2) }
+int __attribute__ ((noipa)) f4_stack (PARAMS_STACK(4))  { CODE_STACK(4) }
+int __attribute__ ((noipa)) f8_stack (PARAMS_STACK(8))  { CODE_STACK(8) }
+int __attribute__ ((noipa)) f16_stack(PARAMS_STACK(16)) { CODE_STACK(16) }
+
+int __attribute__ ((noipa)) fp_stack  (PARAMS_STACK(p))   { CODE_STACK(p) }
+int __attribute__ ((noipa)) f1p_stack (PARAMS_STACK(1p))  { CODE_STACK(1p) }
+int __attribute__ ((noipa)) f2p_stack (PARAMS_STACK(2p))  { CODE_STACK(2p) }
+int __attribute__ ((noipa)) f4p_stack (PARAMS_STACK(4p))  { CODE_STACK(4p) }
+int __attribute__ ((noipa)) f8p_stack (PARAMS_STACK(8p))  { CODE_STACK(8p) }
+int __attribute__ ((noipa)) f16p_stack(PARAMS_STACK(16p)) { CODE_STACK(16p) }
+
+int g1_stack (int x) { return f1_stack (ARGS_STACK(1)); }
+int g2_stack (int x) { return f2_stack (ARGS_STACK(2)); }
+int g4_stack (int x) { return f4_stack (ARGS_STACK(4)); }
+int g8_stack (int x) { return f8_stack (ARGS_STACK(8)); }
+int g16_stack(int x) { return f16_stack (ARGS_STACK(16)); }
+
+int gp_stack  (int x) { return fp_stack (ARGS_STACK(p)); }
+int g1p_stack (int x) { return f1p_stack (ARGS_STACK(1p)); }
+int g2p_stack (int x) { return f2p_stack (ARGS_STACK(2p)); }
+int g4p_stack (int x) { return f4p_stack (ARGS_STACK(4p)); }
+int g8p_stack (int x) { return f8p_stack (ARGS_STACK(8p)); }
+int g16p_stack(int x) { return f16p_stack (ARGS_STACK(16p)); }
+
+/* Bitfield  via stdarg.  */
+int __attribute__ ((noipa)) f1_stdarg (PARAMS_STDARG(1))  { CODE_STDARG(1) }
+int __attribute__ ((noipa)) f2_stdarg (PARAMS_STDARG(2))  { CODE_STDARG(2) }
+int __attribute__ ((noipa)) f4_stdarg (PARAMS_STDARG(4))  { CODE_STDARG(4) }
+int __attribute__ ((noipa)) f8_stdarg (PARAMS_STDARG(8))  { CODE_STDARG(8) }
+int __attribute__ ((noipa)) f16_stdarg(PARAMS_STDARG(16)) { CODE_STDARG(16) }
+
+int __attribute__ ((noipa)) fp_stdarg  (PARAMS_STDARG(p))   { CODE_STDARG(p) }
+int __attribute__ ((noipa)) f1p_stdarg (PARAMS_STDARG(1p))  { CODE_STDARG(1p) }
+int __attribute__ ((noipa)) f2p_stdarg (PARAMS_STDARG(2p))  { CODE_STDARG(2p) }
+int __attribute__ ((noipa)) f4p_stdarg (PARAMS_STDARG(4p))  { CODE_STDARG(4p) }
+int __attribute__ ((noipa)) f8p_stdarg (PARAMS_STDARG(8p))  { CODE_STDARG(8p) }
+int __attribute__ ((noipa)) f16p_stdarg(PARAMS_STDARG(16p)) { CODE_STDARG(16p) }
+
+int g1_stdarg (int x) { return f1_stdarg (ARGS_STDARG(1)); }
+int g2_stdarg (int x) { return f2_stdarg (ARGS_STDARG(2)); }
+int g4_stdarg (int x) { return f4_stdarg (ARGS_STDARG(4)); }
+int g8_stdarg (int x) { return f8_stdarg (ARGS_STDARG(8)); }
+int g16_stdarg(int x) { return f16_stdarg (ARGS_STDARG(16)); }
+
+int gp_stdarg  (int x) { return fp_stdarg (ARGS_STDARG(p)); }
+int g1p_stdarg (int x) { return f1p_stdarg (ARGS_STDARG(1p)); }
+int g2p_stdarg (int x) { return f2p_stdarg (ARGS_STDARG(2p)); }
+int g4p_stdarg (int x) { return f4p_stdarg (ARGS_STDARG(4p)); }
+int g8p_stdarg (int x) { return f8p_stdarg (ARGS_STDARG(8p)); }
+int g16p_stdarg(int x) { return f16p_stdarg (ARGS_STDARG(16p)); }

commit 67d0312ac61b2d9e498340e63db347df8e1247d3
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Thu Jan 26 00:19:26 2023 +0000

    Daily bump.

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index ef3629c0281..17dd3824c2f 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,18 @@
+2023-01-25  Christophe Lyon  <christophe.lyon@arm.com>
+
+	Backported from master:
+	2023-01-12  Christophe Lyon  <christophe.lyon@arm.com>
+		    Richard Sandiford  <richard.sandiford@arm.com>
+
+	* config/aarch64/aarch64.c (aarch64_function_arg_alignment): Fix
+	comment.
+	(aarch64_layout_arg): Factorize warning conditions.
+	(aarch64_function_arg_boundary): Fix typo.
+	* function.c (currently_expanding_function_start): New variable.
+	(expand_function_start): Handle
+	currently_expanding_function_start.
+	* function.h (currently_expanding_function_start): Declare.
+
 2023-01-24  Sergei Trofimovich  <siarheit@google.com>
 
 	Backported from master:
diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index e26ffa6a16c..b0742d6879d 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230125
+20230126
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index f4121e18043..0085d514707 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,26 @@
+2023-01-25  Christophe Lyon  <christophe.lyon@arm.com>
+
+	Backported from master:
+	2023-01-12  Christophe Lyon  <christophe.lyon@arm.com>
+		    Richard Sandiford  <richard.sandiford@arm.com>
+
+	* gcc.target/aarch64/bitfield-abi-warning-align16-O2.c: New test.
+	* gcc.target/aarch64/bitfield-abi-warning-align16-O2-extra.c: New
+	test.
+	* gcc.target/aarch64/bitfield-abi-warning-align32-O2.c: New test.
+	* gcc.target/aarch64/bitfield-abi-warning-align32-O2-extra.c: New
+	test.
+	* gcc.target/aarch64/bitfield-abi-warning-align8-O2.c: New test.
+	* gcc.target/aarch64/bitfield-abi-warning.h: New test.
+	* g++.target/aarch64/bitfield-abi-warning-align16-O2.C: New test.
+	* g++.target/aarch64/bitfield-abi-warning-align16-O2-extra.C: New
+	test.
+	* g++.target/aarch64/bitfield-abi-warning-align32-O2.C: New test.
+	* g++.target/aarch64/bitfield-abi-warning-align32-O2-extra.C: New
+	test.
+	* g++.target/aarch64/bitfield-abi-warning-align8-O2.C: New test.
+	* g++.target/aarch64/bitfield-abi-warning.h: New test.
+
 2023-01-08  Harald Anlauf  <anlauf@gmx.de>
 
 	Backported from master:

commit d0a3e323a0c0e3db7dcd428587f0633209f9ceec
Author: Richard Biener <rguenther@suse.de>
Date:   Wed Sep 14 09:00:35 2022 +0200

    tree-optimization/106934 - avoid BIT_FIELD_REF of bitfields
    
    The following avoids creating BIT_FIELD_REF of bitfields in
    update-address-taken.  The patch doesn't implement punning to
    a full precision integer type but leaves a comment according to
    that.
    
            PR tree-optimization/106934
            * tree-ssa.c (non_rewritable_mem_ref_base): Avoid BIT_FIELD_REFs
            of bitfields.
            (maybe_rewrite_mem_ref_base): Likewise.
    
            * gfortran.dg/pr106934.f90: New testcase.
    
    (cherry picked from commit 05f5c42cb42c5088187d44cc45a5f671d19ad8c5)

diff --git a/gcc/testsuite/gfortran.dg/pr106934.f90 b/gcc/testsuite/gfortran.dg/pr106934.f90
new file mode 100644
index 00000000000..ac58a3e82e3
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr106934.f90
@@ -0,0 +1,7 @@
+! { dg-do compile }
+! { dg-options "-O" }
+subroutine s
+   logical(1) :: a = .true.
+   logical(2) :: b
+   a = transfer(b, a)
+end
diff --git a/gcc/tree-ssa.c b/gcc/tree-ssa.c
index 4f4ab2b8992..e15cc54567a 100644
--- a/gcc/tree-ssa.c
+++ b/gcc/tree-ssa.c
@@ -1409,6 +1409,8 @@ maybe_rewrite_mem_ref_base (tree *tp, bitmap suitable_for_renaming)
 	       && (! INTEGRAL_TYPE_P (TREE_TYPE (*tp)) 
 		   || (wi::to_offset (TYPE_SIZE (TREE_TYPE (*tp)))
 		       == TYPE_PRECISION (TREE_TYPE (*tp))))
+	       && (! INTEGRAL_TYPE_P (TREE_TYPE (sym))
+		   || type_has_mode_precision_p (TREE_TYPE (sym)))
 	       && wi::umod_trunc (wi::to_offset (TYPE_SIZE (TREE_TYPE (*tp))),
 				  BITS_PER_UNIT) == 0)
 	{
@@ -1481,6 +1483,10 @@ non_rewritable_mem_ref_base (tree ref)
 	  && (! INTEGRAL_TYPE_P (TREE_TYPE (base))
 	      || (wi::to_offset (TYPE_SIZE (TREE_TYPE (base)))
 		  == TYPE_PRECISION (TREE_TYPE (base))))
+	  /* ???  Likewise for extracts from bitfields, we'd have
+	     to pun the base object to a size precision mode first.  */
+	  && (! INTEGRAL_TYPE_P (TREE_TYPE (decl))
+	      || type_has_mode_precision_p (TREE_TYPE (decl)))
 	  && wi::umod_trunc (wi::to_offset (TYPE_SIZE (TREE_TYPE (base))),
 			     BITS_PER_UNIT) == 0)
 	return NULL_TREE;

commit 58e39fcaaf298ff54b6f1a45fa9d15390e8113fb
Author: Richard Biener <rguenther@suse.de>
Date:   Thu Oct 6 11:20:16 2022 +0200

    tree-optimization/107107 - tail-merging VN wrong-code
    
    The following fixes an unintended(?) side-effect of the special
    MODIFY_EXPR expression entries we add for tail-merging during VN.
    We shouldn't value-number the virtual operand differently here.
    
            PR tree-optimization/107107
            * tree-ssa-sccvn.c (visit_reference_op_store): Do not
            affect value-numbering when doing the tail merging
            MODIFY_EXPR lookup.
    
            * gcc.dg/pr107107.c: New testcase.
    
    (cherry picked from commit 85333b9265720fc4e49397301cb16324d2b89aa7)

diff --git a/gcc/testsuite/gcc.dg/pr107107.c b/gcc/testsuite/gcc.dg/pr107107.c
new file mode 100644
index 00000000000..5ad6a63159e
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr107107.c
@@ -0,0 +1,25 @@
+/* { dg-do run } */
+/* { dg-options "-O2 -ftree-tail-merge" } */
+
+static inline void set_longish(int is_long_long, void *p, long x)
+{
+  if (is_long_long)
+    *(long long*)p = x;
+  else
+    *(long*)p = x;
+}
+static long test(long long *p, int index, int mode)
+{
+  *p = 1;
+  set_longish(mode, p+index, 2);
+  return *p;
+}
+long (*volatile vtest)(long long*, int, int) = test;
+int main(void)
+{
+  long long x;
+  long result = vtest(&x, 0, 1);
+  if (result != 2 || x != 2)
+    __builtin_abort ();
+  return 0;
+}
diff --git a/gcc/tree-ssa-sccvn.c b/gcc/tree-ssa-sccvn.c
index 18263bd8c9a..2f6f5074b07 100644
--- a/gcc/tree-ssa-sccvn.c
+++ b/gcc/tree-ssa-sccvn.c
@@ -5113,19 +5113,6 @@ visit_reference_op_store (tree lhs, tree op, gimple *stmt)
 
   if (!resultsame)
     {
-      /* Only perform the following when being called from PRE
-	 which embeds tail merging.  */
-      if (default_vn_walk_kind == VN_WALK)
-	{
-	  assign = build2 (MODIFY_EXPR, TREE_TYPE (lhs), lhs, op);
-	  vn_reference_lookup (assign, vuse, VN_NOWALK, &vnresult, false);
-	  if (vnresult)
-	    {
-	      VN_INFO (vdef)->visited = true;
-	      return set_ssa_val_to (vdef, vnresult->result_vdef);
-	    }
-	}
-
       if (dump_file && (dump_flags & TDF_DETAILS))
 	{
 	  fprintf (dump_file, "No store match\n");
@@ -5150,7 +5137,9 @@ visit_reference_op_store (tree lhs, tree op, gimple *stmt)
       if (default_vn_walk_kind == VN_WALK)
 	{
 	  assign = build2 (MODIFY_EXPR, TREE_TYPE (lhs), lhs, op);
-	  vn_reference_insert (assign, lhs, vuse, vdef);
+	  vn_reference_lookup (assign, vuse, VN_NOWALK, &vnresult, false);
+	  if (!vnresult)
+	    vn_reference_insert (assign, lhs, vuse, vdef);
 	}
     }
   else

commit 95e5c07aa216fe2863ea02e8508a51b5f7528839
Author: Richard Biener <rguenther@suse.de>
Date:   Fri Oct 21 09:45:44 2022 +0200

    tree-optimization/107323 - loop distribution partition ordering issue
    
    The following reverts part of the PR94125 fix which causes us to
    use a bogus partition ordering after applying versioning for
    alias to the testcase in PR107323.  Instead PR94125 is fixed by
    appropriately considering to be merged SCCs when skipping edges
    we want to ignore because of the alias versioning.
    
            PR tree-optimization/107323
            * tree-loop-distribution.c (pg_unmark_merged_alias_ddrs):
            New function.
            (loop_distribution::break_alias_scc_partitions): Revert
            postorder save/restore from the PR94125 fix.  Instead
            make sure to not ignore edges from SCCs we are going to
            merge.
    
            * gcc.dg/tree-ssa/pr107323.c: New testcase.
    
    (cherry picked from commit 09f9814dc02c161ed78604c6df70b19b596f7524)

diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr107323.c b/gcc/testsuite/gcc.dg/tree-ssa/pr107323.c
new file mode 100644
index 00000000000..1204b6e36d5
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr107323.c
@@ -0,0 +1,28 @@
+/* { dg-do run } */
+/* { dg-options "-O2 -fno-tree-vectorize" } */
+
+int A[4];
+int B[4];
+
+static const char *__attribute__((noipa)) foo()
+{
+  return "1";
+}
+
+int main()
+{
+  const char *s = foo();
+
+  A[0] = 1000;
+  for(int i = 1; i < 4; ++i) {
+      B[i] = 0;
+      A[i] = 0;
+      if(s[0])
+	B[i] = 1;
+      A[i] = A[i - 1];
+  }
+
+  if (A[3] != 1000)
+    __builtin_abort ();
+  return 0;
+}
diff --git a/gcc/tree-loop-distribution.c b/gcc/tree-loop-distribution.c
index 3a5f03b3e54..4ef37780f8c 100644
--- a/gcc/tree-loop-distribution.c
+++ b/gcc/tree-loop-distribution.c
@@ -2158,8 +2158,6 @@ struct pg_edge_callback_data
   bitmap sccs_to_merge;
   /* Array constains component information for all vertices.  */
   int *vertices_component;
-  /* Array constains postorder information for all vertices.  */
-  int *vertices_post;
   /* Vector to record all data dependence relations which are needed
      to break strong connected components by runtime alias checks.  */
   vec<ddr_p> *alias_ddrs;
@@ -2408,6 +2406,33 @@ pg_collect_alias_ddrs (struct graph *g, struct graph_edge *e, void *data)
     cbdata->alias_ddrs->safe_splice (edata->alias_ddrs);
 }
 
+/* Callback function for traversing edge E.  DATA is private
+   callback data.  */
+
+static void
+pg_unmark_merged_alias_ddrs (struct graph *, struct graph_edge *e, void *data)
+{
+  int i, j, component;
+  struct pg_edge_callback_data *cbdata;
+  struct pg_edata *edata = (struct pg_edata *) e->data;
+
+  if (edata == NULL || edata->alias_ddrs.length () == 0)
+    return;
+
+  cbdata = (struct pg_edge_callback_data *) data;
+  i = e->src;
+  j = e->dest;
+  component = cbdata->vertices_component[i];
+  /* Make sure to not skip vertices inside SCCs we are going to merge.  */
+  if (component == cbdata->vertices_component[j]
+      && bitmap_bit_p (cbdata->sccs_to_merge, component))
+    {
+      edata->alias_ddrs.release ();
+      delete edata;
+      e->data = NULL;
+    }
+}
+
 /* This is the main function breaking strong conected components in
    PARTITIONS giving reduced depdendence graph RDG.  Store data dependence
    relations for runtime alias check in ALIAS_DDRS.  */
@@ -2467,7 +2492,6 @@ loop_distribution::break_alias_scc_partitions (struct graph *rdg,
       cbdata.sccs_to_merge = sccs_to_merge;
       cbdata.alias_ddrs = alias_ddrs;
       cbdata.vertices_component = XNEWVEC (int, pg->n_vertices);
-      cbdata.vertices_post = XNEWVEC (int, pg->n_vertices);
       /* Record the component information which will be corrupted by next
 	 graph scc finding call.  */
       for (i = 0; i < pg->n_vertices; ++i)
@@ -2476,17 +2500,18 @@ loop_distribution::break_alias_scc_partitions (struct graph *rdg,
       /* Collect data dependences for runtime alias checks to break SCCs.  */
       if (bitmap_count_bits (sccs_to_merge) != (unsigned) num_sccs)
 	{
-	  /* Record the postorder information which will be corrupted by next
-	     graph SCC finding call.  */
-	  for (i = 0; i < pg->n_vertices; ++i)
-	    cbdata.vertices_post[i] = pg->vertices[i].post;
+	  /* For SCCs we want to merge clear all alias_ddrs for edges
+	     inside the component.  */
+	  for_each_edge (pg, pg_unmark_merged_alias_ddrs, &cbdata);
 
 	  /* Run SCC finding algorithm again, with alias dependence edges
 	     skipped.  This is to topologically sort partitions according to
 	     compilation time known dependence.  Note the topological order
 	     is stored in the form of pg's post order number.  */
 	  num_sccs_no_alias = graphds_scc (pg, NULL, pg_skip_alias_edge);
-	  gcc_assert (partitions->length () == (unsigned) num_sccs_no_alias);
+	  /* We cannot assert partitions->length () == num_sccs_no_alias
+	     since we are not ignoring alias edges in cycles we are
+	     going to merge.  That's required to compute correct postorder.  */
 	  /* With topological order, we can construct two subgraphs L and R.
 	     L contains edge <x, y> where x < y in terms of post order, while
 	     R contains edge <x, y> where x > y.  Edges for compilation time
@@ -2521,16 +2546,14 @@ loop_distribution::break_alias_scc_partitions (struct graph *rdg,
 	      first->type = PTYPE_SEQUENTIAL;
 	    }
 	}
-      /* Restore the postorder information if it's corrupted in finding SCC
-	 with alias dependence edges skipped.  If reduction partition's SCC is
-	 broken by runtime alias checks, we force a negative post order to it
-	 making sure it will be scheduled in the last.  */
+      /* If reduction partition's SCC is broken by runtime alias checks,
+	 we force a negative post order to it making sure it will be scheduled
+	 in the last.  */
       if (num_sccs_no_alias > 0)
 	{
 	  j = -1;
 	  for (i = 0; i < pg->n_vertices; ++i)
 	    {
-	      pg->vertices[i].post = cbdata.vertices_post[i];
 	      struct pg_vdata *data = (struct pg_vdata *)pg->vertices[i].data;
 	      if (data->partition && partition_reduction_p (data->partition))
 		{
@@ -2543,7 +2566,6 @@ loop_distribution::break_alias_scc_partitions (struct graph *rdg,
 	}
 
       free (cbdata.vertices_component);
-      free (cbdata.vertices_post);
     }
 
   sort_partitions_by_post_order (pg, partitions);

commit 5d62d86d958a217cdb4155a557aeda1d0e644aba
Author: Richard Biener <rguenther@suse.de>
Date:   Fri Nov 11 14:28:52 2022 +0100

    tree-optimization/107554 - fix ICE in stlen optimization
    
    The following fixes a wrongly typed variable causing an ICE.
    
            PR tree-optimization/107554
            * tree-ssa-strlen.c (strlen_pass::count_nonzero_bytes):
            Use unsigned HOST_WIDE_INT type for the strlen.
    
            * gcc.dg/pr107554.c: New testcase.
    
    Co-Authored-By: Nikita Voronov <nik_1357@mail.ru>
    (cherry picked from commit 81de4037454275f8ed6d858fbc129e832c6147ef)

diff --git a/gcc/testsuite/gcc.dg/pr107554.c b/gcc/testsuite/gcc.dg/pr107554.c
new file mode 100644
index 00000000000..8bbe6b07ae9
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr107554.c
@@ -0,0 +1,12 @@
+/* { dg-do compile } */
+/* { dg-options "-O -foptimize-strlen" } */
+
+#define ELEMS 0x40000000
+
+int a[ELEMS];
+int b[ELEMS];
+
+int main()
+{
+  __builtin_memcpy(a, b, ELEMS*sizeof(int));
+}
diff --git a/gcc/tree-ssa-strlen.c b/gcc/tree-ssa-strlen.c
index b0874da5d1e..cc744adb3a5 100644
--- a/gcc/tree-ssa-strlen.c
+++ b/gcc/tree-ssa-strlen.c
@@ -4783,7 +4783,7 @@ count_nonzero_bytes (tree exp, unsigned HOST_WIDE_INT offset,
 
   /* Compute the number of leading nonzero bytes in the representation
      and update the minimum and maximum.  */
-  unsigned n = prep ? strnlen (prep, nbytes) : nbytes;
+  unsigned HOST_WIDE_INT n = prep ? strnlen (prep, nbytes) : nbytes;
 
   if (n < lenrange[0])
     lenrange[0] = n;

commit 719e672cfe89373c12e86e7a5892c1f0028727fa
Author: Richard Biener <rguenther@suse.de>
Date:   Mon Nov 14 08:08:26 2022 +0100

    restrict gcc.dg/pr107554.c to 64bit platforms
    
    The following avoids exceeding the maximum object size on 32bit
    platforms.
    
            * gcc.dg/pr107554.c: Restrict to lp64.
    
    (cherry picked from commit e7ebdf51ea514ad0b2272ecfa97d6ec72a527e40)

diff --git a/gcc/testsuite/gcc.dg/pr107554.c b/gcc/testsuite/gcc.dg/pr107554.c
index 8bbe6b07ae9..61ef2bcd90a 100644
--- a/gcc/testsuite/gcc.dg/pr107554.c
+++ b/gcc/testsuite/gcc.dg/pr107554.c
@@ -1,4 +1,4 @@
-/* { dg-do compile } */
+/* { dg-do compile { target lp64 } } */
 /* { dg-options "-O -foptimize-strlen" } */
 
 #define ELEMS 0x40000000

commit ea7639422f0a93fb8780088e4d69199dec9de86c
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Fri Jan 27 00:20:09 2023 +0000

    Daily bump.

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 17dd3824c2f..f328681a31e 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,46 @@
+2023-01-26  Richard Biener  <rguenther@suse.de>
+
+	Backported from master:
+	2022-11-11  Richard Biener  <rguenther@suse.de>
+		    Nikita Voronov  <nik_1357@mail.ru>
+
+	PR tree-optimization/107554
+	* tree-ssa-strlen.c (strlen_pass::count_nonzero_bytes):
+	Use unsigned HOST_WIDE_INT type for the strlen.
+
+2023-01-26  Richard Biener  <rguenther@suse.de>
+
+	Backported from master:
+	2022-10-21  Richard Biener  <rguenther@suse.de>
+
+	PR tree-optimization/107323
+	* tree-loop-distribution.c (pg_unmark_merged_alias_ddrs):
+	New function.
+	(loop_distribution::break_alias_scc_partitions): Revert
+	postorder save/restore from the PR94125 fix.  Instead
+	make sure to not ignore edges from SCCs we are going to
+	merge.
+
+2023-01-26  Richard Biener  <rguenther@suse.de>
+
+	Backported from master:
+	2022-10-06  Richard Biener  <rguenther@suse.de>
+
+	PR tree-optimization/107107
+	* tree-ssa-sccvn.c (visit_reference_op_store): Do not
+	affect value-numbering when doing the tail merging
+	MODIFY_EXPR lookup.
+
+2023-01-26  Richard Biener  <rguenther@suse.de>
+
+	Backported from master:
+	2022-09-14  Richard Biener  <rguenther@suse.de>
+
+	PR tree-optimization/106934
+	* tree-ssa.c (non_rewritable_mem_ref_base): Avoid BIT_FIELD_REFs
+	of bitfields.
+	(maybe_rewrite_mem_ref_base): Likewise.
+
 2023-01-25  Christophe Lyon  <christophe.lyon@arm.com>
 
 	Backported from master:
diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index b0742d6879d..af4c41feca1 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230126
+20230127
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 0085d514707..ba1cfacc64a 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,43 @@
+2023-01-26  Richard Biener  <rguenther@suse.de>
+
+	Backported from master:
+	2022-11-14  Richard Biener  <rguenther@suse.de>
+
+	* gcc.dg/pr107554.c: Restrict to lp64.
+
+2023-01-26  Richard Biener  <rguenther@suse.de>
+
+	Backported from master:
+	2022-11-11  Richard Biener  <rguenther@suse.de>
+		    Nikita Voronov  <nik_1357@mail.ru>
+
+	PR tree-optimization/107554
+	* gcc.dg/pr107554.c: New testcase.
+
+2023-01-26  Richard Biener  <rguenther@suse.de>
+
+	Backported from master:
+	2022-10-21  Richard Biener  <rguenther@suse.de>
+
+	PR tree-optimization/107323
+	* gcc.dg/tree-ssa/pr107323.c: New testcase.
+
+2023-01-26  Richard Biener  <rguenther@suse.de>
+
+	Backported from master:
+	2022-10-06  Richard Biener  <rguenther@suse.de>
+
+	PR tree-optimization/107107
+	* gcc.dg/pr107107.c: New testcase.
+
+2023-01-26  Richard Biener  <rguenther@suse.de>
+
+	Backported from master:
+	2022-09-14  Richard Biener  <rguenther@suse.de>
+
+	PR tree-optimization/106934
+	* gfortran.dg/pr106934.f90: New testcase.
+
 2023-01-25  Christophe Lyon  <christophe.lyon@arm.com>
 
 	Backported from master:

commit da0a1866dfac045a4fb61672d13307faec7dbeff
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sat Jan 28 00:19:29 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index af4c41feca1..9348a4afb6a 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230127
+20230128

commit 74a4683b34fb87c9c6045559658c45730e5cf9cc
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sun Jan 29 00:19:53 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 9348a4afb6a..4a549ed9f6b 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230128
+20230129

commit 5124f5cff5ff43fad8e5cd264e07dc6b281c1bca
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Mon Jan 30 00:19:19 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 4a549ed9f6b..6878f7c4810 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230129
+20230130

commit 80b3cb6e60342d0c4c35509b552af74772b48e5f
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Tue Jan 31 00:20:35 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 6878f7c4810..aa6d8640ab9 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230130
+20230131

commit e9291c2ff9240f644214552e5a2a6a33cbe43e24
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Wed Feb 1 00:19:58 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index aa6d8640ab9..f295cfe77a7 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230131
+20230201

commit 1ae0814826baceb1efcbdd2c5b6428a9022b9884
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Thu Feb 2 00:19:57 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index f295cfe77a7..05457af7293 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230201
+20230202

commit 1722e6e4803121e0b221b27b460c4f64f6f9bc87
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Fri Feb 3 00:18:32 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 05457af7293..12b84840cd1 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230202
+20230203

commit f835376a1c6ebb2fe701dfbaf98739e1c805e86a
Author: Alex Coplan <alex.coplan@arm.com>
Date:   Thu Dec 1 17:36:02 2022 +0000

    varasm: Fix type confusion bug
    
    This patch fixes a type confusion bug in varasm.c:assemble_variable.
    The problem is that the current code calls:
    
      sect = get_variable_section (decl, false);
    
    and then accesses sect->named.name without checking whether the section
    is in fact a named section. In the surrounding else clause, we only know
    that SECTION_STYLE (sect) != SECTION_NOSWITCH, so it is possible that
    the section is an unnamed section.
    
    In practice, this means that we end up doing a wild string compare
    between a function pointer and the string literal ".vtable_map_vars".
    This is because sect->named.name aliases sect->unnamed.callback in the
    section union.
    
    This can be seen in GDB with a simple testcase such as "int x;".
    
    This patch fixes the issue by checking the SECTION_STYLE of the section
    is in fact SECTION_NAMED before trying to do the string comparison.
    
    We drop the existing check of whether sect->named.name is non-NULL
    because this should presumably always be the case for a named section.
    
    gcc/ChangeLog:
    
            * varasm.c (assemble_variable): Fix type confusion bug when
            checking for ".vtable_map_vars" section.
    
    (cherry picked from commit de144fdab17dbbb64ccb540056ab78b4ffb3fbbc)

diff --git a/gcc/varasm.c b/gcc/varasm.c
index d65985d9748..3ebcdc9aff8 100644
--- a/gcc/varasm.c
+++ b/gcc/varasm.c
@@ -2322,7 +2322,7 @@ assemble_variable (tree decl, int top_level ATTRIBUTE_UNUSED,
   else
     {
       /* Special-case handling of vtv comdat sections.  */
-      if (sect->named.name
+      if (SECTION_STYLE (sect) == SECTION_NAMED
 	  && (strcmp (sect->named.name, ".vtable_map_vars") == 0))
 	handle_vtv_comdat_section (sect, decl);
       else

commit c7798ca75deffc74cd76ec3c77a6fcbf35afc7ae
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sat Feb 4 00:18:02 2023 +0000

    Daily bump.

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index f328681a31e..4ea86423493 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,11 @@
+2023-02-03  Alex Coplan  <alex.coplan@arm.com>
+
+	Backported from master:
+	2022-12-01  Alex Coplan  <alex.coplan@arm.com>
+
+	* varasm.c (assemble_variable): Fix type confusion bug when
+	checking for ".vtable_map_vars" section.
+
 2023-01-26  Richard Biener  <rguenther@suse.de>
 
 	Backported from master:
diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 12b84840cd1..65026ee2abb 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230203
+20230204

commit 59c603ca209598d5984f6f001ef5071ee99b6371
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sun Feb 5 00:19:01 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 65026ee2abb..40ef8d39af3 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230204
+20230205

commit 841e585ad936624f2d080512a9f6244b49e71969
Author: Harald Anlauf <anlauf@gmx.de>
Date:   Sat Jan 28 17:59:23 2023 +0100

    Fortran: diagnose USE associated symbols in COMMON blocks [PR108453]
    
    gcc/fortran/ChangeLog:
    
            PR fortran/108453
            * match.c (gfc_match_common): A USE associated name shall not appear
            in a COMMON block (F2018:C8121).
    
    gcc/testsuite/ChangeLog:
    
            PR fortran/108453
            * gfortran.dg/common_27.f90: New test.
    
    (cherry picked from commit aba9ff8f30d4245294ea2583de1dc28f1c7ccf7b)

diff --git a/gcc/fortran/match.c b/gcc/fortran/match.c
index 7d06e0eef30..cd27ff7b7ec 100644
--- a/gcc/fortran/match.c
+++ b/gcc/fortran/match.c
@@ -5297,6 +5297,16 @@ gfc_match_common (void)
 		goto cleanup;
 	    }
 
+	  /* F2018:R874:  common-block-object is variable-name [ (array-spec) ]
+	     F2018:C8121: A variable-name shall not be a name made accessible
+	     by use association.  */
+	  if (sym->attr.use_assoc)
+	    {
+	      gfc_error ("Symbol %qs at %C is USE associated from module %qs "
+			 "and cannot occur in COMMON", sym->name, sym->module);
+	      goto cleanup;
+	    }
+
 	  /* Deal with an optional array specification after the
 	     symbol name.  */
 	  m = gfc_match_array_spec (&as, true, true);
diff --git a/gcc/testsuite/gfortran.dg/common_27.f90 b/gcc/testsuite/gfortran.dg/common_27.f90
new file mode 100644
index 00000000000..dcde5de2bd2
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/common_27.f90
@@ -0,0 +1,14 @@
+! { dg-do compile }
+! PR fortran/108453 - a use associated variable cannot occur in COMMON
+! Contributed by G.Steinmetz
+
+module m
+  type t
+  end type
+  real :: r
+end
+program p
+  use m, only: t, r
+  common t      ! { dg-error "USE associated from module" }
+  common /cm/ r ! { dg-error "USE associated from module" }
+end

commit b14dcf0c99fab065e11ec87984475580b649edeb
Author: Harald Anlauf <anlauf@gmx.de>
Date:   Mon Jan 16 21:41:09 2023 +0100

    Fortran: fix ICE in check_charlen_present [PR108420]
    
    gcc/fortran/ChangeLog:
    
            PR fortran/108420
            * iresolve.c (check_charlen_present): Preserve character length if
            there is no array constructor.
    
    gcc/testsuite/ChangeLog:
    
            PR fortran/108420
            * gfortran.dg/pr108420.f90: New test.
    
    (cherry picked from commit e6669c0a50ed8aee9e5997d61e6271668d149218)

diff --git a/gcc/fortran/iresolve.c b/gcc/fortran/iresolve.c
index 67a1c3167d9..830d2fdffce 100644
--- a/gcc/fortran/iresolve.c
+++ b/gcc/fortran/iresolve.c
@@ -94,9 +94,12 @@ check_charlen_present (gfc_expr *source)
   else if (source->expr_type == EXPR_ARRAY)
     {
       gfc_constructor *c = gfc_constructor_first (source->value.constructor);
-      source->ts.u.cl->length
-		= gfc_get_int_expr (gfc_charlen_int_kind, NULL,
-				    c->expr->value.character.length);
+      if (c)
+	source->ts.u.cl->length
+	  = gfc_get_int_expr (gfc_charlen_int_kind, NULL,
+			      c->expr->value.character.length);
+      if (source->ts.u.cl->length == NULL)
+	gfc_internal_error ("check_charlen_present(): length not set");
     }
 }
 
diff --git a/gcc/testsuite/gfortran.dg/pr108420.f90 b/gcc/testsuite/gfortran.dg/pr108420.f90
new file mode 100644
index 00000000000..985c0b3bf53
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr108420.f90
@@ -0,0 +1,10 @@
+! { dg-do compile }
+! PR fortran/108420
+! Contributed by G.Steinmetz
+
+program p
+  character :: c = 'c'
+  logical   :: m = .true.
+  print *, merge(transfer('a', 'b', 0), c, .true.)
+  print *, merge(transfer('a', 'b', 0), c, m)
+end

commit 068fce9743ec9f3181c189cb8d03a982ca30eb7e
Author: Harald Anlauf <anlauf@gmx.de>
Date:   Mon Jan 16 21:30:56 2023 +0100

    Fortran: fix ICE in get_expr_storage_size [PR108421]
    
    gcc/fortran/ChangeLog:
    
            PR fortran/108421
            * interface.c (get_expr_storage_size): Check that we actually have
            an integer value before trying to extract it with mpz_get_si.
    
    gcc/testsuite/ChangeLog:
    
            PR fortran/108421
            * gfortran.dg/pr108421.f90: New test.
    
    (cherry picked from commit a75760374ee54768e5fd6a27080698bfbbd041ab)

diff --git a/gcc/fortran/interface.c b/gcc/fortran/interface.c
index 19ba7fd65dc..3fff18bd226 100644
--- a/gcc/fortran/interface.c
+++ b/gcc/fortran/interface.c
@@ -2810,7 +2810,8 @@ get_expr_storage_size (gfc_expr *e)
   if (e->ts.type == BT_CHARACTER)
     {
       if (e->ts.u.cl && e->ts.u.cl->length
-          && e->ts.u.cl->length->expr_type == EXPR_CONSTANT)
+	  && e->ts.u.cl->length->expr_type == EXPR_CONSTANT
+	  && e->ts.u.cl->length->ts.type == BT_INTEGER)
 	strlen = mpz_get_si (e->ts.u.cl->length->value.integer);
       else if (e->expr_type == EXPR_CONSTANT
 	       && (e->ts.u.cl == NULL || e->ts.u.cl->length == NULL))
diff --git a/gcc/testsuite/gfortran.dg/pr108421.f90 b/gcc/testsuite/gfortran.dg/pr108421.f90
new file mode 100644
index 00000000000..89439bc7eec
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr108421.f90
@@ -0,0 +1,11 @@
+! { dg-do compile }
+! PR fortran/108421
+! Contributed by G.Steinmetz
+
+program p
+  character(real(3)) :: c ! { dg-error "must be of INTEGER type" }
+  call s(c)
+end
+subroutine s(x)
+  character(*) :: x
+end

commit c67d76171e87d3ce364400684a654712047058b1
Author: Harald Anlauf <anlauf@gmx.de>
Date:   Mon Jan 23 22:13:44 2023 +0100

    Fortran: fix NULL pointer dereference in gfc_check_dependency [PR108502]
    
    gcc/fortran/ChangeLog:
    
            PR fortran/108502
            * dependency.c (gfc_check_dependency): Prevent NULL pointer
            dereference while recursively checking expressions.
    
    gcc/testsuite/ChangeLog:
    
            PR fortran/108502
            * gfortran.dg/pr108502.f90: New test.
    
    (cherry picked from commit 51767f31878a95161142254dca7119b409699670)

diff --git a/gcc/fortran/dependency.c b/gcc/fortran/dependency.c
index 7edd5d9010d..e304b607ca5 100644
--- a/gcc/fortran/dependency.c
+++ b/gcc/fortran/dependency.c
@@ -1291,6 +1291,11 @@ gfc_check_dependency (gfc_expr *expr1, gfc_expr *expr2, bool identical)
   if (expr1->expr_type != EXPR_VARIABLE)
     gfc_internal_error ("gfc_check_dependency: expecting an EXPR_VARIABLE");
 
+  /* Prevent NULL pointer dereference while recursively analyzing invalid
+     expressions.  */
+  if (expr2 == NULL)
+    return 0;
+
   switch (expr2->expr_type)
     {
     case EXPR_OP:
diff --git a/gcc/testsuite/gfortran.dg/pr108502.f90 b/gcc/testsuite/gfortran.dg/pr108502.f90
new file mode 100644
index 00000000000..45f73849c57
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr108502.f90
@@ -0,0 +1,12 @@
+! { dg-do compile }
+! { dg-options "-O2 -ffrontend-optimize" }
+! PR fortran/108502 - ICE in gfc_check_dependency
+! Contributed by G.Steinmetz
+
+integer function n()
+  integer :: a(1)
+  a = [1] / 0
+end
+program p
+  integer :: b = n() ! { dg-error "must be an intrinsic function" }
+end

commit d4bb7751af090736fb4a3bd7278d7094f35e02e4
Author: Harald Anlauf <anlauf@gmx.de>
Date:   Mon Jan 23 21:19:03 2023 +0100

    Fortran: avoid ICE on invalid array subscript triplets [PR108501]
    
    gcc/fortran/ChangeLog:
    
            PR fortran/108501
            * interface.c (get_expr_storage_size): Check array subscript triplets
            that we actually have integer values before trying to extract with
            mpz_get_si.
    
    gcc/testsuite/ChangeLog:
    
            PR fortran/108501
            * gfortran.dg/pr108501.f90: New test.
    
    (cherry picked from commit 771d793df1622a476e1cf8d05f0a6aee350fa56b)

diff --git a/gcc/fortran/interface.c b/gcc/fortran/interface.c
index 3fff18bd226..bf4cdfebcb9 100644
--- a/gcc/fortran/interface.c
+++ b/gcc/fortran/interface.c
@@ -2862,7 +2862,8 @@ get_expr_storage_size (gfc_expr *e)
 
 	    if (ref->u.ar.stride[i])
 	      {
-		if (ref->u.ar.stride[i]->expr_type == EXPR_CONSTANT)
+		if (ref->u.ar.stride[i]->expr_type == EXPR_CONSTANT
+		    && ref->u.ar.stride[i]->ts.type == BT_INTEGER)
 		  stride = mpz_get_si (ref->u.ar.stride[i]->value.integer);
 		else
 		  return 0;
@@ -2870,26 +2871,30 @@ get_expr_storage_size (gfc_expr *e)
 
 	    if (ref->u.ar.start[i])
 	      {
-		if (ref->u.ar.start[i]->expr_type == EXPR_CONSTANT)
+		if (ref->u.ar.start[i]->expr_type == EXPR_CONSTANT
+		    && ref->u.ar.start[i]->ts.type == BT_INTEGER)
 		  start = mpz_get_si (ref->u.ar.start[i]->value.integer);
 		else
 		  return 0;
 	      }
 	    else if (ref->u.ar.as->lower[i]
-		     && ref->u.ar.as->lower[i]->expr_type == EXPR_CONSTANT)
+		     && ref->u.ar.as->lower[i]->expr_type == EXPR_CONSTANT
+		     && ref->u.ar.as->lower[i]->ts.type == BT_INTEGER)
 	      start = mpz_get_si (ref->u.ar.as->lower[i]->value.integer);
 	    else
 	      return 0;
 
 	    if (ref->u.ar.end[i])
 	      {
-		if (ref->u.ar.end[i]->expr_type == EXPR_CONSTANT)
+		if (ref->u.ar.end[i]->expr_type == EXPR_CONSTANT
+		    && ref->u.ar.end[i]->ts.type == BT_INTEGER)
 		  end = mpz_get_si (ref->u.ar.end[i]->value.integer);
 		else
 		  return 0;
 	      }
 	    else if (ref->u.ar.as->upper[i]
-		     && ref->u.ar.as->upper[i]->expr_type == EXPR_CONSTANT)
+		     && ref->u.ar.as->upper[i]->expr_type == EXPR_CONSTANT
+		     && ref->u.ar.as->upper[i]->ts.type == BT_INTEGER)
 	      end = mpz_get_si (ref->u.ar.as->upper[i]->value.integer);
 	    else
 	      return 0;
@@ -2930,7 +2935,9 @@ get_expr_storage_size (gfc_expr *e)
 		  || ref->u.ar.as->upper[i] == NULL
 		  || ref->u.ar.as->lower[i] == NULL
 		  || ref->u.ar.as->upper[i]->expr_type != EXPR_CONSTANT
-		  || ref->u.ar.as->lower[i]->expr_type != EXPR_CONSTANT)
+		  || ref->u.ar.as->lower[i]->expr_type != EXPR_CONSTANT
+		  || ref->u.ar.as->upper[i]->ts.type != BT_INTEGER
+		  || ref->u.ar.as->lower[i]->ts.type != BT_INTEGER)
 		return 0;
 
 	      elements
@@ -2952,7 +2959,9 @@ get_expr_storage_size (gfc_expr *e)
 	    {
 	      if (!as->upper[i] || !as->lower[i]
 		  || as->upper[i]->expr_type != EXPR_CONSTANT
-		  || as->lower[i]->expr_type != EXPR_CONSTANT)
+		  || as->lower[i]->expr_type != EXPR_CONSTANT
+		  || as->upper[i]->ts.type != BT_INTEGER
+		  || as->lower[i]->ts.type != BT_INTEGER)
 		return 0;
 
 	      elements = elements
diff --git a/gcc/testsuite/gfortran.dg/pr108501.f90 b/gcc/testsuite/gfortran.dg/pr108501.f90
new file mode 100644
index 00000000000..09ab8c9f34f
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr108501.f90
@@ -0,0 +1,14 @@
+! { dg-do compile }
+! PR fortran/108501 - ICE in get_expr_storage_size
+! Contributed by G.Steinmetz
+
+program p
+  real, parameter :: n = 2
+  real :: a(1,(n),2) ! { dg-error "must be of INTEGER type" }
+  call s(a(:,:,1))
+end
+subroutine s(x)
+  real :: x(2)
+end
+
+! { dg-prune-output "must have constant shape" }

commit b523b58690c84b04cc9695d2d652611beb6f28ca
Author: Harald Anlauf <anlauf@gmx.de>
Date:   Thu Jul 14 22:24:55 2022 +0200

    Fortran: error recovery for bad initializers of implied-shape arrays [PR106209]
    
    gcc/fortran/ChangeLog:
    
            PR fortran/106209
            * decl.c (add_init_expr_to_sym): Handle bad initializers for
            implied-shape arrays.
    
    gcc/testsuite/ChangeLog:
    
            PR fortran/106209
            * gfortran.dg/pr106209.f90: New test.
    
    Co-authored-by: Steven G. Kargl <kargl@gcc.gnu.org>
    (cherry picked from commit 748f8a8b145dde59c7b63aa68b5a59515b7efc49)

diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c
index e7b745b0cdb..8ddcbd7b29b 100644
--- a/gcc/fortran/decl.c
+++ b/gcc/fortran/decl.c
@@ -2047,10 +2047,21 @@ add_init_expr_to_sym (const char *name, gfc_expr **initp, locus *var_locus)
 	  /* The shape may be NULL for EXPR_ARRAY, set it.  */
 	  if (init->shape == NULL)
 	    {
-	      gcc_assert (init->expr_type == EXPR_ARRAY);
+	      if (init->expr_type != EXPR_ARRAY)
+		{
+		  gfc_error ("Bad shape of initializer at %L", &init->where);
+		  return false;
+		}
+
 	      init->shape = gfc_get_shape (1);
 	      if (!gfc_array_size (init, &init->shape[0]))
-		  gfc_internal_error ("gfc_array_size failed");
+		{
+		  gfc_error ("Cannot determine shape of initializer at %L",
+			     &init->where);
+		  free (init->shape);
+		  init->shape = NULL;
+		  return false;
+		}
 	    }
 
 	  for (dim = 0; dim < sym->as->rank; ++dim)
diff --git a/gcc/testsuite/gfortran.dg/pr106209.f90 b/gcc/testsuite/gfortran.dg/pr106209.f90
new file mode 100644
index 00000000000..44f9233ec2f
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr106209.f90
@@ -0,0 +1,9 @@
+! { dg-do compile }
+! PR fortran/106209 - ICE in add_init_expr_to_sym
+! Contributed by G.Steinmetz
+
+program p
+  integer, parameter :: a(:) = 0   ! { dg-error "of deferred shape" }
+  integer, parameter :: b(*) = a   ! { dg-error "Bad shape of initializer" }
+  integer, parameter :: c(*) = [a] ! { dg-error "Cannot determine shape" }
+end

commit b66a0f2fecb4dc1ac5960ff5d630ab8f672b4106
Author: Harald Anlauf <anlauf@gmx.de>
Date:   Tue Jan 24 21:39:43 2023 +0100

    Fortran: ICE in transformational_result [PR108529]
    
    gcc/fortran/ChangeLog:
    
            PR fortran/108529
            * simplify.c (simplify_transformation): Do not try to simplify
            transformational intrinsic when the ARRAY argument has a NULL shape.
    
    gcc/testsuite/ChangeLog:
    
            PR fortran/108529
            * gfortran.dg/pr108529.f90: New test.
    
    (cherry picked from commit 6c96382eed96a9285611f2e3e2e59557094172b8)

diff --git a/gcc/fortran/simplify.c b/gcc/fortran/simplify.c
index c1db8650b0d..fe4fee897f0 100644
--- a/gcc/fortran/simplify.c
+++ b/gcc/fortran/simplify.c
@@ -676,6 +676,7 @@ simplify_transformation (gfc_expr *array, gfc_expr *dim, gfc_expr *mask,
   size_zero = gfc_is_size_zero_array (array);
 
   if (!(is_constant_array_expr (array) || size_zero)
+      || array->shape == NULL
       || !gfc_is_constant_expr (dim))
     return NULL;
 
diff --git a/gcc/testsuite/gfortran.dg/pr108529.f90 b/gcc/testsuite/gfortran.dg/pr108529.f90
new file mode 100644
index 00000000000..34c9691fae1
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr108529.f90
@@ -0,0 +1,9 @@
+! { dg-do compile }
+! PR fortran/108529 - ICE in transformational_result
+! Contributed by G.Steinmetz
+
+program p
+  integer, parameter :: a(*,*) = reshape([1, 2, 3, 4], [2, 2])
+  logical, parameter :: b(2,*) = a > 2     ! { dg-error "Assumed size" }
+  logical, parameter :: c(*)   = all(b, 1) ! { dg-error "Bad shape" }
+end

commit b501b052aeb6506185f407b5f9c5f60aed2abb3c
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Mon Feb 6 00:18:37 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 40ef8d39af3..285087c482a 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230205
+20230206
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 64a638dff83..d0ccc5bd3aa 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,68 @@
+2023-02-05  Harald Anlauf  <anlauf@gmx.de>
+
+	Backported from master:
+	2023-01-24  Harald Anlauf  <anlauf@gmx.de>
+
+	PR fortran/108529
+	* simplify.c (simplify_transformation): Do not try to simplify
+	transformational intrinsic when the ARRAY argument has a NULL shape.
+
+2023-02-05  Harald Anlauf  <anlauf@gmx.de>
+
+	Backported from master:
+	2022-07-14  Harald Anlauf  <anlauf@gmx.de>
+		    Steven G. Kargl  <kargl@gcc.gnu.org>
+
+	PR fortran/106209
+	* decl.c (add_init_expr_to_sym): Handle bad initializers for
+	implied-shape arrays.
+
+2023-02-05  Harald Anlauf  <anlauf@gmx.de>
+
+	Backported from master:
+	2023-01-23  Harald Anlauf  <anlauf@gmx.de>
+
+	PR fortran/108501
+	* interface.c (get_expr_storage_size): Check array subscript triplets
+	that we actually have integer values before trying to extract with
+	mpz_get_si.
+
+2023-02-05  Harald Anlauf  <anlauf@gmx.de>
+
+	Backported from master:
+	2023-01-23  Harald Anlauf  <anlauf@gmx.de>
+
+	PR fortran/108502
+	* dependency.c (gfc_check_dependency): Prevent NULL pointer
+	dereference while recursively checking expressions.
+
+2023-02-05  Harald Anlauf  <anlauf@gmx.de>
+
+	Backported from master:
+	2023-01-17  Harald Anlauf  <anlauf@gmx.de>
+
+	PR fortran/108421
+	* interface.c (get_expr_storage_size): Check that we actually have
+	an integer value before trying to extract it with mpz_get_si.
+
+2023-02-05  Harald Anlauf  <anlauf@gmx.de>
+
+	Backported from master:
+	2023-01-23  Harald Anlauf  <anlauf@gmx.de>
+
+	PR fortran/108420
+	* iresolve.c (check_charlen_present): Preserve character length if
+	there is no array constructor.
+
+2023-02-05  Harald Anlauf  <anlauf@gmx.de>
+
+	Backported from master:
+	2023-01-28  Harald Anlauf  <anlauf@gmx.de>
+
+	PR fortran/108453
+	* match.c (gfc_match_common): A USE associated name shall not appear
+	in a COMMON block (F2018:C8121).
+
 2023-01-08  Harald Anlauf  <anlauf@gmx.de>
 
 	Backported from master:
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index ba1cfacc64a..63134537684 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,60 @@
+2023-02-05  Harald Anlauf  <anlauf@gmx.de>
+
+	Backported from master:
+	2023-01-24  Harald Anlauf  <anlauf@gmx.de>
+
+	PR fortran/108529
+	* gfortran.dg/pr108529.f90: New test.
+
+2023-02-05  Harald Anlauf  <anlauf@gmx.de>
+
+	Backported from master:
+	2022-07-14  Harald Anlauf  <anlauf@gmx.de>
+		    Steven G. Kargl  <kargl@gcc.gnu.org>
+
+	PR fortran/106209
+	* gfortran.dg/pr106209.f90: New test.
+
+2023-02-05  Harald Anlauf  <anlauf@gmx.de>
+
+	Backported from master:
+	2023-01-23  Harald Anlauf  <anlauf@gmx.de>
+
+	PR fortran/108501
+	* gfortran.dg/pr108501.f90: New test.
+
+2023-02-05  Harald Anlauf  <anlauf@gmx.de>
+
+	Backported from master:
+	2023-01-23  Harald Anlauf  <anlauf@gmx.de>
+
+	PR fortran/108502
+	* gfortran.dg/pr108502.f90: New test.
+
+2023-02-05  Harald Anlauf  <anlauf@gmx.de>
+
+	Backported from master:
+	2023-01-17  Harald Anlauf  <anlauf@gmx.de>
+
+	PR fortran/108421
+	* gfortran.dg/pr108421.f90: New test.
+
+2023-02-05  Harald Anlauf  <anlauf@gmx.de>
+
+	Backported from master:
+	2023-01-23  Harald Anlauf  <anlauf@gmx.de>
+
+	PR fortran/108420
+	* gfortran.dg/pr108420.f90: New test.
+
+2023-02-05  Harald Anlauf  <anlauf@gmx.de>
+
+	Backported from master:
+	2023-01-28  Harald Anlauf  <anlauf@gmx.de>
+
+	PR fortran/108453
+	* gfortran.dg/common_27.f90: New test.
+
 2023-01-26  Richard Biener  <rguenther@suse.de>
 
 	Backported from master:

commit fa1e01dd01fb7483da4c15a750100ae5713c025b
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Tue Feb 7 00:19:15 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 285087c482a..9e62c1c1935 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230206
+20230207

commit 051f78a5c1d6994c10ee7c35453ff0ccee94e5c6
Author: Richard Biener <rguenther@suse.de>
Date:   Fri Sep 2 13:36:13 2022 +0200

    tree-optimization/106809 - compile time hog in VN
    
    The dominated_by_p_w_unex function is prone to high compile time.
    With GCC 12 we introduced a VN run for uninit diagnostics which now
    runs into a degenerate case with bison generated code.  Fortunately
    this case is easy to fix with a simple extra check - a more
    general fix needs more work.
    
            PR tree-optimization/106809
            * tree-ssa-sccvn.c (dominaged_by_p_w_unex): Check we have
            more than one successor before doing extra work.
    
            * gcc.dg/torture/pr106809.c: New testcase.
    
    (cherry picked from commit be1b42de9c151d46c89f9a8f82d4c5839a19ea94)

diff --git a/gcc/testsuite/gcc.dg/torture/pr106809.c b/gcc/testsuite/gcc.dg/torture/pr106809.c
new file mode 100644
index 00000000000..11e158185cf
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr106809.c
@@ -0,0 +1,28 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-Wuninitialized" } */
+
+int foo (int x, int *val)
+{
+  switch (x)
+    {
+#define C(n) \
+    case n + 0: return *val; \
+    case n + 1: return *val; \
+    case n + 2: return *val; \
+    case n + 3: return *val; \
+    case n + 4: return *val; \
+    case n + 5: return *val; \
+    case n + 6: return *val; \
+    case n + 7: return *val; \
+    case n + 8: return *val; \
+    case n + 9: return *val;
+#define C1(n) \
+    C(n+00) C(n+10) C(n+20) C(n+30) C(n+40) \
+    C(n+50) C(n+60) C(n+70) C(n+80) C(n+90)
+#define C10(n) \
+    C1(n+000) C1(n+100) C1(n+200) C1(n+300) C1(n+400) \
+    C1(n+500) C1(n+600) C1(n+700) C1(n+800) C1(n+900)
+    C10(1000)
+    }
+  return 0;
+}
diff --git a/gcc/tree-ssa-sccvn.c b/gcc/tree-ssa-sccvn.c
index 2f6f5074b07..666d7061aa8 100644
--- a/gcc/tree-ssa-sccvn.c
+++ b/gcc/tree-ssa-sccvn.c
@@ -4509,41 +4509,44 @@ dominated_by_p_w_unex (basic_block bb1, basic_block bb2, bool allow_back)
     }
 
   /* Iterate to the single executable bb2 successor.  */
-  edge succe = NULL;
-  FOR_EACH_EDGE (e, ei, bb2->succs)
-    if ((e->flags & EDGE_EXECUTABLE)
-	|| (!allow_back && (e->flags & EDGE_DFS_BACK)))
-      {
-	if (succe)
-	  {
-	    succe = NULL;
-	    break;
-	  }
-	succe = e;
-      }
-  if (succe)
+  if (EDGE_COUNT (bb2->succs) > 1)
     {
-      /* Verify the reached block is only reached through succe.
-	 If there is only one edge we can spare us the dominator
-	 check and iterate directly.  */
-      if (EDGE_COUNT (succe->dest->preds) > 1)
-	{
-	  FOR_EACH_EDGE (e, ei, succe->dest->preds)
-	    if (e != succe
-		&& ((e->flags & EDGE_EXECUTABLE)
-		    || (!allow_back && (e->flags & EDGE_DFS_BACK))))
+      edge succe = NULL;
+      FOR_EACH_EDGE (e, ei, bb2->succs)
+	if ((e->flags & EDGE_EXECUTABLE)
+	    || (!allow_back && (e->flags & EDGE_DFS_BACK)))
+	  {
+	    if (succe)
 	      {
 		succe = NULL;
 		break;
 	      }
-	}
+	    succe = e;
+	  }
       if (succe)
 	{
-	  bb2 = succe->dest;
+	  /* Verify the reached block is only reached through succe.
+	     If there is only one edge we can spare us the dominator
+	     check and iterate directly.  */
+	  if (EDGE_COUNT (succe->dest->preds) > 1)
+	    {
+	      FOR_EACH_EDGE (e, ei, succe->dest->preds)
+		if (e != succe
+		    && ((e->flags & EDGE_EXECUTABLE)
+			|| (!allow_back && (e->flags & EDGE_DFS_BACK))))
+		  {
+		    succe = NULL;
+		    break;
+		  }
+	    }
+	  if (succe)
+	    {
+	      bb2 = succe->dest;
 
-	  /* Re-do the dominance check with changed bb2.  */
-	  if (dominated_by_p (CDI_DOMINATORS, bb1, bb2))
-	    return true;
+	      /* Re-do the dominance check with changed bb2.  */
+	      if (dominated_by_p (CDI_DOMINATORS, bb1, bb2))
+		return true;
+	    }
 	}
     }
 

commit feb7d31d322af4cae77470f5913755c324d10611
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Wed Feb 8 00:18:32 2023 +0000

    Daily bump.

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 4ea86423493..251c0bfc9e1 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,12 @@
+2023-02-07  Richard Biener  <rguenther@suse.de>
+
+	Backported from master:
+	2022-09-02  Richard Biener  <rguenther@suse.de>
+
+	PR tree-optimization/106809
+	* tree-ssa-sccvn.c (dominaged_by_p_w_unex): Check we have
+	more than one successor before doing extra work.
+
 2023-02-03  Alex Coplan  <alex.coplan@arm.com>
 
 	Backported from master:
diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 9e62c1c1935..a48b5a401cf 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230207
+20230208
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 63134537684..ed25feb41d7 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,11 @@
+2023-02-07  Richard Biener  <rguenther@suse.de>
+
+	Backported from master:
+	2022-09-02  Richard Biener  <rguenther@suse.de>
+
+	PR tree-optimization/106809
+	* gcc.dg/torture/pr106809.c: New testcase.
+
 2023-02-05  Harald Anlauf  <anlauf@gmx.de>
 
 	Backported from master:

commit 9e2c30bc3d9d7da2619694fc3492d83949bfd648
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Thu Feb 9 00:19:06 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index a48b5a401cf..afa750637c5 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230208
+20230209

commit 141dddd301dd49e43a614fa96fae28e3209067f7
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Fri Feb 10 00:18:51 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index afa750637c5..13a9e4dfacf 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230209
+20230210

commit da9cadc5a8b4da316d8e3ee858170753bea8a966
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sat Feb 11 00:18:25 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 13a9e4dfacf..9f537e04ede 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230210
+20230211

commit 2965a4f925461d7814972845fe480e03856fe3fe
Author: Harald Anlauf <anlauf@gmx.de>
Date:   Tue Jan 24 22:36:25 2023 +0100

    Fortran: fix ICE in compare_bound_int [PR108527]
    
    gcc/fortran/ChangeLog:
    
            PR fortran/108527
            * resolve.c (compare_bound_int): Expression to compare must be of
            type INTEGER.
            (compare_bound_mpz_t): Likewise.
            (check_dimension): Fix comment on checks applied to array section
            and clean up associated logic.
    
    gcc/testsuite/ChangeLog:
    
            PR fortran/108527
            * gfortran.dg/pr108527.f90: New test.
    
    Co-authored-by: Steven G. Kargl <kargl@gcc.gnu.org>
    (cherry picked from commit 22afa4947584c701633a79fd8750c9ceeaa96711)

diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c
index 591d3b88227..70c6f57279a 100644
--- a/gcc/fortran/resolve.c
+++ b/gcc/fortran/resolve.c
@@ -4497,12 +4497,11 @@ compare_bound_int (gfc_expr *a, int b)
 {
   int i;
 
-  if (a == NULL || a->expr_type != EXPR_CONSTANT)
+  if (a == NULL
+      || a->expr_type != EXPR_CONSTANT
+      || a->ts.type != BT_INTEGER)
     return CMP_UNKNOWN;
 
-  if (a->ts.type != BT_INTEGER)
-    gfc_internal_error ("compare_bound_int(): Bad expression");
-
   i = mpz_cmp_si (a->value.integer, b);
 
   if (i < 0)
@@ -4520,12 +4519,11 @@ compare_bound_mpz_t (gfc_expr *a, mpz_t b)
 {
   int i;
 
-  if (a == NULL || a->expr_type != EXPR_CONSTANT)
+  if (a == NULL
+      || a->expr_type != EXPR_CONSTANT
+      || a->ts.type != BT_INTEGER)
     return CMP_UNKNOWN;
 
-  if (a->ts.type != BT_INTEGER)
-    gfc_internal_error ("compare_bound_int(): Bad expression");
-
   i = mpz_cmp (a->value.integer, b);
 
   if (i < 0)
@@ -4655,23 +4653,24 @@ check_dimension (int i, gfc_array_ref *ar, gfc_array_spec *as)
 #define AR_END (ar->end[i] ? ar->end[i] : as->upper[i])
 
 	compare_result comp_start_end = compare_bound (AR_START, AR_END);
+	compare_result comp_stride_zero = compare_bound_int (ar->stride[i], 0);
 
 	/* Check for zero stride, which is not allowed.  */
-	if (compare_bound_int (ar->stride[i], 0) == CMP_EQ)
+	if (comp_stride_zero == CMP_EQ)
 	  {
 	    gfc_error ("Illegal stride of zero at %L", &ar->c_where[i]);
 	    return false;
 	  }
 
-	/* if start == len || (stride > 0 && start < len)
-			   || (stride < 0 && start > len),
+	/* if start == end || (stride > 0 && start < end)
+			   || (stride < 0 && start > end),
 	   then the array section contains at least one element.  In this
 	   case, there is an out-of-bounds access if
 	   (start < lower || start > upper).  */
-	if (compare_bound (AR_START, AR_END) == CMP_EQ
-	    || ((compare_bound_int (ar->stride[i], 0) == CMP_GT
-		 || ar->stride[i] == NULL) && comp_start_end == CMP_LT)
-	    || (compare_bound_int (ar->stride[i], 0) == CMP_LT
+	if (comp_start_end == CMP_EQ
+	    || ((comp_stride_zero == CMP_GT || ar->stride[i] == NULL)
+		&& comp_start_end == CMP_LT)
+	    || (comp_stride_zero == CMP_LT
 	        && comp_start_end == CMP_GT))
 	  {
 	    if (compare_bound (AR_START, as->lower[i]) == CMP_LT)
diff --git a/gcc/testsuite/gfortran.dg/pr108527.f90 b/gcc/testsuite/gfortran.dg/pr108527.f90
new file mode 100644
index 00000000000..c97ba3111cb
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr108527.f90
@@ -0,0 +1,10 @@
+! { dg-do compile }
+! PR fortran/108527 - ICE in compare_bound_int
+! Contributed by G.Steinmetz
+
+program p
+  integer, parameter :: a((2.)) = [4,8] ! { dg-error "must be of INTEGER type" }
+  integer(a(1:1)) :: b                  ! { dg-error "out of bounds" }
+end
+
+! { dg-prune-output "Parameter array" }

commit 684a5a8734c4269786089f5d4ba0fbf79f190f3a
Author: Harald Anlauf <anlauf@gmx.de>
Date:   Wed Feb 1 21:01:32 2023 +0100

    Fortran: error recovery on invalid array section [PR108609]
    
    The testcase for PR108527 uncovered a latent issue with invalid array
    sections that resulted in different paths being taken on different
    architectures.  Detect the invalid array declaration for a clean recovery.
    
    gcc/fortran/ChangeLog:
    
            PR fortran/108609
            * expr.c (find_array_section): Add check to prevent interpreting an
            mpz non-integer constant as an integer.
    
    gcc/testsuite/ChangeLog:
    
            PR fortran/108609
            * gfortran.dg/pr108527.f90: Adjust test pattern.
    
    (cherry picked from commit 88a2a09dd4529107e7ef7a6e7ce43acf96457173)

diff --git a/gcc/fortran/expr.c b/gcc/fortran/expr.c
index b65fc764fb8..5f22270c2f0 100644
--- a/gcc/fortran/expr.c
+++ b/gcc/fortran/expr.c
@@ -1549,7 +1549,11 @@ find_array_section (gfc_expr *expr, gfc_ref *ref)
       lower = ref->u.ar.as->lower[d];
       upper = ref->u.ar.as->upper[d];
 
-      if (!lower || !upper)
+      if (!lower || !upper
+	  || lower->expr_type != EXPR_CONSTANT
+	  || upper->expr_type != EXPR_CONSTANT
+	  || lower->ts.type != BT_INTEGER
+	  || upper->ts.type != BT_INTEGER)
 	{
 	  t = false;
 	  goto cleanup;
diff --git a/gcc/testsuite/gfortran.dg/pr108527.f90 b/gcc/testsuite/gfortran.dg/pr108527.f90
index c97ba3111cb..804514810ac 100644
--- a/gcc/testsuite/gfortran.dg/pr108527.f90
+++ b/gcc/testsuite/gfortran.dg/pr108527.f90
@@ -4,7 +4,7 @@
 
 program p
   integer, parameter :: a((2.)) = [4,8] ! { dg-error "must be of INTEGER type" }
-  integer(a(1:1)) :: b                  ! { dg-error "out of bounds" }
+  integer(a(1:1)) :: b                  ! { dg-error "Unclassifiable statement" }
 end
 
 ! { dg-prune-output "Parameter array" }

commit 2db200ea8a63dd580b47002d9464afc7a7b5e90e
Author: Harald Anlauf <anlauf@gmx.de>
Date:   Mon Feb 6 20:59:51 2023 +0100

    Fortran: ASSOCIATE variables should not be TREE_STATIC [PR95107]
    
    gcc/fortran/ChangeLog:
    
            PR fortran/95107
            * trans-decl.c (gfc_finish_var_decl): With -fno-automatic, do not
            make ASSOCIATE variables TREE_STATIC.
    
    gcc/testsuite/ChangeLog:
    
            PR fortran/95107
            * gfortran.dg/save_7.f90: New test.
    
    (cherry picked from commit c36f3da534e7f411c5bc48c5b6b660e238167480)

diff --git a/gcc/fortran/trans-decl.c b/gcc/fortran/trans-decl.c
index bb72eb6731d..b616db34c3f 100644
--- a/gcc/fortran/trans-decl.c
+++ b/gcc/fortran/trans-decl.c
@@ -737,6 +737,7 @@ gfc_finish_var_decl (tree decl, gfc_symbol * sym)
   /* Keep variables larger than max-stack-var-size off stack.  */
   if (!(sym->ns->proc_name && sym->ns->proc_name->attr.recursive)
       && !sym->attr.automatic
+      && !sym->attr.associate_var
       && sym->attr.save != SAVE_EXPLICIT
       && sym->attr.save != SAVE_IMPLICIT
       && INTEGER_CST_P (DECL_SIZE_UNIT (decl))
diff --git a/gcc/testsuite/gfortran.dg/save_7.f90 b/gcc/testsuite/gfortran.dg/save_7.f90
new file mode 100644
index 00000000000..dfbef12bec0
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/save_7.f90
@@ -0,0 +1,17 @@
+! { dg-do compile }
+! { dg-options "-O2 -fno-automatic" }
+!
+! PR fortran/95107 - do not make associate variables TREE_STATIC
+! Contributed by G.Steinmetz
+
+program p
+  type t
+     real, pointer :: a => null()
+  end type
+  type t2
+     type(t) :: b(1)
+  end type
+  type(t2), save :: x
+  associate (y => x%b)
+  end associate
+end

commit 44b8dfb9fa4a15032ad3866890c3aa79bdb9eac3
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sun Feb 12 00:18:43 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 9f537e04ede..d696f4e8b1a 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230211
+20230212
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index d0ccc5bd3aa..2f897d0388d 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,34 @@
+2023-02-11  Harald Anlauf  <anlauf@gmx.de>
+
+	Backported from master:
+	2023-02-07  Harald Anlauf  <anlauf@gmx.de>
+
+	PR fortran/95107
+	* trans-decl.c (gfc_finish_var_decl): With -fno-automatic, do not
+	make ASSOCIATE variables TREE_STATIC.
+
+2023-02-11  Harald Anlauf  <anlauf@gmx.de>
+
+	Backported from master:
+	2023-02-01  Harald Anlauf  <anlauf@gmx.de>
+
+	PR fortran/108609
+	* expr.c (find_array_section): Add check to prevent interpreting an
+	mpz non-integer constant as an integer.
+
+2023-02-11  Harald Anlauf  <anlauf@gmx.de>
+
+	Backported from master:
+	2023-01-28  Harald Anlauf  <anlauf@gmx.de>
+		    Steven G. Kargl  <kargl@gcc.gnu.org>
+
+	PR fortran/108527
+	* resolve.c (compare_bound_int): Expression to compare must be of
+	type INTEGER.
+	(compare_bound_mpz_t): Likewise.
+	(check_dimension): Fix comment on checks applied to array section
+	and clean up associated logic.
+
 2023-02-05  Harald Anlauf  <anlauf@gmx.de>
 
 	Backported from master:
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index ed25feb41d7..5ae05dab3ea 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,28 @@
+2023-02-11  Harald Anlauf  <anlauf@gmx.de>
+
+	Backported from master:
+	2023-02-07  Harald Anlauf  <anlauf@gmx.de>
+
+	PR fortran/95107
+	* gfortran.dg/save_7.f90: New test.
+
+2023-02-11  Harald Anlauf  <anlauf@gmx.de>
+
+	Backported from master:
+	2023-02-01  Harald Anlauf  <anlauf@gmx.de>
+
+	PR fortran/108609
+	* gfortran.dg/pr108527.f90: Adjust test pattern.
+
+2023-02-11  Harald Anlauf  <anlauf@gmx.de>
+
+	Backported from master:
+	2023-01-28  Harald Anlauf  <anlauf@gmx.de>
+		    Steven G. Kargl  <kargl@gcc.gnu.org>
+
+	PR fortran/108527
+	* gfortran.dg/pr108527.f90: New test.
+
 2023-02-07  Richard Biener  <rguenther@suse.de>
 
 	Backported from master:

commit 80f9bda6cc2fc35e019a04336ada77feca72b5e0
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Mon Feb 13 00:19:11 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index d696f4e8b1a..d3e275017e1 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230212
+20230213

commit ec4d91aa885297c3b5bb4bbfb3133ffe2e5e6a2f
Author: Kewen Lin <linkw@linux.ibm.com>
Date:   Sun Feb 12 09:35:27 2023 -0600

    rs6000: Teach rs6000_opaque_type_invalid_use_p about inline asm [PR108272]
    
    As PR108272 shows, there are some invalid uses of MMA opaque
    types in inline asm statements.  This patch is to teach the
    function rs6000_opaque_type_invalid_use_p for inline asm,
    check and error any invalid use of MMA opaque types in input
    and output operands.
    
            PR target/108272
    
    gcc/ChangeLog:
    
            * config/rs6000/rs6000.c (rs6000_opaque_type_invalid_use_p): Add the
            support for invalid uses in inline asm, factor out the checking and
            erroring to lambda function check_and_error_invalid_use.
    
    gcc/testsuite/ChangeLog:
    
            * gcc.target/powerpc/pr108272-1.c: New test.
            * gcc.target/powerpc/pr108272-2.c: New test.
            * gcc.target/powerpc/pr108272-3.c: New test.
            * gcc.target/powerpc/pr108272-4.c: New test.
    
    (cherry picked from commit 074b0c03eabeb8e9c8de813c81bf87a1f88fdb65)

diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index d2ac6c21069..8f524164a05 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -26893,13 +26893,33 @@ rs6000_invalid_conversion (const_tree fromtype, const_tree totype)
   return NULL;
 }
 
+/* If the given TYPE is one MMA opaque type, emit the corresponding
+   error messages and return true, otherwise return false.  */
+
+static inline bool
+check_and_error_invalid_use (tree type)
+{
+  tree mv = TYPE_MAIN_VARIANT (type);
+  if (mv == vector_quad_type_node)
+    {
+      error ("type %<__vector_quad%> requires the %qs option", "-mmma");
+      return true;
+    }
+  else if (mv == vector_pair_type_node)
+    {
+      error ("type %<__vector_pair%> requires the %qs option", "-mmma");
+      return true;
+    }
+  return false;
+}
+
 /* Now we have only two opaque types, they are __vector_quad and
    __vector_pair built-in types.  They are target specific and
    only available when MMA is supported.  With MMA supported, it
    simply returns true, otherwise it checks if the given gimple
-   STMT is an assignment stmt and uses either of these two opaque
-   types unexpectedly, if yes, it would raise an error message
-   and returns true, otherwise it returns false.  */
+   STMT is an assignment or asm stmt and uses either of these two
+   opaque types unexpectedly, if yes, it would raise an error
+   message and returns true, otherwise it returns false.  */
 
 bool
 rs6000_opaque_type_invalid_use_p (gimple *stmt)
@@ -26910,20 +26930,33 @@ rs6000_opaque_type_invalid_use_p (gimple *stmt)
   if (stmt)
     {
       /* The usage of MMA opaque types is very limited for now,
-	 to check with gassign is enough so far.  */
+	 to check with gassign and gasm is enough so far.  */
       if (gassign *ga = dyn_cast<gassign *> (stmt))
 	{
 	  tree lhs = gimple_assign_lhs (ga);
 	  tree type = TREE_TYPE (lhs);
-	  if (type == vector_quad_type_node)
+	  if (check_and_error_invalid_use (type))
+	    return true;
+	}
+      else if (gasm *gs = dyn_cast<gasm *> (stmt))
+	{
+	  unsigned ninputs = gimple_asm_ninputs (gs);
+	  for (unsigned i = 0; i < ninputs; i++)
 	    {
-	      error ("type %<__vector_quad%> requires the %qs option", "-mmma");
-	      return true;
+	      tree op = gimple_asm_input_op (gs, i);
+	      tree val = TREE_VALUE (op);
+	      tree type = TREE_TYPE (val);
+	      if (check_and_error_invalid_use (type))
+		return true;
 	    }
-	  else if (type == vector_pair_type_node)
+	  unsigned noutputs = gimple_asm_noutputs (gs);
+	  for (unsigned i = 0; i < noutputs; i++)
 	    {
-	      error ("type %<__vector_pair%> requires the %qs option", "-mmma");
-	      return true;
+	      tree op = gimple_asm_output_op (gs, i);
+	      tree val = TREE_VALUE (op);
+	      tree type = TREE_TYPE (val);
+	      if (check_and_error_invalid_use (type))
+		return true;
 	    }
 	}
     }
diff --git a/gcc/testsuite/gcc.target/powerpc/pr108272-1.c b/gcc/testsuite/gcc.target/powerpc/pr108272-1.c
new file mode 100644
index 00000000000..b99e6a4d86d
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/pr108272-1.c
@@ -0,0 +1,17 @@
+/* { dg-require-effective-target powerpc_p9modulo_ok } */
+/* If the default cpu type is power10 or later, type __vector_quad is
+   supported.  To keep the test point available all the time, this case
+   specifies -mdejagnu-cpu=power9 here.  */
+/* { dg-options "-mdejagnu-cpu=power9" } */
+
+/* Verify there is no ICE and don't check the error messages on unsupported
+   type since they could be fragile and are not test points of this case.  */
+
+/* { dg-excess-errors "pr108272-1" } */
+
+void
+foo (void)
+{
+  __vector_quad acc;
+  asm("#..." : "=d"(acc));
+}
diff --git a/gcc/testsuite/gcc.target/powerpc/pr108272-2.c b/gcc/testsuite/gcc.target/powerpc/pr108272-2.c
new file mode 100644
index 00000000000..51b2100d0f1
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/pr108272-2.c
@@ -0,0 +1,17 @@
+/* { dg-require-effective-target powerpc_p9modulo_ok } */
+/* If the default cpu type is power10 or later, type __vector_pair is
+   supported.  To keep the test point available all the time, this case
+   specifies -mdejagnu-cpu=power9 here.  */
+/* { dg-options "-mdejagnu-cpu=power9" } */
+
+/* Verify there is no ICE and don't check the error messages on unsupported
+   type since they could be fragile and are not test points of this case.  */
+
+/* { dg-excess-errors "pr108272-2" } */
+
+void
+foo (void)
+{
+  __vector_pair acc;
+  asm("#..." :: "d"(acc));
+}
diff --git a/gcc/testsuite/gcc.target/powerpc/pr108272-3.c b/gcc/testsuite/gcc.target/powerpc/pr108272-3.c
new file mode 100644
index 00000000000..634a529b5c8
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/pr108272-3.c
@@ -0,0 +1,17 @@
+/* { dg-require-effective-target powerpc_p9modulo_ok } */
+/* If the default cpu type is power10 or later, type __vector_quad is
+   supported.  To keep the test point available all the time, this case
+   specifies -mdejagnu-cpu=power9 here.  */
+/* { dg-options "-mdejagnu-cpu=power9" } */
+
+/* Verify there is no ICE and don't check the error messages on unsupported
+   type since they could be fragile and are not test points of this case.  */
+
+/* { dg-excess-errors "pr108272-3" } */
+
+void
+foo (void)
+{
+  volatile __vector_quad acc;
+  asm("#..." : "=d"(acc));
+}
diff --git a/gcc/testsuite/gcc.target/powerpc/pr108272-4.c b/gcc/testsuite/gcc.target/powerpc/pr108272-4.c
new file mode 100644
index 00000000000..7eecd6c5a0d
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/pr108272-4.c
@@ -0,0 +1,18 @@
+/* { dg-require-effective-target powerpc_p9modulo_ok } */
+/* If the default cpu type is power10 or later, type __vector_pair is
+   supported.  To keep the test point available all the time, this case
+   specifies -mdejagnu-cpu=power9 here.  */
+/* { dg-options "-mdejagnu-cpu=power9" } */
+
+/* Verify there is no ICE and don't check the error messages on unsupported
+   type since they could be fragile and are not test points of this case.  */
+
+/* { dg-excess-errors "pr108272-4" } */
+
+typedef __vector_pair vpair_t;
+void
+foo (void)
+{
+  vpair_t acc;
+  asm("#..." : "=d"(acc));
+}

commit 7bbed35a05d735387d406afbf866384feaac21e7
Author: Kewen Lin <linkw@linux.ibm.com>
Date:   Wed Jan 18 02:34:19 2023 -0600

    rs6000: Teach rs6000_opaque_type_invalid_use_p about gcall [PR108348]
    
    PR108348 shows one special case that MMA opaque types are
    used in function arguments and treated as pass by reference,
    it results in one copying from argument to a temp variable,
    since this copying happens before rs6000_function_arg check,
    it can cause ICE without MMA support then.  This patch is to
    teach function rs6000_opaque_type_invalid_use_p to check if
    any function argument in a gcall stmt has the invalid use of
    MMA opaque types.
    
    btw, I checked the handling on return value, it doesn't have
    this kind of issue as its checking and error emission is quite
    early, so this doesn't handle function return value.
    
            PR target/108348
    
    gcc/ChangeLog:
    
            * config/rs6000/rs6000.c (rs6000_opaque_type_invalid_use_p): Add the
            support for invalid uses of MMA opaque type in function arguments.
    
    gcc/testsuite/ChangeLog:
    
            * gcc.target/powerpc/pr108348-1.c: New test.
            * gcc.target/powerpc/pr108348-2.c: New test.
    
    (cherry picked from commit 5d9529687deb9ed009361a16c02a7f6c3e2ebbf3)

diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index 8f524164a05..0ee9cc8047d 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -26917,9 +26917,9 @@ check_and_error_invalid_use (tree type)
    __vector_pair built-in types.  They are target specific and
    only available when MMA is supported.  With MMA supported, it
    simply returns true, otherwise it checks if the given gimple
-   STMT is an assignment or asm stmt and uses either of these two
-   opaque types unexpectedly, if yes, it would raise an error
-   message and returns true, otherwise it returns false.  */
+   STMT is an assignment, asm or call stmt and uses either of
+   these two opaque types unexpectedly, if yes, it would raise
+   an error message and returns true, otherwise it returns false.  */
 
 bool
 rs6000_opaque_type_invalid_use_p (gimple *stmt)
@@ -26930,7 +26930,7 @@ rs6000_opaque_type_invalid_use_p (gimple *stmt)
   if (stmt)
     {
       /* The usage of MMA opaque types is very limited for now,
-	 to check with gassign and gasm is enough so far.  */
+	 to check with gassign, gasm and gcall is enough so far.  */
       if (gassign *ga = dyn_cast<gassign *> (stmt))
 	{
 	  tree lhs = gimple_assign_lhs (ga);
@@ -26959,6 +26959,17 @@ rs6000_opaque_type_invalid_use_p (gimple *stmt)
 		return true;
 	    }
 	}
+      else if (gcall *gc = dyn_cast<gcall *> (stmt))
+	{
+	  unsigned nargs = gimple_call_num_args (gc);
+	  for (unsigned i = 0; i < nargs; i++)
+	    {
+	      tree arg = gimple_call_arg (gc, i);
+	      tree type = TREE_TYPE (arg);
+	      if (check_and_error_invalid_use (type))
+		return true;
+	    }
+	}
     }
 
   return false;
diff --git a/gcc/testsuite/gcc.target/powerpc/pr108348-1.c b/gcc/testsuite/gcc.target/powerpc/pr108348-1.c
new file mode 100644
index 00000000000..29cbe7abffc
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/pr108348-1.c
@@ -0,0 +1,23 @@
+/* { dg-require-effective-target powerpc_altivec_ok } */
+/* If the default cpu type is power10 or later, type __vector_quad is
+   supported.  To keep the test point available all the time, this case
+   specifies -mdejagnu-cpu=power9 here.  This needs -mabi=no-altivec
+   to do the copying for pass-by-reference function argument on 32 bit
+   environment.  */
+/* { dg-options "-mdejagnu-cpu=power9 -mabi=no-altivec" } */
+
+/* Verify there is no ICE on 32 bit and don't check the error messages
+   on unsupported type since they could be fragile and are not test
+   points of this case.  */
+
+/* { dg-excess-errors "pr108348-1" } */
+
+extern void bar (__vector_quad v);
+
+void
+foo (void)
+{
+  __vector_quad v;
+  bar (v);
+}
+
diff --git a/gcc/testsuite/gcc.target/powerpc/pr108348-2.c b/gcc/testsuite/gcc.target/powerpc/pr108348-2.c
new file mode 100644
index 00000000000..9aa8939e2f4
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/pr108348-2.c
@@ -0,0 +1,23 @@
+/* { dg-require-effective-target powerpc_altivec_ok } */
+/* If the default cpu type is power10 or later, type __vector_pair is
+   supported.  To keep the test point available all the time, this case
+   specifies -mdejagnu-cpu=power9 here.  This needs -mabi=no-altivec
+   to do the copying for pass-by-reference function argument on 32 bit
+   environment.  */
+/* { dg-options "-mdejagnu-cpu=power9 -mabi=no-altivec" } */
+
+/* Verify there is no ICE on 32 bit and don't check the error messages
+   on unsupported type since they could be fragile and are not test
+   points of this case.  */
+
+/* { dg-excess-errors "pr108348-2" } */
+
+extern void bar (__vector_pair v);
+
+void
+foo (void)
+{
+  __vector_pair v;
+  bar (v);
+}
+

commit 741484075759034972f570bc624d1fa2399b9208
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Tue Feb 14 00:19:08 2023 +0000

    Daily bump.

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 251c0bfc9e1..898a4ea9b73 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,22 @@
+2023-02-13  Kewen Lin  <linkw@linux.ibm.com>
+
+	Backported from master:
+	2023-01-18  Kewen Lin  <linkw@linux.ibm.com>
+
+	PR target/108348
+	* config/rs6000/rs6000.c (rs6000_opaque_type_invalid_use_p): Add the
+	support for invalid uses of MMA opaque type in function arguments.
+
+2023-02-13  Kewen Lin  <linkw@linux.ibm.com>
+
+	Backported from master:
+	2023-01-16  Kewen Lin  <linkw@linux.ibm.com>
+
+	PR target/108272
+	* config/rs6000/rs6000.c (rs6000_opaque_type_invalid_use_p): Add the
+	support for invalid uses in inline asm, factor out the checking and
+	erroring to lambda function check_and_error_invalid_use.
+
 2023-02-07  Richard Biener  <rguenther@suse.de>
 
 	Backported from master:
diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index d3e275017e1..fe9ab157aec 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230213
+20230214
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 5ae05dab3ea..c67e1882551 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,23 @@
+2023-02-13  Kewen Lin  <linkw@linux.ibm.com>
+
+	Backported from master:
+	2023-01-18  Kewen Lin  <linkw@linux.ibm.com>
+
+	PR target/108348
+	* gcc.target/powerpc/pr108348-1.c: New test.
+	* gcc.target/powerpc/pr108348-2.c: New test.
+
+2023-02-13  Kewen Lin  <linkw@linux.ibm.com>
+
+	Backported from master:
+	2023-01-16  Kewen Lin  <linkw@linux.ibm.com>
+
+	PR target/108272
+	* gcc.target/powerpc/pr108272-1.c: New test.
+	* gcc.target/powerpc/pr108272-2.c: New test.
+	* gcc.target/powerpc/pr108272-3.c: New test.
+	* gcc.target/powerpc/pr108272-4.c: New test.
+
 2023-02-11  Harald Anlauf  <anlauf@gmx.de>
 
 	Backported from master:

commit 641f4fd9b728a372aab70416e5f80569b51c1ba3
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Wed Feb 15 00:19:36 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index fe9ab157aec..79267617449 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230214
+20230215

commit 4303f7d9bc5b37cabb77413c7a4f6946772b9da9
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Thu Feb 16 00:19:47 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 79267617449..22d2daa87ba 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230215
+20230216

commit 1583b98af0895663240e25cd3ae614b6573f794b
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Fri Feb 17 00:19:26 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 22d2daa87ba..ef309477de2 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230216
+20230217

commit a6316ffaf1851a7e6a4b8c3ecf839a7045d21971
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sat Feb 18 00:19:09 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index ef309477de2..ac1301f036f 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230217
+20230218

commit 795839436b05c7885ad6a5d824e42d2f1419d481
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sun Feb 19 00:18:49 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index ac1301f036f..03e603a86b9 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230218
+20230219

commit b7fa32ad2b428c7dcb62e6eef8dd330e5186a0c5
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Mon Feb 20 00:18:22 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 03e603a86b9..09ddb49ab8a 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230219
+20230220

commit d465a40200324d56c51f02f2c5807e716f9c8775
Author: Jim Wilson <jimw@sifive.com>
Date:   Tue Jun 2 11:19:39 2020 -0700

    RISC-V: Make __divdi3 handle div by zero same as hardware.
    
    The ISA manual specifies that divide by zero always returns -1 as the result.
    We were failing to do that when the dividend was negative.
    
    Original patch from Virginie Moser.
    
            libgcc/
            * config/riscv/div.S (__divdi3): For negative arguments, change bgez
            to bgtz.
    
    (cherry picked from commit 4013baf99c38f7bca06a51f8301e8fb195ccfa33)

diff --git a/libgcc/config/riscv/div.S b/libgcc/config/riscv/div.S
index 151f8e273ac..17234324c1e 100644
--- a/libgcc/config/riscv/div.S
+++ b/libgcc/config/riscv/div.S
@@ -107,10 +107,12 @@ FUNC_END (__umoddi3)
   /* Handle negative arguments to __divdi3.  */
 .L10:
   neg   a0, a0
-  bgez  a1, .L12      /* Compute __udivdi3(-a0, a1), then negate the result.  */
+  /* Zero is handled as a negative so that the result will not be inverted.  */
+  bgtz  a1, .L12     /* Compute __udivdi3(-a0, a1), then negate the result.  */
+
   neg   a1, a1
-  j     __udivdi3     /* Compute __udivdi3(-a0, -a1).  */
-.L11:                 /* Compute __udivdi3(a0, -a1), then negate the result.  */
+  j     __udivdi3    /* Compute __udivdi3(-a0, -a1).  */
+.L11:                /* Compute __udivdi3(a0, -a1), then negate the result.  */
   neg   a1, a1
 .L12:
   move  t0, ra

commit 951ca35bdbbde7bb348337d7db3919c4a0628e25
Author: Nelson Chu <nelson.chu@sifive.com>
Date:   Mon Nov 29 04:48:20 2021 -0800

    RISC-V: jal cannot refer to a default visibility symbol for shared object. [PR 108339]
    
    This is the original binutils bugzilla report,
    https://sourceware.org/bugzilla/show_bug.cgi?id=28509
    
    And this is the first version of the proposed binutils patch,
    https://sourceware.org/pipermail/binutils/2021-November/118398.html
    
    After applying the binutils patch, I get the the unexpected error when
    building libgcc,
    
    /scratch/nelsonc/riscv-gnu-toolchain/riscv-gcc/libgcc/config/riscv/div.S:42:
    /scratch/nelsonc/build-upstream/rv64gc-linux/build-install/riscv64-unknown-linux-gnu/bin/ld: relocation R_RISCV_JAL against `__udivdi3' which may bind externally can not be used when making a shared object; recompile with -fPIC
    
    Therefore, this patch add an extra hidden alias symbol for __udivdi3, and
    then use HIDDEN_JUMPTARGET to target a non-preemptible symbol instead.
    The solution is similar to glibc as follows,
    https://sourceware.org/git/?p=glibc.git;a=commit;h=68389203832ab39dd0dbaabbc4059e7fff51c29b
    
    libgcc/ChangeLog:
    
            PR target/108339
            * config/riscv/div.S: Add the hidden alias symbol for __udivdi3, and
            then use HIDDEN_JUMPTARGET to target it since it is non-preemptible.
            * config/riscv/riscv-asm.h: Added new macros HIDDEN_JUMPTARGET and
            HIDDEN_DEF.
    
    (cherry picked from commit 45116f342057b7facecd3d05c2091ce3a77eda59)

diff --git a/libgcc/config/riscv/div.S b/libgcc/config/riscv/div.S
index 17234324c1e..e892a818bee 100644
--- a/libgcc/config/riscv/div.S
+++ b/libgcc/config/riscv/div.S
@@ -40,7 +40,7 @@ FUNC_BEGIN (__udivsi3)
   sll    a0, a0, 32
   sll    a1, a1, 32
   move   t0, ra
-  jal    __udivdi3
+  jal    HIDDEN_JUMPTARGET(__udivdi3)
   sext.w a0, a0
   jr     t0
 FUNC_END (__udivsi3)
@@ -52,7 +52,7 @@ FUNC_BEGIN (__umodsi3)
   srl    a0, a0, 32
   srl    a1, a1, 32
   move   t0, ra
-  jal    __udivdi3
+  jal    HIDDEN_JUMPTARGET(__udivdi3)
   sext.w a0, a1
   jr     t0
 FUNC_END (__umodsi3)
@@ -95,11 +95,12 @@ FUNC_BEGIN (__udivdi3)
 .L5:
   ret
 FUNC_END (__udivdi3)
+HIDDEN_DEF (__udivdi3)
 
 FUNC_BEGIN (__umoddi3)
   /* Call __udivdi3(a0, a1), then return the remainder, which is in a1.  */
   move  t0, ra
-  jal   __udivdi3
+  jal   HIDDEN_JUMPTARGET(__udivdi3)
   move  a0, a1
   jr    t0
 FUNC_END (__umoddi3)
@@ -111,12 +112,12 @@ FUNC_END (__umoddi3)
   bgtz  a1, .L12     /* Compute __udivdi3(-a0, a1), then negate the result.  */
 
   neg   a1, a1
-  j     __udivdi3    /* Compute __udivdi3(-a0, -a1).  */
+  j     HIDDEN_JUMPTARGET(__udivdi3)     /* Compute __udivdi3(-a0, -a1).  */
 .L11:                /* Compute __udivdi3(a0, -a1), then negate the result.  */
   neg   a1, a1
 .L12:
   move  t0, ra
-  jal   __udivdi3
+  jal   HIDDEN_JUMPTARGET(__udivdi3)
   neg   a0, a0
   jr    t0
 FUNC_END (__divdi3)
@@ -126,7 +127,7 @@ FUNC_BEGIN (__moddi3)
   bltz   a1, .L31
   bltz   a0, .L32
 .L30:
-  jal    __udivdi3    /* The dividend is not negative.  */
+  jal    HIDDEN_JUMPTARGET(__udivdi3)    /* The dividend is not negative.  */
   move   a0, a1
   jr     t0
 .L31:
@@ -134,7 +135,7 @@ FUNC_BEGIN (__moddi3)
   bgez   a0, .L30
 .L32:
   neg    a0, a0
-  jal    __udivdi3    /* The dividend is hella negative.  */
+  jal    HIDDEN_JUMPTARGET(__udivdi3)    /* The dividend is hella negative.  */
   neg    a0, a1
   jr     t0
 FUNC_END (__moddi3)
diff --git a/libgcc/config/riscv/riscv-asm.h b/libgcc/config/riscv/riscv-asm.h
index 07977ecdc83..f728a692445 100644
--- a/libgcc/config/riscv/riscv-asm.h
+++ b/libgcc/config/riscv/riscv-asm.h
@@ -33,3 +33,9 @@ X:
 #define FUNC_ALIAS(X,Y)		\
 	.globl X;		\
 	X = Y
+
+#define CONCAT1(a, b)		CONCAT2(a, b)
+#define CONCAT2(a, b)		a ## b
+#define HIDDEN_JUMPTARGET(X)	CONCAT1(__hidden_, X)
+#define HIDDEN_DEF(X)		FUNC_ALIAS(HIDDEN_JUMPTARGET(X), X);     \
+				.hidden HIDDEN_JUMPTARGET(X)

commit 617377cc1641e4f63617b192e224bc96dfbbd324
Author: Alex Coplan <alex.coplan@arm.com>
Date:   Mon Feb 6 14:32:21 2023 +0000

    aarch64: Fix up bfmlal lane pattern [PR104921]
    
    As the testcase shows, this pattern had an incorrect constraint leading
    to GCC's output getting rejected by the assembler.
    
    This patch fixes the constraint accordingly.
    
    The test is split into two: one that can run without bf16 support from
    the assembler and another that checks that the output actually assembles
    when such support is available.
    
    gcc/ChangeLog:
    
            PR target/104921
            * config/aarch64/aarch64-simd.md (aarch64_bfmlal<bt>_lane<q>v4sf):
            Use correct constraint for operand 3.
    
    gcc/testsuite/ChangeLog:
    
            PR target/104921
            * gcc.target/aarch64/pr104921-1.c: New test.
            * gcc.target/aarch64/pr104921-2.c: New test.
            * gcc.target/aarch64/pr104921.x: Include file for new tests.
    
    (cherry picked from commit 277e1f30a5e4e634304a7b8a532825119f0ea47f)

diff --git a/gcc/config/aarch64/aarch64-simd.md b/gcc/config/aarch64/aarch64-simd.md
index e16bc784bb4..45e72ba0761 100644
--- a/gcc/config/aarch64/aarch64-simd.md
+++ b/gcc/config/aarch64/aarch64-simd.md
@@ -7199,7 +7199,7 @@
   [(set (match_operand:V4SF 0 "register_operand" "=w")
         (plus: V4SF (match_operand:V4SF 1 "register_operand" "0")
                     (unspec:V4SF [(match_operand:V8BF 2 "register_operand" "w")
-                                  (match_operand:VBF 3 "register_operand" "w")
+                                  (match_operand:VBF 3 "register_operand" "x")
                                   (match_operand:SI 4 "const_int_operand" "n")]
                      BF_MLA)))]
   "TARGET_BF16_SIMD"
diff --git a/gcc/testsuite/gcc.target/aarch64/pr104921-1.c b/gcc/testsuite/gcc.target/aarch64/pr104921-1.c
new file mode 100644
index 00000000000..dcf6fe7d90d
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/pr104921-1.c
@@ -0,0 +1,12 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-O2 -march=armv8.2-a+bf16 -std=gnu99 -save-temps" }  */
+/* { dg-final { check-function-bodies "**" "" } } */
+
+#include "pr104921.x"
+
+/*
+**foo:
+**	mov	v([0-9]|1[0-5])\.8b, v16\.8b
+**	bfmlalb	v0\.4s, v1\.8h, v([0-9]|1[0-5])\.h\[0\]
+**	ret
+*/
diff --git a/gcc/testsuite/gcc.target/aarch64/pr104921-2.c b/gcc/testsuite/gcc.target/aarch64/pr104921-2.c
new file mode 100644
index 00000000000..211fcd0aca9
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/pr104921-2.c
@@ -0,0 +1,6 @@
+/* { dg-do assemble } */
+/* { dg-add-options arm_v8_2a_bf16_neon }  */
+/* { dg-additional-options "-O2 -std=gnu99" }  */
+/* { dg-require-effective-target arm_v8_2a_bf16_neon_ok } */
+
+#include "pr104921.x"
diff --git a/gcc/testsuite/gcc.target/aarch64/pr104921.x b/gcc/testsuite/gcc.target/aarch64/pr104921.x
new file mode 100644
index 00000000000..1e1a6f24e22
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/pr104921.x
@@ -0,0 +1,9 @@
+#include <arm_neon.h>
+
+float32x4_t
+foo(float32x4_t x, bfloat16x8_t a)
+{
+  register bfloat16x4_t b asm ("v16");
+  asm volatile ("" : "=w"(b));
+  return vbfmlalbq_lane_f32 (x, a, b, 0);
+}

commit 2f2567780dbf5cb95136b3434834c5e9ad3f7cbe
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Tue Feb 21 00:19:52 2023 +0000

    Daily bump.

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 898a4ea9b73..2cccdb98975 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,12 @@
+2023-02-20  Alex Coplan  <alex.coplan@arm.com>
+
+	Backported from master:
+	2023-02-06  Alex Coplan  <alex.coplan@arm.com>
+
+	PR target/104921
+	* config/aarch64/aarch64-simd.md (aarch64_bfmlal<bt>_lane<q>v4sf):
+	Use correct constraint for operand 3.
+
 2023-02-13  Kewen Lin  <linkw@linux.ibm.com>
 
 	Backported from master:
diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 09ddb49ab8a..6d7db2787db 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230220
+20230221
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index c67e1882551..199b360fef5 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,13 @@
+2023-02-20  Alex Coplan  <alex.coplan@arm.com>
+
+	Backported from master:
+	2023-02-06  Alex Coplan  <alex.coplan@arm.com>
+
+	PR target/104921
+	* gcc.target/aarch64/pr104921-1.c: New test.
+	* gcc.target/aarch64/pr104921-2.c: New test.
+	* gcc.target/aarch64/pr104921.x: Include file for new tests.
+
 2023-02-13  Kewen Lin  <linkw@linux.ibm.com>
 
 	Backported from master:
diff --git a/libgcc/ChangeLog b/libgcc/ChangeLog
index a49027e43b6..fa16074a85e 100644
--- a/libgcc/ChangeLog
+++ b/libgcc/ChangeLog
@@ -1,3 +1,22 @@
+2023-02-20  Nelson Chu  <nelson.chu@sifive.com>
+
+	Backported from master:
+	2021-12-06  Nelson Chu  <nelson.chu@sifive.com>
+
+	PR target/108339
+	* config/riscv/div.S: Add the hidden alias symbol for __udivdi3, and
+	then use HIDDEN_JUMPTARGET to target it since it is non-preemptible.
+	* config/riscv/riscv-asm.h: Added new macros HIDDEN_JUMPTARGET and
+	HIDDEN_DEF.
+
+2023-02-20  Jim Wilson  <jimw@sifive.com>
+
+	Backported from master:
+	2020-06-02  Jim Wilson  <jimw@sifive.com>
+
+	* config/riscv/div.S (__divdi3): For negative arguments, change bgez
+	to bgtz.
+
 2022-06-28  Release Manager
 
 	* GCC 10.4.0 released.

commit b995474e1d774acc10561c072c09cc4fee5531bc
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Wed Feb 22 00:20:32 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 6d7db2787db..e7a86509777 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230221
+20230222

commit 4c08446bd1091bb3c0b706cfb5a4fa015b79031f
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Thu Feb 23 00:20:01 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index e7a86509777..40fc3374943 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230222
+20230223

commit 976d4e67e8af30b6d25e1f8ebf571b29555e98a2
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Fri Feb 24 00:19:26 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 40fc3374943..fb96f27d182 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230223
+20230224

commit 92b44cf50dec5c8cc57105fde2de2be76f75758f
Author: Sebastian Huber <sebastian.huber@embedded-brains.de>
Date:   Wed Feb 22 21:38:18 2023 +0100

    RTEMS: Tune multilib selection
    
    gcc/ChangeLog:
    
            * config/riscv/t-rtems: Keep only -mcmodel=medany 64-bit multilibs.
            Add non-compact 32-bit multilibs.
    
    (cherry picked from commit 35a067020e41d97bc3be15b518b3dc2a64b4aae2)

diff --git a/gcc/config/riscv/t-rtems b/gcc/config/riscv/t-rtems
index 41f5927fc87..19b12030895 100644
--- a/gcc/config/riscv/t-rtems
+++ b/gcc/config/riscv/t-rtems
@@ -1,8 +1,8 @@
 MULTILIB_OPTIONS	=
 MULTILIB_DIRNAMES	=
 
-MULTILIB_OPTIONS	+= march=rv32i/march=rv32im/march=rv32imafd/march=rv32iac/march=rv32imac/march=rv32imafc/march=rv64imafd/march=rv64imac/march=rv64imafdc
-MULTILIB_DIRNAMES	+= rv32i       rv32im       rv32imafd       rv32iac       rv32imac       rv32imafc       rv64imafd       rv64imac       rv64imafdc
+MULTILIB_OPTIONS	+= march=rv32i/march=rv32iac/march=rv32im/march=rv32ima/march=rv32imac/march=rv32imaf/march=rv32imafc/march=rv32imafd/march=rv32imafdc/march=rv64ima/march=rv64imac/march=rv64imafd/march=rv64imafdc
+MULTILIB_DIRNAMES	+= rv32i       rv32iac       rv32im       rv32ima       rv32imac       rv32imaf       rv32imafc       rv32imafd       rv32imafdc       rv64ima       rv64imac       rv64imafd       rv64imafdc
 
 MULTILIB_OPTIONS	+= mabi=ilp32/mabi=ilp32f/mabi=ilp32d/mabi=lp64/mabi=lp64d
 MULTILIB_DIRNAMES	+= ilp32      ilp32f      ilp32d      lp64      lp64d
@@ -12,14 +12,15 @@ MULTILIB_DIRNAMES	+= medany
 
 MULTILIB_REQUIRED	=
 MULTILIB_REQUIRED	+= march=rv32i/mabi=ilp32
-MULTILIB_REQUIRED	+= march=rv32im/mabi=ilp32
-MULTILIB_REQUIRED	+= march=rv32imafd/mabi=ilp32d
 MULTILIB_REQUIRED	+= march=rv32iac/mabi=ilp32
+MULTILIB_REQUIRED	+= march=rv32im/mabi=ilp32
+MULTILIB_REQUIRED	+= march=rv32ima/mabi=ilp32
 MULTILIB_REQUIRED	+= march=rv32imac/mabi=ilp32
+MULTILIB_REQUIRED	+= march=rv32imaf/mabi=ilp32f
 MULTILIB_REQUIRED	+= march=rv32imafc/mabi=ilp32f
-MULTILIB_REQUIRED	+= march=rv64imafd/mabi=lp64d
-MULTILIB_REQUIRED	+= march=rv64imafd/mabi=lp64d/mcmodel=medany
-MULTILIB_REQUIRED	+= march=rv64imac/mabi=lp64
+MULTILIB_REQUIRED	+= march=rv32imafd/mabi=ilp32d
+MULTILIB_REQUIRED	+= march=rv32imafdc/mabi=ilp32d
+MULTILIB_REQUIRED	+= march=rv64ima/mabi=lp64/mcmodel=medany
 MULTILIB_REQUIRED	+= march=rv64imac/mabi=lp64/mcmodel=medany
-MULTILIB_REQUIRED	+= march=rv64imafdc/mabi=lp64d
+MULTILIB_REQUIRED	+= march=rv64imafd/mabi=lp64d/mcmodel=medany
 MULTILIB_REQUIRED	+= march=rv64imafdc/mabi=lp64d/mcmodel=medany

commit 4e380c54717713355d7e6a4f6627ccb54f483e9a
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sat Feb 25 00:19:31 2023 +0000

    Daily bump.

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 2cccdb98975..5645182ec63 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,11 @@
+2023-02-24  Sebastian Huber  <sebastian.huber@embedded-brains.de>
+
+	Backported from master:
+	2023-02-24  Sebastian Huber  <sebastian.huber@embedded-brains.de>
+
+	* config/riscv/t-rtems: Keep only -mcmodel=medany 64-bit multilibs.
+	Add non-compact 32-bit multilibs.
+
 2023-02-20  Alex Coplan  <alex.coplan@arm.com>
 
 	Backported from master:
diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index fb96f27d182..cd4bc360c21 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230224
+20230225

commit 5b67f2c1f81e649c6adb665ca3e149d4ebb6b772
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sun Feb 26 00:19:34 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index cd4bc360c21..6ee65af5879 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230225
+20230226

commit de8f557de98890cf36d2b56619c54c863abc7611
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Mon Feb 27 00:18:57 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 6ee65af5879..89de5893b85 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230226
+20230227

commit 1ceffa5a3233f7b5dcbbe2352707778c6e3bdf98
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Tue Feb 28 00:20:19 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 89de5893b85..3a02054ac49 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230227
+20230228

commit dfef9518ac3cf55e9eb460e6c298401f6d19f0ba
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Wed Mar 1 00:19:38 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 3a02054ac49..a0a140e40cc 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230228
+20230301

commit 9e6a3a70b70b6ab16ebbc3ee0b4165378327e453
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Thu Mar 2 00:19:00 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index a0a140e40cc..0ee1d562349 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230301
+20230302

commit d15e7e8fe5210be60dcb98cd301aefb12b3c0991
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Fri Mar 3 00:18:09 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 0ee1d562349..7956071adad 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230302
+20230303

commit c90e68bffa37edd655dd2f5d14bb7b213c9e2431
Author: Iain Buclaw <ibuclaw@gdcproject.org>
Date:   Mon Feb 27 20:46:18 2023 +0100

    d: Fix ICE on explicit immutable struct import [PR108877]
    
    Const and immutable types are built as variants of the type they are
    derived from, and TYPE_STUB_DECL is not set for these variants.
    
            PR d/108877
    
    gcc/d/ChangeLog:
    
            * imports.cc (ImportVisitor::visit (EnumDeclaration *)): Call
            make_import on TYPE_MAIN_VARIANT.
            (ImportVisitor::visit (AggregateDeclaration *)): Likewise.
            (ImportVisitor::visit (ClassDeclaration *)): Likewise.
    
    gcc/testsuite/ChangeLog:
    
            * gdc.dg/imports/pr108877a.d: New test.
            * gdc.dg/pr108877.d: New test.
    
    (cherry picked from commit ce1cea3e22f58bbddde017f8a92e59bae8892339)

diff --git a/gcc/d/imports.cc b/gcc/d/imports.cc
index e72f1ea00ac..7852519bf6d 100644
--- a/gcc/d/imports.cc
+++ b/gcc/d/imports.cc
@@ -97,12 +97,17 @@ public:
     tree type = build_ctype (d->type);
     /* Not all kinds of D enums create a TYPE_DECL.  */
     if (TREE_CODE (type) == ENUMERAL_TYPE)
-      d->isym = this->make_import (TYPE_STUB_DECL (type));
+      {
+	type = TYPE_MAIN_VARIANT (type);
+	d->isym = this->make_import (TYPE_STUB_DECL (type));
+      }
+
   }
 
   void visit (AggregateDeclaration *d)
   {
     tree type = build_ctype (d->type);
+    type = TYPE_MAIN_VARIANT (type);
     d->isym = this->make_import (TYPE_STUB_DECL (type));
   }
 
@@ -110,6 +115,7 @@ public:
   {
     /* Want the RECORD_TYPE, not POINTER_TYPE.  */
     tree type = TREE_TYPE (build_ctype (d->type));
+    type = TYPE_MAIN_VARIANT (type);
     d->isym = this->make_import (TYPE_STUB_DECL (type));
   }
 
diff --git a/gcc/testsuite/gdc.dg/imports/pr108877a.d b/gcc/testsuite/gdc.dg/imports/pr108877a.d
new file mode 100644
index 00000000000..a23c78ddf84
--- /dev/null
+++ b/gcc/testsuite/gdc.dg/imports/pr108877a.d
@@ -0,0 +1,6 @@
+immutable struct ImmutableS { }
+const struct ConstS { }
+immutable class ImmutableC { }
+const class ConstC { }
+immutable enum ImmutableE { _ }
+const enum ConstE { _ }
diff --git a/gcc/testsuite/gdc.dg/pr108877.d b/gcc/testsuite/gdc.dg/pr108877.d
new file mode 100644
index 00000000000..710551f3f9a
--- /dev/null
+++ b/gcc/testsuite/gdc.dg/pr108877.d
@@ -0,0 +1,9 @@
+// { dg-options "-I $srcdir/gdc.dg" }
+// { dg-do compile }
+import imports.pr108877a :
+    ImmutableS,
+    ConstS,
+    ImmutableC,
+    ConstC,
+    ImmutableE,
+    ConstE;

commit 6162b5615627784ab77dcc982310cc249ed791b1
Author: Stefan Schulze Frielinghaus <stefansf@linux.ibm.com>
Date:   Fri Mar 3 17:14:13 2023 +0100

    s390: libatomic: Fix 16 byte atomic {cas,load,store}
    
    This is a follow-up to commit a4c6bd0821099f6b8c0f64a96ffd9d01a025c413
    introducing a runtime check for alignment for 16 byte atomic
    compare-exchange, load, and store.
    
    libatomic/ChangeLog:
    
            * config/s390/cas_n.c: New file.
            * config/s390/load_n.c: New file.
            * config/s390/store_n.c: New file.
    
    (cherry picked from commit 9056d0df830c5a295d7594d517d409d10476990d)

diff --git a/libatomic/config/s390/cas_n.c b/libatomic/config/s390/cas_n.c
new file mode 100644
index 00000000000..44b7152ca5d
--- /dev/null
+++ b/libatomic/config/s390/cas_n.c
@@ -0,0 +1,65 @@
+/* Copyright (C) 2018-2023 Free Software Foundation, Inc.
+
+   This file is part of the GNU Atomic Library (libatomic).
+
+   Libatomic is free software; you can redistribute it and/or modify it
+   under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   Libatomic is distributed in the hope that it will be useful, but WITHOUT ANY
+   WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+   FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+   more details.
+
+   Under Section 7 of GPL version 3, you are granted additional
+   permissions described in the GCC Runtime Library Exception, version
+   3.1, as published by the Free Software Foundation.
+
+   You should have received a copy of the GNU General Public License and
+   a copy of the GCC Runtime Library Exception along with this program;
+   see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <libatomic_i.h>
+
+
+/* Analog to config/s390/exch_n.c.  */
+
+#if !DONE && N == 16
+bool
+SIZE(libat_compare_exchange) (UTYPE *mptr, UTYPE *eptr, UTYPE newval,
+			      int smodel, int fmodel UNUSED)
+{
+  if (!((uintptr_t)mptr & 0xf))
+    {
+      return __atomic_compare_exchange_n (
+	(UTYPE *)__builtin_assume_aligned (mptr, 16), eptr, newval, false,
+	__ATOMIC_SEQ_CST, __ATOMIC_RELAXED);
+    }
+  else
+    {
+      UTYPE oldval;
+      UWORD magic;
+      bool ret;
+
+      pre_seq_barrier (smodel);
+      magic = protect_start (mptr);
+
+      oldval = *mptr;
+      ret = (oldval == *eptr);
+      if (ret)
+	*mptr = newval;
+      else
+	*eptr = oldval;
+
+      protect_end (mptr, magic);
+      post_seq_barrier (smodel);
+
+      return ret;
+    }
+}
+#define DONE 1
+#endif /* N == 16 */
+
+#include "../../cas_n.c"
diff --git a/libatomic/config/s390/load_n.c b/libatomic/config/s390/load_n.c
new file mode 100644
index 00000000000..335d2f8b2c3
--- /dev/null
+++ b/libatomic/config/s390/load_n.c
@@ -0,0 +1,57 @@
+/* Copyright (C) 2018-2023 Free Software Foundation, Inc.
+
+   This file is part of the GNU Atomic Library (libatomic).
+
+   Libatomic is free software; you can redistribute it and/or modify it
+   under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   Libatomic is distributed in the hope that it will be useful, but WITHOUT ANY
+   WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+   FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+   more details.
+
+   Under Section 7 of GPL version 3, you are granted additional
+   permissions described in the GCC Runtime Library Exception, version
+   3.1, as published by the Free Software Foundation.
+
+   You should have received a copy of the GNU General Public License and
+   a copy of the GCC Runtime Library Exception along with this program;
+   see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <libatomic_i.h>
+
+
+/* Analog to config/s390/exch_n.c.  */
+
+#if !DONE && N == 16
+UTYPE
+SIZE(libat_load) (UTYPE *mptr, int smodel)
+{
+  if (!((uintptr_t)mptr & 0xf))
+    {
+      return __atomic_load_n ((UTYPE *)__builtin_assume_aligned (mptr, 16),
+			      __ATOMIC_SEQ_CST);
+    }
+  else
+    {
+      UTYPE ret;
+      UWORD magic;
+
+      pre_seq_barrier (smodel);
+      magic = protect_start (mptr);
+
+      ret = *mptr;
+
+      protect_end (mptr, magic);
+      post_seq_barrier (smodel);
+
+      return ret;
+    }
+}
+#define DONE 1
+#endif /* N == 16 */
+
+#include "../../load_n.c"
diff --git a/libatomic/config/s390/store_n.c b/libatomic/config/s390/store_n.c
new file mode 100644
index 00000000000..9e5b2b8213d
--- /dev/null
+++ b/libatomic/config/s390/store_n.c
@@ -0,0 +1,54 @@
+/* Copyright (C) 2018-2023 Free Software Foundation, Inc.
+
+   This file is part of the GNU Atomic Library (libatomic).
+
+   Libatomic is free software; you can redistribute it and/or modify it
+   under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
+
+   Libatomic is distributed in the hope that it will be useful, but WITHOUT ANY
+   WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+   FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+   more details.
+
+   Under Section 7 of GPL version 3, you are granted additional
+   permissions described in the GCC Runtime Library Exception, version
+   3.1, as published by the Free Software Foundation.
+
+   You should have received a copy of the GNU General Public License and
+   a copy of the GCC Runtime Library Exception along with this program;
+   see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <libatomic_i.h>
+
+
+/* Analog to config/s390/exch_n.c.  */
+
+#if !DONE && N == 16
+void
+SIZE(libat_store) (UTYPE *mptr, UTYPE newval, int smodel)
+{
+  if (!((uintptr_t)mptr & 0xf))
+    {
+      __atomic_store_n ((UTYPE *)__builtin_assume_aligned (mptr, 16), newval,
+			__ATOMIC_SEQ_CST);
+    }
+  else
+    {
+      UWORD magic;
+
+      pre_seq_barrier (smodel);
+      magic = protect_start (mptr);
+
+      *mptr = newval;
+
+      protect_end (mptr, magic);
+      post_seq_barrier (smodel);
+    }
+}
+#define DONE 1
+#endif /* N == 16 */
+
+#include "../../store_n.c"

commit eeeefaf8ff3f72bc91360e204a8713dcc68fcd43
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sat Mar 4 00:18:05 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 7956071adad..887270c7322 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230303
+20230304
diff --git a/gcc/d/ChangeLog b/gcc/d/ChangeLog
index 2174a569bf8..9d495495c67 100644
--- a/gcc/d/ChangeLog
+++ b/gcc/d/ChangeLog
@@ -1,3 +1,14 @@
+2023-03-03  Iain Buclaw  <ibuclaw@gdcproject.org>
+
+	Backported from master:
+	2023-03-03  Iain Buclaw  <ibuclaw@gdcproject.org>
+
+	PR d/108877
+	* imports.cc (ImportVisitor::visit (EnumDeclaration *)): Call
+	make_import on TYPE_MAIN_VARIANT.
+	(ImportVisitor::visit (AggregateDeclaration *)): Likewise.
+	(ImportVisitor::visit (ClassDeclaration *)): Likewise.
+
 2022-12-11  Iain Buclaw  <ibuclaw@gdcproject.org>
 
 	Backported from master:
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 199b360fef5..abce3ce517e 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,12 @@
+2023-03-03  Iain Buclaw  <ibuclaw@gdcproject.org>
+
+	Backported from master:
+	2023-03-03  Iain Buclaw  <ibuclaw@gdcproject.org>
+
+	PR d/108877
+	* gdc.dg/imports/pr108877a.d: New test.
+	* gdc.dg/pr108877.d: New test.
+
 2023-02-20  Alex Coplan  <alex.coplan@arm.com>
 
 	Backported from master:
diff --git a/libatomic/ChangeLog b/libatomic/ChangeLog
index 430a9e805ec..483c31494c5 100644
--- a/libatomic/ChangeLog
+++ b/libatomic/ChangeLog
@@ -1,3 +1,12 @@
+2023-03-03  Stefan Schulze Frielinghaus  <stefansf@linux.ibm.com>
+
+	Backported from master:
+	2023-03-03  Stefan Schulze Frielinghaus  <stefansf@linux.ibm.com>
+
+	* config/s390/cas_n.c: New file.
+	* config/s390/load_n.c: New file.
+	* config/s390/store_n.c: New file.
+
 2022-06-28  Release Manager
 
 	* GCC 10.4.0 released.

commit aaf5fba354ea5d84f6471ad79f0c066e1204c80d
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sun Mar 5 00:18:31 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 887270c7322..f76ec6afe5b 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230304
+20230305

commit 9db1287c8ced5425f6ef9d26b05a3eb9cbcc4b8d
Author: Harald Anlauf <anlauf@gmx.de>
Date:   Mon Feb 20 21:28:09 2023 +0100

    Fortran: improve checking of character length specification [PR96025]
    
    gcc/fortran/ChangeLog:
    
            PR fortran/96025
            * parse.c (check_function_result_typed): Improve type check of
            specification expression for character length and return status.
            (parse_spec): Use status from above.
            * resolve.c (resolve_fntype): Prevent use of invalid specification
            expression for character length.
    
    gcc/testsuite/ChangeLog:
    
            PR fortran/96025
            * gfortran.dg/pr96025.f90: New test.
    
    (cherry picked from commit 6c1b825b3d6499dfeacf7c79dcf4b56a393ac204)

diff --git a/gcc/fortran/parse.c b/gcc/fortran/parse.c
index 6ddc5171e2f..69c0f4350ad 100644
--- a/gcc/fortran/parse.c
+++ b/gcc/fortran/parse.c
@@ -3702,21 +3702,30 @@ match_deferred_characteristics (gfc_typespec * ts)
    For return types specified in a FUNCTION prefix, the IMPLICIT rules of the
    scope are not yet parsed so this has to be delayed up to parse_spec.  */
 
-static void
+static bool
 check_function_result_typed (void)
 {
   gfc_typespec ts;
 
   gcc_assert (gfc_current_state () == COMP_FUNCTION);
 
-  if (!gfc_current_ns->proc_name->result) return;
+  if (!gfc_current_ns->proc_name->result)
+    return true;
 
   ts = gfc_current_ns->proc_name->result->ts;
 
   /* Check type-parameters, at the moment only CHARACTER lengths possible.  */
   /* TODO:  Extend when KIND type parameters are implemented.  */
   if (ts.type == BT_CHARACTER && ts.u.cl && ts.u.cl->length)
-    gfc_expr_check_typed (ts.u.cl->length, gfc_current_ns, true);
+    {
+      /* Reject invalid type of specification expression for length.  */
+      if (ts.u.cl->length->ts.type != BT_INTEGER)
+	  return false;
+
+      gfc_expr_check_typed (ts.u.cl->length, gfc_current_ns, true);
+    }
+
+  return true;
 }
 
 
@@ -3824,10 +3833,7 @@ loop:
 	}
 
       if (verify_now)
-	{
-	  check_function_result_typed ();
-	  function_result_typed = true;
-	}
+	function_result_typed = check_function_result_typed ();
     }
 
   switch (st)
@@ -3838,10 +3844,7 @@ loop:
     case ST_IMPLICIT_NONE:
     case ST_IMPLICIT:
       if (!function_result_typed)
-	{
-	  check_function_result_typed ();
-	  function_result_typed = true;
-	}
+	function_result_typed = check_function_result_typed ();
       goto declSt;
 
     case ST_FORMAT:
diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c
index 70c6f57279a..3163f63c996 100644
--- a/gcc/fortran/resolve.c
+++ b/gcc/fortran/resolve.c
@@ -17139,7 +17139,9 @@ resolve_fntype (gfc_namespace *ns)
 	  }
       }
 
-  if (sym->ts.type == BT_CHARACTER)
+  if (sym->ts.type == BT_CHARACTER
+      && sym->ts.u.cl->length
+      && sym->ts.u.cl->length->ts.type == BT_INTEGER)
     gfc_traverse_expr (sym->ts.u.cl->length, sym, flag_fn_result_spec, 0);
 }
 
diff --git a/gcc/testsuite/gfortran.dg/pr96025.f90 b/gcc/testsuite/gfortran.dg/pr96025.f90
new file mode 100644
index 00000000000..ce292bd9664
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr96025.f90
@@ -0,0 +1,11 @@
+! { dg-do compile }
+! PR fortran/96025 - ICE in expr_check_typed_help
+! Contributed by G.Steinmetz
+
+program p
+  print *, f()
+contains
+  character(char(1)) function f() ! { dg-error "must be of INTEGER type" }
+    f = 'f'
+  end
+end

commit 22031c5868bbb434b51ea4010ccae0cf8c890d6b
Author: Harald Anlauf <anlauf@gmx.de>
Date:   Tue Feb 21 22:06:33 2023 +0100

    Fortran: reject invalid CHARACTER length of derived type components [PR96024]
    
    gcc/fortran/ChangeLog:
    
            PR fortran/96024
            * resolve.c (resolve_component): The type of a CHARACTER length
            expression must be INTEGER.
    
    gcc/testsuite/ChangeLog:
    
            PR fortran/96024
            * gfortran.dg/pr96024.f90: New test.
    
    (cherry picked from commit 31303c9b5bab200754cdb7ef8cd91ae4918f3018)

diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c
index 3163f63c996..288970deca0 100644
--- a/gcc/fortran/resolve.c
+++ b/gcc/fortran/resolve.c
@@ -14643,6 +14643,19 @@ resolve_component (gfc_component *c, gfc_symbol *sym)
                     c->ts.u.cl->length ? &c->ts.u.cl->length->where : &c->loc);
          return false;
        }
+
+     if (c->ts.u.cl->length && c->ts.u.cl->length->ts.type != BT_INTEGER)
+       {
+	 if (!c->ts.u.cl->length->error)
+	   {
+	     gfc_error ("Character length expression of component %qs at %L "
+			"must be of INTEGER type, found %s",
+			c->name, &c->ts.u.cl->length->where,
+			gfc_basic_typename (c->ts.u.cl->length->ts.type));
+	     c->ts.u.cl->length->error = 1;
+	   }
+	 return false;
+       }
     }
 
   if (c->ts.type == BT_CHARACTER && c->ts.deferred
diff --git a/gcc/testsuite/gfortran.dg/pr96024.f90 b/gcc/testsuite/gfortran.dg/pr96024.f90
new file mode 100644
index 00000000000..2c914a997f2
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr96024.f90
@@ -0,0 +1,11 @@
+! { dg-do compile }
+! PR fortran/96024 - ICE in mio_name_expr_t
+! Contributed by G.Steinmetz
+
+module m
+  implicit none
+  type t
+     character(char(1)) :: a ! { dg-error "must be of INTEGER type" }
+  end type
+  type(t) :: z = t('a')
+end

commit 570828e84f751730743093e5f060eeaf98c08cac
Author: Harald Anlauf <anlauf@gmx.de>
Date:   Mon Feb 27 21:37:11 2023 +0100

    Fortran: fix corner case of IBITS intrinsic [PR108937]
    
    gcc/fortran/ChangeLog:
    
            PR fortran/108937
            * trans-intrinsic.c (gfc_conv_intrinsic_ibits): Handle corner case
            LEN argument of IBITS equal to BITSIZE(I).
    
    gcc/testsuite/ChangeLog:
    
            PR fortran/108937
            * gfortran.dg/ibits_2.f90: New test.
    
    (cherry picked from commit 6cce953ebec274f1468d5d3a0697cf05bb43b8f6)

diff --git a/gcc/fortran/trans-intrinsic.c b/gcc/fortran/trans-intrinsic.c
index 9a4aa08f889..1d3ad31eb59 100644
--- a/gcc/fortran/trans-intrinsic.c
+++ b/gcc/fortran/trans-intrinsic.c
@@ -6502,6 +6502,7 @@ gfc_conv_intrinsic_ibits (gfc_se * se, gfc_expr * expr)
   tree type;
   tree tmp;
   tree mask;
+  tree num_bits, cond;
 
   gfc_conv_intrinsic_function_args (se, expr, args, 3);
   type = TREE_TYPE (args[0]);
@@ -6542,8 +6543,17 @@ gfc_conv_intrinsic_ibits (gfc_se * se, gfc_expr * expr)
 			       "in intrinsic IBITS", tmp1, tmp2, nbits);
     }
 
+  /* The Fortran standard allows (shift width) LEN <= BIT_SIZE(I), whereas
+     gcc requires a shift width < BIT_SIZE(I), so we have to catch this
+     special case.  See also gfc_conv_intrinsic_ishft ().  */
+  num_bits = build_int_cst (TREE_TYPE (args[2]), TYPE_PRECISION (type));
+
   mask = build_int_cst (type, -1);
   mask = fold_build2_loc (input_location, LSHIFT_EXPR, type, mask, args[2]);
+  cond = fold_build2_loc (input_location, GE_EXPR, logical_type_node, args[2],
+			  num_bits);
+  mask = fold_build3_loc (input_location, COND_EXPR, type, cond,
+			  build_int_cst (type, 0), mask);
   mask = fold_build1_loc (input_location, BIT_NOT_EXPR, type, mask);
 
   tmp = fold_build2_loc (input_location, RSHIFT_EXPR, type, args[0], args[1]);
diff --git a/gcc/testsuite/gfortran.dg/ibits_2.f90 b/gcc/testsuite/gfortran.dg/ibits_2.f90
new file mode 100644
index 00000000000..2af5542d764
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/ibits_2.f90
@@ -0,0 +1,32 @@
+! { dg-do run }
+! { dg-additional-options "-fcheck=bits" }
+! PR fortran/108937 - Intrinsic IBITS(I,POS,LEN) fails when LEN equals
+!                     to BIT_SIZE(I)
+! Contributed by saitofuyuki@jamstec.go.jp
+
+program test_bits
+  implicit none
+  integer, parameter :: KT = kind (1)
+  integer, parameter :: lbits = bit_size (0_KT)
+  integer(kind=KT) :: x, y0, y1
+  integer(kind=KT) :: p, l
+
+  x = -1
+  p = 0
+  do l = 0, lbits
+     y0 = ibits  (x, p, l)
+     y1 = ibits_1(x, p, l)
+     if (y0 /= y1) then
+        print *, l, y0, y1
+        stop 1+l
+     end if
+  end do
+contains
+  elemental integer(kind=KT) function ibits_1(I, POS, LEN) result(n)
+    !! IBITS(I, POS, LEN) = (I >> POS) & ~((~0) << LEN)
+    implicit none
+    integer(kind=KT),intent(in) :: I
+    integer,         intent(in) :: POS, LEN
+    n = IAND (ISHFT(I, - POS), NOT(ISHFT(-1_KT, LEN)))
+  end function ibits_1
+end program test_bits

commit 9d5ffb65405938bde2fa32d52f4e826f1664f72e
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Mon Mar 6 00:18:27 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index f76ec6afe5b..086e055556f 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230305
+20230306
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 2f897d0388d..83e40200e41 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,33 @@
+2023-03-05  Harald Anlauf  <anlauf@gmx.de>
+
+	Backported from master:
+	2023-02-27  Harald Anlauf  <anlauf@gmx.de>
+
+	PR fortran/108937
+	* trans-intrinsic.c (gfc_conv_intrinsic_ibits): Handle corner case
+	LEN argument of IBITS equal to BITSIZE(I).
+
+2023-03-05  Harald Anlauf  <anlauf@gmx.de>
+
+	Backported from master:
+	2023-02-22  Harald Anlauf  <anlauf@gmx.de>
+
+	PR fortran/96024
+	* resolve.c (resolve_component): The type of a CHARACTER length
+	expression must be INTEGER.
+
+2023-03-05  Harald Anlauf  <anlauf@gmx.de>
+
+	Backported from master:
+	2023-02-21  Harald Anlauf  <anlauf@gmx.de>
+
+	PR fortran/96025
+	* parse.c (check_function_result_typed): Improve type check of
+	specification expression for character length and return status.
+	(parse_spec): Use status from above.
+	* resolve.c (resolve_fntype): Prevent use of invalid specification
+	expression for character length.
+
 2023-02-11  Harald Anlauf  <anlauf@gmx.de>
 
 	Backported from master:
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index abce3ce517e..c3989954224 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,27 @@
+2023-03-05  Harald Anlauf  <anlauf@gmx.de>
+
+	Backported from master:
+	2023-02-27  Harald Anlauf  <anlauf@gmx.de>
+
+	PR fortran/108937
+	* gfortran.dg/ibits_2.f90: New test.
+
+2023-03-05  Harald Anlauf  <anlauf@gmx.de>
+
+	Backported from master:
+	2023-02-22  Harald Anlauf  <anlauf@gmx.de>
+
+	PR fortran/96024
+	* gfortran.dg/pr96024.f90: New test.
+
+2023-03-05  Harald Anlauf  <anlauf@gmx.de>
+
+	Backported from master:
+	2023-02-21  Harald Anlauf  <anlauf@gmx.de>
+
+	PR fortran/96025
+	* gfortran.dg/pr96025.f90: New test.
+
 2023-03-03  Iain Buclaw  <ibuclaw@gdcproject.org>
 
 	Backported from master:

commit 55a43d6a62861870f066ea8583a787a8cd6d3fd0
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Tue Mar 7 00:18:24 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 086e055556f..c01bc02318c 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230306
+20230307

commit 13858bc9331df8c6ff37e185e34ab09fb1fd3553
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Wed Mar 8 00:18:39 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index c01bc02318c..53389297a17 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230307
+20230308

commit 3dd30147e80451cea20ec9dcf76c75dbc86b53aa
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Thu Mar 9 00:18:24 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 53389297a17..c7a9cb13dc6 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230308
+20230309

commit cdad0b7f4259259bb414297aa5bb3f5878b8dfc6
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Fri Mar 10 00:18:43 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index c7a9cb13dc6..cca5b336d18 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230309
+20230310

commit 5247f8c2851b6acb328fd83fd11b401c5e30da90
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sat Mar 11 00:18:11 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index cca5b336d18..1a5dec56378 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230310
+20230311

commit 7b1a2956dafc4576bba0dae4171900578f513fd1
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sun Mar 12 00:18:11 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 1a5dec56378..4ce3ea7c20f 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230311
+20230312

commit 57d8cbbcf4b805c9d66b53e8ea9fb6314d6111a2
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Mon Mar 13 00:18:54 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 4ce3ea7c20f..356057bf73a 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230312
+20230313

commit fcc29feaef9331b6e62c7c00ff7e4557da4b944e
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Tue Mar 14 00:19:09 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 356057bf73a..975096e7c1c 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230313
+20230314

commit d5ae94cb2afb8f8d21892ea427ba153a81a69bd1
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Wed Mar 15 00:18:22 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 975096e7c1c..1541514c486 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230314
+20230315

commit 5d9958d5637cc4f0a6e09e244cbf8565cffd8ba6
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Thu Mar 16 00:18:36 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 1541514c486..b0f638be23e 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230315
+20230316

commit d640e435f156d8f825bf95c2164053b4a3a7b682
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Thu Feb 2 14:06:40 2023 +0000

    libstdc++: Fix std::filesystem errors with -fkeep-inline-functions [PR108636]
    
    With -fkeep-inline-functions there are linker errors when including
    <filesystem>. This happens because there are some filesystem::path
    constructors defined inline which call non-exported functions defined in
    the library. That's usually not a problem, because those constructors
    are only called by code that's also inside the library. But when the
    header is compiled with -fkeep-inline-functions those inline functions
    are emitted even though they aren't called. That then creates an
    undefined reference to the other library internals. The fix is to just
    move the private constructors into the library where they are called.
    That way they are never even seen by users, and so not compiled even if
    -fkeep-inline-functions is used.
    
    libstdc++-v3/ChangeLog:
    
            PR libstdc++/108636
            * include/bits/fs_path.h (path::path(string_view, _Type))
            (path::_Cmpt::_Cmpt(string_view, _Type, size_t)): Move inline
            definitions to ...
            * src/c++17/fs_path.cc: ... here.
            * testsuite/27_io/filesystem/path/108636.cc: New test.
    
    (cherry picked from commit db8d6fc572ec316ccfcf70b1dffe3be0b1b37212)

diff --git a/libstdc++-v3/include/bits/fs_path.h b/libstdc++-v3/include/bits/fs_path.h
index 7b49461794f..3370bf7161e 100644
--- a/libstdc++-v3/include/bits/fs_path.h
+++ b/libstdc++-v3/include/bits/fs_path.h
@@ -515,12 +515,7 @@ namespace __detail
       _Multi = 0, _Root_name, _Root_dir, _Filename
     };
 
-    path(basic_string_view<value_type> __str, _Type __type)
-    : _M_pathname(__str)
-    {
-      __glibcxx_assert(__type != _Type::_Multi);
-      _M_cmpts.type(__type);
-    }
+    path(basic_string_view<value_type> __str, _Type __type);
 
     enum class _Split { _Stem, _Extension };
 
@@ -766,8 +761,7 @@ namespace __detail
 
   struct path::_Cmpt : path
   {
-    _Cmpt(basic_string_view<value_type> __s, _Type __t, size_t __pos)
-      : path(__s, __t), _M_pos(__pos) { }
+    _Cmpt(basic_string_view<value_type> __s, _Type __t, size_t __pos);
 
     _Cmpt() : _M_pos(-1) { }
 
diff --git a/libstdc++-v3/src/c++17/fs_path.cc b/libstdc++-v3/src/c++17/fs_path.cc
index 812f39fe253..9d945ed07a8 100644
--- a/libstdc++-v3/src/c++17/fs_path.cc
+++ b/libstdc++-v3/src/c++17/fs_path.cc
@@ -186,6 +186,19 @@ struct path::_Parser
   { return origin + c.str.data() - input.data(); }
 };
 
+inline
+path::path(basic_string_view<value_type> __str, _Type __type)
+: _M_pathname(__str)
+{
+  __glibcxx_assert(__type != _Type::_Multi);
+  _M_cmpts.type(__type);
+}
+
+inline
+path::_Cmpt::_Cmpt(basic_string_view<value_type> __s, _Type __t, size_t __pos)
+: path(__s, __t), _M_pos(__pos)
+{ }
+
 struct path::_List::_Impl
 {
   using value_type = _Cmpt;
diff --git a/libstdc++-v3/testsuite/27_io/filesystem/path/108636.cc b/libstdc++-v3/testsuite/27_io/filesystem/path/108636.cc
new file mode 100644
index 00000000000..d58de461090
--- /dev/null
+++ b/libstdc++-v3/testsuite/27_io/filesystem/path/108636.cc
@@ -0,0 +1,8 @@
+// { dg-do link { target c++17 } }
+// { dg-options "-fkeep-inline-functions" }
+
+#include <filesystem>
+int main()
+{
+  // PR libstdc++/108636 - link failure with -fkeep-inline-functions
+}

commit d06cdb8e7593cafd44435f02ba63987ec38036c9
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Fri Mar 17 00:18:37 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index b0f638be23e..348f4b8a133 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230316
+20230317
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 77cbdb22e32..1be9436b617 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,15 @@
+2023-03-16  Jonathan Wakely  <jwakely@redhat.com>
+
+	Backported from master:
+	2023-02-02  Jonathan Wakely  <jwakely@redhat.com>
+
+	PR libstdc++/108636
+	* include/bits/fs_path.h (path::path(string_view, _Type))
+	(path::_Cmpt::_Cmpt(string_view, _Type, size_t)): Move inline
+	definitions to ...
+	* src/c++17/fs_path.cc: ... here.
+	* testsuite/27_io/filesystem/path/108636.cc: New test.
+
 2022-11-08  Jonathan Wakely  <jwakely@redhat.com>
 
 	Backported from master:

commit c5cb9d8819eb9551d23f77e63cb3399115f0aab8
Author: Harald Anlauf <anlauf@gmx.de>
Date:   Thu Mar 9 18:59:08 2023 +0100

    Fortran: fix ICE with bind(c) in block data [PR104332]
    
    gcc/fortran/ChangeLog:
    
            PR fortran/104332
            * resolve.c (resolve_symbol): Avoid NULL pointer dereference while
            checking a symbol with the BIND(C) attribute.
    
    gcc/testsuite/ChangeLog:
    
            PR fortran/104332
            * gfortran.dg/bind_c_usage_34.f90: New test.
    
    (cherry picked from commit e20e5d9dc11b64e8eabce6803c91cb5768207083)

diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c
index 288970deca0..98e94044e02 100644
--- a/gcc/fortran/resolve.c
+++ b/gcc/fortran/resolve.c
@@ -15666,8 +15666,8 @@ resolve_symbol (gfc_symbol *sym)
 
       /* First, make sure the variable is declared at the
 	 module-level scope (J3/04-007, Section 15.3).	*/
-      if (sym->ns->proc_name->attr.flavor != FL_MODULE &&
-          sym->attr.in_common == 0)
+      if (!(sym->ns->proc_name && sym->ns->proc_name->attr.flavor == FL_MODULE)
+	  && !sym->attr.in_common)
 	{
 	  gfc_error ("Variable %qs at %L cannot be BIND(C) because it "
 		     "is neither a COMMON block nor declared at the "
diff --git a/gcc/testsuite/gfortran.dg/bind_c_usage_34.f90 b/gcc/testsuite/gfortran.dg/bind_c_usage_34.f90
new file mode 100644
index 00000000000..40c8e9363cf
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/bind_c_usage_34.f90
@@ -0,0 +1,21 @@
+! { dg-do compile }
+! PR fortran/104332 - ICE with bind(c) in block data
+! Contributed by G. Steinmetz
+
+block data
+  bind(c) :: a ! { dg-error "cannot be BIND\\(C\\)" }
+end
+
+block data aa
+   real, bind(c) :: a ! { dg-error "cannot be BIND\\(C\\)" }
+end
+
+block data bb
+   real    :: a ! { dg-error "cannot be BIND\\(C\\)" }
+   bind(c) :: a
+end
+
+block data cc
+   common /a/ x
+   bind(c) :: /a/
+end

commit 3cca6b5fa51fd271644082761de85e89fd56d69c
Author: Harald Anlauf <anlauf@gmx.de>
Date:   Sat Mar 11 15:37:37 2023 +0100

    Fortran: fix bounds check for copying of class expressions [PR106945]
    
    In the bounds check for copying of class expressions, the number of elements
    determined from a descriptor, returned as type gfc_array_index_type (i.e. a
    signed type), should be converted to the type of the passed element count,
    which is of type size_type_node (i.e. unsigned), for use in comparisons.
    
    gcc/fortran/ChangeLog:
    
            PR fortran/106945
            * trans-expr.c (gfc_copy_class_to_class): Convert element counts in
            bounds check to common type for comparison.
    
    gcc/testsuite/ChangeLog:
    
            PR fortran/106945
            * gfortran.dg/pr106945.f90: New test.
    
    (cherry picked from commit 2cf5f485e0351bb1faf46196a99e524688f3966e)

diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c
index 602df7debe6..7dfd19ffe10 100644
--- a/gcc/fortran/trans-expr.c
+++ b/gcc/fortran/trans-expr.c
@@ -1437,6 +1437,7 @@ gfc_copy_class_to_class (tree from, tree to, tree nelems, bool unlimited)
 	    name = (const char *)(DECL_NAME (to)->identifier.id.str);
 
 	  from_len = gfc_conv_descriptor_size (from_data, 1);
+	  from_len = fold_convert (TREE_TYPE (orig_nelems), from_len);
 	  tmp = fold_build2_loc (input_location, NE_EXPR,
 				  logical_type_node, from_len, orig_nelems);
 	  msg = xasprintf ("Array bound mismatch for dimension %d "
diff --git a/gcc/testsuite/gfortran.dg/pr106945.f90 b/gcc/testsuite/gfortran.dg/pr106945.f90
new file mode 100644
index 00000000000..e760ca7d27f
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr106945.f90
@@ -0,0 +1,11 @@
+! { dg-do compile }
+! { dg-options "-fcoarray=single -fcheck=bounds -ftrapv" }
+! PR fortran/106945
+! Contributed by G. Steinmetz
+
+module m
+  implicit none
+  type t
+     class(*), allocatable :: a[:]
+  end type
+end

commit 2da81ed90c182535f56d8fa6b26ad2badc62282c
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sat Mar 18 00:18:14 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 348f4b8a133..4b45c22ce57 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230317
+20230318
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 83e40200e41..1eaa0fe7637 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,21 @@
+2023-03-17  Harald Anlauf  <anlauf@gmx.de>
+
+	Backported from master:
+	2023-03-11  Harald Anlauf  <anlauf@gmx.de>
+
+	PR fortran/106945
+	* trans-expr.c (gfc_copy_class_to_class): Convert element counts in
+	bounds check to common type for comparison.
+
+2023-03-17  Harald Anlauf  <anlauf@gmx.de>
+
+	Backported from master:
+	2023-03-10  Harald Anlauf  <anlauf@gmx.de>
+
+	PR fortran/104332
+	* resolve.c (resolve_symbol): Avoid NULL pointer dereference while
+	checking a symbol with the BIND(C) attribute.
+
 2023-03-05  Harald Anlauf  <anlauf@gmx.de>
 
 	Backported from master:
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index c3989954224..1718a14d34c 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,19 @@
+2023-03-17  Harald Anlauf  <anlauf@gmx.de>
+
+	Backported from master:
+	2023-03-11  Harald Anlauf  <anlauf@gmx.de>
+
+	PR fortran/106945
+	* gfortran.dg/pr106945.f90: New test.
+
+2023-03-17  Harald Anlauf  <anlauf@gmx.de>
+
+	Backported from master:
+	2023-03-10  Harald Anlauf  <anlauf@gmx.de>
+
+	PR fortran/104332
+	* gfortran.dg/bind_c_usage_34.f90: New test.
+
 2023-03-05  Harald Anlauf  <anlauf@gmx.de>
 
 	Backported from master:

commit 6191f9a0177779a1d34c3f4b9cac02c9b19e0975
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sun Mar 19 00:18:54 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 4b45c22ce57..401e9e9bd2a 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230318
+20230319

commit 09f65006ef2b6180657187b1ebf045dfe35c472d
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Mon Mar 20 00:18:48 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 401e9e9bd2a..ad75bcfd2b2 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230319
+20230320

commit 7117686b01ee57523458c3e5513a4825e659e57e
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Tue Mar 21 00:18:25 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index ad75bcfd2b2..b664e28b829 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230320
+20230321

commit cdb16548d55208c034e0525d139e72ce66fdf692
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Wed Mar 22 00:18:41 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index b664e28b829..7c59d0a1976 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230321
+20230322

commit e6623d1dc48526e1a9be40661a0ad5adc67a4e07
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Thu Mar 23 00:19:09 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 7c59d0a1976..1fe01ef2611 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230322
+20230323

commit 840268549508fe161721b1ada0542dd42137916f
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Fri Mar 24 00:18:32 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 1fe01ef2611..c2cc3bfa412 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230323
+20230324

commit dca8e28c990547648543175de9b6e05356f77e8a
Author: Harald Anlauf <anlauf@gmx.de>
Date:   Fri Mar 17 22:24:49 2023 +0100

    Fortran: procedures with BIND(C) attribute require explicit interface [PR85877]
    
    gcc/fortran/ChangeLog:
    
            PR fortran/85877
            * resolve.c (resolve_fl_procedure): Check for an explicit interface
            of procedures with the BIND(C) attribute (F2018:15.4.2.2).
    
    gcc/testsuite/ChangeLog:
    
            PR fortran/85877
            * gfortran.dg/pr85877.f90: New test.
    
    (cherry picked from commit 5426ab34643d9e6502f3ee572891a03471fa33ed)

diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c
index 98e94044e02..dc127abeb64 100644
--- a/gcc/fortran/resolve.c
+++ b/gcc/fortran/resolve.c
@@ -13413,6 +13413,16 @@ check_formal:
 	    }
 	}
     }
+
+  /* F2018:15.4.2.2 requires an explicit interface for procedures with the
+     BIND(C) attribute.  */
+  if (sym->attr.is_bind_c && sym->attr.if_source == IFSRC_UNKNOWN)
+    {
+      gfc_error ("Interface of %qs at %L must be explicit",
+		 sym->name, &sym->declared_at);
+      return false;
+    }
+
   return true;
 }
 
diff --git a/gcc/testsuite/gfortran.dg/pr85877.f90 b/gcc/testsuite/gfortran.dg/pr85877.f90
new file mode 100644
index 00000000000..d8f08cbd210
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr85877.f90
@@ -0,0 +1,25 @@
+! { dg-do compile }
+! PR fortran/85877
+! A procedure with the bind(c) attribute shall have an explicit interface
+! Contributed by G. Steinmetz
+
+function f() bind(c)
+  f = 42.
+end
+
+subroutine p
+  bind(c) f     ! { dg-error "must be explicit" }
+  x = f()
+end
+
+function g() bind(c)
+  g = 42.
+end
+
+subroutine s
+  interface
+     function g() bind(c)
+     end function g
+  end interface
+  x = g()
+end

commit b9f6e7e234bab6ef8b5425c3e8b88bf8dfbc5089
Author: Harald Anlauf <anlauf@gmx.de>
Date:   Sun Mar 19 21:29:46 2023 +0100

    Fortran: simplification of NEAREST for large argument [PR109186]
    
    gcc/fortran/ChangeLog:
    
            PR fortran/109186
            * simplify.c (gfc_simplify_nearest): Fix off-by-one error in setting
            up real kind-specific maximum exponent for mpfr.
    
    gcc/testsuite/ChangeLog:
    
            PR fortran/109186
            * gfortran.dg/nearest_6.f90: New test.
    
    (cherry picked from commit 4410a08b80cc40342eeaa5b6af824cd4352b218c)

diff --git a/gcc/fortran/simplify.c b/gcc/fortran/simplify.c
index fe4fee897f0..2cac5a4e168 100644
--- a/gcc/fortran/simplify.c
+++ b/gcc/fortran/simplify.c
@@ -5958,7 +5958,7 @@ gfc_simplify_nearest (gfc_expr *x, gfc_expr *s)
   kind = gfc_validate_kind (BT_REAL, x->ts.kind, 0);
   mpfr_set_emin ((mpfr_exp_t) gfc_real_kinds[kind].min_exponent -
 		mpfr_get_prec(result->value.real) + 1);
-  mpfr_set_emax ((mpfr_exp_t) gfc_real_kinds[kind].max_exponent - 1);
+  mpfr_set_emax ((mpfr_exp_t) gfc_real_kinds[kind].max_exponent);
   mpfr_check_range (result->value.real, 0, MPFR_RNDU);
 
   if (mpfr_sgn (s->value.real) > 0)
diff --git a/gcc/testsuite/gfortran.dg/nearest_6.f90 b/gcc/testsuite/gfortran.dg/nearest_6.f90
new file mode 100644
index 00000000000..00d1ebe618c
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/nearest_6.f90
@@ -0,0 +1,26 @@
+! { dg-do run }
+! PR fortran/109186 - Verify that NEAREST produces same results at
+!                     compile-time and run-time for corner cases
+! Reported by John Harper
+
+program p
+  implicit none
+  integer,  parameter :: sp = selected_real_kind (6)
+  integer,  parameter :: dp = selected_real_kind (13)
+  real(sp), parameter :: x1 = huge (1._sp), t1 = tiny (1._sp)
+  real(dp), parameter :: x2 = huge (1._dp), t2 = tiny (1._dp)
+  real(sp), volatile  :: y1, z1
+  real(dp), volatile  :: y2, z2
+  y1 = x1
+  z1 = nearest (y1, -1._sp)
+  if (nearest (x1,  -1._sp) /= z1) stop 1
+  y2 = x2
+  z2 = nearest (y2, -1._dp)
+  if (nearest (x2,  -1._dp) /= z2) stop 2
+  y1 = t1
+  z1 = nearest (y1,  1._sp)
+  if (nearest (t1,   1._sp) /= z1) stop 3
+  y2 = t2
+  z2 = nearest (y2,  1._dp)
+  if (nearest (t2,   1._dp) /= z2) stop 4
+end

commit 78a626186aa920dfffbc2c9948dd94227a80bcb9
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sat Mar 25 00:19:25 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index c2cc3bfa412..3c8c315bc19 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230324
+20230325
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 1eaa0fe7637..8b8ee9ab2ad 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,21 @@
+2023-03-24  Harald Anlauf  <anlauf@gmx.de>
+
+	Backported from master:
+	2023-03-20  Harald Anlauf  <anlauf@gmx.de>
+
+	PR fortran/109186
+	* simplify.c (gfc_simplify_nearest): Fix off-by-one error in setting
+	up real kind-specific maximum exponent for mpfr.
+
+2023-03-24  Harald Anlauf  <anlauf@gmx.de>
+
+	Backported from master:
+	2023-03-19  Harald Anlauf  <anlauf@gmx.de>
+
+	PR fortran/85877
+	* resolve.c (resolve_fl_procedure): Check for an explicit interface
+	of procedures with the BIND(C) attribute (F2018:15.4.2.2).
+
 2023-03-17  Harald Anlauf  <anlauf@gmx.de>
 
 	Backported from master:
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 1718a14d34c..38fb279f0bc 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,19 @@
+2023-03-24  Harald Anlauf  <anlauf@gmx.de>
+
+	Backported from master:
+	2023-03-20  Harald Anlauf  <anlauf@gmx.de>
+
+	PR fortran/109186
+	* gfortran.dg/nearest_6.f90: New test.
+
+2023-03-24  Harald Anlauf  <anlauf@gmx.de>
+
+	Backported from master:
+	2023-03-19  Harald Anlauf  <anlauf@gmx.de>
+
+	PR fortran/85877
+	* gfortran.dg/pr85877.f90: New test.
+
 2023-03-17  Harald Anlauf  <anlauf@gmx.de>
 
 	Backported from master:

commit fc109e18c4b38b0e54b3798b780d76e304763156
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sun Mar 26 00:19:07 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 3c8c315bc19..ba111ba97d1 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230325
+20230326

commit f35810e6891b34303e7c5b00846ce71ae1c7ca65
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Mon Mar 27 00:18:17 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index ba111ba97d1..b1ac5d92795 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230326
+20230327

commit 3a8067301878aefb8b1c01cf76f90dbf26eeb662
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Tue Mar 28 00:18:01 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index b1ac5d92795..1f5084a2947 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230327
+20230328

commit f5ee2ecff9176e738d84e3e142687e80fec46b80
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Wed Mar 29 00:17:55 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 1f5084a2947..8696380a31a 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230328
+20230329

commit 31c7046c9461c8f65a42ebbc5a7b2e13511a09ac
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Thu Mar 30 00:18:02 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 8696380a31a..6800443be95 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230329
+20230330

commit d31d9e54214d43095d4a113beb1f05ca2406314a
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Fri Mar 31 00:18:04 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 6800443be95..bc28fe8762d 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230330
+20230331

commit 36293395d6d1dc03e308fe781da3b642e14af5f0
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sat Apr 1 00:18:57 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index bc28fe8762d..7e68af43686 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230331
+20230401

commit ca099bdd77915cd85285df4dc413d5b168903564
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sun Apr 2 00:18:38 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 7e68af43686..afd3f9fc6c8 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230401
+20230402

commit 8c0f4737af30da55935e0097d4411c6e853ce201
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Mon Apr 3 00:18:13 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index afd3f9fc6c8..a77ceb4df4d 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230402
+20230403

commit d86b5399e6f21ee954bf6d8119a974efe4ed9f6c
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Tue Apr 4 00:17:55 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index a77ceb4df4d..8ddc41d9cfc 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230403
+20230404

commit 0376e9d48138cdd9735d58ed7a9abfb2574dd4d6
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Wed Apr 5 00:18:20 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 8ddc41d9cfc..643efe31568 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230404
+20230405

commit a23627d8af71214e27798a2083a337b98b284f3e
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Thu Apr 6 00:18:02 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 643efe31568..b4a11630735 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230405
+20230406

commit 08d7df85637ad8f50839cfa00d090cd3a4129354
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Fri Apr 7 00:18:51 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index b4a11630735..0baf8f53996 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230406
+20230407

commit 52bc6efe322c606de3ebaeff5f68fde73d397555
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sat Apr 8 00:18:05 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 0baf8f53996..83db7a76d0c 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230407
+20230408

commit f488950a40dceee74269d2c4b458175778066658
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sun Apr 9 00:18:54 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 83db7a76d0c..d9c6ca6f33a 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230408
+20230409

commit 3ebba53ad4c02486de7bf8d261f0c779153d5f4c
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Mon Apr 10 00:18:00 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index d9c6ca6f33a..6629bed2dc2 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230409
+20230410

commit c58a9a171cf227ec45d883c11392936d66f4303c
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Tue Apr 11 00:17:58 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 6629bed2dc2..1315cb61cda 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230410
+20230411

commit 73c35ed825c4cbf7c73ac8794450621a34d43e29
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Wed Apr 12 00:18:31 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 1315cb61cda..77737c0af77 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230411
+20230412

commit 50eb64b2ccb2384781421ab80da1c05e9502fd63
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Thu Apr 13 00:18:39 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 77737c0af77..3c5dae80bb1 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230412
+20230413

commit f6af72387704e53b69355ace0d692864220617ba
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Fri Apr 14 00:18:54 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 3c5dae80bb1..7b4841be5c2 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230413
+20230414

commit c2a0042db4f646367228776effc24eeff44e6794
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sat Apr 15 00:18:27 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 7b4841be5c2..0643a1b9102 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230414
+20230415

commit 22055748e5fc75e6dff7da991d7a28e132c093c0
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sun Apr 16 00:18:17 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 0643a1b9102..ba4f30bf048 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230415
+20230416

commit dd2cd1e70509aaeb3db3e7b322d8357bac817632
Author: Harald Anlauf <anlauf@gmx.de>
Date:   Fri Apr 14 20:45:19 2023 +0200

    Fortran: fix compile-time simplification of SET_EXPONENT [PR109511]
    
    gcc/fortran/ChangeLog:
    
            PR fortran/109511
            * simplify.c (gfc_simplify_set_exponent): Fix implementation of
            compile-time simplification of intrinsic SET_EXPONENT for argument
            X < 1 and for I < 0.
    
    gcc/testsuite/ChangeLog:
    
            PR fortran/109511
            * gfortran.dg/set_exponent_1.f90: New test.
    
    (cherry picked from commit fa4cb42870df60deb8888dbd51e2ddc6d6ab9e6a)

diff --git a/gcc/fortran/simplify.c b/gcc/fortran/simplify.c
index 2cac5a4e168..cb6f2404c0b 100644
--- a/gcc/fortran/simplify.c
+++ b/gcc/fortran/simplify.c
@@ -7196,7 +7196,7 @@ gfc_simplify_set_exponent (gfc_expr *x, gfc_expr *i)
 {
   gfc_expr *result;
   mpfr_t exp, absv, log2, pow2, frac;
-  unsigned long exp2;
+  long exp2;
 
   if (x->expr_type != EXPR_CONSTANT || i->expr_type != EXPR_CONSTANT)
     return NULL;
@@ -7228,19 +7228,19 @@ gfc_simplify_set_exponent (gfc_expr *x, gfc_expr *i)
   mpfr_abs (absv, x->value.real, GFC_RND_MODE);
   mpfr_log2 (log2, absv, GFC_RND_MODE);
 
-  mpfr_trunc (log2, log2);
+  mpfr_floor (log2, log2);
   mpfr_add_ui (exp, log2, 1, GFC_RND_MODE);
 
   /* Old exponent value, and fraction.  */
   mpfr_ui_pow (pow2, 2, exp, GFC_RND_MODE);
 
-  mpfr_div (frac, absv, pow2, GFC_RND_MODE);
+  mpfr_div (frac, x->value.real, pow2, GFC_RND_MODE);
 
   /* New exponent.  */
-  exp2 = (unsigned long) mpz_get_d (i->value.integer);
-  mpfr_mul_2exp (result->value.real, frac, exp2, GFC_RND_MODE);
+  exp2 = mpz_get_si (i->value.integer);
+  mpfr_mul_2si (result->value.real, frac, exp2, GFC_RND_MODE);
 
-  mpfr_clears (absv, log2, pow2, frac, NULL);
+  mpfr_clears (absv, log2, exp, pow2, frac, NULL);
 
   return range_check (result, "SET_EXPONENT");
 }
diff --git a/gcc/testsuite/gfortran.dg/set_exponent_1.f90 b/gcc/testsuite/gfortran.dg/set_exponent_1.f90
new file mode 100644
index 00000000000..4c063e8330b
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/set_exponent_1.f90
@@ -0,0 +1,36 @@
+! { dg-do run }
+! PR fortran/109511
+! Check compile-time simplification of SET_EXPONENT against runtime
+
+program exponent
+  implicit none
+  integer :: i
+  i = 0
+  print *, i, set_exponent(1., 0), set_exponent(1., i)
+  if (set_exponent(1., 0) /= set_exponent(1., i)) stop 1
+  i = 1
+  print *, i, set_exponent(1., 1), set_exponent(1., i)
+  if (set_exponent(1., 1) /= set_exponent(1., i)) stop 2
+  i = 2
+  print *, i, set_exponent(-1.75, 2), set_exponent(-1.75, i)
+  if (set_exponent(-1.75, 2) /= set_exponent(-1.75, i)) stop 3
+  print *, i, set_exponent(0.1875, 2), set_exponent(0.1875, i)
+  if (set_exponent(0.1875, 2) /= set_exponent(0.1875, i)) stop 4
+  i = 3
+  print *, i, set_exponent(0.75, 3), set_exponent(0.75, i)
+  if (set_exponent(0.75, 3) /= set_exponent(0.75, i)) stop 5
+  i = 4
+  print *, i, set_exponent(-2.5, 4), set_exponent(-2.5, i)
+  if (set_exponent(-2.5, 4) /= set_exponent(-2.5, i)) stop 6
+  i = -1
+  print *, i, set_exponent(1., -1), set_exponent(1., i)
+  if (set_exponent(1., -1) /= set_exponent(1., i)) stop 7
+  i = -2
+  print *, i, set_exponent(1.125, -2), set_exponent(1.125, i)
+  if (set_exponent(1.125, -2) /= set_exponent(1.125, i)) stop 8
+  print *, i, set_exponent(-0.25, -2), set_exponent(-0.25, i)
+  if (set_exponent(-0.25, -2) /= set_exponent(-0.25, i)) stop 9
+  i = -3
+  print *, i, set_exponent(0.75, -3), set_exponent(0.75, i)
+  if (set_exponent(0.75, -3) /= set_exponent(0.75, i)) stop 10
+end program exponent

commit 86aaa079904315f203ddc8cedd1dcfe748b75acc
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Mon Apr 17 00:18:56 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index ba4f30bf048..27b1d3f07db 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230416
+20230417
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 8b8ee9ab2ad..6714c3a9906 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,13 @@
+2023-04-16  Harald Anlauf  <anlauf@gmx.de>
+
+	Backported from master:
+	2023-04-14  Harald Anlauf  <anlauf@gmx.de>
+
+	PR fortran/109511
+	* simplify.c (gfc_simplify_set_exponent): Fix implementation of
+	compile-time simplification of intrinsic SET_EXPONENT for argument
+	X < 1 and for I < 0.
+
 2023-03-24  Harald Anlauf  <anlauf@gmx.de>
 
 	Backported from master:
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 38fb279f0bc..dfde5a9c5b6 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,11 @@
+2023-04-16  Harald Anlauf  <anlauf@gmx.de>
+
+	Backported from master:
+	2023-04-14  Harald Anlauf  <anlauf@gmx.de>
+
+	PR fortran/109511
+	* gfortran.dg/set_exponent_1.f90: New test.
+
 2023-03-24  Harald Anlauf  <anlauf@gmx.de>
 
 	Backported from master:

commit d88e488ec9321e44291fcaf2a3b14333f64aac01
Author: Kewen Lin <linkw@linux.ibm.com>
Date:   Mon Apr 3 21:47:44 2023 -0500

    rs6000: Fix vector parity support [PR108699]
    
    The failures on the original failed case builtin-bitops-1.c
    and the associated test case pr108699.c here show that the
    current support of parity vector mode is wrong on Power.
    The hardware insns vprtyb[wdq] which operate on the least
    significant bit of each byte per element, they doesn't match
    what RTL opcode parity needs, but the current implementation
    expands it with them wrongly.
    
    This patch is to fix the handling with one more insn vpopcntb.
    
            PR target/108699
    
    gcc/ChangeLog:
    
            * config/rs6000/altivec.md (*p9v_parity<mode>2): Rename to ...
            (rs6000_vprtyb<mode>2): ... this.
            * config/rs6000/rs6000-builtin.def (VPRTYBD): Replace parityv2di2 with
            rs6000_vprtybv2di2.
            (VPRTYBW): Replace parityv4si2 with rs6000_vprtybv4si2.
            (VPRTYBQ): Replace parityv1ti2 with rs6000_vprtybv1ti2.
            * config/rs6000/vector.md (parity<mode>2 with VEC_IP): Expand with
            popcountv16qi2 and the corresponding rs6000_vprtyb<mode>2.
    
    gcc/testsuite/ChangeLog:
    
            * gcc.target/powerpc/p9-vparity.c: Add scan-assembler-not for vpopcntb
            to distinguish parity byte from parity.
            * gcc.target/powerpc/pr108699.c: New test.
    
    (cherry picked from commit cdd2d6643f7fef40e335a7027edfea7276cde608)

diff --git a/gcc/config/rs6000/altivec.md b/gcc/config/rs6000/altivec.md
index 844978544a0..b43b5edf027 100644
--- a/gcc/config/rs6000/altivec.md
+++ b/gcc/config/rs6000/altivec.md
@@ -3916,9 +3916,11 @@
   [(set_attr "type" "vecsimple")])
 
 ;; Vector parity
-(define_insn "*p9v_parity<mode>2"
-  [(set (match_operand:VParity 0 "register_operand" "=v")
-        (parity:VParity (match_operand:VParity 1 "register_operand" "v")))]
+(define_insn "rs6000_vprtyb<mode>2"
+  [(set (match_operand:VEC_IP 0 "register_operand" "=v")
+        (unspec:VEC_IP
+          [(match_operand:VEC_IP 1 "register_operand" "v")]
+          UNSPEC_PARITY))]
   "TARGET_P9_VECTOR"
   "vprtyb<wd> %0,%1"
   [(set_attr "type" "vecsimple")])
diff --git a/gcc/config/rs6000/rs6000-builtin.def b/gcc/config/rs6000/rs6000-builtin.def
index b3ae6fea640..36ba145ad3d 100644
--- a/gcc/config/rs6000/rs6000-builtin.def
+++ b/gcc/config/rs6000/rs6000-builtin.def
@@ -2627,9 +2627,9 @@ BU_P9V_AV_1 (VCTZB,		"vctzb",		CONST,  ctzv16qi2)
 BU_P9V_AV_1 (VCTZH,		"vctzh",		CONST,  ctzv8hi2)
 BU_P9V_AV_1 (VCTZW,		"vctzw",		CONST,  ctzv4si2)
 BU_P9V_AV_1 (VCTZD,		"vctzd",		CONST,  ctzv2di2)
-BU_P9V_AV_1 (VPRTYBD,		"vprtybd",		CONST,  parityv2di2)
-BU_P9V_AV_1 (VPRTYBQ,		"vprtybq",		CONST,  parityv1ti2)
-BU_P9V_AV_1 (VPRTYBW,		"vprtybw",		CONST,  parityv4si2)
+BU_P9V_AV_1 (VPRTYBD,		"vprtybd",		CONST,  rs6000_vprtybv2di2)
+BU_P9V_AV_1 (VPRTYBQ,		"vprtybq",		CONST,  rs6000_vprtybv1ti2)
+BU_P9V_AV_1 (VPRTYBW,		"vprtybw",		CONST,  rs6000_vprtybv4si2)
 
 /* ISA 3.0 vector overloaded 1 argument functions.  */
 BU_P9V_OVERLOAD_1 (VCTZ,	"vctz")
diff --git a/gcc/config/rs6000/vector.md b/gcc/config/rs6000/vector.md
index 62c60956f4d..68fa6552088 100644
--- a/gcc/config/rs6000/vector.md
+++ b/gcc/config/rs6000/vector.md
@@ -1161,7 +1161,16 @@
 (define_expand "parity<mode>2"
   [(set (match_operand:VEC_IP 0 "register_operand")
 	(parity:VEC_IP (match_operand:VEC_IP 1 "register_operand")))]
-  "TARGET_P9_VECTOR")
+  "TARGET_P9_VECTOR"
+{
+  rtx op1 = gen_lowpart (V16QImode, operands[1]);
+  rtx res = gen_reg_rtx (V16QImode);
+  emit_insn (gen_popcountv16qi2 (res, op1));
+  emit_insn (gen_rs6000_vprtyb<mode>2 (operands[0],
+				       gen_lowpart (<MODE>mode, res)));
+
+  DONE;
+})
 
 
 ;; Same size conversions
diff --git a/gcc/testsuite/gcc.target/powerpc/p9-vparity.c b/gcc/testsuite/gcc.target/powerpc/p9-vparity.c
index bd6c83d1b3b..1ebf0fc420e 100644
--- a/gcc/testsuite/gcc.target/powerpc/p9-vparity.c
+++ b/gcc/testsuite/gcc.target/powerpc/p9-vparity.c
@@ -104,3 +104,4 @@ parity_ti_4u (__uint128_t a)
 /* { dg-final { scan-assembler "vprtybd" } } */
 /* { dg-final { scan-assembler "vprtybq" } } */
 /* { dg-final { scan-assembler "vprtybw" } } */
+/* { dg-final { scan-assembler-not "vpopcntb" } } */
diff --git a/gcc/testsuite/gcc.target/powerpc/pr108699.c b/gcc/testsuite/gcc.target/powerpc/pr108699.c
new file mode 100644
index 00000000000..f02bac130cc
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/pr108699.c
@@ -0,0 +1,42 @@
+/* { dg-run } */
+/* { dg-options "-O2 -ftree-vectorize -fno-vect-cost-model" } */
+
+#define N 16
+
+unsigned long long vals[N];
+unsigned int res[N];
+unsigned int expects[N] = {0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+
+unsigned long long inputs[N]
+  = {0x0000000000000000ULL, 0x0000000000000001ULL, 0x8000000000000000ULL,
+     0x0000000000000002ULL, 0x4000000000000000ULL, 0x0000000100000000ULL,
+     0x0000000080000000ULL, 0xa5a5a5a5a5a5a5a5ULL, 0x5a5a5a5a5a5a5a5aULL,
+     0xcafecafe00000000ULL, 0x0000cafecafe0000ULL, 0x00000000cafecafeULL,
+     0x8070600000000000ULL, 0xffffffffffffffffULL};
+
+__attribute__ ((noipa)) void
+init ()
+{
+  for (int i = 0; i < N; i++)
+    vals[i] = inputs[i];
+}
+
+__attribute__ ((noipa)) void
+do_parity ()
+{
+  for (int i = 0; i < N; i++)
+    res[i] = __builtin_parityll (vals[i]);
+}
+
+int
+main (void)
+{
+  init ();
+  do_parity ();
+  for (int i = 0; i < N; i++)
+    if (res[i] != expects[i])
+      __builtin_abort();
+
+  return 0;
+}
+

commit d5e68f4cbab0788fbe618e7aecdf43b79de5b5b7
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Tue Apr 18 00:18:56 2023 +0000

    Daily bump.

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 5645182ec63..08a3c55a179 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,18 @@
+2023-04-17  Kewen Lin  <linkw@linux.ibm.com>
+
+	Backported from master:
+	2023-04-04  Kewen Lin  <linkw@linux.ibm.com>
+
+	PR target/108699
+	* config/rs6000/altivec.md (*p9v_parity<mode>2): Rename to ...
+	(rs6000_vprtyb<mode>2): ... this.
+	* config/rs6000/rs6000-builtin.def (VPRTYBD): Replace parityv2di2 with
+	rs6000_vprtybv2di2.
+	(VPRTYBW): Replace parityv4si2 with rs6000_vprtybv4si2.
+	(VPRTYBQ): Replace parityv1ti2 with rs6000_vprtybv1ti2.
+	* config/rs6000/vector.md (parity<mode>2 with VEC_IP): Expand with
+	popcountv16qi2 and the corresponding rs6000_vprtyb<mode>2.
+
 2023-02-24  Sebastian Huber  <sebastian.huber@embedded-brains.de>
 
 	Backported from master:
diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 27b1d3f07db..378aed56acf 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230417
+20230418
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index dfde5a9c5b6..9ffc5078d3f 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,13 @@
+2023-04-17  Kewen Lin  <linkw@linux.ibm.com>
+
+	Backported from master:
+	2023-04-04  Kewen Lin  <linkw@linux.ibm.com>
+
+	PR target/108699
+	* gcc.target/powerpc/p9-vparity.c: Add scan-assembler-not for vpopcntb
+	to distinguish parity byte from parity.
+	* gcc.target/powerpc/pr108699.c: New test.
+
 2023-04-16  Harald Anlauf  <anlauf@gmx.de>
 
 	Backported from master:

commit 28140a377159b92dad5352cc72df7577157d1781
Author: Philipp Tomsich <philipp.tomsich@vrull.eu>
Date:   Thu May 20 21:57:48 2021 +0200

    aarch64: enable Ampere-1 CPU
    
    This adds support and a basic tuning model for the Ampere Computing
    "Ampere-1" CPU.
    
    The Ampere-1 implements the ARMv8.6 architecture in A64 mode and is
    modelled as a 4-wide issue (as with all modern micro-architectures,
    the chosen issue rate is a compromise between the maximum dispatch
    rate and the maximum rate of uops issued to the scheduler).
    
    This adds the -mcpu=ampere1 command-line option and the relevant cost
    information/tuning tables for the Ampere-1.
    
    gcc/ChangeLog:
    
            * config/aarch64/aarch64-cores.def (AARCH64_CORE): New Ampere-1
            core.
            * config/aarch64/aarch64-tune.md: Regenerate.
            * config/aarch64/aarch64-cost-tables.h: Add extra costs for
            Ampere-1.
            * config/aarch64/aarch64.c: Add tuning structures for Ampere-1.
            * doc/invoke.texi: Add documentation for Ampere-1 core.
    
    (cherry picked from commit 67b0d47e20e655c0dd53a76ea88aab60fafb2059)

diff --git a/gcc/config/aarch64/aarch64-cores.def b/gcc/config/aarch64/aarch64-cores.def
index 197f88d5be2..59825de1ef0 100644
--- a/gcc/config/aarch64/aarch64-cores.def
+++ b/gcc/config/aarch64/aarch64-cores.def
@@ -68,7 +68,8 @@ AARCH64_CORE("octeontx83",    octeontxt83,   thunderx,  8A,  AARCH64_FL_FOR_ARCH
 AARCH64_CORE("thunderxt81",   thunderxt81,   thunderx,  8A,  AARCH64_FL_FOR_ARCH8 | AARCH64_FL_CRC | AARCH64_FL_CRYPTO, thunderx,  0x43, 0x0a2, -1)
 AARCH64_CORE("thunderxt83",   thunderxt83,   thunderx,  8A,  AARCH64_FL_FOR_ARCH8 | AARCH64_FL_CRC | AARCH64_FL_CRYPTO, thunderx,  0x43, 0x0a3, -1)
 
-/* Ampere Computing cores. */
+/* Ampere Computing ('\xC0') cores. */
+AARCH64_CORE("ampere1", ampere1, cortexa57, 8_6A, AARCH64_FL_FOR_ARCH8_6, ampere1, 0xC0, 0xac3, -1)
 /* Do not swap around "emag" and "xgene1",
    this order is required to handle variant correctly. */
 AARCH64_CORE("emag",        emag,      xgene1,    8A,  AARCH64_FL_FOR_ARCH8 | AARCH64_FL_CRC | AARCH64_FL_CRYPTO, emag, 0x50, 0x000, 3)
diff --git a/gcc/config/aarch64/aarch64-cost-tables.h b/gcc/config/aarch64/aarch64-cost-tables.h
index c6805717f6e..9f9627b864e 100644
--- a/gcc/config/aarch64/aarch64-cost-tables.h
+++ b/gcc/config/aarch64/aarch64-cost-tables.h
@@ -644,4 +644,107 @@ const struct cpu_cost_table a64fx_extra_costs =
   }
 };
 
+const struct cpu_cost_table ampere1_extra_costs =
+{
+  /* ALU */
+  {
+    0,                 /* arith.  */
+    0,                 /* logical.  */
+    0,                 /* shift.  */
+    COSTS_N_INSNS (1), /* shift_reg.  */
+    0,                 /* arith_shift.  */
+    COSTS_N_INSNS (1), /* arith_shift_reg.  */
+    0,                 /* log_shift.  */
+    COSTS_N_INSNS (1), /* log_shift_reg.  */
+    0,                 /* extend.  */
+    COSTS_N_INSNS (1), /* extend_arith.  */
+    0,                 /* bfi.  */
+    0,                 /* bfx.  */
+    0,                 /* clz.  */
+    0,                 /* rev.  */
+    0,                 /* non_exec.  */
+    true               /* non_exec_costs_exec.  */
+  },
+  {
+    /* MULT SImode */
+    {
+      COSTS_N_INSNS (3),       /* simple.  */
+      COSTS_N_INSNS (3),       /* flag_setting.  */
+      COSTS_N_INSNS (3),       /* extend.  */
+      COSTS_N_INSNS (4),       /* add.  */
+      COSTS_N_INSNS (4),       /* extend_add.  */
+      COSTS_N_INSNS (18)       /* idiv.  */
+    },
+    /* MULT DImode */
+    {
+      COSTS_N_INSNS (3),       /* simple.  */
+      0,                       /* flag_setting (N/A).  */
+      COSTS_N_INSNS (3),       /* extend.  */
+      COSTS_N_INSNS (4),       /* add.  */
+      COSTS_N_INSNS (4),       /* extend_add.  */
+      COSTS_N_INSNS (34)       /* idiv.  */
+    }
+  },
+  /* LD/ST */
+  {
+    COSTS_N_INSNS (4),         /* load.  */
+    COSTS_N_INSNS (4),         /* load_sign_extend.  */
+    0,                         /* ldrd (n/a).  */
+    0,                         /* ldm_1st.  */
+    0,                         /* ldm_regs_per_insn_1st.  */
+    0,                         /* ldm_regs_per_insn_subsequent.  */
+    COSTS_N_INSNS (5),         /* loadf.  */
+    COSTS_N_INSNS (5),         /* loadd.  */
+    COSTS_N_INSNS (5),         /* load_unaligned.  */
+    0,                         /* store.  */
+    0,                         /* strd.  */
+    0,                         /* stm_1st.  */
+    0,                         /* stm_regs_per_insn_1st.  */
+    0,                         /* stm_regs_per_insn_subsequent.  */
+    COSTS_N_INSNS (2),         /* storef.  */
+    COSTS_N_INSNS (2),         /* stored.  */
+    COSTS_N_INSNS (2),         /* store_unaligned.  */
+    COSTS_N_INSNS (3),         /* loadv.  */
+    COSTS_N_INSNS (3)          /* storev.  */
+  },
+  {
+    /* FP SFmode */
+    {
+      COSTS_N_INSNS (25),      /* div.  */
+      COSTS_N_INSNS (4),       /* mult.  */
+      COSTS_N_INSNS (4),       /* mult_addsub.  */
+      COSTS_N_INSNS (4),       /* fma.  */
+      COSTS_N_INSNS (4),       /* addsub.  */
+      COSTS_N_INSNS (2),       /* fpconst.  */
+      COSTS_N_INSNS (4),       /* neg.  */
+      COSTS_N_INSNS (4),       /* compare.  */
+      COSTS_N_INSNS (4),       /* widen.  */
+      COSTS_N_INSNS (4),       /* narrow.  */
+      COSTS_N_INSNS (4),       /* toint.  */
+      COSTS_N_INSNS (4),       /* fromint.  */
+      COSTS_N_INSNS (4)        /* roundint.  */
+    },
+    /* FP DFmode */
+    {
+      COSTS_N_INSNS (34),      /* div.  */
+      COSTS_N_INSNS (5),       /* mult.  */
+      COSTS_N_INSNS (5),       /* mult_addsub.  */
+      COSTS_N_INSNS (5),       /* fma.  */
+      COSTS_N_INSNS (5),       /* addsub.  */
+      COSTS_N_INSNS (2),       /* fpconst.  */
+      COSTS_N_INSNS (5),       /* neg.  */
+      COSTS_N_INSNS (5),       /* compare.  */
+      COSTS_N_INSNS (5),       /* widen.  */
+      COSTS_N_INSNS (5),       /* narrow.  */
+      COSTS_N_INSNS (6),       /* toint.  */
+      COSTS_N_INSNS (6),       /* fromint.  */
+      COSTS_N_INSNS (5)        /* roundint.  */
+    }
+  },
+  /* Vector */
+  {
+    COSTS_N_INSNS (3),  /* alu.  */
+  }
+};
+
 #endif
diff --git a/gcc/config/aarch64/aarch64-tune.md b/gcc/config/aarch64/aarch64-tune.md
index d116b0e5e97..51486b7cd25 100644
--- a/gcc/config/aarch64/aarch64-tune.md
+++ b/gcc/config/aarch64/aarch64-tune.md
@@ -1,5 +1,5 @@
 ;; -*- buffer-read-only: t -*-
 ;; Generated automatically by gentune.sh from aarch64-cores.def
 (define_attr "tune"
-	"cortexa34,cortexa35,cortexa53,cortexa57,cortexa72,cortexa73,thunderx,thunderxt88p1,thunderxt88,octeontx,octeontxt81,octeontxt83,thunderxt81,thunderxt83,emag,xgene1,falkor,qdf24xx,exynosm1,phecda,thunderx2t99p1,vulcan,thunderx2t99,cortexa55,cortexa75,cortexa76,cortexa76ae,cortexa77,cortexa65,cortexa65ae,ares,neoversen1,neoversee1,octeontx2,octeontx2t98,octeontx2t96,octeontx2t93,octeontx2f95,octeontx2f95n,octeontx2f95mm,a64fx,tsv110,thunderx3t110,zeus,neoversev1,neoverse512tvb,saphira,neoversen2,neoversev2,cortexa57cortexa53,cortexa72cortexa53,cortexa73cortexa35,cortexa73cortexa53,cortexa75cortexa55,cortexa76cortexa55"
+	"cortexa34,cortexa35,cortexa53,cortexa57,cortexa72,cortexa73,thunderx,thunderxt88p1,thunderxt88,octeontx,octeontxt81,octeontxt83,thunderxt81,thunderxt83,ampere1,emag,xgene1,falkor,qdf24xx,exynosm1,phecda,thunderx2t99p1,vulcan,thunderx2t99,cortexa55,cortexa75,cortexa76,cortexa76ae,cortexa77,cortexa65,cortexa65ae,ares,neoversen1,neoversee1,octeontx2,octeontx2t98,octeontx2t96,octeontx2t93,octeontx2f95,octeontx2f95n,octeontx2f95mm,a64fx,tsv110,thunderx3t110,zeus,neoversev1,neoverse512tvb,saphira,neoversen2,neoversev2,cortexa57cortexa53,cortexa72cortexa53,cortexa73cortexa35,cortexa73cortexa53,cortexa75cortexa55,cortexa76cortexa55"
 	(const (symbol_ref "((enum attr_tune) aarch64_tune)")))
diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
index 92c2f0dae6f..f99644be618 100644
--- a/gcc/config/aarch64/aarch64.c
+++ b/gcc/config/aarch64/aarch64.c
@@ -781,6 +781,25 @@ static const struct cpu_vector_cost a64fx_vector_cost =
   1 /* cond_not_taken_branch_cost  */
 };
 
+/* Ampere-1 costs for vector insn classes.  */
+static const struct cpu_vector_cost ampere1_vector_cost =
+{
+  1, /* scalar_int_stmt_cost  */
+  1, /* scalar_fp_stmt_cost  */
+  4, /* scalar_load_cost  */
+  1, /* scalar_store_cost  */
+  3, /* int_stmt_cost  */
+  3, /* fp_stmt_cost  */
+  2, /* permute_cost  */
+  6, /* vec_to_scalar_cost  */
+  7, /* scalar_to_vec_cost  */
+  5, /* align_load_cost  */
+  5, /* unalign_load_cost  */
+  2, /* unalign_store_cost  */
+  2, /* store_cost  */
+  1, /* cond_taken_branch_cost  */
+  1 /* cond_not_taken_branch_cost  */
+};
 
 /* Generic costs for branch instructions.  */
 static const struct cpu_branch_cost generic_branch_cost =
@@ -924,6 +943,17 @@ static const cpu_prefetch_tune a64fx_prefetch_tune =
   -1			/* default_opt_level  */
 };
 
+static const cpu_prefetch_tune ampere1_prefetch_tune =
+{
+  0,			/* num_slots  */
+  64,			/* l1_cache_size  */
+  64,			/* l1_cache_line_size  */
+  2048,			/* l2_cache_size  */
+  true,			/* prefetch_dynamic_strides */
+  -1,			/* minimum_stride */
+  -1			/* default_opt_level  */
+};
+
 static const struct tune_params generic_tunings =
 {
   &cortexa57_extra_costs,
@@ -1384,6 +1414,36 @@ static const struct tune_params neoversen1_tunings =
   &generic_prefetch_tune
 };
 
+static const struct tune_params ampere1_tunings =
+{
+  &ampere1_extra_costs,
+  &generic_addrcost_table,
+  &generic_regmove_cost,
+  &ampere1_vector_cost,
+  &generic_branch_cost,
+  &generic_approx_modes,
+  SVE_NOT_IMPLEMENTED, /* sve_width  */
+  4, /* memmov_cost  */
+  4, /* issue_rate  */
+  (AARCH64_FUSE_ADRP_ADD | AARCH64_FUSE_AES_AESMC |
+   AARCH64_FUSE_MOV_MOVK | AARCH64_FUSE_MOVK_MOVK |
+   AARCH64_FUSE_ALU_BRANCH /* adds, ands, bics, ccmp, ccmn */ |
+   AARCH64_FUSE_CMP_BRANCH),
+  /* fusible_ops  */
+  "32",		/* function_align.  */
+  "4",		/* jump_align.  */
+  "32:16",	/* loop_align.  */
+  2,	/* int_reassoc_width.  */
+  4,	/* fp_reassoc_width.  */
+  2,	/* vec_reassoc_width.  */
+  2,	/* min_div_recip_mul_sf.  */
+  2,	/* min_div_recip_mul_df.  */
+  0,	/* max_case_values.  */
+  tune_params::AUTOPREFETCHER_WEAK,	/* autoprefetcher_model.  */
+  (AARCH64_EXTRA_TUNE_NONE),		/* tune_flags.  */
+  &ampere1_prefetch_tune
+};
+
 static const struct tune_params neoversev1_tunings =
 {
   &cortexa57_extra_costs,
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 4f399d3eeac..48d458aadfb 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -17011,8 +17011,8 @@ performance of the code.  Permissible values for this option are:
 @samp{thunderxt83}, @samp{thunderx2t99}, @samp{thunderx3t110}, @samp{zeus},
 @samp{cortex-a57.cortex-a53}, @samp{cortex-a72.cortex-a53},
 @samp{cortex-a73.cortex-a35}, @samp{cortex-a73.cortex-a53},
-@samp{cortex-a75.cortex-a55}, @samp{cortex-a76.cortex-a55}
-@samp{native}.
+@samp{cortex-a75.cortex-a55}, @samp{cortex-a76.cortex-a55},
+@samp{ampere1}, @samp{native}.
 
 The values @samp{cortex-a57.cortex-a53}, @samp{cortex-a72.cortex-a53},
 @samp{cortex-a73.cortex-a35}, @samp{cortex-a73.cortex-a53},

commit 786d5f34c209ae76d49f938492f8d0220fb18c5d
Author: Philipp Tomsich <philipp.tomsich@vrull.eu>
Date:   Mon Oct 3 21:59:50 2022 +0200

    aarch64: fix off-by-one in reading cpuinfo
    
    Fixes: 341573406b39
    
    Don't subtract one from the result of strnlen() when trying to point
    to the first character after the current string.  This issue would
    cause individual characters (where the 128 byte buffers are stitched
    together) to be lost.
    
    gcc/ChangeLog:
    
            * config/aarch64/driver-aarch64.c (readline): Fix off-by-one.
    
    gcc/testsuite/ChangeLog:
    
            * gcc.target/aarch64/cpunative/info_18: New test.
            * gcc.target/aarch64/cpunative/native_cpu_18.c: New test.
    
    (cherry picked from commit b1cfbccc41de6aec950c0f662e7e85ab34bfff8a)

diff --git a/gcc/config/aarch64/driver-aarch64.c b/gcc/config/aarch64/driver-aarch64.c
index d99834c9989..838d5648fcc 100644
--- a/gcc/config/aarch64/driver-aarch64.c
+++ b/gcc/config/aarch64/driver-aarch64.c
@@ -202,9 +202,9 @@ readline (FILE *f)
 	return std::string ();
       /* If we're not at the end of the line then override the
 	 \0 added by fgets.  */
-      last = strnlen (buf, size) - 1;
+      last = strnlen (buf, size);
     }
-  while (!feof (f) && buf[last] != '\n');
+  while (!feof (f) && last > 0 && buf[last - 1] != '\n');
 
   std::string result (buf);
   free (buf);
diff --git a/gcc/testsuite/gcc.target/aarch64/cpunative/info_18 b/gcc/testsuite/gcc.target/aarch64/cpunative/info_18
new file mode 100644
index 00000000000..25061a4abe8
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/cpunative/info_18
@@ -0,0 +1,8 @@
+processor	: 0
+BogoMIPS	: 2000.00
+Features	: fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm jscvt fcma lrcpc dcpop sha3 asimddp sha512 asimdfhm dit uscat ilrcpc flagm ssbs sb dcpodp flagm2 frint i8mm bf16 rng ecv
+CPU implementer	: 0xc0
+CPU architecture: 8
+CPU variant	: 0x0
+CPU part	: 0xac3
+CPU revision	: 0
diff --git a/gcc/testsuite/gcc.target/aarch64/cpunative/native_cpu_18.c b/gcc/testsuite/gcc.target/aarch64/cpunative/native_cpu_18.c
new file mode 100644
index 00000000000..b5f0a3005f5
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/cpunative/native_cpu_18.c
@@ -0,0 +1,15 @@
+/* { dg-do compile { target { { aarch64*-*-linux*} && native } } } */
+/* { dg-set-compiler-env-var GCC_CPUINFO "$srcdir/gcc.target/aarch64/cpunative/info_18" } */
+/* { dg-additional-options "-mcpu=native" } */
+
+int main()
+{
+  return 0;
+}
+
+/* { dg-final { scan-assembler {\.arch armv8.6-a\+crc\+fp16\+aes\+sha3\+rng} } } */
+
+/* Test one where the boundary of buffer size would overwrite the last
+   character read when stitching the fgets-calls together.  With the
+   test data provided, this would truncate the 'sha512' into 'ha512'
+   (dropping the 'sha3' feature). */

commit 7ba40e6c2e19bee6a7ac4fe1f038b4de43148df3
Author: Philipp Tomsich <philipp.tomsich@vrull.eu>
Date:   Mon Aug 8 00:30:52 2022 +0200

    aarch64: update Ampere-1 core definition
    
    This brings the extensions detected by -mcpu=native on Ampere-1 systems
    in sync with the defaults generated for -mcpu=ampere1.
    
    Note that some early kernel versions on Ampere1 may misreport the
    presence of PAUTH and PREDRES (i.e., -mcpu=native will add 'nopauth'
    and 'nopredres').
    
    gcc/ChangeLog:
    
            * config/aarch64/aarch64-cores.def (AARCH64_CORE): Update
            Ampere-1 core entry.
    
    (cherry picked from commit db2f5d661239737157cf131de7d4df1c17d8d88d)

diff --git a/gcc/config/aarch64/aarch64-cores.def b/gcc/config/aarch64/aarch64-cores.def
index 59825de1ef0..f00be84a226 100644
--- a/gcc/config/aarch64/aarch64-cores.def
+++ b/gcc/config/aarch64/aarch64-cores.def
@@ -69,7 +69,7 @@ AARCH64_CORE("thunderxt81",   thunderxt81,   thunderx,  8A,  AARCH64_FL_FOR_ARCH
 AARCH64_CORE("thunderxt83",   thunderxt83,   thunderx,  8A,  AARCH64_FL_FOR_ARCH8 | AARCH64_FL_CRC | AARCH64_FL_CRYPTO, thunderx,  0x43, 0x0a3, -1)
 
 /* Ampere Computing ('\xC0') cores. */
-AARCH64_CORE("ampere1", ampere1, cortexa57, 8_6A, AARCH64_FL_FOR_ARCH8_6, ampere1, 0xC0, 0xac3, -1)
+AARCH64_CORE("ampere1", ampere1, cortexa57, 8_6A, AARCH64_FL_FOR_ARCH8_6 | AARCH64_FL_CRYPTO | AARCH64_FL_F16 | AARCH64_FL_RNG | AARCH64_FL_SHA3, ampere1, 0xC0, 0xac3, -1)
 /* Do not swap around "emag" and "xgene1",
    this order is required to handle variant correctly. */
 AARCH64_CORE("emag",        emag,      xgene1,    8A,  AARCH64_FL_FOR_ARCH8 | AARCH64_FL_CRC | AARCH64_FL_CRYPTO, emag, 0x50, 0x000, 3)

commit 09ca9d62858f7ee86d8170810e729c86fd1e15d0
Author: Philipp Tomsich <philipp.tomsich@vrull.eu>
Date:   Mon Nov 7 14:22:21 2022 +0100

    aarch64: Add support for Ampere-1A (-mcpu=ampere1a) CPU
    
    This patch adds support for Ampere-1A CPU:
     - recognize the name of the core and provide detection for -mcpu=native,
     - updated extra_costs,
     - adds a new fusion pair for (A+B+1 and A-B-1).
    
    Ampere-1A and Ampere-1 have more timing difference than the extra
    costs indicate, but these don't propagate through to the headline
    items in our extra costs (e.g. the change in latency for scalar sqrt
    doesn't have a corresponding table entry).
    
    gcc/ChangeLog:
    
            * config/aarch64/aarch64-cores.def (AARCH64_CORE): Add ampere1a.
            * config/aarch64/aarch64-cost-tables.h: Add ampere1a_extra_costs.
            * config/aarch64/aarch64-fusion-pairs.def (AARCH64_FUSION_PAIR):
            Define a new fusion pair for A+B+1/A-B-1 (i.e., add/subtract two
            registers and then +1/-1).
            * config/aarch64/aarch64-tune.md: Regenerate.
            * config/aarch64/aarch64.c (aarch_macro_fusion_pair_p): Implement
            idiom-matcher for the new fusion pair.
            * doc/invoke.texi: Add ampere1a.
    
    (cherry picked from commit 590a06afbf0e96813b5879742f38f3665512c854)

diff --git a/gcc/config/aarch64/aarch64-cores.def b/gcc/config/aarch64/aarch64-cores.def
index f00be84a226..d58076b33f7 100644
--- a/gcc/config/aarch64/aarch64-cores.def
+++ b/gcc/config/aarch64/aarch64-cores.def
@@ -70,6 +70,7 @@ AARCH64_CORE("thunderxt83",   thunderxt83,   thunderx,  8A,  AARCH64_FL_FOR_ARCH
 
 /* Ampere Computing ('\xC0') cores. */
 AARCH64_CORE("ampere1", ampere1, cortexa57, 8_6A, AARCH64_FL_FOR_ARCH8_6 | AARCH64_FL_CRYPTO | AARCH64_FL_F16 | AARCH64_FL_RNG | AARCH64_FL_SHA3, ampere1, 0xC0, 0xac3, -1)
+AARCH64_CORE("ampere1a", ampere1a, cortexa57, 8_6A, AARCH64_FL_FOR_ARCH8_6 | AARCH64_FL_CRYPTO | AARCH64_FL_F16 | AARCH64_FL_RNG | AARCH64_FL_SHA3 | AARCH64_FL_MEMTAG, ampere1a, 0xC0, 0xac4, -1)
 /* Do not swap around "emag" and "xgene1",
    this order is required to handle variant correctly. */
 AARCH64_CORE("emag",        emag,      xgene1,    8A,  AARCH64_FL_FOR_ARCH8 | AARCH64_FL_CRC | AARCH64_FL_CRYPTO, emag, 0x50, 0x000, 3)
diff --git a/gcc/config/aarch64/aarch64-cost-tables.h b/gcc/config/aarch64/aarch64-cost-tables.h
index 9f9627b864e..042d45821c2 100644
--- a/gcc/config/aarch64/aarch64-cost-tables.h
+++ b/gcc/config/aarch64/aarch64-cost-tables.h
@@ -747,4 +747,107 @@ const struct cpu_cost_table ampere1_extra_costs =
   }
 };
 
+const struct cpu_cost_table ampere1a_extra_costs =
+{
+  /* ALU */
+  {
+    0,                 /* arith.  */
+    0,                 /* logical.  */
+    0,                 /* shift.  */
+    COSTS_N_INSNS (1), /* shift_reg.  */
+    0,                 /* arith_shift.  */
+    COSTS_N_INSNS (1), /* arith_shift_reg.  */
+    0,                 /* log_shift.  */
+    COSTS_N_INSNS (1), /* log_shift_reg.  */
+    0,                 /* extend.  */
+    COSTS_N_INSNS (1), /* extend_arith.  */
+    0,                 /* bfi.  */
+    0,                 /* bfx.  */
+    0,                 /* clz.  */
+    0,                 /* rev.  */
+    0,                 /* non_exec.  */
+    true               /* non_exec_costs_exec.  */
+  },
+  {
+    /* MULT SImode */
+    {
+      COSTS_N_INSNS (3),       /* simple.  */
+      COSTS_N_INSNS (3),       /* flag_setting.  */
+      COSTS_N_INSNS (3),       /* extend.  */
+      COSTS_N_INSNS (4),       /* add.  */
+      COSTS_N_INSNS (4),       /* extend_add.  */
+      COSTS_N_INSNS (19)       /* idiv.  */
+    },
+    /* MULT DImode */
+    {
+      COSTS_N_INSNS (3),       /* simple.  */
+      0,                       /* flag_setting (N/A).  */
+      COSTS_N_INSNS (3),       /* extend.  */
+      COSTS_N_INSNS (4),       /* add.  */
+      COSTS_N_INSNS (4),       /* extend_add.  */
+      COSTS_N_INSNS (35)       /* idiv.  */
+    }
+  },
+  /* LD/ST */
+  {
+    COSTS_N_INSNS (4),         /* load.  */
+    COSTS_N_INSNS (4),         /* load_sign_extend.  */
+    0,                         /* ldrd (n/a).  */
+    0,                         /* ldm_1st.  */
+    0,                         /* ldm_regs_per_insn_1st.  */
+    0,                         /* ldm_regs_per_insn_subsequent.  */
+    COSTS_N_INSNS (5),         /* loadf.  */
+    COSTS_N_INSNS (5),         /* loadd.  */
+    COSTS_N_INSNS (5),         /* load_unaligned.  */
+    0,                         /* store.  */
+    0,                         /* strd.  */
+    0,                         /* stm_1st.  */
+    0,                         /* stm_regs_per_insn_1st.  */
+    0,                         /* stm_regs_per_insn_subsequent.  */
+    COSTS_N_INSNS (2),         /* storef.  */
+    COSTS_N_INSNS (2),         /* stored.  */
+    COSTS_N_INSNS (2),         /* store_unaligned.  */
+    COSTS_N_INSNS (3),         /* loadv.  */
+    COSTS_N_INSNS (3)          /* storev.  */
+  },
+  {
+    /* FP SFmode */
+    {
+      COSTS_N_INSNS (25),      /* div.  */
+      COSTS_N_INSNS (4),       /* mult.  */
+      COSTS_N_INSNS (4),       /* mult_addsub.  */
+      COSTS_N_INSNS (4),       /* fma.  */
+      COSTS_N_INSNS (4),       /* addsub.  */
+      COSTS_N_INSNS (2),       /* fpconst.  */
+      COSTS_N_INSNS (4),       /* neg.  */
+      COSTS_N_INSNS (4),       /* compare.  */
+      COSTS_N_INSNS (4),       /* widen.  */
+      COSTS_N_INSNS (4),       /* narrow.  */
+      COSTS_N_INSNS (4),       /* toint.  */
+      COSTS_N_INSNS (4),       /* fromint.  */
+      COSTS_N_INSNS (4)        /* roundint.  */
+    },
+    /* FP DFmode */
+    {
+      COSTS_N_INSNS (34),      /* div.  */
+      COSTS_N_INSNS (5),       /* mult.  */
+      COSTS_N_INSNS (5),       /* mult_addsub.  */
+      COSTS_N_INSNS (5),       /* fma.  */
+      COSTS_N_INSNS (5),       /* addsub.  */
+      COSTS_N_INSNS (2),       /* fpconst.  */
+      COSTS_N_INSNS (5),       /* neg.  */
+      COSTS_N_INSNS (5),       /* compare.  */
+      COSTS_N_INSNS (5),       /* widen.  */
+      COSTS_N_INSNS (5),       /* narrow.  */
+      COSTS_N_INSNS (6),       /* toint.  */
+      COSTS_N_INSNS (6),       /* fromint.  */
+      COSTS_N_INSNS (5)        /* roundint.  */
+    }
+  },
+  /* Vector */
+  {
+    COSTS_N_INSNS (3),  /* alu.  */
+  }
+};
+
 #endif
diff --git a/gcc/config/aarch64/aarch64-fusion-pairs.def b/gcc/config/aarch64/aarch64-fusion-pairs.def
index 34d3a5765aa..39ca57d56cf 100644
--- a/gcc/config/aarch64/aarch64-fusion-pairs.def
+++ b/gcc/config/aarch64/aarch64-fusion-pairs.def
@@ -36,5 +36,6 @@ AARCH64_FUSION_PAIR ("cmp+branch", CMP_BRANCH)
 AARCH64_FUSION_PAIR ("aes+aesmc", AES_AESMC)
 AARCH64_FUSION_PAIR ("alu+branch", ALU_BRANCH)
 AARCH64_FUSION_PAIR ("alu+cbz", ALU_CBZ)
+AARCH64_FUSION_PAIR ("addsub_2reg_const1", ADDSUB_2REG_CONST1)
 
 #undef AARCH64_FUSION_PAIR
diff --git a/gcc/config/aarch64/aarch64-tune.md b/gcc/config/aarch64/aarch64-tune.md
index 51486b7cd25..ffe2ee857fa 100644
--- a/gcc/config/aarch64/aarch64-tune.md
+++ b/gcc/config/aarch64/aarch64-tune.md
@@ -1,5 +1,5 @@
 ;; -*- buffer-read-only: t -*-
 ;; Generated automatically by gentune.sh from aarch64-cores.def
 (define_attr "tune"
-	"cortexa34,cortexa35,cortexa53,cortexa57,cortexa72,cortexa73,thunderx,thunderxt88p1,thunderxt88,octeontx,octeontxt81,octeontxt83,thunderxt81,thunderxt83,ampere1,emag,xgene1,falkor,qdf24xx,exynosm1,phecda,thunderx2t99p1,vulcan,thunderx2t99,cortexa55,cortexa75,cortexa76,cortexa76ae,cortexa77,cortexa65,cortexa65ae,ares,neoversen1,neoversee1,octeontx2,octeontx2t98,octeontx2t96,octeontx2t93,octeontx2f95,octeontx2f95n,octeontx2f95mm,a64fx,tsv110,thunderx3t110,zeus,neoversev1,neoverse512tvb,saphira,neoversen2,neoversev2,cortexa57cortexa53,cortexa72cortexa53,cortexa73cortexa35,cortexa73cortexa53,cortexa75cortexa55,cortexa76cortexa55"
+	"cortexa34,cortexa35,cortexa53,cortexa57,cortexa72,cortexa73,thunderx,thunderxt88p1,thunderxt88,octeontx,octeontxt81,octeontxt83,thunderxt81,thunderxt83,ampere1,ampere1a,emag,xgene1,falkor,qdf24xx,exynosm1,phecda,thunderx2t99p1,vulcan,thunderx2t99,cortexa55,cortexa75,cortexa76,cortexa76ae,cortexa77,cortexa65,cortexa65ae,ares,neoversen1,neoversee1,octeontx2,octeontx2t98,octeontx2t96,octeontx2t93,octeontx2f95,octeontx2f95n,octeontx2f95mm,a64fx,tsv110,thunderx3t110,zeus,neoversev1,neoverse512tvb,saphira,neoversen2,neoversev2,cortexa57cortexa53,cortexa72cortexa53,cortexa73cortexa35,cortexa73cortexa53,cortexa75cortexa55,cortexa76cortexa55"
 	(const (symbol_ref "((enum attr_tune) aarch64_tune)")))
diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
index f99644be618..e491b9d0d38 100644
--- a/gcc/config/aarch64/aarch64.c
+++ b/gcc/config/aarch64/aarch64.c
@@ -1444,6 +1444,37 @@ static const struct tune_params ampere1_tunings =
   &ampere1_prefetch_tune
 };
 
+static const struct tune_params ampere1a_tunings =
+{
+  &ampere1a_extra_costs,
+  &generic_addrcost_table,
+  &generic_regmove_cost,
+  &ampere1_vector_cost,
+  &generic_branch_cost,
+  &generic_approx_modes,
+  SVE_NOT_IMPLEMENTED, /* sve_width  */
+  4, /* memmov_cost  */
+  4, /* issue_rate  */
+  (AARCH64_FUSE_ADRP_ADD | AARCH64_FUSE_AES_AESMC |
+   AARCH64_FUSE_MOV_MOVK | AARCH64_FUSE_MOVK_MOVK |
+   AARCH64_FUSE_ALU_BRANCH /* adds, ands, bics, ccmp, ccmn */ |
+   AARCH64_FUSE_CMP_BRANCH | AARCH64_FUSE_ALU_CBZ |
+   AARCH64_FUSE_ADDSUB_2REG_CONST1),
+  /* fusible_ops  */
+  "32",		/* function_align.  */
+  "4",		/* jump_align.  */
+  "32:16",	/* loop_align.  */
+  2,	/* int_reassoc_width.  */
+  4,	/* fp_reassoc_width.  */
+  2,	/* vec_reassoc_width.  */
+  2,	/* min_div_recip_mul_sf.  */
+  2,	/* min_div_recip_mul_df.  */
+  0,	/* max_case_values.  */
+  tune_params::AUTOPREFETCHER_WEAK,	/* autoprefetcher_model.  */
+  (AARCH64_EXTRA_TUNE_NONE),		/* tune_flags.  */
+  &ampere1_prefetch_tune
+};
+
 static const struct tune_params neoversev1_tunings =
 {
   &cortexa57_extra_costs,
@@ -22101,6 +22132,33 @@ aarch_macro_fusion_pair_p (rtx_insn *prev, rtx_insn *curr)
 	}
     }
 
+  /* Fuse A+B+1 and A-B-1 */
+  if (simple_sets_p
+      && aarch64_fusion_enabled_p (AARCH64_FUSE_ADDSUB_2REG_CONST1))
+    {
+      /* We're trying to match:
+	  prev == (set (r0) (plus (r0) (r1)))
+	  curr == (set (r0) (plus (r0) (const_int 1)))
+	or:
+	  prev == (set (r0) (minus (r0) (r1)))
+	  curr == (set (r0) (plus (r0) (const_int -1))) */
+
+      rtx prev_src = SET_SRC (prev_set);
+      rtx curr_src = SET_SRC (curr_set);
+
+      int polarity = 1;
+      if (GET_CODE (prev_src) == MINUS)
+	polarity = -1;
+
+      if (GET_CODE (curr_src) == PLUS
+	  && (GET_CODE (prev_src) == PLUS || GET_CODE (prev_src) == MINUS)
+	  && CONST_INT_P (XEXP (curr_src, 1))
+	  && INTVAL (XEXP (curr_src, 1)) == polarity
+	  && REG_P (XEXP (curr_src, 0))
+	  && REGNO (SET_DEST (prev_set)) == REGNO (XEXP (curr_src, 0)))
+	return true;
+    }
+
   return false;
 }
 
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 48d458aadfb..39ed6fcfb94 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -17012,7 +17012,7 @@ performance of the code.  Permissible values for this option are:
 @samp{cortex-a57.cortex-a53}, @samp{cortex-a72.cortex-a53},
 @samp{cortex-a73.cortex-a35}, @samp{cortex-a73.cortex-a53},
 @samp{cortex-a75.cortex-a55}, @samp{cortex-a76.cortex-a55},
-@samp{ampere1}, @samp{native}.
+@samp{ampere1}, @samp{ampere1a}, @samp{native}.
 
 The values @samp{cortex-a57.cortex-a53}, @samp{cortex-a72.cortex-a53},
 @samp{cortex-a73.cortex-a35}, @samp{cortex-a73.cortex-a53},

commit 9414c71c1e01664d2dfacb997c863d278298d565
Author: Philipp Tomsich <philipp.tomsich@vrull.eu>
Date:   Tue Apr 18 01:26:32 2023 +0200

    aarch64: update ampere1 vectorization cost
    
    The original submission of AmpereOne (-mcpu=ampere1) costs occurred
    prior to exhaustive testing of vectorizable workloads against
    hardware.
    
    Adjust the vector costs to achieve the best results and more closely
    match the underlying hardware.
    
    gcc/ChangeLog:
    
            * config/aarch64/aarch64.c: Update vector costs for ampere1.
    
    Co-Authored-By: Jiangning Liu <jiangning.liu@amperecomputing.com>
    Co-Authored-By: Manolis Tsamis <manolis.tsamis@vrull.eu>
    
    (cherry picked from commit ff1f2f2412bda118f7ddc10e69bd4284d9b24b9e)

diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
index e491b9d0d38..9aebbbd4910 100644
--- a/gcc/config/aarch64/aarch64.c
+++ b/gcc/config/aarch64/aarch64.c
@@ -785,18 +785,18 @@ static const struct cpu_vector_cost a64fx_vector_cost =
 static const struct cpu_vector_cost ampere1_vector_cost =
 {
   1, /* scalar_int_stmt_cost  */
-  1, /* scalar_fp_stmt_cost  */
+  3, /* scalar_fp_stmt_cost  */
   4, /* scalar_load_cost  */
   1, /* scalar_store_cost  */
-  3, /* int_stmt_cost  */
+  1, /* int_stmt_cost  */
   3, /* fp_stmt_cost  */
   2, /* permute_cost  */
   6, /* vec_to_scalar_cost  */
   7, /* scalar_to_vec_cost  */
-  5, /* align_load_cost  */
-  5, /* unalign_load_cost  */
-  2, /* unalign_store_cost  */
-  2, /* store_cost  */
+  4, /* align_load_cost  */
+  4, /* unalign_load_cost  */
+  1, /* unalign_store_cost  */
+  1, /* store_cost  */
   1, /* cond_taken_branch_cost  */
   1 /* cond_not_taken_branch_cost  */
 };

commit cd963f8d6bf24ef8bebe4fc4e51c13b463c358c4
Author: Philipp Tomsich <philipp.tomsich@vrull.eu>
Date:   Thu Mar 23 19:47:57 2023 +0100

    aarch64: disable LDP via tuning structure for -mcpu=ampere1
    
    AmpereOne (-mcpu=ampere1) breaks LDP instructions into two uops.
    Given the chance that this causes instructions to slip into the next
    decoding cycle and the additional overheads when handling
    cacheline-crossing LDP instructions, we disable the generation of LDP
    isntructions through the tuning structure from instruction combining
    (such as in peephole2).
    
    Given the code-density benefits in builtins and prologue/epilogue
    expansion, we allow LDPs there.
    
    This commit:
     * adds a new tuning option AARCH64_EXTRA_TUNE_NO_LDP_COMBINE
     * allows -moverride=tune=... to override this
    
    These changes are benchmark-driven, yielding the following changes
    (with a net-overall improvement):
       503.bwaves_r.      -0.88%
       507.cactuBSSN_r     0.35%
       508.namd_r          3.09%
       510.parest_r       -2.99%
       511.povray_r        5.54%
       519.lbm_r          15.83%
       521.wrf_r           0.56%
       526.blender_r       2.47%
       527.cam4_r          0.70%
       538.imagick_r       0.00%
       544.nab_r          -0.33%
       549.fotonik3d_r.   -0.42%
       554.roms_r          0.00%
       -------------------------
       = total             1.79%
    
    Signed-off-by: Philipp Tomsich <philipp.tomsich@vrull.eu>
    Co-Authored-By: Di Zhao <di.zhao@amperecomputing.com>
    
    gcc/ChangeLog:
    
            * config/aarch64/aarch64-tuning-flags.def (AARCH64_EXTRA_TUNING_OPTION):
            Add AARCH64_EXTRA_TUNE_NO_LDP_COMBINE.
            * config/aarch64/aarch64.c (aarch64_operands_ok_for_ldpstp):
            Check for the above tuning option when processing loads.
    
    gcc/testsuite/ChangeLog:
    
            * gcc.target/aarch64/ampere1-no_ldp_combine.c: New test.
    
    (cherry picked from commit f200c56787f2c6f93ffb739d57d01a294ab72f68)

diff --git a/gcc/config/aarch64/aarch64-tuning-flags.def b/gcc/config/aarch64/aarch64-tuning-flags.def
index 7677ec0b0b4..9758bfaa65d 100644
--- a/gcc/config/aarch64/aarch64-tuning-flags.def
+++ b/gcc/config/aarch64/aarch64-tuning-flags.def
@@ -44,6 +44,9 @@ AARCH64_EXTRA_TUNING_OPTION ("cheap_shift_extend", CHEAP_SHIFT_EXTEND)
 /* Disallow load/store pair instructions on Q-registers.  */
 AARCH64_EXTRA_TUNING_OPTION ("no_ldp_stp_qregs", NO_LDP_STP_QREGS)
 
+/* Disallow load-pair instructions to be formed in combine/peephole.  */
+AARCH64_EXTRA_TUNING_OPTION ("no_ldp_combine", NO_LDP_COMBINE)
+
 AARCH64_EXTRA_TUNING_OPTION ("rename_load_regs", RENAME_LOAD_REGS)
 
 /* Prefer Advanced SIMD over SVE for auto-vectorization.  */
diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
index 9aebbbd4910..7bc6e5153ad 100644
--- a/gcc/config/aarch64/aarch64.c
+++ b/gcc/config/aarch64/aarch64.c
@@ -1440,7 +1440,7 @@ static const struct tune_params ampere1_tunings =
   2,	/* min_div_recip_mul_df.  */
   0,	/* max_case_values.  */
   tune_params::AUTOPREFETCHER_WEAK,	/* autoprefetcher_model.  */
-  (AARCH64_EXTRA_TUNE_NONE),		/* tune_flags.  */
+  (AARCH64_EXTRA_TUNE_NO_LDP_COMBINE),	/* tune_flags.  */
   &ampere1_prefetch_tune
 };
 
@@ -1471,7 +1471,7 @@ static const struct tune_params ampere1a_tunings =
   2,	/* min_div_recip_mul_df.  */
   0,	/* max_case_values.  */
   tune_params::AUTOPREFETCHER_WEAK,	/* autoprefetcher_model.  */
-  (AARCH64_EXTRA_TUNE_NONE),		/* tune_flags.  */
+  (AARCH64_EXTRA_TUNE_NO_LDP_COMBINE),	/* tune_flags.  */
   &ampere1_prefetch_tune
 };
 
@@ -22346,6 +22346,12 @@ aarch64_operands_ok_for_ldpstp (rtx *operands, bool load,
   enum reg_class rclass_1, rclass_2;
   rtx mem_1, mem_2, reg_1, reg_2, base_1, base_2, offset_1, offset_2;
 
+  /* Allow the tuning structure to disable LDP instruction formation
+     from combining instructions (e.g., in peephole2).  */
+  if (load && (aarch64_tune_params.extra_tuning_flags
+	       & AARCH64_EXTRA_TUNE_NO_LDP_COMBINE))
+    return false;
+
   if (load)
     {
       mem_1 = operands[1];
diff --git a/gcc/testsuite/gcc.target/aarch64/ampere1-no_ldp_combine.c b/gcc/testsuite/gcc.target/aarch64/ampere1-no_ldp_combine.c
new file mode 100644
index 00000000000..bc871f4481d
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/ampere1-no_ldp_combine.c
@@ -0,0 +1,11 @@
+/* { dg-options "-O3 -mtune=ampere1" } */
+
+long
+foo (long a[])
+{
+  return a[0] + a[1];
+}
+
+/* We should see two ldrs instead of one ldp. */
+/* { dg-final { scan-assembler {\tldr\t} } } */
+/* { dg-final { scan-assembler-not {\tldp\t} } } */

commit 28fc1297adde1be51f25a13e110d38dd9e804320
Author: Philipp Tomsich <philipp.tomsich@vrull.eu>
Date:   Mon Jan 30 23:40:26 2023 +0100

    PR target/108589 - Check REG_P for AARCH64_FUSE_ADDSUB_2REG_CONST1
    
    This adds a check for REG_P on SET_DEST for the new idiom recognizer
    for AARCH64_FUSE_ADDSUB_2REG_CONST1.  The reported ICE is only
    observable with checking=rtl.
    
    Bootstrapped/regtested aarch64-linux, committed.
    
            PR target/108589
    
    gcc/ChangeLog:
    
            * config/aarch64/aarch64.c (aarch_macro_fusion_pair_p): Check
            REG_P on SET_DEST.
    
    gcc/testsuite/ChangeLog:
    
            * gcc.target/aarch64/pr108589.c: New test.
    
    (cherry picked from commit a39c6ec97906766ad65d15d4856fd41121ee7a45)

diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c
index 7bc6e5153ad..e6bf5ae3808 100644
--- a/gcc/config/aarch64/aarch64.c
+++ b/gcc/config/aarch64/aarch64.c
@@ -22155,6 +22155,7 @@ aarch_macro_fusion_pair_p (rtx_insn *prev, rtx_insn *curr)
 	  && CONST_INT_P (XEXP (curr_src, 1))
 	  && INTVAL (XEXP (curr_src, 1)) == polarity
 	  && REG_P (XEXP (curr_src, 0))
+	  && REG_P (SET_DEST (prev_set))
 	  && REGNO (SET_DEST (prev_set)) == REGNO (XEXP (curr_src, 0)))
 	return true;
     }
diff --git a/gcc/testsuite/gcc.target/aarch64/pr108589.c b/gcc/testsuite/gcc.target/aarch64/pr108589.c
new file mode 100644
index 00000000000..861727f7268
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/pr108589.c
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target lp64 } */
+/* { dg-options "-Os -O2 -mtune=ampere1a -fno-split-wide-types" } */
+
+int i;
+__int128 j;
+short s;
+
+void
+foo (void)
+{
+  j -= i;
+  int l = i - __builtin_sub_overflow_p (0, 61680, s);
+  j -= __builtin_mul_overflow_p (i, l, 0);
+}

commit 73c330131031b459334b39f74a7c79a7bae3c1d0
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Wed Apr 19 00:19:40 2023 +0000

    Daily bump.

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 08a3c55a179..cb315e901a7 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,75 @@
+2023-04-18  Philipp Tomsich  <philipp.tomsich@vrull.eu>
+
+	Backported from master:
+	2023-01-31  Philipp Tomsich  <philipp.tomsich@vrull.eu>
+
+	PR target/108589
+	* config/aarch64/aarch64.c (aarch_macro_fusion_pair_p): Check
+	REG_P on SET_DEST.
+
+2023-04-18  Philipp Tomsich  <philipp.tomsich@vrull.eu>
+
+	Backported from master:
+	2023-04-17  Philipp Tomsich  <philipp.tomsich@vrull.eu>
+		    Di Zhao  <di.zhao@amperecomputing.com>
+
+	* config/aarch64/aarch64-tuning-flags.def (AARCH64_EXTRA_TUNING_OPTION):
+	Add AARCH64_EXTRA_TUNE_NO_LDP_COMBINE.
+	* config/aarch64/aarch64.c (aarch64_operands_ok_for_ldpstp):
+	Check for the above tuning option when processing loads.
+
+2023-04-18  Philipp Tomsich  <philipp.tomsich@vrull.eu>
+
+	Backported from master:
+	2023-03-27  Philipp Tomsich  <philipp.tomsich@vrull.eu>
+		    Jiangning Liu  <jiangning.liu@amperecomputing.com>
+		    Manolis Tsamis  <manolis.tsamis@vrull.eu>
+
+	* config/aarch64/aarch64.c: Update vector costs for ampere1.
+
+2023-04-18  Philipp Tomsich  <philipp.tomsich@vrull.eu>
+
+	Backported from master:
+	2022-11-14  Philipp Tomsich  <philipp.tomsich@vrull.eu>
+
+	* config/aarch64/aarch64-cores.def (AARCH64_CORE): Add ampere1a.
+	* config/aarch64/aarch64-cost-tables.h: Add ampere1a_extra_costs.
+	* config/aarch64/aarch64-fusion-pairs.def (AARCH64_FUSION_PAIR):
+	Define a new fusion pair for A+B+1/A-B-1 (i.e., add/subtract two
+	registers and then +1/-1).
+	* config/aarch64/aarch64-tune.md: Regenerate.
+	* config/aarch64/aarch64.c (aarch_macro_fusion_pair_p): Implement
+	idiom-matcher for the new fusion pair.
+	* doc/invoke.texi: Add ampere1a.
+
+2023-04-18  Philipp Tomsich  <philipp.tomsich@vrull.eu>
+
+	Backported from master:
+	2022-10-06  Philipp Tomsich  <philipp.tomsich@vrull.eu>
+
+	* config/aarch64/aarch64-cores.def (AARCH64_CORE): Update
+	Ampere-1 core entry.
+
+2023-04-18  Philipp Tomsich  <philipp.tomsich@vrull.eu>
+
+	Backported from master:
+	2022-10-06  Philipp Tomsich  <philipp.tomsich@vrull.eu>
+
+	* config/aarch64/driver-aarch64.c (readline): Fix off-by-one.
+
+2023-04-18  Philipp Tomsich  <philipp.tomsich@vrull.eu>
+
+	Backported from master:
+	2021-11-03  Philipp Tomsich  <philipp.tomsich@vrull.eu>
+
+	* config/aarch64/aarch64-cores.def (AARCH64_CORE): New Ampere-1
+	core.
+	* config/aarch64/aarch64-tune.md: Regenerate.
+	* config/aarch64/aarch64-cost-tables.h: Add extra costs for
+	Ampere-1.
+	* config/aarch64/aarch64.c: Add tuning structures for Ampere-1.
+	* doc/invoke.texi: Add documentation for Ampere-1 core.
+
 2023-04-17  Kewen Lin  <linkw@linux.ibm.com>
 
 	Backported from master:
diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 378aed56acf..59726e584d2 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230418
+20230419
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 9ffc5078d3f..6d8ef488fbb 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,27 @@
+2023-04-18  Philipp Tomsich  <philipp.tomsich@vrull.eu>
+
+	Backported from master:
+	2023-01-31  Philipp Tomsich  <philipp.tomsich@vrull.eu>
+
+	PR target/108589
+	* gcc.target/aarch64/pr108589.c: New test.
+
+2023-04-18  Philipp Tomsich  <philipp.tomsich@vrull.eu>
+
+	Backported from master:
+	2023-04-17  Philipp Tomsich  <philipp.tomsich@vrull.eu>
+		    Di Zhao  <di.zhao@amperecomputing.com>
+
+	* gcc.target/aarch64/ampere1-no_ldp_combine.c: New test.
+
+2023-04-18  Philipp Tomsich  <philipp.tomsich@vrull.eu>
+
+	Backported from master:
+	2022-10-06  Philipp Tomsich  <philipp.tomsich@vrull.eu>
+
+	* gcc.target/aarch64/cpunative/info_18: New test.
+	* gcc.target/aarch64/cpunative/native_cpu_18.c: New test.
+
 2023-04-17  Kewen Lin  <linkw@linux.ibm.com>
 
 	Backported from master:

commit 00dfa3db49c57bb430eb8b5dedf952b4ef76ce79
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Thu Apr 20 00:18:47 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 59726e584d2..758629bff2e 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230419
+20230420

commit e43a0d0dc56eb7699750cffc06ee6c916199772e
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Fri Apr 21 00:19:13 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 758629bff2e..1bf412b8655 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230420
+20230421

commit 6f7f90113bc78440a248bef4b917583fde3e6e5f
Author: Jason Merrill <jason@redhat.com>
Date:   Thu Mar 16 13:11:32 2023 -0400

    c++: &enum::enumerator [PR101869]
    
    We don't want to call build_offset_ref with an enum.
    
            PR c++/101869
    
    gcc/cp/ChangeLog:
    
            * semantics.c (finish_qualified_id_expr): Don't try to build a
            pointer-to-member if the scope is an enumeration.
    
    gcc/testsuite/ChangeLog:
    
            * g++.dg/cpp0x/enum43.C: New test.

diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c
index d846a1bd8f0..568f019fede 100644
--- a/gcc/cp/semantics.c
+++ b/gcc/cp/semantics.c
@@ -2143,7 +2143,8 @@ finish_qualified_id_expr (tree qualifying_class,
 
   /* If EXPR occurs as the operand of '&', use special handling that
      permits a pointer-to-member.  */
-  if (address_p && done)
+  if (address_p && done
+      && TREE_CODE (qualifying_class) != ENUMERAL_TYPE)
     {
       if (TREE_CODE (expr) == SCOPE_REF)
 	expr = TREE_OPERAND (expr, 1);
diff --git a/gcc/testsuite/g++.dg/cpp0x/enum43.C b/gcc/testsuite/g++.dg/cpp0x/enum43.C
new file mode 100644
index 00000000000..b2cd9797a06
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/enum43.C
@@ -0,0 +1,11 @@
+// PR c++/101869
+
+enum E { A };
+E operator & (E e)
+{
+  return e;
+}
+E f(void)
+{
+    return &E::A;	 // { dg-error "not a class" "" { target c++98_only } }
+}

commit fc03893d2fead133ed336511ac00d75c10c5a88d
Author: Jason Merrill <jason@redhat.com>
Date:   Fri Mar 17 09:43:48 2023 -0400

    c++: namespace-scoped friend in local class [PR69410]
    
    do_friend was only considering class-qualified identifiers for the
    qualified-id case, but we also need to skip local scope when there's an
    explicit namespace scope.
    
            PR c++/69410
    
    gcc/cp/ChangeLog:
    
            * friend.c (do_friend): Handle namespace as scope argument.
            * decl.c (grokdeclarator): Pass down in_namespace.
    
    gcc/testsuite/ChangeLog:
    
            * g++.dg/lookup/friend24.C: New test.

diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 6af7a97a7b9..4c7174395b6 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -13467,7 +13467,8 @@ grokdeclarator (const cp_declarator *declarator,
 		      return error_mark_node;
 		  }
 
-		decl = do_friend (ctype, unqualified_id, decl,
+		tree scope = ctype ? ctype : in_namespace;
+		decl = do_friend (scope, unqualified_id, decl,
 				  *attrlist, flags,
 				  funcdef_flag);
 		return decl;
diff --git a/gcc/cp/friend.c b/gcc/cp/friend.c
index fa20a9377a7..e6e2639be4a 100644
--- a/gcc/cp/friend.c
+++ b/gcc/cp/friend.c
@@ -467,19 +467,32 @@ make_friend_class (tree type, tree friend_type, bool complain)
 }
 
 /* Record DECL (a FUNCTION_DECL) as a friend of the
-   CURRENT_CLASS_TYPE.  If DECL is a member function, CTYPE is the
+   CURRENT_CLASS_TYPE.  If DECL is a member function, SCOPE is the
    class of which it is a member, as named in the friend declaration.
+   If the friend declaration was explicitly namespace-qualified, SCOPE
+   is that namespace.
    DECLARATOR is the name of the friend.  FUNCDEF_FLAG is true if the
    friend declaration is a definition of the function.  FLAGS is as
    for grokclass fn.  */
 
 tree
-do_friend (tree ctype, tree declarator, tree decl,
+do_friend (tree scope, tree declarator, tree decl,
 	   tree attrlist, enum overload_flags flags,
 	   bool funcdef_flag)
 {
   gcc_assert (TREE_CODE (decl) == FUNCTION_DECL);
-  gcc_assert (!ctype || MAYBE_CLASS_TYPE_P (ctype));
+
+  tree ctype = NULL_TREE;
+  tree in_namespace = NULL_TREE;
+  if (!scope)
+    ;
+  else if (MAYBE_CLASS_TYPE_P (scope))
+    ctype = scope;
+  else
+    {
+      gcc_checking_assert (TREE_CODE (scope) == NAMESPACE_DECL);
+      in_namespace = scope;
+    }
 
   /* Every decl that gets here is a friend of something.  */
   DECL_FRIEND_P (decl) = 1;
@@ -612,7 +625,7 @@ do_friend (tree ctype, tree declarator, tree decl,
 	       parameters.  Instead, we call pushdecl when the class
 	       is instantiated.  */
 	    decl = push_template_decl_real (decl, /*is_friend=*/true);
-	  else if (current_function_decl)
+	  else if (current_function_decl && !in_namespace)
 	    /* pushdecl will check there's a local decl already.  */
 	    decl = pushdecl (decl, /*is_friend=*/true);
 	  else
diff --git a/gcc/testsuite/g++.dg/lookup/friend24.C b/gcc/testsuite/g++.dg/lookup/friend24.C
new file mode 100644
index 00000000000..9a45410d2a7
--- /dev/null
+++ b/gcc/testsuite/g++.dg/lookup/friend24.C
@@ -0,0 +1,9 @@
+// PR c++/69410
+
+void a();
+void f() {
+    class A {
+        friend void ::a();
+        friend class Z;
+    };
+}

commit 92e2bb31ffe25271e5ae70d7533469419b883864
Author: Jason Merrill <jason@redhat.com>
Date:   Fri Mar 17 17:26:40 2023 -0400

    c++: constant, array, lambda, template [PR108975]
    
    When a lambda refers to a constant local variable in the enclosing scope, we
    tentatively capture it, but if we end up pulling out its constant value, we
    go back at the end of the lambda and prune any unneeded captures.  Here
    while parsing the template we decided that the dim capture was unneeded,
    because we folded it away, but then we brought back the use in the template
    trees that try to preserve the source representation with added type info.
    So then when we tried to instantiate that use, we couldn't find what it was
    trying to use, and crashed.
    
    Fixed by not trying to prune when parsing a template; we'll prune at
    instantiation time.
    
            PR c++/108975
    
    gcc/cp/ChangeLog:
    
            * lambda.c (prune_lambda_captures): Don't bother in a template.
    
    gcc/testsuite/ChangeLog:
    
            * g++.dg/cpp0x/lambda/lambda-const11.C: New test.

diff --git a/gcc/cp/lambda.c b/gcc/cp/lambda.c
index ec87f3b163c..42b9d075f9e 100644
--- a/gcc/cp/lambda.c
+++ b/gcc/cp/lambda.c
@@ -1537,6 +1537,9 @@ prune_lambda_captures (tree body)
   if (LAMBDA_EXPR_DEFAULT_CAPTURE_MODE (lam) == CPLD_NONE)
     /* No default captures, and we don't prune explicit captures.  */
     return;
+  /* Don't bother pruning in a template, we'll prune at instantiation time.  */
+  if (dependent_type_p (TREE_TYPE (lam)))
+    return;
 
   hash_map<tree,tree*> const_vars;
 
diff --git a/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-const11.C b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-const11.C
new file mode 100644
index 00000000000..26af75bf132
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/lambda/lambda-const11.C
@@ -0,0 +1,14 @@
+// PR c++/108975
+// { dg-do compile { target c++11 } }
+
+template<class T>
+void f() {
+  constexpr int dim = 1;
+  auto l = [&] {
+    int n[dim * 1];
+  };
+  // In f<int>, we shouldn't actually capture dim.
+  static_assert (sizeof(l) == 1, "");
+}
+
+template void f<int>();

commit da17a9049ee0a8ca9f93edf137df92e824a7593e
Author: Jason Merrill <jason@redhat.com>
Date:   Thu Mar 23 16:50:09 2023 -0400

    c++: constexpr PMF conversion [PR105996]
    
    Here, we were calling build_reinterpret_cast regardless of whether there was
    actually a cast, and that now sets REINTERPRET_CAST_P.  But that
    optimization seems dodgy anyway, as it involves NOP_EXPR from one
    RECORD_TYPE to another and we try to reserve NOP_EXPR for fundamental types.
    And the generated code seems the same, so let's drop it.  And also strip
    location wrappers.
    
            PR c++/105996
    
    gcc/cp/ChangeLog:
    
            * typeck.c (build_ptrmemfunc): Drop 0-offset optimization
            and location wrappers.
    
    gcc/testsuite/ChangeLog:
    
            * g++.dg/cpp0x/constexpr-pmf3.C: New test.

diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index aec933b863b..35bd3c8b056 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -9036,18 +9036,15 @@ build_ptrmemfunc (tree type, tree pfn, int force, bool c_cast_p,
       if (n == error_mark_node)
 	return error_mark_node;
 
+      STRIP_ANY_LOCATION_WRAPPER (pfn);
+
       /* We don't have to do any conversion to convert a
 	 pointer-to-member to its own type.  But, we don't want to
 	 just return a PTRMEM_CST if there's an explicit cast; that
 	 cast should make the expression an invalid template argument.  */
-      if (TREE_CODE (pfn) != PTRMEM_CST)
-	{
-	  if (same_type_p (to_type, pfn_type))
-	    return pfn;
-	  else if (integer_zerop (n) && TREE_CODE (pfn) != CONSTRUCTOR)
-	    return build_reinterpret_cast (input_location, to_type, pfn, 
-                                           complain);
-	}
+      if (TREE_CODE (pfn) != PTRMEM_CST
+	  && same_type_p (to_type, pfn_type))
+	return pfn;
 
       if (TREE_SIDE_EFFECTS (pfn))
 	pfn = save_expr (pfn);
diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-pmf3.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-pmf3.C
new file mode 100644
index 00000000000..14daea312b7
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-pmf3.C
@@ -0,0 +1,13 @@
+// PR c++/105996
+// { dg-do compile { target c++11 } }
+
+struct A {
+  void CB() {}
+};
+struct B : public A { };
+
+using APMF = void (A::*)();
+using BPMF = void (B::*)();
+
+constexpr APMF foo () { return &A::CB; };
+static constexpr BPMF b = foo();

commit e81e393cd864abcd2de02602bd51e435dc28f418
Author: Jason Merrill <jason@redhat.com>
Date:   Thu Mar 23 15:57:39 2023 -0400

    c-family: -Wsequence-point and COMPONENT_REF [PR107163]
    
    The patch for PR91415 fixed -Wsequence-point to treat shifts and ARRAY_REF
    as sequenced in C++17, and COMPONENT_REF as well.  But this is unnecessary
    for COMPONENT_REF, since the RHS is just a FIELD_DECL with no actual
    evaluation, and in this testcase handling COMPONENT_REF as sequenced blows
    up fast in a deep inheritance tree.  Instead, look through it.
    
            PR c++/107163
    
    gcc/c-family/ChangeLog:
    
            * c-common.c (verify_tree): Don't use sequenced handling
            for COMPONENT_REF.
    
    gcc/testsuite/ChangeLog:
    
            * g++.dg/warn/Wsequence-point-5.C: New test.

diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c
index 8105a27ab56..409dbfeec09 100644
--- a/gcc/c-family/c-common.c
+++ b/gcc/c-family/c-common.c
@@ -2006,12 +2006,17 @@ verify_tree (tree x, struct tlist **pbefore_sp, struct tlist **pno_sp,
 
     case LSHIFT_EXPR:
     case RSHIFT_EXPR:
-    case COMPONENT_REF:
     case ARRAY_REF:
       if (cxx_dialect >= cxx17)
 	goto sequenced_binary;
       goto do_default;
 
+    case COMPONENT_REF:
+      /* Treat as unary, the other operands aren't evaluated.  */
+      x = TREE_OPERAND (x, 0);
+      writer = 0;
+      goto restart;
+
     default:
     do_default:
       /* For other expressions, simply recurse on their operands.
diff --git a/gcc/testsuite/g++.dg/warn/Wsequence-point-5.C b/gcc/testsuite/g++.dg/warn/Wsequence-point-5.C
new file mode 100644
index 00000000000..0354ab09f53
--- /dev/null
+++ b/gcc/testsuite/g++.dg/warn/Wsequence-point-5.C
@@ -0,0 +1,37 @@
+// PR c++/107163
+// { dg-additional-options "-Wsequence-point" }
+
+struct BaseType  {
+  int i;
+};
+
+template< int Seq >
+class DerivedType : public DerivedType< Seq - 1 > { };
+
+template<>
+class DerivedType< -1 > : public BaseType { };
+
+int main() {
+  DerivedType< 400 > d;
+  d.i = 42;
+  d.i = 42;
+  d.i = 42;
+  d.i = 42;
+  d.i = 42;
+  d.i = 42;
+  d.i = 42;
+  d.i = 42;
+  d.i = 42;
+  d.i = 42;
+  d.i = 42;
+  d.i = 42;
+  d.i = 42;
+  d.i = 42;
+  d.i = 42;
+  d.i = 42;
+  d.i = 42;
+  d.i = 42;
+  d.i = 42;
+  d.i = 42;
+  return d.i;
+}

commit ee8d6c5c3860af572c9befc6a4444061c1f82656
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sat Apr 22 00:19:16 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 1bf412b8655..255d261f77a 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230421
+20230422
diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog
index 18ee28e6680..a419e0486fd 100644
--- a/gcc/c-family/ChangeLog
+++ b/gcc/c-family/ChangeLog
@@ -1,3 +1,9 @@
+2023-04-21  Jason Merrill  <jason@redhat.com>
+
+	PR c++/107163
+	* c-common.c (verify_tree): Don't use sequenced handling
+	for COMPONENT_REF.
+
 2022-06-28  Release Manager
 
 	* GCC 10.4.0 released.
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 1c57627714a..bbb71668e1f 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,26 @@
+2023-04-21  Jason Merrill  <jason@redhat.com>
+
+	PR c++/105996
+	* typeck.c (build_ptrmemfunc): Drop 0-offset optimization
+	and location wrappers.
+
+2023-04-21  Jason Merrill  <jason@redhat.com>
+
+	PR c++/108975
+	* lambda.c (prune_lambda_captures): Don't bother in a template.
+
+2023-04-21  Jason Merrill  <jason@redhat.com>
+
+	PR c++/69410
+	* friend.c (do_friend): Handle namespace as scope argument.
+	* decl.c (grokdeclarator): Pass down in_namespace.
+
+2023-04-21  Jason Merrill  <jason@redhat.com>
+
+	PR c++/101869
+	* semantics.c (finish_qualified_id_expr): Don't try to build a
+	pointer-to-member if the scope is an enumeration.
+
 2022-12-16  Patrick Palka  <ppalka@redhat.com>
 
 	Backported from master:
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 6d8ef488fbb..ee1501c253e 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,28 @@
+2023-04-21  Jason Merrill  <jason@redhat.com>
+
+	PR c++/107163
+	* g++.dg/warn/Wsequence-point-5.C: New test.
+
+2023-04-21  Jason Merrill  <jason@redhat.com>
+
+	PR c++/105996
+	* g++.dg/cpp0x/constexpr-pmf3.C: New test.
+
+2023-04-21  Jason Merrill  <jason@redhat.com>
+
+	PR c++/108975
+	* g++.dg/cpp0x/lambda/lambda-const11.C: New test.
+
+2023-04-21  Jason Merrill  <jason@redhat.com>
+
+	PR c++/69410
+	* g++.dg/lookup/friend24.C: New test.
+
+2023-04-21  Jason Merrill  <jason@redhat.com>
+
+	PR c++/101869
+	* g++.dg/cpp0x/enum43.C: New test.
+
 2023-04-18  Philipp Tomsich  <philipp.tomsich@vrull.eu>
 
 	Backported from master:

commit 5fc6f9df4cb7491b2693b39a67b95f9c2ca0a555
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sun Apr 23 00:18:57 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 255d261f77a..e372b3d6ca6 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230422
+20230423

commit fb00cf68fdacd9179cf039235bed95c073ffe137
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Mon Apr 24 00:19:30 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index e372b3d6ca6..b5f339e560b 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230423
+20230424

commit 555c2e7505da7e83923cee07c0cfe3baacfd1101
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Tue Apr 25 00:19:47 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index b5f339e560b..6d3fa5c3171 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230424
+20230425

commit 52c451e6ef67d428304be3299bb67195177f6759
Author: Jason Merrill <jason@redhat.com>
Date:   Tue Apr 25 11:12:33 2023 -0400

    testsuite: remove stray ';' [PR109608]
    
    GCC 10 is still pedantic about empty declarations.
    
            PR testsuite/109608
    
    gcc/testsuite/ChangeLog:
    
            * g++.dg/cpp0x/constexpr-pmf3.C: Remove stray ';'.

diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-pmf3.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-pmf3.C
index 14daea312b7..279478e9dcc 100644
--- a/gcc/testsuite/g++.dg/cpp0x/constexpr-pmf3.C
+++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-pmf3.C
@@ -9,5 +9,5 @@ struct B : public A { };
 using APMF = void (A::*)();
 using BPMF = void (B::*)();
 
-constexpr APMF foo () { return &A::CB; };
+constexpr APMF foo () { return &A::CB; }
 static constexpr BPMF b = foo();

commit db0b8927d663cf54ad13dc2629ec195e3883d0d0
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Wed Apr 26 00:19:27 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 6d3fa5c3171..927b96ecaa8 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230425
+20230426
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index ee1501c253e..6fe83cf831a 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2023-04-25  Jason Merrill  <jason@redhat.com>
+
+	PR testsuite/109608
+	* g++.dg/cpp0x/constexpr-pmf3.C: Remove stray ';'.
+
 2023-04-21  Jason Merrill  <jason@redhat.com>
 
 	PR c++/107163

commit 1dff032086144efc6943a88b34640e246b73399e
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Thu Apr 27 00:17:59 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 927b96ecaa8..faac45ae8d2 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230426
+20230427

commit 5d572ffe2e05dbe44edaf19fa10ef2ca3ae8227c
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Tue Nov 22 19:15:53 2022 +0000

    libstdc++: Fix unsafe use of dirent::d_name [PR107814]
    
    Copy the fix for PR 104731 to the equivalent experimental::filesystem
    test.
    
    libstdc++-v3/ChangeLog:
    
            PR libstdc++/107814
            * testsuite/experimental/filesystem/iterators/error_reporting.cc:
            Use a static buffer with space after it.
    
    (cherry picked from commit 1cac00d013856fea4cee0f13c4959c8e21afd2d9)

diff --git a/libstdc++-v3/testsuite/experimental/filesystem/iterators/error_reporting.cc b/libstdc++-v3/testsuite/experimental/filesystem/iterators/error_reporting.cc
index 806c511ebef..ddf0d7fec54 100644
--- a/libstdc++-v3/testsuite/experimental/filesystem/iterators/error_reporting.cc
+++ b/libstdc++-v3/testsuite/experimental/filesystem/iterators/error_reporting.cc
@@ -29,35 +29,44 @@
 
 int choice;
 
-struct dirent global_dirent;
-
 extern "C" struct dirent* readdir(DIR*)
 {
+  // On some targets dirent::d_name is very small, but the OS allocates
+  // a trailing char array after the dirent struct. Emulate that here.
+  union State
+  {
+    struct dirent d;
+    char buf[sizeof(struct dirent) + 16] = {};
+  };
+
+  static State state;
+  char* d_name = state.buf + offsetof(struct dirent, d_name);
+
   switch (choice)
   {
   case 1:
-    global_dirent.d_ino = 999;
+    state.d.d_ino = 999;
 #if defined _GLIBCXX_HAVE_STRUCT_DIRENT_D_TYPE && defined DT_REG
-    global_dirent.d_type = DT_REG;
+    state.d.d_type = DT_REG;
 #endif
-    global_dirent.d_reclen = 0;
-    std::char_traits<char>::copy(global_dirent.d_name, "file", 5);
+    state.d.d_reclen = 0;
+    std::char_traits<char>::copy(d_name, "file", 5);
     choice = 0;
-    return &global_dirent;
+    return &state.d;
   case 2:
-    global_dirent.d_ino = 111;
+    state.d.d_ino = 111;
 #if defined _GLIBCXX_HAVE_STRUCT_DIRENT_D_TYPE && defined DT_DIR
-    global_dirent.d_type = DT_DIR;
+    state.d.d_type = DT_DIR;
 #endif
-    global_dirent.d_reclen = 60;
-    std::char_traits<char>::copy(global_dirent.d_name, "subdir", 7);
+    state.d.d_reclen = 60;
+    std::char_traits<char>::copy(d_name, "subdir", 7);
     choice = 1;
-    return &global_dirent;
+    return &state.d;
   default:
     errno = EIO;
     return nullptr;
   }
-  return &global_dirent;
+  return &state.d;
 }
 
 void

commit 3cf551240fcbc7a5e0f5ba07a9164e237e6c097b
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Wed Jul 20 12:49:28 2022 +0100

    libstdc++: Fix minor bugs in std::common_iterator
    
    The noexcept-specifier for some std::common_iterator constructors was
    incorrectly using an rvalue as the first argument of
    std::is_nothrow_assignable_v. This gave the wrong answer for some types,
    e.g. std::common_iterator<int*, S>, because an rvalue of scalar type
    cannot be assigned to.
    
    Also fix the friend declaration to use the same constraints as on the
    definition of the class template. G++ fails to diagnose this error, due
    to PR c++/96830.
    
    Finally, the copy constructor was using std::move for its argument
    in some cases, which should be removed.
    
    libstdc++-v3/ChangeLog:
    
            * include/bits/stl_iterator.h (common_iterator): Fix incorrect
            uses of is_nothrow_assignable_v. Fix inconsistent constraints on
            friend declaration. Do not move argument in copy constructor.
            * testsuite/24_iterators/common_iterator/1.cc: Check for
            noexcept constructibnle/assignable.
    
    (cherry picked from commit 3b5567c3ec7e5759bdecc6a6fc0be2b65a93636e)

diff --git a/libstdc++-v3/include/bits/stl_iterator.h b/libstdc++-v3/include/bits/stl_iterator.h
index a46872fc3c2..ca15fb46cf2 100644
--- a/libstdc++-v3/include/bits/stl_iterator.h
+++ b/libstdc++-v3/include/bits/stl_iterator.h
@@ -1683,7 +1683,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       _S_noexcept1()
       {
 	if constexpr (is_trivially_default_constructible_v<_Tp>)
-	  return is_nothrow_assignable_v<_Tp, _Up>;
+	  return is_nothrow_assignable_v<_Tp&, _Up>;
 	else
 	  return is_nothrow_constructible_v<_Tp, _Up>;
       }
@@ -1777,14 +1777,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       if (_M_index == 0)
 	{
 	  if constexpr (is_trivially_default_constructible_v<_It>)
-	    _M_it = std::move(__x._M_it);
+	    _M_it = __x._M_it;
 	  else
 	    ::new((void*)std::__addressof(_M_it)) _It(__x._M_it);
 	}
       else if (_M_index == 1)
 	{
 	  if constexpr (is_trivially_default_constructible_v<_Sent>)
-	    _M_sent = std::move(__x._M_sent);
+	    _M_sent = __x._M_sent;
 	  else
 	    ::new((void*)std::__addressof(_M_sent)) _Sent(__x._M_sent);
 	}
@@ -1809,8 +1809,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       operator=(const common_iterator<_It2, _Sent2>& __x)
       noexcept(is_nothrow_constructible_v<_It, const _It2&>
 	       && is_nothrow_constructible_v<_Sent, const _Sent2&>
-	       && is_nothrow_assignable_v<_It, const _It2&>
-	       && is_nothrow_assignable_v<_Sent, const _Sent2&>)
+	       && is_nothrow_assignable_v<_It&, const _It2&>
+	       && is_nothrow_assignable_v<_Sent&, const _Sent2&>)
       {
 	switch(_M_index << 2 | __x._M_index)
 	  {
@@ -2004,6 +2004,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
   private:
     template<input_or_output_iterator _It2, sentinel_for<_It2> _Sent2>
+      requires (!same_as<_It2, _Sent2>) && copyable<_It2>
       friend class common_iterator;
 
     bool _M_has_value() const noexcept { return _M_index < 2; }
diff --git a/libstdc++-v3/testsuite/24_iterators/common_iterator/1.cc b/libstdc++-v3/testsuite/24_iterators/common_iterator/1.cc
index 576c4d818a4..8b69ecd54fe 100644
--- a/libstdc++-v3/testsuite/24_iterators/common_iterator/1.cc
+++ b/libstdc++-v3/testsuite/24_iterators/common_iterator/1.cc
@@ -27,15 +27,30 @@ test01()
   using I = std::common_iterator<int*, const int*>;
   static_assert( std::is_default_constructible_v<I> );
   static_assert( std::is_copy_constructible_v<I> );
+  static_assert( std::is_move_constructible_v<I> );
   static_assert( std::is_copy_assignable_v<I> );
+  static_assert( std::is_move_assignable_v<I> );
   static_assert( std::is_constructible_v<I, int*> );
   static_assert( std::is_constructible_v<I, const int*> );
 
-  struct sentinel { operator int*() const { return nullptr; } };
+  static_assert( std::is_nothrow_copy_constructible_v<I> ); // GCC extension
+  static_assert( std::is_nothrow_move_constructible_v<I> ); // GCC extension
+  static_assert( std::is_nothrow_copy_assignable_v<I> ); // GCC extension
+  static_assert( std::is_nothrow_move_assignable_v<I> ); // GCC extension
+
+  struct sentinel { operator int*() const noexcept { return nullptr; } };
   using K = std::common_iterator<int*, sentinel>;
   static_assert( std::is_constructible_v<I, const K&> );
   static_assert( std::is_assignable_v<I, const K&> );
 
+  static_assert( std::is_nothrow_assignable_v<I&, const K&> ); // GCC extension
+
+  struct sentinel_throwing { operator int*() const { return nullptr; } };
+  using K_throwing = std::common_iterator<int*, sentinel_throwing>;
+  // Conversion is noexcept(false)
+  static_assert( ! std::is_nothrow_assignable_v<I&, const K_throwing&> );
+
+
   struct sentinel2
   {
     const int* p;
@@ -46,6 +61,12 @@ test01()
   using J = std::common_iterator<const int*, sentinel2>;
   static_assert( std::is_constructible_v<J, const I&> );
   static_assert( std::is_convertible_v<const I&, J> );
+
+  static_assert( std::is_constructible_v<J, I> );
+  static_assert( std::is_convertible_v<I, J> );
+
+  // Constructor is noexcept(false)
+  static_assert( ! std::is_nothrow_constructible_v<J, I> );
 }
 
 void

commit 5d7de4c8fd9af68011e1fa7bc1d022db81d89594
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Wed Jul 20 16:51:44 2022 +0100

    libstdc++: Fix std::common_iterator assignment [PR100823]
    
    This fixes the following conformance problems reported in the PR:
    
    - Move constructor and move assignment should be defined.
    - Copy assignment from a valueless object should be allowed.
    
    Assignment is completely rewritten by this patch, as the previous
    version had a number of problems. The converting assignment failed to
    handle the case of assigning a new value to a valueless object, which
    should work. It only accepted lvalue arguments, so wasn't usable to
    implement the move assignment operator. Finally, it enforced the
    precondition that the argument is not valueless, which is correct for
    the converting assignment but not for the copy assignment.
    
    A new _M_assign member is added to handle all cases of assignment
    (copying from an lvalue, moving from an rvalue, and converting from a
    different type). The not valueless precondition is checked in the
    converting assignment before calling _M_assign, so isn't enforced for
    copy and move assignment. The new function no longer uses a switch, so
    handles valueless objects as the LHS or RHS of the assignment.
    
    libstdc++-v3/ChangeLog:
    
            PR libstdc++/100823
            * include/bits/stl_iterator.h (common_iterator): Define move
            constructor and move assignment operator.
            (common_iterator::_M_assign): New function implementing
            assignment.
            (common_iterator::operator=): Use _M_assign.
            (common_iterator::_S_valueless): New constant.
            * testsuite/24_iterators/common_iterator/100823.cc: New test.
    
    (cherry picked from commit 56c999860bbbb2fd5091ba0985e2e5eaa90c6478)

diff --git a/libstdc++-v3/include/bits/stl_iterator.h b/libstdc++-v3/include/bits/stl_iterator.h
index ca15fb46cf2..15fedc32d5f 100644
--- a/libstdc++-v3/include/bits/stl_iterator.h
+++ b/libstdc++-v3/include/bits/stl_iterator.h
@@ -1753,6 +1753,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       noexcept(_S_noexcept<const _It2&, const _Sent2&>())
       : _M_valueless(), _M_index(__x._M_index)
       {
+	__glibcxx_assert(__x._M_has_value());
 	if (_M_index == 0)
 	  {
 	    if constexpr (is_trivially_default_constructible_v<_It>)
@@ -1790,14 +1791,58 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	}
     }
 
+    constexpr
+    common_iterator(common_iterator&& __x)
+    noexcept(_S_noexcept<_It, _Sent>())
+    : _M_valueless(), _M_index(__x._M_index)
+    {
+      if (_M_index == 0)
+	{
+	  if constexpr (is_trivially_default_constructible_v<_It>)
+	    _M_it = std::move(__x._M_it);
+	  else
+	    ::new((void*)std::__addressof(_M_it)) _It(std::move(__x._M_it));
+	}
+      else if (_M_index == 1)
+	{
+	  if constexpr (is_trivially_default_constructible_v<_Sent>)
+	    _M_sent = std::move(__x._M_sent);
+	  else
+	    ::new((void*)std::__addressof(_M_sent))
+	      _Sent(std::move(__x._M_sent));
+	}
+    }
+
+    constexpr common_iterator&
+    operator=(const common_iterator&) = default;
+
     common_iterator&
     operator=(const common_iterator& __x)
     noexcept(is_nothrow_copy_assignable_v<_It>
 	     && is_nothrow_copy_assignable_v<_Sent>
 	     && is_nothrow_copy_constructible_v<_It>
 	     && is_nothrow_copy_constructible_v<_Sent>)
+    requires (!is_trivially_copy_assignable_v<_It>
+		|| !is_trivially_copy_assignable_v<_Sent>)
+    {
+      _M_assign(__x);
+      return *this;
+    }
+
+    constexpr common_iterator&
+    operator=(common_iterator&&) = default;
+
+    common_iterator&
+    operator=(common_iterator&& __x)
+    noexcept(is_nothrow_move_assignable_v<_It>
+	     && is_nothrow_move_assignable_v<_Sent>
+	     && is_nothrow_move_constructible_v<_It>
+	     && is_nothrow_move_constructible_v<_Sent>)
+    requires (!is_trivially_move_assignable_v<_It>
+		|| !is_trivially_move_assignable_v<_Sent>)
     {
-      return this->operator=<_It, _Sent>(__x);
+      _M_assign(std::move(__x));
+      return *this;
     }
 
     template<typename _It2, typename _Sent2>
@@ -1812,48 +1857,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	       && is_nothrow_assignable_v<_It&, const _It2&>
 	       && is_nothrow_assignable_v<_Sent&, const _Sent2&>)
       {
-	switch(_M_index << 2 | __x._M_index)
-	  {
-	  case 0b0000:
-	    _M_it = __x._M_it;
-	    break;
-	  case 0b0101:
-	    _M_sent = __x._M_sent;
-	    break;
-	  case 0b0001:
-	    _M_it.~_It();
-	    _M_index = -1;
-	    [[fallthrough]];
-	  case 0b1001:
-	    ::new((void*)std::__addressof(_M_sent)) _Sent(__x._M_sent);
-	    _M_index = 1;
-	    break;
-	  case 0b0100:
-	    _M_sent.~_Sent();
-	    _M_index = -1;
-	    [[fallthrough]];
-	  case 0b1000:
-	    ::new((void*)std::__addressof(_M_it)) _It(__x._M_it);
-	    _M_index = 0;
-	    break;
-	  default:
-	    __glibcxx_assert(__x._M_has_value());
-	    __builtin_unreachable();
-	  }
+	__glibcxx_assert(__x._M_has_value());
+	_M_assign(__x);
 	return *this;
       }
 
     ~common_iterator()
     {
-      switch (_M_index)
-	{
-	case 0:
-	  _M_it.~_It();
-	  break;
-	case 1:
-	  _M_sent.~_Sent();
-	  break;
-	}
+      if (_M_index == 0)
+	_M_it.~_It();
+      else if (_M_index == 1)
+	_M_sent.~_Sent();
     }
 
     decltype(auto)
@@ -2007,7 +2021,37 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       requires (!same_as<_It2, _Sent2>) && copyable<_It2>
       friend class common_iterator;
 
-    bool _M_has_value() const noexcept { return _M_index < 2; }
+    bool
+    _M_has_value() const noexcept { return _M_index != _S_valueless; }
+
+    template<typename _CIt>
+      void
+      _M_assign(_CIt&& __x)
+      {
+	if (_M_index == __x._M_index)
+	  {
+	    if (_M_index == 0)
+	      _M_it = std::forward<_CIt>(__x)._M_it;
+	    else if (_M_index == 1)
+	      _M_sent = std::forward<_CIt>(__x)._M_sent;
+	  }
+	else
+	  {
+	    if (_M_index == 0)
+	      _M_it.~_It();
+	    else if (_M_index == 1)
+	      _M_sent.~_Sent();
+	    _M_index = _S_valueless;
+
+	    if (__x._M_index == 0)
+	      ::new((void*)std::__addressof(_M_it))
+		_It(std::forward<_CIt>(__x)._M_it);
+	    else if (__x._M_index == 1)
+	      ::new((void*)std::__addressof(_M_sent))
+		_Sent(std::forward<_CIt>(__x)._M_sent);
+	    _M_index = __x._M_index;
+	  }
+      }
 
     union
     {
@@ -2015,7 +2059,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       _Sent _M_sent;
       unsigned char _M_valueless;
     };
-    unsigned char _M_index; // 0==_M_it, 1==_M_sent, 2==valueless
+    unsigned char _M_index; // 0 == _M_it, 1 == _M_sent, 2 == valueless
+
+    static constexpr unsigned char _S_valueless{2};
   };
 
   template<typename _It, typename _Sent>
diff --git a/libstdc++-v3/testsuite/24_iterators/common_iterator/100823.cc b/libstdc++-v3/testsuite/24_iterators/common_iterator/100823.cc
new file mode 100644
index 00000000000..4f2b23de8cc
--- /dev/null
+++ b/libstdc++-v3/testsuite/24_iterators/common_iterator/100823.cc
@@ -0,0 +1,43 @@
+// { dg-options "-std=gnu++20 -D_GLIBCXX_ASSERTIONS" }
+// { dg-do run { target c++20 } }
+#include <iterator>
+#include <testsuite_iterators.h>
+#include <testsuite_hooks.h>
+
+void
+test_valueless_assignment()
+{
+  int x[1] { };
+  __gnu_test::test_forward_range<int> r(x);
+  using Iter = decltype(r.begin());
+  using Sent = decltype(r.end());
+
+  std::common_iterator<Iter, Sent> i;
+  const std::common_iterator<Iter, Sent> j(r.begin());
+  try
+  {
+    struct Bomb
+    {
+      bool operator==(Iter) const { return true; }
+      operator Sent() const { throw 1; }
+    };
+    std::common_iterator<Iter, Bomb> b{Bomb{}};
+    i = b; // Throws, leaving i valueless-by-exception.
+    VERIFY(false);
+  }
+  catch (int)
+  {
+    std::common_iterator<Iter, Sent> k(i);
+
+    // PR libstdc++/100823
+    k = i; // Valid even though both operands are valueless.
+
+    i = j; // No longer valueless.
+  }
+  VERIFY( i == j );
+}
+
+int main()
+{
+  test_valueless_assignment();
+}

commit 497094c9d61c20643c93b8a5960b1b498ac5685e
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Wed Feb 15 13:29:56 2023 +0000

    libstdc++: Fix name of <experimental/optional> in comment
    
    libstdc++-v3/ChangeLog:
    
            * include/experimental/optional: Fix header name in comment.
    
    (cherry picked from commit 38f321793ae18d25399f0396ac1371caa7cc7043)

diff --git a/libstdc++-v3/include/experimental/optional b/libstdc++-v3/include/experimental/optional
index 33c509678c1..b779e3d2cee 100644
--- a/libstdc++-v3/include/experimental/optional
+++ b/libstdc++-v3/include/experimental/optional
@@ -1,4 +1,4 @@
-// <optional> -*- C++ -*-
+// <experimental/optional> -*- C++ -*-
 
 // Copyright (C) 2013-2020 Free Software Foundation, Inc.
 //

commit bd0179f31dfb9b009cb561d336f3f1c6fbdd4ceb
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Mon Feb 27 22:34:57 2023 +0000

    libstdc++: Fix uses_allocator_construction_args for pair<T&&, U&&> [PR108952]
    
    This implements LWG 3527 which fixes the handling of pair<T&&, U&&> in
    std::uses_allocator_construction_args.
    
    libstdc++-v3/ChangeLog:
    
            PR libstdc++/108952
            * include/std/memory (uses_allocator_construction_args):
            Implement LWG 3527.
            * testsuite/20_util/pair/astuple/get-2.cc: New test.
            * testsuite/20_util/scoped_allocator/108952.cc: New test.
            * testsuite/20_util/uses_allocator/lwg3527.cc: New test.
    
    (cherry picked from commit 8e342c04550466ab088c33746091ce7f3498ee44)

diff --git a/libstdc++-v3/include/std/memory b/libstdc++-v3/include/std/memory
index eea472e8600..ce54f260257 100644
--- a/libstdc++-v3/include/std/memory
+++ b/libstdc++-v3/include/std/memory
@@ -378,11 +378,14 @@ get_pointer_safety() noexcept { return pointer_safety::relaxed; }
       using _Tp1 = typename _Tp::first_type;
       using _Tp2 = typename _Tp::second_type;
 
+      // _GLIBCXX_RESOLVE_LIB_DEFECTS
+      // 3527. uses_allocator_construction_args handles rvalue pairs
+      // of rvalue references incorrectly
       return std::make_tuple(piecewise_construct,
 	  std::uses_allocator_construction_args<_Tp1>(__a,
-	    std::move(__pr).first),
+	    std::get<0>(std::move(__pr))),
 	  std::uses_allocator_construction_args<_Tp2>(__a,
-	    std::move(__pr).second));
+	    std::get<1>(std::move(__pr))));
     }
 
   template<typename _Tp, typename _Alloc, typename... _Args>
diff --git a/libstdc++-v3/testsuite/20_util/pair/astuple/get-2.cc b/libstdc++-v3/testsuite/20_util/pair/astuple/get-2.cc
new file mode 100644
index 00000000000..573d239effa
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/pair/astuple/get-2.cc
@@ -0,0 +1,68 @@
+// { dg-do compile { target c++11 } }
+
+#include <utility>
+
+template<int N, typename T, typename Pair>
+constexpr bool
+check()
+{
+  return std::is_same<decltype(std::get<N>(std::declval<Pair>())), T>::value;
+}
+
+void
+test_value_category()
+{
+  using P = std::pair<int, long>;
+  static_assert( check<0, int&, P&>(),
+		 "get<0>(pair<T1, T2>&)" );
+  static_assert( check<1, long&, P&>(),
+		 "get<1>(pair<T1, T2>&)" );
+  static_assert( check<0, int&&, P&&>(),
+		 "get<0>(pair<T1, T2>&&)" );
+  static_assert( check<1, long&&, P&&>(),
+		 "get<1>(pair<T1, T2>&&)" );
+  static_assert( check<0, const int&, const P&>(),
+		 "get<0>(const pair<T1, T2>&)" );
+  static_assert( check<1, const long&, const P&>(),
+		 "get<1>(const pair<T1, T2>&)" );
+  static_assert( check<0, const int&&, const P&&>(),
+		 "get<0>(const pair<T1, T2>&&)" );
+  static_assert( check<1, const long&&, const P&&>(),
+		 "get<1>(const pair<T1, T2>&&)" );
+
+  using PL = std::pair<int&, long&>;
+  static_assert( check<0, int&, PL&>(),
+		 "get<0>(pair<T1&, T2&>&)" );
+  static_assert( check<1, long&, PL&>(),
+		 "get<1>(pair<T1&, T2&>&)" );
+  static_assert( check<0, int&, PL&&>(),
+		 "get<0>(pair<T1&, T2&>&&)" );
+  static_assert( check<1, long&, PL&&>(),
+		 "get<1>(pair<T1&, T2&>&&)" );
+  static_assert( check<0, int&, const PL&>(),
+		 "get<0>(const pair<T1&, T2&>&)" );
+  static_assert( check<1, long&, const PL&>(),
+		 "get<1>(const pair<T1&, T2&>&)" );
+  static_assert( check<0, int&, const PL&&>(),
+		 "get<0>(const pair<T1&, T2&>&&)" );
+  static_assert( check<1, long&, const PL&&>(),
+		 "get<1>(const pair<T1&, T2&>&&)" );
+
+  using PR = std::pair<int&&, long&&>;
+  static_assert( check<0, int&, P&>(),
+		 "get<0>(pair<T1&&, T2&&>&)" );
+  static_assert( check<1, long&, P&>(),
+		 "get<1>(pair<T1&&, T2&&>&)" );
+  static_assert( check<0, int&&, PR&&>(),
+		 "get<0>(pair<T1&&, T2&&>&&)" );
+  static_assert( check<1, long&&, PR&&>(),
+		 "get<1>(pair<T1&&, T2&&>&&)" );
+  static_assert( check<0, int&, const PR&>(),
+		 "get<0>(const pair<T1&&, T2&&>&)" );
+  static_assert( check<1, long&, const PR&>(),
+		 "get<1>(const pair<T1&&, T2&&>&)" );
+  static_assert( check<0, int&&, const PR&&>(),
+		 "get<0>(const pair<T1&&, T2&&>&&)" );
+  static_assert( check<1, long&&, const PR&&>(),
+		 "get<1>(const pair<T1&&, T2&&>&&)" );
+}
diff --git a/libstdc++-v3/testsuite/20_util/scoped_allocator/108952.cc b/libstdc++-v3/testsuite/20_util/scoped_allocator/108952.cc
new file mode 100644
index 00000000000..a6b9c67498c
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/scoped_allocator/108952.cc
@@ -0,0 +1,23 @@
+// { dg-do compile { target c++11 } }
+
+#include <scoped_allocator>
+
+struct move_only
+{
+  move_only(move_only&&);
+};
+
+using P = std::pair<move_only, move_only>;
+
+void
+test_pr108952(std::pair<move_only&&, move_only&&> rvals)
+{
+  // LWG 3527. uses_allocator_construction_args handles rvalue pairs of
+  // rvalue references incorrectly.
+  // PR libstdc++/108952 Regression in uses_allocator_construction_args
+  // for pair of rvalue references
+  std::scoped_allocator_adaptor<std::allocator<P>> a;
+  auto p = a.allocate(1);
+  a.construct(p, std::move(rvals));
+  a.deallocate(p, 1);
+}
diff --git a/libstdc++-v3/testsuite/20_util/uses_allocator/lwg3527.cc b/libstdc++-v3/testsuite/20_util/uses_allocator/lwg3527.cc
new file mode 100644
index 00000000000..ae377f4b5a3
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/uses_allocator/lwg3527.cc
@@ -0,0 +1,22 @@
+// { dg-options "-std=gnu++20" }
+// { dg-do compile { target c++20 } }
+
+#include <memory>
+
+struct move_only
+{
+  move_only(move_only&&);
+};
+
+using P = std::pair<move_only, move_only>;
+
+void
+test_lwg3527(std::pair<move_only&&, move_only&&> rvals)
+{
+  // LWG 3527. uses_allocator_construction_args handles rvalue pairs of
+  // rvalue references incorrectly.
+  // PR libstdc++/108952 Regression in uses_allocator_construction_args
+  // for pair of rvalue references
+  std::allocator<move_only> a;
+  (void) std::uses_allocator_construction_args<P>(a, std::move(rvals));
+}

commit cc75195ee8811d6c48f05727c170916c0adc227b
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Fri Mar 10 11:06:25 2023 +0000

    libstdc++: Fix GDB Xmethod for std::shared_ptr::use_count() [PR109064]
    
    libstdc++-v3/ChangeLog:
    
            PR libstdc++/109064
            * python/libstdcxx/v6/xmethods.py (SharedPtrUseCountWorker):
            Remove self-recursion in __init__. Add missing _supports.
            * testsuite/libstdc++-xmethods/shared_ptr.cc: Check use_count()
            and unique().

diff --git a/libstdc++-v3/python/libstdcxx/v6/xmethods.py b/libstdc++-v3/python/libstdcxx/v6/xmethods.py
index 2617c189e40..cd535fb5ed6 100644
--- a/libstdc++-v3/python/libstdcxx/v6/xmethods.py
+++ b/libstdc++-v3/python/libstdcxx/v6/xmethods.py
@@ -730,7 +730,7 @@ class SharedPtrUseCountWorker(gdb.xmethod.XMethodWorker):
     "Implements std::shared_ptr<T>::use_count()"
 
     def __init__(self, elem_type):
-        SharedPtrUseCountWorker.__init__(self, elem_type)
+        pass
 
     def get_arg_types(self):
         return None
@@ -738,6 +738,9 @@ class SharedPtrUseCountWorker(gdb.xmethod.XMethodWorker):
     def get_result_type(self, obj):
         return gdb.lookup_type('long')
 
+    def _supports(self, method_name):
+        return True
+
     def __call__(self, obj):
         refcounts = obj['_M_refcount']['_M_pi']
         return refcounts['_M_use_count'] if refcounts else 0
diff --git a/libstdc++-v3/testsuite/libstdc++-xmethods/shared_ptr.cc b/libstdc++-v3/testsuite/libstdc++-xmethods/shared_ptr.cc
index 05fdd57ec3f..e7a79d67d59 100644
--- a/libstdc++-v3/testsuite/libstdc++-xmethods/shared_ptr.cc
+++ b/libstdc++-v3/testsuite/libstdc++-xmethods/shared_ptr.cc
@@ -36,6 +36,8 @@ main ()
 
   std::shared_ptr<x_struct[3]> s(new x_struct[2]{ {92}, {115} });
 
+  auto qq = q;
+
 // { dg-final { note-test *p 10 } }
 // { dg-final { regexp-test p.get() 0x.* } }
 
@@ -66,6 +68,11 @@ main ()
 // { dg-final { whatis-test s.get() "x_struct \*" } }
 // { dg-final { whatis-test s\[1].y int } }
 
+// { dg-final { note-test p.use_count() 1 } }
+// { dg-final { note-test p.unique() true } }
+// { dg-final { note-test q.use_count() 2 } }
+// { dg-final { note-test q.unique() false } }
+
   return 0;  // Mark SPOT
 }
 

commit cf9eaeaaeec3eb9438b7fc184c493425e8741c88
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Fri Oct 28 15:28:09 2022 +0100

    libstdc++: Fix dangling reference in filesystem::path::filename()
    
    The new -Wdangling-reference warning noticed this.
    
    libstdc++-v3/ChangeLog:
    
            * include/bits/fs_path.h (path::filename()): Fix dangling
            reference.
    
    (cherry picked from commit 49237fe6ef677a81eae701f937546210c90b5914)

diff --git a/libstdc++-v3/include/bits/fs_path.h b/libstdc++-v3/include/bits/fs_path.h
index 3370bf7161e..9f0f2bf5d2d 100644
--- a/libstdc++-v3/include/bits/fs_path.h
+++ b/libstdc++-v3/include/bits/fs_path.h
@@ -1211,9 +1211,9 @@ namespace __detail
       {
 	if (_M_pathname.back() == preferred_separator)
 	  return {};
-	auto& __last = *--end();
-	if (__last._M_type() == _Type::_Filename)
-	  return __last;
+	auto __last = --end();
+	if (__last->_M_type() == _Type::_Filename)
+	  return *__last;
       }
     return {};
   }

commit 33623bbafe06c5e39fd343d51b0e7ee0b0df47b0
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Wed Apr 26 12:27:59 2023 +0100

    libstdc++: Reduce Doxygen output for PDF
    
    Including the header source code in the doxygen-generated PDF file makes
    it too large, and causes pdflatex to run out of memory. If we only set
    SOURCE_BROWSER=YES for the HTML docs then we won't include the sources
    in the PDF file.
    
    There are several macros defined for std::valarray that are only used to
    generate repetitive code and then #undef'd. Those aren't useful in the
    doxygen docs, especially the ones that reuse the same name in different
    files. Omitting them avoids warnings about duplicate labels in the
    refman.tex file.
    
    libstdc++-v3/ChangeLog:
    
            * doc/doxygen/user.cfg.in (SOURCE_BROWSER): Only set to YES for
            HTML docs.
            * include/bits/gslice_array.h (_DEFINE_VALARRAY_OPERATOR): Omit
            from doxygen docs.
            * include/bits/indirect_array.h (_DEFINE_VALARRAY_OPERATOR):
            Likewise.
            * include/bits/mask_array.h (_DEFINE_VALARRAY_OPERATOR):
            Likewise.
            * include/bits/slice_array.h (_DEFINE_VALARRAY_OPERATOR):
            Likewise.
            * include/std/valarray (_DEFINE_VALARRAY_UNARY_OPERATOR)
            (_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT)
            (_DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT)
            (_DEFINE_BINARY_OPERATOR): Likewise.
    
    (cherry picked from commit afa69618d1627435841c9164b019ef98000e0365)

diff --git a/libstdc++-v3/doc/doxygen/user.cfg.in b/libstdc++-v3/doc/doxygen/user.cfg.in
index 19f8ffd8230..b5ab9e9413b 100644
--- a/libstdc++-v3/doc/doxygen/user.cfg.in
+++ b/libstdc++-v3/doc/doxygen/user.cfg.in
@@ -1157,7 +1157,7 @@ USE_MDFILE_AS_MAINPAGE =
 # also VERBATIM_HEADERS is set to NO.
 # The default value is: NO.
 
-SOURCE_BROWSER         = YES
+SOURCE_BROWSER         = @do_html@
 
 # Setting the INLINE_SOURCES tag to YES will include the body of functions,
 # classes and enums directly into the documentation.
diff --git a/libstdc++-v3/include/bits/gslice_array.h b/libstdc++-v3/include/bits/gslice_array.h
index da60e3bf3c7..8c7075a5d38 100644
--- a/libstdc++-v3/include/bits/gslice_array.h
+++ b/libstdc++-v3/include/bits/gslice_array.h
@@ -183,6 +183,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 			      _Array<size_t>(_M_index));
       }
 
+  /// @cond undocumented
 #undef _DEFINE_VALARRAY_OPERATOR
 #define _DEFINE_VALARRAY_OPERATOR(_Op, _Name)				\
   template<typename _Tp>						\
@@ -214,6 +215,7 @@ _DEFINE_VALARRAY_OPERATOR(<<, __shift_left)
 _DEFINE_VALARRAY_OPERATOR(>>, __shift_right)
 
 #undef _DEFINE_VALARRAY_OPERATOR
+  /// @endcond
 
   /// @} group numeric_arrays
 
diff --git a/libstdc++-v3/include/bits/indirect_array.h b/libstdc++-v3/include/bits/indirect_array.h
index 9d75219a741..ab24867fda3 100644
--- a/libstdc++-v3/include/bits/indirect_array.h
+++ b/libstdc++-v3/include/bits/indirect_array.h
@@ -174,6 +174,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       indirect_array<_Tp>::operator=(const _Expr<_Dom, _Tp>& __e) const
       { std::__valarray_copy(__e, _M_sz, _M_array, _M_index); }
 
+  /// @cond undocumented
 #undef _DEFINE_VALARRAY_OPERATOR
 #define _DEFINE_VALARRAY_OPERATOR(_Op, _Name)				\
   template<typename _Tp>						\
@@ -203,6 +204,7 @@ _DEFINE_VALARRAY_OPERATOR(<<, __shift_left)
 _DEFINE_VALARRAY_OPERATOR(>>, __shift_right)
 
 #undef _DEFINE_VALARRAY_OPERATOR
+  /// @endcond
 
   /// @} group numeric_arrays
 
diff --git a/libstdc++-v3/include/bits/mask_array.h b/libstdc++-v3/include/bits/mask_array.h
index 845a1d6570a..bcfa17e4df5 100644
--- a/libstdc++-v3/include/bits/mask_array.h
+++ b/libstdc++-v3/include/bits/mask_array.h
@@ -174,6 +174,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       mask_array<_Tp>::operator=(const _Expr<_Ex, _Tp>& __e) const
       { std::__valarray_copy(__e, __e.size(), _M_array, _M_mask); }
 
+  /// @cond undocumented
 #undef _DEFINE_VALARRAY_OPERATOR
 #define _DEFINE_VALARRAY_OPERATOR(_Op, _Name)				\
   template<typename _Tp>						\
@@ -204,6 +205,7 @@ _DEFINE_VALARRAY_OPERATOR(<<, __shift_left)
 _DEFINE_VALARRAY_OPERATOR(>>, __shift_right)
 
 #undef _DEFINE_VALARRAY_OPERATOR
+  /// @endcond
 
   /// @} group numeric_arrays
 
diff --git a/libstdc++-v3/include/bits/slice_array.h b/libstdc++-v3/include/bits/slice_array.h
index d875fc225b3..1fbb010feb4 100644
--- a/libstdc++-v3/include/bits/slice_array.h
+++ b/libstdc++-v3/include/bits/slice_array.h
@@ -245,6 +245,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     slice_array<_Tp>::operator=(const _Expr<_Dom,_Tp>& __e) const
     { std::__valarray_copy(__e, _M_sz, _M_array, _M_stride); }
 
+  /// @cond undocumented
 #undef _DEFINE_VALARRAY_OPERATOR
 #define _DEFINE_VALARRAY_OPERATOR(_Op,_Name)				\
   template<typename _Tp>						\
@@ -275,6 +276,7 @@ _DEFINE_VALARRAY_OPERATOR(<<, __shift_left)
 _DEFINE_VALARRAY_OPERATOR(>>, __shift_right)
 
 #undef _DEFINE_VALARRAY_OPERATOR
+  /// @endcond
 
   /// @} group numeric_arrays
 
diff --git a/libstdc++-v3/include/std/valarray b/libstdc++-v3/include/std/valarray
index e1b5d5f4f02..df001b5b720 100644
--- a/libstdc++-v3/include/std/valarray
+++ b/libstdc++-v3/include/std/valarray
@@ -1076,6 +1076,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       return _Expr<_Closure, _Tp>(_Closure(*this, func));
     }
 
+  /// @cond undocumented
 #define _DEFINE_VALARRAY_UNARY_OPERATOR(_Op, _Name)                     \
   template<typename _Tp>						\
     inline typename valarray<_Tp>::template _UnaryOp<_Name>::_Rt	\
@@ -1202,6 +1203,7 @@ _DEFINE_BINARY_OPERATOR(<=, __less_equal)
 _DEFINE_BINARY_OPERATOR(>=, __greater_equal)
 
 #undef _DEFINE_BINARY_OPERATOR
+  /// @endcond
 
 #if __cplusplus >= 201103L
   /**

commit c73f20e67ee8d268bf0dfd6732c1bd3e79e098ca
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Tue Apr 4 12:04:14 2023 +0100

    libstdc++: Fix outdated docs about demangling exception messages
    
    The string returned by std::bad_exception::what() hasn't been a mangled
    name since PR libstdc++/14493 was fixed for GCC 4.2.0, so remove the
    docs showing how to demangle it.
    
    libstdc++-v3/ChangeLog:
    
            * doc/xml/manual/extensions.xml: Remove std::bad_exception from
            example program.
            * doc/html/manual/ext_demangling.html: Regenerate.
    
    (cherry picked from commit 688d126b69215db29774c249b052e52d765782b3)

diff --git a/libstdc++-v3/doc/html/manual/ext_demangling.html b/libstdc++-v3/doc/html/manual/ext_demangling.html
index 879497f7d08..028ec71d8c8 100644
--- a/libstdc++-v3/doc/html/manual/ext_demangling.html
+++ b/libstdc++-v3/doc/html/manual/ext_demangling.html
@@ -39,14 +39,6 @@ int main()
   int     status;
   char   *realname;
 
-  // exception classes not in &lt;stdexcept&gt;, thrown by the implementation
-  // instead of the user
-  std::bad_exception  e;
-  realname = abi::__cxa_demangle(e.what(), 0, 0, &amp;status);
-  std::cout &lt;&lt; e.what() &lt;&lt; "\t=&gt; " &lt;&lt; realname &lt;&lt; "\t: " &lt;&lt; status &lt;&lt; '\n';
-  free(realname);
-
-
   // typeid
   bar&lt;empty,17&gt;          u;
   const std::type_info  &amp;ti = typeid(u);
@@ -61,13 +53,12 @@ int main()
      This prints
    </p><pre class="screen">
    <code class="computeroutput">
-      St13bad_exception       =&gt; std::bad_exception   : 0
       3barI5emptyLi17EE       =&gt; bar&lt;empty, 17&gt;       : 0
    </code>
    </pre><p>
      The demangler interface is described in the source documentation
      linked to above.  It is actually written in C, so you don't need to
      be writing C++ in order to demangle C++.  (That also means we have to
-     use crummy memory management facilities, so don't forget to free()
-     the returned char array.)
+     use crummy memory management facilities, so don't forget to
+     <code class="code">free()</code> the returned char array.)
    </p></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ext_io.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="extensions.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="ext_concurrency.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Chapter 27. Input and Output </td><td width="20%" align="center"><a accesskey="h" href="../index.html">Home</a></td><td width="40%" align="right" valign="top"> Chapter 29. Concurrency</td></tr></table></div></body></html>
\ No newline at end of file
diff --git a/libstdc++-v3/doc/xml/manual/extensions.xml b/libstdc++-v3/doc/xml/manual/extensions.xml
index 86e92beffd3..196b55d8347 100644
--- a/libstdc++-v3/doc/xml/manual/extensions.xml
+++ b/libstdc++-v3/doc/xml/manual/extensions.xml
@@ -534,14 +534,6 @@ int main()
   int     status;
   char   *realname;
 
-  // exception classes not in &lt;stdexcept&gt;, thrown by the implementation
-  // instead of the user
-  std::bad_exception  e;
-  realname = abi::__cxa_demangle(e.what(), 0, 0, &amp;status);
-  std::cout &lt;&lt; e.what() &lt;&lt; "\t=&gt; " &lt;&lt; realname &lt;&lt; "\t: " &lt;&lt; status &lt;&lt; '\n';
-  free(realname);
-
-
   // typeid
   bar&lt;empty,17&gt;          u;
   const std::type_info  &amp;ti = typeid(u);
@@ -559,7 +551,6 @@ int main()
 
    <screen>
    <computeroutput>
-      St13bad_exception       =&gt; std::bad_exception   : 0
       3barI5emptyLi17EE       =&gt; bar&lt;empty, 17&gt;       : 0
    </computeroutput>
    </screen>
@@ -568,8 +559,8 @@ int main()
      The demangler interface is described in the source documentation
      linked to above.  It is actually written in C, so you don't need to
      be writing C++ in order to demangle C++.  (That also means we have to
-     use crummy memory management facilities, so don't forget to free()
-     the returned char array.)
+     use crummy memory management facilities, so don't forget to
+     <code>free()</code> the returned char array.)
    </para>
 </chapter>
 

commit 256c9824a5c2d8def1105f077327e097657905d0
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Fri Apr 28 00:18:57 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index faac45ae8d2..dd82014ea01 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230427
+20230428
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 1be9436b617..eaf7f85c3fc 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,101 @@
+2023-04-27  Jonathan Wakely  <jwakely@redhat.com>
+
+	Backported from master:
+	2023-04-04  Jonathan Wakely  <jwakely@redhat.com>
+
+	* doc/xml/manual/extensions.xml: Remove std::bad_exception from
+	example program.
+	* doc/html/manual/ext_demangling.html: Regenerate.
+
+2023-04-27  Jonathan Wakely  <jwakely@redhat.com>
+
+	Backported from master:
+	2023-04-27  Jonathan Wakely  <jwakely@redhat.com>
+
+	* doc/doxygen/user.cfg.in (SOURCE_BROWSER): Only set to YES for
+	HTML docs.
+	* include/bits/gslice_array.h (_DEFINE_VALARRAY_OPERATOR): Omit
+	from doxygen docs.
+	* include/bits/indirect_array.h (_DEFINE_VALARRAY_OPERATOR):
+	Likewise.
+	* include/bits/mask_array.h (_DEFINE_VALARRAY_OPERATOR):
+	Likewise.
+	* include/bits/slice_array.h (_DEFINE_VALARRAY_OPERATOR):
+	Likewise.
+	* include/std/valarray (_DEFINE_VALARRAY_UNARY_OPERATOR)
+	(_DEFINE_VALARRAY_AUGMENTED_ASSIGNMENT)
+	(_DEFINE_VALARRAY_EXPR_AUGMENTED_ASSIGNMENT)
+	(_DEFINE_BINARY_OPERATOR): Likewise.
+
+2023-04-27  Jonathan Wakely  <jwakely@redhat.com>
+
+	Backported from master:
+	2022-10-28  Jonathan Wakely  <jwakely@redhat.com>
+
+	* include/bits/fs_path.h (path::filename()): Fix dangling
+	reference.
+
+2023-04-27  Jonathan Wakely  <jwakely@redhat.com>
+
+	PR libstdc++/109064
+	* python/libstdcxx/v6/xmethods.py (SharedPtrUseCountWorker):
+	Remove self-recursion in __init__. Add missing _supports.
+	* testsuite/libstdc++-xmethods/shared_ptr.cc: Check use_count()
+	and unique().
+
+2023-04-27  Jonathan Wakely  <jwakely@redhat.com>
+
+	Backported from master:
+	2023-02-28  Jonathan Wakely  <jwakely@redhat.com>
+
+	PR libstdc++/108952
+	* include/std/memory (uses_allocator_construction_args):
+	Implement LWG 3527.
+	* testsuite/20_util/pair/astuple/get-2.cc: New test.
+	* testsuite/20_util/scoped_allocator/108952.cc: New test.
+	* testsuite/20_util/uses_allocator/lwg3527.cc: New test.
+
+2023-04-27  Jonathan Wakely  <jwakely@redhat.com>
+
+	Backported from master:
+	2023-02-16  Jonathan Wakely  <jwakely@redhat.com>
+
+	* include/experimental/optional: Fix header name in comment.
+
+2023-04-27  Jonathan Wakely  <jwakely@redhat.com>
+
+	Backported from master:
+	2022-07-20  Jonathan Wakely  <jwakely@redhat.com>
+
+	PR libstdc++/100823
+	* include/bits/stl_iterator.h (common_iterator): Define move
+	constructor and move assignment operator.
+	(common_iterator::_M_assign): New function implementing
+	assignment.
+	(common_iterator::operator=): Use _M_assign.
+	(common_iterator::_S_valueless): New constant.
+	* testsuite/24_iterators/common_iterator/100823.cc: New test.
+
+2023-04-27  Jonathan Wakely  <jwakely@redhat.com>
+
+	Backported from master:
+	2022-07-20  Jonathan Wakely  <jwakely@redhat.com>
+
+	* include/bits/stl_iterator.h (common_iterator): Fix incorrect
+	uses of is_nothrow_assignable_v. Fix inconsistent constraints on
+	friend declaration. Do not move argument in copy constructor.
+	* testsuite/24_iterators/common_iterator/1.cc: Check for
+	noexcept constructibnle/assignable.
+
+2023-04-27  Jonathan Wakely  <jwakely@redhat.com>
+
+	Backported from master:
+	2022-11-23  Jonathan Wakely  <jwakely@redhat.com>
+
+	PR libstdc++/107814
+	* testsuite/experimental/filesystem/iterators/error_reporting.cc:
+	Use a static buffer with space after it.
+
 2023-03-16  Jonathan Wakely  <jwakely@redhat.com>
 
 	Backported from master:

commit e2babb0540cfa66752214f3f111461e1da4b26ce
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Tue Nov 24 12:48:31 2020 +0000

    libstdc++: Throw instead of segfaulting in std::thread constructor [PR 67791]
    
    This turns a mysterious segfault into an exception with a more useful
    message. If the exception isn't caught, the user sees this instead of
    just a segfault:
    
    terminate called after throwing an instance of 'std::system_error'
      what():  Enable multithreading to use std::thread: Operation not permitted
    Aborted (core dumped)
    
    libstdc++-v3/ChangeLog:
    
            PR libstdc++/67791
            * src/c++11/thread.cc (thread::_M_start_thread(_State_ptr, void (*)())):
            Check that gthreads is available before calling __gthread_create.
    
    (cherry picked from commit 4bbd5d0c5fb2b7527938ad44a6d8a2f2ef8bbe12)

diff --git a/libstdc++-v3/src/c++11/thread.cc b/libstdc++-v3/src/c++11/thread.cc
index 2d8781724f2..b175ad5413e 100644
--- a/libstdc++-v3/src/c++11/thread.cc
+++ b/libstdc++-v3/src/c++11/thread.cc
@@ -132,6 +132,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   void
   thread::_M_start_thread(_State_ptr state, void (*)())
   {
+    if (!__gthread_active_p())
+      {
+#if __cpp_exceptions
+	throw system_error(make_error_code(errc::operation_not_permitted),
+			   "Enable multithreading to use std::thread");
+#else
+	__builtin_abort();
+#endif
+      }
+
     const int err = __gthread_create(&_M_id._M_thread,
 				     &execute_native_thread_routine,
 				     state.get());

commit d9713e74f8d7fb614f36b373655daf7e0925ce5c
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sat Apr 29 00:18:31 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index dd82014ea01..24dd3ed9702 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230428
+20230429
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index eaf7f85c3fc..edb95007826 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,12 @@
+2023-04-28  Jonathan Wakely  <jwakely@redhat.com>
+
+	Backported from master:
+	2020-11-24  Jonathan Wakely  <jwakely@redhat.com>
+
+	PR libstdc++/67791
+	* src/c++11/thread.cc (thread::_M_start_thread(_State_ptr, void (*)())):
+	Check that gthreads is available before calling __gthread_create.
+
 2023-04-27  Jonathan Wakely  <jwakely@redhat.com>
 
 	Backported from master:

commit 2a47cf943e888439b971e7d2d10737e3519c01f2
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sun Apr 30 00:18:21 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 24dd3ed9702..8de8e66b47c 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230429
+20230430

commit 7a7cf78000bc4f711a5c8e9383aea3bebbb2a747
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Mon May 1 00:18:31 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 8de8e66b47c..cc2a1e59ade 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230430
+20230501

commit e5ef29d162c1da273d948c86da3037d98b557de8
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Tue May 2 00:18:25 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index cc2a1e59ade..d4349ffd34f 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230501
+20230502

commit c0d51048ce1d7aa118c0ed9fdc0c7b1118188d8e
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Wed May 3 00:18:25 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index d4349ffd34f..61f8aade98f 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230502
+20230503

commit 58c396a2ce4f8f66e6c379d74e834e3c8d93f36b
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Tue Jun 21 17:51:08 2022 +0200

    libgomp: Fix up target-31.c test [PR106045]
    
    The i variable is used inside of the parallel in:
          #pragma omp simd safelen(32) private (v)
          for (i = 0; i < 64; i++)
            {
              v = 3 * i;
              ll[i] = u1 + v * u2[0] + u2[1] + x + y[0] + y[1] + v + h[0] + u3[i];
            }
    where i is predetermined linear (so while inside of the body
    it is safe, private per SIMD lane var) the final value is written to
    the shared variable, and in:
          for (i = 0; i < 64; i++)
            if (ll[i] != u1 + 3 * i * u2[0] + u2[1] + x + y[0] + y[1] + 3 * i + 13 + 14 + i)
              #pragma omp atomic write
                err = 1;
    which is a normal loop and so it isn't in any way privatized there.
    So we have a data race, fixed by adding private (i) clause to the
    parallel.
    
    2022-06-21  Jakub Jelinek  <jakub@redhat.com>
                Paul Iannetta  <piannetta@kalrayinc.com>
    
            PR libgomp/106045
            * testsuite/libgomp.c/target-31.c: Add private (i) clause.
    
    (cherry picked from commit 85d613da341b76308edea48359a5dbc7061937c4)

diff --git a/libgomp/testsuite/libgomp.c/target-31.c b/libgomp/testsuite/libgomp.c/target-31.c
index 8e63d286b43..1123b7ea561 100644
--- a/libgomp/testsuite/libgomp.c/target-31.c
+++ b/libgomp/testsuite/libgomp.c/target-31.c
@@ -76,7 +76,7 @@ main ()
       m[1] += 3 * b;
     }
     use (&a, &b, &c, &d, e, f, g, h);
-    #pragma omp parallel firstprivate (u1, u2)
+    #pragma omp parallel firstprivate (u1, u2) private (i)
     {
       int w = omp_get_thread_num ();
       int x = 19;

commit 89741783f6e7127d4d8be5a5e8e4fb7d5785f8a6
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Tue Jun 21 11:38:59 2022 +0200

    expand: Fix up expand_cond_expr_using_cmove [PR106030]
    
    If expand_cond_expr_using_cmove can't find a cmove optab for a particular
    mode, it tries to promote the mode and perform the cmove in the promoted
    mode.
    
    The testcase in the patch ICEs on arm because in that case we pass temp which
    has the promoted mode (SImode) as target to expand_operands where the
    operands have the non-promoted mode (QImode).
    Later on the function uses paradoxical subregs:
      if (GET_MODE (op1) != mode)
        op1 = gen_lowpart (mode, op1);
    
      if (GET_MODE (op2) != mode)
        op2 = gen_lowpart (mode, op2);
    to change the operand modes.
    
    The following patch fixes it by passing NULL_RTX as target if it has
    promoted mode.
    
    2022-06-21  Jakub Jelinek  <jakub@redhat.com>
    
            PR middle-end/106030
            * expr.c (expand_cond_expr_using_cmove): Pass NULL_RTX instead of
            temp to expand_operands if mode has been promoted.
    
            * gcc.c-torture/compile/pr106030.c: New test.
    
    (cherry picked from commit 2df1df945fac85d7b3d084001414a66a2709d8fe)

diff --git a/gcc/expr.c b/gcc/expr.c
index dabee814240..a904b4c9785 100644
--- a/gcc/expr.c
+++ b/gcc/expr.c
@@ -8411,7 +8411,8 @@ expand_cond_expr_using_cmove (tree treeop0 ATTRIBUTE_UNUSED,
   expanding_cond_expr_using_cmove = true;
   start_sequence ();
   expand_operands (treeop1, treeop2,
-		   temp, &op1, &op2, EXPAND_NORMAL);
+		   mode == orig_mode ? temp : NULL_RTX, &op1, &op2,
+		   EXPAND_NORMAL);
 
   if (TREE_CODE (treeop0) == SSA_NAME
       && (srcstmt = get_def_for_expr_class (treeop0, tcc_comparison)))
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr106030.c b/gcc/testsuite/gcc.c-torture/compile/pr106030.c
new file mode 100644
index 00000000000..7514b348ff9
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/compile/pr106030.c
@@ -0,0 +1,16 @@
+/* PR middle-end/106030 */
+
+int a, b, c;
+
+char
+foo (int x, int y)
+{
+  return x * y;
+}
+
+void
+bar (void)
+{
+  char d = (foo <= b) * a;
+  c = foo (2 != bar, d);
+}

commit 99d9cdbd0135b97df8c5aa9cd008683c86d42dc4
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Tue Jun 21 11:40:16 2022 +0200

    ifcvt: Don't introduce trapping or faulting reads in noce_try_sign_mask [PR106032]
    
    noce_try_sign_mask as documented will optimize
      if (c < 0)
        x = t;
      else
        x = 0;
    into x = (c >> bitsm1) & t;
    The optimization is done if either t is unconditional
    (e.g. for
      x = t;
      if (c >= 0)
        x = 0;
    ) or if it is cheap.  We already check that t doesn't have side-effects,
    but if t is conditional, we need to punt also if it may trap or fault,
    as we make it unconditional.
    
    I've briefly skimmed other noce_try* optimizations and didn't find one that
    would suffer from the same problem.
    
    2022-06-21  Jakub Jelinek  <jakub@redhat.com>
    
            PR rtl-optimization/106032
            * ifcvt.c (noce_try_sign_mask): Punt if !t_unconditional, and
            t may_trap_or_fault_p, even if it is cheap.
    
            * gcc.c-torture/execute/pr106032.c: New test.
    
    (cherry picked from commit a0c30fe3b888f20215f3e040d21b62b603804ca9)

diff --git a/gcc/ifcvt.c b/gcc/ifcvt.c
index 5fcd09fc78f..7629965a92a 100644
--- a/gcc/ifcvt.c
+++ b/gcc/ifcvt.c
@@ -2814,18 +2814,19 @@ noce_try_sign_mask (struct noce_if_info *if_info)
     return FALSE;
 
   /* This is only profitable if T is unconditionally executed/evaluated in the
-     original insn sequence or T is cheap.  The former happens if B is the
-     non-zero (T) value and if INSN_B was taken from TEST_BB, or there was no
-     INSN_B which can happen for e.g. conditional stores to memory.  For the
-     cost computation use the block TEST_BB where the evaluation will end up
-     after the transformation.  */
+     original insn sequence or T is cheap and can't trap or fault.  The former
+     happens if B is the non-zero (T) value and if INSN_B was taken from
+     TEST_BB, or there was no INSN_B which can happen for e.g. conditional
+     stores to memory.  For the cost computation use the block TEST_BB where
+     the evaluation will end up after the transformation.  */
   t_unconditional
     = (t == if_info->b
        && (if_info->insn_b == NULL_RTX
 	   || BLOCK_FOR_INSN (if_info->insn_b) == if_info->test_bb));
   if (!(t_unconditional
-	|| (set_src_cost (t, mode, if_info->speed_p)
-	    < COSTS_N_INSNS (2))))
+	|| ((set_src_cost (t, mode, if_info->speed_p)
+	     < COSTS_N_INSNS (2))
+	    && !may_trap_or_fault_p (t))))
     return FALSE;
 
   if (!noce_can_force_operand (t))
diff --git a/gcc/testsuite/gcc.c-torture/execute/pr106032.c b/gcc/testsuite/gcc.c-torture/execute/pr106032.c
new file mode 100644
index 00000000000..d2ccf6a5b52
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/execute/pr106032.c
@@ -0,0 +1,21 @@
+/* PR rtl-optimization/106032 */
+
+__attribute__((noipa)) int
+foo (int x, int *y)
+{
+  int a = 0;
+  if (x < 0)
+    a = *y;
+  return a;  
+}
+
+int
+main ()
+{
+  int a = 42;
+  if (foo (0, 0) != 0 || foo (1, 0) != 0)
+    __builtin_abort ();
+  if (foo (-1, &a) != 42 || foo (-42, &a) != 42)
+    __builtin_abort ();
+  return 0;
+}

commit 6e7bf9bc3e51d2d0d0df3d810cb20624594573cf
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Fri Jul 1 11:17:41 2022 +0200

    wide-int: Fix up wi::shifted_mask [PR106144]
    
    As the following self-test testcase shows, wi::shifted_mask sometimes
    doesn't create canonicalized wide_ints, which then fail to compare equal
    to canonicalized wide_ints with the same value.
    In particular, wi::mask (128, false, 128) gives { -1 } with len 1 and prec 128,
    while wi::shifted_mask (0, 128, false, 128) gives { -1, -1 } with len 2
    and prec 128.
    The problem is that the code is written with the assumption that there are
    3 bit blocks (or 2 if start is 0), but doesn't consider the possibility
    where there are 2 bit blocks (or 1 if start is 0) where the highest block
    isn't present.  In that case, there is the optional block of negate ? 0 : -1
    elts, followed by just one elt (either one from the if (shift) or just
    negate ? -1 : 0) and the rest is implicit sign-extension.
    Only if end < prec there is 1 or more bits above it that have different bit
    value and so we need to emit all the elts till end and then one more elt.
    
    if (end == prec) would work too, because we have:
      if (width > prec - start)
        width = prec - start;
      unsigned int end = start + width;
    so end is guaranteed to be end <= prec, dunno what is preferred.
    
    2022-07-01  Jakub Jelinek  <jakub@redhat.com>
    
            PR middle-end/106144
            * wide-int.cc (wi::shifted_mask): If end >= prec, return right after
            emitting element for shift or if shift is 0 first element after start.
            (wide_int_cc_tests): Add tests for equivalency of wi::mask and
            wi::shifted_mask with 0 start.
    
    (cherry picked from commit e52592073f6df3d7a3acd9f0436dcc32a8b7493d)

diff --git a/gcc/wide-int.cc b/gcc/wide-int.cc
index c377e68e4b9..b173d0247a5 100644
--- a/gcc/wide-int.cc
+++ b/gcc/wide-int.cc
@@ -842,6 +842,13 @@ wi::shifted_mask (HOST_WIDE_INT *val, unsigned int start, unsigned int width,
 	val[i++] = negate ? block : ~block;
     }
 
+  if (end >= prec)
+    {
+      if (!shift)
+	val[i++] = negate ? 0 : -1;
+      return i;
+    }
+
   while (i < end / HOST_BITS_PER_WIDE_INT)
     /* 1111111 */
     val[i++] = negate ? 0 : -1;
@@ -853,7 +860,7 @@ wi::shifted_mask (HOST_WIDE_INT *val, unsigned int start, unsigned int width,
       HOST_WIDE_INT block = (HOST_WIDE_INT_1U << shift) - 1;
       val[i++] = negate ? ~block : block;
     }
-  else if (end < prec)
+  else
     val[i++] = negate ? -1 : 0;
 
   return i;
@@ -2549,6 +2556,10 @@ wide_int_cc_tests ()
   run_all_wide_int_tests <widest_int> ();
   test_overflow ();
   test_round_for_mask ();
+  ASSERT_EQ (wi::mask (128, false, 128),
+	     wi::shifted_mask (0, 128, false, 128));
+  ASSERT_EQ (wi::mask (128, true, 128),
+	     wi::shifted_mask (0, 128, true, 128));
 }
 
 } // namespace selftest

commit 408fe10442aa53e2b4573abbf0536aa677c92512
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Wed Jul 27 12:06:22 2022 +0200

    cgraphunit: Don't emit asm thunks for -dx [PR106261]
    
    When -dx option is used (didn't know we have it and no idea what is it
    useful for), we just expand functions to RTL and then omit all further
    RTL passes, so the normal functions aren't actually emitted into assembly,
    just variables.
    The following testcase ICEs, because we don't emit the methods, but do
    emit thunks pointing to that and those thunks have unwind info and rely on
    at least some real functions to be emitted (which is normally the case,
    thunks are only emitted for locally defined functions) because otherwise
    there are no CIEs, only FDEs and dwarf2out is upset about it.
    
    The following patch fixes that by not emitting assembly thunks for -dx
    either.
    
    2022-07-27  Jakub Jelinek  <jakub@redhat.com>
    
            PR debug/106261
            * cgraphunit.c (cgraph_node::assemble_thunks_and_aliases): Don't
            output asm thunks for -dx.
    
            * g++.dg/debug/pr106261.C: New test.
    
    (cherry picked from commit f9671b60f9395cb1dca128b92f5dd215f5aeaae1)

diff --git a/gcc/cgraphunit.c b/gcc/cgraphunit.c
index 5071322fec0..93b45ca19a5 100644
--- a/gcc/cgraphunit.c
+++ b/gcc/cgraphunit.c
@@ -2223,7 +2223,7 @@ cgraph_node::assemble_thunks_and_aliases (void)
 	cgraph_node *thunk = e->caller;
 
 	e = e->next_caller;
-	thunk->expand_thunk (true, false);
+	thunk->expand_thunk (!rtl_dump_and_exit, false);
 	thunk->assemble_thunks_and_aliases ();
       }
     else
diff --git a/gcc/testsuite/g++.dg/debug/pr106261.C b/gcc/testsuite/g++.dg/debug/pr106261.C
new file mode 100644
index 00000000000..6dee7e68ff5
--- /dev/null
+++ b/gcc/testsuite/g++.dg/debug/pr106261.C
@@ -0,0 +1,36 @@
+// PR debug/106261
+// { dg-do compile }
+// { dg-options "-dx -fno-dwarf2-cfi-asm" }
+
+struct A
+{
+  virtual void foo ();
+  int a;
+};
+class C : virtual public A
+{
+};
+struct B
+{
+  A *b;
+
+  B (A *x) : b (x) { b->foo (); }
+};
+struct E
+{
+  virtual ~E ();
+};
+class D : public C, E
+{
+};
+struct F : D
+{
+  F (int);
+
+  static void bar ()
+  {
+    F a (0);
+    B b (&a);
+  }
+};
+void baz () { F::bar (); }

commit f0ce91c8bb7311b5e98292ee3ae323a24bbe9c09
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Tue Aug 16 13:15:32 2022 +0200

    c++: Implement P2327R1 - De-deprecating volatile compound operations
    
    From what I can see, this has been voted in as a DR and as it means
    we warn less often than before in -std={gnu,c}++2{0,3} modes or with
    -Wvolatile, I wonder if it shouldn't be backported to affected release
    branches as well.
    
    2022-08-16  Jakub Jelinek  <jakub@redhat.com>
    
            * typeck.c (cp_build_modify_expr): Implement
            P2327R1 - De-deprecating volatile compound operations.  Don't warn
            for |=, &= or ^= with volatile lhs.
            * expr.c (mark_use) <case MODIFY_EXPR>: Adjust warning wording,
            leave out simple.
    
            * g++.dg/cpp2a/volatile1.C: Adjust for de-deprecation of volatile
            compound |=, &= and ^= operations.
            * g++.dg/cpp2a/volatile3.C: Likewise.
            * g++.dg/cpp2a/volatile5.C: Likewise.
    
    (cherry picked from commit 6e790ca4615443fa395ac5cdba1ab6c87810985c)

diff --git a/gcc/cp/expr.c b/gcc/cp/expr.c
index 6a7569418b1..9214e3dfd05 100644
--- a/gcc/cp/expr.c
+++ b/gcc/cp/expr.c
@@ -222,7 +222,7 @@ mark_use (tree expr, bool rvalue_p, bool read_p,
     case MODIFY_EXPR:
 	{
 	  tree lhs = TREE_OPERAND (expr, 0);
-	  /* [expr.ass] "A simple assignment whose left operand is of
+	  /* [expr.ass] "An assignment whose left operand is of
 	     a volatile-qualified type is deprecated unless the assignment
 	     is either a discarded-value expression or appears in an
 	     unevaluated context."  */
@@ -232,7 +232,7 @@ mark_use (tree expr, bool rvalue_p, bool read_p,
 	      && !TREE_THIS_VOLATILE (expr))
 	    {
 	      if (warning_at (location_of (expr), OPT_Wvolatile,
-			      "using value of simple assignment with "
+			      "using value of assignment with "
 			      "%<volatile%>-qualified left operand is "
 			      "deprecated"))
 		/* Make sure not to warn about this assignment again.  */
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index 35bd3c8b056..def6442779d 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -8600,10 +8600,14 @@ cp_build_modify_expr (location_t loc, tree lhs, enum tree_code modifycode,
 
 	  /* An expression of the form E1 op= E2.  [expr.ass] says:
 	     "Such expressions are deprecated if E1 has volatile-qualified
-	     type."  We warn here rather than in cp_genericize_r because
+	     type and op is not one of the bitwise operators |, &, ^."
+	     We warn here rather than in cp_genericize_r because
 	     for compound assignments we are supposed to warn even if the
 	     assignment is a discarded-value expression.  */
-	  if (TREE_THIS_VOLATILE (lhs) || CP_TYPE_VOLATILE_P (lhstype))
+	  if (modifycode != BIT_AND_EXPR
+	      && modifycode != BIT_IOR_EXPR
+	      && modifycode != BIT_XOR_EXPR
+	      && (TREE_THIS_VOLATILE (lhs) || CP_TYPE_VOLATILE_P (lhstype)))
 	    warning_at (loc, OPT_Wvolatile,
 			"compound assignment with %<volatile%>-qualified left "
 			"operand is deprecated");
diff --git a/gcc/testsuite/g++.dg/cpp2a/volatile1.C b/gcc/testsuite/g++.dg/cpp2a/volatile1.C
index e47591b13bc..2f38765f53b 100644
--- a/gcc/testsuite/g++.dg/cpp2a/volatile1.C
+++ b/gcc/testsuite/g++.dg/cpp2a/volatile1.C
@@ -56,6 +56,9 @@ fn2 ()
   vi = i;
   vi = i = 42;
   i = vi = 42; // { dg-warning "assignment with .volatile.-qualified left operand is deprecated" "" { target c++2a } }
+  i = vi |= 42; // { dg-warning "using value of assignment with .volatile.-qualified left operand is deprecated" "" { target c++2a } }
+  i = vi &= 42; // { dg-warning "using value of assignment with .volatile.-qualified left operand is deprecated" "" { target c++2a } }
+  i = vi ^= 42; // { dg-warning "using value of assignment with .volatile.-qualified left operand is deprecated" "" { target c++2a } }
   &(vi = i); // { dg-warning "assignment with .volatile.-qualified left operand is deprecated" "" { target c++2a } }
   (vi = 42, 45);
   (i = vi = 42, 10); // { dg-warning "assignment with .volatile.-qualified left operand is deprecated" "" { target c++2a } }
@@ -74,8 +77,9 @@ fn2 ()
   vi += i; // { dg-warning "assignment with .volatile.-qualified left operand is deprecated" "" { target c++2a } }
   vi -= i; // { dg-warning "assignment with .volatile.-qualified left operand is deprecated" "" { target c++2a } }
   vi %= i; // { dg-warning "assignment with .volatile.-qualified left operand is deprecated" "" { target c++2a } }
-  vi ^= i; // { dg-warning "assignment with .volatile.-qualified left operand is deprecated" "" { target c++2a } }
-  vi |= i; // { dg-warning "assignment with .volatile.-qualified left operand is deprecated" "" { target c++2a } }
+  vi ^= i; // { dg-bogus "assignment with .volatile.-qualified left operand is deprecated" }
+  vi |= i; // { dg-bogus "assignment with .volatile.-qualified left operand is deprecated" }
+  vi &= i; // { dg-bogus "assignment with .volatile.-qualified left operand is deprecated" }
   vi /= i; // { dg-warning "assignment with .volatile.-qualified left operand is deprecated" "" { target c++2a } }
   vi = vi += 42; // { dg-warning "assignment with .volatile.-qualified left operand is deprecated" "" { target c++2a } }
   vi += vi = 42; // { dg-warning "assignment with .volatile.-qualified left operand is deprecated" "" { target c++2a } }
@@ -131,7 +135,8 @@ void raccoon ()
   volatile T t, u;
   t = 42;
   u = t = 42; // { dg-warning "assignment with .volatile.-qualified left operand is deprecated" "" { target c++2a } }
-  t &= 42; // { dg-warning "assignment with .volatile.-qualified left operand is deprecated" "" { target c++2a } }
+  t += 42; // { dg-warning "assignment with .volatile.-qualified left operand is deprecated" "" { target c++2a } }
+  t &= 42; // { dg-bogus "assignment with .volatile.-qualified left operand is deprecated" }
 }
 
 void
diff --git a/gcc/testsuite/g++.dg/cpp2a/volatile3.C b/gcc/testsuite/g++.dg/cpp2a/volatile3.C
index f10a29756a9..58816dc3084 100644
--- a/gcc/testsuite/g++.dg/cpp2a/volatile3.C
+++ b/gcc/testsuite/g++.dg/cpp2a/volatile3.C
@@ -57,6 +57,9 @@ fn2 ()
   vi = i;
   vi = i = 42;
   i = vi = 42; // { dg-warning "assignment with .volatile.-qualified left operand is deprecated" }
+  i = vi |= 42; // { dg-warning "using value of assignment with .volatile.-qualified left operand is deprecated" }
+  i = vi &= 42; // { dg-warning "using value of assignment with .volatile.-qualified left operand is deprecated" }
+  i = vi ^= 42; // { dg-warning "using value of assignment with .volatile.-qualified left operand is deprecated" }
   &(vi = i); // { dg-warning "assignment with .volatile.-qualified left operand is deprecated" }
   (vi = 42, 45);
   (i = vi = 42, 10); // { dg-warning "assignment with .volatile.-qualified left operand is deprecated" }
@@ -75,8 +78,9 @@ fn2 ()
   vi += i; // { dg-warning "assignment with .volatile.-qualified left operand is deprecated" }
   vi -= i; // { dg-warning "assignment with .volatile.-qualified left operand is deprecated" }
   vi %= i; // { dg-warning "assignment with .volatile.-qualified left operand is deprecated" }
-  vi ^= i; // { dg-warning "assignment with .volatile.-qualified left operand is deprecated" }
-  vi |= i; // { dg-warning "assignment with .volatile.-qualified left operand is deprecated" }
+  vi ^= i; // { dg-bogus "assignment with .volatile.-qualified left operand is deprecated" }
+  vi |= i; // { dg-bogus "assignment with .volatile.-qualified left operand is deprecated" }
+  vi &= i; // { dg-bogus "assignment with .volatile.-qualified left operand is deprecated" }
   vi /= i; // { dg-warning "assignment with .volatile.-qualified left operand is deprecated" }
   vi = vi += 42; // { dg-warning "assignment with .volatile.-qualified left operand is deprecated" }
   vi += vi = 42; // { dg-warning "assignment with .volatile.-qualified left operand is deprecated" }
@@ -132,7 +136,8 @@ void raccoon ()
   volatile T t, u;
   t = 42;
   u = t = 42; // { dg-warning "assignment with .volatile.-qualified left operand is deprecated" }
-  t &= 42; // { dg-warning "assignment with .volatile.-qualified left operand is deprecated" }
+  t += 42; // { dg-warning "assignment with .volatile.-qualified left operand is deprecated" }
+  t &= 42; // { dg-bogus "assignment with .volatile.-qualified left operand is deprecated" }
 }
 
 void
diff --git a/gcc/testsuite/g++.dg/cpp2a/volatile5.C b/gcc/testsuite/g++.dg/cpp2a/volatile5.C
index 1f9d23845b4..3684be9837e 100644
--- a/gcc/testsuite/g++.dg/cpp2a/volatile5.C
+++ b/gcc/testsuite/g++.dg/cpp2a/volatile5.C
@@ -8,8 +8,8 @@ f (bool b)
 {
   (b ? x : y) = 1;
   (b ? x : y) += 1; // { dg-warning "compound assignment" "" { target c++20 } }
-  z = (b ? x : y) = 1; // { dg-warning "using value of simple assignment" "" { target c++20 } }
-  ((z = 2) ? x : y) = 1; // { dg-warning "using value of simple assignment" "" { target c++20 } }
-  (b ? (x = 2) : y) = 1; // { dg-warning "using value of simple assignment" "" { target c++20 } }
-  (b ? x : (y = 5)) = 1; // { dg-warning "using value of simple assignment" "" { target c++20 } }
+  z = (b ? x : y) = 1; // { dg-warning "using value of assignment" "" { target c++20 } }
+  ((z = 2) ? x : y) = 1; // { dg-warning "using value of assignment" "" { target c++20 } }
+  (b ? (x = 2) : y) = 1; // { dg-warning "using value of assignment" "" { target c++20 } }
+  (b ? x : (y = 5)) = 1; // { dg-warning "using value of assignment" "" { target c++20 } }
 }

commit 7cdefaee48af5d203560091bd37aad206df683b9
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Sat Sep 24 09:19:26 2022 +0200

    openmp, c: Tighten up c_tree_equal [PR106981]
    
    This patch changes c_tree_equal to work more like cp_tree_equal, be
    more strict in what it accepts.  The ICE on the first testcase was
    due to INTEGER_CST wi::wide (t1) == wi::wide (t2) comparison which
    ICEs if the two constants have different precision, but as the second
    testcase shows, being too lenient in it can also lead to miscompilation
    of valid OpenMP programs where we think certain expression is the same
    even when it isn't and can be guaranteed at runtime to represent different
    memory location.  So, the patch looks through only NON_LVALUE_EXPRs
    and for constants as well as casts requires that the types match before
    actually comparing the constant values or recursing on the cast operands.
    
    2022-09-24  Jakub Jelinek  <jakub@redhat.com>
    
            PR c/106981
    gcc/c/
            * c-typeck.c (c_tree_equal): Only strip NON_LVALUE_EXPRs at the
            start.  For CONSTANT_CLASS_P or CASE_CONVERT: return false if t1 and
            t2 have different types.
    gcc/testsuite/
            * c-c++-common/gomp/pr106981.c: New test.
    libgomp/
            * testsuite/libgomp.c-c++-common/pr106981.c: New test.
    
    (cherry picked from commit 3c5bccb608c665ac3f62adb1817c42c845812428)

diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c
index 1892d93fb75..3b0cc4f1b63 100644
--- a/gcc/c/c-typeck.c
+++ b/gcc/c/c-typeck.c
@@ -15360,14 +15360,10 @@ c_tree_equal (tree t1, tree t2)
   if (!t1 || !t2)
     return false;
 
-  for (code1 = TREE_CODE (t1);
-       CONVERT_EXPR_CODE_P (code1)
-	 || code1 == NON_LVALUE_EXPR;
+  for (code1 = TREE_CODE (t1); code1 == NON_LVALUE_EXPR;
        code1 = TREE_CODE (t1))
     t1 = TREE_OPERAND (t1, 0);
-  for (code2 = TREE_CODE (t2);
-       CONVERT_EXPR_CODE_P (code2)
-	 || code2 == NON_LVALUE_EXPR;
+  for (code2 = TREE_CODE (t2); code2 == NON_LVALUE_EXPR;
        code2 = TREE_CODE (t2))
     t2 = TREE_OPERAND (t2, 0);
 
@@ -15378,6 +15374,9 @@ c_tree_equal (tree t1, tree t2)
   if (code1 != code2)
     return false;
 
+  if (CONSTANT_CLASS_P (t1) && !comptypes (TREE_TYPE (t1), TREE_TYPE (t2)))
+    return false;
+
   switch (code1)
     {
     case INTEGER_CST:
@@ -15497,6 +15496,11 @@ c_tree_equal (tree t1, tree t2)
 	return true;
       }
 
+    CASE_CONVERT:
+      if (!comptypes (TREE_TYPE (t1), TREE_TYPE (t2)))
+	return false;
+      break;
+
     default:
       break;
     }
diff --git a/gcc/testsuite/c-c++-common/gomp/pr106981.c b/gcc/testsuite/c-c++-common/gomp/pr106981.c
new file mode 100644
index 00000000000..a21d3c2029d
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/gomp/pr106981.c
@@ -0,0 +1,9 @@
+/* PR c/106981 */
+/* { dg-do compile } */
+
+void
+foo (int a, double *b, double *c, double *d, long long e)
+{
+#pragma omp atomic capture
+  c[a] = d[((int) (e / 10 + 1))] = b[a] + d[((int) e / 10 + 1)];	/* { dg-error "invalid form" } */
+}
diff --git a/libgomp/testsuite/libgomp.c-c++-common/pr106981.c b/libgomp/testsuite/libgomp.c-c++-common/pr106981.c
new file mode 100644
index 00000000000..ed48d2774f2
--- /dev/null
+++ b/libgomp/testsuite/libgomp.c-c++-common/pr106981.c
@@ -0,0 +1,19 @@
+/* PR c/106981 */
+
+int
+main ()
+{
+  int a[0x101];
+  unsigned int b = 0x100;
+  if ((unsigned char) b || (unsigned short) b != 0x100)
+    return 0;
+  a[0] = 0;
+  a[0x100] = 42;
+  #pragma omp atomic update
+  a[(unsigned char) b] = a[(unsigned short) b] + a[(unsigned char) b];
+  #pragma omp atomic update
+  a[(unsigned char) b] = a[(unsigned char) b] + a[(unsigned short) b];
+  if (a[0] != 84 || a[0x100] != 42)
+    __builtin_abort ();
+  return 0;
+}

commit 8629045a50bbc37d25fe9203c810a96ef96ef0f7
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Sat Sep 24 09:24:26 2022 +0200

    openmp: Fix ICE with taskgroup at -O0 -fexceptions [PR107001]
    
    The following testcase ICEs because with -O0 -fexceptions GOMP_taskgroup_end
    call isn't directly followed by GOMP_RETURN statement, but there are some
    conditionals to handle exceptions and we fail to find the correct GOMP_RETURN.
    
    The fix is to treat taskgroup similarly to target data, both of these constructs
    emit a try { body } finally { end_call } around the construct's body during
    gimplification and we need to see proper construct nesting during gimplification
    and omp lowering (including nesting of regions checks), but during omp expansion
    we don't really need their nesting anymore, all we need is emit something at
    the start of the region and the end of the region is the end API call we've
    already emitted during gimplification.  For target data, we weren't adding
    GOMP_RETURN statement during omp lowering, so after that pass it is treated
    merely like stand-alone omp directives.  This patch does the same for
    taskgroup too.
    
    2022-09-24  Jakub Jelinek  <jakub@redhat.com>
    
            PR c/107001
            * omp-low.c (lower_omp_taskgroup): Don't add GOMP_RETURN statement
            at the end.
            * omp-expand.c (build_omp_regions_1): Clarify GF_OMP_TARGET_KIND_DATA
            is not stand-alone directive.  For GIMPLE_OMP_TASKGROUP, also don't
            update parent.
            (omp_make_gimple_edges) <case GIMPLE_OMP_TASKGROUP>: Reset
            cur_region back after new_omp_region.
    
            * c-c++-common/gomp/pr107001.c: New test.
    
    (cherry picked from commit ad2aab5c816a6fd56b46210c0a4a4c6243da1de9)

diff --git a/gcc/omp-expand.c b/gcc/omp-expand.c
index af4059cc2ab..3ca9300d41a 100644
--- a/gcc/omp-expand.c
+++ b/gcc/omp-expand.c
@@ -8973,7 +8973,10 @@ build_omp_regions_1 (basic_block bb, struct omp_region *parent,
 		case GF_OMP_TARGET_KIND_OACC_UPDATE:
 		case GF_OMP_TARGET_KIND_OACC_ENTER_EXIT_DATA:
 		case GF_OMP_TARGET_KIND_OACC_DECLARE:
-		  /* ..., other than for those stand-alone directives...  */
+		  /* ..., other than for those stand-alone directives...
+		     To be precise, target data isn't stand-alone, but
+		     gimplifier put the end API call into try finally block
+		     for it, so omp expansion can treat it as such.  */
 		  region = NULL;
 		  break;
 		default:
@@ -8991,6 +8994,11 @@ build_omp_regions_1 (basic_block bb, struct omp_region *parent,
 		   && gimple_omp_task_taskwait_p (stmt))
 	    /* #pragma omp taskwait depend(...) is a stand-alone directive.  */
 	    region = NULL;
+	  else if (code == GIMPLE_OMP_TASKGROUP)
+	    /* #pragma omp taskgroup isn't a stand-alone directive, but
+	       gimplifier put the end API call into try finall block
+	       for it, so omp expansion can treat it as such.  */
+	    region = NULL;
 	  /* ..., this directive becomes the parent for a new region.  */
 	  if (region)
 	    parent = region;
@@ -9185,7 +9193,6 @@ omp_make_gimple_edges (basic_block bb, struct omp_region **region,
     case GIMPLE_OMP_SINGLE:
     case GIMPLE_OMP_TEAMS:
     case GIMPLE_OMP_MASTER:
-    case GIMPLE_OMP_TASKGROUP:
     case GIMPLE_OMP_CRITICAL:
     case GIMPLE_OMP_SECTION:
     case GIMPLE_OMP_GRID_BODY:
@@ -9193,6 +9200,12 @@ omp_make_gimple_edges (basic_block bb, struct omp_region **region,
       fallthru = true;
       break;
 
+    case GIMPLE_OMP_TASKGROUP:
+      cur_region = new_omp_region (bb, code, cur_region);
+      fallthru = true;
+      cur_region = cur_region->outer;
+      break;
+
     case GIMPLE_OMP_TASK:
       cur_region = new_omp_region (bb, code, cur_region);
       fallthru = true;
diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index f9aa3930803..0b367998ce7 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -8833,7 +8833,6 @@ lower_omp_taskgroup (gimple_stmt_iterator *gsi_p, omp_context *ctx)
   gimple_bind_add_seq (bind, gimple_omp_body (stmt));
   gimple_omp_set_body (stmt, NULL);
 
-  gimple_bind_add_stmt (bind, gimple_build_omp_return (true));
   gimple_bind_add_seq (bind, dseq);
 
   pop_gimplify_context (bind);
diff --git a/gcc/testsuite/c-c++-common/gomp/pr107001.c b/gcc/testsuite/c-c++-common/gomp/pr107001.c
new file mode 100644
index 00000000000..9c19d9b8745
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/gomp/pr107001.c
@@ -0,0 +1,14 @@
+/* PR c/107001 */
+/* { dg-do compile } */
+/* { dg-options "-O0 -fopenmp -fexceptions" } */
+/* { dg-require-effective-target exceptions } */
+
+void bar (void);
+void foo (void)
+{
+  #pragma omp taskgroup
+  {
+    #pragma omp taskgroup
+    bar ();
+  }
+}

commit 6d15acadb95c91bd6154b4e3f9b99e7af2fa46cb
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Wed Oct 12 17:54:08 2022 +0200

    libgomp: Fix up creation of artificial teams
    
    When not in explicit parallel/target/teams construct, we in some cases create
    an artificial parallel with a single thread (either to handle target nowait
    or for task reduction purposes).  In those cases, it handled again artificially
    created implicit task (created by gomp_new_icv for cases where we needed to write
    to some ICVs), but as the testcases show, didn't take into account possibility
    of this being done from explicit task(s).  The code would destroy/free the previous
    task and replace it with the new implicit task.  If task is an explicit task
    (when teams is NULL, all explicit tasks behave like if (0)), it is a pointer to
    a local stack variable, so freeing it doesn't work, and additionally we shouldn't
    lose the explicit tasks - the new implicit task should instead replace the
    ancestor task which is the first implicit one.
    
    2022-10-12  Jakub Jelinek  <jakub@redhat.com>
    
            * task.c (gomp_create_artificial_team): Fix up handling of invocations
            from within explicit task.
            * target.c (GOMP_target_ext): Likewise.
            * testsuite/libgomp.c/task-7.c: New test.
            * testsuite/libgomp.c/task-8.c: New test.
            * testsuite/libgomp.c-c++-common/task-reduction-17.c: New test.
            * testsuite/libgomp.c-c++-common/task-reduction-18.c: New test.
    
    (cherry picked from commit a58a965eb73253759f6a3e1c7380392557da89c8)

diff --git a/libgomp/target.c b/libgomp/target.c
index 3e292eb8c62..42d700ae465 100644
--- a/libgomp/target.c
+++ b/libgomp/target.c
@@ -2064,6 +2064,7 @@ GOMP_target_ext (int device, void (*fn) (void *), size_t mapnum,
 	{
 	  struct gomp_team *team = gomp_new_team (1);
 	  struct gomp_task *task = thr->task;
+	  struct gomp_task **implicit_task = &task;
 	  struct gomp_task_icv *icv = task ? &task->icv : &gomp_global_icv;
 	  team->prev_ts = thr->ts;
 	  thr->ts.team = team;
@@ -2076,15 +2077,23 @@ GOMP_target_ext (int device, void (*fn) (void *), size_t mapnum,
 	  thr->ts.static_trip = 0;
 	  thr->task = &team->implicit_task[0];
 	  gomp_init_task (thr->task, NULL, icv);
-	  if (task)
+	  while (*implicit_task
+		 && (*implicit_task)->kind != GOMP_TASK_IMPLICIT)
+	    implicit_task = &(*implicit_task)->parent;
+	  if (*implicit_task)
 	    {
-	      thr->task = task;
+	      thr->task = *implicit_task;
 	      gomp_end_task ();
-	      free (task);
+	      free (*implicit_task);
 	      thr->task = &team->implicit_task[0];
 	    }
 	  else
 	    pthread_setspecific (gomp_thread_destructor, thr);
+	  if (implicit_task != &task)
+	    {
+	      *implicit_task = thr->task;
+	      thr->task = task;
+	    }
 	}
       if (thr->ts.team
 	  && !thr->task->final_task)
diff --git a/libgomp/task.c b/libgomp/task.c
index dc64b9a67f6..ba5481f3329 100644
--- a/libgomp/task.c
+++ b/libgomp/task.c
@@ -2116,6 +2116,7 @@ gomp_create_artificial_team (void)
   struct gomp_task_icv *icv;
   struct gomp_team *team = gomp_new_team (1);
   struct gomp_task *task = thr->task;
+  struct gomp_task **implicit_task = &task;
   icv = task ? &task->icv : &gomp_global_icv;
   team->prev_ts = thr->ts;
   thr->ts.team = team;
@@ -2128,17 +2129,25 @@ gomp_create_artificial_team (void)
   thr->ts.static_trip = 0;
   thr->task = &team->implicit_task[0];
   gomp_init_task (thr->task, NULL, icv);
-  if (task)
+  while (*implicit_task
+	 && (*implicit_task)->kind != GOMP_TASK_IMPLICIT)
+    implicit_task = &(*implicit_task)->parent;
+  if (*implicit_task)
     {
-      thr->task = task;
+      thr->task = *implicit_task;
       gomp_end_task ();
-      free (task);
+      free (*implicit_task);
       thr->task = &team->implicit_task[0];
     }
 #ifdef LIBGOMP_USE_PTHREADS
   else
     pthread_setspecific (gomp_thread_destructor, thr);
 #endif
+  if (implicit_task != &task)
+    {
+      *implicit_task = thr->task;
+      thr->task = task;
+    }
 }
 
 /* The format of data is:
diff --git a/libgomp/testsuite/libgomp.c-c++-common/task-reduction-17.c b/libgomp/testsuite/libgomp.c-c++-common/task-reduction-17.c
new file mode 100644
index 00000000000..4a8d1e8bb73
--- /dev/null
+++ b/libgomp/testsuite/libgomp.c-c++-common/task-reduction-17.c
@@ -0,0 +1,36 @@
+/* { dg-do run } */
+
+#include <omp.h>
+#include <stdlib.h>
+
+int a;
+
+int
+main ()
+{
+  #pragma omp task final (1)
+  {
+    if (!omp_in_final ())
+      abort ();
+    #pragma omp task
+    {
+      if (!omp_in_final ())
+	abort ();
+      #pragma omp taskgroup task_reduction (+: a)
+      {
+	if (!omp_in_final ())
+	  abort ();
+	#pragma omp task in_reduction (+: a)
+	{
+	  ++a;
+	  if (!omp_in_final ())
+	    abort ();
+	}
+      }
+      if (!omp_in_final ())
+	abort ();
+      #pragma omp taskwait
+    }
+  }
+  return 0;
+}
diff --git a/libgomp/testsuite/libgomp.c-c++-common/task-reduction-18.c b/libgomp/testsuite/libgomp.c-c++-common/task-reduction-18.c
new file mode 100644
index 00000000000..483f4406f6f
--- /dev/null
+++ b/libgomp/testsuite/libgomp.c-c++-common/task-reduction-18.c
@@ -0,0 +1,17 @@
+/* { dg-do run } */
+
+int a;
+
+int
+main ()
+{
+  #pragma omp task
+  {
+    #pragma omp taskgroup task_reduction (+: a)
+    {
+      #pragma omp task in_reduction (+: a)
+      ++a;
+    }
+  }
+  return 0;
+}
diff --git a/libgomp/testsuite/libgomp.c/task-7.c b/libgomp/testsuite/libgomp.c/task-7.c
new file mode 100644
index 00000000000..0307575f978
--- /dev/null
+++ b/libgomp/testsuite/libgomp.c/task-7.c
@@ -0,0 +1,26 @@
+/* { dg-do run } */
+
+#include <omp.h>
+#include <stdlib.h>
+
+int
+main ()
+{
+  #pragma omp task final (1)
+  {
+    if (!omp_in_final ())
+      abort ();
+    #pragma omp task
+    {
+      if (!omp_in_final ())
+	abort ();
+      #pragma omp target nowait
+      if (omp_in_final ())
+	abort ();
+      if (!omp_in_final ())
+	abort ();
+      #pragma omp taskwait
+    }
+  }
+  return 0;
+}
diff --git a/libgomp/testsuite/libgomp.c/task-8.c b/libgomp/testsuite/libgomp.c/task-8.c
new file mode 100644
index 00000000000..f03aef6a030
--- /dev/null
+++ b/libgomp/testsuite/libgomp.c/task-8.c
@@ -0,0 +1,14 @@
+/* { dg-do run } */
+
+int
+main ()
+{
+  int i = 0;
+  #pragma omp task
+  {
+    #pragma omp target nowait private (i)
+    i = 1;
+    #pragma omp taskwait
+  }
+  return 0;
+}

commit 11bf3345c74139c05c405d3e5bc73ee8d9e7d6a6
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Mon Oct 24 16:25:29 2022 +0200

    c++: Fix up constexpr handling of char/signed char/short pre/post inc/decrement [PR105774]
    
    signed char, char or short int pre/post inc/decrement are represented by
    normal {PRE,POST}_{INC,DEC}REMENT_EXPRs in the FE and only gimplification
    ensures that the {PLUS,MINUS}_EXPR is done in unsigned version of those
    types:
        case PREINCREMENT_EXPR:
        case PREDECREMENT_EXPR:
        case POSTINCREMENT_EXPR:
        case POSTDECREMENT_EXPR:
          {
            tree type = TREE_TYPE (TREE_OPERAND (*expr_p, 0));
            if (INTEGRAL_TYPE_P (type) && c_promoting_integer_type_p (type))
              {
                if (!TYPE_OVERFLOW_WRAPS (type))
                  type = unsigned_type_for (type);
                return gimplify_self_mod_expr (expr_p, pre_p, post_p, 1, type);
              }
            break;
          }
    This means during constant evaluation we need to do it similarly (either
    using unsigned_type_for or using widening to integer_type_node).
    The following patch does the latter.
    
    2022-10-24  Jakub Jelinek  <jakub@redhat.com>
    
            PR c++/105774
            * constexpr.c (cxx_eval_increment_expression): For signed types
            that promote to int, evaluate PLUS_EXPR or MINUS_EXPR in int type.
    
            * g++.dg/cpp1y/constexpr-105774.C: New test.
    
    (cherry picked from commit da8c362c4c18cff2f2dfd5c4706bdda7576899a4)

diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c
index 369920eda90..62cb2c5e06a 100644
--- a/gcc/cp/constexpr.c
+++ b/gcc/cp/constexpr.c
@@ -5248,6 +5248,18 @@ cxx_eval_increment_expression (const constexpr_ctx *ctx, tree t,
 	offset = fold_build1 (NEGATE_EXPR, TREE_TYPE (offset), offset);
       mod = fold_build2 (POINTER_PLUS_EXPR, type, val, offset);
     }
+  else if (c_promoting_integer_type_p (type)
+	   && !TYPE_UNSIGNED (type)
+	   && TYPE_PRECISION (type) < TYPE_PRECISION (integer_type_node))
+    {
+      offset = fold_convert (integer_type_node, offset);
+      mod = fold_convert (integer_type_node, val);
+      tree t = fold_build2 (inc ? PLUS_EXPR : MINUS_EXPR, integer_type_node,
+			    mod, offset);
+      mod = fold_convert (type, t);
+      if (TREE_OVERFLOW_P (mod) && !TREE_OVERFLOW_P (t))
+	TREE_OVERFLOW (mod) = false;
+    }
   else
     mod = fold_build2 (inc ? PLUS_EXPR : MINUS_EXPR, type, val, offset);
   if (!ptr)
diff --git a/gcc/testsuite/g++.dg/cpp1y/constexpr-105774.C b/gcc/testsuite/g++.dg/cpp1y/constexpr-105774.C
new file mode 100644
index 00000000000..8ca6fce7570
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1y/constexpr-105774.C
@@ -0,0 +1,15 @@
+// PR c++/105774
+// { dg-do compile { target c++14 } }
+
+constexpr signed char
+foo ()
+{
+#if __SCHAR_MAX__ < __INT_MAX__
+  signed char x = __SCHAR_MAX__;
+#else
+  signed char x = 0;
+#endif
+  return ++x;
+}
+
+constexpr auto a = foo ();

commit 16bdaf29ff9df3c3c70ecc07bb37511d456d05c6
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Mon Oct 24 17:53:16 2022 +0200

    c, c++: Fix up excess precision handling of scalar_to_vector conversion [PR107358]
    
    As mentioned earlier in the C++ excess precision support mail, the following
    testcase is broken with excess precision both in C and C++ (though just in C++
    it was triggered in real-world code).
    scalar_to_vector is called in both FEs after the excess precision promotions
    (or stripping of EXCESS_PRECISION_EXPR), so we can then get invalid
    diagnostics that say float vector + float involves truncation (on ia32
    from long double to float).
    
    The following patch fixes that by calling scalar_to_vector on the operands
    before the excess precision promotions, let scalar_to_vector just do the
    diagnostics (it does e.g. fold_for_warn so it will fold
    EXCESS_PRECISION_EXPR around REAL_CST to constants etc.) but will then
    do the actual conversions using the excess precision promoted operands
    (so say if we have vector double + (float + float) we don't actually do
    vector double + (float) ((long double) float + (long double) float)
    but
    vector double + (double) ((long double) float + (long double) float)
    
    2022-10-24  Jakub Jelinek  <jakub@redhat.com>
    
            PR c++/107358
    gcc/c/
            * c-typeck.c (build_binary_op): Pass operands before excess precision
            promotions to scalar_to_vector call.
    gcc/testsuite/
            * c-c++-common/pr107358.c: New test.
    
    (cherry picked from commit 65e3274e363cb2c6bfe6b5e648916eb7696f7e2f)

diff --git a/gcc/c/c-typeck.c b/gcc/c/c-typeck.c
index 3b0cc4f1b63..fbcbcc9f481 100644
--- a/gcc/c/c-typeck.c
+++ b/gcc/c/c-typeck.c
@@ -11706,8 +11706,8 @@ build_binary_op (location_t location, enum tree_code code,
   if ((gnu_vector_type_p (type0) && code1 != VECTOR_TYPE)
       || (gnu_vector_type_p (type1) && code0 != VECTOR_TYPE))
     {
-      enum stv_conv convert_flag = scalar_to_vector (location, code, op0, op1,
-						     true);
+      enum stv_conv convert_flag = scalar_to_vector (location, code, orig_op0,
+						     orig_op1, true);
 
       switch (convert_flag)
 	{
diff --git a/gcc/testsuite/c-c++-common/pr107358.c b/gcc/testsuite/c-c++-common/pr107358.c
new file mode 100644
index 00000000000..d976da7393a
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/pr107358.c
@@ -0,0 +1,30 @@
+/* PR c++/107358 */
+/* { dg-do compile { target c } } */
+/* { dg-options "-O2 -fexcess-precision=standard" } */
+
+typedef float __attribute__((vector_size (4 * sizeof (float)))) A;
+typedef double __attribute__((vector_size (2 * sizeof (double)))) B;
+
+void
+foo (A *x)
+{
+  *x = *x - 124.225514990f;
+}
+
+void
+bar (A *x, float y)
+{
+  *x = *x - y;
+}
+
+void
+baz (B *x)
+{
+  *x = *x + 124.225514990f;
+}
+
+void
+qux (B *x, double y)
+{
+  *x = *x + y;
+}

commit 2c83256249624cdf6feae6814cc31ef2cd94c185
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Sun Nov 20 17:42:42 2022 +0100

    reg-stack: Fix a -fcompare-debug bug in reg-stack [PR107183]
    
    As the following testcase shows, the swap_rtx_condition function
    in reg-stack can result in different code generation between -g and -g0.
    The function is doing the changes as it goes, so does analysis and
    changes together, which makes it harder to deal with DEBUG_INSNs,
    where normally analysis phase ignores them and the later phase
    doesn't.
    swap_rtx_condition walks instructions two different ways, one is
    using next_flags_user function which stops on non-call instructions
    that mention the flags register, and the other is a loop on fnstsw
    where it stops on instructions mentioning it and tries to find
    sahf instruction that uses it (in both cases calls stop it and so
    does end of basic block).
    Now both of these currently stop on DEBUG_INSNs that mention
    the flags register resp. the fnstsw result register.
    On success the function recurses on next flags user instruction
    if still live and if the recursion failed, reverts the changes
    it did too and fails.
    If it were just for the next_flags_user case, the fix could be
    just not doing
          INSN_CODE (insn) = -1;
          if (recog_memoized (insn) == -1)
            fail = 1;
    on DEBUG_INSNs (assuming all changes to those are fine),
    swap_rtx_condition_1 just changes one comparison to a different
    one.  But due to the possibility of fnstsw result being used
    in theory before sahf in some DEBUG_INSNs, this patch takes
    a different approach.  swap_rtx_condition has now a new argument
    and two modes.  The first mode is when debug_seen is >= 0, in this
    case both next_flags_user and the loop for fnstsw -> sahf will
    ignore but note DEBUG_INSNs (that mention flags register or fnstsw
    result).  If no such DEBUG_INSN is found during the whole call
    including recursive invocations (so e.g. for -g0 but probably most
    often for -g as well), it behaves as before, if it returns true
    all the changes are done and nothing further needs to be done later.
    If any DEBUG_INSNs are seen along the way, even when returning success
    all the changes are reverted, so it just reports that the function
    would be successful if DEBUG_INSNs were ignored.
    In this case, compare_for_stack_reg needs to call it again in
    debug_seen = -1 mode, which tells the function to update everything
    including DEBUG_INSNs.  For the fnstsw -> sahf case which I hope
    will be very rare I just reset the DEBUG_INSNs, I don't really
    know how to express it easily otherwise.  For the rest
    swap_rtx_condition_1 is done even on the DEBUG_INSNs.
    
    2022-11-20  Jakub Jelinek  <jakub@redhat.com>
    
            PR target/107183
            * reg-stack.c (next_flags_user): Add DEBUG_SEEN argument.
            If >= 0 and a DEBUG_INSN would be otherwise returned, set
            DEBUG_SEEN to 1 and ignore it.
            (swap_rtx_condition): Add DEBUG_SEEN argument.  In >= 0
            mode only set DEBUG_SEEN to 1 if problematic DEBUG_ISNSs
            were seen and revert all changes on success in that case.
            Don't try to recog_memoized DEBUG_INSNs.
            (compare_for_stack_reg): Adjust swap_rtx_condition caller.
            If it returns true and debug_seen is 1, call swap_rtx_condition
            again with debug_seen -1.
    
            * gcc.dg/ubsan/pr107183.c: New test.
    
    (cherry picked from commit 6b5c98c1c0003bd470a4428bede6c862637a94b8)

diff --git a/gcc/reg-stack.c b/gcc/reg-stack.c
index 3aac3c14817..6b61a6d8975 100644
--- a/gcc/reg-stack.c
+++ b/gcc/reg-stack.c
@@ -262,14 +262,14 @@ static void swap_to_top (rtx_insn *, stack_ptr, rtx, rtx);
 static bool move_for_stack_reg (rtx_insn *, stack_ptr, rtx);
 static bool move_nan_for_stack_reg (rtx_insn *, stack_ptr, rtx);
 static int swap_rtx_condition_1 (rtx);
-static int swap_rtx_condition (rtx_insn *);
+static int swap_rtx_condition (rtx_insn *, int &);
 static void compare_for_stack_reg (rtx_insn *, stack_ptr, rtx, bool);
 static bool subst_stack_regs_pat (rtx_insn *, stack_ptr, rtx);
 static void subst_asm_stack_regs (rtx_insn *, stack_ptr);
 static bool subst_stack_regs (rtx_insn *, stack_ptr);
 static void change_stack (rtx_insn *, stack_ptr, stack_ptr, enum emit_where);
 static void print_stack (FILE *, stack_ptr);
-static rtx_insn *next_flags_user (rtx_insn *);
+static rtx_insn *next_flags_user (rtx_insn *, int &);
 
 /* Return nonzero if any stack register is mentioned somewhere within PAT.  */
 
@@ -335,7 +335,7 @@ stack_regs_mentioned (const_rtx insn)
 static rtx ix86_flags_rtx;
 
 static rtx_insn *
-next_flags_user (rtx_insn *insn)
+next_flags_user (rtx_insn *insn, int &debug_seen)
 {
   /* Search forward looking for the first use of this value.
      Stop at block boundaries.  */
@@ -345,7 +345,14 @@ next_flags_user (rtx_insn *insn)
       insn = NEXT_INSN (insn);
 
       if (INSN_P (insn) && reg_mentioned_p (ix86_flags_rtx, PATTERN (insn)))
-	return insn;
+	{
+	  if (DEBUG_INSN_P (insn) && debug_seen >= 0)
+	    {
+	      debug_seen = 1;
+	      continue;
+	    }
+	  return insn;
+	}
 
       if (CALL_P (insn))
 	return NULL;
@@ -1246,8 +1253,22 @@ swap_rtx_condition_1 (rtx pat)
   return r;
 }
 
+/* This function swaps condition in cc users and returns true
+   if successful.  It is invoked in 2 different modes, one with
+   DEBUG_SEEN set initially to 0.  In this mode, next_flags_user
+   will skip DEBUG_INSNs that it would otherwise return and just
+   sets DEBUG_SEEN to 1 in that case.  If DEBUG_SEEN is 0 at
+   the end of toplevel swap_rtx_condition which returns true,
+   it means no problematic DEBUG_INSNs were seen and all changes
+   have been applied.  If it returns true but DEBUG_SEEN is 1,
+   it means some problematic DEBUG_INSNs were seen and no changes
+   have been applied so far.  In that case one needs to call
+   swap_rtx_condition again with DEBUG_SEEN set to -1, in which
+   case it doesn't skip DEBUG_INSNs, but instead adjusts the
+   flags related condition in them or resets them as needed.  */
+
 static int
-swap_rtx_condition (rtx_insn *insn)
+swap_rtx_condition (rtx_insn *insn, int &debug_seen)
 {
   rtx pat = PATTERN (insn);
 
@@ -1257,7 +1278,7 @@ swap_rtx_condition (rtx_insn *insn)
       && REG_P (SET_DEST (pat))
       && REGNO (SET_DEST (pat)) == FLAGS_REG)
     {
-      insn = next_flags_user (insn);
+      insn = next_flags_user (insn, debug_seen);
       if (insn == NULL_RTX)
 	return 0;
       pat = PATTERN (insn);
@@ -1279,7 +1300,18 @@ swap_rtx_condition (rtx_insn *insn)
 	{
 	  insn = NEXT_INSN (insn);
 	  if (INSN_P (insn) && reg_mentioned_p (dest, insn))
-	    break;
+	    {
+	      if (DEBUG_INSN_P (insn))
+		{
+		  if (debug_seen >= 0)
+		    debug_seen = 1;
+		  else
+		    /* Reset the DEBUG insn otherwise.  */
+		    INSN_VAR_LOCATION_LOC (insn) = gen_rtx_UNKNOWN_VAR_LOC ();
+		  continue;
+		}
+	      break;
+	    }
 	  if (CALL_P (insn))
 	    return 0;
 	}
@@ -1299,7 +1331,7 @@ swap_rtx_condition (rtx_insn *insn)
 	return 0;
 
       /* Now we are prepared to handle this as a normal cc0 setter.  */
-      insn = next_flags_user (insn);
+      insn = next_flags_user (insn, debug_seen);
       if (insn == NULL_RTX)
 	return 0;
       pat = PATTERN (insn);
@@ -1308,23 +1340,25 @@ swap_rtx_condition (rtx_insn *insn)
   if (swap_rtx_condition_1 (pat))
     {
       int fail = 0;
-      INSN_CODE (insn) = -1;
-      if (recog_memoized (insn) == -1)
-	fail = 1;
-      /* In case the flags don't die here, recurse to try fix
-         following user too.  */
-      else if (! dead_or_set_p (insn, ix86_flags_rtx))
+      if (DEBUG_INSN_P (insn))
+	gcc_assert (debug_seen < 0);
+      else
 	{
-	  insn = next_flags_user (insn);
-	  if (!insn || !swap_rtx_condition (insn))
+	  INSN_CODE (insn) = -1;
+	  if (recog_memoized (insn) == -1)
 	    fail = 1;
 	}
-      if (fail)
+      /* In case the flags don't die here, recurse to try fix
+	 following user too.  */
+      if (!fail && !dead_or_set_p (insn, ix86_flags_rtx))
 	{
-	  swap_rtx_condition_1 (pat);
-	  return 0;
+	  insn = next_flags_user (insn, debug_seen);
+	  if (!insn || !swap_rtx_condition (insn, debug_seen))
+	    fail = 1;
 	}
-      return 1;
+      if (fail || debug_seen == 1)
+	swap_rtx_condition_1 (pat);
+      return !fail;
     }
   return 0;
 }
@@ -1343,6 +1377,7 @@ compare_for_stack_reg (rtx_insn *insn, stack_ptr regstack,
 {
   rtx *src1, *src2;
   rtx src1_note, src2_note;
+  int debug_seen = 0;
 
   src1 = get_true_reg (&XEXP (pat_src, 0));
   src2 = get_true_reg (&XEXP (pat_src, 1));
@@ -1352,8 +1387,17 @@ compare_for_stack_reg (rtx_insn *insn, stack_ptr regstack,
   if ((! STACK_REG_P (*src1)
        || (STACK_REG_P (*src2)
 	   && get_hard_regnum (regstack, *src2) == FIRST_STACK_REG))
-      && swap_rtx_condition (insn))
+      && swap_rtx_condition (insn, debug_seen))
     {
+      /* If swap_rtx_condition succeeded but some debug insns
+	 were seen along the way, it has actually reverted all the
+	 changes.  Rerun swap_rtx_condition in a mode where DEBUG_ISNSs
+	 will be adjusted as well.  */
+      if (debug_seen)
+	{
+	  debug_seen = -1;
+	  swap_rtx_condition (insn, debug_seen);
+	}
       std::swap (XEXP (pat_src, 0), XEXP (pat_src, 1));
 
       src1 = get_true_reg (&XEXP (pat_src, 0));
diff --git a/gcc/testsuite/gcc.dg/ubsan/pr107183.c b/gcc/testsuite/gcc.dg/ubsan/pr107183.c
new file mode 100644
index 00000000000..e54a361c7c9
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/ubsan/pr107183.c
@@ -0,0 +1,12 @@
+/* PR target/107183 */
+/* { dg-do compile } */
+/* { dg-options "-O -fsanitize=float-cast-overflow -fcompare-debug" } */
+
+long double a, b, c;
+
+int
+foo (void)
+{
+  unsigned u = b || __builtin_rintl (c);
+  return u + (unsigned) a;
+}

commit 02bacbdac4855bdd22f6f1fedd2734ff0afae2db
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Mon Nov 21 10:28:27 2022 +0100

    i386: Uglify some local identifiers in *intrin.h [PR107748]
    
    While reporting PR107748 (where is a problem with non-uglified names,
    but I've left it out because it needs fixing anyway), I've noticed
    various spots where identifiers in *intrin.h headers weren't uglified.
    The following patch fixed those that are related to unions (I've grepped
    for [a-zA-Z]\.[a-zA-Z] spots).
    The reason we need those to be uglified is the same as why the arguments
    of the inlines are __ prefixed and most of automatic vars in the inlines
    - say a, v or u aren't part of implementation namespace and so users could
     #define u whatever->something
     #include <x86intrin.h>
    and it should still work, as long as u is not e.g. one of the names
    of the functions/macros the header provides (_mm* etc.).
    
    2022-11-21  Jakub Jelinek  <jakub@redhat.com>
    
            PR target/107748
            * config/i386/smmintrin.h (_mm_extract_ps): Uglify names of local
            variables and union members.
    
    (cherry picked from commit ec8ec09f9414be871e322fecf4ebf53e3687bd22)

diff --git a/gcc/config/i386/smmintrin.h b/gcc/config/i386/smmintrin.h
index 64377528682..ddf068c8505 100644
--- a/gcc/config/i386/smmintrin.h
+++ b/gcc/config/i386/smmintrin.h
@@ -365,17 +365,18 @@ _mm_insert_ps (__m128 __D, __m128 __S, const int __N)
 extern __inline int __attribute__((__gnu_inline__, __always_inline__, __artificial__))
 _mm_extract_ps (__m128 __X, const int __N)
 {
-  union { int i; float f; } __tmp;
-  __tmp.f = __builtin_ia32_vec_ext_v4sf ((__v4sf)__X, __N);
-  return __tmp.i;
+  union { int __i; float __f; } __tmp;
+  __tmp.__f = __builtin_ia32_vec_ext_v4sf ((__v4sf)__X, __N);
+  return __tmp.__i;
 }
 #else
 #define _mm_extract_ps(X, N)						\
   (__extension__							\
    ({									\
-     union { int i; float f; } __tmp;					\
-     __tmp.f = __builtin_ia32_vec_ext_v4sf ((__v4sf)(__m128)(X), (int)(N)); \
-     __tmp.i;								\
+     union { int __i; float __f; } __tmp;				\
+     __tmp.__f = __builtin_ia32_vec_ext_v4sf ((__v4sf)(__m128)(X),	\
+					      (int)(N));		\
+     __tmp.__i;								\
    }))
 #endif
 

commit 2525ad2b2aa0c2ddc64b091ba8a35c04c47e8723
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Thu Nov 24 11:29:54 2022 +0100

    asan: Fix up error recovery for too large frames [PR107317]
    
    asan_emit_stack_protection and functions it calls have various asserts that
    verify sanity of the stack protection instrumentation.  But, that
    verification can easily fail if we've diagnosed a frame offset overflow.
    asan_emit_stack_protection just emits some extra code in the prologue,
    if we've reported errors, we aren't producing assembly, so it doesn't
    really matter if we don't include the protection code, compilation
    is going to fail anyway.
    
    2022-11-24  Jakub Jelinek  <jakub@redhat.com>
    
            PR middle-end/107317
            * asan.c: Include diagnostic-core.h.
            (asan_emit_stack_protection): Return NULL early if seen_error ().
    
            * gcc.dg/asan/pr107317.c: New test.
    
    (cherry picked from commit b6330a7685476fc30b8ae9bbf3fca1a9b0d4be95)

diff --git a/gcc/asan.c b/gcc/asan.c
index 866df2e74cb..f8abefa357d 100644
--- a/gcc/asan.c
+++ b/gcc/asan.c
@@ -64,6 +64,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "tree-inline.h"
 #include "tree-ssa.h"
 #include "tree-eh.h"
+#include "diagnostic-core.h"
 
 /* AddressSanitizer finds out-of-bounds and use-after-free bugs
    with <2x slowdown on average.
@@ -1429,6 +1430,11 @@ asan_emit_stack_protection (rtx base, rtx pbase, unsigned int alignb,
   tree str_cst, decl, id;
   int use_after_return_class = -1;
 
+  /* Don't emit anything when doing error recovery, the assertions
+     might fail e.g. if a function had a frame offset overflow.  */
+  if (seen_error ())
+    return NULL;
+
   if (shadow_ptr_types[0] == NULL_TREE)
     asan_init_shadow_ptr_types ();
 
diff --git a/gcc/testsuite/gcc.dg/asan/pr107317.c b/gcc/testsuite/gcc.dg/asan/pr107317.c
new file mode 100644
index 00000000000..dd7ad7d2449
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/asan/pr107317.c
@@ -0,0 +1,13 @@
+/* PR middle-end/107317 */
+/* { dg-do compile { target ilp32 } } */
+/* { dg-options "-fsanitize=address -ffat-lto-objects" } */
+
+void bar (float *, float *);
+
+void
+foo (void)		/* { dg-error "exceeds maximum" } */
+{
+  float a[400000000];
+  float b[200000000];
+  bar (a, b);
+}

commit 611df5a1400865cf8718c7c60029a03215bbae48
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Thu Dec 8 14:57:22 2022 +0100

    cfgbuild: Fix DEBUG_INSN handling in find_bb_boundaries [PR106719]
    
    The following testcase FAILs on aarch64-linux.  We have some atomic
    instruction followed by 2 DEBUG_INSNs (if -g only of course) followed
    by NOTE_INSN_EPILOGUE_BEG followed by some USE insn.
    Now, split3 pass replaces the atomic instruction with a code sequence
    which ends with a conditional jump and the split3 pass calls
    find_many_sub_basic_blocks.
    For -g0, find_bb_boundaries sees the flow_transfer_insn (the new conditional
    jump), then NOTE_INSN_EPILOGUE_BEG which can live in between basic blocks
    and then the USE insn, so splits block after the NOTE_INSN_EPILOGUE_BEG
    and puts the NOTE in between the blocks.
    For -g, if sees a DEBUG_INSN after the flow_transfer_insn, so sets
    debug_insn to it, then walks over another DEBUG_INSN, NOTE_INSN_EPILOGUE_BEG
    until it finally sees the USE insn, and triggers the:
              rtx_insn *prev = PREV_INSN (insn);
    
              /* If the first non-debug inside_basic_block_p insn after a control
                 flow transfer is not a label, split the block before the debug
                 insn instead of before the non-debug insn, so that the debug
                 insns are not lost.  */
              if (debug_insn && code != CODE_LABEL && code != BARRIER)
                prev = PREV_INSN (debug_insn);
    code I've added for PR81325.  If there are only DEBUG_INSNs, that is
    the right thing to do, but if in between debug_insn and insn there are
    notes which can stay in between basic blocks or simnilarly JUMP_TABLE_DATA
    or their associated CODE_LABELs, it causes -fcompare-debug differences.
    
    The following patch fixes it by clearing debug_insn if JUMP_TABLE_DATA
    or associated CODE_LABEL is seen (I'm afraid there is no good answer
    what to do with DEBUG_INSNs before those; the code then removes them:
                  /* Clean up the bb field for the insns between the blocks.  */
                  for (x = NEXT_INSN (flow_transfer_insn);
                       x != BB_HEAD (fallthru->dest);
                       x = next)
                    {
                      next = NEXT_INSN (x);
                      /* Debug insns should not be in between basic blocks,
                         drop them on the floor.  */
                      if (DEBUG_INSN_P (x))
                        delete_insn (x);
                      else if (!BARRIER_P (x))
                        set_block_for_insn (x, NULL);
                    }
    but if there are NOTEs, the patch just reorders the NOTEs and DEBUG_INSNs,
    such that the NOTEs come first (so that they stay in between basic blocks
    like with -g0) and DEBUG_INSNs after those (so that bb is split before
    them, so they will be in the basic block after NOTE_INSN_BASIC_BLOCK).
    
    2022-12-08  Jakub Jelinek  <jakub@redhat.com>
    
            PR debug/106719
            * cfgbuild.c (find_bb_boundaries): If there are NOTEs in between
            debug_insn (seen after flow_transfer_insn) and insn, move NOTEs
            before all the DEBUG_INSNs and split after NOTEs.  If there are
            other insns like jump table data, clear debug_insn.
    
            * gcc.dg/pr106719.c: New test.
    
    (cherry picked from commit d9f9d5d30feb33c359955d7030cc6be50ef6dc0a)

diff --git a/gcc/cfgbuild.c b/gcc/cfgbuild.c
index 9ea6056cad6..055fcb173f0 100644
--- a/gcc/cfgbuild.c
+++ b/gcc/cfgbuild.c
@@ -445,6 +445,7 @@ find_bb_boundaries (basic_block bb)
   rtx_insn *debug_insn = NULL;
   edge fallthru = NULL;
   bool skip_purge;
+  bool seen_note_after_debug = false;
 
   if (insn == end)
     return;
@@ -492,7 +493,10 @@ find_bb_boundaries (basic_block bb)
       if (code == DEBUG_INSN)
 	{
 	  if (flow_transfer_insn && !debug_insn)
-	    debug_insn = insn;
+	    {
+	      debug_insn = insn;
+	      seen_note_after_debug = false;
+	    }
 	}
       /* In case we've previously seen an insn that effects a control
 	 flow transfer, split the block.  */
@@ -506,7 +510,40 @@ find_bb_boundaries (basic_block bb)
 	     insn instead of before the non-debug insn, so that the debug
 	     insns are not lost.  */
 	  if (debug_insn && code != CODE_LABEL && code != BARRIER)
-	    prev = PREV_INSN (debug_insn);
+	    {
+	      prev = PREV_INSN (debug_insn);
+	      if (seen_note_after_debug)
+		{
+		  /* Though, if there are NOTEs intermixed with DEBUG_INSNs,
+		     move the NOTEs before the DEBUG_INSNs and split after
+		     the last NOTE.  */
+		  rtx_insn *first = NULL, *last = NULL;
+		  for (x = debug_insn; x != insn; x = NEXT_INSN (x))
+		    {
+		      if (NOTE_P (x))
+			{
+			  if (first == NULL)
+			    first = x;
+			  last = x;
+			}
+		      else
+			{
+			  gcc_assert (DEBUG_INSN_P (x));
+			  if (first)
+			    {
+			      reorder_insns_nobb (first, last, prev);
+			      prev = last;
+			      first = last = NULL;
+			    }
+			}
+		    }
+		  if (first)
+		    {
+		      reorder_insns_nobb (first, last, prev);
+		      prev = last;
+		    }
+		}
+	    }
 	  fallthru = split_block (bb, prev);
 	  if (flow_transfer_insn)
 	    {
@@ -547,6 +584,14 @@ find_bb_boundaries (basic_block bb)
 	    flow_transfer_insn = prev_nonnote_nondebug_insn_bb (insn);
 	  debug_insn = NULL;
 	}
+      else if (debug_insn)
+	{
+	  if (code == NOTE)
+	    seen_note_after_debug = true;
+	  else
+	    /* Jump tables.  */
+	    debug_insn = NULL;
+	}
 
       if (control_flow_insn_p (insn))
 	flow_transfer_insn = insn;
diff --git a/gcc/testsuite/gcc.dg/pr106719.c b/gcc/testsuite/gcc.dg/pr106719.c
new file mode 100644
index 00000000000..772bd4a2d3e
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr106719.c
@@ -0,0 +1,13 @@
+/* PR debug/106719 */
+/* { dg-do compile { target sync_char_short } } */
+/* { dg-options "-O2 -fcompare-debug" } */
+
+extern short int esi, easi[2];
+
+void
+foo (void)
+{
+  short int *psi = &easi[1];
+  __atomic_nand_fetch (psi, esi, 0);
+  psi = &easi[1];
+}

commit 5589bb8d1fd3d4ecfb71e764d54bf931a743b85d
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Sat Dec 10 16:50:39 2022 +0100

    ivopts: Fix IP_END handling for asm goto [PR107997]
    
    The following testcase ICEs, because the latch bb ends with
    asm goto which has both fallthrough to the header and one or more labels
    in the header too.  In that case there is just a single edge out of the
    latch block, but still the asm goto is stmt_ends_bb_p statement, yet
    ivopts decides to emit an IV bump at the IP_END position and inserts
    it into the same bb as the asm goto after it, which then fails verification
    (control flow in the middle of bb).
    
    The following patch fixes it by splitting the latch -> header edge in that
    case and inserting into the newly created bb, where split_edge ->
    redirect_edge_and_branch is able to deal with this case correctly.
    
    2022-12-10  Jakub Jelinek  <jakub@redhat.com>
    
            PR tree-optimization/107997
            * tree-ssa-loop-ivopts.c: Include cfganal.h.
            (create_new_iv) <case IP_END>: If ip_end_pos bb is non-empty and ends
            with a stmt which ends bb, instead of adding iv update after it split
            the latch edge and insert iterator into the new latch bb.
    
            * gcc.c-torture/compile/pr107997.c: New test.
    
    (cherry picked from commit 7676235f690e624b7ed41a22b22ce8ccfac1492f)

diff --git a/gcc/testsuite/gcc.c-torture/compile/pr107997.c b/gcc/testsuite/gcc.c-torture/compile/pr107997.c
new file mode 100644
index 00000000000..89e1fd349c3
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/compile/pr107997.c
@@ -0,0 +1,23 @@
+/* PR tree-optimization/107997 */
+
+int a, b;
+void bar (int);
+int baz (void);
+
+void *
+foo (int x, void *y)
+{
+  asm goto ("" : : "r" (x || !a) : : l);
+l:
+  if (y)
+    return 0;
+  bar (b ? b : x);
+  while (x--)
+    {
+      if (!baz ())
+	baz ();
+      asm goto ("" : : : : l2);
+    l2:;
+    }
+  return y;
+}
diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c
index 1d2697ae1ba..458681f56f4 100644
--- a/gcc/tree-ssa-loop-ivopts.c
+++ b/gcc/tree-ssa-loop-ivopts.c
@@ -131,6 +131,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "builtins.h"
 #include "tree-vectorizer.h"
 #include "dbgcnt.h"
+#include "cfganal.h"
 
 /* For lang_hooks.types.type_for_mode.  */
 #include "langhooks.h"
@@ -7105,6 +7106,12 @@ create_new_iv (struct ivopts_data *data, struct iv_cand *cand)
     case IP_END:
       incr_pos = gsi_last_bb (ip_end_pos (data->current_loop));
       after = true;
+      if (!gsi_end_p (incr_pos) && stmt_ends_bb_p (gsi_stmt (incr_pos)))
+	{
+	  edge e = find_edge (gsi_bb (incr_pos), data->current_loop->header);
+	  incr_pos = gsi_after_labels (split_edge (e));
+	  after = false;
+	}
       break;
 
     case IP_AFTER_USE:

commit 52921a6c7249ac5d0aa58231ae45997bebd2bc67
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Thu Dec 15 19:17:45 2022 +0100

    c++: Ensure !!var is not an lvalue [PR107065]
    
    The TRUTH_NOT_EXPR case in cp_build_unary_op is one of the spots where
    we somewhat fold immediately using invert_truthvalue_loc.
    I've tried using
      return build1_loc (location, TRUTH_NOT_EXPR, boolean_type_node, arg);
    in there instead, but unfortunately that regressed
    Wlogical-not-parentheses-*.c pr49706.c pr62199.c pr65120.c sequence-pt-1.C
    tests, so at least for backporting that doesn't seem to be a way to go.
    
    So, this patch instead wraps it into NON_LVALUE_EXPR if needed (which also
    need a tweak for some tests in the pr47906.c test, but nothing major),
    with the intent to make it backportable, and later I'll try to do further
    steps to avoid folding here prematurely.  Most of the problems with
    build1 TRUTH_NOT_EXPR are that it doesn't even invert comparisons as most
    common case and lots of warning code isn't able to deal with ! around
    comparisons; so perhaps one way to do this would be fold by hand only
    invertable comparisons and for the rest create TRUTH_NOT_EXPR.
    
    2022-12-15  Jakub Jelinek  <jakub@redhat.com>
    
            PR c++/107065
    gcc/cp/
            * typeck.c (cp_build_unary_op) <case TRUTH_NOT_EXPR>: If
            invert_truthvalue_loc returns obvalue_p, wrap it into NON_LVALUE_EXPR.
            * parser.c (cp_parser_binary_expression): Don't call
            warn_logical_not_parentheses if current.lhs is a NON_LVALUE_EXPR
            of a decl with boolean type.
    gcc/testsuite/
            * g++.dg/cpp0x/pr107065.C: New test.
    
    (cherry picked from commit 8b775b4c48a3cc4ef5c50e56144aea02da2e9cc6)

diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 4c36cbeeb48..fcc0bd60a49 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -9689,7 +9689,10 @@ cp_parser_binary_expression (cp_parser* parser, bool cast_p,
 		      || (TREE_CODE (TREE_TYPE (TREE_OPERAND (current.lhs, 0)))
 			  != BOOLEAN_TYPE))))
 	  /* Avoid warning for !!b == y where b is boolean.  */
-	  && (!DECL_P (tree_strip_any_location_wrapper (current.lhs))
+	  && (!(DECL_P (tree_strip_any_location_wrapper (current.lhs))
+		|| (TREE_CODE (current.lhs) == NON_LVALUE_EXPR
+		    && DECL_P (tree_strip_any_location_wrapper
+					    (TREE_OPERAND (current.lhs, 0)))))
 	      || TREE_TYPE (current.lhs) == NULL_TREE
 	      || TREE_CODE (TREE_TYPE (current.lhs)) != BOOLEAN_TYPE))
 	warn_logical_not_parentheses (current.loc, current.tree_type,
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index def6442779d..c2194b96400 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -6582,9 +6582,13 @@ cp_build_unary_op (enum tree_code code, tree xarg, bool noconvert,
 				   build_zero_cst (TREE_TYPE (arg)), complain);
       arg = perform_implicit_conversion (boolean_type_node, arg,
 					 complain);
-      val = invert_truthvalue_loc (location, arg);
       if (arg != error_mark_node)
-	return val;
+	{
+	  val = invert_truthvalue_loc (location, arg);
+	  if (obvalue_p (val))
+	    val = non_lvalue_loc (location, val);
+	  return val;
+	}
       errstring = _("in argument to unary !");
       break;
 
diff --git a/gcc/testsuite/g++.dg/cpp0x/pr107065.C b/gcc/testsuite/g++.dg/cpp0x/pr107065.C
new file mode 100644
index 00000000000..5e18bb91cff
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/pr107065.C
@@ -0,0 +1,14 @@
+// PR c++/107065
+// { dg-do compile { target c++11 } }
+
+template<class, class> struct is_same { static constexpr bool value = false; };
+template<class T> struct is_same<T, T> { static constexpr bool value = true; };
+
+int
+main ()
+{
+  bool b = true;
+  static_assert (is_same<decltype (!(!b)), bool>::value, "");
+  auto bb = (!(!b));
+  static_assert (is_same<decltype (bb), bool>::value, "");
+}

commit c88f917d2aa1c2ac065fbc0a10298f5551f392b6
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Fri Dec 16 10:19:22 2022 +0100

    loop-invariant: Split preheader edge if the preheader bb ends with jump [PR106751]
    
    The RTL loop passes only request simple preheaders, but don't require
    fallthru preheaders, while move_invariant_reg apparently assumes the
    latter, that it can just append instruction(s) to the end of the preheader
    basic block.
    
    The following patch fixes that by splitting the preheader edge if
    the preheader bb ends with a JUMP_INSN (asm goto in this case).
    Without that we get control flow in the middle of a bb.
    
    2022-12-16  Jakub Jelinek  <jakub@redhat.com>
    
            PR rtl-optimization/106751
            * loop-invariant.c (move_invariant_reg): If preheader bb ends
            with a JUMP_INSN, split the preheader edge and emit invariants
            into the new preheader basic block.
    
            * gcc.c-torture/compile/pr106751.c: New test.
    
    (cherry picked from commit ddcaa60983b50378bde1b7e327086fe0ce101795)

diff --git a/gcc/loop-invariant.c b/gcc/loop-invariant.c
index 3a9fcfabce8..9809a8c9341 100644
--- a/gcc/loop-invariant.c
+++ b/gcc/loop-invariant.c
@@ -1829,6 +1829,8 @@ move_invariant_reg (class loop *loop, unsigned invno)
       else if (dump_file)
 	fprintf (dump_file, "Invariant %d moved without introducing a new "
 			    "temporary register\n", invno);
+      if (JUMP_P (BB_END (preheader)))
+	preheader = split_edge (loop_preheader_edge (loop));
       reorder_insns (inv->insn, inv->insn, BB_END (preheader));
       df_recompute_luids (preheader);
 
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr106751.c b/gcc/testsuite/gcc.c-torture/compile/pr106751.c
new file mode 100644
index 00000000000..5fbf93bd332
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/compile/pr106751.c
@@ -0,0 +1,17 @@
+/* PR rtl-optimization/106751 */
+
+int *foo (void);
+
+void
+bar (void)
+{
+  asm goto ("" : : : : lab);
+  __builtin_unreachable ();
+lab:
+  while (1)
+    {
+      int o;
+      asm ("" : "=r" (o) : "g" (1));
+      *foo () = o;
+    }
+}

commit 954a2f46085df0cd1cb1cb34a72aec0e96c4be85
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Mon Dec 19 13:49:52 2022 +0100

    testsuite: Fix up pr64536.c for LLP64 targets [PR108151]
    
    The test casts a pointer to long, which is ok for ilp32 and lp64
    targets but not for llp64 targets.  Nothing reads the values later,
    it is a link test, so all we care about is that it is the same
    cast on s390x-linux where it used to fail before the PR64536 fix,
    and that we don't warn about it.
    
    2022-12-19  Jakub Jelinek  <jakub@redhat.com>
    
            PR testsuite/108151
            * gcc.dg/pr64536.c (bar): Use casts to __INTPTR_TYPE__ rather than
            long when casting pointer to integral type.
    
    (cherry picked from commit ea37e96a37b50dad17b91d46edc518bbb9132d8e)

diff --git a/gcc/testsuite/gcc.dg/pr64536.c b/gcc/testsuite/gcc.dg/pr64536.c
index f2728fbc938..bca2d4f0efe 100644
--- a/gcc/testsuite/gcc.dg/pr64536.c
+++ b/gcc/testsuite/gcc.dg/pr64536.c
@@ -41,7 +41,7 @@ bar (int x)
 	    }
 	  else
 	    i = (long *) (h->q = *f);
-	  *c++ = (long) f;
+	  *c++ = (__INTPTR_TYPE__) f;
 	  e += 6;
 	}
       else
@@ -55,7 +55,7 @@ bar (int x)
 	    }
 	  else
 	    i = (long *) (h->q = *f);
-	  *c++ = (long) f;
+	  *c++ = (__INTPTR_TYPE__) f;
 	  e += 6;
 	}
     }

commit 39cac73d73962bc7623fa6f9bc138ed291b964c8
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Mon Dec 19 15:05:16 2022 +0100

    testsuite: Fix up pr64536.c for LLP64 targets [PR108151]
    
    Apparently llp64 had 2 further warnings, fixed thusly.
    
    2022-12-19  Jakub Jelinek  <jakub@redhat.com>
    
            PR testsuite/108151
            * gcc.dg/pr64536.c (bar): Cast long to __INTPTR_TYPE__
            before casting to long *.
    
    (cherry picked from commit 6e85f89a7d59a99a3395b6e153b99262a58b2f6c)

diff --git a/gcc/testsuite/gcc.dg/pr64536.c b/gcc/testsuite/gcc.dg/pr64536.c
index bca2d4f0efe..18afa9d0232 100644
--- a/gcc/testsuite/gcc.dg/pr64536.c
+++ b/gcc/testsuite/gcc.dg/pr64536.c
@@ -40,7 +40,7 @@ bar (int x)
 	      h->q = *f;
 	    }
 	  else
-	    i = (long *) (h->q = *f);
+	    i = (long *) (__INTPTR_TYPE__) (h->q = *f);
 	  *c++ = (__INTPTR_TYPE__) f;
 	  e += 6;
 	}
@@ -54,7 +54,7 @@ bar (int x)
 	      h->q = *f;
 	    }
 	  else
-	    i = (long *) (h->q = *f);
+	    i = (long *) (__INTPTR_TYPE__) (h->q = *f);
 	  *c++ = (__INTPTR_TYPE__) f;
 	  e += 6;
 	}

commit 2a8357535300e9d4d6126d7b3ce4cd951f0eb6aa
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Wed Dec 21 09:05:27 2022 +0100

    openmp: Don't try to destruct DECL_OMP_PRIVATIZED_MEMBER vars [PR108180]
    
    DECL_OMP_PRIVATIZED_MEMBER vars are artificial vars with DECL_VALUE_EXPR
    of this->field used just during gimplification and omp lowering/expansion
    to privatize individual fields in methods when needed.
    As the following testcase shows, when not in templates, they were handled
    right, but in templates we actually called cp_finish_decl on them and
    that can result in their destruction, which is obviously undesirable,
    we should only destruct the privatized copies of them created in omp
    lowering.
    
    Fixed thusly.
    
    2022-12-21  Jakub Jelinek  <jakub@redhat.com>
    
            PR c++/108180
            * pt.c (tsubst_expr): Don't call cp_finish_decl on
            DECL_OMP_PRIVATIZED_MEMBER vars.
    
            * testsuite/libgomp.c++/pr108180.C: New test.
    
    (cherry picked from commit 1119902b6c7c1c50123ed85ec1def8be4772d68c)

diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index 0a52f0993ab..1185cdcaab6 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -18157,6 +18157,11 @@ tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl,
 		    tree asmspec_tree = NULL_TREE;
 		    maybe_push_decl (decl);
 
+		    if (VAR_P (decl)
+			&& DECL_LANG_SPECIFIC (decl)
+			&& DECL_OMP_PRIVATIZED_MEMBER (decl))
+		      break;
+
 		    if (VAR_P (decl)
 			&& DECL_DECOMPOSITION_P (decl)
 			&& TREE_TYPE (pattern_decl) != error_mark_node)
diff --git a/libgomp/testsuite/libgomp.c++/pr108180.C b/libgomp/testsuite/libgomp.c++/pr108180.C
new file mode 100644
index 00000000000..452910cebeb
--- /dev/null
+++ b/libgomp/testsuite/libgomp.c++/pr108180.C
@@ -0,0 +1,55 @@
+// PR c++/108180
+// { dg-do run }
+
+struct A {
+  A () { ++a; }
+  A (A &&) = delete;
+  A (const A &) { ++a; }
+  A &operator= (const A &) = delete;
+  A &operator= (A &&) = delete;
+  ~A () { --a; }
+  static int a;
+};
+int A::a = 0;
+
+struct B {
+  A a;
+  template <int N>
+  int
+  foo ()
+  {
+    int res = 0;
+    #pragma omp parallel for if(false) firstprivate(a)
+    for (int i = 0; i < 64; ++i)
+      res += i;
+    return res;
+  }
+  int
+  bar ()
+  {
+    int res = 0;
+    #pragma omp parallel for if(false) firstprivate(a)
+    for (int i = 0; i < 64; ++i)
+      res += i;
+    return res;
+  }
+};
+
+int
+main ()
+{
+  {
+    B b;
+    if (b.foo<0> () != 2016)
+      __builtin_abort ();
+  }
+  if (A::a != 0)
+    __builtin_abort ();
+  {
+    B b;
+    if (b.bar () != 2016)
+      __builtin_abort ();
+  }
+  if (A::a != 0)
+    __builtin_abort ();
+}

commit 14cb8af5a6a1f09250a207359535399fedbbb4ff
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Thu Dec 22 12:44:13 2022 +0100

    cse: Fix up CSE const_anchor handling [PR108193]
    
    The following testcase ICEs on aarch64, because insert_const_anchor
    inserts invalid CONST_INT into the CSE tables - 0x80000000 for SImode.
    The second hunk of the patch fixes that, the first one is to avoid
    triggering undefined behavior at compile time during compute_const_anchors
    computations - performing those additions and subtractions in
    HOST_WIDE_INT means it can overflow for certain constants.
    
    2022-12-22  Jakub Jelinek  <jakub@redhat.com>
    
            PR rtl-optimization/108193
            * cse.c (compute_const_anchors): Change n type to
            unsigned HOST_WIDE_INT, adjust comparison against it to avoid
            warnings.  Formatting fix.
            (insert_const_anchor): Use gen_int_mode instead of GEN_INT.
    
            * gfortran.dg/pr108193.f90: New test.
    
    (cherry picked from commit 0cb5d7cdbab8e5f8359764ef5f62d93c2bc88552)

diff --git a/gcc/cse.c b/gcc/cse.c
index f69a33a82e0..7253b7caf6c 100644
--- a/gcc/cse.c
+++ b/gcc/cse.c
@@ -1190,14 +1190,14 @@ compute_const_anchors (rtx cst,
 		       HOST_WIDE_INT *lower_base, HOST_WIDE_INT *lower_offs,
 		       HOST_WIDE_INT *upper_base, HOST_WIDE_INT *upper_offs)
 {
-  HOST_WIDE_INT n = INTVAL (cst);
+  unsigned HOST_WIDE_INT n = UINTVAL (cst);
 
   *lower_base = n & ~(targetm.const_anchor - 1);
-  if (*lower_base == n)
+  if ((unsigned HOST_WIDE_INT) *lower_base == n)
     return false;
 
-  *upper_base =
-    (n + (targetm.const_anchor - 1)) & ~(targetm.const_anchor - 1);
+  *upper_base = ((n + (targetm.const_anchor - 1))
+		 & ~(targetm.const_anchor - 1));
   *upper_offs = n - *upper_base;
   *lower_offs = n - *lower_base;
   return true;
@@ -1214,7 +1214,7 @@ insert_const_anchor (HOST_WIDE_INT anchor, rtx reg, HOST_WIDE_INT offs,
   rtx anchor_exp;
   rtx exp;
 
-  anchor_exp = GEN_INT (anchor);
+  anchor_exp = gen_int_mode (anchor, mode);
   hash = HASH (anchor_exp, mode);
   elt = lookup (anchor_exp, hash, mode);
   if (!elt)
diff --git a/gcc/testsuite/gfortran.dg/pr108193.f90 b/gcc/testsuite/gfortran.dg/pr108193.f90
new file mode 100644
index 00000000000..3a3655f1248
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr108193.f90
@@ -0,0 +1,24 @@
+! PR rtl-optimization/108193
+! { dg-do compile { target pthread } }
+! { dg-options "-O2 -fsplit-loops -ftree-parallelize-loops=2 -fno-tree-dominator-opts" }
+
+subroutine foo (n, r)
+  implicit none
+  integer :: i, j, n
+  real :: s, r(*)
+
+  s = 0.0
+
+  do j = 1, 2
+     do i = j, n
+        s = r(i)
+     end do
+  end do
+
+  do i = 1, n
+     do j = i, n
+        s = s + 1
+     end do
+     r(i) = s
+  end do
+end subroutine foo

commit fc8c0f806728692b24fe57849ca4e1f70d882e92
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Fri Dec 23 16:12:21 2022 +0100

    tree-ssa-dom: can_infer_simple_equiv fixes [PR108068]
    
    As reported in the PR, tree-ssa-dom.cc uses real_zerop call to find
    if a floating point constant is zero and it shouldn't try to infer
    equivalences from comparison against it if signed zeros are honored.
    This doesn't work at all for decimal types, because real_zerop always
    returns false for them (one can have different representations of decimal
    zero beyond -0/+0), and it doesn't work for vector compares either,
    as real_zerop checks if all elements are zero, while we need to avoid
    infering equivalences from comparison against vector constants which have
    at least one zero element in it (if signed zeros are honored).
    Furthermore, as mentioned by Joseph, for decimal types many other values
    aren't singleton.
    
    So, this patch stops infering anything if element mode is decimal, and
    otherwise uses instead of real_zerop a new function, real_maybe_zerop,
    which will work even for decimal types and for complex or vector will
    return true if any element is or might be zero (so it returns true
    for anything but constants for now).
    
    2022-12-23  Jakub Jelinek  <jakub@redhat.com>
    
            PR tree-optimization/108068
            * tree.h (real_maybe_zerop): Declare.
            * tree.c (real_maybe_zerop): Define.
            * tree-ssa-dom.c (record_edge_info): Use it instead of
            real_zerop or TREE_CODE (op1) == SSA_NAME || real_zerop.  Always set
            can_infer_simple_equiv to false for decimal floating point types.
    
            * gcc.dg/dfp/pr108068.c: New test.
    
    (cherry picked from commit fd1b0aefda5b65f3f841ca6e61ccea6a72daa060)

diff --git a/gcc/testsuite/gcc.dg/dfp/pr108068.c b/gcc/testsuite/gcc.dg/dfp/pr108068.c
new file mode 100644
index 00000000000..6cbb0fbe602
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/dfp/pr108068.c
@@ -0,0 +1,14 @@
+/* PR tree-optimization/108068 */
+/* { dg-do run } */
+/* { dg-options "-O2" } */
+
+int
+main ()
+{
+  _Decimal64 x = -1;
+  while (x != 0)
+    x /= 10;
+  double d = x;
+  if (!__builtin_signbit (d))
+    __builtin_abort ();
+}
diff --git a/gcc/tree-ssa-dom.c b/gcc/tree-ssa-dom.c
index c0d77b5f46c..fcdbf547c42 100644
--- a/gcc/tree-ssa-dom.c
+++ b/gcc/tree-ssa-dom.c
@@ -540,9 +540,9 @@ record_edge_info (basic_block bb)
             {
               tree cond = build2 (code, boolean_type_node, op0, op1);
               tree inverted = invert_truthvalue_loc (loc, cond);
-              bool can_infer_simple_equiv
-                = !(HONOR_SIGNED_ZEROS (op0)
-                    && real_zerop (op0));
+	      bool can_infer_simple_equiv
+		= !(HONOR_SIGNED_ZEROS (op0) && real_maybe_zerop (op0))
+		  && !DECIMAL_FLOAT_MODE_P (element_mode (TREE_TYPE (op0)));
 	      class edge_info *edge_info;
 
 	      edge_info = new class edge_info (true_edge);
@@ -564,9 +564,9 @@ record_edge_info (basic_block bb)
             {
               tree cond = build2 (code, boolean_type_node, op0, op1);
               tree inverted = invert_truthvalue_loc (loc, cond);
-              bool can_infer_simple_equiv
-                = !(HONOR_SIGNED_ZEROS (op1)
-                    && (TREE_CODE (op1) == SSA_NAME || real_zerop (op1)));
+	      bool can_infer_simple_equiv
+		= !(HONOR_SIGNED_ZEROS (op1) && real_maybe_zerop (op1))
+		  && !DECIMAL_FLOAT_MODE_P (element_mode (TREE_TYPE (op1)));
 	      class edge_info *edge_info;
 
 	      edge_info = new class edge_info (true_edge);
diff --git a/gcc/tree.c b/gcc/tree.c
index d82c308f14c..8719f0c0645 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -2927,6 +2927,35 @@ real_minus_onep (const_tree expr)
     }
 }
 
+/* Return true if T could be a floating point zero.  */
+
+bool
+real_maybe_zerop (const_tree expr)
+{
+  switch (TREE_CODE (expr))
+    {
+    case REAL_CST:
+      /* Can't use real_zerop here, as it always returns false for decimal
+	 floats.  And can't use TREE_REAL_CST (expr).cl == rvc_zero
+	 either, as decimal zeros are rvc_normal.  */
+      return real_equal (&TREE_REAL_CST (expr), &dconst0);
+    case COMPLEX_CST:
+      return (real_maybe_zerop (TREE_REALPART (expr))
+	      || real_maybe_zerop (TREE_IMAGPART (expr)));
+    case VECTOR_CST:
+      {
+	unsigned count = vector_cst_encoded_nelts (expr);
+	for (unsigned int i = 0; i < count; ++i)
+	  if (real_maybe_zerop (VECTOR_CST_ENCODED_ELT (expr, i)))
+	    return true;
+	return false;
+      }
+    default:
+      /* Perhaps for SSA_NAMEs we could query frange.  */
+      return true;
+    }
+}
+
 /* Nonzero if EXP is a constant or a cast of a constant.  */
 
 bool
diff --git a/gcc/tree.h b/gcc/tree.h
index bb80e81d389..80bb8ed156c 100644
--- a/gcc/tree.h
+++ b/gcc/tree.h
@@ -5216,6 +5216,7 @@ extern bool needs_to_live_in_memory (const_tree);
 extern tree reconstruct_complex_type (tree, tree);
 extern bool real_onep (const_tree);
 extern bool real_minus_onep (const_tree);
+extern bool real_maybe_zerop (const_tree);
 extern void init_ttree (void);
 extern void build_common_tree_nodes (bool);
 extern void build_common_builtin_nodes (void);

commit a91ca4212faca201291633a8016c5c47dbba07e2
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Wed Jan 4 10:54:38 2023 +0100

    generic-match-head: Don't assume GENERIC folding is done only early [PR108237]
    
    We ICE on the following testcase, because a valid V2DImode
    != comparison is folded into an unsupported V2DImode > comparison.
    The match.pd pattern which does this looks like:
    /* Transform comparisons of the form (X & Y) CMP 0 to X CMP2 Z
       where ~Y + 1 == pow2 and Z = ~Y.  */
    (for cst (VECTOR_CST INTEGER_CST)
     (for cmp (eq ne)
          icmp (le gt)
      (simplify
       (cmp (bit_and:c@2 @0 cst@1) integer_zerop)
        (with { tree csts = bitmask_inv_cst_vector_p (@1); }
         (if (csts && (VECTOR_TYPE_P (TREE_TYPE (@1)) || single_use (@2)))
          (with { auto optab = VECTOR_TYPE_P (TREE_TYPE (@1))
                             ? optab_vector : optab_default;
                  tree utype = unsigned_type_for (TREE_TYPE (@1)); }
           (if (target_supports_op_p (utype, icmp, optab)
                || (optimize_vectors_before_lowering_p ()
                    && (!target_supports_op_p (type, cmp, optab)
                        || !target_supports_op_p (type, BIT_AND_EXPR, optab))))
            (if (TYPE_UNSIGNED (TREE_TYPE (@1)))
             (icmp @0 { csts; })
             (icmp (view_convert:utype @0) { csts; })))))))))
    and that optimize_vectors_before_lowering_p () guarded stuff there
    already deals with this problem, not trying to fold a supported comparison
    into a non-supported one.  The reason it doesn't work in this case is that
    it isn't GIMPLE folding which does this, but GENERIC folding done during
    forwprop4 - forward_propagate_into_comparison -> forward_propagate_into_comparison_1
    -> combine_cond_expr_cond -> fold_binary_loc -> generic_simplify
    and we simply assumed that GENERIC folding happens only before
    gimplification.
    
    The following patch fixes that by checking cfun properties instead of
    always returning true in those cases.
    
    2023-01-04  Jakub Jelinek  <jakub@redhat.com>
    
            PR middle-end/108237
            * generic-match-head.c: Include tree-pass.h.
            (canonicalize_math_p): Define to false if cfun and
            cfun->curr_properties has PROP_gimple_opt_math resp. PROP_gimple_lvec
            property set.
    
            * gcc.c-torture/compile/pr108237.c: New test.
    
    (cherry picked from commit 345dffd0d4ebff7e705dfff1a8a72017a167120a)

diff --git a/gcc/generic-match-head.c b/gcc/generic-match-head.c
index 2454baac9d4..28114f367e7 100644
--- a/gcc/generic-match-head.c
+++ b/gcc/generic-match-head.c
@@ -37,6 +37,8 @@ along with GCC; see the file COPYING3.  If not see
 #include "gimplify.h"
 #include "optabs-tree.h"
 #include "dbgcnt.h"
+#include "tm.h"
+#include "tree-pass.h"
 
 /* Routine to determine if the types T1 and T2 are effectively
    the same for GENERIC.  If T1 or T2 is not a type, the test
@@ -68,7 +70,7 @@ single_use (tree t ATTRIBUTE_UNUSED)
 static inline bool
 canonicalize_math_p ()
 {
-  return true;
+  return !cfun || (cfun->curr_properties & PROP_gimple_opt_math) == 0;
 }
 
 /* Return true if math operations that are beneficial only after
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr108237.c b/gcc/testsuite/gcc.c-torture/compile/pr108237.c
new file mode 100644
index 00000000000..52b7f9d177f
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/compile/pr108237.c
@@ -0,0 +1,14 @@
+/* PR middle-end/108237 */
+
+typedef unsigned char __attribute__((__vector_size__ (1))) U;
+typedef unsigned long long __attribute__((__vector_size__ (16))) V;
+
+U u;
+V v;
+
+V
+foo (void)
+{
+  V w = v != ((unsigned char) ((unsigned char) u == u) & v);
+  return w;
+}

commit 532cbd4d96285dce2440424faff30e5cc94954e4
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Wed Jan 11 10:40:54 2023 +0100

    fortran: Fix up function types for realloc and sincos{,f,l} builtins [PR108349]
    
    As reported in the PR, the FUNCTION_TYPE for __builtin_realloc in the
    Fortran FE is wrong since r0-100026-gb64fca63690ad which changed
    -  tmp = tree_cons (NULL_TREE, pvoid_type_node, void_list_node);
    -  tmp = tree_cons (NULL_TREE, size_type_node, tmp);
    -  ftype = build_function_type (pvoid_type_node, tmp);
    +  ftype = build_function_type_list (pvoid_type_node,
    +                                    size_type_node, pvoid_type_node,
    +                                    NULL_TREE);
       gfc_define_builtin ("__builtin_realloc", ftype, BUILT_IN_REALLOC,
                          "realloc", false);
    The return type is correct, void *, but the first argument should be
    void * too and only second one size_t, while the above change changed
    realloc to be void *__builtin_realloc (size_t, void *);
    I went through all other changes from that commit and found that
    __builtin_sincos{,f,l} got broken as well, instead of the former
    void __builtin_sincos{,f,l} (ftype, ftype *, ftype *);
    where ftype is {double,float,long double} it is now incorrectly
    void __builtin_sincos{,f,l} (ftype *, ftype *);
    
    The following patch fixes that, plus some formatting issues around
    the spots I've changed.
    
    2023-01-11  Jakub Jelinek  <jakub@redhat.com>
    
            PR fortran/108349
            * f95-lang.c (gfc_init_builtin_function): Fix up function types
            for BUILT_IN_REALLOC and BUILT_IN_SINCOS{F,,L}.  Formatting fixes.
    
    (cherry picked from commit 0986c351aa8a9f08b3cb614baec13564dd62c114)

diff --git a/gcc/fortran/f95-lang.c b/gcc/fortran/f95-lang.c
index 44ebe3e294d..169c972f31b 100644
--- a/gcc/fortran/f95-lang.c
+++ b/gcc/fortran/f95-lang.c
@@ -692,31 +692,34 @@ gfc_init_builtin_functions (void)
                                                 float_type_node, NULL_TREE);
 
   func_cdouble_double = build_function_type_list (double_type_node,
-                                                  complex_double_type_node,
-                                                  NULL_TREE);
+						  complex_double_type_node,
+						  NULL_TREE);
 
   func_double_cdouble = build_function_type_list (complex_double_type_node,
-                                                  double_type_node, NULL_TREE);
+						  double_type_node, NULL_TREE);
 
-  func_clongdouble_longdouble =
-    build_function_type_list (long_double_type_node,
-                              complex_long_double_type_node, NULL_TREE);
+  func_clongdouble_longdouble
+    = build_function_type_list (long_double_type_node,
+				complex_long_double_type_node, NULL_TREE);
 
-  func_longdouble_clongdouble =
-    build_function_type_list (complex_long_double_type_node,
-                              long_double_type_node, NULL_TREE);
+  func_longdouble_clongdouble
+    = build_function_type_list (complex_long_double_type_node,
+				long_double_type_node, NULL_TREE);
 
   ptype = build_pointer_type (float_type_node);
-  func_float_floatp_floatp =
-    build_function_type_list (void_type_node, ptype, ptype, NULL_TREE);
+  func_float_floatp_floatp
+    = build_function_type_list (void_type_node, float_type_node, ptype, ptype,
+				NULL_TREE);
 
   ptype = build_pointer_type (double_type_node);
-  func_double_doublep_doublep =
-    build_function_type_list (void_type_node, ptype, ptype, NULL_TREE);
+  func_double_doublep_doublep
+    = build_function_type_list (void_type_node, double_type_node, ptype,
+				ptype, NULL_TREE);
 
   ptype = build_pointer_type (long_double_type_node);
-  func_longdouble_longdoublep_longdoublep =
-    build_function_type_list (void_type_node, ptype, ptype, NULL_TREE);
+  func_longdouble_longdoublep_longdoublep
+    = build_function_type_list (void_type_node, long_double_type_node, ptype,
+				ptype, NULL_TREE);
 
 /* Non-math builtins are defined manually, so they're not included here.  */
 #define OTHER_BUILTIN(ID,NAME,TYPE,CONST)
@@ -970,9 +973,8 @@ gfc_init_builtin_functions (void)
 		      "calloc", ATTR_NOTHROW_LEAF_MALLOC_LIST);
   DECL_IS_MALLOC (builtin_decl_explicit (BUILT_IN_CALLOC)) = 1;
 
-  ftype = build_function_type_list (pvoid_type_node,
-                                    size_type_node, pvoid_type_node,
-                                    NULL_TREE);
+  ftype = build_function_type_list (pvoid_type_node, pvoid_type_node,
+				    size_type_node, NULL_TREE);
   gfc_define_builtin ("__builtin_realloc", ftype, BUILT_IN_REALLOC,
 		      "realloc", ATTR_NOTHROW_LEAF_LIST);
 

commit 04cf6b57c7c467f615a16b7bbda574671e3fb2df
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Thu Jan 19 23:27:34 2023 +0100

    c++: Fix up handling of references to anon union members in initializers [PR53932]
    
    For anonymous union members we create artificial VAR_DECLs which
    have DECL_VALUE_EXPR for the actual COMPONENT_REF.  That works
    just fine inside of functions (including global dynamic constructors),
    because during gimplification such VAR_DECLs are gimplified as
    their DECL_VALUE_EXPR.  This is also done during regimplification.
    
    But references to these artificial vars in DECL_INITIAL expressions
    aren't ever replaced by the DECL_VALUE_EXPRs, so we end up either
    with link failures like on the testcase below, or worse ICEs with
    LTO.
    
    The following patch fixes those during cp_fully_fold_init where we
    already walk all the trees (!data->genericize means that
    function rather than cp_fold_function).
    
    2023-01-19  Jakub Jelinek  <jakub@redhat.com>
    
            PR c++/53932
            * cp-gimplify.c (cp_fold_r): During cp_fully_fold_init replace
            DECL_ANON_UNION_VAR_P VAR_DECLs with their corresponding
            DECL_VALUE_EXPR.
    
            * g++.dg/init/pr53932.C: New test.
    
    (cherry picked from commit 9b9a989adc042b304572fd6d4ade46b47be6ccb8)

diff --git a/gcc/cp/cp-gimplify.c b/gcc/cp/cp-gimplify.c
index 9d87ff42b2f..7a8a4f101cb 100644
--- a/gcc/cp/cp-gimplify.c
+++ b/gcc/cp/cp-gimplify.c
@@ -42,6 +42,14 @@ along with GCC; see the file COPYING3.  If not see
 #include "cgraph.h"
 #include "omp-general.h"
 
+struct cp_fold_data
+{
+  hash_set<tree> pset;
+  bool genericize; // called from cp_fold_function?
+
+  cp_fold_data (bool g): genericize (g) {}
+};
+
 /* Forward declarations.  */
 
 static tree cp_genericize_r (tree *, int *, void *);
@@ -750,8 +758,8 @@ cp_gimplify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p)
 				  init, VEC_INIT_EXPR_VALUE_INIT (*expr_p),
 				  from_array,
 				  tf_warning_or_error);
-	hash_set<tree> pset;
-	cp_walk_tree (expr_p, cp_fold_r, &pset, NULL);
+	cp_fold_data data (/*genericize*/true);
+	cp_walk_tree (expr_p, cp_fold_r, &data, NULL);
 	cp_genericize_tree (expr_p, false);
 	copy_if_shared (expr_p);
 	ret = GS_OK;
@@ -1172,14 +1180,31 @@ struct cp_genericize_data
      GIMPLE-form.  */
 
 static tree
-cp_fold_r (tree *stmt_p, int *walk_subtrees, void *data)
+cp_fold_r (tree *stmt_p, int *walk_subtrees, void *data_)
 {
-  tree stmt;
-  enum tree_code code;
+  cp_fold_data *data = (cp_fold_data*)data_;
+  tree stmt = *stmt_p;
+  enum tree_code code = TREE_CODE (stmt);
+
+  switch (code)
+    {
+    case VAR_DECL:
+      /* In initializers replace anon union artificial VAR_DECLs
+	 with their DECL_VALUE_EXPRs, as nothing will do it later.  */
+      if (DECL_ANON_UNION_VAR_P (stmt) && !data->genericize)
+	{
+	  *stmt_p = stmt = unshare_expr (DECL_VALUE_EXPR (stmt));
+	  break;
+	}
+      break;
+
+    default:
+      break;
+    }
 
   *stmt_p = stmt = cp_fold (*stmt_p);
 
-  if (((hash_set<tree> *) data)->add (stmt))
+  if (data->pset.add (stmt))
     {
       /* Don't walk subtrees of stmts we've already walked once, otherwise
 	 we can have exponential complexity with e.g. lots of nested
@@ -1246,8 +1271,8 @@ cp_fold_r (tree *stmt_p, int *walk_subtrees, void *data)
 void
 cp_fold_function (tree fndecl)
 {
-  hash_set<tree> pset;
-  cp_walk_tree (&DECL_SAVED_TREE (fndecl), cp_fold_r, &pset, NULL);
+  cp_fold_data data (/*genericize*/true);
+  cp_walk_tree (&DECL_SAVED_TREE (fndecl), cp_fold_r, &data, NULL);
 }
 
 /* Turn SPACESHIP_EXPR EXPR into GENERIC.  */
@@ -2525,8 +2550,8 @@ cp_fully_fold_init (tree x)
   if (processing_template_decl)
     return x;
   x = cp_fully_fold (x);
-  hash_set<tree> pset;
-  cp_walk_tree (&x, cp_fold_r, &pset, NULL);
+  cp_fold_data data (/*genericize*/false);
+  cp_walk_tree (&x, cp_fold_r, &data, NULL);
   return x;
 }
 
diff --git a/gcc/testsuite/g++.dg/init/pr53932.C b/gcc/testsuite/g++.dg/init/pr53932.C
new file mode 100644
index 00000000000..3b129e7d68a
--- /dev/null
+++ b/gcc/testsuite/g++.dg/init/pr53932.C
@@ -0,0 +1,25 @@
+// PR c++/53932
+// { dg-do link }
+
+static union { int i; };
+int &r = i;
+int s = i;
+int *t = &i;
+
+void
+foo (int **p, int *q)
+{
+  static int &u = i;
+  static int v = i;
+  static int *w = &i;
+  int &x = i;
+  int y = i;
+  int *z = &i;
+  *p = &i;
+  *q = i;
+}
+
+int
+main ()
+{
+}

commit e205cd507ed964defb2365b12296391b0be66dfc
Author: Eric Biggers <ebiggers@google.com>
Date:   Tue Jan 24 11:54:41 2023 +0100

    options: fix cl_target_option_print_diff() with strings
    
    Fix an obvious copy-and-paste error where ptr1 was used instead of ptr2.
    This bug caused the dump file produced by -fdump-ipa-inline-details to
    not correctly show the difference in target options when a function
    could not be inlined due to a target option mismatch.
    
    gcc/ChangeLog:
            PR bootstrap/90543
            * optc-save-gen.awk: Fix copy-and-paste error.
    
    Signed-off-by: Eric Biggers <ebiggers@google.com>
    (cherry picked from commit 9f0cb3368af735e95776769c4f28fa9cbb60eaf8)

diff --git a/gcc/optc-save-gen.awk b/gcc/optc-save-gen.awk
index 6033f519866..f87bef3e554 100644
--- a/gcc/optc-save-gen.awk
+++ b/gcc/optc-save-gen.awk
@@ -634,7 +634,7 @@ for (i = 0; i < n_target_string; i++) {
 	print "             indent, \"\",";
 	print "             \"" name "\",";
 	print "             ptr1->x_" name " ? ptr1->x_" name " : \"(null)\",";
-	print "             ptr2->x_" name " ? ptr1->x_" name " : \"(null)\");";
+	print "             ptr2->x_" name " ? ptr2->x_" name " : \"(null)\");";
 	print "";
 }
 

commit 5ebdbf03c7fb77c2535faca020e25a16658e8cb6
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Fri Jan 27 11:17:35 2023 +0100

    doc: Fix up return type of __builtin_va_arg_pack_len [PR108560]
    
    __builtin_va_arg_pack_len as implemented returned int since its introduction
    in 2007.  The initial documentation didn't mention any return type,
    which changed in 2010 in r0-103077-gab940b73bfabe2cec4 during some
    documentation formatting cleanups
    https://gcc.gnu.org/legacy-ml/gcc-patches/2010-09/msg01632.html
    I can understand that for formatting some type was needed there
    but what exactly hasn't been really discussed.
    
    So, I think we should change documentation to match the implementation,
    rather than change implementation to match the documentation.
    Most people don't use more than 2147483647 arguments to inline functions,
    and on poor targets with 16-bit ints I bet even having more than 65535
    arguments to inline functions would be highly unexpected.
    
    2023-01-27  Jakub Jelinek  <jakub@redhat.com>
    
            PR other/108560
            * doc/extend.texi: Fix up return type of __builtin_va_arg_pack_len
            from size_t to int.
    
    (cherry picked from commit 16f30680f403891556da2ad6329fcef9dc9b47db)

diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
index 8184f59e820..1732de2f5b8 100644
--- a/gcc/doc/extend.texi
+++ b/gcc/doc/extend.texi
@@ -688,7 +688,7 @@ myprintf (FILE *f, const char *format, ...)
 @end smallexample
 @end deftypefn
 
-@deftypefn {Built-in Function} {size_t} __builtin_va_arg_pack_len ()
+@deftypefn {Built-in Function} {int} __builtin_va_arg_pack_len ()
 This built-in function returns the number of anonymous arguments of
 an inline function.  It can be used only in inline functions that
 are always inlined, never compiled as a separate function, such

commit 73abd84646142b2a6177df9366917fea696d4df3
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Tue Jan 31 09:46:35 2023 +0100

    bbpart: Fix up ICE on asm goto [PR108596]
    
    On the following testcase we have asm goto in hot block with 2 successors,
    one cold to which it both falls through and has one of the label
    pointing to it and another hot successor with another label.
    
    Now, during bbpart we want to ensure that no blocks from one partition fall
    through into a block in a different partition.  fix_up_fall_thru_edges
    does that by temporarily clearing the EDGE_CROSSING on the fallthrough edge,
    calling force_nonfallthru and then depending on whether it created a new
    bb either set EDGE_CROSSING on the single successor edge from the new bb
    (the new bb is kept in the same partition as the predecessor block), or
    if no new bb has been created setting EDGE_CROSSING back on the fallthru
    edge which has been forced non-EDGE_FALLTHRU.
    For asm goto this doesn't always work, force_nonfallthru can create a new bb
    and change the fallthrough edge to point to that, but if the original
    fallthru destination block has its label referenced among the asm goto
    labels, it will create a new non-fallthru edge for the label(s).
    But because we've temporarily cheated and cleared EDGE_CROSSING on the edge,
    it is cleared on the new edge as well, then the caller sees we've created
    a new bb and just sets EDGE_CROSSING on the single fallthru edge from the
    new bb.  But the direct edge from cur_bb to fallthru edge's destination
    isn't handled and fails afterwards consistency checks, because it crosses
    partitions.
    
    The following patch notes the case and sets EDGE_CROSSING on that edge too.
    
    2023-01-31  Jakub Jelinek  <jakub@redhat.com>
    
            PR rtl-optimization/108596
            * bb-reorder.c (fix_up_fall_thru_edges): Handle the case where cur_bb
            ends with asm goto and has a crossing fallthrough edge to the same bb
            that contains at least one of its labels by restoring EDGE_CROSSING
            flag even on possible edge from cur_bb to new_bb successor.
    
            * gcc.c-torture/compile/pr108596.c: New test.
    
    (cherry picked from commit 603a6fbcaac1e80aa90d1d26318c881a53473066)

diff --git a/gcc/bb-reorder.c b/gcc/bb-reorder.c
index c635010c69f..07d360a9041 100644
--- a/gcc/bb-reorder.c
+++ b/gcc/bb-reorder.c
@@ -1998,6 +1998,7 @@ fix_up_fall_thru_edges (void)
 		     becomes EDGE_CROSSING.  */
 
 		  fall_thru->flags &= ~EDGE_CROSSING;
+		  unsigned old_count = EDGE_COUNT (cur_bb->succs);
 		  basic_block new_bb = force_nonfallthru (fall_thru);
 
 		  if (new_bb)
@@ -2009,7 +2010,25 @@ fix_up_fall_thru_edges (void)
 		      gcc_assert (BB_PARTITION (new_bb)
                                   == BB_PARTITION (cur_bb));
 
-		      single_succ_edge (new_bb)->flags |= EDGE_CROSSING;
+		      edge e = single_succ_edge (new_bb);
+		      e->flags |= EDGE_CROSSING;
+		      if (EDGE_COUNT (cur_bb->succs) > old_count)
+			{
+			  /* If asm goto has a crossing fallthrough edge
+			     and at least one of the labels to the same bb,
+			     force_nonfallthru can result in the fallthrough
+			     edge being redirected and a new edge added for the
+			     label or more labels to e->dest.  As we've
+			     temporarily cleared EDGE_CROSSING flag on the
+			     fallthrough edge, we need to restore it again.
+			     See PR108596.  */
+			  rtx_insn *j = BB_END (cur_bb);
+			  gcc_checking_assert (JUMP_P (j)
+					       && asm_noperands (PATTERN (j)));
+			  edge e2 = find_edge (cur_bb, e->dest);
+			  if (e2)
+			    e2->flags |= EDGE_CROSSING;
+			}
 		    }
 		  else
 		    {
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr108596.c b/gcc/testsuite/gcc.c-torture/compile/pr108596.c
new file mode 100644
index 00000000000..4de6c49d7ce
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/compile/pr108596.c
@@ -0,0 +1,26 @@
+/* PR rtl-optimization/108596 */
+
+__attribute__((__cold__)) void foo (void);
+void bar (void);
+
+void
+baz (void)
+{
+  asm goto ("" : : : : l1, l0);
+  goto l0;
+l1:
+  bar ();
+l0:
+  foo ();
+}
+
+void
+qux (void)
+{
+  asm goto ("" : : : : l1, l0);
+  __builtin_unreachable ();
+l1:
+  bar ();
+l0:
+  foo ();
+}

commit bd28648bf4923592462a938b31069a06ee39caea
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Wed Feb 1 10:38:46 2023 +0100

    c++, openmp: Handle some OMP_*/OACC_* constructs during constant expression evaluation [PR108607]
    
    While potential_constant_expression_1 handled most of OMP_* codes (by saying that
    they aren't potential constant expressions), OMP_SCOPE was missing in that list.
    I've also added OMP_SCAN, though that is less important (similarly to OMP_SECTION
    it ought to appear solely inside of OMP_{FOR,SIMD} resp. OMP_SECTIONS).
    As the testcase shows, it isn't enough, potential_constant_expression_1
    can catch only some cases, as soon as one uses switch or ifs where at least
    one of the possible paths could be constant expression, we can run into the
    same codes during cxx_eval_constant_expression, so this patch handles those
    there as well.
    
    2023-02-01  Jakub Jelinek  <jakub@redhat.com>
    
            PR c++/108607
            * constexpr.c (cxx_eval_constant_expression): Handle OMP_*
            and OACC_* constructs as non-constant.
            (potential_constant_expression_1): Handle OMP_SCAN.
    
            * g++.dg/gomp/pr108607.C: New test.
    
    (cherry picked from commit bfc070595bfb00abef88a002eee5d9117f5b86a7)

diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c
index 62cb2c5e06a..744b8796dd3 100644
--- a/gcc/cp/constexpr.c
+++ b/gcc/cp/constexpr.c
@@ -6718,6 +6718,49 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, tree t,
       *non_constant_p = true;
       return t;
 
+    case OMP_PARALLEL:
+    case OMP_TASK:
+    case OMP_FOR:
+    case OMP_SIMD:
+    case OMP_DISTRIBUTE:
+    case OMP_TASKLOOP:
+    case OMP_LOOP:
+    case OMP_TEAMS:
+    case OMP_TARGET_DATA:
+    case OMP_TARGET:
+    case OMP_SECTIONS:
+    case OMP_ORDERED:
+    case OMP_CRITICAL:
+    case OMP_SINGLE:
+    case OMP_SCAN:
+    case OMP_SECTION:
+    case OMP_MASTER:
+    case OMP_TASKGROUP:
+    case OMP_TARGET_UPDATE:
+    case OMP_TARGET_ENTER_DATA:
+    case OMP_TARGET_EXIT_DATA:
+    case OMP_ATOMIC:
+    case OMP_ATOMIC_READ:
+    case OMP_ATOMIC_CAPTURE_OLD:
+    case OMP_ATOMIC_CAPTURE_NEW:
+    case OMP_DEPOBJ:
+    case OACC_PARALLEL:
+    case OACC_KERNELS:
+    case OACC_SERIAL:
+    case OACC_DATA:
+    case OACC_HOST_DATA:
+    case OACC_LOOP:
+    case OACC_CACHE:
+    case OACC_DECLARE:
+    case OACC_ENTER_DATA:
+    case OACC_EXIT_DATA:
+    case OACC_UPDATE:
+      if (!ctx->quiet)
+	error_at (EXPR_LOCATION (t),
+		  "statement is not a constant expression");
+      *non_constant_p = true;
+      break;
+
     default:
       if (STATEMENT_CODE_P (TREE_CODE (t)))
 	{
@@ -8149,6 +8192,7 @@ potential_constant_expression_1 (tree t, bool want_rval, bool strict, bool now,
     case OMP_ORDERED:
     case OMP_CRITICAL:
     case OMP_SINGLE:
+    case OMP_SCAN:
     case OMP_SECTION:
     case OMP_MASTER:
     case OMP_TASKGROUP:
diff --git a/gcc/testsuite/g++.dg/gomp/pr108607.C b/gcc/testsuite/g++.dg/gomp/pr108607.C
new file mode 100644
index 00000000000..b0eb0483a8a
--- /dev/null
+++ b/gcc/testsuite/g++.dg/gomp/pr108607.C
@@ -0,0 +1,33 @@
+// PR c++/108607
+// { dg-do compile { target c++14 } }
+// { dg-options "-fopenmp" }
+
+constexpr int
+bar (int x)
+{
+  return x;
+}
+
+constexpr int
+baz (int x)
+{
+  switch (x)
+    {
+    case 42:
+      return 0;
+    case 3:
+      #pragma omp parallel	// { dg-error "statement is not a constant expression" }
+      x = bar (x);
+      return x;
+    case 4:
+      #pragma omp task		// { dg-error "statement is not a constant expression" }
+      x = bar (x);
+      return x;
+    default:
+      return -1;
+    }
+}
+
+constexpr int b = baz (42);
+constexpr int d = baz (3);
+constexpr int e = baz (4);

commit d868dd64ccd176cbd2829aa6175b40323f937b20
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Wed Feb 1 12:52:52 2023 +0100

    ree: Fix -fcompare-debug issues in combine_reaching_defs [PR108573]
    
    The PR78437 r7-4871 changes made combine_reaching_defs punt on
    WORD_REGISTER_OPERATIONS targets if a setter of smaller than word
    register has wider uses.  This unfortunately breaks -fcompare-debug,
    because if such a use appears only in DEBUG_INSN(s), while all other
    uses aren't wider than the setter, we can REE optimize it without -g
    and not with -g.
    
    Such decisions shouldn't be based on debug instructions.  We could try
    to reset them or adjust in some other way after we decide to perform the
    change, but at least on the testcase which used to fail on riscv64-linux
    the
    (debug_insn 8 7 9 2 (var_location:HI s (minus:HI (subreg:HI (and:DI (reg:DI 10 a0 [160])
                    (const_int 1 [0x1])) 0)
            (subreg:HI (ashiftrt:DI (reg/v:DI 9 s1 [orig:151 l ] [151])
                    (debug_expr:SI D#1)) 0))) "pr108573.c":12:5 -1
         (nil))
    clearly doesn't care about the upper bits and I have hard time imaging how
    could one end up with DEBUG_INSN which actually cares about those upper
    bits.
    
    So, the following patch just ignores uses on DEBUG_INSNs in this case,
    if we run into something where we'd need to do something further later on,
    let's deal with it when we have a testcase for it.
    
    2023-02-01  Jakub Jelinek  <jakub@redhat.com>
    
            PR debug/108573
            * ree.c (combine_reaching_defs): Don't return false for paradoxical
            subregs in DEBUG_INSNs.
    
            * gcc.dg/pr108573.c: New test.
    
    (cherry picked from commit e4473d7cf871c8ddf8f22d105c5af6375ebe37bf)

diff --git a/gcc/ree.c b/gcc/ree.c
index aa15498ff5e..180e36af64e 100644
--- a/gcc/ree.c
+++ b/gcc/ree.c
@@ -876,7 +876,8 @@ combine_reaching_defs (ext_cand *cand, const_rtx set_pat, ext_state *state)
 
 	  for (df_link *use = uses; use; use = use->next)
 	    if (paradoxical_subreg_p (GET_MODE (*DF_REF_LOC (use->ref)),
-				      GET_MODE (SET_DEST (*dest_sub_rtx))))
+				      GET_MODE (SET_DEST (*dest_sub_rtx)))
+		&& !DEBUG_INSN_P (DF_REF_INSN (use->ref)))
 	      return false;
 	}
 
@@ -965,7 +966,8 @@ combine_reaching_defs (ext_cand *cand, const_rtx set_pat, ext_state *state)
 	      rtx dest2 = SET_DEST (*dest_sub_rtx2);
 	      for (use = uses; use; use = use->next)
 		if (paradoxical_subreg_p (GET_MODE (*DF_REF_LOC (use->ref)),
-					  GET_MODE (dest2)))
+					  GET_MODE (dest2))
+		    && !DEBUG_INSN_P (DF_REF_INSN (use->ref)))
 		  break;
 	      if (use)
 		break;
diff --git a/gcc/testsuite/gcc.dg/pr108573.c b/gcc/testsuite/gcc.dg/pr108573.c
new file mode 100644
index 00000000000..5dd18043b2b
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr108573.c
@@ -0,0 +1,18 @@
+/* PR debug/108573 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -fcompare-debug" } */
+
+unsigned g;
+
+int bar (void);
+int baz (int);
+
+void
+foo (unsigned short s, long l)
+{
+  unsigned u = bar ();
+  s &= __builtin_add_overflow_p (0, u, 0);
+  s %= g;
+  s -= l >> s;
+  baz (s);
+}

commit 837723e0543d74663f05e1c000f7ea32e38ded5e
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Thu Feb 2 09:54:18 2023 +0100

    nested, openmp: Wrap OMP_CLAUSE_*_GIMPLE_SEQ into GIMPLE_BIND for declare_vars [PR108435]
    
    When gimplifying OMP_CLAUSE_{LASTPRIVATE,LINEAR}_STMT, we wrap it always
    into a GIMPLE_BIND, but when putting statements directly into
    OMP_CLAUSE_{LASTPRIVATE,LINEAR}_GIMPLE_SEQ, we do it only if needed (there
    are any temporaries that need to be declared in the sequence).
    convert_nonlocal_omp_clauses was relying on the GIMPLE_BIND to be there always
    because it called declare_vars on it.
    
    The following patch wraps it into GIMPLE_BIND in tree-nested if we need to
    declare_vars on it on demand.
    
    2023-02-02  Jakub Jelinek  <jakub@redhat.com>
    
            PR middle-end/108435
            * tree-nested.c (convert_nonlocal_omp_clauses)
            <case OMP_CLAUSE_LASTPRIVATE>: If info->new_local_var_chain and *seq
            is not a GIMPLE_BIND, wrap the sequence into a new GIMPLE_BIND
            before calling declare_vars.
            (convert_nonlocal_omp_clauses) <case OMP_CLAUSE_LINEAR>: Merge
            with the OMP_CLAUSE_LASTPRIVATE handling except for whether
            seq is initialized to &OMP_CLAUSE_LASTPRIVATE_GIMPLE_SEQ (clause)
            or &OMP_CLAUSE_LINEAR_GIMPLE_SEQ (clause).
    
            * gcc.dg/gomp/pr108435.c: New test.
    
    (cherry picked from commit 0f349928e16fdc7dba52561e8d40347909f9f0ff)

diff --git a/gcc/testsuite/gcc.dg/gomp/pr108435.c b/gcc/testsuite/gcc.dg/gomp/pr108435.c
new file mode 100644
index 00000000000..ca692ad0451
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/gomp/pr108435.c
@@ -0,0 +1,18 @@
+/* PR middle-end/108435 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -fopenmp" } */
+
+int
+main ()
+{
+  int i, j;
+  void
+  bar (void)
+  {
+    #pragma omp for simd collapse(2)
+     for (i = 1; i <= 16; i++)
+       for (j = 1; j <= 16; j++)
+	 ;
+  }
+  bar ();
+}
diff --git a/gcc/tree-nested.c b/gcc/tree-nested.c
index 0337fbe3787..3e30126a712 100644
--- a/gcc/tree-nested.c
+++ b/gcc/tree-nested.c
@@ -1448,29 +1448,29 @@ convert_nonlocal_omp_clauses (tree *pclauses, struct walk_stmt_info *wi)
 	  break;
 
 	case OMP_CLAUSE_LASTPRIVATE:
-	  {
-	    tree save_local_var_chain = info->new_local_var_chain;
-	    info->new_local_var_chain = NULL;
-	    gimple_seq *seq = &OMP_CLAUSE_LASTPRIVATE_GIMPLE_SEQ (clause);
-	    walk_body (convert_nonlocal_reference_stmt,
-		       convert_nonlocal_reference_op, info, seq);
-	    if (info->new_local_var_chain)
-	      declare_vars (info->new_local_var_chain,
-			    gimple_seq_first_stmt (*seq), false);
-	    info->new_local_var_chain = save_local_var_chain;
-	  }
-	  break;
-
 	case OMP_CLAUSE_LINEAR:
 	  {
 	    tree save_local_var_chain = info->new_local_var_chain;
 	    info->new_local_var_chain = NULL;
-	    gimple_seq *seq = &OMP_CLAUSE_LINEAR_GIMPLE_SEQ (clause);
+	    gimple_seq *seq;
+	    if (OMP_CLAUSE_CODE (clause) == OMP_CLAUSE_LASTPRIVATE)
+	      seq = &OMP_CLAUSE_LASTPRIVATE_GIMPLE_SEQ (clause);
+	    else
+	      seq = &OMP_CLAUSE_LINEAR_GIMPLE_SEQ (clause);
 	    walk_body (convert_nonlocal_reference_stmt,
 		       convert_nonlocal_reference_op, info, seq);
 	    if (info->new_local_var_chain)
-	      declare_vars (info->new_local_var_chain,
-			    gimple_seq_first_stmt (*seq), false);
+	      {
+		gimple *g = gimple_seq_first_stmt (*seq);
+		if (gimple_code (g) != GIMPLE_BIND)
+		  {
+		    g = gimple_build_bind (NULL_TREE, *seq, NULL_TREE);
+		    *seq = NULL;
+		    gimple_seq_add_stmt_without_update (seq, g);
+		  }
+		declare_vars (info->new_local_var_chain,
+			      gimple_seq_first_stmt (*seq), false);
+	      }
 	    info->new_local_var_chain = save_local_var_chain;
 	  }
 	  break;

commit 072b2cdb620767c283f1329e95c7d4d35686596e
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Fri Feb 3 21:37:27 2023 +0100

    fortran: Fix up hash table usage in gfc_trans_use_stmts [PR108451]
    
    The first testcase in the PR (which I haven't included in the patch because
    it is unclear to me if it is supposed to be valid or not) ICEs since extra
    hash table checking has been added recently.  The problem is that
    gfc_trans_use_stmts does
              tree *slot = entry->decls->find_slot_with_hash (rent->use_name, hash,
                                                              INSERT);
              if (*slot == NULL)
    and later on doesn't store anything into *slot and continues.  Another spot
    a few lines later correctly clears the slot if it decides not to use the
    slot, so the following patch does the same.
    
    2023-02-03  Jakub Jelinek  <jakub@redhat.com>
    
            PR fortran/108451
            * trans-decl.c (gfc_trans_use_stmts): Call clear_slot before
            doing continue.
    
    (cherry picked from commit 76f7f0eddcb7c418d1ec3dea3e2341ca99097301)

diff --git a/gcc/fortran/trans-decl.c b/gcc/fortran/trans-decl.c
index b616db34c3f..897928a327f 100644
--- a/gcc/fortran/trans-decl.c
+++ b/gcc/fortran/trans-decl.c
@@ -5408,7 +5408,11 @@ gfc_trans_use_stmts (gfc_namespace * ns)
 	      /* Sometimes, generic interfaces wind up being over-ruled by a
 		 local symbol (see PR41062).  */
 	      if (!st->n.sym->attr.use_assoc)
-		continue;
+		{
+		  *slot = error_mark_node;
+		  entry->decls->clear_slot (slot);
+		  continue;
+		}
 
 	      if (st->n.sym->backend_decl
 		  && DECL_P (st->n.sym->backend_decl)

commit 0200ac49e6281fd86ad391b539a4f564ca44e397
Author: Andrew Pinski <apinski@marvell.com>
Date:   Thu Feb 9 16:03:54 2023 +0100

    match.pd: When simplifying BFR of an insert, require a mode precision integral type [PR108688]
    
    The same problem as PR 88739 has crept in but
    this time in match.pd when simplifying bit_field_ref of
    an bit_insert. That is we are generating a BIT_FIELD_REF
    of a non-mode-precision integral type.
    
            PR tree-optimization/108688
            * match.pd (bit_field_ref [bit_insert]): Avoid generating
            BIT_FIELD_REFs of non-mode-precision integral operands.
    
            * gcc.c-torture/compile/pr108688-1.c: New test.
    
    (cherry picked from commit 44f308e59bfa0f93ae05b17e257d8563c12399fd)

diff --git a/gcc/match.pd b/gcc/match.pd
index 1a4f0dab463..cab87c5f32d 100644
--- a/gcc/match.pd
+++ b/gcc/match.pd
@@ -5724,7 +5724,9 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
       isize = tree_to_uhwi (TYPE_SIZE (TREE_TYPE (@1)));
   }
   (switch
-   (if (wi::leu_p (wi::to_wide (@ipos), wi::to_wide (@rpos))
+   (if ((!INTEGRAL_TYPE_P (TREE_TYPE (@1))
+         || type_has_mode_precision_p (TREE_TYPE (@1)))
+        && wi::leu_p (wi::to_wide (@ipos), wi::to_wide (@rpos))
 	&& wi::leu_p (wi::to_wide (@rpos) + wi::to_wide (@rsize),
 		      wi::to_wide (@ipos) + isize))
     (BIT_FIELD_REF @1 @rsize { wide_int_to_tree (bitsizetype,
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr108688-1.c b/gcc/testsuite/gcc.c-torture/compile/pr108688-1.c
new file mode 100644
index 00000000000..43d782d62bd
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/compile/pr108688-1.c
@@ -0,0 +1,15 @@
+
+
+union U { signed int d : 7; signed int e : 2; } u;
+int a, b;
+
+void
+foo (void)
+{
+  for (int i = 0; i < 64; i++)
+    {
+      u.d = a;
+      u.e ^= b;
+    }
+}
+

commit 61948b4113a817b0cd61e7e5311d9cfae31bc623
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Sat Jan 14 10:17:14 2023 +0100

    c++: Avoid incorrect shortening of divisions [PR108365]
    
    The following testcase is miscompiled, because we shorten the division
    in a case where it should not be shortened.
    Divisions (and modulos) can be shortened if it is unsigned division/modulo,
    or if it is signed division/modulo where we can prove the dividend will
    not be the minimum signed value or divisor will not be -1, because e.g.
    on sizeof(long long)==sizeof(int)*2 && __INT_MAX__ == 0x7fffffff targets
    (-2147483647 - 1) / -1 is UB
    but
    (int) (-2147483648LL / -1LL) is not, it is -2147483648.
    The primary aim of both the C and C++ FE division/modulo shortening I assume
    was for the implicit integral promotions of {,signed,unsigned} {char,short}
    and because at this point we have no VRP information etc., the shortening
    is done if the integral promotion is from unsigned type for the divisor
    or if the dividend is an integer constant other than -1.
    This works fine for char/short -> int promotions when char/short have
    smaller precision than int - unsigned char -> int or unsigned short -> int
    will always be a positive int, so never the most negative.
    
    Now, the C FE checks whether orig_op0 is TYPE_UNSIGNED where op0 is either
    the same as orig_op0 or that promoted to int, I think that works fine,
    if it isn't promoted, either the division/modulo common type will have the
    same precision as op0 but then the division/modulo is unsigned and so
    without UB, or it will be done in wider precision (e.g. because op1 has
    wider precision), but then op0 can't be minimum signed value.  Or it has
    been promoted to int, but in that case it was again from narrower type and
    so never minimum signed int.
    
    But the C++ FE was checking if op0 is a NOP_EXPR from TYPE_UNSIGNED.
    First of all, not sure if the operand of NOP_EXPR couldn't be non-integral
    type where TYPE_UNSIGNED wouldn't be meaningful, but more importantly,
    even if it is a cast from unsigned integral type, we only know it can't be
    minimum signed value if it is a widening cast, if it is same precision or
    narrowing cast, we know nothing.
    
    So, the following patch for the NOP_EXPR cases checks just in case that
    it is from integral type and more importantly checks it is a widening
    conversion.
    
    2023-01-14  Jakub Jelinek  <jakub@redhat.com>
    
            PR c++/108365
            * typeck.c (cp_build_binary_op): For integral division or modulo,
            shorten if type0 is unsigned, or op0 is cast from narrower unsigned
            integral type or stripped_op1 is INTEGER_CST other than -1.
    
            * g++.dg/opt/pr108365.C: New test.
            * g++.dg/warn/pr108365.C: New test.
    
    (cherry picked from commit 5b3a88640f962d4ffca31ae651bed2d8672f1a8c)

diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index c2194b96400..548c81ef12c 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -4779,7 +4779,12 @@ cp_build_binary_op (const op_location_t &location,
 		 it was unsigned.  */
 	      tree stripped_op1 = tree_strip_any_location_wrapper (op1);
 	      shorten = ((TREE_CODE (op0) == NOP_EXPR
-			  && TYPE_UNSIGNED (TREE_TYPE (TREE_OPERAND (op0, 0))))
+			  && INTEGRAL_TYPE_P (TREE_TYPE (TREE_OPERAND (op0,
+								       0)))
+			  && TYPE_UNSIGNED (TREE_TYPE (TREE_OPERAND (op0, 0)))
+			  && (TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (op0,
+								       0)))
+			      < TYPE_PRECISION (type0)))
 			 || (TREE_CODE (stripped_op1) == INTEGER_CST
 			     && ! integer_all_onesp (stripped_op1)));
 	    }
@@ -4815,7 +4820,10 @@ cp_build_binary_op (const op_location_t &location,
 	     only if unsigned or if dividing by something we know != -1.  */
 	  tree stripped_op1 = tree_strip_any_location_wrapper (op1);
 	  shorten = ((TREE_CODE (op0) == NOP_EXPR
-		      && TYPE_UNSIGNED (TREE_TYPE (TREE_OPERAND (op0, 0))))
+		      && INTEGRAL_TYPE_P (TREE_TYPE (TREE_OPERAND (op0, 0)))
+		      && TYPE_UNSIGNED (TREE_TYPE (TREE_OPERAND (op0, 0)))
+		      && (TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (op0, 0)))
+			  < TYPE_PRECISION (type0)))
 		     || (TREE_CODE (stripped_op1) == INTEGER_CST
 			 && ! integer_all_onesp (stripped_op1)));
 	  common = 1;
diff --git a/gcc/testsuite/g++.dg/opt/pr108365.C b/gcc/testsuite/g++.dg/opt/pr108365.C
new file mode 100644
index 00000000000..47eefa2b29a
--- /dev/null
+++ b/gcc/testsuite/g++.dg/opt/pr108365.C
@@ -0,0 +1,13 @@
+// PR c++/108365
+// { dg-do run }
+
+char b = 1;
+
+int
+main ()
+{
+#if __CHAR_BIT__ == 8 && __SIZEOF_SHORT__ == 2 && __SIZEOF_INT__ == 4 && __SIZEOF_LONG_LONG__ == 8
+  while ((short) ((long long) (unsigned long long) (-__INT_MAX__ - 1) / (long long) (b ? -1 : 0)))
+    ;
+#endif
+}
diff --git a/gcc/testsuite/g++.dg/warn/pr108365.C b/gcc/testsuite/g++.dg/warn/pr108365.C
new file mode 100644
index 00000000000..6d40957c9b3
--- /dev/null
+++ b/gcc/testsuite/g++.dg/warn/pr108365.C
@@ -0,0 +1,5 @@
+// PR c++/108365
+// { dg-do compile { target { { { ilp32 || lp64 } || llp64 } && c++11 } } }
+
+constexpr char b = 1;
+long t = (short) ((long long) (unsigned long long) (-__INT_MAX__ - 1) / (long long) (b ? -1 : 0)); // { dg-bogus "integer overflow in expression of type" }

commit 8776316329f34ba87cca64622e93c05ff36890bb
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Tue Jan 24 11:28:00 2023 +0100

    c++: Handle structured bindings like anon unions in initializers [PR108474]
    
    As reported by Andrew Pinski, structured bindings (with the exception
    of the ones using std::tuple_{size,element} and get which are really
    standalone variables in addition to the binding one) also use
    DECL_VALUE_EXPR and needs the same treatment in static initializers.
    
    On Sun, Jan 22, 2023 at 07:19:07PM -0500, Jason Merrill wrote:
    > Though, actually, why not instead fix expand_expr_real_1 (and staticp) to
    > look through DECL_VALUE_EXPR?
    
    Doing it when emitting the initializers seems to be too late to me,
    we in various spots try to put parts of the static var DECL_INITIAL expressions
    into the IL, or e.g. for varpool purposes remember which vars are referenced
    there.
    
    This patch moves it to record_reference, which is called from varpool_node::analyze
    and so about the same time as gimplification of the bodies which also
    replaces DECL_VALUE_EXPRs.
    
    2023-01-24  Jakub Jelinek  <jakub@redhat.com>
    
            PR c++/108474
            * cp-gimplify.c (cp_fold_r): Handle structured bindings
            vars like anon union artificial vars.
    
            * g++.dg/cpp1z/decomp57.C: New test.
            * g++.dg/cpp1z/decomp58.C: New test.
    
    (cherry picked from commit b84e21115700523b4d0ac44275443f7b9c670344)

diff --git a/gcc/cp/cp-gimplify.c b/gcc/cp/cp-gimplify.c
index 7a8a4f101cb..7f94796ea01 100644
--- a/gcc/cp/cp-gimplify.c
+++ b/gcc/cp/cp-gimplify.c
@@ -1190,8 +1190,12 @@ cp_fold_r (tree *stmt_p, int *walk_subtrees, void *data_)
     {
     case VAR_DECL:
       /* In initializers replace anon union artificial VAR_DECLs
-	 with their DECL_VALUE_EXPRs, as nothing will do it later.  */
-      if (DECL_ANON_UNION_VAR_P (stmt) && !data->genericize)
+	 with their DECL_VALUE_EXPRs, as nothing will do it later.
+	 Ditto for structured bindings.  */
+      if (!data->genericize
+	  && DECL_HAS_VALUE_EXPR_P (stmt)
+	  && (DECL_ANON_UNION_VAR_P (stmt)
+	      || (DECL_DECOMPOSITION_P (stmt) && DECL_DECOMP_BASE (stmt))))
 	{
 	  *stmt_p = stmt = unshare_expr (DECL_VALUE_EXPR (stmt));
 	  break;
diff --git a/gcc/testsuite/g++.dg/cpp1z/decomp57.C b/gcc/testsuite/g++.dg/cpp1z/decomp57.C
new file mode 100644
index 00000000000..923862e78d1
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1z/decomp57.C
@@ -0,0 +1,27 @@
+// PR c++/108474
+// { dg-do link { target c++17 } }
+
+struct T { int i, j; };
+T h;
+auto [i, j] = h;
+int &r = i;
+int s = i;
+int *t = &i;
+
+void
+foo (int **p, int *q)
+{
+  static int &u = i;
+  static int v = i;
+  static int *w = &i;
+  int &x = i;
+  int y = i;
+  int *z = &i;
+  *p = &i;
+  *q = i;
+}
+
+int
+main ()
+{
+}
diff --git a/gcc/testsuite/g++.dg/cpp1z/decomp58.C b/gcc/testsuite/g++.dg/cpp1z/decomp58.C
new file mode 100644
index 00000000000..b2604373bde
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1z/decomp58.C
@@ -0,0 +1,39 @@
+// PR c++/108474
+// { dg-do link { target c++17 } }
+
+namespace std {
+  template <typename T> struct tuple_size;
+  template <int, typename> struct tuple_element;
+}
+
+struct A {
+  int i;
+  template <int I> int& get() { return i; }
+};
+
+template <> struct std::tuple_size <A> { static const int value = 2; };
+template <int I> struct std::tuple_element <I, A> { using type = int; };
+
+struct A a;
+auto [i, j] = a;
+int &r = i;
+int s = i;
+int *t = &i;
+
+void
+foo (int **p, int *q)
+{
+  static int &u = i;
+  static int v = i;
+  static int *w = &i;
+  int &x = i;
+  int y = i;
+  int *z = &i;
+  *p = &i;
+  *q = i;
+}
+
+int
+main ()
+{
+}

commit be80a2e64a38540a371fa4f03513653d2741bc89
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Thu Feb 9 17:43:19 2023 +0100

    i386: Call get_available_features for all CPUs with max_level >= 1 [PR100758]
    
    get_available_features doesn't depend on cpu_model2->__cpu_{family,model}
    and just sets stuff up based on CPUID leaf 1, or some extended ones,
    so I wonder why are we calling it separately for Intel, AMD and Zhaoxin
    and not for all other CPUs too?  I think various programs in the wild
    which aren't using __builtin_cpu_{is,supports} just check the various CPUID
    leafs and query bits in there, without blacklisting unknown CPU vendors,
    so I think even __builtin_cpu_supports ("sse2") etc. should be reliable
    if those VENDOR_{CENTAUR,CYRIX,NSC,OTHER} CPUs set those bits in CPUID leaf
    1 or some extended ones.  Calling it for all CPUs also means it can be
    inlined because there will be just a single caller.
    
    I have tested it on Intel and Martin tested it on AMD, but can't test it
    on non-Intel/AMD; for Intel/AMD/Zhaoxin it should be really no change in
    behavior.
    
    2023-02-09  Jakub Jelinek  <jakub@redhat.com>
    
            PR target/100758
            * config/i386/cpuinfo.c (cpu_indicator_init): Call
            get_available_features for all CPUs with max_level >= 1, rather
            than just Intel or AMD.
    
    (cherry picked from commit b24e9c083093a9e1b1007933a184c02f7ff058db)

diff --git a/libgcc/config/i386/cpuinfo.c b/libgcc/config/i386/cpuinfo.c
index 83301a1445f..ad250edbcb7 100644
--- a/libgcc/config/i386/cpuinfo.c
+++ b/libgcc/config/i386/cpuinfo.c
@@ -474,6 +474,9 @@ __cpu_indicator_init (void)
   extended_model = (eax >> 12) & 0xf0;
   extended_family = (eax >> 20) & 0xff;
 
+  /* Find available features. */
+  get_available_features (ecx, edx, max_level);
+
   if (vendor == signature_INTEL_ebx)
     {
       /* Adjust model and family for Intel CPUS. */
@@ -487,8 +490,6 @@ __cpu_indicator_init (void)
 
       /* Get CPU type.  */
       get_intel_cpu (family, model, brand_id);
-      /* Find available features. */
-      get_available_features (ecx, edx, max_level);
       __cpu_model.__cpu_vendor = VENDOR_INTEL;
     }
   else if (vendor == signature_AMD_ebx)
@@ -502,8 +503,6 @@ __cpu_indicator_init (void)
 
       /* Get CPU type.  */
       get_amd_cpu (family, model);
-      /* Find available features. */
-      get_available_features (ecx, edx, max_level);
       __cpu_model.__cpu_vendor = VENDOR_AMD;
     }
   else

commit 94bee742afd56c051a20ec0fcf85edc022ae39ff
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Thu Feb 16 12:15:03 2023 +0100

    libgomp: Fix up some typos in libgomp.texi
    
    I decided to check for repeated the the in libgomp and noticed
    there are several occurrences of a typo theads rather than threads
    in libgomp.texi.
    
    2023-02-16  Jakub Jelinek  <jakub@redhat.com>
    
            * libgomp.texi: Fix typos - theads -> threads.
    
    (cherry picked from commit 0b9bd33d69d0c30330a465e6bad262d90c94d4ea)

diff --git a/libgomp/libgomp.texi b/libgomp/libgomp.texi
index 5331230c207..80e06c93ce9 100644
--- a/libgomp/libgomp.texi
+++ b/libgomp/libgomp.texi
@@ -175,7 +175,7 @@ linkage, and do not throw exceptions.
 * omp_get_num_procs::           Number of processors online
 * omp_get_num_teams::           Number of teams
 * omp_get_num_threads::         Size of the active team
-* omp_get_proc_bind::           Whether theads may be moved between CPUs
+* omp_get_proc_bind::           Whether threads may be moved between CPUs
 * omp_get_schedule::            Obtain the runtime scheduling method
 * omp_get_team_num::            Get team number
 * omp_get_team_size::           Number of threads in a team
@@ -582,7 +582,7 @@ one thread per CPU online is used.
 
 
 @node omp_get_proc_bind
-@section @code{omp_get_proc_bind} -- Whether theads may be moved between CPUs
+@section @code{omp_get_proc_bind} -- Whether threads may be moved between CPUs
 @table @asis
 @item @emph{Description}:
 This functions returns the currently active thread affinity policy, which is
@@ -1349,8 +1349,8 @@ beginning with @env{GOMP_} are GNU extensions.
 * OMP_MAX_TASK_PRIORITY::   Set the maximum task priority value
 * OMP_NESTED::              Nested parallel regions
 * OMP_NUM_THREADS::         Specifies the number of threads to use
-* OMP_PROC_BIND::           Whether theads may be moved between CPUs
-* OMP_PLACES::              Specifies on which CPUs the theads should be placed
+* OMP_PROC_BIND::           Whether threads may be moved between CPUs
+* OMP_PLACES::              Specifies on which CPUs the threads should be placed
 * OMP_STACKSIZE::           Set default thread stack size
 * OMP_SCHEDULE::            How threads are scheduled
 * OMP_THREAD_LIMIT::        Set the maximum number of threads
@@ -1517,12 +1517,12 @@ level.  If undefined one thread per CPU is used.
 
 
 @node OMP_PROC_BIND
-@section @env{OMP_PROC_BIND} -- Whether theads may be moved between CPUs
+@section @env{OMP_PROC_BIND} -- Whether threads may be moved between CPUs
 @cindex Environment Variable
 @table @asis
 @item @emph{Description}:
 Specifies whether threads may be moved between processors.  If set to
-@code{TRUE}, OpenMP theads should not be moved; if set to @code{FALSE}
+@code{TRUE}, OpenMP threads should not be moved; if set to @code{FALSE}
 they may be moved.  Alternatively, a comma separated list with the
 values @code{MASTER}, @code{CLOSE} and @code{SPREAD} can be used to specify
 the thread affinity policy for the corresponding nesting level.  With
@@ -1544,7 +1544,7 @@ When undefined, @env{OMP_PROC_BIND} defaults to @code{TRUE} when
 
 
 @node OMP_PLACES
-@section @env{OMP_PLACES} -- Specifies on which CPUs the theads should be placed
+@section @env{OMP_PLACES} -- Specifies on which CPUs the threads should be placed
 @cindex Environment Variable
 @table @asis
 @item @emph{Description}:

commit 8f8472f3119751df3b4906bbd08fdad74ef63f33
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Fri Feb 24 10:12:44 2023 +0100

    i386: Fix up builtins used in avx512bf16vlintrin.h [PR108881]
    
    The builtins used in avx512bf16vlintrin.h implementation need both
    avx512bf16 and avx512vl ISAs, which the header ensures for them, but
    the builtins weren't actually requiring avx512vl, so when used by hand
    with just -mavx512bf16 -mno-avx512vl it resulted in ICEs.
    
    Fixed by adding OPTION_MASK_ISA_AVX512VL to their BDESC.
    
    2023-02-24  Jakub Jelinek  <jakub@redhat.com>
    
            PR target/108881
            * config/i386/i386-builtin.def (__builtin_ia32_cvtne2ps2bf16_v16hi,
            __builtin_ia32_cvtne2ps2bf16_v16hi_mask,
            __builtin_ia32_cvtne2ps2bf16_v16hi_maskz,
            __builtin_ia32_cvtne2ps2bf16_v8hi,
            __builtin_ia32_cvtne2ps2bf16_v8hi_mask,
            __builtin_ia32_cvtne2ps2bf16_v8hi_maskz,
            __builtin_ia32_cvtneps2bf16_v8sf_mask,
            __builtin_ia32_cvtneps2bf16_v8sf_maskz,
            __builtin_ia32_cvtneps2bf16_v4sf_mask,
            __builtin_ia32_cvtneps2bf16_v4sf_maskz,
            __builtin_ia32_dpbf16ps_v8sf, __builtin_ia32_dpbf16ps_v8sf_mask,
            __builtin_ia32_dpbf16ps_v8sf_maskz, __builtin_ia32_dpbf16ps_v4sf,
            __builtin_ia32_dpbf16ps_v4sf_mask,
            __builtin_ia32_dpbf16ps_v4sf_maskz): Require also
            OPTION_MASK_ISA_AVX512VL.
    
            * gcc.target/i386/avx512bf16-pr108881.c: New test.
    
    (cherry picked from commit 0ccfa3884f638816af0f5a3f0ee2695e0771ef6d)

diff --git a/gcc/config/i386/i386-builtin.def b/gcc/config/i386/i386-builtin.def
index 4d5863ce0aa..4d44c2c34d9 100644
--- a/gcc/config/i386/i386-builtin.def
+++ b/gcc/config/i386/i386-builtin.def
@@ -2715,30 +2715,30 @@ BDESC (0, OPTION_MASK_ISA2_VAES, CODE_FOR_vaesenclast_v64qi, "__builtin_ia32_vae
 BDESC (0, OPTION_MASK_ISA2_AVX512BF16, CODE_FOR_avx512f_cvtne2ps2bf16_v32hi, "__builtin_ia32_cvtne2ps2bf16_v32hi", IX86_BUILTIN_CVTNE2PS2HI16_V32HI, UNKNOWN, (int) V32HI_FTYPE_V16SF_V16SF)
 BDESC (0, OPTION_MASK_ISA2_AVX512BF16, CODE_FOR_avx512f_cvtne2ps2bf16_v32hi_mask, "__builtin_ia32_cvtne2ps2bf16_v32hi_mask", IX86_BUILTIN_CVTNE2PS2HI16_V32HI_MASK, UNKNOWN, (int) V32HI_FTYPE_V16SF_V16SF_V32HI_USI)
 BDESC (0, OPTION_MASK_ISA2_AVX512BF16, CODE_FOR_avx512f_cvtne2ps2bf16_v32hi_maskz, "__builtin_ia32_cvtne2ps2bf16_v32hi_maskz", IX86_BUILTIN_CVTNE2PS2HI16_V32HI_MASKZ, UNKNOWN, (int) V32HI_FTYPE_V16SF_V16SF_USI)
-BDESC (0, OPTION_MASK_ISA2_AVX512BF16, CODE_FOR_avx512f_cvtne2ps2bf16_v16hi, "__builtin_ia32_cvtne2ps2bf16_v16hi", IX86_BUILTIN_CVTNE2PS2HI16_V16HI, UNKNOWN, (int) V16HI_FTYPE_V8SF_V8SF)
-BDESC (0, OPTION_MASK_ISA2_AVX512BF16, CODE_FOR_avx512f_cvtne2ps2bf16_v16hi_mask, "__builtin_ia32_cvtne2ps2bf16_v16hi_mask", IX86_BUILTIN_CVTNE2PS2HI16_V16HI_MASK, UNKNOWN, (int) V16HI_FTYPE_V8SF_V8SF_V16HI_UHI)
-BDESC (0, OPTION_MASK_ISA2_AVX512BF16, CODE_FOR_avx512f_cvtne2ps2bf16_v16hi_maskz, "__builtin_ia32_cvtne2ps2bf16_v16hi_maskz", IX86_BUILTIN_CVTNE2PS2HI16_V16HI_MASKZ, UNKNOWN, (int) V16HI_FTYPE_V8SF_V8SF_UHI)
-BDESC (0, OPTION_MASK_ISA2_AVX512BF16, CODE_FOR_avx512f_cvtne2ps2bf16_v8hi, "__builtin_ia32_cvtne2ps2bf16_v8hi", IX86_BUILTIN_CVTNE2PS2HI16_V8HI, UNKNOWN, (int) V8HI_FTYPE_V4SF_V4SF)
-BDESC (0, OPTION_MASK_ISA2_AVX512BF16, CODE_FOR_avx512f_cvtne2ps2bf16_v8hi_mask, "__builtin_ia32_cvtne2ps2bf16_v8hi_mask", IX86_BUILTIN_CVTNE2PS2HI16_V8HI_MASK, UNKNOWN, (int) V8HI_FTYPE_V4SF_V4SF_V8HI_UQI)
-BDESC (0, OPTION_MASK_ISA2_AVX512BF16, CODE_FOR_avx512f_cvtne2ps2bf16_v8hi_maskz, "__builtin_ia32_cvtne2ps2bf16_v8hi_maskz", IX86_BUILTIN_CVTNE2PS2HI16_V8HI_MASKZ, UNKNOWN, (int) V8HI_FTYPE_V4SF_V4SF_UQI)
+BDESC (OPTION_MASK_ISA_AVX512VL, OPTION_MASK_ISA2_AVX512BF16, CODE_FOR_avx512f_cvtne2ps2bf16_v16hi, "__builtin_ia32_cvtne2ps2bf16_v16hi", IX86_BUILTIN_CVTNE2PS2HI16_V16HI, UNKNOWN, (int) V16HI_FTYPE_V8SF_V8SF)
+BDESC (OPTION_MASK_ISA_AVX512VL, OPTION_MASK_ISA2_AVX512BF16, CODE_FOR_avx512f_cvtne2ps2bf16_v16hi_mask, "__builtin_ia32_cvtne2ps2bf16_v16hi_mask", IX86_BUILTIN_CVTNE2PS2HI16_V16HI_MASK, UNKNOWN, (int) V16HI_FTYPE_V8SF_V8SF_V16HI_UHI)
+BDESC (OPTION_MASK_ISA_AVX512VL, OPTION_MASK_ISA2_AVX512BF16, CODE_FOR_avx512f_cvtne2ps2bf16_v16hi_maskz, "__builtin_ia32_cvtne2ps2bf16_v16hi_maskz", IX86_BUILTIN_CVTNE2PS2HI16_V16HI_MASKZ, UNKNOWN, (int) V16HI_FTYPE_V8SF_V8SF_UHI)
+BDESC (OPTION_MASK_ISA_AVX512VL, OPTION_MASK_ISA2_AVX512BF16, CODE_FOR_avx512f_cvtne2ps2bf16_v8hi, "__builtin_ia32_cvtne2ps2bf16_v8hi", IX86_BUILTIN_CVTNE2PS2HI16_V8HI, UNKNOWN, (int) V8HI_FTYPE_V4SF_V4SF)
+BDESC (OPTION_MASK_ISA_AVX512VL, OPTION_MASK_ISA2_AVX512BF16, CODE_FOR_avx512f_cvtne2ps2bf16_v8hi_mask, "__builtin_ia32_cvtne2ps2bf16_v8hi_mask", IX86_BUILTIN_CVTNE2PS2HI16_V8HI_MASK, UNKNOWN, (int) V8HI_FTYPE_V4SF_V4SF_V8HI_UQI)
+BDESC (OPTION_MASK_ISA_AVX512VL, OPTION_MASK_ISA2_AVX512BF16, CODE_FOR_avx512f_cvtne2ps2bf16_v8hi_maskz, "__builtin_ia32_cvtne2ps2bf16_v8hi_maskz", IX86_BUILTIN_CVTNE2PS2HI16_V8HI_MASKZ, UNKNOWN, (int) V8HI_FTYPE_V4SF_V4SF_UQI)
 BDESC (0, OPTION_MASK_ISA2_AVX512BF16, CODE_FOR_avx512f_cvtneps2bf16_v16sf, "__builtin_ia32_cvtneps2bf16_v16sf", IX86_BUILTIN_CVTNEPS2HI16_V16SF, UNKNOWN, (int) V16HI_FTYPE_V16SF)
 BDESC (0, OPTION_MASK_ISA2_AVX512BF16, CODE_FOR_avx512f_cvtneps2bf16_v16sf_mask, "__builtin_ia32_cvtneps2bf16_v16sf_mask", IX86_BUILTIN_CVTNEPS2HI16_V16SF_MASK, UNKNOWN, (int) V16HI_FTYPE_V16SF_V16HI_UHI)
 BDESC (0, OPTION_MASK_ISA2_AVX512BF16, CODE_FOR_avx512f_cvtneps2bf16_v16sf_maskz, "__builtin_ia32_cvtneps2bf16_v16sf_maskz", IX86_BUILTIN_CVTNE2PS2HI16_V16SF_MASKZ, UNKNOWN, (int) V16HI_FTYPE_V16SF_UHI)
-BDESC (0, OPTION_MASK_ISA2_AVX512BF16, CODE_FOR_avx512f_cvtneps2bf16_v8sf, "__builtin_ia32_cvtneps2bf16_v8sf", IX86_BUILTIN_CVTNEPS2HI16_V8SF, UNKNOWN, (int) V8HI_FTYPE_V8SF)
-BDESC (0, OPTION_MASK_ISA2_AVX512BF16, CODE_FOR_avx512f_cvtneps2bf16_v8sf_mask, "__builtin_ia32_cvtneps2bf16_v8sf_mask", IX86_BUILTIN_CVTNEPS2HI16_V8SF_MASK, UNKNOWN, (int) V8HI_FTYPE_V8SF_V8HI_UQI)
-BDESC (0, OPTION_MASK_ISA2_AVX512BF16, CODE_FOR_avx512f_cvtneps2bf16_v8sf_maskz, "__builtin_ia32_cvtneps2bf16_v8sf_maskz", IX86_BUILTIN_CVTNE2PS2HI16_V8SF_MASKZ, UNKNOWN, (int) V8HI_FTYPE_V8SF_UQI)
-BDESC (0, OPTION_MASK_ISA2_AVX512BF16, CODE_FOR_avx512f_cvtneps2bf16_v4sf, "__builtin_ia32_cvtneps2bf16_v4sf", IX86_BUILTIN_CVTNEPS2HI16_V4SF, UNKNOWN, (int) V8HI_FTYPE_V4SF)
-BDESC (0, OPTION_MASK_ISA2_AVX512BF16, CODE_FOR_avx512f_cvtneps2bf16_v4sf_mask, "__builtin_ia32_cvtneps2bf16_v4sf_mask", IX86_BUILTIN_CVTNEPS2HI16_V4SF_MASK, UNKNOWN, (int) V8HI_FTYPE_V4SF_V8HI_UQI)
-BDESC (0, OPTION_MASK_ISA2_AVX512BF16, CODE_FOR_avx512f_cvtneps2bf16_v4sf_maskz, "__builtin_ia32_cvtneps2bf16_v4sf_maskz", IX86_BUILTIN_CVTNE2PS2HI16_V4SF_MASKZ, UNKNOWN, (int) V8HI_FTYPE_V4SF_UQI)
+BDESC (OPTION_MASK_ISA_AVX512VL, OPTION_MASK_ISA2_AVX512BF16, CODE_FOR_avx512f_cvtneps2bf16_v8sf, "__builtin_ia32_cvtneps2bf16_v8sf", IX86_BUILTIN_CVTNEPS2HI16_V8SF, UNKNOWN, (int) V8HI_FTYPE_V8SF)
+BDESC (OPTION_MASK_ISA_AVX512VL, OPTION_MASK_ISA2_AVX512BF16, CODE_FOR_avx512f_cvtneps2bf16_v8sf_mask, "__builtin_ia32_cvtneps2bf16_v8sf_mask", IX86_BUILTIN_CVTNEPS2HI16_V8SF_MASK, UNKNOWN, (int) V8HI_FTYPE_V8SF_V8HI_UQI)
+BDESC (OPTION_MASK_ISA_AVX512VL, OPTION_MASK_ISA2_AVX512BF16, CODE_FOR_avx512f_cvtneps2bf16_v8sf_maskz, "__builtin_ia32_cvtneps2bf16_v8sf_maskz", IX86_BUILTIN_CVTNE2PS2HI16_V8SF_MASKZ, UNKNOWN, (int) V8HI_FTYPE_V8SF_UQI)
+BDESC (OPTION_MASK_ISA_AVX512VL, OPTION_MASK_ISA2_AVX512BF16, CODE_FOR_avx512f_cvtneps2bf16_v4sf, "__builtin_ia32_cvtneps2bf16_v4sf", IX86_BUILTIN_CVTNEPS2HI16_V4SF, UNKNOWN, (int) V8HI_FTYPE_V4SF)
+BDESC (OPTION_MASK_ISA_AVX512VL, OPTION_MASK_ISA2_AVX512BF16, CODE_FOR_avx512f_cvtneps2bf16_v4sf_mask, "__builtin_ia32_cvtneps2bf16_v4sf_mask", IX86_BUILTIN_CVTNEPS2HI16_V4SF_MASK, UNKNOWN, (int) V8HI_FTYPE_V4SF_V8HI_UQI)
+BDESC (OPTION_MASK_ISA_AVX512VL, OPTION_MASK_ISA2_AVX512BF16, CODE_FOR_avx512f_cvtneps2bf16_v4sf_maskz, "__builtin_ia32_cvtneps2bf16_v4sf_maskz", IX86_BUILTIN_CVTNE2PS2HI16_V4SF_MASKZ, UNKNOWN, (int) V8HI_FTYPE_V4SF_UQI)
 BDESC (0, OPTION_MASK_ISA2_AVX512BF16, CODE_FOR_avx512f_dpbf16ps_v16sf, "__builtin_ia32_dpbf16ps_v16sf", IX86_BUILTIN_DPHI16PS_V16SF, UNKNOWN, (int) V16SF_FTYPE_V16SF_V32HI_V32HI)
 BDESC (0, OPTION_MASK_ISA2_AVX512BF16, CODE_FOR_avx512f_dpbf16ps_v16sf_mask, "__builtin_ia32_dpbf16ps_v16sf_mask", IX86_BUILTIN_DPHI16PS_V16SF_MASK, UNKNOWN, (int) V16SF_FTYPE_V16SF_V32HI_V32HI_UHI)
 BDESC (0, OPTION_MASK_ISA2_AVX512BF16, CODE_FOR_avx512f_dpbf16ps_v16sf_maskz, "__builtin_ia32_dpbf16ps_v16sf_maskz", IX86_BUILTIN_DPHI16PS_V16SF_MASKZ, UNKNOWN, (int) V16SF_FTYPE_V16SF_V32HI_V32HI_UHI)
-BDESC (0, OPTION_MASK_ISA2_AVX512BF16, CODE_FOR_avx512f_dpbf16ps_v8sf, "__builtin_ia32_dpbf16ps_v8sf", IX86_BUILTIN_DPHI16PS_V8SF, UNKNOWN, (int) V8SF_FTYPE_V8SF_V16HI_V16HI)
-BDESC (0, OPTION_MASK_ISA2_AVX512BF16, CODE_FOR_avx512f_dpbf16ps_v8sf_mask, "__builtin_ia32_dpbf16ps_v8sf_mask", IX86_BUILTIN_DPHI16PS_V8SF_MASK, UNKNOWN, (int) V8SF_FTYPE_V8SF_V16HI_V16HI_UQI)
-BDESC (0, OPTION_MASK_ISA2_AVX512BF16, CODE_FOR_avx512f_dpbf16ps_v8sf_maskz, "__builtin_ia32_dpbf16ps_v8sf_maskz", IX86_BUILTIN_DPHI16PS_V8SF_MASKZ, UNKNOWN, (int) V8SF_FTYPE_V8SF_V16HI_V16HI_UQI)
-BDESC (0, OPTION_MASK_ISA2_AVX512BF16, CODE_FOR_avx512f_dpbf16ps_v4sf, "__builtin_ia32_dpbf16ps_v4sf", IX86_BUILTIN_DPHI16PS_V4SF, UNKNOWN, (int) V4SF_FTYPE_V4SF_V8HI_V8HI)
-BDESC (0, OPTION_MASK_ISA2_AVX512BF16, CODE_FOR_avx512f_dpbf16ps_v4sf_mask, "__builtin_ia32_dpbf16ps_v4sf_mask", IX86_BUILTIN_DPHI16PS_V4SF_MASK, UNKNOWN, (int) V4SF_FTYPE_V4SF_V8HI_V8HI_UQI)
-BDESC (0, OPTION_MASK_ISA2_AVX512BF16, CODE_FOR_avx512f_dpbf16ps_v4sf_maskz, "__builtin_ia32_dpbf16ps_v4sf_maskz", IX86_BUILTIN_DPHI16PS_V4SF_MASKZ, UNKNOWN, (int) V4SF_FTYPE_V4SF_V8HI_V8HI_UQI)
+BDESC (OPTION_MASK_ISA_AVX512VL, OPTION_MASK_ISA2_AVX512BF16, CODE_FOR_avx512f_dpbf16ps_v8sf, "__builtin_ia32_dpbf16ps_v8sf", IX86_BUILTIN_DPHI16PS_V8SF, UNKNOWN, (int) V8SF_FTYPE_V8SF_V16HI_V16HI)
+BDESC (OPTION_MASK_ISA_AVX512VL, OPTION_MASK_ISA2_AVX512BF16, CODE_FOR_avx512f_dpbf16ps_v8sf_mask, "__builtin_ia32_dpbf16ps_v8sf_mask", IX86_BUILTIN_DPHI16PS_V8SF_MASK, UNKNOWN, (int) V8SF_FTYPE_V8SF_V16HI_V16HI_UQI)
+BDESC (OPTION_MASK_ISA_AVX512VL, OPTION_MASK_ISA2_AVX512BF16, CODE_FOR_avx512f_dpbf16ps_v8sf_maskz, "__builtin_ia32_dpbf16ps_v8sf_maskz", IX86_BUILTIN_DPHI16PS_V8SF_MASKZ, UNKNOWN, (int) V8SF_FTYPE_V8SF_V16HI_V16HI_UQI)
+BDESC (OPTION_MASK_ISA_AVX512VL, OPTION_MASK_ISA2_AVX512BF16, CODE_FOR_avx512f_dpbf16ps_v4sf, "__builtin_ia32_dpbf16ps_v4sf", IX86_BUILTIN_DPHI16PS_V4SF, UNKNOWN, (int) V4SF_FTYPE_V4SF_V8HI_V8HI)
+BDESC (OPTION_MASK_ISA_AVX512VL, OPTION_MASK_ISA2_AVX512BF16, CODE_FOR_avx512f_dpbf16ps_v4sf_mask, "__builtin_ia32_dpbf16ps_v4sf_mask", IX86_BUILTIN_DPHI16PS_V4SF_MASK, UNKNOWN, (int) V4SF_FTYPE_V4SF_V8HI_V8HI_UQI)
+BDESC (OPTION_MASK_ISA_AVX512VL, OPTION_MASK_ISA2_AVX512BF16, CODE_FOR_avx512f_dpbf16ps_v4sf_maskz, "__builtin_ia32_dpbf16ps_v4sf_maskz", IX86_BUILTIN_DPHI16PS_V4SF_MASKZ, UNKNOWN, (int) V4SF_FTYPE_V4SF_V8HI_V8HI_UQI)
 
 /* Builtins with rounding support.  */
 BDESC_END (ARGS, ROUND_ARGS)
diff --git a/gcc/testsuite/gcc.target/i386/avx512bf16-pr108881.c b/gcc/testsuite/gcc.target/i386/avx512bf16-pr108881.c
new file mode 100644
index 00000000000..9428c53abec
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/avx512bf16-pr108881.c
@@ -0,0 +1,14 @@
+/* PR target/108881 */
+/* { dg-do compile } */
+/* { dg-options "-mavx512bf16 -mno-avx512vl" } */
+
+typedef float __m256 __attribute__((__vector_size__(32)));
+typedef short __v16hi __attribute__((__vector_size__(32)));
+__v16hi a;
+__m256 b, c;
+
+void
+foo (void)
+{
+  a = __builtin_ia32_cvtne2ps2bf16_v16hi (b, c);	/* { dg-warning "implicit declaration of function" } */
+}							/* { dg-error "incompatible types when assigning to type" "" { target *-*-* } .-1 } */

commit f1789989ca265abaa246592cd4223cc3ca89b361
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Fri Feb 24 11:05:27 2023 +0100

    cgraphclones: Don't share DECL_ARGUMENTS between thunk and its artificial thunk [PR108854]
    
    The following testcase ICEs on x86_64-linux with -m32.  The problem is
    we create an artificial thunk and because of -fPIC, ia32 and thunk
    destination which doesn't bind locally can't use a mi thunk.
    The ICE is because during expansion to RTL we see SSA_NAME for a PARM_DECL,
    but the PARM_DECL doesn't have DECL_CONTEXT of the current function.
    This is because duplicate_thunk_for_node creates a new DECL_ARGUMENTS chain
    only if some arguments need modification.
    
    The following patch fixes it by copying the DECL_ARGUMENTS list even if
    the arguments can stay as is, to update DECL_CONTEXT on them.  While for
    mi thunks it doesn't really matter because we don't use those arguments
    in any way, for other thunks it is important.
    
    2023-02-23  Jakub Jelinek  <jakub@redhat.com>
    
            PR middle-end/108854
            * cgraphclones.c (duplicate_thunk_for_node): If no parameter
            changes are needed, copy at least DECL_ARGUMENTS PARM_DECL
            nodes and adjust their DECL_CONTEXT.
    
            * g++.dg/opt/pr108854.C: New test.
    
    (cherry picked from commit 2f1691be517fcdcabae9cd671ab511eb0e08b1d5)

diff --git a/gcc/cgraphclones.c b/gcc/cgraphclones.c
index e4f1c1d4b5e..79b29e524c7 100644
--- a/gcc/cgraphclones.c
+++ b/gcc/cgraphclones.c
@@ -214,7 +214,17 @@ duplicate_thunk_for_node (cgraph_node *thunk, cgraph_node *node)
       body_adj.modify_formal_parameters ();
     }
   else
-    new_decl = copy_node (thunk->decl);
+    {
+      new_decl = copy_node (thunk->decl);
+      for (tree *arg = &DECL_ARGUMENTS (new_decl);
+	   *arg; arg = &DECL_CHAIN (*arg))
+	{
+	  tree next = DECL_CHAIN (*arg);
+	  *arg = copy_node (*arg);
+	  DECL_CONTEXT (*arg) = new_decl;
+	  DECL_CHAIN (*arg) = next;
+	}
+    }
 
   gcc_checking_assert (!DECL_STRUCT_FUNCTION (new_decl));
   gcc_checking_assert (!DECL_INITIAL (new_decl));
diff --git a/gcc/testsuite/g++.dg/opt/pr108854.C b/gcc/testsuite/g++.dg/opt/pr108854.C
new file mode 100644
index 00000000000..9f2d9030f75
--- /dev/null
+++ b/gcc/testsuite/g++.dg/opt/pr108854.C
@@ -0,0 +1,37 @@
+// PR middle-end/108854
+// { dg-do compile { target c++11 } }
+// { dg-options "-O3" }
+// { dg-additional-options "-fPIC" { target fpic } }
+
+struct A { A (int); ~A (); };
+struct B { B (int, bool); ~B (); };
+template <typename T>
+struct C { void m1 (T); void m2 (T &&); };
+class D;
+struct E { virtual void m3 (); };
+template <typename>
+struct F { virtual bool m4 (D &); };
+struct D { virtual D m5 () { return D (); } };
+void foo (void *, void *);
+struct G {
+  int a;
+  C <D *> b;
+  void m4 (D &r) { B l (a, true); r.m5 (); b.m1 (&r); b.m2 (&r); }
+};
+struct H : E, F <int> {
+  template <typename T>
+  H (int, T);
+  bool m4 (D &r) { A l (a); b.m4 (r); if (c) return true; } // { dg-warning "control reaches end of non-void function" }
+  int a;
+  bool c;
+  G b;
+};
+inline void bar (F <int> &p) { D s, t; p.m4 (t); foo (&p, &s); }
+enum I { I1, I2 };
+template <I>
+struct J;
+template <class, class T, class, class, class, class>
+void baz () { int g = 0, h = 0; T i (g, h); bar (i); }
+template <class, int, I T>
+void qux () { baz <int, H, int, int, E, J<T>> (); }
+void corge () { qux <int, I2, I1> (); qux <int, I2, I2> (); }

commit 17ea4d1f5d3609ef2540a10c29f57c0bd185ba4b
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Thu Mar 2 19:17:52 2023 +0100

    c++, debug: Fix up locus of DW_TAG_imported_module [PR108716]
    
    Before IMPORTED_DECL has been introduced in PR37410, we used to emit correct
    DW_AT_decl_line on DW_TAG_imported_module on the testcase below, after that
    change we haven't emitted it at all for a while and after some time
    started emitting incorrect locus, in particular the location of } closing
    the function.
    
    The problem is that while we have correct EXPR_LOCATION on the USING_STMT,
    when genericizing that USING_STMT into IMPORTED_DECL we don't copy the
    location to DECL_SOURCE_LOCATION, so it gets whatever input_location happens
    to be when it is created.
    
    2023-03-02  Jakub Jelinek  <jakub@redhat.com>
    
            PR debug/108716
            * cp-gimplify.c (cp_genericize_r) <case USING_STMT>: Set
            DECL_SOURCE_LOCATION on IMPORTED_DECL to expression location
            of USING_STMT or input_location.
    
            * g++.dg/debug/dwarf2/pr108716.C: New test.
    
    (cherry picked from commit 4d82022bfd15d36717bf60a11e75e9ea02204269)

diff --git a/gcc/cp/cp-gimplify.c b/gcc/cp/cp-gimplify.c
index 7f94796ea01..6432e82fdea 100644
--- a/gcc/cp/cp-gimplify.c
+++ b/gcc/cp/cp-gimplify.c
@@ -1590,6 +1590,8 @@ cp_genericize_r (tree *stmt_p, int *walk_subtrees, void *data)
 	      {
 		tree using_directive = make_node (IMPORTED_DECL);
 		TREE_TYPE (using_directive) = void_type_node;
+		DECL_SOURCE_LOCATION (using_directive)
+		  = cp_expr_loc_or_input_loc (stmt);
 
 		IMPORTED_DECL_ASSOCIATED_DECL (using_directive) = decl;
 		DECL_CHAIN (using_directive) = BLOCK_VARS (block);
diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/pr108716.C b/gcc/testsuite/g++.dg/debug/dwarf2/pr108716.C
new file mode 100644
index 00000000000..59ed52424da
--- /dev/null
+++ b/gcc/testsuite/g++.dg/debug/dwarf2/pr108716.C
@@ -0,0 +1,14 @@
+// PR debug/108716
+// { dg-options "-O0 -gdwarf-5 -dA -fno-merge-debug-strings" }
+// { dg-final { scan-assembler "DIE \\(\[^\n\r\]*\\) DW_TAG_imported_module\[^\n\r\]*\[\n\r]*\[^\n\r\]* DW_AT_decl_file\[^\n\r\]*\[\n\r]*\[^\n\r\]*0xc\[^\n\r\]* DW_AT_decl_line\[^\n\r\]*\[\n\r]*(\[^\n\r\]*0x13\[^\n\r\]* DW_AT_decl_column\[^\n\r\]*\[\n\r]*)?" } }
+
+namespace M {
+  int x = 1;
+}
+
+int
+main ()
+{
+  using namespace M;
+  return 0;
+}

commit 964741883aedae54621992e25aac928a96b9c096
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Fri Mar 3 00:40:13 2023 +0100

    libquadmath: Assorted libquadmath strtoflt128 fixes [PR87204, PR94756]
    
    This patch cherry-pickx 8 commits from glibc which fix various strtod_l
    bugs.
    
    2023-03-03  niXman  <i.nixman@autistici.org>
                Jakub Jelinek  <jakub@redhat.com>
    
            PR libquadmath/87204
            PR libquadmath/94756
            * strtod/strtod_l.c (round_and_return): Cherry-pick glibc
            9310c284ae9 BZ #16151, 4406c41c1d6 BZ #16965 and fcd6b5ac36a
            BZ #23279 fixes.
            (____STRTOF_INTERNAL): Cherry-pick glibc b0debe14fcf BZ #23007,
            5556d30caee BZ #18247, 09555b9721d and c6aac3bf366 BZ #26137 and
            d84f25c7d87 fixes.
    
    (cherry picked from commit df63f4162c78ef799d4ea9dec3443d5e9c51e5aa)

diff --git a/libquadmath/strtod/strtod_l.c b/libquadmath/strtod/strtod_l.c
index 0b0e85a3cf7..38602841cd7 100644
--- a/libquadmath/strtod/strtod_l.c
+++ b/libquadmath/strtod/strtod_l.c
@@ -200,7 +200,7 @@ round_and_return (mp_limb_t *retval, intmax_t exponent, int negative,
 
 	  round_limb = retval[RETURN_LIMB_SIZE - 1];
 	  round_bit = (MANT_DIG - 1) % BITS_PER_MP_LIMB;
-	  for (i = 0; i < RETURN_LIMB_SIZE; ++i)
+	  for (i = 0; i < RETURN_LIMB_SIZE - 1; ++i)
 	    more_bits |= retval[i] != 0;
 	  MPN_ZERO (retval, RETURN_LIMB_SIZE);
 	}
@@ -215,9 +215,14 @@ round_and_return (mp_limb_t *retval, intmax_t exponent, int negative,
 	  more_bits |= ((round_limb & ((((mp_limb_t) 1) << round_bit) - 1))
 			!= 0);
 
-	  (void) mpn_rshift (retval, &retval[shift / BITS_PER_MP_LIMB],
-			     RETURN_LIMB_SIZE - (shift / BITS_PER_MP_LIMB),
-			     shift % BITS_PER_MP_LIMB);
+	  /* mpn_rshift requires 0 < shift < BITS_PER_MP_LIMB.  */
+	  if ((shift % BITS_PER_MP_LIMB) != 0)
+	    (void) mpn_rshift (retval, &retval[shift / BITS_PER_MP_LIMB],
+			       RETURN_LIMB_SIZE - (shift / BITS_PER_MP_LIMB),
+			       shift % BITS_PER_MP_LIMB);
+	  else
+	    for (i = 0; i < RETURN_LIMB_SIZE - (shift / BITS_PER_MP_LIMB); i++)
+	      retval[i] = retval[i + (shift / BITS_PER_MP_LIMB)];
 	  MPN_ZERO (&retval[RETURN_LIMB_SIZE - (shift / BITS_PER_MP_LIMB)],
 		    shift / BITS_PER_MP_LIMB);
 	}
@@ -276,7 +281,7 @@ round_and_return (mp_limb_t *retval, intmax_t exponent, int negative,
 	}
     }
 
-  if (exponent > MAX_EXP)
+  if (exponent >= MAX_EXP)
     goto overflow;
 
 #ifdef HAVE_FENV_H
@@ -308,7 +313,7 @@ round_and_return (mp_limb_t *retval, intmax_t exponent, int negative,
     }
 #endif
 
-  if (exponent > MAX_EXP)
+  if (exponent >= MAX_EXP)
   overflow:
     return overflow_value (negative);
 
@@ -688,7 +693,7 @@ ____STRTOF_INTERNAL (nptr, endptr, group)
 	  if (endptr != NULL)
 	    *endptr = (STRING_TYPE *) cp;
 
-	  return retval;
+	  return negative ? -retval : retval;
 	}
 
       /* It is really a text we do not recognize.  */
@@ -1193,7 +1198,16 @@ ____STRTOF_INTERNAL (nptr, endptr, group)
   if (__builtin_expect (exponent > MAX_10_EXP + 1 - (intmax_t) int_no, 0))
     return overflow_value (negative);
 
-  if (__builtin_expect (exponent < MIN_10_EXP - (DIG + 1), 0))
+  /* 10^(MIN_10_EXP-1) is not normal.  Thus, 10^(MIN_10_EXP-1) /
+     2^MANT_DIG is below half the least subnormal, so anything with a
+     base-10 exponent less than the base-10 exponent (which is
+     MIN_10_EXP - 1 - ceil(MANT_DIG*log10(2))) of that value
+     underflows.  DIG is floor((MANT_DIG-1)log10(2)), so an exponent
+     below MIN_10_EXP - (DIG + 3) underflows.  But EXPONENT is
+     actually an exponent multiplied only by a fractional part, not an
+     integer part, so an exponent below MIN_10_EXP - (DIG + 2)
+     underflows.  */
+  if (__builtin_expect (exponent < MIN_10_EXP - (DIG + 2), 0))
     return underflow_value (negative);
 
   if (int_no > 0)
@@ -1360,7 +1374,7 @@ ____STRTOF_INTERNAL (nptr, endptr, group)
 
     assert (dig_no > int_no
 	    && exponent <= 0
-	    && exponent >= MIN_10_EXP - (DIG + 1));
+	    && exponent >= MIN_10_EXP - (DIG + 2));
 
     /* We need to compute MANT_DIG - BITS fractional bits that lie
        within the mantissa of the result, the following bit for
@@ -1651,8 +1665,8 @@ ____STRTOF_INTERNAL (nptr, endptr, group)
 	  d1 = den[densize - 2];
 
 	  /* The division does not work if the upper limb of the two-limb
-	     numerator is greater than the denominator.  */
-	  if (mpn_cmp (num, &den[densize - numsize], numsize) > 0)
+	     numerator is greater than or equal to the denominator.  */
+	  if (mpn_cmp (num, &den[densize - numsize], numsize) >= 0)
 	    num[numsize++] = 0;
 
 	  if (numsize < densize)
@@ -1761,7 +1775,7 @@ ____STRTOF_INTERNAL (nptr, endptr, group)
 	      got_limb;
 	    }
 
-	  for (i = densize; num[i] == 0 && i >= 0; --i)
+	  for (i = densize; i >= 0 && num[i] == 0; --i)
 	    ;
 	  return round_and_return (retval, exponent - 1, negative,
 				   quot, BITS_PER_MP_LIMB - 1 - used,

commit 880fc42b29d1f1d076ddb1953bad4d9a67df2b1a
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Sat Mar 4 09:48:17 2023 +0100

    diagnostics: Fix up selftests with $COLUMNS < 42 [PR108973]
    
    As mentioned in the PR, GCC's diagnostics self-tests fail if $COLUMNS < 42.
    Guarding each self-test with if (get_terminal_width () > 41) or similar
    would be a maintainance nightmare (PR has a patch to do so without
    reformatting to make it work for $COLUMNS in [30, 41] inclusive, but
    I'm afraid going down to $COLUMNS 1 would mean marking everything).
    Furthermore, the self-tests don't really emit stuff to the terminal,
    but into a buffer, so using get_terminal_width () for it seems
    inappropriate.  The following patch makes sure test_diagnostic_context
    constructor uses exactly 80 columns wide caret max width, of course
    some tests override it already if they want to test for behavior in narrower
    cases.
    
    2023-03-04  Jakub Jelinek  <jakub@redhat.com>
    
            PR testsuite/108973
            * selftest-diagnostic.c
            (test_diagnostic_context::test_diagnostic_context): Set
            caret_max_width to 80.
    
    (cherry picked from commit 739e7ebb3d378ece25d64b39baae47c584253498)

diff --git a/gcc/selftest-diagnostic.c b/gcc/selftest-diagnostic.c
index 82fddca89ab..8f9c31eb467 100644
--- a/gcc/selftest-diagnostic.c
+++ b/gcc/selftest-diagnostic.c
@@ -41,6 +41,7 @@ test_diagnostic_context::test_diagnostic_context ()
   show_column = true;
   start_span = start_span_cb;
   min_margin_width = 6;
+  caret_max_width = 80;
 }
 
 test_diagnostic_context::~test_diagnostic_context ()

commit e870422424310f7b5867e204360ec7094ba999c6
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Sat Mar 4 10:18:37 2023 +0100

    c-family: Fix up -Wsign-compare BIT_NOT_EXPR handling [PR107465]
    
    The following patch fixes multiple bugs in warn_for_sign_compare related to
    the BIT_NOT_EXPR related warnings.
    My understanding is that what those 3 warnings are meant to warn (since 1995
    apparently) is the case where we have BIT_NOT_EXPR of a zero-extended
    value, so in result_type the value is something like:
    0b11111111XXXXXXXX (e.g. ~ of a 8->16 bit zero extension)
    0b000000000000000011111111XXXXXXXX (e.g. ~ of a 8->16 bit zero extension
    then zero extended to 32 bits)
    0b111111111111111111111111XXXXXXXX (e.g. ~ of a 8->16 bit zero extension
    then sign extended to 32 bits)
    and the intention of the warning is to warn when this is compared against
    something that has some 0 bits at the place where the above has guaranteed
    1 bits, either ensured through comparison against constant where we know
    the bits exactly, or through zero extension from some narrower type where
    again we know at least some upper bits are zero extended.
    The bugs in the warning code are:
    1) misunderstanding of the {,c_common_}get_narrower APIs - the unsignedp
       it sets is only meaningful if the function actually returns something
       narrower (in that case it says whether the narrower value is then
       sign (0) or zero (1) extended to the originally passed value.
       Though op0 or op1 at this point might be already narrower than
       result_type, and if the function doesn't return anything narrower,
       it all depends on whether the passed in op{0,1} had TYPE_UNSIGNED
       type or not
    2) the code didn't check at all whether the BIT_NOT_EXPR operand
       was actually zero extended (i.e. that it was narrower and unsignedp
       was set to 1 for it), all it did is check that unsignedp from the
       call was 1.  But that isn't well defined thing, if the argument
       is returned as is, the function sets unsignedp to 0, but if there
       is e.g. a useless cast to the same or compatible type in between,
       it can return 1 if the cast is unsigned; now, if BIT_NOT_EXPR
       operand is not zero extended, we know nothing at all about any bits
       in the operand containing BIT_NOT_EXPR, so there is nothing to warn
       about
    3) the code was actually testing both operands after calling
       c_common_get_narrower on them and on the one with BIT_NOT_EXPR
       again for constants; I think that is just wrong in case the BIT_NOT_EXPR
       operand wouldn't be fully folded, the warning makes sense only if the
       other operand not having BIT_NOT_EXPR in it is constant
    4) as can be seen from the above bit pattern examples, the upper bits above
       (in the patch arg0) aren't always all 1s, there could be some zero extension
       above it and from it one would have 0s, so that needs to be taken into
       account for the choice which constant bits to test for being always set
       otherwise warning is emitted, or for the zero extension guaranteed zero
       bits
    5) the patch also simplifies the handling, we only do it if one but not
       both operands are BIT_NOT_EXPR after first {,c_common_}get_narrower,
       so we can just use std::swap to ensure it is the first one
    6) the code compared bits against HOST_BITS_PER_LONG, which made sense
       back in 1995 when the values were stored into long, but now that they
       are HOST_WIDE_INT should test HOST_BITS_PER_WIDE_INT (or we could rewrite
       the stuff to wide_int, not done in the patch)
    
    2023-03-04  Jakub Jelinek  <jakub@redhat.com>
    
            PR c/107465
            * c-warn.c (warn_for_sign_compare): If c_common_get_narrower
            doesn't return a narrower result, use TYPE_UNSIGNED to set unsignedp0
            and unsignedp1.  For the one BIT_NOT_EXPR case vs. one without,
            only check for constant in the non-BIT_NOT_EXPR operand, use std::swap
            to simplify the code, only warn if BIT_NOT_EXPR operand is extended
            from narrower unsigned, fix up computation of mask for the constant
            cases and for unsigned other operand case handle differently
            BIT_NOT_EXPR result being sign vs. zero extended.
    
            * c-c++-common/Wsign-compare-2.c: New test.
            * c-c++-common/pr107465.c: New test.
    
    (cherry picked from commit daaf74a714c41c8dbaf9954bcc58462c63062b4f)

diff --git a/gcc/c-family/c-warn.c b/gcc/c-family/c-warn.c
index 3dfb716e536..4571a05dcb1 100644
--- a/gcc/c-family/c-warn.c
+++ b/gcc/c-family/c-warn.c
@@ -2340,42 +2340,50 @@ warn_for_sign_compare (location_t location,
      have all bits set that are set in the ~ operand when it is
      extended.  */
 
-  op0 = c_common_get_narrower (op0, &unsignedp0);
-  op1 = c_common_get_narrower (op1, &unsignedp1);
+  tree arg0 = c_common_get_narrower (op0, &unsignedp0);
+  if (TYPE_PRECISION (TREE_TYPE (arg0)) == TYPE_PRECISION (TREE_TYPE (op0)))
+    unsignedp0 = TYPE_UNSIGNED (TREE_TYPE (op0));
+  op0 = arg0;
+  tree arg1 = c_common_get_narrower (op1, &unsignedp1);
+  if (TYPE_PRECISION (TREE_TYPE (arg1)) == TYPE_PRECISION (TREE_TYPE (op1)))
+    unsignedp1 = TYPE_UNSIGNED (TREE_TYPE (op1));
+  op1 = arg1;
 
   if ((TREE_CODE (op0) == BIT_NOT_EXPR)
       ^ (TREE_CODE (op1) == BIT_NOT_EXPR))
     {
-      if (TREE_CODE (op0) == BIT_NOT_EXPR)
-	op0 = c_common_get_narrower (TREE_OPERAND (op0, 0), &unsignedp0);
       if (TREE_CODE (op1) == BIT_NOT_EXPR)
-	op1 = c_common_get_narrower (TREE_OPERAND (op1, 0), &unsignedp1);
-
-      if (tree_fits_shwi_p (op0) || tree_fits_shwi_p (op1))
 	{
-	  tree primop;
-	  HOST_WIDE_INT constant, mask;
-	  int unsignedp;
-	  unsigned int bits;
+	  std::swap (op0, op1);
+	  std::swap (unsignedp0, unsignedp1);
+	}
 
-	  if (tree_fits_shwi_p (op0))
-	    {
-	      primop = op1;
-	      unsignedp = unsignedp1;
-	      constant = tree_to_shwi (op0);
-	    }
-	  else
-	    {
-	      primop = op0;
-	      unsignedp = unsignedp0;
-	      constant = tree_to_shwi (op1);
-	    }
+      int unsignedp;
+      arg0 = c_common_get_narrower (TREE_OPERAND (op0, 0), &unsignedp);
 
-	  bits = TYPE_PRECISION (TREE_TYPE (primop));
-	  if (bits < TYPE_PRECISION (result_type)
-	      && bits < HOST_BITS_PER_LONG && unsignedp)
+      /* For these warnings, we need BIT_NOT_EXPR operand to be
+	 zero extended from narrower type to BIT_NOT_EXPR's type.
+	 In that case, all those bits above the narrower's type
+	 are after BIT_NOT_EXPR set to 1.  */
+      if (tree_fits_shwi_p (op1))
+	{
+	  HOST_WIDE_INT constant = tree_to_shwi (op1);
+	  unsigned int bits = TYPE_PRECISION (TREE_TYPE (arg0));
+	  if (unsignedp
+	      && bits < TYPE_PRECISION (TREE_TYPE (op0))
+	      && bits < HOST_BITS_PER_WIDE_INT)
 	    {
-	      mask = HOST_WIDE_INT_M1U << bits;
+	      HOST_WIDE_INT mask = HOST_WIDE_INT_M1U << bits;
+	      if (unsignedp0)
+		{
+		  bits = TYPE_PRECISION (TREE_TYPE (op0));
+		  if (bits < TYPE_PRECISION (result_type)
+		      && bits < HOST_BITS_PER_WIDE_INT)
+		    mask &= ~(HOST_WIDE_INT_M1U << bits);
+		}
+	      bits = TYPE_PRECISION (result_type);
+	      if (bits < HOST_BITS_PER_WIDE_INT)
+		mask &= ~(HOST_WIDE_INT_M1U << bits);
 	      if ((mask & constant) != mask)
 		{
 		  if (constant == 0)
@@ -2389,11 +2397,28 @@ warn_for_sign_compare (location_t location,
 		}
 	    }
 	}
-      else if (unsignedp0 && unsignedp1
-	       && (TYPE_PRECISION (TREE_TYPE (op0))
-		   < TYPE_PRECISION (result_type))
+      else if ((TYPE_PRECISION (TREE_TYPE (arg0))
+		< TYPE_PRECISION (TREE_TYPE (op0)))
+	       && unsignedp
+	       && unsignedp1
+	       /* If unsignedp0, the BIT_NOT_EXPR result is
+		  zero extended, so say if op0 is unsigned char
+		  variable, BIT_NOT_EXPR is unsigned short and
+		  result type int and op0 has value 0x55, the
+		  int value will be 0xffaa, or for op0 0xaa it
+		  will be 0xff55.  In these cases, warn if
+		  op1 is unsigned and narrower than unsigned short.
+		  While if unsignedp0 is false, the BIT_NOT_EXPR
+		  result is sign extended and because of the
+		  above TYPE_PRECISION comparison we know the
+		  MSB of BIT_NOT_EXPR is set (perhaps with some
+		  further bits below it).  The sign extension will
+		  then ensure all bits above BIT_NOT_EXPR up to
+		  result_type's precision are set.  */
 	       && (TYPE_PRECISION (TREE_TYPE (op1))
-		   < TYPE_PRECISION (result_type)))
+		   < TYPE_PRECISION (unsignedp0
+				     ? TREE_TYPE (op0)
+				     : result_type)))
 	warning_at (location, OPT_Wsign_compare,
 		    "comparison of promoted bitwise complement "
 		    "of an unsigned value with unsigned");
diff --git a/gcc/testsuite/c-c++-common/Wsign-compare-2.c b/gcc/testsuite/c-c++-common/Wsign-compare-2.c
new file mode 100644
index 00000000000..23933d09cdc
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/Wsign-compare-2.c
@@ -0,0 +1,106 @@
+/* { dg-do compile { target { ilp32 || lp64 } } } */
+/* { dg-options "-Wsign-compare" } */
+
+int
+f1 (unsigned char x)
+{
+  return (unsigned short) (~(unsigned short) x) == 0;		/* { dg-warning "promoted bitwise complement of an unsigned value is always nonzero" "" { target c } } */
+}
+
+int
+f2 (unsigned char x)
+{
+  return (unsigned short) (~(unsigned short) x) == 5;		/* { dg-warning "comparison of promoted bitwise complement of an unsigned value with constant" "" { target c }  } */
+}
+
+int
+f3 (unsigned char x)
+{
+  return (unsigned int) (~(unsigned short) x) == 0xffff0005U;	/* { dg-warning "comparison of promoted bitwise complement of an unsigned value with constant" } */
+}
+
+int
+f4 (unsigned char x)
+{
+  return (unsigned int) (~(unsigned short) x) == 0xffff0005ULL;	/* { dg-warning "comparison of promoted bitwise complement of an unsigned value with constant" } */
+}
+
+int
+f5 (unsigned char x)
+{
+  return (unsigned int) (~(unsigned short) x) == 0xffffff05U;	/* { dg-bogus "comparison of promoted bitwise complement of an unsigned value with constant" } */
+}
+
+int
+f6 (unsigned char x)
+{
+  return (unsigned int) (~(unsigned short) x) == 0xffffff05ULL;	/* { dg-bogus "comparison of promoted bitwise complement of an unsigned value with constant" } */
+}
+
+int
+f7 (unsigned char x)
+{
+  return (unsigned long long) (~(unsigned short) x) == 0xffffffffffffff05ULL;	/* { dg-bogus "comparison of promoted bitwise complement of an unsigned value with constant" } */
+}
+
+typedef unsigned short T;
+
+int
+f8 (T x)
+{
+  return (unsigned short) (~(unsigned short) x) == 0;		/* { dg-bogus "promoted bitwise complement of an unsigned value is always nonzero" } */
+}
+
+int
+f9 (T x)
+{
+  return (unsigned short) (~(unsigned short) x) == 5;		/* { dg-bogus "comparison of promoted bitwise complement of an unsigned value with constant" } */
+}
+
+int
+f10 (T x, unsigned char y)
+{
+  return (unsigned short) (~(unsigned short) x) == y;		/* { dg-bogus "comparison of promoted bitwise complement of an unsigned value with unsigned" } */
+}
+
+int
+f11 (T x, unsigned char y)
+{
+  return (unsigned short) (~(unsigned short) x) == y;		/* { dg-bogus "comparison of promoted bitwise complement of an unsigned value with unsigned" } */
+}
+
+int
+f12 (unsigned char x, unsigned char y)
+{
+  return (unsigned short) (~(unsigned short) x) == y;		/* { dg-warning "comparison of promoted bitwise complement of an unsigned value with unsigned" "" { target c } } */
+}
+
+int
+f13 (unsigned char x, unsigned char y)
+{
+  return (unsigned short) (~(unsigned short) x) == y;		/* { dg-warning "comparison of promoted bitwise complement of an unsigned value with unsigned" "" { target c } } */
+}
+
+int
+f14 (unsigned char x, unsigned int y)
+{
+  return (unsigned long long) (~x) == y;			/* { dg-warning "comparison of promoted bitwise complement of an unsigned value with unsigned" } */
+}
+
+int
+f15 (unsigned short x, unsigned int y)
+{
+  return (long long) (~x) == y;					/* { dg-warning "comparison of promoted bitwise complement of an unsigned value with unsigned" } */
+}
+
+int
+f16 (unsigned char x, unsigned short y)
+{
+  return (unsigned short) (~(unsigned short) x) == y;		/* { dg-bogus "comparison of promoted bitwise complement of an unsigned value with unsigned" } */
+}
+
+int
+f17 (unsigned char x, unsigned short y)
+{
+  return (unsigned short) (~(unsigned short) x) == y;		/* { dg-bogus "comparison of promoted bitwise complement of an unsigned value with unsigned" } */
+}
diff --git a/gcc/testsuite/c-c++-common/pr107465.c b/gcc/testsuite/c-c++-common/pr107465.c
new file mode 100644
index 00000000000..7c9ff24bc83
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/pr107465.c
@@ -0,0 +1,22 @@
+/* PR c/107465 */
+/* { dg-do compile } */
+/* { dg-options "-Wsign-compare" } */
+
+void baz (void);
+typedef unsigned short T;
+
+#if __SIZEOF_SHORT__ * __CHAR_BIT__ == 16
+void
+foo (unsigned short x)
+{
+  if (!(x ^ 0xFFFF))
+    baz ();
+}
+
+void
+bar (T x)
+{
+  if (!(x ^ 0xFFFF))	/* { dg-bogus "promoted bitwise complement of an unsigned value is always nonzero" } */
+    baz ();
+}
+#endif

commit 42bbe4c068011e78f8cb264f56aaa4c392783326
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Sat Mar 4 10:21:45 2023 +0100

    c-family: Incremental fix for -Wsign-compare BIT_NOT_EXPR handling [PR107465]
    
    There can be too many extensions and seems I didn't get everything right in
    the previously posted patch.
    
    The following incremental patch ought to fix that.
    The code can deal with quite a few sign/zero extensions at various spots
    and it is important to deal with all of them right.
    On the argument that contains BIT_NOT_EXPR we have:
    MSB bits#4 bits#3 BIT_NOT_EXPR bits#2 bits#1 LSB
    where bits#1 is one or more bits (TYPE_PRECISION (TREE_TYPE (arg0))
    at the end of the function) we don't know anything about, for the purposes
    of this warning it is VARYING that is inverted with BIT_NOT_EXPR to some other
    VARYING bits;
    bits#2 is one or more bits (TYPE_PRECISION (TREE_TYPE (op0)) -
    TYPE_PRECISION (TREE_TYPE (arg0)) at the end of the function)
    which are known to be 0 before the BIT_NOT_EXPR and 1 after it.
    bits#3 is zero or more bits from the TYPE_PRECISION (TREE_TYPE (op0))
    at the end of function to the TYPE_PRECISION (TREE_TYPE (op0)) at the
    end of the function to TYPE_PRECISION (TREE_TYPE (op0)) at the start
    of the function, which are either zero extension or sign extension.
    And bits#4 is zero or more bits from the TYPE_PRECISION (TREE_TYPE (op0))
    at the start of the function to TYPE_PRECISION (result_type), which
    again can be zero or sign extension.
    
    Now, vanilla trunk as well as the previously posted patch mishandles the
    case where bits#3 are sign extended (as bits#2 are known to be all set,
    that means bits#3 are all set too) but bits#4 are zero extended and are
    thus all 0.
    
    The patch fixes it by tracking the lowest bit which is known to be clear
    above the known to be set bits (if any, otherwise it is precision of
    result_type).
    
    2023-03-04  Jakub Jelinek  <jakub@redhat.com>
    
            PR c/107465
            * c-warn.c (warn_for_sign_compare): Don't warn for unset bits
            above innermost zero extension of BIT_NOT_EXPR result.
    
            * c-c++-common/Wsign-compare-2.c (f18): New test.
    
    (cherry picked from commit 3ec9a8728086ad86a2d421e067329f305f40e005)

diff --git a/gcc/c-family/c-warn.c b/gcc/c-family/c-warn.c
index 4571a05dcb1..0ec9aa107aa 100644
--- a/gcc/c-family/c-warn.c
+++ b/gcc/c-family/c-warn.c
@@ -2340,13 +2340,33 @@ warn_for_sign_compare (location_t location,
      have all bits set that are set in the ~ operand when it is
      extended.  */
 
+  /* bits0 is the bit index of op0 extended to result_type, which will
+     be always 0 and so all bits above it.  If there is a BIT_NOT_EXPR
+     in that operand possibly sign or zero extended to op0 and then
+     possibly further sign or zero extended to result_type, bits0 will
+     be the precision of result type if all the extensions involved
+     if any are sign extensions, and will be the place of the innermost
+     zero extension otherwise.  We warn only if BIT_NOT_EXPR's operand is
+     zero extended from some even smaller precision, in that case after
+     BIT_NOT_EXPR some bits below bits0 will be guaranteed to be set.
+     Similarly for bits1.  */
+  int bits0 = TYPE_PRECISION (result_type);
+  if (TYPE_UNSIGNED (TREE_TYPE (op0)))
+    bits0 = TYPE_PRECISION (TREE_TYPE (op0));
   tree arg0 = c_common_get_narrower (op0, &unsignedp0);
   if (TYPE_PRECISION (TREE_TYPE (arg0)) == TYPE_PRECISION (TREE_TYPE (op0)))
     unsignedp0 = TYPE_UNSIGNED (TREE_TYPE (op0));
+  else if (unsignedp0)
+    bits0 = TYPE_PRECISION (TREE_TYPE (arg0));
   op0 = arg0;
+  int bits1 = TYPE_PRECISION (result_type);
+  if (TYPE_UNSIGNED (TREE_TYPE (op1)))
+    bits1 = TYPE_PRECISION (TREE_TYPE (op1));
   tree arg1 = c_common_get_narrower (op1, &unsignedp1);
   if (TYPE_PRECISION (TREE_TYPE (arg1)) == TYPE_PRECISION (TREE_TYPE (op1)))
     unsignedp1 = TYPE_UNSIGNED (TREE_TYPE (op1));
+  else if (unsignedp1)
+    bits1 = TYPE_PRECISION (TREE_TYPE (arg1));
   op1 = arg1;
 
   if ((TREE_CODE (op0) == BIT_NOT_EXPR)
@@ -2356,6 +2376,7 @@ warn_for_sign_compare (location_t location,
 	{
 	  std::swap (op0, op1);
 	  std::swap (unsignedp0, unsignedp1);
+	  std::swap (bits0, bits1);
 	}
 
       int unsignedp;
@@ -2374,16 +2395,8 @@ warn_for_sign_compare (location_t location,
 	      && bits < HOST_BITS_PER_WIDE_INT)
 	    {
 	      HOST_WIDE_INT mask = HOST_WIDE_INT_M1U << bits;
-	      if (unsignedp0)
-		{
-		  bits = TYPE_PRECISION (TREE_TYPE (op0));
-		  if (bits < TYPE_PRECISION (result_type)
-		      && bits < HOST_BITS_PER_WIDE_INT)
-		    mask &= ~(HOST_WIDE_INT_M1U << bits);
-		}
-	      bits = TYPE_PRECISION (result_type);
-	      if (bits < HOST_BITS_PER_WIDE_INT)
-		mask &= ~(HOST_WIDE_INT_M1U << bits);
+	      if (bits0 < HOST_BITS_PER_WIDE_INT)
+		mask &= ~(HOST_WIDE_INT_M1U << bits0);
 	      if ((mask & constant) != mask)
 		{
 		  if (constant == 0)
@@ -2401,24 +2414,7 @@ warn_for_sign_compare (location_t location,
 		< TYPE_PRECISION (TREE_TYPE (op0)))
 	       && unsignedp
 	       && unsignedp1
-	       /* If unsignedp0, the BIT_NOT_EXPR result is
-		  zero extended, so say if op0 is unsigned char
-		  variable, BIT_NOT_EXPR is unsigned short and
-		  result type int and op0 has value 0x55, the
-		  int value will be 0xffaa, or for op0 0xaa it
-		  will be 0xff55.  In these cases, warn if
-		  op1 is unsigned and narrower than unsigned short.
-		  While if unsignedp0 is false, the BIT_NOT_EXPR
-		  result is sign extended and because of the
-		  above TYPE_PRECISION comparison we know the
-		  MSB of BIT_NOT_EXPR is set (perhaps with some
-		  further bits below it).  The sign extension will
-		  then ensure all bits above BIT_NOT_EXPR up to
-		  result_type's precision are set.  */
-	       && (TYPE_PRECISION (TREE_TYPE (op1))
-		   < TYPE_PRECISION (unsignedp0
-				     ? TREE_TYPE (op0)
-				     : result_type)))
+	       && TYPE_PRECISION (TREE_TYPE (op1)) < bits0)
 	warning_at (location, OPT_Wsign_compare,
 		    "comparison of promoted bitwise complement "
 		    "of an unsigned value with unsigned");
diff --git a/gcc/testsuite/c-c++-common/Wsign-compare-2.c b/gcc/testsuite/c-c++-common/Wsign-compare-2.c
index 23933d09cdc..71a7c9899fb 100644
--- a/gcc/testsuite/c-c++-common/Wsign-compare-2.c
+++ b/gcc/testsuite/c-c++-common/Wsign-compare-2.c
@@ -104,3 +104,9 @@ f17 (unsigned char x, unsigned short y)
 {
   return (unsigned short) (~(unsigned short) x) == y;		/* { dg-bogus "comparison of promoted bitwise complement of an unsigned value with unsigned" } */
 }
+
+int
+f18 (unsigned char x)
+{
+  return (unsigned int) (short) (~(unsigned short) x) == 0xffffff05ULL;	/* { dg-bogus "comparison of promoted bitwise complement of an unsigned value with constant" } */
+}

commit 71ddae709ba21af895622d70480f5ebce0779723
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Fri Mar 10 20:38:13 2023 +0100

    c++: Don't clear TREE_READONLY for -fmerge-all-constants for non-aggregates [PR107558]
    
    The following testcase ICEs, because OpenMP lowering for shared clause
    on l variable with REFERENCE_TYPE creates POINTER_TYPE to REFERENCE_TYPE.
    The reason is that the automatic variable has non-trivial construction
    (reference to a lambda) and -fmerge-all-constants is on and so TREE_READONLY
    isn't set - omp-low will handle automatic TREE_READONLY vars in shared
    specially and only copy to the construct and not back, while !TREE_READONLY
    are assumed to be changeable.
    The PR91529 change rationale was that the gimplification can change
    some non-addressable automatic variables to TREE_STATIC with
    -fmerge-all-constants and therefore TREE_READONLY on them is undesirable.
    But, the gimplifier does that only for aggregate variables:
      switch (TREE_CODE (type))
        {
        case RECORD_TYPE:
        case UNION_TYPE:
        case QUAL_UNION_TYPE:
        case ARRAY_TYPE:
    and not for anything else.  So, I think clearing TREE_READONLY for
    automatic integral or reference or pointer etc. vars for
    -fmerge-all-constants only is unnecessary.
    
    2023-03-10  Jakub Jelinek  <jakub@redhat.com>
    
            PR c++/107558
            * decl.c (cp_finish_decl): Don't clear TREE_READONLY on
            automatic non-aggregate variables just because of
            -fmerge-all-constants.
    
            * g++.dg/gomp/pr107558.C: New test.
    
    (cherry picked from commit 60b6f5c0a334db3f8f6dffaf0b9aab42fd5c54a2)

diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 4c7174395b6..0eb15de734a 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -7920,8 +7920,10 @@ cp_finish_decl (tree decl, tree init, bool init_const_expr_p,
 
       if (var_definition_p
 	  /* With -fmerge-all-constants, gimplify_init_constructor
-	     might add TREE_STATIC to the variable.  */
-	  && (TREE_STATIC (decl) || flag_merge_constants >= 2))
+	     might add TREE_STATIC to aggregate variables.  */
+	  && (TREE_STATIC (decl)
+	      || (flag_merge_constants >= 2
+		  && AGGREGATE_TYPE_P (type))))
 	{
 	  /* If a TREE_READONLY variable needs initialization
 	     at runtime, it is no longer readonly and we need to
diff --git a/gcc/testsuite/g++.dg/gomp/pr107558.C b/gcc/testsuite/g++.dg/gomp/pr107558.C
new file mode 100644
index 00000000000..8a6b8d45df7
--- /dev/null
+++ b/gcc/testsuite/g++.dg/gomp/pr107558.C
@@ -0,0 +1,14 @@
+// PR c++/107558
+// { dg-do compile { target c++11 } }
+// { dg-additional-options "-fmerge-all-constants" }
+// { dg-additional-options "-flto" { target lto } }
+
+int a = 15;
+
+void
+foo ()
+{
+  auto &&l = [&]() { return a; };
+#pragma omp target parallel
+  l ();
+}

commit 066de3a9bb2bc796cfc02767ab4d4440660f7086
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Tue Mar 14 16:17:32 2023 +0100

    c++: Treat unnamed bitfields as padding for __has_unique_object_representations [PR109096]
    
    As reported in the PR, for __has_unique_object_representations we
    were treating unnamed bitfields as named ones, which is wrong, they
    are actually padding.
    
    THe following patch fixes that.
    
    2023-03-14  Jakub Jelinek  <jakub@redhat.com>
    
            PR c++/109096
            * tree.c (record_has_unique_obj_representations): Ignore unnamed
            bitfields.
    
            * g++.dg/cpp1z/has-unique-obj-representations3.C: New test.
    
    (cherry picked from commit c35cf160a0ed81570cff6600dba465cf95fa80fa)

diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c
index 6b9765fb71a..399c4435293 100644
--- a/gcc/cp/tree.c
+++ b/gcc/cp/tree.c
@@ -4466,7 +4466,7 @@ record_has_unique_obj_representations (const_tree t, const_tree sz)
 						    DECL_SIZE (field)))
 	  return false;
       }
-    else if (DECL_C_BIT_FIELD (field))
+    else if (DECL_C_BIT_FIELD (field) && !DECL_UNNAMED_BIT_FIELD (field))
       {
 	tree btype = DECL_BIT_FIELD_TYPE (field);
 	if (!type_has_unique_obj_representations (btype))
@@ -4477,7 +4477,7 @@ record_has_unique_obj_representations (const_tree t, const_tree sz)
 
   offset_int cur = 0;
   for (tree field = TYPE_FIELDS (t); field; field = DECL_CHAIN (field))
-    if (TREE_CODE (field) == FIELD_DECL)
+    if (TREE_CODE (field) == FIELD_DECL && !DECL_UNNAMED_BIT_FIELD (field))
       {
 	offset_int fld = wi::to_offset (DECL_FIELD_OFFSET (field));
 	offset_int bitpos = wi::to_offset (DECL_FIELD_BIT_OFFSET (field));
diff --git a/gcc/testsuite/g++.dg/cpp1z/has-unique-obj-representations3.C b/gcc/testsuite/g++.dg/cpp1z/has-unique-obj-representations3.C
new file mode 100644
index 00000000000..349c93e3c2b
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp1z/has-unique-obj-representations3.C
@@ -0,0 +1,10 @@
+// PR c++/109096
+// { dg-do compile { target c++11 } }
+
+#define INTB (__SIZEOF_INT__ * __CHAR_BIT__)
+struct U { int i : INTB * 3 / 4; int : INTB / 4; };
+struct V { int : INTB * 3 / 4; int j : INTB / 4; };
+struct W { int i; int : 0; int j; };
+static_assert (__has_unique_object_representations (U) == false, "");
+static_assert (__has_unique_object_representations (V) == false, "");
+static_assert (sizeof (W) != 2 * sizeof (int) || __has_unique_object_representations (W) == true, "");

commit 605449d80639a9892c645ce3449f01cb955512fa
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Fri Mar 17 08:46:28 2023 +0100

    openmp: Fix up handling of doacross loops with noreturn body in loops [PR108685]
    
    The following patch fixes an ICE with doacross loops which have a single entry
    no exit body, at least one of the ordered > collapse loops isn't guaranteed to
    have at least one iteration and the whole doacross loop is inside some other loop.
    The OpenMP constructs aren't represented by struct loop until the omp expansions,
    so for a normal doacross loop which doesn't have a noreturn body the entry_bb
    with the GOMP_FOR statement and the first bb of the body typically have the
    same loop_father, and if the doacross loop isn't inside of some other loop
    and the body is noreturn as well, both are part of loop 0.  The problematic
    case is when the entry_bb is inside of some deeper loop, but the body, because
    it falls through into EXIT, has loop 0 as loop_father.  l0_bb is created by
    splitting the entry_bb fallthru edge into l1_bb, and because the two basic blocks
    have different loop_father, a common loop is found for those (which is loop 0).
    Now, if the doacross loop has collapse == ordered or all the ordered > collapse
    loops are guaranteed to iterate at least once, all is still fine, because all
    enter the l1_bb (body), which doesn't return and so doesn't loop further either.
    But, if one of those loops could loop 0 times, the user written body wouldn't be
    reached at all, so unlike the expectations the whole construct actually wouldn't
    be noreturn if entry_bb is encountered and decides to handle at least one
    iteration.
    
    In this case, we need to fix up, move the l0_bb into the same loop as entry_bb
    (initially) and for the extra added loops put them as children of that same
    loop, rather than of loop 0.
    
    2023-03-17  Jakub Jelinek  <jakub@redhat.com>
    
            PR middle-end/108685
            * omp-expand.c (expand_omp_for_ordered_loops): Add L0_BB argument,
            use its loop_father rather than BODY_BB's loop_father.
            (expand_omp_for_generic): Adjust expand_omp_for_ordered_loops caller.
            If broken_loop with ordered > collapse and at least one of those
            extra loops aren't guaranteed to have at least one iteration, change
            l0_bb's loop_father to entry_bb's loop_father.  Set cont_bb's
            loop_father to l0_bb's loop_father rather than l1_bb's.
    
            * c-c++-common/gomp/doacross-8.c: New test.
    
    (cherry picked from commit 713fa5db8ceb4ba8783a0d690ceb4c07f2ff03d0)

diff --git a/gcc/omp-expand.c b/gcc/omp-expand.c
index 3ca9300d41a..7e3fd196fb3 100644
--- a/gcc/omp-expand.c
+++ b/gcc/omp-expand.c
@@ -2410,7 +2410,7 @@ expand_omp_ordered_source_sink (struct omp_region *region,
 static basic_block
 expand_omp_for_ordered_loops (struct omp_for_data *fd, tree *counts,
 			      basic_block cont_bb, basic_block body_bb,
-			      bool ordered_lastprivate)
+			      basic_block l0_bb, bool ordered_lastprivate)
 {
   if (fd->ordered == fd->collapse)
     return cont_bb;
@@ -2515,7 +2515,7 @@ expand_omp_for_ordered_loops (struct omp_for_data *fd, tree *counts,
 	  class loop *loop = alloc_loop ();
 	  loop->header = new_header;
 	  loop->latch = e2->src;
-	  add_loop (loop, body_bb->loop_father);
+	  add_loop (loop, l0_bb->loop_father);
 	}
     }
 
@@ -3204,9 +3204,15 @@ expand_omp_for_generic (struct omp_region *region,
 	    }
 	  if (i < fd->ordered)
 	    {
+	      if (entry_bb->loop_father != l0_bb->loop_father)
+		{
+		  remove_bb_from_loops (l0_bb);
+		  add_bb_to_loop (l0_bb, entry_bb->loop_father);
+		  gcc_assert (single_succ (l0_bb) == l1_bb);
+		}
 	      cont_bb
 		= create_empty_bb (EXIT_BLOCK_PTR_FOR_FN (cfun)->prev_bb);
-	      add_bb_to_loop (cont_bb, l1_bb->loop_father);
+	      add_bb_to_loop (cont_bb, l0_bb->loop_father);
 	      gimple_stmt_iterator gsi = gsi_after_labels (cont_bb);
 	      gimple *g = gimple_build_omp_continue (fd->loop.v, fd->loop.v);
 	      gsi_insert_before (&gsi, g, GSI_SAME_STMT);
@@ -3218,7 +3224,7 @@ expand_omp_for_generic (struct omp_region *region,
 	}
       expand_omp_ordered_source_sink (region, fd, counts, cont_bb);
       cont_bb = expand_omp_for_ordered_loops (fd, counts, cont_bb, l1_bb,
-					      ordered_lastprivate);
+					      l0_bb, ordered_lastprivate);
       if (counts[fd->collapse - 1])
 	{
 	  gcc_assert (fd->collapse == 1);
diff --git a/gcc/testsuite/c-c++-common/gomp/doacross-8.c b/gcc/testsuite/c-c++-common/gomp/doacross-8.c
new file mode 100644
index 00000000000..6de06341af7
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/gomp/doacross-8.c
@@ -0,0 +1,17 @@
+/* PR middle-end/108685 */
+/* { dg-do compile } */
+
+void
+foo (int a)
+{
+  for (int m = 0; m < 10; m++)
+    #pragma omp for collapse(2) ordered(4)
+    for (int i = 0; i < 2; i++)
+      for (int j = 0; j < a; j++)
+	for (int k = 0; k < 2; k++)
+	  for (int l = 0; l < a; l++)
+	    {
+	      #pragma omp ordered depend (source)
+	      __builtin_abort ();
+	    }
+}

commit bdd543db33706643993a468740487147c89a4bd2
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Fri Mar 17 16:10:14 2023 +0100

    c, ubsan: Instrument even shortened divisions [PR109151]
    
    On the following testcase, the C FE decides to shorten the division because
    it has a guarantee that INT_MIN / -1 division won't be encountered, the
    first operand is widened from narrower unsigned and/or the second operand is
    a constant other than all ones (in this case both are true).
    The problem is that the narrower type in this case is _Bool and
    ubsan_instrument_division only instruments it if op0's type is INTEGER_TYPE
    or REAL_TYPE.  Strangely this doesn't happen in C++ FE.
    Anyway, we only shorten divisions if the INT_MIN / -1 case is impossible,
    so I think we should be fine even with -fstrict-enums in C++ in case it
    shortened to ENUMERAL_TYPEs.
    
    The following patch just instruments those on the ubsan_instrument_division
    side.  Perhaps only the first hunk and testcase might be needed because
    we shouldn't shorten if the other case could be triggered.
    
    2023-03-17  Jakub Jelinek  <jakub@redhat.com>
    
            PR c/109151
            * c-ubsan.c (ubsan_instrument_division): Handle all scalar integral
            types rather than just INTEGER_TYPE.
    
            * c-c++-common/ubsan/div-by-zero-8.c: New test.
    
    (cherry picked from commit 103d423f6ce72ccb03d55b7b1dfa2dabd5854371)

diff --git a/gcc/c-family/c-ubsan.c b/gcc/c-family/c-ubsan.c
index 1997e8b5bd1..63e6f11fba2 100644
--- a/gcc/c-family/c-ubsan.c
+++ b/gcc/c-family/c-ubsan.c
@@ -53,7 +53,7 @@ ubsan_instrument_division (location_t loc, tree op0, tree op1)
   op0 = unshare_expr (op0);
   op1 = unshare_expr (op1);
 
-  if (TREE_CODE (type) == INTEGER_TYPE
+  if (INTEGRAL_TYPE_P (type)
       && sanitize_flags_p (SANITIZE_DIVIDE))
     t = fold_build2 (EQ_EXPR, boolean_type_node,
 		     op1, build_int_cst (type, 0));
@@ -68,7 +68,7 @@ ubsan_instrument_division (location_t loc, tree op0, tree op1)
     return NULL_TREE;
 
   /* We check INT_MIN / -1 only for signed types.  */
-  if (TREE_CODE (type) == INTEGER_TYPE
+  if (INTEGRAL_TYPE_P (type)
       && sanitize_flags_p (SANITIZE_DIVIDE)
       && !TYPE_UNSIGNED (type))
     {
diff --git a/gcc/testsuite/c-c++-common/ubsan/div-by-zero-8.c b/gcc/testsuite/c-c++-common/ubsan/div-by-zero-8.c
new file mode 100644
index 00000000000..02e1d7cfc95
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/ubsan/div-by-zero-8.c
@@ -0,0 +1,14 @@
+/* PR c/109151 */
+/* { dg-do run } */
+/* { dg-options "-fsanitize=integer-divide-by-zero -Wno-div-by-zero -fno-sanitize-recover=integer-divide-by-zero" } */
+/* { dg-shouldfail "ubsan" } */
+
+int d;
+
+int
+main ()
+{
+  d = ((short) (d == 1 | d > 9)) / 0;
+}
+
+/* { dg-output "division by zero" } */

commit 06b34c0d76153549fb83001c3d90b798066a1851
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Fri Mar 17 18:59:56 2023 +0100

    tree-inline: Fix up multiversioning with vector arguments [PR105554]
    
    The following testcase ICEs, because we call tree_function_versioning from
    old_decl which has target attributes not supporting V4DImode and so
    DECL_MODE of DECL_ARGUMENTS is BLKmode, while new_decl supports those.
    tree_function_versioning initially copies DECL_RESULT and DECL_ARGUMENTS
    from old_decl to new_decl, then calls initialize_cfun to create cfun
    and only when the cfun is created it can later actually remap_decl
    DECL_RESULT and DECL_ARGUMENTS etc.
    The problem is that initialize_cfun -> push_struct_function ->
    allocate_struct_function calls relayout_decl on DECL_RESULT and
    DECL_ARGUMENTS, which clobbers DECL_MODE of old_decl and we then ICE because
    of it.
    In particular, allocate_struct_function does:
          if (!abstract_p)
            {
              /* Now that we have activated any function-specific attributes
                 that might affect layout, particularly vector modes, relayout
                 each of the parameters and the result.  */
              relayout_decl (result);
              for (tree parm = DECL_ARGUMENTS (fndecl); parm;
                   parm = DECL_CHAIN (parm))
                relayout_decl (parm);
    
              /* Similarly relayout the function decl.  */
              targetm.target_option.relayout_function (fndecl);
            }
    
          if (!abstract_p && aggregate_value_p (result, fndecl))
            {
     #ifdef PCC_STATIC_STRUCT_RETURN
              cfun->returns_pcc_struct = 1;
     #endif
              cfun->returns_struct = 1;
            }
    Now, in the case of tree_function_versioning, I believe all that we need
    from these is possibly the
    targetm.target_option.relayout_function (fndecl);
    call (arm only), we will remap DECL_RESULT and DECL_ARGUMENTS later on
    and copy_decl_for_dup_finish in that case will handle all we need:
      /* For vector typed decls make sure to update DECL_MODE according
         to the new function context.  */
      if (VECTOR_TYPE_P (TREE_TYPE (copy)))
        SET_DECL_MODE (copy, TYPE_MODE (TREE_TYPE (copy)));
    We don't need the cfun->returns_*struct either, because we override it
    in initialize_cfun a few lines later:
      /* Copy items we preserve during cloning.  */
    ...
      cfun->returns_struct = src_cfun->returns_struct;
      cfun->returns_pcc_struct = src_cfun->returns_pcc_struct;
    
    So, to avoid the clobbering of DECL_RESULT/DECL_ARGUMENTS of old_decl,
    the following patch arranges allocate_struct_function to be called with
    abstract_p true and calls targetm.target_option.relayout_function (fndecl);
    by hand.
    
    The removal of DECL_RESULT/DECL_ARGUMENTS copying at the start of
    initialize_cfun is removed because the only caller -
    tree_function_versioning, does that unconditionally before.
    
    2023-03-17  Jakub Jelinek  <jakub@redhat.com>
    
            PR target/105554
            * function.h (push_struct_function): Add ABSTRACT_P argument defaulted
            to false.
            * function.c (push_struct_function): Add ABSTRACT_P argument, pass it
            to allocate_struct_function instead of false.
            * tree-inline.c (initialize_cfun): Don't copy DECL_ARGUMENTS
            nor DECL_RESULT here.  Pass true as ABSTRACT_P to
            push_struct_function.  Call targetm.target_option.relayout_function
            after it.
            (tree_function_versioning): Formatting fix.
    
            * gcc.target/i386/pr105554.c: New test.
    
    (cherry picked from commit 24c06560a7fa39049911eeb8777325d112e0deb9)

diff --git a/gcc/function.c b/gcc/function.c
index d26392a252c..d937873a149 100644
--- a/gcc/function.c
+++ b/gcc/function.c
@@ -4848,7 +4848,7 @@ allocate_struct_function (tree fndecl, bool abstract_p)
    instead of just setting it.  */
 
 void
-push_struct_function (tree fndecl)
+push_struct_function (tree fndecl, bool abstract_p)
 {
   /* When in_dummy_function we might be in the middle of a pop_cfun and
      current_function_decl and cfun may not match.  */
@@ -4857,7 +4857,7 @@ push_struct_function (tree fndecl)
 	      || (cfun && current_function_decl == cfun->decl));
   cfun_stack.safe_push (cfun);
   current_function_decl = fndecl;
-  allocate_struct_function (fndecl, false);
+  allocate_struct_function (fndecl, abstract_p);
 }
 
 /* Reset crtl and other non-struct-function variables to defaults as
diff --git a/gcc/function.h b/gcc/function.h
index 7af1af496ea..58816d2d927 100644
--- a/gcc/function.h
+++ b/gcc/function.h
@@ -666,7 +666,7 @@ extern void pop_cfun (void);
 extern int get_next_funcdef_no (void);
 extern int get_last_funcdef_no (void);
 extern void allocate_struct_function (tree, bool);
-extern void push_struct_function (tree fndecl);
+extern void push_struct_function (tree fndecl, bool = false);
 extern void push_dummy_function (bool);
 extern void pop_dummy_function (void);
 extern void init_dummy_function_start (void);
diff --git a/gcc/testsuite/gcc.target/i386/pr105554.c b/gcc/testsuite/gcc.target/i386/pr105554.c
new file mode 100644
index 00000000000..08e90bb3368
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr105554.c
@@ -0,0 +1,10 @@
+/* PR target/105554 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -Wno-psabi -mno-sse3" } */
+
+typedef long long v4di __attribute__((__vector_size__(32)));
+
+__attribute__((target_clones ("arch=core-avx2", "default"))) void
+foo (v4di x)
+{
+}
diff --git a/gcc/tree-inline.c b/gcc/tree-inline.c
index 658b09c07d2..1e8351837c2 100644
--- a/gcc/tree-inline.c
+++ b/gcc/tree-inline.c
@@ -2769,16 +2769,12 @@ initialize_cfun (tree new_fndecl, tree callee_fndecl, profile_count count)
 {
   struct function *src_cfun = DECL_STRUCT_FUNCTION (callee_fndecl);
 
-  if (!DECL_ARGUMENTS (new_fndecl))
-    DECL_ARGUMENTS (new_fndecl) = DECL_ARGUMENTS (callee_fndecl);
-  if (!DECL_RESULT (new_fndecl))
-    DECL_RESULT (new_fndecl) = DECL_RESULT (callee_fndecl);
-
   /* Register specific tree functions.  */
   gimple_register_cfg_hooks ();
 
   /* Get clean struct function.  */
-  push_struct_function (new_fndecl);
+  push_struct_function (new_fndecl, true);
+  targetm.target_option.relayout_function (new_fndecl);
 
   /* We will rebuild these, so just sanity check that they are empty.  */
   gcc_assert (VALUE_HISTOGRAMS (cfun) == NULL);
@@ -6266,8 +6262,7 @@ tree_function_versioning (tree old_decl, tree new_decl,
   id.transform_parameter = false;
   id.transform_lang_insert_block = NULL;
 
-  old_entry_block = ENTRY_BLOCK_PTR_FOR_FN
-    (DECL_STRUCT_FUNCTION (old_decl));
+  old_entry_block = ENTRY_BLOCK_PTR_FOR_FN (DECL_STRUCT_FUNCTION (old_decl));
   DECL_RESULT (new_decl) = DECL_RESULT (old_decl);
   DECL_ARGUMENTS (new_decl) = DECL_ARGUMENTS (old_decl);
   initialize_cfun (new_decl, old_decl,

commit 73accd859e80e5d50937b8dc85a4e509fc174b97
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Mon Mar 20 20:29:47 2023 +0100

    c++: Drop TREE_READONLY on vars (possibly) initialized by tls wrapper [PR109164]
    
    The following two testcases are miscompiled, because we keep TREE_READONLY
    on the vars even when they are (possibly) dynamically initialized by a TLS
    wrapper function.  Normally cp_finish_decl drops TREE_READONLY from vars
    which need dynamic initialization, but for TLS we do this kind of
    initialization upon every access to those variables.  Keeping them
    TREE_READONLY means e.g. PRE can hoist loads from those before loops
    which contain the TLS wrapper calls, so we can access the TLS variables
    before they are initialized.
    
    2023-03-20  Jakub Jelinek  <jakub@redhat.com>
    
            PR c++/109164
            * cp-tree.h (var_needs_tls_wrapper): Declare.
            * decl2.c (var_needs_tls_wrapper): No longer static.
            * decl.c (cp_finish_decl): Clear TREE_READONLY on TLS variables
            for which a TLS wrapper will be needed.
    
            * g++.dg/tls/thread_local13.C: New test.
            * g++.dg/tls/thread_local13-aux.cc: New file.
            * g++.dg/tls/thread_local14.C: New test.
            * g++.dg/tls/thread_local14-aux.cc: New file.
    
    (cherry picked from commit 0a846340b99675d57fc2f2923a0412134eed09d3)

diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index 15ec4cd199f..36e047ad4c0 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -6683,6 +6683,7 @@ extern void copy_linkage			(tree, tree);
 extern tree get_guard				(tree);
 extern tree get_guard_cond			(tree, bool);
 extern tree set_guard				(tree);
+extern bool var_needs_tls_wrapper		(tree);
 extern tree maybe_get_tls_wrapper_call		(tree);
 extern void mark_needed				(tree);
 extern bool decl_needed_p			(tree);
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 0eb15de734a..1608c0a2560 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -7941,6 +7941,18 @@ cp_finish_decl (tree decl, tree init, bool init_const_expr_p,
 	  if (!decl_maybe_constant_destruction (decl, type))
 	    TREE_READONLY (decl) = 0;
 	}
+      else if (VAR_P (decl)
+	       && CP_DECL_THREAD_LOCAL_P (decl)
+	       && (!DECL_EXTERNAL (decl) || flag_extern_tls_init)
+	       && (was_readonly || TREE_READONLY (decl))
+	       && var_needs_tls_wrapper (decl))
+	{
+	  /* TLS variables need dynamic initialization by the TLS wrapper
+	     function, we don't want to hoist accesses to it before the
+	     wrapper.  */
+	  was_readonly = 0;
+	  TREE_READONLY (decl) = 0;
+	}
 
       make_rtl_for_nonlocal_decl (decl, init, asmspec);
 
diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c
index 7a4e05807e6..577bec362ad 100644
--- a/gcc/cp/decl2.c
+++ b/gcc/cp/decl2.c
@@ -3405,7 +3405,7 @@ var_defined_without_dynamic_init (tree var)
 /* Returns true iff VAR is a variable that needs uses to be
    wrapped for possible dynamic initialization.  */
 
-static bool
+bool
 var_needs_tls_wrapper (tree var)
 {
   return (!error_operand_p (var)
diff --git a/gcc/testsuite/g++.dg/tls/thread_local13-aux.cc b/gcc/testsuite/g++.dg/tls/thread_local13-aux.cc
new file mode 100644
index 00000000000..691f308cff1
--- /dev/null
+++ b/gcc/testsuite/g++.dg/tls/thread_local13-aux.cc
@@ -0,0 +1,35 @@
+// PR c++/109164
+
+struct S { virtual void foo (); int s; };
+extern bool baz ();
+
+void
+S::foo ()
+{
+  if (s != 42)
+    __builtin_abort ();
+}
+
+S s;
+
+S &
+qux ()
+{
+  s.s = 42;
+  return s;
+}
+
+thread_local S &t = qux ();
+
+bool
+bar ()
+{
+  return false;
+}
+
+int
+main ()
+{
+  if (baz ())
+    __builtin_abort ();
+}
diff --git a/gcc/testsuite/g++.dg/tls/thread_local13.C b/gcc/testsuite/g++.dg/tls/thread_local13.C
new file mode 100644
index 00000000000..b424b9f8acf
--- /dev/null
+++ b/gcc/testsuite/g++.dg/tls/thread_local13.C
@@ -0,0 +1,21 @@
+// PR c++/109164
+// { dg-do run { target c++11 } }
+// { dg-options "-O2" }
+// { dg-add-options tls }
+// { dg-require-effective-target tls_runtime }
+// { dg-additional-sources "thread_local13-aux.cc" }
+
+struct S { virtual void foo (); int s; };
+extern thread_local S &t;
+bool bar ();
+
+bool
+baz ()
+{
+  while (1)
+    {
+      t.foo ();
+      if (!bar ())
+        return false;
+    }
+}
diff --git a/gcc/testsuite/g++.dg/tls/thread_local14-aux.cc b/gcc/testsuite/g++.dg/tls/thread_local14-aux.cc
new file mode 100644
index 00000000000..e8f2a243fc1
--- /dev/null
+++ b/gcc/testsuite/g++.dg/tls/thread_local14-aux.cc
@@ -0,0 +1,26 @@
+// PR c++/109164
+
+extern bool baz ();
+
+int
+qux ()
+{
+  return 42;
+}
+
+extern thread_local const int t = qux ();
+
+bool
+bar (int x)
+{
+  if (x != 42)
+    __builtin_abort ();
+  return false;
+}
+
+int
+main ()
+{
+  if (baz ())
+    __builtin_abort ();
+}
diff --git a/gcc/testsuite/g++.dg/tls/thread_local14.C b/gcc/testsuite/g++.dg/tls/thread_local14.C
new file mode 100644
index 00000000000..a7402d0d631
--- /dev/null
+++ b/gcc/testsuite/g++.dg/tls/thread_local14.C
@@ -0,0 +1,19 @@
+// PR c++/109164
+// { dg-do run { target c++11 } }
+// { dg-options "-O2" }
+// { dg-add-options tls }
+// { dg-require-effective-target tls_runtime }
+// { dg-additional-sources "thread_local14-aux.cc" }
+
+extern thread_local const int t;
+bool bar (int);
+
+bool
+baz ()
+{
+  while (1)
+    {
+      if (!bar (t))
+        return false;
+    }
+}

commit 9fa953c8dfc7ee57ffd33e0b4e8be782c3119666
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Sun Mar 26 20:15:05 2023 +0200

    predict: Don't emit -Wsuggest-attribute=cold warning for functions which already have that attribute [PR105685]
    
    In the following testcase, we predict baz to have cold
    entry regardless of the user supplied attribute (as it call
    unconditionally a cold function), but still issue
    a -Wsuggest-attribute=cold warning despite it having that attribute
    already.
    
    The following patch avoids that.
    
    2023-03-26  Jakub Jelinek  <jakub@redhat.com>
    
            PR ipa/105685
            * predict.c (compute_function_frequency): Don't call
            warn_function_cold if function already has cold attribute.
    
            * c-c++-common/cold-2.c: New test.
    
    (cherry picked from commit 7eca91d4781bb3df941f25c30b971dac66ba1b3d)

diff --git a/gcc/predict.c b/gcc/predict.c
index a7ae977c866..b28474a0977 100644
--- a/gcc/predict.c
+++ b/gcc/predict.c
@@ -3941,7 +3941,9 @@ compute_function_frequency (void)
     }
 
   node->frequency = NODE_FREQUENCY_UNLIKELY_EXECUTED;
-  warn_function_cold (current_function_decl);
+  if (lookup_attribute ("cold", DECL_ATTRIBUTES (current_function_decl))
+      == NULL)
+    warn_function_cold (current_function_decl);
   if (ENTRY_BLOCK_PTR_FOR_FN (cfun)->count.ipa() == profile_count::zero ())
     return;
   FOR_EACH_BB_FN (bb, cfun)
diff --git a/gcc/testsuite/c-c++-common/cold-2.c b/gcc/testsuite/c-c++-common/cold-2.c
new file mode 100644
index 00000000000..7f78496fb82
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/cold-2.c
@@ -0,0 +1,19 @@
+/* PR ipa/105685 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -Wsuggest-attribute=cold" } */
+
+extern void foo (char *, char const *, int);
+
+__attribute__((cold)) char *
+bar (int x)
+{
+  static char b[42];
+  foo (b, "foo", x);
+  return b;
+}
+
+__attribute__((cold)) char *
+baz (int x)		/* { dg-bogus "function might be candidate for attribute 'cold'" } */
+{
+  return bar (x);
+}

commit c8dc9e474549c3c6692a71f5d0c791ef900cb60c
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Tue Mar 28 10:56:44 2023 +0200

    sanopt: Return TODO_cleanup_cfg if any .{UB,HWA,A}SAN_* calls were lowered [PR106190]
    
    The following testcase ICEs, because without optimization eh lowering
    decides not to duplicate finally block of try/finally and so we end up
    with variable guarded cleanup.  The sanopt pass creates a cfg that ought
    to be cleaned up (some IFN_UBSAN_* functions are lowered in this case with
    constant conditions in gcond and when not allowing recovery some bbs which
    end with noreturn calls actually have successor edges), but the cfg cleanup
    is actually (it is -O0) done only during the optimized pass.  We notice
    there that the d[1][a] = 0; statement which has an EH edge is unreachable
    (because ubsan would always abort on the out of bounds d[1] access), remove
    the EH landing pad and block, but because that block just sets a variable
    and jumps to another one which tests that variable and that one is reachable
    from normal control flow, the __builtin_eh_pointer (1) later in there is
    kept in the IL and we ICE during expansion of that statement because the
    EH region has been removed.
    
    The following patch fixes it by doing the cfg cleanup already during
    sanopt pass if we create something that might need it, while the EH
    landing pad is then removed already during sanopt pass, there is ehcleanup
    later and we don't ICE anymore.
    
    2023-03-28  Jakub Jelinek  <jakub@redhat.com>
    
            PR middle-end/106190
            * sanopt.c (pass_sanopt::execute): Return TODO_cleanup_cfg if any
            of the IFN_{UB,HWA,A}SAN_* internal fns are lowered.
    
            * gcc.dg/asan/pr106190.c: New test.
    
    (cherry picked from commit 39a43dc336561e0eba0de477b16c7355f19d84ee)

diff --git a/gcc/sanopt.c b/gcc/sanopt.c
index 170da61949c..def9252e353 100644
--- a/gcc/sanopt.c
+++ b/gcc/sanopt.c
@@ -1268,6 +1268,7 @@ pass_sanopt::execute (function *fun)
   basic_block bb;
   int asan_num_accesses = 0;
   bool contains_asan_mark = false;
+  int ret = 0;
 
   /* Try to remove redundant checks.  */
   if (optimize
@@ -1320,6 +1321,7 @@ pass_sanopt::execute (function *fun)
 	  if (gimple_call_internal_p (stmt))
 	    {
 	      enum internal_fn ifn = gimple_call_internal_fn (stmt);
+	      int this_ret = TODO_cleanup_cfg;
 	      switch (ifn)
 		{
 		case IFN_UBSAN_NULL:
@@ -1349,8 +1351,10 @@ pass_sanopt::execute (function *fun)
 						    shadow_vars_mapping);
 		  break;
 		default:
+		  this_ret = 0;
 		  break;
 		}
+	      ret |= this_ret;
 	    }
 	  else if (gimple_call_builtin_p (stmt, BUILT_IN_NORMAL))
 	    {
@@ -1380,7 +1384,7 @@ pass_sanopt::execute (function *fun)
   if (need_commit_edge_insert)
     gsi_commit_edge_inserts ();
 
-  return 0;
+  return ret;
 }
 
 } // anon namespace
diff --git a/gcc/testsuite/gcc.dg/asan/pr106190.c b/gcc/testsuite/gcc.dg/asan/pr106190.c
new file mode 100644
index 00000000000..10eb2789a49
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/asan/pr106190.c
@@ -0,0 +1,15 @@
+/* PR middle-end/106190 */
+/* { dg-do compile } */
+/* { dg-options "-fnon-call-exceptions -fsanitize=address,undefined -fno-sanitize-recover=all" } */
+
+int
+main ()
+{
+  int a;
+  int *b[1];
+  int c[10];
+  int d[1][1];
+  for (a = 0; a < 1; a++)
+    d[1][a] = 0;
+  return 0;
+}

commit 9ae5c50751ef4217b22cc24b67a44a55efef59b9
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Sun Apr 2 20:05:31 2023 +0200

    libiberty: Make strstr.c in libiberty ANSI compliant
    
    On Fri, Nov 13, 2020 at 11:53:43AM -0700, Jeff Law via Gcc-patches wrote:
    >
    > On 5/1/20 6:06 PM, Seija Kijin via Gcc-patches wrote:
    > > The original code in libiberty says "FIXME" and then says it has not been
    > > validated to be ANSI compliant. However, this patch changes the function to
    > > match implementations that ARE compliant, and such code is in the public
    > > domain.
    > >
    > > I ran the test results, and there are no test failures.
    >
    > Thanks.  This seems to be the standard "simple" strstr implementation. 
    > There's significantly faster implementations available, but I doubt it's
    > worth the effort as the version in this file only gets used if there is
    > no system strstr.c.
    
    Except that PR109306 says the new version is non-compliant and
    is certainly slower than what we used to have.  The only problem I see
    on the old version (sure, it is not very fast version) is that for
    strstr ("abcd", "") it returned "abcd"+4 rather than "abcd" because
    strchr in that case changed p to point to the last character and then
    strncmp returned 0.
    
    The question reported in PR109306 is whether memcmp is required not to
    access characters beyond the first difference or not.
    For all of memcmp/strcmp/strncmp, C17 says:
    "The sign of a nonzero value returned by the comparison functions memcmp, strcmp, and strncmp
    is determined by the sign of the difference between the values of the first pair of characters (both
    interpreted as unsigned char) that differ in the objects being compared."
    but then in memcmp description says:
    "The memcmp function compares the first n characters of the object pointed to by s1 to the first n
    characters of the object pointed to by s2."
    rather than something similar to strncmp wording:
    "The strncmp function compares not more than n characters (characters that follow a null character
    are not compared) from the array pointed to by s1 to the array pointed to by
    s2."
    So, while for strncmp it seems clearly well defined when there is zero
    terminator before reaching the n, for memcmp it is unclear if say
    int
    memcmp (const void *s1, const void *s2, size_t n)
    {
      int ret = 0;
      size_t i;
      const unsigned char *p1 = (const unsigned char *) s1;
      const unsigned char *p2 = (const unsigned char *) s2;
    
      for (i = n; i; i--)
        if (p1[i - 1] != p2[i - 1])
          ret = p1[i - 1] < p2[i - 1] ? -1 : 1;
      return ret;
    }
    wouldn't be valid implementation (one which always compares all characters
    and just returns non-zero from the first one that differs).
    
    So, shouldn't we just revert and handle the len == 0 case correctly?
    
    I think almost nothing really uses it, but still, the old version
    at least worked nicer with a fast strchr.
    Could as well strncmp (p + 1, s2 + 1, len - 1) if that is preferred
    because strchr already compared the first character.
    
    2023-04-02  Jakub Jelinek  <jakub@redhat.com>
    
            PR other/109306
            * strstr.c (strstr): Return s1 if len is 0.
    
    (cherry picked from commit 1719fa40c4ee4def60a2ce2f27e17f8168cf28ba)

diff --git a/libiberty/strstr.c b/libiberty/strstr.c
index 60902ea40ee..e6e70fa6fc7 100644
--- a/libiberty/strstr.c
+++ b/libiberty/strstr.c
@@ -32,6 +32,9 @@ strstr (const char *s1, const char *s2)
   const char *p = s1;
   const size_t len = strlen (s2);
 
+  if (!len)
+    return s1;
+
   for (; (p = strchr (p, *s2)) != 0; p++)
     {
       if (strncmp (p, s2, len) == 0)

commit dc457bc1c72c53ee8c4800bac84264e0c8085f24
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Wed Apr 12 16:55:15 2023 +0200

    reassoc: Fix up another ICE with returns_twice call [PR109410]
    
    The following testcase ICEs in reassoc, unlike the last case I've fixed
    there here SSA_NAME_USED_IN_ABNORMAL_PHI is not the case anywhere.
    build_and_add_sum places new statements after the later appearing definition
    of an operand but if both operands are default defs or constants, we place
    statement at the start of the function.
    
    If the very first statement of a function is a call to returns_twice
    function, this doesn't work though, because that call has to be the first
    thing in its basic block, so the following patch splits the entry successor
    edge such that the new statements are added into a different block from the
    returns_twice call.
    
    I think we should in stage1 reconsider such placements, I think it
    unnecessarily enlarges the lifetime of the new lhs if its operand(s)
    are used more than once in the function.  Unless something sinks those
    again.  Would be nice to place it closer to the actual uses (or where
    they will be placed).
    
    2023-04-12  Jakub Jelinek  <jakub@redhat.com>
    
            PR tree-optimization/109410
            * tree-ssa-reassoc.c (build_and_add_sum): Split edge from entry
            block if first statement of the function is a call to returns_twice
            function.
    
            * gcc.dg/pr109410.c: New test.
    
    (cherry picked from commit 51856718a82ce60f067910d9037ca255645b37eb)

diff --git a/gcc/testsuite/gcc.dg/pr109410.c b/gcc/testsuite/gcc.dg/pr109410.c
new file mode 100644
index 00000000000..a6401fc100c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr109410.c
@@ -0,0 +1,19 @@
+/* PR tree-optimization/109410 */
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+__attribute__((returns_twice)) int baz (int, int);
+
+int
+bar (int x)
+{
+  return x;
+}
+
+int
+foo (int x, int y)
+{
+  baz (x, y);
+  int a = bar (x);
+  return y || a == 42 || a > 42;
+}
diff --git a/gcc/tree-ssa-reassoc.c b/gcc/tree-ssa-reassoc.c
index 3a4d7e046c5..1a665928c13 100644
--- a/gcc/tree-ssa-reassoc.c
+++ b/gcc/tree-ssa-reassoc.c
@@ -1495,6 +1495,15 @@ build_and_add_sum (tree type, tree op1, tree op2, enum tree_code opcode)
       && (!op2def || gimple_nop_p (op2def)))
     {
       gsi = gsi_after_labels (single_succ (ENTRY_BLOCK_PTR_FOR_FN (cfun)));
+      if (!gsi_end_p (gsi)
+	  && is_gimple_call (gsi_stmt (gsi))
+	  && (gimple_call_flags (gsi_stmt (gsi)) & ECF_RETURNS_TWICE))
+	{
+	  /* Don't add statements before a returns_twice call at the start
+	     of a function.  */
+	  split_edge (single_succ_edge (ENTRY_BLOCK_PTR_FOR_FN (cfun)));
+	  gsi = gsi_after_labels (single_succ (ENTRY_BLOCK_PTR_FOR_FN (cfun)));
+	}
       if (gsi_end_p (gsi))
 	{
 	  gimple_stmt_iterator gsi2

commit b3f20577e1380bee9066ae3a4072ea5aca3d8f43
Author: Anthony Sharp <anthonysharp15@gmail.com>
Date:   Fri Aug 27 10:02:42 2021 -0400

    call_summary: add missing template keyword
    
    Without the 'template', this function template compares 'traverse' to 'f',
    and then compares the result to 'a'.  Evidently it hasn't been instantiated
    yet.
    
    gcc/ChangeLog:
    
            * symbol-summary.h: Added missing template keyword.
    
    (cherry picked from commit fccd5b48adf568f0aabe5d5f51206a9d42da095a)

diff --git a/gcc/symbol-summary.h b/gcc/symbol-summary.h
index fa1df5c8015..a87dc1df360 100644
--- a/gcc/symbol-summary.h
+++ b/gcc/symbol-summary.h
@@ -142,7 +142,7 @@ public:
   template<typename Arg, bool (*f)(const T &, Arg)>
   void traverse (Arg a) const
   {
-    m_map.traverse <f> (a);
+    m_map.template traverse <f> (a);
   }
 
   /* Getter for summary callgraph node pointer.  If a summary for a node
@@ -634,7 +634,7 @@ public:
   template<typename Arg, bool (*f)(const T &, Arg)>
   void traverse (Arg a) const
   {
-    m_map.traverse <f> (a);
+    m_map.template traverse <f> (a);
   }
 
   /* Getter for summary callgraph edge pointer.

commit 93a1c99b015395ebdfaebf7ff3512b2f9445d5e4
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Fri Apr 28 11:22:26 2023 +0100

    libstdc++: Strip absolute paths from files shown in Doxygen docs
    
    This avoids showing absolute paths from the expansion of
    @srcdir@/libsupc++/ in the doxygen File List view.
    
    libstdc++-v3/ChangeLog:
    
            * doc/doxygen/user.cfg.in (STRIP_FROM_PATH): Remove prefixes
            from header paths.
    
    (cherry picked from commit 975e8e836ead0e9055a125a2a23463db5d847cb3)

diff --git a/libstdc++-v3/doc/doxygen/user.cfg.in b/libstdc++-v3/doc/doxygen/user.cfg.in
index b5ab9e9413b..b02de4f29f3 100644
--- a/libstdc++-v3/doc/doxygen/user.cfg.in
+++ b/libstdc++-v3/doc/doxygen/user.cfg.in
@@ -152,7 +152,7 @@ FULL_PATH_NAMES        = NO
 # will be relative from the directory where doxygen is started.
 # This tag requires that the tag FULL_PATH_NAMES is set to YES.
 
-STRIP_FROM_PATH        =
+STRIP_FROM_PATH        = @srcdir@/doc/ @srcdir@/libsupc++/ include/
 
 # The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of the
 # path mentioned in the documentation of a class, which tells the reader which
@@ -786,6 +786,7 @@ WARN_LOGFILE           =
 # spaces. See also FILE_PATTERNS and EXTENSION_MAPPING
 # Note: If this tag is empty the current directory is searched.
 
+# N.B. update STRIP_FROM_PATH to sanitize paths outside the build tree.
 INPUT                  = @srcdir@/doc/doxygen/doxygroups.cc \
                          @srcdir@/libsupc++/compare \
                          @srcdir@/libsupc++/cxxabi.h \

commit 14175f2262c94868e26f01eef1e14418f2b5e6a9
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Fri Jun 10 14:39:13 2022 +0100

    libstdc++: Make std::lcm and std::gcd detect overflow [PR105844]
    
    When I fixed PR libstdc++/92978 I introduced a regression whereby
    std::lcm(INT_MIN, 1) and std::lcm(50000, 49999) would no longer produce
    errors during constant evaluation. Those calls are undefined, because
    they violate the preconditions that |m| and the result can be
    represented in the return type (which is int in both those cases). The
    regression occurred because __absu<unsigned>(INT_MIN) is well-formed,
    due to the explicit casts to unsigned in that new helper function, and
    the out-of-range multiplication is well-formed, because unsigned
    arithmetic wraps instead of overflowing.
    
    To fix 92978 I made std::gcm and std::lcm calculate |m| and |n|
    immediately, yielding a common unsigned type that was used to calculate
    the result. That was partly correct, but there's no need to use an
    unsigned type. Doing so only suppresses the overflow errors so the
    compiler can't detect them. This change replaces __absu with __abs_r
    that returns the common type (not its corresponding unsigned type). This
    way we can detect overflow in __abs_r when required, while still
    supporting the most-negative value when it can be represented in the
    result type. To detect LCM results that are out of range of the result
    type we still need explicit checks, because neither constant evaluation
    nor UBsan will complain about unsigned wrapping for cases such as
    std::lcm(500000u, 499999u). We can detect those overflows efficiently by
    using __builtin_mul_overflow and asserting.
    
    libstdc++-v3/ChangeLog:
    
            PR libstdc++/105844
            * include/experimental/numeric (experimental::gcd): Simplify
            assertions. Use __abs_r instead of __absu.
            (experimental::lcm): Likewise. Remove use of __detail::__lcm so
            overflow can be detected.
            * include/std/numeric (__detail::__absu): Rename to __abs_r and
            change to allow signed result type, so overflow can be detected.
            (__detail::__lcm): Remove.
            (gcd): Simplify assertions. Use __abs_r instead of __absu.
            (lcm): Likewise. Remove use of __detail::__lcm so overflow can
            be detected.
            * testsuite/26_numerics/gcd/gcd_neg.cc: Adjust dg-error lines.
            * testsuite/26_numerics/lcm/lcm_neg.cc: Likewise.
            * testsuite/26_numerics/gcd/105844.cc: New test.
            * testsuite/26_numerics/lcm/105844.cc: New test.
    
    (cherry picked from commit 671970a5621e18e7079b4ca113e56434c858db66)

diff --git a/libstdc++-v3/include/experimental/numeric b/libstdc++-v3/include/experimental/numeric
index 4154e535a94..2b06d9ffb51 100644
--- a/libstdc++-v3/include/experimental/numeric
+++ b/libstdc++-v3/include/experimental/numeric
@@ -56,17 +56,15 @@ inline namespace fundamentals_v2
     constexpr common_type_t<_Mn, _Nn>
     gcd(_Mn __m, _Nn __n) noexcept
     {
-      static_assert(is_integral_v<_Mn>,
-	  "std::experimental::gcd arguments must be integers");
-      static_assert(is_integral_v<_Nn>,
-	  "std::experimental::gcd arguments must be integers");
-      static_assert(_Mn(2) != _Mn(1),
-	  "std::experimental::gcd arguments must not be bool");
-      static_assert(_Nn(2) != _Nn(1),
-	  "std::experimental::gcd arguments must not be bool");
-      using _Up = make_unsigned_t<common_type_t<_Mn, _Nn>>;
-      return std::__detail::__gcd(std::__detail::__absu<_Up>(__m),
-				  std::__detail::__absu<_Up>(__n));
+      static_assert(is_integral_v<_Mn> && is_integral_v<_Nn>,
+		    "std::experimental::gcd arguments must be integers");
+      static_assert(_Mn(2) == 2 && _Nn(2) == 2,
+		    "std::experimental::gcd arguments must not be bool");
+      namespace __detail = std::__detail;
+      using _Ct = common_type_t<_Mn, _Nn>;
+      const _Ct __m2 = __detail::__abs_r<_Ct>(__m);
+      const _Ct __n2 = __detail::__abs_r<_Ct>(__n);
+      return __detail::__gcd<make_unsigned_t<_Ct>>(__m2, __n2);
     }
 
   /// Least common multiple
@@ -74,17 +72,27 @@ inline namespace fundamentals_v2
     constexpr common_type_t<_Mn, _Nn>
     lcm(_Mn __m, _Nn __n)
     {
-      static_assert(is_integral_v<_Mn>,
+      static_assert(is_integral_v<_Mn> && is_integral_v<_Nn>,
 	  "std::experimental::lcm arguments must be integers");
-      static_assert(is_integral_v<_Nn>,
-	  "std::experimental::lcm arguments must be integers");
-      static_assert(_Mn(2) != _Mn(1),
-	  "std::experimental::lcm arguments must not be bool");
-      static_assert(_Nn(2) != _Nn(1),
+      static_assert(_Mn(2) == 2 && _Nn(2) == 2,
 	  "std::experimental::lcm arguments must not be bool");
-      using _Up = make_unsigned_t<common_type_t<_Mn, _Nn>>;
-      return std::__detail::__lcm(std::__detail::__absu<_Up>(__m),
-				  std::__detail::__absu<_Up>(__n));
+      namespace __detail = std::__detail;
+      using _Ct = common_type_t<_Mn, _Nn>;
+      const _Ct __m2 = __detail::__abs_r<_Ct>(__m);
+      const _Ct __n2 = __detail::__abs_r<_Ct>(__n);
+      if (__m2 == 0 || __n2 == 0)
+	return 0;
+      _Ct __r = __m2 / __detail::__gcd<make_unsigned_t<_Ct>>(__m2, __n2);
+
+#if defined _GLIBCXX_HAVE_BUILTIN_IS_CONSTANT_EVALUATED
+      if _GLIBCXX17_CONSTEXPR (is_signed_v<_Ct>)
+	if (__builtin_is_constant_evaluated())
+	  return __r * __n2; // constant evaluation can detect overflow here.
+#endif
+
+      bool __overflow = __builtin_mul_overflow(__r, __n2, &__r);
+      __glibcxx_assert(!__overflow);
+      return __r;
     }
 } // namespace fundamentals_v2
 } // namespace experimental
diff --git a/libstdc++-v3/include/std/numeric b/libstdc++-v3/include/std/numeric
index 03cf719c676..b81b5e4a30f 100644
--- a/libstdc++-v3/include/std/numeric
+++ b/libstdc++-v3/include/std/numeric
@@ -76,6 +76,7 @@
 
 #if __cplusplus >= 201402L
 #include <type_traits>
+#include <ext/numeric_traits.h>
 
 namespace std _GLIBCXX_VISIBILITY(default)
 {
@@ -83,19 +84,25 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
 namespace __detail
 {
-  // std::abs is not constexpr, doesn't support unsigned integers,
-  // and std::abs(std::numeric_limits<T>::min()) is undefined.
-  template<typename _Up, typename _Tp>
-    constexpr _Up
-    __absu(_Tp __val)
+  // Like std::abs, but supports unsigned types and returns the specified type,
+  // so |std::numeric_limits<_Tp>::min()| is OK if representable in _Res.
+  template<typename _Res, typename _Tp>
+    constexpr _Res
+    __abs_r(_Tp __val)
     {
-      static_assert(is_unsigned<_Up>::value, "result type must be unsigned");
-      static_assert(sizeof(_Up) >= sizeof(_Tp),
+      static_assert(sizeof(_Res) >= sizeof(_Tp),
 	  "result type must be at least as wide as the input type");
-      return __val < 0 ? -(_Up)__val : (_Up)__val;
+
+      if (__val >= 0)
+	return __val;
+#if defined _GLIBCXX_ASSERTIONS && defined _GLIBCXX_HAVE_BUILTIN_IS_CONSTANT_EVALUATED
+      if (!__builtin_is_constant_evaluated()) // overflow already detected in constexpr
+	__glibcxx_assert(__val != __gnu_cxx::__int_traits<_Res>::__min);
+#endif
+      return -static_cast<_Res>(__val);
     }
 
-  template<typename _Up> void __absu(bool) = delete;
+  template<typename> void __abs_r(bool) = delete;
 
   // GCD implementation
   template<typename _Tp>
@@ -107,16 +114,6 @@ namespace __detail
 	: __n == 0 ? __m
 	: __detail::__gcd(__n, _Tp(__m % __n));
     }
-
-  // LCM implementation
-  template<typename _Tp>
-    constexpr _Tp
-    __lcm(_Tp __m, _Tp __n)
-    {
-      return (__m != 0 && __n != 0)
-	? (__m / __detail::__gcd(__m, __n)) * __n
-	: 0;
-    }
 } // namespace __detail
 
 #if __cplusplus >= 201703L
@@ -131,13 +128,14 @@ namespace __detail
     constexpr common_type_t<_Mn, _Nn>
     gcd(_Mn __m, _Nn __n) noexcept
     {
-      static_assert(is_integral_v<_Mn>, "std::gcd arguments must be integers");
-      static_assert(is_integral_v<_Nn>, "std::gcd arguments must be integers");
-      static_assert(_Mn(2) != _Mn(1), "std::gcd arguments must not be bool");
-      static_assert(_Nn(2) != _Nn(1), "std::gcd arguments must not be bool");
-      using _Up = make_unsigned_t<common_type_t<_Mn, _Nn>>;
-      return __detail::__gcd(__detail::__absu<_Up>(__m),
-			     __detail::__absu<_Up>(__n));
+      static_assert(is_integral_v<_Mn> && is_integral_v<_Nn>,
+		    "std::gcd arguments must be integers");
+      static_assert(_Mn(2) == 2 && _Nn(2) == 2,
+		    "std::gcd arguments must not be bool");
+      using _Ct = common_type_t<_Mn, _Nn>;
+      const _Ct __m2 = __detail::__abs_r<_Ct>(__m);
+      const _Ct __n2 = __detail::__abs_r<_Ct>(__n);
+      return __detail::__gcd<make_unsigned_t<_Ct>>(__m2, __n2);
     }
 
   /// Least common multiple
@@ -145,13 +143,26 @@ namespace __detail
     constexpr common_type_t<_Mn, _Nn>
     lcm(_Mn __m, _Nn __n) noexcept
     {
-      static_assert(is_integral_v<_Mn>, "std::lcm arguments must be integers");
-      static_assert(is_integral_v<_Nn>, "std::lcm arguments must be integers");
-      static_assert(_Mn(2) == 2, "std::lcm arguments must not be bool");
-      static_assert(_Nn(2) == 2, "std::lcm arguments must not be bool");
-      using _Up = make_unsigned_t<common_type_t<_Mn, _Nn>>;
-      return __detail::__lcm(__detail::__absu<_Up>(__m),
-			     __detail::__absu<_Up>(__n));
+      static_assert(is_integral_v<_Mn> && is_integral_v<_Nn>,
+		    "std::lcm arguments must be integers");
+      static_assert(_Mn(2) == 2 && _Nn(2) == 2,
+		    "std::lcm arguments must not be bool");
+      using _Ct = common_type_t<_Mn, _Nn>;
+      const _Ct __m2 = __detail::__abs_r<_Ct>(__m);
+      const _Ct __n2 = __detail::__abs_r<_Ct>(__n);
+      if (__m2 == 0 || __n2 == 0)
+	return 0;
+      _Ct __r = __m2 / __detail::__gcd<make_unsigned_t<_Ct>>(__m2, __n2);
+
+#if defined _GLIBCXX_HAVE_BUILTIN_IS_CONSTANT_EVALUATED
+      if constexpr (is_signed_v<_Ct>)
+	if (__builtin_is_constant_evaluated())
+	  return __r * __n2; // constant evaluation can detect overflow here.
+#endif
+
+      bool __overflow = __builtin_mul_overflow(__r, __n2, &__r);
+      __glibcxx_assert(!__overflow);
+      return __r;
     }
 
 #endif // C++17
diff --git a/libstdc++-v3/testsuite/26_numerics/gcd/105844.cc b/libstdc++-v3/testsuite/26_numerics/gcd/105844.cc
new file mode 100644
index 00000000000..3be18330a0f
--- /dev/null
+++ b/libstdc++-v3/testsuite/26_numerics/gcd/105844.cc
@@ -0,0 +1,23 @@
+// { dg-do compile { target c++17 } }
+#include <numeric>
+#include <climits>
+
+// PR libstdc++/105844
+
+// |INT_MIN| can be represented in common_type_t<int, unsigned> i.e. unsigned.
+static_assert( std::gcd(INT_MIN, 2u) == 2 );
+static_assert( std::gcd(2u, INT_MIN) == 2 );
+
+// |LLONG_MIN| can be represented in unsigned long long.
+static_assert( std::gcd(LLONG_MIN, 2ull) == 2 );
+static_assert( std::gcd(2ull, LLONG_MIN) == 2 );
+
+// But |INT_MIN| cannot be represented in common_type<int, int> i.e. int.
+constexpr int a = std::gcd(INT_MIN, 1); // { dg-error "overflow" }
+constexpr int b = std::gcd(1, INT_MIN); // { dg-error "overflow" }
+
+// And |LLONG_MIN| cannot be represented in long.
+constexpr long long c = std::gcd(LLONG_MIN, 1); // { dg-error "overflow" }
+constexpr long long d = std::gcd(1, LLONG_MIN); // { dg-error "overflow" }
+
+// { dg-prune-output "in 'constexpr' expansion" }
diff --git a/libstdc++-v3/testsuite/26_numerics/gcd/gcd_neg.cc b/libstdc++-v3/testsuite/26_numerics/gcd/gcd_neg.cc
index 2e56bc650a7..393863cce0a 100644
--- a/libstdc++-v3/testsuite/26_numerics/gcd/gcd_neg.cc
+++ b/libstdc++-v3/testsuite/26_numerics/gcd/gcd_neg.cc
@@ -46,9 +46,11 @@ test01()
   std::gcd<const int&, const int&>(0.1, 0.1);   // { dg-error "from here" }
 }
 
-// { dg-error "must be integers" "" { target *-*-* } 134 }
-// { dg-error "must be integers" "" { target *-*-* } 135 }
-// { dg-error "must not be bool" "" { target *-*-* } 136 }
-// { dg-error "must not be bool" "" { target *-*-* } 137 }
+// { dg-error "must be integers" "" { target *-*-* } 0 }
+// { dg-error "must not be bool" "" { target *-*-* } 0 }
+// These prunes could be removed if a fix for PR c++/96286 stops them.
 // { dg-prune-output "deleted function" }
 // { dg-prune-output "incomplete type .*make_unsigned" }
+// { dg-prune-output "does not have integral type" }
+// { dg-prune-output "non-integral type" }
+// { dg-prune-output "invalid specialization" }
diff --git a/libstdc++-v3/testsuite/26_numerics/lcm/105844.cc b/libstdc++-v3/testsuite/26_numerics/lcm/105844.cc
new file mode 100644
index 00000000000..0b5ef5ae5e9
--- /dev/null
+++ b/libstdc++-v3/testsuite/26_numerics/lcm/105844.cc
@@ -0,0 +1,24 @@
+// { dg-do compile { target c++17 } }
+#include <numeric>
+#include <climits>
+
+// PR libstdc++/105844
+
+// |INT_MIN| can be represented in common_type_t<int, unsigned> i.e. unsigned.
+static_assert( std::lcm(INT_MIN, 1u) == INT_MAX+1u );
+static_assert( std::lcm(1u, INT_MIN) == INT_MAX+1u );
+
+// But |INT_MIN| cannot be represented in common_type<int, int> i.e. int.
+constexpr int a = std::lcm(INT_MIN, 1); // { dg-error "overflow" }
+constexpr int b = std::lcm(1, INT_MIN); // { dg-error "overflow" }
+
+// And the LCM of 50000 and 49999 cannot be represented in int.
+constexpr int c = std::lcm(50000, 49999); // { dg-error "overflow" }
+constexpr int d = std::lcm(49999, 50000); // { dg-error "overflow" }
+
+// Similarly for unsigned, but the diagnostic is a failed assertion instead.
+constexpr int e = std::lcm(500000u, 499999); // { dg-error "in 'constexpr'" }
+constexpr int f = std::lcm(499999u, 500000); // { dg-error "in 'constexpr'" }
+// { dg-error "unreachable" "" { target *-*-* } 0 }
+
+// { dg-prune-output "in 'constexpr' expansion" }
diff --git a/libstdc++-v3/testsuite/26_numerics/lcm/lcm_neg.cc b/libstdc++-v3/testsuite/26_numerics/lcm/lcm_neg.cc
index 9e83fdcae0b..5616aa132fa 100644
--- a/libstdc++-v3/testsuite/26_numerics/lcm/lcm_neg.cc
+++ b/libstdc++-v3/testsuite/26_numerics/lcm/lcm_neg.cc
@@ -46,9 +46,11 @@ test01()
   std::lcm<const int&, const int&>(0.1, 0.1);   // { dg-error "from here" }
 }
 
-// { dg-error "must be integers" "" { target *-*-* } 148 }
-// { dg-error "must be integers" "" { target *-*-* } 149 }
-// { dg-error "must not be bool" "" { target *-*-* } 150 }
-// { dg-error "must not be bool" "" { target *-*-* } 151 }
+// { dg-error "must be integers" "" { target *-*-* } 0 }
+// { dg-error "must not be bool" "" { target *-*-* } 0 }
+// These prunes could be removed if a fix for PR c++/96286 stops them.
 // { dg-prune-output "deleted function" }
 // { dg-prune-output "incomplete type .*make_unsigned" }
+// { dg-prune-output "does not have integral type" }
+// { dg-prune-output "non-integral type" }
+// { dg-prune-output "invalid specialization" }

commit b357af31b8d1e93f0f70133e25d3ad4045f7a32b
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Wed May 3 21:40:01 2023 +0100

    libstdc++: Ensure constexpr std::lcm detects out-of-range result [PR105844]
    
    On the gcc-10 branch, __glibcxx_assert does not unconditionally check
    the condition during constant evaluation. This means we need an explicit
    additional check for std::lcm results that cannot be represented in an
    unsigned result type.
    
    libstdc++-v3/ChangeLog:
    
            PR libstdc++/105844
            * include/std/numeric (lcm): Ensure out-of-range result is
            detected in constant evaluation.
            * testsuite/26_numerics/lcm/105844.cc: Adjust dg-error string.

diff --git a/libstdc++-v3/include/std/numeric b/libstdc++-v3/include/std/numeric
index b81b5e4a30f..f4636679223 100644
--- a/libstdc++-v3/include/std/numeric
+++ b/libstdc++-v3/include/std/numeric
@@ -161,6 +161,11 @@ namespace __detail
 #endif
 
       bool __overflow = __builtin_mul_overflow(__r, __n2, &__r);
+#if defined _GLIBCXX_HAVE_BUILTIN_IS_CONSTANT_EVALUATED
+      if (__builtin_is_constant_evaluated())
+	if (__overflow)
+	  _GLIBCXX_THROW_OR_ABORT("std::lcm result is out of range of type");
+#endif
       __glibcxx_assert(!__overflow);
       return __r;
     }
diff --git a/libstdc++-v3/testsuite/26_numerics/lcm/105844.cc b/libstdc++-v3/testsuite/26_numerics/lcm/105844.cc
index 0b5ef5ae5e9..c7338f3cbf3 100644
--- a/libstdc++-v3/testsuite/26_numerics/lcm/105844.cc
+++ b/libstdc++-v3/testsuite/26_numerics/lcm/105844.cc
@@ -19,6 +19,6 @@ constexpr int d = std::lcm(49999, 50000); // { dg-error "overflow" }
 // Similarly for unsigned, but the diagnostic is a failed assertion instead.
 constexpr int e = std::lcm(500000u, 499999); // { dg-error "in 'constexpr'" }
 constexpr int f = std::lcm(499999u, 500000); // { dg-error "in 'constexpr'" }
-// { dg-error "unreachable" "" { target *-*-* } 0 }
+// { dg-error "throw.* not a constant expression" "" { target *-*-* } 0 }
 
 // { dg-prune-output "in 'constexpr' expansion" }

commit c642277ccba36cb411c1e9b2f70a4fbb7916d18d
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Thu May 4 00:19:22 2023 +0000

    Daily bump.

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index cb315e901a7..33ac88accd0 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,324 @@
+2023-05-03  Anthony Sharp  <anthonysharp15@gmail.com>
+
+	Backported from master:
+	2021-08-27  Anthony Sharp  <anthonysharp15@gmail.com>
+
+	* symbol-summary.h: Added missing template keyword.
+
+2023-05-03  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2023-04-12  Jakub Jelinek  <jakub@redhat.com>
+
+	PR tree-optimization/109410
+	* tree-ssa-reassoc.c (build_and_add_sum): Split edge from entry
+	block if first statement of the function is a call to returns_twice
+	function.
+
+2023-05-03  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2023-03-28  Jakub Jelinek  <jakub@redhat.com>
+
+	PR middle-end/106190
+	* sanopt.c (pass_sanopt::execute): Return TODO_cleanup_cfg if any
+	of the IFN_{UB,HWA,A}SAN_* internal fns are lowered.
+
+2023-05-03  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2023-03-26  Jakub Jelinek  <jakub@redhat.com>
+
+	PR ipa/105685
+	* predict.c (compute_function_frequency): Don't call
+	warn_function_cold if function already has cold attribute.
+
+2023-05-03  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2023-03-17  Jakub Jelinek  <jakub@redhat.com>
+
+	PR target/105554
+	* function.h (push_struct_function): Add ABSTRACT_P argument defaulted
+	to false.
+	* function.c (push_struct_function): Add ABSTRACT_P argument, pass it
+	to allocate_struct_function instead of false.
+	* tree-inline.c (initialize_cfun): Don't copy DECL_ARGUMENTS
+	nor DECL_RESULT here.  Pass true as ABSTRACT_P to
+	push_struct_function.  Call targetm.target_option.relayout_function
+	after it.
+	(tree_function_versioning): Formatting fix.
+
+2023-05-03  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2023-03-17  Jakub Jelinek  <jakub@redhat.com>
+
+	PR middle-end/108685
+	* omp-expand.c (expand_omp_for_ordered_loops): Add L0_BB argument,
+	use its loop_father rather than BODY_BB's loop_father.
+	(expand_omp_for_generic): Adjust expand_omp_for_ordered_loops caller.
+	If broken_loop with ordered > collapse and at least one of those
+	extra loops aren't guaranteed to have at least one iteration, change
+	l0_bb's loop_father to entry_bb's loop_father.  Set cont_bb's
+	loop_father to l0_bb's loop_father rather than l1_bb's.
+
+2023-05-03  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2023-03-04  Jakub Jelinek  <jakub@redhat.com>
+
+	PR testsuite/108973
+	* selftest-diagnostic.c
+	(test_diagnostic_context::test_diagnostic_context): Set
+	caret_max_width to 80.
+
+2023-05-03  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2023-02-24  Jakub Jelinek  <jakub@redhat.com>
+
+	PR middle-end/108854
+	* cgraphclones.c (duplicate_thunk_for_node): If no parameter
+	changes are needed, copy at least DECL_ARGUMENTS PARM_DECL
+	nodes and adjust their DECL_CONTEXT.
+
+2023-05-03  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2023-02-24  Jakub Jelinek  <jakub@redhat.com>
+
+	PR target/108881
+	* config/i386/i386-builtin.def (__builtin_ia32_cvtne2ps2bf16_v16hi,
+	__builtin_ia32_cvtne2ps2bf16_v16hi_mask,
+	__builtin_ia32_cvtne2ps2bf16_v16hi_maskz,
+	__builtin_ia32_cvtne2ps2bf16_v8hi,
+	__builtin_ia32_cvtne2ps2bf16_v8hi_mask,
+	__builtin_ia32_cvtne2ps2bf16_v8hi_maskz,
+	__builtin_ia32_cvtneps2bf16_v8sf_mask,
+	__builtin_ia32_cvtneps2bf16_v8sf_maskz,
+	__builtin_ia32_cvtneps2bf16_v4sf_mask,
+	__builtin_ia32_cvtneps2bf16_v4sf_maskz,
+	__builtin_ia32_dpbf16ps_v8sf, __builtin_ia32_dpbf16ps_v8sf_mask,
+	__builtin_ia32_dpbf16ps_v8sf_maskz, __builtin_ia32_dpbf16ps_v4sf,
+	__builtin_ia32_dpbf16ps_v4sf_mask,
+	__builtin_ia32_dpbf16ps_v4sf_maskz): Require also
+	OPTION_MASK_ISA_AVX512VL.
+
+2023-05-03  Andrew Pinski  <apinski@marvell.com>
+
+	Backported from master:
+	2023-02-09  Andrew Pinski  <apinski@marvell.com>
+
+	PR tree-optimization/108688
+	* match.pd (bit_field_ref [bit_insert]): Avoid generating
+	BIT_FIELD_REFs of non-mode-precision integral operands.
+
+2023-05-03  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2023-02-02  Jakub Jelinek  <jakub@redhat.com>
+
+	PR middle-end/108435
+	* tree-nested.c (convert_nonlocal_omp_clauses)
+	<case OMP_CLAUSE_LASTPRIVATE>: If info->new_local_var_chain and *seq
+	is not a GIMPLE_BIND, wrap the sequence into a new GIMPLE_BIND
+	before calling declare_vars.
+	(convert_nonlocal_omp_clauses) <case OMP_CLAUSE_LINEAR>: Merge
+	with the OMP_CLAUSE_LASTPRIVATE handling except for whether
+	seq is initialized to &OMP_CLAUSE_LASTPRIVATE_GIMPLE_SEQ (clause)
+	or &OMP_CLAUSE_LINEAR_GIMPLE_SEQ (clause).
+
+2023-05-03  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2023-02-01  Jakub Jelinek  <jakub@redhat.com>
+
+	PR debug/108573
+	* ree.c (combine_reaching_defs): Don't return false for paradoxical
+	subregs in DEBUG_INSNs.
+
+2023-05-03  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2023-01-31  Jakub Jelinek  <jakub@redhat.com>
+
+	PR rtl-optimization/108596
+	* bb-reorder.c (fix_up_fall_thru_edges): Handle the case where cur_bb
+	ends with asm goto and has a crossing fallthrough edge to the same bb
+	that contains at least one of its labels by restoring EDGE_CROSSING
+	flag even on possible edge from cur_bb to new_bb successor.
+
+2023-05-03  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2023-01-27  Jakub Jelinek  <jakub@redhat.com>
+
+	PR other/108560
+	* doc/extend.texi: Fix up return type of __builtin_va_arg_pack_len
+	from size_t to int.
+
+2023-05-03  Eric Biggers  <ebiggers@google.com>
+
+	Backported from master:
+	2023-01-24  Eric Biggers  <ebiggers@google.com>
+
+	PR bootstrap/90543
+	* optc-save-gen.awk: Fix copy-and-paste error.
+
+2023-05-03  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2023-01-04  Jakub Jelinek  <jakub@redhat.com>
+
+	PR middle-end/108237
+	* generic-match-head.c: Include tree-pass.h.
+	(canonicalize_math_p): Define to false if cfun and
+	cfun->curr_properties has PROP_gimple_opt_math resp. PROP_gimple_lvec
+	property set.
+
+2023-05-03  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2022-12-23  Jakub Jelinek  <jakub@redhat.com>
+
+	PR tree-optimization/108068
+	* tree.h (real_maybe_zerop): Declare.
+	* tree.c (real_maybe_zerop): Define.
+	* tree-ssa-dom.c (record_edge_info): Use it instead of
+	real_zerop or TREE_CODE (op1) == SSA_NAME || real_zerop.  Always set
+	can_infer_simple_equiv to false for decimal floating point types.
+
+2023-05-03  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2022-12-22  Jakub Jelinek  <jakub@redhat.com>
+
+	PR rtl-optimization/108193
+	* cse.c (compute_const_anchors): Change n type to
+	unsigned HOST_WIDE_INT, adjust comparison against it to avoid
+	warnings.  Formatting fix.
+	(insert_const_anchor): Use gen_int_mode instead of GEN_INT.
+
+2023-05-03  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2022-12-16  Jakub Jelinek  <jakub@redhat.com>
+
+	PR rtl-optimization/106751
+	* loop-invariant.c (move_invariant_reg): If preheader bb ends
+	with a JUMP_INSN, split the preheader edge and emit invariants
+	into the new preheader basic block.
+
+2023-05-03  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2022-12-10  Jakub Jelinek  <jakub@redhat.com>
+
+	PR tree-optimization/107997
+	* tree-ssa-loop-ivopts.c: Include cfganal.h.
+	(create_new_iv) <case IP_END>: If ip_end_pos bb is non-empty and ends
+	with a stmt which ends bb, instead of adding iv update after it split
+	the latch edge and insert iterator into the new latch bb.
+
+2023-05-03  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2022-12-08  Jakub Jelinek  <jakub@redhat.com>
+
+	PR debug/106719
+	* cfgbuild.c (find_bb_boundaries): If there are NOTEs in between
+	debug_insn (seen after flow_transfer_insn) and insn, move NOTEs
+	before all the DEBUG_INSNs and split after NOTEs.  If there are
+	other insns like jump table data, clear debug_insn.
+
+2023-05-03  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2022-11-24  Jakub Jelinek  <jakub@redhat.com>
+
+	PR middle-end/107317
+	* asan.c: Include diagnostic-core.h.
+	(asan_emit_stack_protection): Return NULL early if seen_error ().
+
+2023-05-03  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2022-11-21  Jakub Jelinek  <jakub@redhat.com>
+
+	PR target/107748
+	* config/i386/smmintrin.h (_mm_extract_ps): Uglify names of local
+	variables and union members.
+
+2023-05-03  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2022-11-20  Jakub Jelinek  <jakub@redhat.com>
+
+	PR target/107183
+	* reg-stack.c (next_flags_user): Add DEBUG_SEEN argument.
+	If >= 0 and a DEBUG_INSN would be otherwise returned, set
+	DEBUG_SEEN to 1 and ignore it.
+	(swap_rtx_condition): Add DEBUG_SEEN argument.  In >= 0
+	mode only set DEBUG_SEEN to 1 if problematic DEBUG_ISNSs
+	were seen and revert all changes on success in that case.
+	Don't try to recog_memoized DEBUG_INSNs.
+	(compare_for_stack_reg): Adjust swap_rtx_condition caller.
+	If it returns true and debug_seen is 1, call swap_rtx_condition
+	again with debug_seen -1.
+
+2023-05-03  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2022-09-24  Jakub Jelinek  <jakub@redhat.com>
+
+	PR c/107001
+	* omp-low.c (lower_omp_taskgroup): Don't add GOMP_RETURN statement
+	at the end.
+	* omp-expand.c (build_omp_regions_1): Clarify GF_OMP_TARGET_KIND_DATA
+	is not stand-alone directive.  For GIMPLE_OMP_TASKGROUP, also don't
+	update parent.
+	(omp_make_gimple_edges) <case GIMPLE_OMP_TASKGROUP>: Reset
+	cur_region back after new_omp_region.
+
+2023-05-03  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2022-07-27  Jakub Jelinek  <jakub@redhat.com>
+
+	PR debug/106261
+	* cgraphunit.c (cgraph_node::assemble_thunks_and_aliases): Don't
+	output asm thunks for -dx.
+
+2023-05-03  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2022-07-01  Jakub Jelinek  <jakub@redhat.com>
+
+	PR middle-end/106144
+	* wide-int.cc (wi::shifted_mask): If end >= prec, return right after
+	emitting element for shift or if shift is 0 first element after start.
+	(wide_int_cc_tests): Add tests for equivalency of wi::mask and
+	wi::shifted_mask with 0 start.
+
+2023-05-03  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2022-06-21  Jakub Jelinek  <jakub@redhat.com>
+
+	PR rtl-optimization/106032
+	* ifcvt.c (noce_try_sign_mask): Punt if !t_unconditional, and
+	t may_trap_or_fault_p, even if it is cheap.
+
+2023-05-03  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2022-06-21  Jakub Jelinek  <jakub@redhat.com>
+
+	PR middle-end/106030
+	* expr.c (expand_cond_expr_using_cmove): Pass NULL_RTX instead of
+	temp to expand_operands if mode has been promoted.
+
 2023-04-18  Philipp Tomsich  <philipp.tomsich@vrull.eu>
 
 	Backported from master:
diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 61f8aade98f..2e0cd4ba7e1 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230503
+20230504
diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog
index a419e0486fd..66bece3b08e 100644
--- a/gcc/c-family/ChangeLog
+++ b/gcc/c-family/ChangeLog
@@ -1,3 +1,36 @@
+2023-05-03  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2023-03-17  Jakub Jelinek  <jakub@redhat.com>
+
+	PR c/109151
+	* c-ubsan.c (ubsan_instrument_division): Handle all scalar integral
+	types rather than just INTEGER_TYPE.
+
+2023-05-03  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2023-03-04  Jakub Jelinek  <jakub@redhat.com>
+
+	PR c/107465
+	* c-warn.c (warn_for_sign_compare): Don't warn for unset bits
+	above innermost zero extension of BIT_NOT_EXPR result.
+
+2023-05-03  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2023-03-04  Jakub Jelinek  <jakub@redhat.com>
+
+	PR c/107465
+	* c-warn.c (warn_for_sign_compare): If c_common_get_narrower
+	doesn't return a narrower result, use TYPE_UNSIGNED to set unsignedp0
+	and unsignedp1.  For the one BIT_NOT_EXPR case vs. one without,
+	only check for constant in the non-BIT_NOT_EXPR operand, use std::swap
+	to simplify the code, only warn if BIT_NOT_EXPR operand is extended
+	from narrower unsigned, fix up computation of mask for the constant
+	cases and for unsigned other operand case handle differently
+	BIT_NOT_EXPR result being sign vs. zero extended.
+
 2023-04-21  Jason Merrill  <jason@redhat.com>
 
 	PR c++/107163
diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog
index 61ad810c12e..b4367dd4769 100644
--- a/gcc/c/ChangeLog
+++ b/gcc/c/ChangeLog
@@ -1,3 +1,22 @@
+2023-05-03  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2022-10-24  Jakub Jelinek  <jakub@redhat.com>
+
+	PR c++/107358
+	* c-typeck.c (build_binary_op): Pass operands before excess precision
+	promotions to scalar_to_vector call.
+
+2023-05-03  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2022-09-24  Jakub Jelinek  <jakub@redhat.com>
+
+	PR c/106981
+	* c-typeck.c (c_tree_equal): Only strip NON_LVALUE_EXPRs at the
+	start.  For CONSTANT_CLASS_P or CASE_CONVERT: return false if t1 and
+	t2 have different types.
+
 2022-08-02  Lewis Hyatt  <lhyatt@gmail.com>
 
 	Backported from master:
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index bbb71668e1f..a8d4a726e55 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,123 @@
+2023-05-03  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2023-03-20  Jakub Jelinek  <jakub@redhat.com>
+
+	PR c++/109164
+	* cp-tree.h (var_needs_tls_wrapper): Declare.
+	* decl2.c (var_needs_tls_wrapper): No longer static.
+	* decl.c (cp_finish_decl): Clear TREE_READONLY on TLS variables
+	for which a TLS wrapper will be needed.
+
+2023-05-03  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2023-03-14  Jakub Jelinek  <jakub@redhat.com>
+
+	PR c++/109096
+	* tree.c (record_has_unique_obj_representations): Ignore unnamed
+	bitfields.
+
+2023-05-03  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2023-03-10  Jakub Jelinek  <jakub@redhat.com>
+
+	PR c++/107558
+	* decl.c (cp_finish_decl): Don't clear TREE_READONLY on
+	automatic non-aggregate variables just because of
+	-fmerge-all-constants.
+
+2023-05-03  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2023-03-02  Jakub Jelinek  <jakub@redhat.com>
+
+	PR debug/108716
+	* cp-gimplify.c (cp_genericize_r) <case USING_STMT>: Set
+	DECL_SOURCE_LOCATION on IMPORTED_DECL to expression location
+	of USING_STMT or input_location.
+
+2023-05-03  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2023-01-24  Jakub Jelinek  <jakub@redhat.com>
+
+	PR c++/108474
+	* cp-gimplify.c (cp_fold_r): Handle structured bindings
+	vars like anon union artificial vars.
+
+2023-05-03  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2023-01-14  Jakub Jelinek  <jakub@redhat.com>
+
+	PR c++/108365
+	* typeck.c (cp_build_binary_op): For integral division or modulo,
+	shorten if type0 is unsigned, or op0 is cast from narrower unsigned
+	integral type or stripped_op1 is INTEGER_CST other than -1.
+
+2023-05-03  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2023-02-01  Jakub Jelinek  <jakub@redhat.com>
+
+	PR c++/108607
+	* constexpr.c (cxx_eval_constant_expression): Handle OMP_*
+	and OACC_* constructs as non-constant.
+	(potential_constant_expression_1): Handle OMP_SCAN.
+
+2023-05-03  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2023-01-19  Jakub Jelinek  <jakub@redhat.com>
+
+	PR c++/53932
+	* cp-gimplify.c (cp_fold_r): During cp_fully_fold_init replace
+	DECL_ANON_UNION_VAR_P VAR_DECLs with their corresponding
+	DECL_VALUE_EXPR.
+
+2023-05-03  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2022-12-21  Jakub Jelinek  <jakub@redhat.com>
+
+	PR c++/108180
+	* pt.c (tsubst_expr): Don't call cp_finish_decl on
+	DECL_OMP_PRIVATIZED_MEMBER vars.
+
+2023-05-03  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2022-12-15  Jakub Jelinek  <jakub@redhat.com>
+
+	PR c++/107065
+	* typeck.c (cp_build_unary_op) <case TRUTH_NOT_EXPR>: If
+	invert_truthvalue_loc returns obvalue_p, wrap it into NON_LVALUE_EXPR.
+	* parser.c (cp_parser_binary_expression): Don't call
+	warn_logical_not_parentheses if current.lhs is a NON_LVALUE_EXPR
+	of a decl with boolean type.
+
+2023-05-03  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2022-10-24  Jakub Jelinek  <jakub@redhat.com>
+
+	PR c++/105774
+	* constexpr.c (cxx_eval_increment_expression): For signed types
+	that promote to int, evaluate PLUS_EXPR or MINUS_EXPR in int type.
+
+2023-05-03  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2022-08-16  Jakub Jelinek  <jakub@redhat.com>
+
+	* typeck.c (cp_build_modify_expr): Implement
+	P2327R1 - De-deprecating volatile compound operations.  Don't warn
+	for |=, &= or ^= with volatile lhs.
+	* expr.c (mark_use) <case MODIFY_EXPR>: Adjust warning wording,
+	leave out simple.
+
 2023-04-21  Jason Merrill  <jason@redhat.com>
 
 	PR c++/105996
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 6714c3a9906..4d79f1d4eb4 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,21 @@
+2023-05-03  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2023-02-03  Jakub Jelinek  <jakub@redhat.com>
+
+	PR fortran/108451
+	* trans-decl.c (gfc_trans_use_stmts): Call clear_slot before
+	doing continue.
+
+2023-05-03  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2023-01-11  Jakub Jelinek  <jakub@redhat.com>
+
+	PR fortran/108349
+	* f95-lang.c (gfc_init_builtin_function): Fix up function types
+	for BUILT_IN_REALLOC and BUILT_IN_SINCOS{F,,L}.  Formatting fixes.
+
 2023-04-16  Harald Anlauf  <anlauf@gmx.de>
 
 	Backported from master:
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 6fe83cf831a..df4a53ebf05 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,341 @@
+2023-05-03  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2023-04-12  Jakub Jelinek  <jakub@redhat.com>
+
+	PR tree-optimization/109410
+	* gcc.dg/pr109410.c: New test.
+
+2023-05-03  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2023-03-28  Jakub Jelinek  <jakub@redhat.com>
+
+	PR middle-end/106190
+	* gcc.dg/asan/pr106190.c: New test.
+
+2023-05-03  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2023-03-26  Jakub Jelinek  <jakub@redhat.com>
+
+	PR ipa/105685
+	* c-c++-common/cold-2.c: New test.
+
+2023-05-03  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2023-03-20  Jakub Jelinek  <jakub@redhat.com>
+
+	PR c++/109164
+	* g++.dg/tls/thread_local13.C: New test.
+	* g++.dg/tls/thread_local13-aux.cc: New file.
+	* g++.dg/tls/thread_local14.C: New test.
+	* g++.dg/tls/thread_local14-aux.cc: New file.
+
+2023-05-03  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2023-03-17  Jakub Jelinek  <jakub@redhat.com>
+
+	PR target/105554
+	* gcc.target/i386/pr105554.c: New test.
+
+2023-05-03  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2023-03-17  Jakub Jelinek  <jakub@redhat.com>
+
+	PR c/109151
+	* c-c++-common/ubsan/div-by-zero-8.c: New test.
+
+2023-05-03  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2023-03-17  Jakub Jelinek  <jakub@redhat.com>
+
+	PR middle-end/108685
+	* c-c++-common/gomp/doacross-8.c: New test.
+
+2023-05-03  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2023-03-14  Jakub Jelinek  <jakub@redhat.com>
+
+	PR c++/109096
+	* g++.dg/cpp1z/has-unique-obj-representations3.C: New test.
+
+2023-05-03  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2023-03-10  Jakub Jelinek  <jakub@redhat.com>
+
+	PR c++/107558
+	* g++.dg/gomp/pr107558.C: New test.
+
+2023-05-03  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2023-03-04  Jakub Jelinek  <jakub@redhat.com>
+
+	PR c/107465
+	* c-c++-common/Wsign-compare-2.c (f18): New test.
+
+2023-05-03  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2023-03-04  Jakub Jelinek  <jakub@redhat.com>
+
+	PR c/107465
+	* c-c++-common/Wsign-compare-2.c: New test.
+	* c-c++-common/pr107465.c: New test.
+
+2023-05-03  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2023-03-02  Jakub Jelinek  <jakub@redhat.com>
+
+	PR debug/108716
+	* g++.dg/debug/dwarf2/pr108716.C: New test.
+
+2023-05-03  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2023-02-24  Jakub Jelinek  <jakub@redhat.com>
+
+	PR middle-end/108854
+	* g++.dg/opt/pr108854.C: New test.
+
+2023-05-03  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2023-02-24  Jakub Jelinek  <jakub@redhat.com>
+
+	PR target/108881
+	* gcc.target/i386/avx512bf16-pr108881.c: New test.
+
+2023-05-03  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2023-01-24  Jakub Jelinek  <jakub@redhat.com>
+
+	PR c++/108474
+	* g++.dg/cpp1z/decomp57.C: New test.
+	* g++.dg/cpp1z/decomp58.C: New test.
+
+2023-05-03  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2023-01-14  Jakub Jelinek  <jakub@redhat.com>
+
+	PR c++/108365
+	* g++.dg/opt/pr108365.C: New test.
+	* g++.dg/warn/pr108365.C: New test.
+
+2023-05-03  Andrew Pinski  <apinski@marvell.com>
+
+	Backported from master:
+	2023-02-09  Andrew Pinski  <apinski@marvell.com>
+
+	PR tree-optimization/108688
+	* gcc.c-torture/compile/pr108688-1.c: New test.
+
+2023-05-03  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2023-02-02  Jakub Jelinek  <jakub@redhat.com>
+
+	PR middle-end/108435
+	* gcc.dg/gomp/pr108435.c: New test.
+
+2023-05-03  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2023-02-01  Jakub Jelinek  <jakub@redhat.com>
+
+	PR debug/108573
+	* gcc.dg/pr108573.c: New test.
+
+2023-05-03  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2023-02-01  Jakub Jelinek  <jakub@redhat.com>
+
+	PR c++/108607
+	* g++.dg/gomp/pr108607.C: New test.
+
+2023-05-03  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2023-01-31  Jakub Jelinek  <jakub@redhat.com>
+
+	PR rtl-optimization/108596
+	* gcc.c-torture/compile/pr108596.c: New test.
+
+2023-05-03  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2023-01-19  Jakub Jelinek  <jakub@redhat.com>
+
+	PR c++/53932
+	* g++.dg/init/pr53932.C: New test.
+
+2023-05-03  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2023-01-04  Jakub Jelinek  <jakub@redhat.com>
+
+	PR middle-end/108237
+	* gcc.c-torture/compile/pr108237.c: New test.
+
+2023-05-03  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2022-12-23  Jakub Jelinek  <jakub@redhat.com>
+
+	PR tree-optimization/108068
+	* gcc.dg/dfp/pr108068.c: New test.
+
+2023-05-03  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2022-12-22  Jakub Jelinek  <jakub@redhat.com>
+
+	PR rtl-optimization/108193
+	* gfortran.dg/pr108193.f90: New test.
+
+2023-05-03  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2022-12-19  Jakub Jelinek  <jakub@redhat.com>
+
+	PR testsuite/108151
+	* gcc.dg/pr64536.c (bar): Cast long to __INTPTR_TYPE__
+	before casting to long *.
+
+2023-05-03  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2022-12-19  Jakub Jelinek  <jakub@redhat.com>
+
+	PR testsuite/108151
+	* gcc.dg/pr64536.c (bar): Use casts to __INTPTR_TYPE__ rather than
+	long when casting pointer to integral type.
+
+2023-05-03  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2022-12-16  Jakub Jelinek  <jakub@redhat.com>
+
+	PR rtl-optimization/106751
+	* gcc.c-torture/compile/pr106751.c: New test.
+
+2023-05-03  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2022-12-15  Jakub Jelinek  <jakub@redhat.com>
+
+	PR c++/107065
+	* g++.dg/cpp0x/pr107065.C: New test.
+
+2023-05-03  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2022-12-10  Jakub Jelinek  <jakub@redhat.com>
+
+	PR tree-optimization/107997
+	* gcc.c-torture/compile/pr107997.c: New test.
+
+2023-05-03  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2022-12-08  Jakub Jelinek  <jakub@redhat.com>
+
+	PR debug/106719
+	* gcc.dg/pr106719.c: New test.
+
+2023-05-03  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2022-11-24  Jakub Jelinek  <jakub@redhat.com>
+
+	PR middle-end/107317
+	* gcc.dg/asan/pr107317.c: New test.
+
+2023-05-03  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2022-11-20  Jakub Jelinek  <jakub@redhat.com>
+
+	PR target/107183
+	* gcc.dg/ubsan/pr107183.c: New test.
+
+2023-05-03  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2022-10-24  Jakub Jelinek  <jakub@redhat.com>
+
+	PR c++/107358
+	* c-c++-common/pr107358.c: New test.
+
+2023-05-03  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2022-10-24  Jakub Jelinek  <jakub@redhat.com>
+
+	PR c++/105774
+	* g++.dg/cpp1y/constexpr-105774.C: New test.
+
+2023-05-03  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2022-09-24  Jakub Jelinek  <jakub@redhat.com>
+
+	PR c/107001
+	* c-c++-common/gomp/pr107001.c: New test.
+
+2023-05-03  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2022-09-24  Jakub Jelinek  <jakub@redhat.com>
+
+	PR c/106981
+	* c-c++-common/gomp/pr106981.c: New test.
+
+2023-05-03  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2022-08-16  Jakub Jelinek  <jakub@redhat.com>
+
+	* g++.dg/cpp2a/volatile1.C: Adjust for de-deprecation of volatile
+	compound |=, &= and ^= operations.
+	* g++.dg/cpp2a/volatile3.C: Likewise.
+	* g++.dg/cpp2a/volatile5.C: Likewise.
+
+2023-05-03  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2022-07-27  Jakub Jelinek  <jakub@redhat.com>
+
+	PR debug/106261
+	* g++.dg/debug/pr106261.C: New test.
+
+2023-05-03  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2022-06-21  Jakub Jelinek  <jakub@redhat.com>
+
+	PR rtl-optimization/106032
+	* gcc.c-torture/execute/pr106032.c: New test.
+
+2023-05-03  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2022-06-21  Jakub Jelinek  <jakub@redhat.com>
+
+	PR middle-end/106030
+	* gcc.c-torture/compile/pr106030.c: New test.
+
 2023-04-25  Jason Merrill  <jason@redhat.com>
 
 	PR testsuite/109608
diff --git a/libgcc/ChangeLog b/libgcc/ChangeLog
index fa16074a85e..3737ea93681 100644
--- a/libgcc/ChangeLog
+++ b/libgcc/ChangeLog
@@ -1,3 +1,13 @@
+2023-05-03  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2023-02-09  Jakub Jelinek  <jakub@redhat.com>
+
+	PR target/100758
+	* config/i386/cpuinfo.c (cpu_indicator_init): Call
+	get_available_features for all CPUs with max_level >= 1, rather
+	than just Intel or AMD.
+
 2023-02-20  Nelson Chu  <nelson.chu@sifive.com>
 
 	Backported from master:
diff --git a/libgomp/ChangeLog b/libgomp/ChangeLog
index aac1d805a49..3b392e3a630 100644
--- a/libgomp/ChangeLog
+++ b/libgomp/ChangeLog
@@ -1,3 +1,48 @@
+2023-05-03  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2023-02-16  Jakub Jelinek  <jakub@redhat.com>
+
+	* libgomp.texi: Fix typos - theads -> threads.
+
+2023-05-03  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2022-12-21  Jakub Jelinek  <jakub@redhat.com>
+
+	PR c++/108180
+	* testsuite/libgomp.c++/pr108180.C: New test.
+
+2023-05-03  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2022-10-12  Jakub Jelinek  <jakub@redhat.com>
+
+	* task.c (gomp_create_artificial_team): Fix up handling of invocations
+	from within explicit task.
+	* target.c (GOMP_target_ext): Likewise.
+	* testsuite/libgomp.c/task-7.c: New test.
+	* testsuite/libgomp.c/task-8.c: New test.
+	* testsuite/libgomp.c-c++-common/task-reduction-17.c: New test.
+	* testsuite/libgomp.c-c++-common/task-reduction-18.c: New test.
+
+2023-05-03  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2022-09-24  Jakub Jelinek  <jakub@redhat.com>
+
+	PR c/106981
+	* testsuite/libgomp.c-c++-common/pr106981.c: New test.
+
+2023-05-03  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2022-06-21  Jakub Jelinek  <jakub@redhat.com>
+		    Paul Iannetta  <piannetta@kalrayinc.com>
+
+	PR libgomp/106045
+	* testsuite/libgomp.c/target-31.c: Add private (i) clause.
+
 2022-06-28  Release Manager
 
 	* GCC 10.4.0 released.
diff --git a/libiberty/ChangeLog b/libiberty/ChangeLog
index 3801e0186dd..844cbcae96a 100644
--- a/libiberty/ChangeLog
+++ b/libiberty/ChangeLog
@@ -1,3 +1,11 @@
+2023-05-03  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2023-04-02  Jakub Jelinek  <jakub@redhat.com>
+
+	PR other/109306
+	* strstr.c (strstr): Return s1 if len is 0.
+
 2022-06-28  Release Manager
 
 	* GCC 10.4.0 released.
diff --git a/libquadmath/ChangeLog b/libquadmath/ChangeLog
index 65cd67bcb05..02050e3449a 100644
--- a/libquadmath/ChangeLog
+++ b/libquadmath/ChangeLog
@@ -1,3 +1,18 @@
+2023-05-03  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2023-03-02  niXman  <i.nixman@autistici.org>
+		    Jakub Jelinek  <jakub@redhat.com>
+
+	PR libquadmath/87204
+	PR libquadmath/94756
+	* strtod/strtod_l.c (round_and_return): Cherry-pick glibc
+	9310c284ae9 BZ #16151, 4406c41c1d6 BZ #16965 and fcd6b5ac36a
+	BZ #23279 fixes.
+	(____STRTOF_INTERNAL): Cherry-pick glibc b0debe14fcf BZ #23007,
+	5556d30caee BZ #18247, 09555b9721d and c6aac3bf366 BZ #26137 and
+	d84f25c7d87 fixes.
+
 2022-06-28  Release Manager
 
 	* GCC 10.4.0 released.
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index edb95007826..a3cef8f3031 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,39 @@
+2023-05-03  Jonathan Wakely  <jwakely@redhat.com>
+
+	PR libstdc++/105844
+	* include/std/numeric (lcm): Ensure out-of-range result is
+	detected in constant evaluation.
+	* testsuite/26_numerics/lcm/105844.cc: Adjust dg-error string.
+
+2023-05-03  Jonathan Wakely  <jwakely@redhat.com>
+
+	Backported from master:
+	2022-06-10  Jonathan Wakely  <jwakely@redhat.com>
+
+	PR libstdc++/105844
+	* include/experimental/numeric (experimental::gcd): Simplify
+	assertions. Use __abs_r instead of __absu.
+	(experimental::lcm): Likewise. Remove use of __detail::__lcm so
+	overflow can be detected.
+	* include/std/numeric (__detail::__absu): Rename to __abs_r and
+	change to allow signed result type, so overflow can be detected.
+	(__detail::__lcm): Remove.
+	(gcd): Simplify assertions. Use __abs_r instead of __absu.
+	(lcm): Likewise. Remove use of __detail::__lcm so overflow can
+	be detected.
+	* testsuite/26_numerics/gcd/gcd_neg.cc: Adjust dg-error lines.
+	* testsuite/26_numerics/lcm/lcm_neg.cc: Likewise.
+	* testsuite/26_numerics/gcd/105844.cc: New test.
+	* testsuite/26_numerics/lcm/105844.cc: New test.
+
+2023-05-03  Jonathan Wakely  <jwakely@redhat.com>
+
+	Backported from master:
+	2023-04-28  Jonathan Wakely  <jwakely@redhat.com>
+
+	* doc/doxygen/user.cfg.in (STRIP_FROM_PATH): Remove prefixes
+	from header paths.
+
 2023-04-28  Jonathan Wakely  <jwakely@redhat.com>
 
 	Backported from master:

commit 4ee3d035a9beddab30515d906dde5186e844d4a2
Author: Richard Biener <rguenther@suse.de>
Date:   Thu May 4 09:39:12 2023 +0200

    Revert "tree-optimization/106809 - compile time hog in VN"
    
    This reverts commit 051f78a5c1d6994c10ee7c35453ff0ccee94e5c6.

diff --git a/gcc/testsuite/gcc.dg/torture/pr106809.c b/gcc/testsuite/gcc.dg/torture/pr106809.c
deleted file mode 100644
index 11e158185cf..00000000000
--- a/gcc/testsuite/gcc.dg/torture/pr106809.c
+++ /dev/null
@@ -1,28 +0,0 @@
-/* { dg-do compile } */
-/* { dg-additional-options "-Wuninitialized" } */
-
-int foo (int x, int *val)
-{
-  switch (x)
-    {
-#define C(n) \
-    case n + 0: return *val; \
-    case n + 1: return *val; \
-    case n + 2: return *val; \
-    case n + 3: return *val; \
-    case n + 4: return *val; \
-    case n + 5: return *val; \
-    case n + 6: return *val; \
-    case n + 7: return *val; \
-    case n + 8: return *val; \
-    case n + 9: return *val;
-#define C1(n) \
-    C(n+00) C(n+10) C(n+20) C(n+30) C(n+40) \
-    C(n+50) C(n+60) C(n+70) C(n+80) C(n+90)
-#define C10(n) \
-    C1(n+000) C1(n+100) C1(n+200) C1(n+300) C1(n+400) \
-    C1(n+500) C1(n+600) C1(n+700) C1(n+800) C1(n+900)
-    C10(1000)
-    }
-  return 0;
-}
diff --git a/gcc/tree-ssa-sccvn.c b/gcc/tree-ssa-sccvn.c
index 666d7061aa8..2f6f5074b07 100644
--- a/gcc/tree-ssa-sccvn.c
+++ b/gcc/tree-ssa-sccvn.c
@@ -4509,44 +4509,41 @@ dominated_by_p_w_unex (basic_block bb1, basic_block bb2, bool allow_back)
     }
 
   /* Iterate to the single executable bb2 successor.  */
-  if (EDGE_COUNT (bb2->succs) > 1)
-    {
-      edge succe = NULL;
-      FOR_EACH_EDGE (e, ei, bb2->succs)
-	if ((e->flags & EDGE_EXECUTABLE)
-	    || (!allow_back && (e->flags & EDGE_DFS_BACK)))
+  edge succe = NULL;
+  FOR_EACH_EDGE (e, ei, bb2->succs)
+    if ((e->flags & EDGE_EXECUTABLE)
+	|| (!allow_back && (e->flags & EDGE_DFS_BACK)))
+      {
+	if (succe)
 	  {
-	    if (succe)
+	    succe = NULL;
+	    break;
+	  }
+	succe = e;
+      }
+  if (succe)
+    {
+      /* Verify the reached block is only reached through succe.
+	 If there is only one edge we can spare us the dominator
+	 check and iterate directly.  */
+      if (EDGE_COUNT (succe->dest->preds) > 1)
+	{
+	  FOR_EACH_EDGE (e, ei, succe->dest->preds)
+	    if (e != succe
+		&& ((e->flags & EDGE_EXECUTABLE)
+		    || (!allow_back && (e->flags & EDGE_DFS_BACK))))
 	      {
 		succe = NULL;
 		break;
 	      }
-	    succe = e;
-	  }
+	}
       if (succe)
 	{
-	  /* Verify the reached block is only reached through succe.
-	     If there is only one edge we can spare us the dominator
-	     check and iterate directly.  */
-	  if (EDGE_COUNT (succe->dest->preds) > 1)
-	    {
-	      FOR_EACH_EDGE (e, ei, succe->dest->preds)
-		if (e != succe
-		    && ((e->flags & EDGE_EXECUTABLE)
-			|| (!allow_back && (e->flags & EDGE_DFS_BACK))))
-		  {
-		    succe = NULL;
-		    break;
-		  }
-	    }
-	  if (succe)
-	    {
-	      bb2 = succe->dest;
+	  bb2 = succe->dest;
 
-	      /* Re-do the dominance check with changed bb2.  */
-	      if (dominated_by_p (CDI_DOMINATORS, bb1, bb2))
-		return true;
-	    }
+	  /* Re-do the dominance check with changed bb2.  */
+	  if (dominated_by_p (CDI_DOMINATORS, bb1, bb2))
+	    return true;
 	}
     }
 

commit 946dc2eb7aeb1f3bf0085975a7325941acfb978f
Author: Richard Biener <rguenther@suse.de>
Date:   Thu May 4 09:41:33 2023 +0200

    tree-optimization/109724 - new testcase
    
    The following adds a testcase for PR109724 which was caused by
    backporting r13-2375-gbe1b42de9c151d and fixed by r11-199-g2b42509f8b7bdf.
    
            PR tree-optimization/109724
            * g++.dg/torture/pr109724.C: New testcase.
    
    (cherry picked from commit ee99aaae4aeecd55f1d945a959652cf07e3b2e9e)

diff --git a/gcc/testsuite/g++.dg/torture/pr109724.C b/gcc/testsuite/g++.dg/torture/pr109724.C
new file mode 100644
index 00000000000..4a88e1519d0
--- /dev/null
+++ b/gcc/testsuite/g++.dg/torture/pr109724.C
@@ -0,0 +1,32 @@
+// { dg-do compile }
+
+double &SkTMax(double &a, double &b) { return a ?: b; }
+struct SkDPoint {
+  double fX;
+};
+struct SkDCubic {
+  SkDPoint &operator[](int n) { return fPts[n]; }
+  SkDPoint fPts[4];
+};
+struct SkDCurve {
+  SkDCubic fCubic;
+  SkDPoint &operator[](int n) { return fCubic[n]; }
+};
+struct SkDCurveSweep {
+  SkDCurve fCurve;
+};
+int endsIntersect_rPts;
+double endsIntersect_maxX;
+struct SkOpAngle {
+  void endsIntersect();
+  SkDCurveSweep fPart;
+} endsIntersect_rh;
+void SkOpAngle::endsIntersect() {
+  for (int index = 0;; ++index) {
+    SkDCurve &curve = index ? endsIntersect_rh.fPart.fCurve : fPart.fCurve;
+    for (int idx2 = 0; endsIntersect_rPts; ++idx2) {
+      SkDPoint &__trans_tmp_1 = curve[idx2];
+      endsIntersect_maxX = SkTMax(endsIntersect_maxX, __trans_tmp_1.fX);
+    }
+  }
+}

commit 6dac5d60fabebda09ba3e3dddcf3267bf21e2ba1
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Fri May 5 00:18:26 2023 +0000

    Daily bump.

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 33ac88accd0..c7cf1827737 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,12 @@
+2023-05-04  Richard Biener  <rguenther@suse.de>
+
+	Revert:
+	2023-02-07  Richard Biener  <rguenther@suse.de>
+
+	PR tree-optimization/106809
+	* tree-ssa-sccvn.c (dominaged_by_p_w_unex): Check we have
+	more than one successor before doing extra work.
+
 2023-05-03  Anthony Sharp  <anthonysharp15@gmail.com>
 
 	Backported from master:
diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 2e0cd4ba7e1..fcb6f128085 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230504
+20230505
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index df4a53ebf05..34d0f8d74ec 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,19 @@
+2023-05-04  Richard Biener  <rguenther@suse.de>
+
+	Backported from master:
+	2023-05-04  Richard Biener  <rguenther@suse.de>
+
+	PR tree-optimization/109724
+	* g++.dg/torture/pr109724.C: New testcase.
+
+2023-05-04  Richard Biener  <rguenther@suse.de>
+
+	Revert:
+	2023-05-04  Richard Biener  <rguenther@suse.de>
+
+	PR tree-optimization/106809
+	* gcc.dg/torture/pr106809.c: New testcase.
+
 2023-05-03  Jakub Jelinek  <jakub@redhat.com>
 
 	Backported from master:

commit 96ac48b058422071510ececdc5d129d008bfb7d7
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sat May 6 00:18:00 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index fcb6f128085..9d05bc7fa40 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230505
+20230506

commit 517b779453a07bf070d5c16dd1676c72bbfe8728
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sun May 7 00:18:36 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 9d05bc7fa40..f84acaf5db4 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230506
+20230507

commit bec0425c4a230077f7707c726d7f4bf0db534930
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Mon May 8 00:18:48 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index f84acaf5db4..e50dc5212d2 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230507
+20230508

commit 482693576a7b380d675889bad74de74ee3bf966a
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Tue May 9 00:18:11 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index e50dc5212d2..d3869af5806 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230508
+20230509

commit f06a5c09287ad4606872403c6f8b01d1fe2f5540
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Tue May 9 12:10:07 2023 +0200

    tree-ssa-ccp, wide-int: Fix up handling of [LR]ROTATE_EXPR in bitwise ccp [PR109778]
    
    The following testcase is miscompiled, because bitwise ccp2 handles
    a rotate with a signed type incorrectly.
    Seems tree-ssa-ccp.cc has the only callers of wi::[lr]rotate with 3
    arguments, all other callers just rotate in the right precision and
    I think work correctly.  ccp works with widest_ints and so rotations
    by the excessive precision certainly don't match what it wants
    when it sees a rotate in some specific bitsize.  Still, if it is
    unsigned rotate and the widest_int is zero extended from width,
    the functions perform left shift and logical right shift on the value
    and then at the end zero extend the result of left shift and uselessly
    also the result of logical right shift and return | of that.
    On the testcase we the signed char rrotate by 4 argument is
    CONSTANT -75 i.e. 0xffffffff....fffffb5 with mask 2.
    The mask is correctly rotated to 0x20, but because the 8-bit constant
    is sign extended to 192-bit one, the logical right shift by 4 doesn't
    yield expected 0xb, but gives 0xfffffffffff....ffffb, and then
    return wi::zext (left, width) | wi::zext (right, width); where left is
    0xfffffff....fb50, so we return 0xfb instead of the expected
    0x5b.
    
    The following patch fixes that by doing the zero extension in case of
    the right variable before doing wi::lrshift rather than after it.
    
    Also, wi::[lr]rotate widht width < precision always zero extends
    the result.  I'm afraid it can't do better because it doesn't know
    if it is done for an unsigned or signed type, but the caller in this
    case knows that very well, so I've done the extension based on sgn
    in the caller.  E.g. 0x5b rotated right (or left) by 4 with width 8
    previously gave 0xb5, but sgn == SIGNED in widest_int it should be
    0xffffffff....fffb5 instead.
    
    2023-05-09  Jakub Jelinek  <jakub@redhat.com>
    
            PR tree-optimization/109778
            * wide-int.h (wi::lrotate, wi::rrotate): Call wi::lrshift on
            wi::zext (x, width) rather than x if width != precision, rather
            than using wi::zext (right, width) after the shift.
            * tree-ssa-ccp.c (bit_value_binop): Call wi::ext on the results
            of wi::lrotate or wi::rrotate.
    
            * gcc.c-torture/execute/pr109778.c: New test.
    
    (cherry picked from commit a8302d2a4669984c7c287d12ef5b37cde6699c80)

diff --git a/gcc/testsuite/gcc.c-torture/execute/pr109778.c b/gcc/testsuite/gcc.c-torture/execute/pr109778.c
new file mode 100644
index 00000000000..309fbf413e0
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/execute/pr109778.c
@@ -0,0 +1,26 @@
+/* PR tree-optimization/109778 */
+
+int a, b, c, d, *e = &c;
+
+static inline unsigned
+foo (unsigned char x)
+{
+  x = 1 | x << 1;
+  x = x >> 4 | x << 4;
+  return x;
+}
+
+static inline void
+bar (unsigned x)
+{
+  *e = 8 > foo (x + 86) - 86;
+}
+
+int
+main ()
+{
+  d = a && b;
+  bar (d + 4);
+  if (c != 1)
+    __builtin_abort ();
+}
diff --git a/gcc/tree-ssa-ccp.c b/gcc/tree-ssa-ccp.c
index 952fd9cd4bd..37619dfdafa 100644
--- a/gcc/tree-ssa-ccp.c
+++ b/gcc/tree-ssa-ccp.c
@@ -1412,6 +1412,8 @@ bit_value_binop (enum tree_code code, signop sgn, int width,
 		  *mask = wi::lrotate (r1mask, shift, width);
 		  *val = wi::lrotate (r1val, shift, width);
 		}
+	      *mask = wi::ext (*mask, width, sgn);
+	      *val = wi::ext (*val, width, sgn);
 	    }
 	}
       break;
diff --git a/gcc/wide-int.h b/gcc/wide-int.h
index bb0d16b99b1..e529a3157a8 100644
--- a/gcc/wide-int.h
+++ b/gcc/wide-int.h
@@ -3167,9 +3167,11 @@ wi::lrotate (const T1 &x, const T2 &y, unsigned int width)
     width = precision;
   WI_UNARY_RESULT (T2) ymod = umod_trunc (y, width);
   WI_UNARY_RESULT (T1) left = wi::lshift (x, ymod);
-  WI_UNARY_RESULT (T1) right = wi::lrshift (x, wi::sub (width, ymod));
+  WI_UNARY_RESULT (T1) right
+    = wi::lrshift (width != precision ? wi::zext (x, width) : x,
+		   wi::sub (width, ymod));
   if (width != precision)
-    return wi::zext (left, width) | wi::zext (right, width);
+    return wi::zext (left, width) | right;
   return left | right;
 }
 
@@ -3184,10 +3186,11 @@ wi::rrotate (const T1 &x, const T2 &y, unsigned int width)
   if (width == 0)
     width = precision;
   WI_UNARY_RESULT (T2) ymod = umod_trunc (y, width);
-  WI_UNARY_RESULT (T1) right = wi::lrshift (x, ymod);
+  WI_UNARY_RESULT (T1) right
+    = wi::lrshift (width != precision ? wi::zext (x, width) : x, ymod);
   WI_UNARY_RESULT (T1) left = wi::lshift (x, wi::sub (width, ymod));
   if (width != precision)
-    return wi::zext (left, width) | wi::zext (right, width);
+    return wi::zext (left, width) | right;
   return left | right;
 }
 

commit d68d989286340c20bc0f713addf44dc0f0d77ac3
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Tue May 9 12:14:18 2023 +0200

    testsuite: Add further testcase for already fixed PR [PR109778]
    
    I came up with a testcase which reproduces all the way to r10-7469.
    LTO to avoid early inlining it, so that ccp handles rotates and not
    shifts before they are turned into rotates.
    
    2023-05-09  Jakub Jelinek  <jakub@redhat.com>
    
            PR tree-optimization/109778
            * gcc.dg/lto/pr109778_0.c: New test.
            * gcc.dg/lto/pr109778_1.c: New file.
    
    (cherry picked from commit c2cf2dc988eb93551fa1c01d3f8d73ef21f39dc5)

diff --git a/gcc/testsuite/gcc.dg/lto/pr109778_0.c b/gcc/testsuite/gcc.dg/lto/pr109778_0.c
new file mode 100644
index 00000000000..3c6e1b8f7b7
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/pr109778_0.c
@@ -0,0 +1,22 @@
+/* PR tree-optimization/109778 */
+/* { dg-lto-do run } */
+/* { dg-lto-options { "-O2 -flto" } } */
+/* { dg-require-effective-target int32 } */
+
+int bar (int);
+
+__attribute__((noipa)) int
+foo (int x)
+{
+  x = bar (x);
+  x = (x << 16) | (int) ((unsigned) x >> 16);
+  return x & 0x10000000;
+}
+
+int
+main ()
+{
+  if (foo (0) || foo (-1))
+    __builtin_abort ();
+  return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/lto/pr109778_1.c b/gcc/testsuite/gcc.dg/lto/pr109778_1.c
new file mode 100644
index 00000000000..d18a7209983
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/pr109778_1.c
@@ -0,0 +1,7 @@
+int
+bar (int x)
+{
+  x &= 0x22222222;
+  x |= (int) 0xf1234567U;
+  return x;
+}

commit d2ddb2b9ad2b601a0e1929cefcdf21f81f7c99f2
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Wed May 10 00:19:30 2023 +0000

    Daily bump.

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index c7cf1827737..55a23b47eeb 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,15 @@
+2023-05-09  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2023-05-09  Jakub Jelinek  <jakub@redhat.com>
+
+	PR tree-optimization/109778
+	* wide-int.h (wi::lrotate, wi::rrotate): Call wi::lrshift on
+	wi::zext (x, width) rather than x if width != precision, rather
+	than using wi::zext (right, width) after the shift.
+	* tree-ssa-ccp.c (bit_value_binop): Call wi::ext on the results
+	of wi::lrotate or wi::rrotate.
+
 2023-05-04  Richard Biener  <rguenther@suse.de>
 
 	Revert:
diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index d3869af5806..c5a9ee88f24 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230509
+20230510
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 34d0f8d74ec..22d8bc74181 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,20 @@
+2023-05-09  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2023-05-09  Jakub Jelinek  <jakub@redhat.com>
+
+	PR tree-optimization/109778
+	* gcc.dg/lto/pr109778_0.c: New test.
+	* gcc.dg/lto/pr109778_1.c: New file.
+
+2023-05-09  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2023-05-09  Jakub Jelinek  <jakub@redhat.com>
+
+	PR tree-optimization/109778
+	* gcc.c-torture/execute/pr109778.c: New test.
+
 2023-05-04  Richard Biener  <rguenther@suse.de>
 
 	Backported from master:

commit 8f28e4971aab04370e51f964fc77e55eeafc0195
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Thu May 11 00:18:07 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index c5a9ee88f24..4744698a31c 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230510
+20230511

commit 107dcca4e232fbda2443c0c84dbc83709e2034b3
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Fri May 12 00:20:04 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 4744698a31c..d44f41a9779 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230511
+20230512

commit 1a9acf5a4614f6b3adfd8f4a439074c2421dab85
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sat May 13 00:18:37 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index d44f41a9779..9e964bcb0cd 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230512
+20230513

commit 432f532ed37662840093a00ff109ce027345c4bf
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sun May 14 00:18:17 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 9e964bcb0cd..1d22f342aef 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230513
+20230514

commit 6349a1a1f66924f515c51ebf394960144be698ad
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Mon May 15 00:19:04 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 1d22f342aef..0bf2258d634 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230514
+20230515

commit e58f6d903d35d7cec064a1e30fa2445bb839bccc
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Tue May 16 00:19:08 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 0bf2258d634..ae488c0e7fc 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230515
+20230516

commit 7e273bdadbf78803f4f3e408476bea843a0d67e7
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Wed May 17 00:18:39 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index ae488c0e7fc..e2f60e4d429 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230516
+20230517

commit b636af12e76f9181dc3c932e67fb857c82e39f3b
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Thu May 18 00:18:13 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index e2f60e4d429..460c1ea9af3 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230517
+20230518

commit 3bf2ffa74fa9b36e25761c79c63e2c4b80156aa7
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Fri May 19 00:19:17 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 460c1ea9af3..69b7e9e68cc 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230518
+20230519

commit 9760310efb4c08278f0affcf7953a8a2fd3712f4
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sat May 20 00:18:17 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 69b7e9e68cc..3113e73604c 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230519
+20230520

commit f625d13d2d7769db0913f505b9c545da96462203
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sun May 21 00:18:18 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 3113e73604c..7b10b7bde80 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230520
+20230521

commit 9473ba97f087a080b41e2c5e29a695aa295a6b31
Author: Iain Sandoe <iain@sandoe.co.uk>
Date:   Mon Dec 20 15:19:50 2021 +0000

    Darwin: Update rules for handling alignment of globals.
    
    The current rule was too strict and has not been required since Darwin11.
    
    This relaxes the constraint to allow up to 2^28 alignment for non-common
    entities.  Common is still restricted to a maximum aligment of 2^15.
    
    When the host is an older version of Darwin ( earlier that 11 ) then the
    existing constraint is still applied.  Note that this is a host constraint
    not a target one (so that a compilation on 10.7 targeting 10.6 is allowed
    to use a greater alignment than the tools on 10.6 support).  This matches
    the behaviour of clang.
    
    Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
    
    gcc/ChangeLog:
    
            * config.gcc: Emit L2_MAX_OFILE_ALIGNMENT with suitable
            values for the host.
            * config/darwin.c (darwin_emit_common): Error for alignment
            values > 32768.
            * config/darwin.h (MAX_OFILE_ALIGNMENT): Rework to use the
            configured L2_MAX_OFILE_ALIGNMENT.
    
    gcc/testsuite/ChangeLog:
    
            * gcc.dg/darwin-aligned-globals.c: New test.
            * gcc.dg/darwin-comm-1.c: New test.
            * gcc.dg/attr-aligned.c: Amend for new alignment values on
            Darwin.
            * gcc.target/i386/pr89261.c: Likewise.
    
    (cherry picked from commit 19bf83a9a068f2d5293b63c9300f99172b2d278d)

diff --git a/gcc/config.gcc b/gcc/config.gcc
index 7fc88087c15..77bcd145eaf 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -686,6 +686,20 @@ case ${target} in
     macos_min=0
   fi
   def_ld64=85.2
+  # Tools hosted on earlier versions of Darwin constrained all object
+  # alignment to be 2^15 or smaller.  From Darwin11 (macOS 10.7) the
+  # alignment of non-common is allowed to be up to 2^28.  Note that the
+  # larger alignment is permitted when targeting 10.6 from 10.7 so that
+  # the constraint only need be applied per host (and only if the host
+  # is Darwin).
+  case ${host} in
+      *-*-darwin[4-9]* | *-*-darwin10*)
+          tm_defines="$tm_defines L2_MAX_OFILE_ALIGNMENT=15U"
+          ;;
+      *)
+          tm_defines="$tm_defines L2_MAX_OFILE_ALIGNMENT=28U"
+          ;;
+  esac
   case ${target} in
       # Darwin 4 to 19 correspond to macOS 10.0 to 10.15
       *-*-darwin[4-9]* | *-*-darwin1[0-9]*)
diff --git a/gcc/config/darwin.c b/gcc/config/darwin.c
index 20d89a18443..966c20b746a 100644
--- a/gcc/config/darwin.c
+++ b/gcc/config/darwin.c
@@ -2553,7 +2553,6 @@ darwin_emit_common (FILE *fp, const char *name,
     rounded = (size + (align-1)) & ~(align-1);
 
   l2align = floor_log2 (align);
-  gcc_assert (l2align <= L2_MAX_OFILE_ALIGNMENT);
 
   in_section = comm_section;
   /* We mustn't allow multiple public symbols to share an address when using
@@ -2704,6 +2703,10 @@ darwin_asm_output_aligned_decl_common (FILE *fp, tree decl, const char *name,
 #ifdef DEBUG_DARWIN_MEM_ALLOCATORS
 fprintf (fp, "# adcom: %s (%d,%d) decl=0x0\n", name, (int)size, (int)align);
 #endif
+     /* Common variables are limited to a maximum alignment of 2^15.  */
+      if (align > 32768)
+	error_at (UNKNOWN_LOCATION, "common variables must have an alignment"
+		  " of 32678 or less");
       darwin_emit_common (fp, name, size, align);
       return;
     }
@@ -2731,7 +2734,7 @@ fprintf (fp, "# adcom: %s (%lld,%d) ro %d cst %d stat %d com %d pub %d"
     }
 
   /* We shouldn't be messing with this if the decl has a section name.  */
-  gcc_assert (DECL_SECTION_NAME (decl) == NULL);
+  gcc_checking_assert (DECL_SECTION_NAME (decl) == NULL);
 
   /* We would rather not have to check this here - but it seems that we might
      be passed a decl that should be in coalesced space.  */
@@ -2760,10 +2763,16 @@ fprintf (fp, "# adcom: %s (%lld,%d) ro %d cst %d stat %d com %d pub %d"
 
   l2align = floor_log2 (align / BITS_PER_UNIT);
   /* Check we aren't asking for more aligment than the platform allows.  */
-  gcc_assert (l2align <= L2_MAX_OFILE_ALIGNMENT);
+  gcc_checking_assert (l2align <= L2_MAX_OFILE_ALIGNMENT);
 
   if (TREE_PUBLIC (decl) != 0)
-    darwin_emit_common (fp, name, size, align);
+    {
+      /* Common variables are limited to a maximum alignment of 2^15.  */
+      if (l2align > 15)
+	error_at (DECL_SOURCE_LOCATION (decl), "common variables must have"
+		  " an alignment of 32678 or less");
+      darwin_emit_common (fp, name, size, align);
+    }
   else
     darwin_emit_local_bss (fp, decl, name, size, l2align);
 }
diff --git a/gcc/config/darwin.h b/gcc/config/darwin.h
index e6b8ee1d91e..5649df2885b 100644
--- a/gcc/config/darwin.h
+++ b/gcc/config/darwin.h
@@ -859,13 +859,12 @@ int darwin_label_is_anonymous_local_objc_name (const char *name);
   if ((LOG) != 0)			\
     fprintf (FILE, "\t%s\t%d\n", ALIGN_ASM_OP, (LOG))
 
-/* The maximum alignment which the object file format can support in
-   bits.  For Mach-O, this is 2^15 bytes.  */
+/* The maximum alignment which the object file format can support in bits
+   which depends on the OS version and whether the object is a common
+   variable.  */
 
 #undef	MAX_OFILE_ALIGNMENT
-#define MAX_OFILE_ALIGNMENT (0x8000 * 8)
-
-#define L2_MAX_OFILE_ALIGNMENT 15
+#define MAX_OFILE_ALIGNMENT ((1U << L2_MAX_OFILE_ALIGNMENT) * 8U)
 
 /*  These are the three variants that emit referenced blank space.  */
 #define ASM_OUTPUT_ALIGNED_BSS(FILE, DECL, NAME, SIZE, ALIGN)		\
diff --git a/gcc/testsuite/gcc.dg/attr-aligned.c b/gcc/testsuite/gcc.dg/attr-aligned.c
index ec545639f79..a2e11c96180 100644
--- a/gcc/testsuite/gcc.dg/attr-aligned.c
+++ b/gcc/testsuite/gcc.dg/attr-aligned.c
@@ -12,8 +12,12 @@
 #  define ALIGN_MAX_STATIC      0x1000
    /* Excessive alignment for functions and objects with static storage
       duration that's expected to trigger an error.  */
-#elif __MACH__
-#  define ALIGN_MAX_STATIC      0x8000
+#elif __APPLE__
+# if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1070
+#   define ALIGN_MAX_STATIC      0x8000
+# else
+#   define ALIGN_MAX_STATIC      ALIGN_MAX_HARD
+# endif
 #elif pdp11
 #  define ALIGN_MAX_STATIC      2
 /* Work around a pdp11 ICE (see PR target/87821).  */
diff --git a/gcc/testsuite/gcc.dg/darwin-aligned-globals.c b/gcc/testsuite/gcc.dg/darwin-aligned-globals.c
new file mode 100644
index 00000000000..18b71e7e327
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/darwin-aligned-globals.c
@@ -0,0 +1,24 @@
+/* { dg-do compile { target *-*-darwin* } } */
+/* { dg-additional-options "-fcommon" } */
+
+/* Test alignment rules which differ for earlier hosts (so we must
+   work on the principle that this test will be exercised by self-
+   hosted compilers. */
+
+#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1070
+#define align_OK (1ul << 28)
+#define align_BAD (1ul << 29)
+#else
+#define align_OK (1ul << 15)
+#define align_BAD (1ul << 16)
+#endif
+
+/* All non common vars are allowed larger alignment on modern systems.  */
+static int xn __attribute__ ((aligned (align_OK)));
+static int xi __attribute__ ((aligned (align_OK))) = 5  ;
+int gxi __attribute__ ((aligned (align_OK))) = 6 ;
+
+/* test that we detect bad cases.  */
+static int yn __attribute__ ((aligned (align_BAD))); /* { dg-error {requested alignment .[0-9]+. exceeds object file maximum} } */
+static int yi __attribute__ ((aligned (align_BAD))) = 5;  /* { dg-error {requested alignment .[0-9]+. exceeds object file maximum} } */
+int yni __attribute__ ((aligned (align_BAD))) = 6;  /* { dg-error {requested alignment .[0-9]+. exceeds object file maximum} } */
diff --git a/gcc/testsuite/gcc.dg/darwin-comm-1.c b/gcc/testsuite/gcc.dg/darwin-comm-1.c
new file mode 100644
index 00000000000..46519984fd8
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/darwin-comm-1.c
@@ -0,0 +1,5 @@
+/* { dg-do compile { target *-*-darwin[912]* } } */
+/* { dg-options "-fcommon" } */
+
+/* In all cases, common has a max alignment of 2^15.  */
+int badcommon __attribute__ ((aligned (65536))); /* { dg-error "common variables must have an alignment" } */
diff --git a/gcc/testsuite/gcc.target/i386/pr89261.c b/gcc/testsuite/gcc.target/i386/pr89261.c
index c5c4273439b..b599d49fd48 100644
--- a/gcc/testsuite/gcc.target/i386/pr89261.c
+++ b/gcc/testsuite/gcc.target/i386/pr89261.c
@@ -5,6 +5,7 @@
 typedef double __v2df __attribute__ ((vector_size (16), aligned (1 << 28)));
 
 __v2df foo = { 1.0, 2.0 };
-/* { dg-error {alignment of 'foo' is greater than maximum object file alignment 32768} "" { target *-*-darwin* } .-1 } */
+/* { dg-error {alignment of 'foo' is greater than maximum object file alignment 32768} "" { target { *-*-darwin[89]*  *-*-darwin10* } } .-1 } */
 
 /* { dg-final { scan-assembler "\.align\[ \t]+268435456" { target { ! *-*-darwin* } } } } */
+/* { dg-final { scan-assembler "\.align\[ \t]+28" { target { *-*-darwin1[1-9]* *-*-darwin2* } } } } */

commit 5bd1e853b30e783b8a8bc360d0dc2196af801529
Author: Iain Sandoe <iain@sandoe.co.uk>
Date:   Thu Dec 22 17:32:06 2022 +0000

    libgcc, Darwin: No early install for the compatibility libgcc_s.1.dylib.
    
    On Darwin, GCC now uses a libgcc_s.1.1 for builtins and forwards the system
    unwinder.  We do, however, build a backwards compatibility libgcc_s.1.dylib.
    However, this is not needed by GCC and can cause incorrect operation when
    DYLD_LIBRARY_PATH is in use.
    
    Since we do not need or use it during the build, the solution is to skip the
    installation into the $build/gcc directory.
    
    Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
    
    libgcc/ChangeLog:
    
            * config/t-slibgcc-darwin (install-darwin-libgcc-stubs): Skip the
            install of libgcc_s.1.dylib when the installation is into the build
            gcc directory.
    
    (cherry picked from commit 163f0f2267370575a9950e7e30a2c9cd72f559f0)

diff --git a/libgcc/config/t-slibgcc-darwin b/libgcc/config/t-slibgcc-darwin
index a8f69666a82..cb0cbbdb1c5 100644
--- a/libgcc/config/t-slibgcc-darwin
+++ b/libgcc/config/t-slibgcc-darwin
@@ -72,14 +72,15 @@ all: libgcc_ehs$(SHLIB_EXT)
 LGCC_FILES += libgcc_ehs.$(SHLIB_SOVERSION)$(SHLIB_EXT)
 
 endif
-
-# Provide libgcc_s.1 for backwards compatibility.
-LGCC_FILES += libgcc_s.1.dylib
-
 endif
 
 INSTALL_FILES=$(LGCC_FILES)
 
+ifeq ($(BUILD_LIBGCCS1),YES)
+# Provide libgcc_s.1 for backwards compatibility.
+INSTALL_FILES += libgcc_s.1.dylib
+endif
+
 # For the toplevel multilib, build FAT dylibs including all the multilibs.
 ifeq ($(MULTIBUILDTOP),)
 
@@ -158,9 +159,15 @@ endif
 
 install-darwin-libgcc-stubs :
 	$(mkinstalldirs) $(DESTDIR)$(slibdir)
-	for d in $(INSTALL_FILES) ; do \
-	  $(INSTALL_DATA) $$d $(DESTDIR)$(slibdir)/$$d || exit 1 ; \
-	done
+	if test x$(slibdir) = x; then \
+	  for d in $(LGCC_FILES) ; do \
+	    $(INSTALL_DATA) $$d $(DESTDIR)$(slibdir)/$$d || exit 1 ; \
+	  done; \
+	else \
+	  for d in $(INSTALL_FILES) ; do \
+	    $(INSTALL_DATA) $$d $(DESTDIR)$(slibdir)/$$d || exit 1 ; \
+	  done; \
+	fi
 
 else
 

commit 34608a771216b40307bcbee767605a328265a940
Author: Iain Sandoe <iain@sandoe.co.uk>
Date:   Wed Jan 18 19:58:33 2023 +0000

    Darwin, fixincludes: Handle MacOS13 SDK Apple-specific deprecations [PR107568].
    
    The SDK for MacOS13 includes Apple-specific deprecations of some functions that
    are not deprecated in Posix, C or C++ and widely used in GCC.
    
    The fix makes the deprecation conditional on __APPLE_LOCAL_DEPRECATIONS so that
    end users may still observe them but they are hidden from normal compilations.
    
    Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
    
            PR target/107568
    
    fixincludes/ChangeLog:
    
            * fixincl.x: Regenerate.
            * inclhack.def: Add a fix for MacOS13 SDK function deprecations
            in stdio.h.
            * tests/base/stdio.h (__deprecated_msg): New test.
    
    (cherry picked from commit 442d2bdc1d2a98aba0b18aeaa3e87fa946ac8031)

diff --git a/fixincludes/fixincl.x b/fixincludes/fixincl.x
index b88139950e3..d69c2d11da1 100644
--- a/fixincludes/fixincl.x
+++ b/fixincludes/fixincl.x
@@ -2,11 +2,11 @@
  *
  * DO NOT EDIT THIS FILE   (fixincl.x)
  *
- * It has been AutoGen-ed  January 25, 2020 at 12:15:43 PM by AutoGen 5.18.16
+ * It has been AutoGen-ed  May 19, 2023 at 08:08:20 PM by AutoGen 5.18.7
  * From the definitions    inclhack.def
  * and the template file   fixincl
  */
-/* DO NOT SVN-MERGE THIS FILE, EITHER Sat Jan 25 12:15:43 EST 2020
+/* DO NOT SVN-MERGE THIS FILE, EITHER Fri May 19 20:08:20 BST 2023
  *
  * You must regenerate it.  Use the ./genfixes script.
  *
@@ -15,7 +15,7 @@
  * certain ANSI-incompatible system header files which are fixed to work
  * correctly with ANSI C and placed in a directory that GNU C will search.
  *
- * This file contains 258 fixup descriptions.
+ * This file contains 259 fixup descriptions.
  *
  * See README for more information.
  *
@@ -2524,6 +2524,46 @@ static const char* apzBsd_Stdio_Attrs_ConflictPatch[] = {
 int vfscanf(FILE *, const char *, __builtin_va_list) __asm__ (_BSD_STRING(__USER_LABEL_PREFIX__) \"__svfscanf\");",
     (char*)NULL };
 
+/* * * * * * * * * * * * * * * * * * * * * * * * * *
+ *
+ *  Description of Apple_Local_Stdio_Fn_Deprecation fix
+ */
+tSCC zApple_Local_Stdio_Fn_DeprecationName[] =
+     "apple_local_stdio_fn_deprecation";
+
+/*
+ *  File name selection pattern
+ */
+tSCC zApple_Local_Stdio_Fn_DeprecationList[] =
+  "stdio.h\0";
+/*
+ *  Machine/OS name selection pattern
+ */
+tSCC* apzApple_Local_Stdio_Fn_DeprecationMachs[] = {
+        "*-*-*darwin2*",
+        (const char*)NULL };
+
+/*
+ *  content selection pattern - do fix if pattern found
+ */
+tSCC zApple_Local_Stdio_Fn_DeprecationSelect0[] =
+       "__deprecated_msg([^\n\
+]*)$";
+
+#define    APPLE_LOCAL_STDIO_FN_DEPRECATION_TEST_CT  1
+static tTestDesc aApple_Local_Stdio_Fn_DeprecationTests[] = {
+  { TT_EGREP,    zApple_Local_Stdio_Fn_DeprecationSelect0, (regex_t*)NULL }, };
+
+/*
+ *  Fix Command Arguments for Apple_Local_Stdio_Fn_Deprecation
+ */
+static const char* apzApple_Local_Stdio_Fn_DeprecationPatch[] = {
+    "format",
+    "#if defined(__APPLE_LOCAL_DEPRECATIONS)\n\
+%0\n\
+#endif",
+    (char*)NULL };
+
 /* * * * * * * * * * * * * * * * * * * * * * * * * *
  *
  *  Description of Ctrl_Quotes_Def fix
@@ -10476,9 +10516,9 @@ static const char* apzX11_SprintfPatch[] = {
  *
  *  List of all fixes
  */
-#define REGEX_COUNT          296
+#define REGEX_COUNT          297
 #define MACH_LIST_SIZE_LIMIT 187
-#define FIX_COUNT            258
+#define FIX_COUNT            259
 
 /*
  *  Enumerate the fixes
@@ -10543,6 +10583,7 @@ typedef enum {
     BROKEN_CABS_FIXIDX,
     BROKEN_NAN_FIXIDX,
     BSD_STDIO_ATTRS_CONFLICT_FIXIDX,
+    APPLE_LOCAL_STDIO_FN_DEPRECATION_FIXIDX,
     CTRL_QUOTES_DEF_FIXIDX,
     CTRL_QUOTES_USE_FIXIDX,
     CXX_UNREADY_FIXIDX,
@@ -11040,6 +11081,11 @@ tFixDesc fixDescList[ FIX_COUNT ] = {
      BSD_STDIO_ATTRS_CONFLICT_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE,
      aBsd_Stdio_Attrs_ConflictTests,   apzBsd_Stdio_Attrs_ConflictPatch, 0 },
 
+  {  zApple_Local_Stdio_Fn_DeprecationName,    zApple_Local_Stdio_Fn_DeprecationList,
+     apzApple_Local_Stdio_Fn_DeprecationMachs,
+     APPLE_LOCAL_STDIO_FN_DEPRECATION_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE,
+     aApple_Local_Stdio_Fn_DeprecationTests,   apzApple_Local_Stdio_Fn_DeprecationPatch, 0 },
+
   {  zCtrl_Quotes_DefName,    zCtrl_Quotes_DefList,
      apzCtrl_Quotes_DefMachs,
      CTRL_QUOTES_DEF_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE,
diff --git a/fixincludes/inclhack.def b/fixincludes/inclhack.def
index f58e7771e1c..c6f3a44b0bd 100644
--- a/fixincludes/inclhack.def
+++ b/fixincludes/inclhack.def
@@ -1229,6 +1229,18 @@ fix = {
     test_text = '#define  vfscanf	__svfscanf';
 };
 
+fix = {
+    hackname  = apple_local_stdio_fn_deprecation;
+    mach      = "*-*-*darwin2*";
+    files     = stdio.h;
+    select    = "__deprecated_msg([^\n]*)$";
+    c_fix     = format;
+    c_fix_arg = "#if defined(__APPLE_LOCAL_DEPRECATIONS)\n"
+                "%0\n"
+                "#endif";
+    test_text = '__deprecated_msg("This function is provided for compat...")';
+};
+
 /*
  *  Fix various macros used to define ioctl numbers.
  *  The traditional syntax was:
diff --git a/fixincludes/tests/base/stdio.h b/fixincludes/tests/base/stdio.h
index 491c75da6e5..38381bacb2d 100644
--- a/fixincludes/tests/base/stdio.h
+++ b/fixincludes/tests/base/stdio.h
@@ -41,6 +41,13 @@ int vfscanf(FILE *, const char *, __builtin_va_list) __asm__ (_BSD_STRING(__USER
 #endif  /* BSD_STDIO_ATTRS_CONFLICT_CHECK */
 
 
+#if defined( APPLE_LOCAL_STDIO_FN_DEPRECATION_CHECK )
+#if defined(__APPLE_LOCAL_DEPRECATIONS)
+__deprecated_msg("This function is provided for compat...")
+#endif
+#endif  /* APPLE_LOCAL_STDIO_FN_DEPRECATION_CHECK */
+
+
 #if defined( HPUX10_STDIO_DECLARATIONS_CHECK )
 #  define _iob __iob
 

commit 0a4550a326e4a299578df92933bcc82084d5b188
Author: Iain Sandoe <iain@sandoe.co.uk>
Date:   Wed Jan 18 23:25:36 2023 +0000

    Darwin, fixincludes: Handle Apple Blocks in objc/runtime.h.
    
    The macOS 13 SDK has unguarded Apple Blocks use in objc/runtime.h which
    causes most of the objective-c tests to fail.
    
    Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
    
    fixincludes/ChangeLog:
    
            * fixincl.x: Regenerate.
            * inclhack.def (darwin_objc_runtime_1): New hack.
            * tests/base/objc/runtime.h: New file.
    
    (cherry picked from commit 046dc9d0d4683bab99d28983d8841ba3c56ef744)

diff --git a/fixincludes/fixincl.x b/fixincludes/fixincl.x
index d69c2d11da1..34290ce26d1 100644
--- a/fixincludes/fixincl.x
+++ b/fixincludes/fixincl.x
@@ -2,11 +2,11 @@
  *
  * DO NOT EDIT THIS FILE   (fixincl.x)
  *
- * It has been AutoGen-ed  May 19, 2023 at 08:08:20 PM by AutoGen 5.18.7
+ * It has been AutoGen-ed  May 19, 2023 at 08:09:14 PM by AutoGen 5.18.7
  * From the definitions    inclhack.def
  * and the template file   fixincl
  */
-/* DO NOT SVN-MERGE THIS FILE, EITHER Fri May 19 20:08:20 BST 2023
+/* DO NOT SVN-MERGE THIS FILE, EITHER Fri May 19 20:09:14 BST 2023
  *
  * You must regenerate it.  Use the ./genfixes script.
  *
@@ -15,7 +15,7 @@
  * certain ANSI-incompatible system header files which are fixed to work
  * correctly with ANSI C and placed in a directory that GNU C will search.
  *
- * This file contains 259 fixup descriptions.
+ * This file contains 260 fixup descriptions.
  *
  * See README for more information.
  *
@@ -3000,6 +3000,53 @@ static const char* apzDarwin_Os_Trace_2Patch[] = {
 #endif",
     (char*)NULL };
 
+/* * * * * * * * * * * * * * * * * * * * * * * * * *
+ *
+ *  Description of Darwin_Objc_Runtime_1 fix
+ */
+tSCC zDarwin_Objc_Runtime_1Name[] =
+     "darwin_objc_runtime_1";
+
+/*
+ *  File name selection pattern
+ */
+tSCC zDarwin_Objc_Runtime_1List[] =
+  "objc/runtime.h\0";
+/*
+ *  Machine/OS name selection pattern
+ */
+tSCC* apzDarwin_Objc_Runtime_1Machs[] = {
+        "*-*-darwin2*",
+        (const char*)NULL };
+
+/*
+ *  content selection pattern - do fix if pattern found
+ */
+tSCC zDarwin_Objc_Runtime_1Select0[] =
+       "OBJC_EXPORT void.*\n\
+objc_enumerateClasses.*\n\
+.*\n\
+.*\n\
+.*\n\
+.*void \\(\\^ _Nonnull block.*\n\
+.*\n\
+.*\n\
+.*OBJC_REFINED_FOR_SWIFT.*";
+
+#define    DARWIN_OBJC_RUNTIME_1_TEST_CT  1
+static tTestDesc aDarwin_Objc_Runtime_1Tests[] = {
+  { TT_EGREP,    zDarwin_Objc_Runtime_1Select0, (regex_t*)NULL }, };
+
+/*
+ *  Fix Command Arguments for Darwin_Objc_Runtime_1
+ */
+static const char* apzDarwin_Objc_Runtime_1Patch[] = {
+    "format",
+    "#if __BLOCKS__\n\
+%0\n\
+#endif",
+    (char*)NULL };
+
 /* * * * * * * * * * * * * * * * * * * * * * * * * *
  *
  *  Description of Darwin_Os_Trace_3 fix
@@ -10516,9 +10563,9 @@ static const char* apzX11_SprintfPatch[] = {
  *
  *  List of all fixes
  */
-#define REGEX_COUNT          297
+#define REGEX_COUNT          298
 #define MACH_LIST_SIZE_LIMIT 187
-#define FIX_COUNT            259
+#define FIX_COUNT            260
 
 /*
  *  Enumerate the fixes
@@ -10595,6 +10642,7 @@ typedef enum {
     DARWIN_LONGJMP_NORETURN_FIXIDX,
     DARWIN_OS_TRACE_1_FIXIDX,
     DARWIN_OS_TRACE_2_FIXIDX,
+    DARWIN_OBJC_RUNTIME_1_FIXIDX,
     DARWIN_OS_TRACE_3_FIXIDX,
     DARWIN_OS_BASE_1_FIXIDX,
     DARWIN_DISPATCH_OBJECT_1_FIXIDX,
@@ -11141,6 +11189,11 @@ tFixDesc fixDescList[ FIX_COUNT ] = {
      DARWIN_OS_TRACE_2_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE,
      aDarwin_Os_Trace_2Tests,   apzDarwin_Os_Trace_2Patch, 0 },
 
+  {  zDarwin_Objc_Runtime_1Name,    zDarwin_Objc_Runtime_1List,
+     apzDarwin_Objc_Runtime_1Machs,
+     DARWIN_OBJC_RUNTIME_1_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE,
+     aDarwin_Objc_Runtime_1Tests,   apzDarwin_Objc_Runtime_1Patch, 0 },
+
   {  zDarwin_Os_Trace_3Name,    zDarwin_Os_Trace_3List,
      apzDarwin_Os_Trace_3Machs,
      DARWIN_OS_TRACE_3_TEST_CT, FD_MACH_ONLY | FD_SUBROUTINE,
diff --git a/fixincludes/inclhack.def b/fixincludes/inclhack.def
index c6f3a44b0bd..6a2a1ac10bf 100644
--- a/fixincludes/inclhack.def
+++ b/fixincludes/inclhack.def
@@ -1451,6 +1451,41 @@ fix = {
   test_text = "typedef void (^os_trace_payload_t)(xpc_object_t xdict);";
 };
 
+/*
+ *  macOSX 13.0 SDK objc/runtime.h uses Apple Blocks extension without a guard.
+ */
+
+fix = {
+  hackname  = darwin_objc_runtime_1;
+  mach      = "*-*-darwin2*";
+  files     = objc/runtime.h;
+  select    =   <<- _EOSelect_
+	OBJC_EXPORT void.*
+	objc_enumerateClasses.*
+	.*
+	.*
+	.*
+	.*void \(\^ _Nonnull block.*
+	.*
+	.*
+	.*OBJC_REFINED_FOR_SWIFT.*
+	_EOSelect_;
+  c_fix     = format;
+  c_fix_arg = "#if __BLOCKS__\n%0\n#endif";
+  test_text = <<- _OBJC_RUNTIME_1
+OBJC_EXPORT void
+objc_enumerateClasses(const void * _Nullable image,
+                      const char * _Nullable namePrefix,
+                      Protocol * _Nullable conformingTo,
+                      Class _Nullable subclassing,
+                      void (^ _Nonnull block)(Class _Nonnull aClass, BOOL * _Nonnull stop)
+                      OBJC_NOESCAPE)
+OBJC_AVAILABLE(13.0, 16.0, 16.0, 9.0, 7.0)
+OBJC_REFINED_FOR_SWIFT;
+_OBJC_RUNTIME_1;
+};
+
+
 /*
  *  In Mac OS X 10.1[012] <os/trace.h>, need to guard users of
  *  os_trace_payload_t typedef, too.
diff --git a/fixincludes/tests/base/objc/runtime.h b/fixincludes/tests/base/objc/runtime.h
new file mode 100644
index 00000000000..8b4855bb8ab
--- /dev/null
+++ b/fixincludes/tests/base/objc/runtime.h
@@ -0,0 +1,24 @@
+/*  DO NOT EDIT THIS FILE.
+
+    It has been auto-edited by fixincludes from:
+
+	"fixinc/tests/inc/objc/runtime.h"
+
+    This had to be done to correct non-standard usages in the
+    original, manufacturer supplied header file.  */
+
+
+
+#if defined( DARWIN_OBJC_RUNTIME_1_CHECK )
+#if __BLOCKS__
+OBJC_EXPORT void
+objc_enumerateClasses(const void * _Nullable image,
+                      const char * _Nullable namePrefix,
+                      Protocol * _Nullable conformingTo,
+                      Class _Nullable subclassing,
+                      void (^ _Nonnull block)(Class _Nonnull aClass, BOOL * _Nonnull stop)
+                      OBJC_NOESCAPE)
+OBJC_AVAILABLE(13.0, 16.0, 16.0, 9.0, 7.0)
+OBJC_REFINED_FOR_SWIFT;
+#endif
+#endif  /* DARWIN_OBJC_RUNTIME_1_CHECK */

commit 13cea2625edaeedd965f56986bb8eede70057006
Author: Iain Sandoe <iain@sandoe.co.uk>
Date:   Mon Nov 1 16:58:20 2021 +0000

    Darwin, crts: Fix a build warning.
    
    We have a shim crt for Darwin10 that implements functionality
    missing in libSystem. Provide this with a prototype to silence the
    warning about this.
    
    libgcc/ChangeLog:
    
            * config/darwin10-unwind-find-enc-func.c: Include libgcc_tm.h.
    
    Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
    (cherry picked from commit 7a300b413a62e1989bd89064fd5594aabe371d3a)

diff --git a/libgcc/config/darwin10-unwind-find-enc-func.c b/libgcc/config/darwin10-unwind-find-enc-func.c
index 67c43757e50..882ec3a2372 100644
--- a/libgcc/config/darwin10-unwind-find-enc-func.c
+++ b/libgcc/config/darwin10-unwind-find-enc-func.c
@@ -1,6 +1,7 @@
 #include "tconfig.h"
 #include "tsystem.h"
 #include "unwind-dw2-fde.h"
+#include "libgcc_tm.h"
 
 void *
 _darwin10_Unwind_FindEnclosingFunction (void *pc)

commit c87db1256f14407bb860a6f958b26c0e48992d48
Author: Iain Sandoe <iain@sandoe.co.uk>
Date:   Thu May 11 23:24:02 2023 +0100

    Darwin, libgcc : Adjust min version supported for the OS.
    
    Tools from later versions of the OS deprecate or fail to support
    earlier OS revisions.
    
    Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
    
    libgcc/ChangeLog:
    
            * config.host: Arrange to set min Darwin OS versions from
            the configured host version.
            * config/darwin10-unwind-find-enc-func.c: Do not use current
            headers, but declare the nexessary structures locally to the
            versions in use for Mac OSX 10.6.
            * config/t-darwin: Amend to handle configured min OS
            versions.
            * config/t-darwin-min-1: New.
            * config/t-darwin-min-5: New.
            * config/t-darwin-min-8: New.
    
    (cherry picked from commit 20b8779ea9bd82b26eeb195b30f695168cd7ae1d)

diff --git a/libgcc/config.host b/libgcc/config.host
index 89f41b56000..2b276ce3436 100644
--- a/libgcc/config.host
+++ b/libgcc/config.host
@@ -228,6 +228,24 @@ case ${host} in
       ;;
   esac
   tmake_file="$tmake_file t-slibgcc-darwin"
+  # newer toolsets produce warnings when building for unsupported versions.
+  case ${host} in
+    *-*-darwin1[89]* | *-*-darwin2* )
+      tmake_file="t-darwin-min-8 $tmake_file"
+      ;;
+    *-*-darwin9* | *-*-darwin1[0-7]*)
+      tmake_file="t-darwin-min-5 $tmake_file"
+      ;;
+    *-*-darwin[4-8]*)
+      tmake_file="t-darwin-min-1 $tmake_file"
+      ;;
+    *)
+      # Fall back to configuring for the oldest system known to work with
+      # all archs and the current sources.
+      tmake_file="t-darwin-min-5 $tmake_file"
+      echo "Warning: libgcc configured to support macOS 10.5" 1>&2
+      ;;
+  esac
   extra_parts="crt3.o libd10-uwfef.a crttms.o crttme.o libemutls_w.a"
   ;;
 *-*-dragonfly*)
diff --git a/libgcc/config/darwin10-unwind-find-enc-func.c b/libgcc/config/darwin10-unwind-find-enc-func.c
index 882ec3a2372..b08396c5f1b 100644
--- a/libgcc/config/darwin10-unwind-find-enc-func.c
+++ b/libgcc/config/darwin10-unwind-find-enc-func.c
@@ -1,8 +1,34 @@
-#include "tconfig.h"
-#include "tsystem.h"
-#include "unwind-dw2-fde.h"
 #include "libgcc_tm.h"
 
+/* This shim is special, it needs to be built for Mac OSX 10.6
+   regardless of the current system version.
+   We must also build it to use the unwinder layout that was
+   present for 10.6 (and not update that).
+   So we copy the referenced structures from unwind-dw2-fde.h
+   to avoid pulling in newer system headers and/or changed
+   layouts.  */
+struct dwarf_eh_bases
+{
+  void *tbase;
+  void *dbase;
+  void *func;
+};
+
+typedef          int  sword __attribute__ ((mode (SI)));
+typedef unsigned int  uword __attribute__ ((mode (SI)));
+
+/* The first few fields of an FDE.  */
+struct dwarf_fde
+{
+  uword length;
+  sword CIE_delta;
+  unsigned char pc_begin[];
+} __attribute__ ((packed, aligned (__alignof__ (void *))));
+
+typedef struct dwarf_fde fde;
+
+extern const fde * _Unwind_Find_FDE (void *, struct dwarf_eh_bases *);
+
 void *
 _darwin10_Unwind_FindEnclosingFunction (void *pc)
 {
@@ -10,5 +36,5 @@ _darwin10_Unwind_FindEnclosingFunction (void *pc)
   const struct dwarf_fde *fde = _Unwind_Find_FDE (pc-1, &bases);
   if (fde)
     return bases.func;
-  return NULL;
+  return (void *) 0;
 }
diff --git a/libgcc/config/t-darwin b/libgcc/config/t-darwin
index 299d26c2c96..a3bb70c6a0a 100644
--- a/libgcc/config/t-darwin
+++ b/libgcc/config/t-darwin
@@ -1,15 +1,15 @@
 # Set this as a minimum (unless overriden by arch t-files) since it's a
 # reasonable lowest common denominator that works for all our archs.
-HOST_LIBGCC2_CFLAGS += -mmacosx-version-min=10.4
+HOST_LIBGCC2_CFLAGS += $(DARWIN_MIN_LIB_VERSION)
 
 crt3.o: $(srcdir)/config/darwin-crt3.c
-	$(crt_compile) -mmacosx-version-min=10.4 -c $<
+	$(crt_compile) $(DARWIN_MIN_CRT_VERSION) -c $<
 
 crttms.o: $(srcdir)/config/darwin-crt-tm.c
-	$(crt_compile) -mmacosx-version-min=10.4 -DSTART -c $<
+	$(crt_compile) $(DARWIN_MIN_CRT_VERSION) -DSTART -c $<
 
 crttme.o: $(srcdir)/config/darwin-crt-tm.c
-	$(crt_compile) -mmacosx-version-min=10.4 -DEND -c $<
+	$(crt_compile) $(DARWIN_MIN_CRT_VERSION) -DEND -c $<
 
 # Make emutls weak so that we can deal with -static-libgcc, override the
 # hidden visibility when this is present in libgcc_eh.
@@ -25,6 +25,8 @@ libemutls_w.a: emutls_s.o
 	$(RANLIB_FOR_TARGET) $@
 
 # Patch to __Unwind_Find_Enclosing_Function for Darwin10.
+# This needs to be built for darwin10, regardless of the current platform
+# version.
 d10-uwfef.o: $(srcdir)/config/darwin10-unwind-find-enc-func.c libgcc_tm.h
 	$(crt_compile) -mmacosx-version-min=10.6 -c $<
 
diff --git a/libgcc/config/t-darwin-min-1 b/libgcc/config/t-darwin-min-1
new file mode 100644
index 00000000000..8c2cf8acd39
--- /dev/null
+++ b/libgcc/config/t-darwin-min-1
@@ -0,0 +1,3 @@
+# Support building with -mmacosx-version-min back to 10.1.
+DARWIN_MIN_LIB_VERSION = -mmacosx-version-min=10.4
+DARWIN_MIN_CRT_VERSION = -mmacosx-version-min=10.1
diff --git a/libgcc/config/t-darwin-min-5 b/libgcc/config/t-darwin-min-5
new file mode 100644
index 00000000000..138193151e7
--- /dev/null
+++ b/libgcc/config/t-darwin-min-5
@@ -0,0 +1,3 @@
+# Support building with -mmacosx-version-min back to 10.5.
+DARWIN_MIN_LIB_VERSION = -mmacosx-version-min=10.5
+DARWIN_MIN_CRT_VERSION = -mmacosx-version-min=10.5
diff --git a/libgcc/config/t-darwin-min-8 b/libgcc/config/t-darwin-min-8
new file mode 100644
index 00000000000..9efc9dc0257
--- /dev/null
+++ b/libgcc/config/t-darwin-min-8
@@ -0,0 +1,3 @@
+# Support building with -mmacosx-version-min back to 10.8.
+DARWIN_MIN_LIB_VERSION = -mmacosx-version-min=10.8
+DARWIN_MIN_CRT_VERSION = -mmacosx-version-min=10.8

commit 9202c49e1b50db147769c08359acbef588d521a3
Author: Iain Sandoe <iain@sandoe.co.uk>
Date:   Mon Apr 17 10:23:16 2023 +0100

    libsanitizer, darwin: Unsupport Darwin >= 22 for now.
    
    The mechanism for location dyld has altered from Darwin22 since dyld is now
    in the shared cache.  The implemented mechanism for walking the cache uses
    Apple Blocks which GCC does not yet support, and the fallback to the original
    mechanism does not work there.
    
    Until a suitable work-around can be found, unsupport Darwin22+.
    
            Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
    
    libsanitizer/ChangeLog:
    
            * configure.tgt: Unsupport Darwin22+ until a mechanism can be found
            to locate dyld in the shared cache.
    
    (cherry picked from commit e722a1f42b28092c9f709a3f758fc4fe57db32b0)

diff --git a/libsanitizer/configure.tgt b/libsanitizer/configure.tgt
index fa30065b595..ef446011912 100644
--- a/libsanitizer/configure.tgt
+++ b/libsanitizer/configure.tgt
@@ -60,7 +60,7 @@ case "${target}" in
 		TSAN_TARGET_DEPENDENT_OBJECTS=tsan_rtl_aarch64.lo
 	fi
 	;;
-  x86_64-*-darwin2* | x86_64-*-darwin1[2-9]* | i?86-*-darwin1[2-9]*)
+  x86_64-*-darwin2[01]* | x86_64-*-darwin1[2-9]* | i?86-*-darwin1[2-9]*)
 	TSAN_SUPPORTED=no
 	EXTRA_CXXFLAGS+="-Wl,-undefined,dynamic_lookup"
 	;;

commit a905ee4924cdd0a70a1029afce07b860f0bc6d8b
Author: Iain Sandoe <iain@sandoe.co.uk>
Date:   Sun May 21 10:45:25 2023 +0100

    libstdc++: Rename __null_terminated to avoid a collision with system headers.
    
    r13-1073-g254e88b3d7e8ab made this change for experimental/bits/fs-path.h.
    The change is needed on the 10.x branch for bits/fs-path.h (it is not required
    on later branches since this header was reworked).
    
    Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
    
    libstdc++-v3/ChangeLog:
    
            * include/bits/fs_path.h: Rename __null_terminated to __nul_terminated
            to avoid colliding with a macro in Darwin system headers.

diff --git a/libstdc++-v3/include/bits/fs_path.h b/libstdc++-v3/include/bits/fs_path.h
index 9f0f2bf5d2d..9c7838ef9df 100644
--- a/libstdc++-v3/include/bits/fs_path.h
+++ b/libstdc++-v3/include/bits/fs_path.h
@@ -130,10 +130,10 @@ namespace __detail
     _Source
     _S_range_begin(_Source __begin) { return __begin; }
 
-  struct __null_terminated { };
+  struct __nul_terminated { };
 
   template<typename _Source>
-    __null_terminated
+    __nul_terminated
     _S_range_end(_Source) { return {}; }
 
   template<typename _CharT, typename _Traits, typename _Alloc>
@@ -528,11 +528,11 @@ namespace __detail
       struct _Cvt;
 
     static basic_string_view<value_type>
-    _S_convert(value_type* __src, __detail::__null_terminated)
+    _S_convert(value_type* __src, __detail::__nul_terminated)
     { return __src; }
 
     static basic_string_view<value_type>
-    _S_convert(const value_type* __src, __detail::__null_terminated)
+    _S_convert(const value_type* __src, __detail::__nul_terminated)
     { return __src; }
 
     static basic_string_view<value_type>
@@ -554,7 +554,7 @@ namespace __detail
 
     template<typename _InputIterator>
       static string_type
-      _S_convert(_InputIterator __src, __detail::__null_terminated)
+      _S_convert(_InputIterator __src, __detail::__nul_terminated)
       {
 	// Read from iterator into basic_string until a null value is seen:
 	auto __s = _S_string_from_iter(__src);
@@ -576,7 +576,7 @@ namespace __detail
 
     template<typename _InputIterator>
       static string_type
-      _S_convert_loc(_InputIterator __src, __detail::__null_terminated,
+      _S_convert_loc(_InputIterator __src, __detail::__nul_terminated,
 		     const std::locale& __loc)
       {
 	const std::string __s = _S_string_from_iter(__src);

commit 79a7d8fa0000b389405c935fa5943d28c48baec2
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Mon May 22 00:18:45 2023 +0000

    Daily bump.

diff --git a/fixincludes/ChangeLog b/fixincludes/ChangeLog
index a36b6b7c192..8cad739247e 100644
--- a/fixincludes/ChangeLog
+++ b/fixincludes/ChangeLog
@@ -1,3 +1,23 @@
+2023-05-21  Iain Sandoe  <iain@sandoe.co.uk>
+
+	Backported from master:
+	2023-01-21  Iain Sandoe  <iain@sandoe.co.uk>
+
+	* fixincl.x: Regenerate.
+	* inclhack.def (darwin_objc_runtime_1): New hack.
+	* tests/base/objc/runtime.h: New file.
+
+2023-05-21  Iain Sandoe  <iain@sandoe.co.uk>
+
+	Backported from master:
+	2023-01-21  Iain Sandoe  <iain@sandoe.co.uk>
+
+	PR target/107568
+	* fixincl.x: Regenerate.
+	* inclhack.def: Add a fix for MacOS13 SDK function deprecations
+	in stdio.h.
+	* tests/base/stdio.h (__deprecated_msg): New test.
+
 2022-06-28  Release Manager
 
 	* GCC 10.4.0 released.
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 55a23b47eeb..0e8f1aa07c7 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,15 @@
+2023-05-21  Iain Sandoe  <iain@sandoe.co.uk>
+
+	Backported from master:
+	2021-12-24  Iain Sandoe  <iain@sandoe.co.uk>
+
+	* config.gcc: Emit L2_MAX_OFILE_ALIGNMENT with suitable
+	values for the host.
+	* config/darwin.c (darwin_emit_common): Error for alignment
+	values > 32768.
+	* config/darwin.h (MAX_OFILE_ALIGNMENT): Rework to use the
+	configured L2_MAX_OFILE_ALIGNMENT.
+
 2023-05-09  Jakub Jelinek  <jakub@redhat.com>
 
 	Backported from master:
diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 7b10b7bde80..f25bef13f1e 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230521
+20230522
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 22d8bc74181..e1f3d8da7a2 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,14 @@
+2023-05-21  Iain Sandoe  <iain@sandoe.co.uk>
+
+	Backported from master:
+	2021-12-24  Iain Sandoe  <iain@sandoe.co.uk>
+
+	* gcc.dg/darwin-aligned-globals.c: New test.
+	* gcc.dg/darwin-comm-1.c: New test.
+	* gcc.dg/attr-aligned.c: Amend for new alignment values on
+	Darwin.
+	* gcc.target/i386/pr89261.c: Likewise.
+
 2023-05-09  Jakub Jelinek  <jakub@redhat.com>
 
 	Backported from master:
diff --git a/libgcc/ChangeLog b/libgcc/ChangeLog
index 3737ea93681..0ed255bf6d7 100644
--- a/libgcc/ChangeLog
+++ b/libgcc/ChangeLog
@@ -1,3 +1,35 @@
+2023-05-21  Iain Sandoe  <iain@sandoe.co.uk>
+
+	Backported from master:
+	2023-05-19  Iain Sandoe  <iain@sandoe.co.uk>
+
+	* config.host: Arrange to set min Darwin OS versions from
+	the configured host version.
+	* config/darwin10-unwind-find-enc-func.c: Do not use current
+	headers, but declare the nexessary structures locally to the
+	versions in use for Mac OSX 10.6.
+	* config/t-darwin: Amend to handle configured min OS
+	versions.
+	* config/t-darwin-min-1: New.
+	* config/t-darwin-min-5: New.
+	* config/t-darwin-min-8: New.
+
+2023-05-21  Iain Sandoe  <iain@sandoe.co.uk>
+
+	Backported from master:
+	2021-11-05  Iain Sandoe  <iain@sandoe.co.uk>
+
+	* config/darwin10-unwind-find-enc-func.c: Include libgcc_tm.h.
+
+2023-05-21  Iain Sandoe  <iain@sandoe.co.uk>
+
+	Backported from master:
+	2022-12-24  Iain Sandoe  <iain@sandoe.co.uk>
+
+	* config/t-slibgcc-darwin (install-darwin-libgcc-stubs): Skip the
+	install of libgcc_s.1.dylib when the installation is into the build
+	gcc directory.
+
 2023-05-03  Jakub Jelinek  <jakub@redhat.com>
 
 	Backported from master:
diff --git a/libsanitizer/ChangeLog b/libsanitizer/ChangeLog
index 5fede980241..7ec5fc80c91 100644
--- a/libsanitizer/ChangeLog
+++ b/libsanitizer/ChangeLog
@@ -1,3 +1,11 @@
+2023-05-21  Iain Sandoe  <iain@sandoe.co.uk>
+
+	Backported from master:
+	2023-04-18  Iain Sandoe  <iain@sandoe.co.uk>
+
+	* configure.tgt: Unsupport Darwin22+ until a mechanism can be found
+	to locate dyld in the shared cache.
+
 2022-06-28  Release Manager
 
 	* GCC 10.4.0 released.
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index a3cef8f3031..0498257dcd9 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,8 @@
+2023-05-21  Iain Sandoe  <iain@sandoe.co.uk>
+
+	* include/bits/fs_path.h: Rename __null_terminated to __nul_terminated
+	to avoid colliding with a macro in Darwin system headers.
+
 2023-05-03  Jonathan Wakely  <jwakely@redhat.com>
 
 	PR libstdc++/105844

commit c970030226341f0c7fa9f319b37786ca81703c6d
Author: Michael Meissner <meissner@linux.ibm.com>
Date:   Mon May 22 11:26:08 2023 -0400

    Do not generate vmaddfp and vnmsubfp
    
    This is version 3 of the patch.  This is essentially version 1 with the removal
    of changes to altivec.md, and cleanup of the comments.
    
    Version 2 generated the vmaddfp and vnmsubfp instructions if -Ofast was used,
    and those changes are deleted in this patch.
    
    The Altivec instructions vmaddfp and vnmsubfp have different rounding behaviors
    than the VSX xvmaddsp and xvnmsubsp instructions.  In particular, generating
    these instructions seems to break Eigen on big endian systems.
    
    I have done bootstrap builds on power9 little endian (with both IEEE long
    double and IBM long double).  I have also done the builds and test on a power8
    big endian system (testing both 32-bit and 64-bit code generation).  Chip has
    verified that it fixes the problem that Eigen encountered.  Can I check this
    into the master GCC branch?  After a burn-in period, can I check this patch
    into the active GCC branches?
    
    Thanks in advance.
    
    2023-05-22   Michael Meissner  <meissner@linux.ibm.com>
    
    gcc/
    
            PR target/70243
            * config/rs6000/vsx.md (vsx_fmav4sf4): Do not generate vmaddfp.  Back
            port from master 04/10/2023.
            (vsx_nfmsv4sf4): Do not generate vnmsubfp.
    
    gcc/testsuite/
    
            PR target/70243
            * gcc.target/powerpc/pr70243.c: New test.  Back port from master
            04/10/2023.

diff --git a/gcc/config/rs6000/vsx.md b/gcc/config/rs6000/vsx.md
index 2c1416be583..72c848b7e4a 100644
--- a/gcc/config/rs6000/vsx.md
+++ b/gcc/config/rs6000/vsx.md
@@ -1844,22 +1844,20 @@
   "x<VSv>tsqrt<sd>p %0,%x1"
   [(set_attr "type" "<VStype_simple>")])
 
-;; Fused vector multiply/add instructions. Support the classical Altivec
-;; versions of fma, which allows the target to be a separate register from the
-;; 3 inputs.  Under VSX, the target must be either the addend or the first
-;; multiply.
-
+;; Fused vector multiply/add instructions. Do not generate the Altivec versions
+;; of fma (vmaddfp and vnmsubfp).  These instructions allows the target to be a
+;; separate register from the 3 inputs, but they have different rounding
+;; behaviors than the VSX instructions.
 (define_insn "*vsx_fmav4sf4"
-  [(set (match_operand:V4SF 0 "vsx_register_operand" "=wa,wa,v")
+  [(set (match_operand:V4SF 0 "vsx_register_operand" "=wa,wa")
 	(fma:V4SF
-	  (match_operand:V4SF 1 "vsx_register_operand" "%wa,wa,v")
-	  (match_operand:V4SF 2 "vsx_register_operand" "wa,0,v")
-	  (match_operand:V4SF 3 "vsx_register_operand" "0,wa,v")))]
+	  (match_operand:V4SF 1 "vsx_register_operand" "%wa,wa")
+	  (match_operand:V4SF 2 "vsx_register_operand" "wa,0")
+	  (match_operand:V4SF 3 "vsx_register_operand" "0,wa")))]
   "VECTOR_UNIT_VSX_P (V4SFmode)"
   "@
    xvmaddasp %x0,%x1,%x2
-   xvmaddmsp %x0,%x1,%x3
-   vmaddfp %0,%1,%2,%3"
+   xvmaddmsp %x0,%x1,%x3"
   [(set_attr "type" "vecfloat")])
 
 (define_insn "*vsx_fmav2df4"
@@ -1901,18 +1899,17 @@
   [(set_attr "type" "<VStype_mul>")])
 
 (define_insn "*vsx_nfmsv4sf4"
-  [(set (match_operand:V4SF 0 "vsx_register_operand" "=wa,wa,v")
+  [(set (match_operand:V4SF 0 "vsx_register_operand" "=wa,wa")
 	(neg:V4SF
 	 (fma:V4SF
-	   (match_operand:V4SF 1 "vsx_register_operand" "%wa,wa,v")
-	   (match_operand:V4SF 2 "vsx_register_operand" "wa,0,v")
+	   (match_operand:V4SF 1 "vsx_register_operand" "%wa,wa")
+	   (match_operand:V4SF 2 "vsx_register_operand" "wa,0")
 	   (neg:V4SF
-	     (match_operand:V4SF 3 "vsx_register_operand" "0,wa,v")))))]
+	     (match_operand:V4SF 3 "vsx_register_operand" "0,wa")))))]
   "VECTOR_UNIT_VSX_P (V4SFmode)"
   "@
    xvnmsubasp %x0,%x1,%x2
-   xvnmsubmsp %x0,%x1,%x3
-   vnmsubfp %0,%1,%2,%3"
+   xvnmsubmsp %x0,%x1,%x3"
   [(set_attr "type" "vecfloat")])
 
 (define_insn "*vsx_nfmsv2df4"
diff --git a/gcc/testsuite/gcc.target/powerpc/pr70243.c b/gcc/testsuite/gcc.target/powerpc/pr70243.c
new file mode 100644
index 00000000000..18a5ce78792
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/pr70243.c
@@ -0,0 +1,41 @@
+/* { dg-do compile */
+/* { dg-require-effective-target powerpc_vsx_ok } */
+/* { dg-options "-O2 -mvsx" } */
+
+/* PR 70423, Make sure we don't generate vmaddfp or vnmsubfp.  These
+   instructions have different rounding modes than the VSX instructions
+   xvmaddsp and xvnmsubsp.  These tests are written where the 3 inputs and
+   target are all separate registers.  Because vmaddfp and vnmsubfp are no
+   longer generated the compiler will have to generate an xsmaddsp or xsnmsubsp
+   instruction followed by a move operation.  */
+
+#include <altivec.h>
+
+vector float
+do_add1 (vector float dummy, vector float a, vector float b, vector float c)
+{
+  return (a * b) + c;
+}
+
+vector float
+do_nsub1 (vector float dummy, vector float a, vector float b, vector float c)
+{
+  return -((a * b) - c);
+}
+
+vector float
+do_add2 (vector float dummy, vector float a, vector float b, vector float c)
+{
+  return vec_madd (a, b, c);
+}
+
+vector float
+do_nsub2 (vector float dummy, vector float a, vector float b, vector float c)
+{
+  return vec_nmsub (a, b, c);
+}
+
+/* { dg-final { scan-assembler     {\mxvmadd[am]sp\M}  } } */
+/* { dg-final { scan-assembler     {\mxvnmsub[am]sp\M} } } */
+/* { dg-final { scan-assembler-not {\mvmaddfp\M}       } } */
+/* { dg-final { scan-assembler-not {\mvnmsubfp\M}      } } */

commit 945685be924fc896fb90e6380faad26662e1c327
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Tue May 23 00:18:12 2023 +0000

    Daily bump.

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 0e8f1aa07c7..02d04d6d087 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,10 @@
+2023-05-22   Michael Meissner  <meissner@linux.ibm.com>
+
+	PR target/70243
+	* config/rs6000/vsx.md (vsx_fmav4sf4): Do not generate vmaddfp.  Back
+	port from master 04/10/2023.
+	(vsx_nfmsv4sf4): Do not generate vnmsubfp.
+
 2023-05-21  Iain Sandoe  <iain@sandoe.co.uk>
 
 	Backported from master:
diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index f25bef13f1e..b7d9ba7ed1a 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230522
+20230523
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index e1f3d8da7a2..5f48b96f01a 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2023-05-22   Michael Meissner  <meissner@linux.ibm.com>
+
+	PR target/70243
+	* gcc.target/powerpc/pr70243.c: New test.  Back port from master
+	04/10/2023.
+
 2023-05-21  Iain Sandoe  <iain@sandoe.co.uk>
 
 	Backported from master:

commit 40b2f2a62ce65c425df904b2307803b5ea203991
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Wed May 24 00:19:12 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index b7d9ba7ed1a..5b2cd0ee4d1 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230523
+20230524

commit 428a691458decb7a9215533c7ce1a39f0d71078d
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Thu May 25 00:18:35 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 5b2cd0ee4d1..37d8ec9db79 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230524
+20230525

commit 61b4ec2e9b1953fb3b62990640a3c8d6b52be0be
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Fri May 26 00:18:23 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 37d8ec9db79..1ecb4a83fea 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230525
+20230526

commit 6a3c32c266d11d1d39ea4015ebdb20c85a1b80b8
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sat May 27 00:17:51 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 1ecb4a83fea..f2e1a8687bc 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230526
+20230527

commit 8872ab88c1126e56f1049e8f623142f20ad075b7
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sun May 28 00:17:54 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index f2e1a8687bc..4f495f3bb8a 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230527
+20230528

commit 4732273b833818dd1f0756d09a81ace5eccedd58
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Mon May 29 11:16:15 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 4f495f3bb8a..5f5439b6a42 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230528
+20230529

commit 0139bf20dfa1ce8bc6f23122072347718325c999
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Tue May 30 00:17:56 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 5f5439b6a42..9de50cecbd7 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230529
+20230530

commit a659b9915cdf6472992a1c2a572c4680c71f9d68
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Wed May 31 00:18:39 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 9de50cecbd7..748e702e080 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230530
+20230531

commit 0304b121c687d897e0a79259e4dc477f733ecc22
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Thu Jun 1 00:18:28 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 748e702e080..e171f9ed053 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230531
+20230601

commit bdd038cc1782b550b434a806ce995fc79f5d1f6b
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Thu Jun 1 11:30:10 2023 +0100

    doc: Fix description of x86 -m32 option [PR109954]
    
    This option does not imply -march=i386 so it's incorrect to say it
    generates code that will run on "any i386 system".
    
    gcc/ChangeLog:
    
            PR target/109954
            * doc/invoke.texi (x86 Options): Fix description of -m32 option.
    
    (cherry picked from commit eeb92704967875411416b0b9508aa6f49e8192fd)

diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 39ed6fcfb94..a2f05de39cf 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -30278,7 +30278,7 @@ on x86-64 processors in 64-bit environments.
 Generate code for a 16-bit, 32-bit or 64-bit environment.
 The @option{-m32} option sets @code{int}, @code{long}, and pointer types
 to 32 bits, and
-generates code that runs on any i386 system.
+generates code that runs in 32-bit mode.
 
 The @option{-m64} option sets @code{int} to 32 bits and @code{long} and pointer
 types to 64 bits, and generates code for the x86-64 architecture.

commit 3068cf0c9fe3c0a6183edc00a0f398ea49ce48cc
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Fri Jun 2 00:19:11 2023 +0000

    Daily bump.

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 02d04d6d087..c34c740daae 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,11 @@
+2023-06-01  Jonathan Wakely  <jwakely@redhat.com>
+
+	Backported from master:
+	2023-06-01  Jonathan Wakely  <jwakely@redhat.com>
+
+	PR target/109954
+	* doc/invoke.texi (x86 Options): Fix description of -m32 option.
+
 2023-05-22   Michael Meissner  <meissner@linux.ibm.com>
 
 	PR target/70243
diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index e171f9ed053..d0de28459d0 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230601
+20230602

commit 0e95f779503b2ca75b34e55066faea91ed716b9b
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sat Jun 3 00:18:46 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index d0de28459d0..1760b75fb77 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230602
+20230603

commit e2f058dd0e1f69a9331f0fc359f4fd6e4ed66b5d
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sun Jun 4 00:18:17 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 1760b75fb77..a5bdb7bdd09 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230603
+20230604

commit 786782770243c343b7962e4e9d4625a73cb78ff0
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Mon Jun 5 00:18:20 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index a5bdb7bdd09..3e73975bf5e 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230604
+20230605

commit b29647cda76d1f5677e3b09913b9687f36fe433a
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Tue Jun 6 00:19:22 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 3e73975bf5e..7e14e0ee146 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230605
+20230606

commit 27d409610fa67b6c296ef29c4585e699a4e32414
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Wed Jun 7 00:19:31 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 7e14e0ee146..2e61d1d960e 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230606
+20230607

commit d1db0d32d59311648ac0bdec17f3213f81247a65
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Thu Jun 8 00:19:06 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 2e61d1d960e..73ca44c893e 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230607
+20230608

commit 3d52220f3ac85776109bfb9a1c8de5eeda2c9ca9
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Fri Jun 9 00:18:24 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 73ca44c893e..a4ca097fc3e 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230608
+20230609

commit f46b16ef25fec4f936724ca449259db5c3de0f54
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Fri Jun 9 09:10:29 2023 +0200

    fortran: Fix ICE on pr96024.f90 on big-endian hosts [PR96024]
    
    The pr96024.f90 testcase ICEs on big-endian hosts.  The problem is
    that length->val.integer is accessed after checking
    length->expr_type == EXPR_CONSTANT, but it is a CHARACTER constant
    which uses length->val.character union member instead and on big-endian
    we end up reading constant 0x100000000 rather than some small number
    on little-endian and if target doesn't have enough memory for 4 times
    that (i.e. 16GB allocation), it ICEs.
    
    2023-06-09  Jakub Jelinek  <jakub@redhat.com>
    
            PR fortran/96024
            * primary.c (gfc_convert_to_structure_constructor): Only do
            constant string ctor length verification and truncation/padding
            if constant length has INTEGER type.
    
    (cherry picked from commit 4cf6e322adc19f927859e0a5edfa93cec4b8c844)

diff --git a/gcc/fortran/primary.c b/gcc/fortran/primary.c
index 56b05795c27..c12cbe92e85 100644
--- a/gcc/fortran/primary.c
+++ b/gcc/fortran/primary.c
@@ -3209,10 +3209,11 @@ gfc_convert_to_structure_constructor (gfc_expr *e, gfc_symbol *sym, gfc_expr **c
 	goto cleanup;
 
       /* For a constant string constructor, make sure the length is
-	 correct; truncate of fill with blanks if needed.  */
+	 correct; truncate or fill with blanks if needed.  */
       if (this_comp->ts.type == BT_CHARACTER && !this_comp->attr.allocatable
 	  && this_comp->ts.u.cl && this_comp->ts.u.cl->length
 	  && this_comp->ts.u.cl->length->expr_type == EXPR_CONSTANT
+	  && this_comp->ts.u.cl->length->ts.type == BT_INTEGER
 	  && actual->expr->ts.type == BT_CHARACTER
 	  && actual->expr->expr_type == EXPR_CONSTANT)
 	{

commit dfbf62f87824ac2bd40222bd9c1cbc8d65875a9c
Author: Iain Sandoe <iain@sandoe.co.uk>
Date:   Thu Jun 1 13:43:35 2023 +0100

    Darwin, PPC: Fix struct layout with pragma pack [PR110044].
    
    This bug was essentially that darwin_rs6000_special_round_type_align()
    was ignoring externally-imposed capping of field alignment.
    
    Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
    
            PR target/110044
    
    gcc/ChangeLog:
    
            * config/rs6000/rs6000.c (darwin_rs6000_special_round_type_align):
            Make sure that we do not have a cap on field alignment before altering
            the struct layout based on the type alignment of the first entry.
    
    gcc/testsuite/ChangeLog:
    
            * gcc.target/powerpc/darwin-abi-13-0.c: New test.
            * gcc.target/powerpc/darwin-abi-13-1.c: New test.
            * gcc.target/powerpc/darwin-abi-13-2.c: New test.
            * gcc.target/powerpc/darwin-structs-0.h: New test.
    
    (cherry picked from commit 84d080a29a780973bef47171ba708ae2f7b4ee47)

diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index 0ee9cc8047d..21816f061b4 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -7420,7 +7420,8 @@ darwin_rs6000_special_round_type_align (tree type, unsigned int computed,
       type = TREE_TYPE (type);
   } while (AGGREGATE_TYPE_P (type));
 
-  if (! AGGREGATE_TYPE_P (type) && type != error_mark_node)
+  if (type != error_mark_node && ! AGGREGATE_TYPE_P (type)
+      && ! TYPE_PACKED (type) && maximum_field_alignment == 0)
     align = MAX (align, TYPE_ALIGN (type));
 
   return align;
diff --git a/gcc/testsuite/gcc.target/powerpc/darwin-abi-13-0.c b/gcc/testsuite/gcc.target/powerpc/darwin-abi-13-0.c
new file mode 100644
index 00000000000..d8d3c63a083
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/darwin-abi-13-0.c
@@ -0,0 +1,23 @@
+/* { dg-do compile { target powerpc*-*-darwin* } } */
+/* { dg-require-effective-target ilp32 } */
+/* { dg-options "-Wno-long-long" } */
+
+#include "darwin-structs-0.h"
+
+int tcd[sizeof(cd) != 12 ? -1 : 1];
+int acd[__alignof__(cd) != 4 ? -1 : 1];
+
+int sdc[sizeof(dc) != 16 ? -1 : 1];
+int adc[__alignof__(dc) != 8 ? -1 : 1];
+
+int scL[sizeof(cL) != 12 ? -1 : 1];
+int acL[__alignof__(cL) != 4 ? -1 : 1];
+
+int sLc[sizeof(Lc) != 16 ? -1 : 1];
+int aLc[__alignof__(Lc) != 8 ? -1 : 1];
+
+int scD[sizeof(cD) != 32 ? -1 : 1];
+int acD[__alignof__(cD) != 16 ? -1 : 1];
+
+int sDc[sizeof(Dc) != 32 ? -1 : 1];
+int aDc[__alignof__(Dc) != 16 ? -1 : 1];
diff --git a/gcc/testsuite/gcc.target/powerpc/darwin-abi-13-1.c b/gcc/testsuite/gcc.target/powerpc/darwin-abi-13-1.c
new file mode 100644
index 00000000000..4d888d383fa
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/darwin-abi-13-1.c
@@ -0,0 +1,27 @@
+/* { dg-do compile { target powerpc*-*-darwin* } } */
+/* { dg-require-effective-target ilp32 } */
+/* { dg-options "-Wno-long-long" } */
+
+#pragma pack(push, 1)
+
+#include "darwin-structs-0.h"
+
+int tcd[sizeof(cd) != 9 ? -1 : 1];
+int acd[__alignof__(cd) != 1 ? -1 : 1];
+
+int sdc[sizeof(dc) != 9 ? -1 : 1];
+int adc[__alignof__(dc) != 1 ? -1 : 1];
+
+int scL[sizeof(cL) != 9 ? -1 : 1];
+int acL[__alignof__(cL) != 1 ? -1 : 1];
+
+int sLc[sizeof(Lc) != 9 ? -1 : 1];
+int aLc[__alignof__(Lc) != 1 ? -1 : 1];
+
+int scD[sizeof(cD) != 17 ? -1 : 1];
+int acD[__alignof__(cD) != 1 ? -1 : 1];
+
+int sDc[sizeof(Dc) != 17 ? -1 : 1];
+int aDc[__alignof__(Dc) != 1 ? -1 : 1];
+
+#pragma pack(pop)
diff --git a/gcc/testsuite/gcc.target/powerpc/darwin-abi-13-2.c b/gcc/testsuite/gcc.target/powerpc/darwin-abi-13-2.c
new file mode 100644
index 00000000000..3bd52c0a8f8
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/darwin-abi-13-2.c
@@ -0,0 +1,27 @@
+/* { dg-do compile { target powerpc*-*-darwin* } } */
+/* { dg-require-effective-target ilp32 } */
+/* { dg-options "-Wno-long-long" } */
+
+#pragma pack(push, 2)
+
+#include "darwin-structs-0.h"
+
+int tcd[sizeof(cd) != 10 ? -1 : 1];
+int acd[__alignof__(cd) != 2 ? -1 : 1];
+
+int sdc[sizeof(dc) != 10 ? -1 : 1];
+int adc[__alignof__(dc) != 2 ? -1 : 1];
+
+int scL[sizeof(cL) != 10 ? -1 : 1];
+int acL[__alignof__(cL) != 2 ? -1 : 1];
+
+int sLc[sizeof(Lc) != 10 ? -1 : 1];
+int aLc[__alignof__(Lc) != 2 ? -1 : 1];
+
+int scD[sizeof(cD) != 18 ? -1 : 1];
+int acD[__alignof__(cD) != 2 ? -1 : 1];
+
+int sDc[sizeof(Dc) != 18 ? -1 : 1];
+int aDc[__alignof__(Dc) != 2 ? -1 : 1];
+
+#pragma pack(pop)
diff --git a/gcc/testsuite/gcc.target/powerpc/darwin-structs-0.h b/gcc/testsuite/gcc.target/powerpc/darwin-structs-0.h
new file mode 100644
index 00000000000..1db44f7a808
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/darwin-structs-0.h
@@ -0,0 +1,29 @@
+typedef struct _cd {
+ char c;
+ double d;
+} cd;
+
+typedef struct _dc {
+ double d;
+ char c;
+} dc;
+
+typedef struct _cL {
+ char c;
+ long long L;
+} cL;
+
+typedef struct _Lc {
+ long long L;
+ char c;
+} Lc;
+
+typedef struct _cD {
+ char c;
+ long double D;
+} cD;
+
+typedef struct _Dc {
+ long double D;
+ char c;
+} Dc;

commit d2bd4e16501c359d27205162ee622af269097696
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sat Jun 10 00:19:06 2023 +0000

    Daily bump.

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index c34c740daae..f1fe413d9a7 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,13 @@
+2023-06-09  Iain Sandoe  <iain@sandoe.co.uk>
+
+	Backported from master:
+	2023-06-02  Iain Sandoe  <iain@sandoe.co.uk>
+
+	PR target/110044
+	* config/rs6000/rs6000.c (darwin_rs6000_special_round_type_align):
+	Make sure that we do not have a cap on field alignment before altering
+	the struct layout based on the type alignment of the first entry.
+
 2023-06-01  Jonathan Wakely  <jwakely@redhat.com>
 
 	Backported from master:
diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index a4ca097fc3e..dc88eb6d69e 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230609
+20230610
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 4d79f1d4eb4..92b191f252f 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,13 @@
+2023-06-09  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2023-06-09  Jakub Jelinek  <jakub@redhat.com>
+
+	PR fortran/96024
+	* primary.c (gfc_convert_to_structure_constructor): Only do
+	constant string ctor length verification and truncation/padding
+	if constant length has INTEGER type.
+
 2023-05-03  Jakub Jelinek  <jakub@redhat.com>
 
 	Backported from master:
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 5f48b96f01a..8b962439ea9 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,14 @@
+2023-06-09  Iain Sandoe  <iain@sandoe.co.uk>
+
+	Backported from master:
+	2023-06-02  Iain Sandoe  <iain@sandoe.co.uk>
+
+	PR target/110044
+	* gcc.target/powerpc/darwin-abi-13-0.c: New test.
+	* gcc.target/powerpc/darwin-abi-13-1.c: New test.
+	* gcc.target/powerpc/darwin-abi-13-2.c: New test.
+	* gcc.target/powerpc/darwin-structs-0.h: New test.
+
 2023-05-22   Michael Meissner  <meissner@linux.ibm.com>
 
 	PR target/70243

commit f46901f263143ccbb81d75e1facb19430b38ad84
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sun Jun 11 00:19:02 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index dc88eb6d69e..0f040c2846a 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230610
+20230611

commit f5d806040dcc45c1f369e61633d8ddcdbe47d963
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Mon Jun 12 00:18:44 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 0f040c2846a..995c0c1e119 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230611
+20230612

commit 2052f1bd5f7930308d2481ad38f213e42a72da66
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Tue Jun 13 00:19:21 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 995c0c1e119..5180e2ea7c6 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230612
+20230613

commit 5ccfdffd8988b3328d573bc2d819287d2c09a7a1
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Wed Jun 14 00:18:55 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 5180e2ea7c6..60b8c2b92b7 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230613
+20230614

commit dcfb0ef6cebbf89b1bb3c64655bb103d48306ea7
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Thu Jun 15 00:18:34 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 60b8c2b92b7..3f6866a6b54 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230614
+20230615

commit 1aa7f422dd82c06dbcf1b14b2adacd13db1fb04d
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Fri Jun 16 00:18:50 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 3f6866a6b54..d8455aa601e 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230615
+20230616

commit f9ec94df34dc8ee6a66c18f7ce75ae8b28f9ea0c
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sat Jun 17 00:18:49 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index d8455aa601e..e65e8e48ae9 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230616
+20230617

commit 703029dad0c6764b5f180b989c71047853fd8ce5
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sun Jun 18 00:18:30 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index e65e8e48ae9..8f07d5bff0e 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230617
+20230618

commit a7bef2942e8693eebd61b64612c0ebbba3ff39d5
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Mon Jun 19 00:18:39 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 8f07d5bff0e..b45a5ceabca 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230618
+20230619

commit a137fc8de056c7e0e93047b865bcc1948bd8ee03
Author: Kewen Lin <linkw@linux.ibm.com>
Date:   Mon Jun 12 01:07:52 2023 -0500

    rs6000: Don't use TFmode for 128 bits fp constant in toc [PR110011]
    
    As PR110011 shows, when encoding 128 bits fp constant into
    toc, we adopts REAL_VALUE_TO_TARGET_LONG_DOUBLE which is
    to find the first float mode with LONG_DOUBLE_TYPE_SIZE
    bits of precision, it would be TFmode here.  But the 128
    bits fp constant can be with mode IFmode or KFmode, which
    doesn't necessarily have the same underlying float format
    as the one of TFmode, like this PR exposes, with option
    -mabi=ibmlongdouble TFmode has ibm_extended_format while
    KFmode has ieee_quad_format, mixing up the formats (the
    encoding/decoding ways) would cause unexpected results.
    
    This patch is to make it use constant's own mode instead
    of TFmode for real_to_target call.
    
            PR target/110011
    
    gcc/ChangeLog:
    
            * config/rs6000/rs6000.c (output_toc): Use the mode of the 128-bit
            floating constant itself for real_to_target call.
    
    gcc/testsuite/ChangeLog:
    
            * gcc.target/powerpc/pr110011.c: New test.
    
    (cherry picked from commit 388809f2afde874180da0669c669e241037eeba0)

diff --git a/gcc/config/rs6000/rs6000.c b/gcc/config/rs6000/rs6000.c
index 21816f061b4..1e288eb8222 100644
--- a/gcc/config/rs6000/rs6000.c
+++ b/gcc/config/rs6000/rs6000.c
@@ -16650,7 +16650,7 @@ output_toc (FILE *file, rtx x, int labelno, machine_mode mode)
       if (DECIMAL_FLOAT_MODE_P (GET_MODE (x)))
 	REAL_VALUE_TO_TARGET_DECIMAL128 (*CONST_DOUBLE_REAL_VALUE (x), k);
       else
-	REAL_VALUE_TO_TARGET_LONG_DOUBLE (*CONST_DOUBLE_REAL_VALUE (x), k);
+	real_to_target (k, CONST_DOUBLE_REAL_VALUE (x), GET_MODE (x));
 
       if (TARGET_64BIT)
 	{
diff --git a/gcc/testsuite/gcc.target/powerpc/pr110011.c b/gcc/testsuite/gcc.target/powerpc/pr110011.c
new file mode 100644
index 00000000000..5b04d3e298a
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/pr110011.c
@@ -0,0 +1,42 @@
+/* { dg-do run } */
+/* { dg-require-effective-target float128_runtime } */
+/* Force long double to be with IBM format here, to verify
+   _Float128 constant still uses its own format (IEEE) for
+   encoding rather than IBM format.  */
+/* { dg-options "-mfp-in-toc -mabi=ibmlongdouble" } */
+/* { dg-add-options float128 } */
+
+#define MPFR_FLOAT128_MAX 0x1.ffffffffffffffffffffffffffffp+16383f128
+
+__attribute__ ((noipa))
+_Float128 f128_max ()
+{
+  return MPFR_FLOAT128_MAX;
+}
+
+typedef union
+{
+  int w[4];
+  _Float128 f128;
+} U;
+
+int main ()
+{
+
+  U umax;
+  umax.f128 = f128_max ();
+  /* ieee float128 max:
+     7ffeffff ffffffff ffffffff ffffffff.  */
+  if (umax.w[1] != 0xffffffff || umax.w[2] != 0xffffffff)
+    __builtin_abort ();
+#ifdef __LITTLE_ENDIAN__
+  if (umax.w[0] != 0xffffffff || umax.w[3] != 0x7ffeffff)
+    __builtin_abort ();
+#else
+  if (umax.w[3] != 0xffffffff || umax.w[0] != 0x7ffeffff)
+    __builtin_abort ();
+#endif
+
+  return 0;
+}
+

commit 273e4d282dae6d0c600cbe240caae33ab2f7de44
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Tue Jun 20 00:19:12 2023 +0000

    Daily bump.

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index f1fe413d9a7..4bc7a2c122e 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,12 @@
+2023-06-19  Kewen Lin  <linkw@linux.ibm.com>
+
+	Backported from master:
+	2023-06-12  Kewen Lin  <linkw@linux.ibm.com>
+
+	PR target/110011
+	* config/rs6000/rs6000.c (output_toc): Use the mode of the 128-bit
+	floating constant itself for real_to_target call.
+
 2023-06-09  Iain Sandoe  <iain@sandoe.co.uk>
 
 	Backported from master:
diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index b45a5ceabca..414ba4c8afb 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230619
+20230620
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 8b962439ea9..c9da55f92ac 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,11 @@
+2023-06-19  Kewen Lin  <linkw@linux.ibm.com>
+
+	Backported from master:
+	2023-06-12  Kewen Lin  <linkw@linux.ibm.com>
+
+	PR target/110011
+	* gcc.target/powerpc/pr110011.c: New test.
+
 2023-06-09  Iain Sandoe  <iain@sandoe.co.uk>
 
 	Backported from master:

commit 98763feef24b58573fa9e6c6eedaccc1e932bb46
Author: Kewen Lin <linkw@linux.ibm.com>
Date:   Tue Jun 20 01:40:52 2023 -0500

    rs6000: Guard __builtin_{un,}pack_vector_int128 with vsx [PR109932]
    
    As PR109932 shows, builtins __builtin_{un,}pack_vector_int128
    should be guarded under vsx rather than power7, as their
    corresponding bif patterns have the conditions TARGET_VSX
    and VECTOR_MEM_ALTIVEC_OR_VSX_P (V1TImode).  This patch is to
    ensure __builtin_{un,}pack_vector_int128 only available under
    vsx.
    
            PR target/109932
    
    gcc/ChangeLog:
    
            * config/rs6000/rs6000-builtin.def (BU_VSX_MISC_2): New macro.
            ({un,}pack_vector_int128): Use BU_VSX_MISC_2 instead of
            BU_P7_MISC_2.
    
    gcc/testsuite/ChangeLog:
    
            * gcc.target/powerpc/pr109932-1.c: New test.
            * gcc.target/powerpc/pr109932-2.c: New test.
    
    (cherry picked from commit db291447877aae67979ce3655fcc6fc877f57c6a)

diff --git a/gcc/config/rs6000/rs6000-builtin.def b/gcc/config/rs6000/rs6000-builtin.def
index 36ba145ad3d..52ca2416e36 100644
--- a/gcc/config/rs6000/rs6000-builtin.def
+++ b/gcc/config/rs6000/rs6000-builtin.def
@@ -320,6 +320,14 @@
 		     | RS6000_BTC_SPECIAL),				\
 		    CODE_FOR_nothing)			/* ICODE */
 
+#define BU_VSX_MISC_2(ENUM, NAME, ATTR, ICODE)				\
+  RS6000_BUILTIN_2 (MISC_BUILTIN_ ## ENUM,		/* ENUM */	\
+		    "__builtin_" NAME,			/* NAME */	\
+		    RS6000_BTM_VSX,			/* MASK */	\
+		    (RS6000_BTC_ ## ATTR		/* ATTR */	\
+		     | RS6000_BTC_BINARY),				\
+		    CODE_FOR_ ## ICODE)			/* ICODE */
+
 /* VSX overloaded builtin function macros.  */
 #define BU_VSX_OVERLOAD_1(ENUM, NAME)					\
   RS6000_BUILTIN_1 (VSX_BUILTIN_VEC_ ## ENUM,		/* ENUM */	\
@@ -2589,8 +2597,8 @@ BU_LDBL128_2 (UNPACK_TF,	"unpack_longdouble",	CONST,	unpacktf)
 BU_IBM128_2 (PACK_IF,		"pack_ibm128",		CONST,	packif)
 BU_IBM128_2 (UNPACK_IF,		"unpack_ibm128",	CONST,	unpackif)
 
-BU_P7_MISC_2 (PACK_V1TI,	"pack_vector_int128",	CONST,	packv1ti)
-BU_P7_MISC_2 (UNPACK_V1TI,	"unpack_vector_int128",	CONST,	unpackv1ti)
+BU_VSX_MISC_2 (PACK_V1TI,	"pack_vector_int128",	CONST,	packv1ti)
+BU_VSX_MISC_2 (UNPACK_V1TI,	"unpack_vector_int128",	CONST,	unpackv1ti)
 
 /* 2 argument DFP (Decimal Floating Point) functions added in ISA 3.0.  */
 BU_P9_DFP_MISC_2 (TSTSFI_LT_DD, "dtstsfi_lt_dd", CONST, dfptstsfi_lt_dd)
diff --git a/gcc/testsuite/gcc.target/powerpc/pr109932-1.c b/gcc/testsuite/gcc.target/powerpc/pr109932-1.c
new file mode 100644
index 00000000000..374d9f60618
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/pr109932-1.c
@@ -0,0 +1,17 @@
+/* { dg-require-effective-target int128 } */
+/* { dg-require-effective-target powerpc_altivec_ok } */
+/* { dg-options "-maltivec -mno-vsx" } */
+
+/* Verify there is no ICE but one expected error message instead.  */
+
+#include <altivec.h>
+
+extern vector signed __int128 res_vslll;
+extern unsigned long long aull[2];
+
+void
+testVectorInt128Pack ()
+{
+  res_vslll = __builtin_pack_vector_int128 (aull[0], aull[1]); /* { dg-error "'__builtin_pack_vector_int128' requires the '-mvsx' option" } */
+}
+
diff --git a/gcc/testsuite/gcc.target/powerpc/pr109932-2.c b/gcc/testsuite/gcc.target/powerpc/pr109932-2.c
new file mode 100644
index 00000000000..374d9f60618
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/pr109932-2.c
@@ -0,0 +1,17 @@
+/* { dg-require-effective-target int128 } */
+/* { dg-require-effective-target powerpc_altivec_ok } */
+/* { dg-options "-maltivec -mno-vsx" } */
+
+/* Verify there is no ICE but one expected error message instead.  */
+
+#include <altivec.h>
+
+extern vector signed __int128 res_vslll;
+extern unsigned long long aull[2];
+
+void
+testVectorInt128Pack ()
+{
+  res_vslll = __builtin_pack_vector_int128 (aull[0], aull[1]); /* { dg-error "'__builtin_pack_vector_int128' requires the '-mvsx' option" } */
+}
+

commit 4ed8a07704b05816711491588ad621db4d29c132
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Wed Jun 21 00:18:36 2023 +0000

    Daily bump.

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 4bc7a2c122e..8a396fad62c 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,13 @@
+2023-06-20  Kewen Lin  <linkw@linux.ibm.com>
+
+	Backported from master:
+	2023-06-20  Kewen Lin  <linkw@linux.ibm.com>
+
+	PR target/109932
+	* config/rs6000/rs6000-builtin.def (BU_VSX_MISC_2): New macro.
+	({un,}pack_vector_int128): Use BU_VSX_MISC_2 instead of
+	BU_P7_MISC_2.
+
 2023-06-19  Kewen Lin  <linkw@linux.ibm.com>
 
 	Backported from master:
diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 414ba4c8afb..047f836b4f3 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230620
+20230621
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index c9da55f92ac..b777a953a90 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,12 @@
+2023-06-20  Kewen Lin  <linkw@linux.ibm.com>
+
+	Backported from master:
+	2023-06-20  Kewen Lin  <linkw@linux.ibm.com>
+
+	PR target/109932
+	* gcc.target/powerpc/pr109932-1.c: New test.
+	* gcc.target/powerpc/pr109932-2.c: New test.
+
 2023-06-19  Kewen Lin  <linkw@linux.ibm.com>
 
 	Backported from master:

commit 4728408b5d461c0046cadedcf69b50b4bd23c67d
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Thu Jun 22 00:18:13 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 047f836b4f3..2fa39115675 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230621
+20230622

commit 179b130864652b88da4570e127ea97b627899c39
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Fri Jun 23 00:18:33 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 2fa39115675..0d054fa2ec3 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230622
+20230623

commit f0f8cb2a9f6ec5fdfebb0ee15064133d36a91d64
Author: Christophe Lyon <christophe.lyon@linaro.org>
Date:   Fri Sep 11 11:53:15 2020 +0000

    libstdc++: include/bits/regex_error.h: Avoid warning with -fno-exceptions.
    
    When building with -fno-exceptions, __GLIBCXX_THROW_OR_ABORT expands to
    abort(), causing warnings:
    unused parameter '__ecode'
    unused parameter '__what'
    
    This patch adds __attribute__((unused)) to avoid them.
    
    2020-09-11  Torbjörn SVENSSON <torbjorn.svensson@st.com>
                Christophe Lyon  <christophe.lyon@linaro.org>
    
            libstdc++-v3/
            * include/bits/regex_error.h: Avoid warning with -fno-exceptions.
    
    (cherry picked from commit b32d2ea8c29203519fbd9c5e90b06941e7cd75f3)

diff --git a/libstdc++-v3/include/bits/regex_error.h b/libstdc++-v3/include/bits/regex_error.h
index b150002ceff..a5b553862ce 100644
--- a/libstdc++-v3/include/bits/regex_error.h
+++ b/libstdc++-v3/include/bits/regex_error.h
@@ -167,7 +167,8 @@ namespace regex_constants
   __throw_regex_error(regex_constants::error_type __ecode);
 
   inline void
-  __throw_regex_error(regex_constants::error_type __ecode, const char* __what)
+  __throw_regex_error(regex_constants::error_type __ecode __attribute__((unused)),
+		      const char* __what__attribute__((unused)))
   { _GLIBCXX_THROW_OR_ABORT(regex_error(__ecode, __what)); }
 
 _GLIBCXX_END_NAMESPACE_VERSION

commit 61dc491950863d0b441ddd3f9d609b83a01deaf7
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Fri Sep 11 14:51:36 2020 +0100

    libstdc++: Fix build error in <bits/regex_error.h>
    
    libstdc++-v3/ChangeLog:
    
            * include/bits/regex_error.h (__throw_regex_error): Fix
            parameter declaration and use reserved attribute names.
    
    (cherry picked from commit 29216f56d002982f10c33056f4b3d7f07e164122)

diff --git a/libstdc++-v3/include/bits/regex_error.h b/libstdc++-v3/include/bits/regex_error.h
index a5b553862ce..b40351a39cc 100644
--- a/libstdc++-v3/include/bits/regex_error.h
+++ b/libstdc++-v3/include/bits/regex_error.h
@@ -167,8 +167,9 @@ namespace regex_constants
   __throw_regex_error(regex_constants::error_type __ecode);
 
   inline void
-  __throw_regex_error(regex_constants::error_type __ecode __attribute__((unused)),
-		      const char* __what__attribute__((unused)))
+  __throw_regex_error(regex_constants::error_type __ecode
+			__attribute__((__unused__)),
+		      const char* __what __attribute__((__unused__)))
   { _GLIBCXX_THROW_OR_ABORT(regex_error(__ecode, __what)); }
 
 _GLIBCXX_END_NAMESPACE_VERSION

commit d877bf3bdf46b5c996505fc247d170e79fbfa4bf
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Wed Sep 29 13:48:11 2021 +0100

    libstdc++: std::basic_regex should treat '\0' as an ordinary char [PR84110]
    
    When the input sequence contains a _CharT(0) character, the strchr call
    in _Scanner<_CharT>::_M_scan_normal() will search for '\0' and so return
    a pointer to the terminating null at the end of the string. This makes
    the scanner think it's found a special character. Because it doesn't
    match any of the actual special characters, we fall off the end of the
    function (or assert in debug mode).
    
    We should check for a null character explicitly and either treat it as
    an ordinary character (for the ECMAScript grammar) or an error (for all
    others). I'm not 100% sure that's right, but it seems consistent with
    the POSIX RE rules where a '\0' means the end of the regex pattern or
    the end of the sequence being matched.
    
    Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
    
    libstdc++-v3/ChangeLog:
    
            PR libstdc++/84110
            * include/bits/regex_error.h (regex_constants::_S_null): New
            error code for internal use.
            * include/bits/regex_scanner.tcc (_Scanner::_M_scan_normal()):
            Check for null character.
            * testsuite/28_regex/basic_regex/84110.cc: New test.
    
    (cherry picked from commit b701e1f8f6870c0f8cb4050674da489101dd05a5)

diff --git a/libstdc++-v3/include/bits/regex_error.h b/libstdc++-v3/include/bits/regex_error.h
index b40351a39cc..f2899174352 100644
--- a/libstdc++-v3/include/bits/regex_error.h
+++ b/libstdc++-v3/include/bits/regex_error.h
@@ -61,6 +61,7 @@ namespace regex_constants
       _S_error_badrepeat,
       _S_error_complexity,
       _S_error_stack,
+      _S_null
     };
 
   /** The expression contained an invalid collating element name. */
diff --git a/libstdc++-v3/include/bits/regex_scanner.tcc b/libstdc++-v3/include/bits/regex_scanner.tcc
index cb8a526ea1a..a5a16af6cec 100644
--- a/libstdc++-v3/include/bits/regex_scanner.tcc
+++ b/libstdc++-v3/include/bits/regex_scanner.tcc
@@ -176,6 +176,16 @@ namespace __detail
 	  _M_state = _S_state_in_brace;
 	  _M_token = _S_token_interval_begin;
 	}
+      else if (__builtin_expect(__c == _CharT(0), false))
+	{
+	  if (!_M_is_ecma())
+	    {
+	      __throw_regex_error(regex_constants::_S_null,
+		  "Unexpected null character in regular expression");
+	    }
+	  _M_token = _S_token_ord_char;
+	  _M_value.assign(1, __c);
+	}
       else if (__c != ']' && __c != '}')
 	{
 	  auto __it = _M_token_tbl;
diff --git a/libstdc++-v3/testsuite/28_regex/basic_regex/84110.cc b/libstdc++-v3/testsuite/28_regex/basic_regex/84110.cc
new file mode 100644
index 00000000000..b9971dcaac5
--- /dev/null
+++ b/libstdc++-v3/testsuite/28_regex/basic_regex/84110.cc
@@ -0,0 +1,39 @@
+// { dg-do run { target c++11 } }
+#include <regex>
+#include <string>
+#include <testsuite_hooks.h>
+
+void test01()
+{
+  const std::string s(1ul, '\0');
+  std::regex re(s);
+  VERIFY( std::regex_match(s, re) ); // PR libstdc++/84110
+
+#if __cpp_exceptions
+  using namespace std::regex_constants;
+  for (auto syn : {basic, extended, awk, grep, egrep})
+  {
+    try
+    {
+      std::regex{s, syn}; // '\0' is not valid for other grammars
+      VERIFY( false );
+    }
+    catch (const std::regex_error&)
+    {
+    }
+  }
+#endif
+}
+
+void test02()
+{
+  const std::string s("uh-\0h", 5);
+  std::regex re(s);
+  VERIFY( std::regex_match(s, re) );
+}
+
+int main()
+{
+  test01();
+  test02();
+}

commit 364cb498c472790e14561f7672dc5ab4a9222287
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Sun Dec 12 21:15:17 2021 +0000

    libstdc++: Fix std::regex_replace for strings with embedded null [PR103664]
    
    The overload of std::regex_replace that takes a std::basic_string as the
    fmt argument (for the replacement string) is implemented in terms of the
    one taking a const C*, which uses std::char_traits to find the length.
    That means it stops at a null character, even though the basic_string
    might have additional characters beyond that.
    
    Rather than duplicate the implementation of the const C* one for the
    std::basic_string case, this moves that implementation to a new
    __regex_replace function which takes a const C* and a length. Then both
    the std::basic_string and const C* overloads can call that (with the
    latter using char_traits to find the length to pass to the new
    function).
    
    libstdc++-v3/ChangeLog:
    
            PR libstdc++/103664
            * include/bits/regex.h (__regex_replace): Declare.
            (regex_replace): Use it.
            * include/bits/regex.tcc (__regex_replace): Replace regex_replace
            definition with __regex_replace.
            * testsuite/28_regex/algorithms/regex_replace/char/103664.cc: New test.
    
    (cherry picked from commit ef5d671cd80a4afa4f74c3dfe2904c63f51fcfde)

diff --git a/libstdc++-v3/include/bits/regex.h b/libstdc++-v3/include/bits/regex.h
index 3fded333d47..c7630869548 100644
--- a/libstdc++-v3/include/bits/regex.h
+++ b/libstdc++-v3/include/bits/regex.h
@@ -2457,6 +2457,15 @@ _GLIBCXX_END_NAMESPACE_CXX11
 		 = regex_constants::match_default) = delete;
 
   // std [28.11.4] Function template regex_replace
+
+  template<typename _Out_iter, typename _Bi_iter,
+	   typename _Rx_traits, typename _Ch_type>
+    _Out_iter
+    __regex_replace(_Out_iter __out, _Bi_iter __first, _Bi_iter __last,
+		    const basic_regex<_Ch_type, _Rx_traits>& __e,
+		    const _Ch_type* __fmt, size_t __len,
+		    regex_constants::match_flag_type __flags);
+
   /**
    * @brief Search for a regular expression within a range for multiple times,
    and replace the matched parts through filling a format string.
@@ -2480,7 +2489,8 @@ _GLIBCXX_END_NAMESPACE_CXX11
 		  regex_constants::match_flag_type __flags
 		  = regex_constants::match_default)
     {
-      return regex_replace(__out, __first, __last, __e, __fmt.c_str(), __flags);
+      return std::__regex_replace(__out, __first, __last, __e, __fmt.c_str(),
+				  __fmt.length(), __flags);
     }
 
   /**
@@ -2503,7 +2513,13 @@ _GLIBCXX_END_NAMESPACE_CXX11
 		  const basic_regex<_Ch_type, _Rx_traits>& __e,
 		  const _Ch_type* __fmt,
 		  regex_constants::match_flag_type __flags
-		  = regex_constants::match_default);
+		  = regex_constants::match_default)
+    {
+      return std::__regex_replace(__out, __first, __last, __e, __fmt,
+				  char_traits<_Ch_type>::length(__fmt),
+				  __flags);
+    }
+
 
   /**
    * @brief Search for a regular expression within a string for multiple times,
diff --git a/libstdc++-v3/include/bits/regex.tcc b/libstdc++-v3/include/bits/regex.tcc
index 0ca4f7a7c43..5ff01d115f0 100644
--- a/libstdc++-v3/include/bits/regex.tcc
+++ b/libstdc++-v3/include/bits/regex.tcc
@@ -461,10 +461,10 @@ namespace __detail
   template<typename _Out_iter, typename _Bi_iter,
 	   typename _Rx_traits, typename _Ch_type>
     _Out_iter
-    regex_replace(_Out_iter __out, _Bi_iter __first, _Bi_iter __last,
-		  const basic_regex<_Ch_type, _Rx_traits>& __e,
-		  const _Ch_type* __fmt,
-		  regex_constants::match_flag_type __flags)
+    __regex_replace(_Out_iter __out, _Bi_iter __first, _Bi_iter __last,
+		    const basic_regex<_Ch_type, _Rx_traits>& __e,
+		    const _Ch_type* __fmt, size_t __len,
+		    regex_constants::match_flag_type __flags)
     {
       typedef regex_iterator<_Bi_iter, _Ch_type, _Rx_traits> _IterT;
       _IterT __i(__first, __last, __e, __flags);
@@ -477,7 +477,6 @@ namespace __detail
       else
 	{
 	  sub_match<_Bi_iter> __last;
-	  auto __len = char_traits<_Ch_type>::length(__fmt);
 	  for (; __i != __end; ++__i)
 	    {
 	      if (!(__flags & regex_constants::format_no_copy))
diff --git a/libstdc++-v3/testsuite/28_regex/algorithms/regex_replace/char/103664.cc b/libstdc++-v3/testsuite/28_regex/algorithms/regex_replace/char/103664.cc
new file mode 100644
index 00000000000..ca75e49ed3e
--- /dev/null
+++ b/libstdc++-v3/testsuite/28_regex/algorithms/regex_replace/char/103664.cc
@@ -0,0 +1,11 @@
+// { dg-do run { target c++11 } }
+
+#include <regex>
+#include <testsuite_hooks.h>
+
+int main()
+{
+  // PR libstdc++/103664
+  std::string a = regex_replace("123", std::regex("2"), std::string("a\0b", 3));
+  VERIFY( a == std::string("1a\0b3", 5) );
+}

commit 884751cc4f24ae92f550a4733632e9c54e7182d8
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Mon Sep 27 20:44:24 2021 +0100

    libstdc++: Tweaks to <regex> to avoid warnings
    
    Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
    
    libstdc++-v3/ChangeLog:
    
            * include/bits/regex_compiler.tcc: Add line break in empty while
            statement.
            * include/bits/regex_executor.tcc: Avoid unused parameter
            warning.
    
    (cherry picked from commit b5f276b8c76d892f7fed229153cfbadc13f4696e)

diff --git a/libstdc++-v3/include/bits/regex_compiler.tcc b/libstdc++-v3/include/bits/regex_compiler.tcc
index d29a0537283..3667c860690 100644
--- a/libstdc++-v3/include/bits/regex_compiler.tcc
+++ b/libstdc++-v3/include/bits/regex_compiler.tcc
@@ -140,7 +140,8 @@ namespace __detail
 	return true;
       if (this->_M_atom())
 	{
-	  while (this->_M_quantifier());
+	  while (this->_M_quantifier())
+	    ;
 	  return true;
 	}
       return false;
@@ -440,7 +441,8 @@ namespace __detail
 	      __last_char.second = '-';
 	    }
 	}
-      while (_M_expression_term(__last_char, __matcher));
+      while (_M_expression_term(__last_char, __matcher))
+	;
       if (__last_char.first)
 	__matcher._M_add_char(__last_char.second);
       __matcher._M_ready();
diff --git a/libstdc++-v3/include/bits/regex_executor.tcc b/libstdc++-v3/include/bits/regex_executor.tcc
index 5c8f8492de1..352f24bf306 100644
--- a/libstdc++-v3/include/bits/regex_executor.tcc
+++ b/libstdc++-v3/include/bits/regex_executor.tcc
@@ -423,7 +423,7 @@ namespace __detail
   template<typename _BiIter, typename _Alloc, typename _TraitsT,
 	   bool __dfs_mode>
     void _Executor<_BiIter, _Alloc, _TraitsT, __dfs_mode>::
-    _M_handle_accept(_Match_mode __match_mode, _StateIdT __i)
+    _M_handle_accept(_Match_mode __match_mode, _StateIdT)
     {
       if (__dfs_mode)
 	{

commit 7e52977d21a916de480e310aca9e64c6a30d912f
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Wed Sep 29 13:48:15 2021 +0100

    libstdc++: Check for invalid syntax_option_type values in <regex>
    
    The standard says that it is invalid for more than one grammar element
    to be set in a value of type regex_constants::syntax_option_type. This
    adds a check in the regex compiler andthrows an exception if an invalid
    value is used.
    
    Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
    
    libstdc++-v3/ChangeLog:
    
            * include/bits/regex_compiler.h (_Compiler::_S_validate): New
            function.
            * include/bits/regex_compiler.tcc (_Compiler::_Compiler): Use
            _S_validate to check flags.
            * include/bits/regex_error.h (_S_grammar): New error code for
            internal use.
            * testsuite/28_regex/basic_regex/ctors/grammar.cc: New test.
    
    (cherry picked from commit 9ca4c42a3b756e54a92ff8e1ac6c396b680b7839)

diff --git a/libstdc++-v3/include/bits/regex_compiler.h b/libstdc++-v3/include/bits/regex_compiler.h
index 809ae419f5e..df7e41f1a0d 100644
--- a/libstdc++-v3/include/bits/regex_compiler.h
+++ b/libstdc++-v3/include/bits/regex_compiler.h
@@ -144,6 +144,26 @@ namespace __detail
 	return ret;
       }
 
+      static _FlagT
+      _S_validate(_FlagT __f)
+      {
+	using namespace regex_constants;
+	switch (__f & (ECMAScript|basic|extended|awk|grep|egrep))
+	  {
+	  case ECMAScript:
+	  case basic:
+	  case extended:
+	  case awk:
+	  case grep:
+	  case egrep:
+	    return __f;
+	  case _FlagT(0):
+	    return __f | ECMAScript;
+	  default:
+	    std::__throw_regex_error(_S_grammar, "conflicting grammar options");
+	  }
+      }
+
       _FlagT              _M_flags;
       _ScannerT           _M_scanner;
       shared_ptr<_RegexT> _M_nfa;
diff --git a/libstdc++-v3/include/bits/regex_compiler.tcc b/libstdc++-v3/include/bits/regex_compiler.tcc
index 3667c860690..243b4a5cdbb 100644
--- a/libstdc++-v3/include/bits/regex_compiler.tcc
+++ b/libstdc++-v3/include/bits/regex_compiler.tcc
@@ -65,15 +65,7 @@ namespace __detail
     _Compiler<_TraitsT>::
     _Compiler(_IterT __b, _IterT __e,
 	      const typename _TraitsT::locale_type& __loc, _FlagT __flags)
-    : _M_flags((__flags
-		& (regex_constants::ECMAScript
-		   | regex_constants::basic
-		   | regex_constants::extended
-		   | regex_constants::grep
-		   | regex_constants::egrep
-		   | regex_constants::awk))
-	       ? __flags
-	       : __flags | regex_constants::ECMAScript),
+    : _M_flags(_S_validate(__flags)),
       _M_scanner(__b, __e, _M_flags, __loc),
       _M_nfa(make_shared<_RegexT>(__loc, _M_flags)),
       _M_traits(_M_nfa->_M_traits),
diff --git a/libstdc++-v3/include/bits/regex_error.h b/libstdc++-v3/include/bits/regex_error.h
index f2899174352..b63d6572961 100644
--- a/libstdc++-v3/include/bits/regex_error.h
+++ b/libstdc++-v3/include/bits/regex_error.h
@@ -61,7 +61,8 @@ namespace regex_constants
       _S_error_badrepeat,
       _S_error_complexity,
       _S_error_stack,
-      _S_null
+      _S_null,
+      _S_grammar
     };
 
   /** The expression contained an invalid collating element name. */
diff --git a/libstdc++-v3/testsuite/28_regex/basic_regex/ctors/grammar.cc b/libstdc++-v3/testsuite/28_regex/basic_regex/ctors/grammar.cc
new file mode 100644
index 00000000000..fd8531c4530
--- /dev/null
+++ b/libstdc++-v3/testsuite/28_regex/basic_regex/ctors/grammar.cc
@@ -0,0 +1,53 @@
+// { dg-do run { target c++11 } }
+#include <regex>
+#include <testsuite_hooks.h>
+
+void
+test01()
+{
+  std::regex re{""};
+  VERIFY( re.flags() & std::regex::ECMAScript );
+
+  std::regex re2{"", std::regex::flag_type{}};
+  VERIFY( re2.flags() == std::regex::flag_type() ); // See also PR 83598
+}
+
+void
+test02()
+{
+  // A valid value of type syntax_option_type shall have at most one of the
+  // grammar elements ECMAScript, basic, extended, awk, grep, egrep, set.
+
+  try
+  {
+    std::regex{"", std::regex::ECMAScript|std::regex::basic};
+    VERIFY( false );
+  }
+  catch (const std::regex_error&)
+  {
+  }
+
+  try
+  {
+    std::regex{"", std::regex::extended|std::regex::basic};
+    VERIFY( false );
+  }
+  catch (const std::regex_error&)
+  {
+  }
+
+  try
+  {
+    std::regex{"", std::regex::grep|std::regex::basic};
+    VERIFY( false );
+  }
+  catch (const std::regex_error&)
+  {
+  }
+}
+
+int main()
+{
+  test01();
+  test02();
+}

commit 4c347b8d59958d5aa76c5fdcecd72478e08c5aa3
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Tue Dec 14 14:32:35 2021 +0000

    libstdc++: Fix handling of invalid ranges in std::regex [PR102447]
    
    std::regex currently allows invalid bracket ranges such as [\w-a] which
    are only allowed by ECMAScript when in web browser compatibility mode.
    It should be an error, because the start of the range is a character
    class, not a single character. The current implementation of
    _Compiler::_M_expression_term does not provide a way to reject this,
    because we only remember a previous character, not whether we just
    processed a character class (or collating symbol etc.)
    
    This patch replaces the pair<bool, CharT> used to emulate
    optional<CharT> with a custom class closer to pair<tribool,CharT>. That
    allows us to track three states, so that we can tell when we've just
    seen a character class.
    
    With this additional state the code in _M_expression_term for processing
    the _S_token_bracket_dash can be improved to correctly reject the [\w-a]
    case, without regressing for valid cases such as [\w-] and [----].
    
    libstdc++-v3/ChangeLog:
    
            PR libstdc++/102447
            * include/bits/regex_compiler.h (_Compiler::_BracketState): New
            class.
            (_Compiler::_BrackeyMatcher): New alias template.
            (_Compiler::_M_expression_term): Change pair<bool, CharT>
            parameter to _BracketState. Process first character for
            ECMAScript syntax as well as POSIX.
            * include/bits/regex_compiler.tcc
            (_Compiler::_M_insert_bracket_matcher): Pass _BracketState.
            (_Compiler::_M_expression_term): Use _BracketState to store
            state between calls. Improve handling of dashes in ranges.
            * testsuite/28_regex/algorithms/regex_match/cstring_bracket_01.cc:
            Add more tests for ranges containing dashes. Check invalid
            ranges with character class at the beginning.
    
    (cherry picked from commit 7ce3c230edf6e498e125c805a6dd313bf87dc439)

diff --git a/libstdc++-v3/include/bits/regex_compiler.h b/libstdc++-v3/include/bits/regex_compiler.h
index df7e41f1a0d..a3001b2a432 100644
--- a/libstdc++-v3/include/bits/regex_compiler.h
+++ b/libstdc++-v3/include/bits/regex_compiler.h
@@ -122,13 +122,45 @@ namespace __detail
 	void
 	_M_insert_bracket_matcher(bool __neg);
 
-      // Returns true if successfully matched one term and should continue.
+      // Cache of the last atom seen in a bracketed range expression.
+      struct _BracketState
+      {
+	enum class _Type : char { _None, _Char, _Class } _M_type = _Type::_None;
+	_CharT _M_char;
+
+	void
+	set(_CharT __c) noexcept { _M_type = _Type::_Char; _M_char = __c; }
+
+	_GLIBCXX_NODISCARD _CharT
+	get() const noexcept { return _M_char; }
+
+	void
+	reset(_Type __t = _Type::_None) noexcept { _M_type = __t; }
+
+	explicit operator bool() const noexcept
+	{ return _M_type != _Type::_None; }
+
+	// Previous token was a single character.
+	_GLIBCXX_NODISCARD bool
+	_M_is_char() const noexcept { return _M_type == _Type::_Char; }
+
+	// Previous token was a character class, equivalent class,
+	// collating symbol etc.
+	_GLIBCXX_NODISCARD bool
+	_M_is_class() const noexcept { return _M_type == _Type::_Class; }
+      };
+
+      template<bool __icase, bool __collate>
+	using _BracketMatcher
+	  = std::__detail::_BracketMatcher<_TraitsT, __icase, __collate>;
+
+      // Returns true if successfully parsed one term and should continue
+      // compiling a bracket expression.
       // Returns false if the compiler should move on.
       template<bool __icase, bool __collate>
 	bool
-	_M_expression_term(pair<bool, _CharT>& __last_char,
-			   _BracketMatcher<_TraitsT, __icase, __collate>&
-			   __matcher);
+	_M_expression_term(_BracketState& __last_char,
+			   _BracketMatcher<__icase, __collate>& __matcher);
 
       int
       _M_cur_int_value(int __radix);
diff --git a/libstdc++-v3/include/bits/regex_compiler.tcc b/libstdc++-v3/include/bits/regex_compiler.tcc
index 243b4a5cdbb..da71af90b95 100644
--- a/libstdc++-v3/include/bits/regex_compiler.tcc
+++ b/libstdc++-v3/include/bits/regex_compiler.tcc
@@ -403,7 +403,7 @@ namespace __detail
     _M_insert_character_class_matcher()
     {
       __glibcxx_assert(_M_value.size() == 1);
-      _BracketMatcher<_TraitsT, __icase, __collate> __matcher
+      _BracketMatcher<__icase, __collate> __matcher
 	(_M_ctype.is(_CtypeT::upper, _M_value[0]), _M_traits);
       __matcher._M_add_character_class(_M_value, false);
       __matcher._M_ready();
@@ -417,26 +417,17 @@ namespace __detail
     _Compiler<_TraitsT>::
     _M_insert_bracket_matcher(bool __neg)
     {
-      _BracketMatcher<_TraitsT, __icase, __collate> __matcher(__neg, _M_traits);
-      pair<bool, _CharT> __last_char; // Optional<_CharT>
-      __last_char.first = false;
-      if (!(_M_flags & regex_constants::ECMAScript))
-	{
-	  if (_M_try_char())
-	    {
-	      __last_char.first = true;
-	      __last_char.second = _M_value[0];
-	    }
-	  else if (_M_match_token(_ScannerT::_S_token_bracket_dash))
-	    {
-	      __last_char.first = true;
-	      __last_char.second = '-';
-	    }
-	}
+      _BracketMatcher<__icase, __collate> __matcher(__neg, _M_traits);
+      _BracketState __last_char;
+      if (_M_try_char())
+	__last_char.set(_M_value[0]);
+      else if (_M_match_token(_ScannerT::_S_token_bracket_dash))
+	// Dash as first character is a normal character.
+	__last_char.set('-');
       while (_M_expression_term(__last_char, __matcher))
 	;
-      if (__last_char.first)
-	__matcher._M_add_char(__last_char.second);
+      if (__last_char._M_is_char())
+	__matcher._M_add_char(__last_char.get());
       __matcher._M_ready();
       _M_stack.push(_StateSeqT(
 		      *_M_nfa,
@@ -447,27 +438,27 @@ namespace __detail
   template<bool __icase, bool __collate>
     bool
     _Compiler<_TraitsT>::
-    _M_expression_term(pair<bool, _CharT>& __last_char,
-		       _BracketMatcher<_TraitsT, __icase, __collate>& __matcher)
+    _M_expression_term(_BracketState& __last_char,
+		       _BracketMatcher<__icase, __collate>& __matcher)
     {
       if (_M_match_token(_ScannerT::_S_token_bracket_end))
 	return false;
 
+      // Add any previously cached char into the matcher and update cache.
       const auto __push_char = [&](_CharT __ch)
       {
-	if (__last_char.first)
-	  __matcher._M_add_char(__last_char.second);
-	else
-	  __last_char.first = true;
-	__last_char.second = __ch;
+	if (__last_char._M_is_char())
+	  __matcher._M_add_char(__last_char.get());
+	__last_char.set(__ch);
       };
-      const auto __flush = [&]
+      // Add any previously cached char into the matcher and update cache.
+      const auto __push_class = [&]
       {
-	if (__last_char.first)
-	  {
-	    __matcher._M_add_char(__last_char.second);
-	    __last_char.first = false;
-	  }
+        if (__last_char._M_is_char())
+	  __matcher._M_add_char(__last_char.get());
+	// We don't cache anything here, just record that the last thing
+	// processed was a character class (or similar).
+	__last_char.reset(_BracketState::_Type::_Class);
       };
 
       if (_M_match_token(_ScannerT::_S_token_collsymbol))
@@ -476,16 +467,16 @@ namespace __detail
 	  if (__symbol.size() == 1)
 	    __push_char(__symbol[0]);
 	  else
-	    __flush();
+	    __push_class();
 	}
       else if (_M_match_token(_ScannerT::_S_token_equiv_class_name))
 	{
-	  __flush();
+	  __push_class();
 	  __matcher._M_add_equivalence_class(_M_value);
 	}
       else if (_M_match_token(_ScannerT::_S_token_char_class_name))
 	{
-	  __flush();
+	  __push_class();
 	  __matcher._M_add_character_class(_M_value, false);
 	}
       else if (_M_try_char())
@@ -502,49 +493,50 @@ namespace __detail
       // It turns out that no one reads BNFs ;)
       else if (_M_match_token(_ScannerT::_S_token_bracket_dash))
 	{
-	  if (!__last_char.first)
+	  if (_M_match_token(_ScannerT::_S_token_bracket_end))
 	    {
-	      if (!(_M_flags & regex_constants::ECMAScript))
-		{
-		  if (_M_match_token(_ScannerT::_S_token_bracket_end))
-		    {
-		      __push_char('-');
-		      return false;
-		    }
-		  __throw_regex_error(
-		    regex_constants::error_range,
-		    "Unexpected dash in bracket expression. For POSIX syntax, "
-		    "a dash is not treated literally only when it is at "
-		    "beginning or end.");
-		}
+	      // For "-]" the dash is a literal character.
 	      __push_char('-');
+	      return false;
 	    }
-	  else
+	  else if (__last_char._M_is_class())
+	    {
+	      // "\\w-" is invalid, start of range must be a single char.
+	      __throw_regex_error(regex_constants::error_range,
+		    "Invalid start of range in bracket expression.");
+	    }
+	  else if (__last_char._M_is_char())
 	    {
 	      if (_M_try_char())
 		{
-		  __matcher._M_make_range(__last_char.second, _M_value[0]);
-		  __last_char.first = false;
+		  // "x-y"
+		  __matcher._M_make_range(__last_char.get(), _M_value[0]);
+		  __last_char.reset();
 		}
 	      else if (_M_match_token(_ScannerT::_S_token_bracket_dash))
 		{
-		  __matcher._M_make_range(__last_char.second, '-');
-		  __last_char.first = false;
+		  // "x--"
+		  __matcher._M_make_range(__last_char.get(), '-');
+		  __last_char.reset();
 		}
 	      else
-		{
-		  if (_M_scanner._M_get_token()
-		      != _ScannerT::_S_token_bracket_end)
-		    __throw_regex_error(
-		      regex_constants::error_range,
-		      "Character is expected after a dash.");
-		  __push_char('-');
-		}
+		__throw_regex_error(regex_constants::error_range,
+		      "Invalid end of range in bracket expression.");
 	    }
+	  else if (_M_flags & regex_constants::ECMAScript)
+	    {
+	      // A dash that is not part of an existing range. Might be the
+	      // start of a new range, or might just be a literal '-' char.
+	      // Only ECMAScript allows that in the middle of a bracket expr.
+	      __push_char('-');
+	    }
+	  else
+	    __throw_regex_error(regex_constants::error_range,
+				"Invalid dash in bracket expression.");
 	}
       else if (_M_match_token(_ScannerT::_S_token_quoted_class))
 	{
-	  __flush();
+	  __push_class();
 	  __matcher._M_add_character_class(_M_value,
 					   _M_ctype.is(_CtypeT::upper,
 						       _M_value[0]));
diff --git a/libstdc++-v3/testsuite/28_regex/algorithms/regex_match/cstring_bracket_01.cc b/libstdc++-v3/testsuite/28_regex/algorithms/regex_match/cstring_bracket_01.cc
index 6bf6a7737b7..0a693afced2 100644
--- a/libstdc++-v3/testsuite/28_regex/algorithms/regex_match/cstring_bracket_01.cc
+++ b/libstdc++-v3/testsuite/28_regex/algorithms/regex_match/cstring_bracket_01.cc
@@ -69,6 +69,16 @@ test01()
 void
 test02()
 {
+  VERIFY(regex_match("-", regex("[-]", regex_constants::ECMAScript)));
+  VERIFY(regex_match("-", regex("[--]", regex_constants::ECMAScript)));
+  VERIFY(regex_match("-", regex("[---]", regex_constants::ECMAScript)));
+  VERIFY(regex_match("-", regex("[----]", regex_constants::ECMAScript)));
+  VERIFY(regex_match("-", regex("[-----]", regex_constants::ECMAScript)));
+
+  VERIFY(regex_match("-", regex("[-]", regex_constants::extended)));
+  VERIFY(regex_match("-", regex("[--]", regex_constants::extended)));
+  VERIFY(regex_match("-", regex("[---]", regex_constants::extended)));
+  VERIFY(regex_match("-", regex("[----]", regex_constants::extended)));
   try
   {
     std::regex re("[-----]", std::regex::extended);
@@ -78,7 +88,6 @@ test02()
   {
     VERIFY(e.code() == std::regex_constants::error_range);
   }
-  std::regex re("[-----]", std::regex::ECMAScript);
 
   VERIFY(!regex_match("b", regex("[-ac]", regex_constants::extended)));
   VERIFY(!regex_match("b", regex("[ac-]", regex_constants::extended)));
@@ -93,7 +102,27 @@ test02()
   }
   catch (const std::regex_error& e)
   {
+    VERIFY(e.code() == std::regex_constants::error_range);
+  }
+  try
+  {
+    regex("[@--]", regex_constants::extended);
+    VERIFY(false);
   }
+  catch (const std::regex_error& e)
+  {
+    VERIFY(e.code() == std::regex_constants::error_range);
+  }
+  try
+  {
+    regex("[--%]", regex_constants::extended);
+    VERIFY(false);
+  }
+  catch (const std::regex_error& e)
+  {
+    VERIFY(e.code() == std::regex_constants::error_range);
+  }
+
   VERIFY(regex_match("].", regex("[][.hyphen.]-0]*", regex_constants::extended)));
 }
 
@@ -158,6 +187,36 @@ test06()
   VERIFY(regex_match("a-", debian_cron_namespace_ok));
 }
 
+// libstdc++/102447
+void
+test07()
+{
+  VERIFY(regex_match("-", std::regex("[\\w-]", std::regex::ECMAScript)));
+  VERIFY(regex_match("a", std::regex("[\\w-]", std::regex::ECMAScript)));
+  VERIFY(regex_match("-", std::regex("[a-]", std::regex::ECMAScript)));
+  VERIFY(regex_match("a", std::regex("[a-]", std::regex::ECMAScript)));
+
+  try
+  {
+    std::regex re("[\\w-a]", std::regex::ECMAScript);
+    VERIFY(false);
+  }
+  catch (const std::regex_error& e)
+  {
+    VERIFY(e.code() == std::regex_constants::error_range);
+  }
+
+  try
+  {
+    std::regex re("[\\w--]", std::regex::ECMAScript);
+    VERIFY(false);
+  }
+  catch (const std::regex_error& e)
+  {
+    VERIFY(e.code() == std::regex_constants::error_range);
+  }
+}
+
 int
 main()
 {
@@ -167,6 +226,7 @@ main()
   test04();
   test05();
   test06();
+  test07();
 
   return 0;
 }

commit 596aa947770806d93395d190de3b1d7e14391a21
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Mon Sep 27 20:42:17 2021 +0100

    libstdc++: Add noexcept to functions in <regex>
    
    Signed-off-by: Jonathan Wakely <jwakely@redhat.com>
    
    libstdc++-v3/ChangeLog:
    
            * include/bits/regex.h (basic_regex, swap): Add noexcept to
            non-throwing functions.
            * include/bits/regex_automaton.h (_State_base, _State)
            (_NFA_base): Likewise.
            * include/bits/regex_compiler.h (_Compiler): Likewise.
            * include/bits/regex_error.h (regex_error::code()): Likewise.
            * include/bits/regex_scanner.h (_Scanner): Likewise.
    
    (cherry picked from commit df0dd04b78cfc0f723387b703978600caac93cbb)

diff --git a/libstdc++-v3/include/bits/regex.h b/libstdc++-v3/include/bits/regex.h
index c7630869548..647f26b8975 100644
--- a/libstdc++-v3/include/bits/regex.h
+++ b/libstdc++-v3/include/bits/regex.h
@@ -420,7 +420,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
        * Constructs a basic regular expression that does not match any
        * character sequence.
        */
-      basic_regex()
+      basic_regex() noexcept
       : _M_flags(ECMAScript), _M_loc(), _M_automaton(nullptr)
       { }
 
@@ -696,7 +696,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
        * expression.
        */
       unsigned int
-      mark_count() const
+      mark_count() const noexcept
       {
 	if (_M_automaton)
 	  return _M_automaton->_M_sub_count() - 1;
@@ -708,7 +708,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
        * or in the last call to assign().
        */
       flag_type
-      flags() const
+      flags() const noexcept
       { return _M_flags; }
 
       // [7.8.5] locale
@@ -730,7 +730,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
        *        object.
        */
       locale_type
-      getloc() const
+      getloc() const noexcept
       { return _M_loc; }
 
       // [7.8.6] swap
@@ -740,7 +740,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
        * @param __rhs Another regular expression object.
        */
       void
-      swap(basic_regex& __rhs)
+      swap(basic_regex& __rhs) noexcept
       {
 	std::swap(_M_flags, __rhs._M_flags);
 	std::swap(_M_loc, __rhs._M_loc);
@@ -847,7 +847,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
   template<typename _Ch_type, typename _Rx_traits>
     inline void
     swap(basic_regex<_Ch_type, _Rx_traits>& __lhs,
-	 basic_regex<_Ch_type, _Rx_traits>& __rhs)
+	 basic_regex<_Ch_type, _Rx_traits>& __rhs) noexcept
     { __lhs.swap(__rhs); }
 
 
diff --git a/libstdc++-v3/include/bits/regex_automaton.h b/libstdc++-v3/include/bits/regex_automaton.h
index b7165f19cec..25d9ee98480 100644
--- a/libstdc++-v3/include/bits/regex_automaton.h
+++ b/libstdc++-v3/include/bits/regex_automaton.h
@@ -95,13 +95,13 @@ namespace __detail
     };
 
   protected:
-    explicit _State_base(_Opcode __opcode)
+    explicit _State_base(_Opcode __opcode) noexcept
     : _M_opcode(__opcode), _M_next(_S_invalid_state_id)
     { }
 
   public:
     bool
-    _M_has_alt()
+    _M_has_alt() const noexcept
     {
       return _M_opcode == _S_opcode_alternative
 	|| _M_opcode == _S_opcode_repeat
@@ -130,7 +130,7 @@ namespace __detail
 		    "std::function<bool(char)>");
 
       explicit
-      _State(_Opcode __opcode) : _State_base(__opcode)
+      _State(_Opcode __opcode) noexcept : _State_base(__opcode)
       {
 	if (_M_opcode() == _S_opcode_match)
 	  new (this->_M_matcher_storage._M_addr()) _MatcherT();
@@ -143,7 +143,7 @@ namespace __detail
 	    _MatcherT(__rhs._M_get_matcher());
       }
 
-      _State(_State&& __rhs) : _State_base(__rhs)
+      _State(_State&& __rhs) noexcept : _State_base(__rhs)
       {
 	if (__rhs._M_opcode() == _S_opcode_match)
 	  new (this->_M_matcher_storage._M_addr())
@@ -162,7 +162,7 @@ namespace __detail
       // Since correct ctor and dtor rely on _M_opcode, it's better not to
       // change it over time.
       _Opcode
-      _M_opcode() const
+      _M_opcode() const noexcept
       { return _State_base::_M_opcode; }
 
       bool
@@ -170,11 +170,11 @@ namespace __detail
       { return _M_get_matcher()(__char); }
 
       _MatcherT&
-      _M_get_matcher()
+      _M_get_matcher() noexcept
       { return *static_cast<_MatcherT*>(this->_M_matcher_storage._M_addr()); }
 
       const _MatcherT&
-      _M_get_matcher() const
+      _M_get_matcher() const noexcept
       {
 	return *static_cast<const _MatcherT*>(
 	    this->_M_matcher_storage._M_addr());
@@ -187,7 +187,7 @@ namespace __detail
     typedef regex_constants::syntax_option_type _FlagT;
 
     explicit
-    _NFA_base(_FlagT __f)
+    _NFA_base(_FlagT __f) noexcept
     : _M_flags(__f), _M_start_state(0), _M_subexpr_count(0),
     _M_has_backref(false)
     { }
@@ -199,15 +199,15 @@ namespace __detail
 
   public:
     _FlagT
-    _M_options() const
+    _M_options() const noexcept
     { return _M_flags; }
 
     _StateIdT
-    _M_start() const
+    _M_start() const noexcept
     { return _M_start_state; }
 
     _SizeT
-    _M_sub_count() const
+    _M_sub_count() const noexcept
     { return _M_subexpr_count; }
 
     _GLIBCXX_STD_C::vector<size_t> _M_paren_stack;
diff --git a/libstdc++-v3/include/bits/regex_compiler.h b/libstdc++-v3/include/bits/regex_compiler.h
index a3001b2a432..0e9ffc430dc 100644
--- a/libstdc++-v3/include/bits/regex_compiler.h
+++ b/libstdc++-v3/include/bits/regex_compiler.h
@@ -66,7 +66,7 @@ namespace __detail
 		const typename _TraitsT::locale_type& __traits, _FlagT __flags);
 
       shared_ptr<const _RegexT>
-      _M_get_nfa()
+      _M_get_nfa() noexcept
       { return std::move(_M_nfa); }
 
     private:
diff --git a/libstdc++-v3/include/bits/regex_error.h b/libstdc++-v3/include/bits/regex_error.h
index b63d6572961..21d4cd85c1e 100644
--- a/libstdc++-v3/include/bits/regex_error.h
+++ b/libstdc++-v3/include/bits/regex_error.h
@@ -152,7 +152,7 @@ namespace regex_constants
      * @returns the regex error code.
      */
     regex_constants::error_type
-    code() const
+    code() const noexcept
     { return _M_code; }
 
   private:
diff --git a/libstdc++-v3/include/bits/regex_scanner.h b/libstdc++-v3/include/bits/regex_scanner.h
index 93ef4c66f38..eb82bbbee8c 100644
--- a/libstdc++-v3/include/bits/regex_scanner.h
+++ b/libstdc++-v3/include/bits/regex_scanner.h
@@ -223,11 +223,11 @@ namespace __detail
       _M_advance();
 
       _TokenT
-      _M_get_token() const
+      _M_get_token() const noexcept
       { return _M_token; }
 
       const _StringT&
-      _M_get_value() const
+      _M_get_value() const noexcept
       { return _M_value; }
 
 #ifdef _GLIBCXX_DEBUG

commit fab3692a2cf961b7364d7f77dd976ba0e4f752b7
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Mon Aug 22 15:16:16 2022 +0100

    libstdc++: Check for overflow in regex back-reference [PR106607]
    
    Currently we fail to notice integer overflow when parsing a
    back-reference expression, or when converting the parsed result from
    long to int. This changes the result to be int, so no conversion is
    needed, and uses the overflow-checking built-ins to detect an
    out-of-range back-reference.
    
    libstdc++-v3/ChangeLog:
    
            PR libstdc++/106607
            * include/bits/regex_compiler.tcc (_Compiler::_M_cur_int_value):
            Use built-ins to check for integer overflow in back-reference
            number.
            * testsuite/28_regex/basic_regex/106607.cc: New test.
    
    (cherry picked from commit 1b09eea33f2bf9d1eae73b25cc25efb05ea1dc3f)

diff --git a/libstdc++-v3/include/bits/regex_compiler.tcc b/libstdc++-v3/include/bits/regex_compiler.tcc
index da71af90b95..762d0e19f5f 100644
--- a/libstdc++-v3/include/bits/regex_compiler.tcc
+++ b/libstdc++-v3/include/bits/regex_compiler.tcc
@@ -588,10 +588,12 @@ namespace __detail
     _Compiler<_TraitsT>::
     _M_cur_int_value(int __radix)
     {
-      long __v = 0;
-      for (typename _StringT::size_type __i = 0;
-	   __i < _M_value.length(); ++__i)
-	__v =__v * __radix + _M_traits.value(_M_value[__i], __radix);
+      int __v = 0;
+      for (_CharT __c : _M_value)
+	if (__builtin_mul_overflow(__v, __radix, &__v)
+	    || __builtin_add_overflow(__v, _M_traits.value(__c, __radix), &__v))
+	    std::__throw_regex_error(regex_constants::error_backref,
+				     "invalid back reference");
       return __v;
     }
 
diff --git a/libstdc++-v3/testsuite/28_regex/basic_regex/106607.cc b/libstdc++-v3/testsuite/28_regex/basic_regex/106607.cc
new file mode 100644
index 00000000000..f8e7fb2364d
--- /dev/null
+++ b/libstdc++-v3/testsuite/28_regex/basic_regex/106607.cc
@@ -0,0 +1,25 @@
+// { dg-do run { target c++11 } }
+
+#include <regex>
+#include <string>
+#include <climits>
+#include <testsuite_hooks.h>
+
+// PR libstdc++/106607 - Regex integer overflow on large backreference value
+
+int main()
+{
+  std::regex r("(.)\\1"); // OK
+
+  try
+  {
+    long long n = (unsigned)-1 + 2LL;          // 4294967297 for 32-bit int
+    VERIFY( (int)n == 1 );                     // 4294967297 % 2^32 == 1
+    std::regex r("(.)\\" + std::to_string(n)); // Invalid back reference.
+    VERIFY(false);
+  }
+  catch (const std::regex_error& e)
+  {
+    VERIFY( e.code() == std::regex_constants::error_backref );
+  }
+}

commit 7dba69b5e9977408921c635681a0daa34b813e16
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Wed Jun 17 22:49:06 2020 +0100

    libstdc++: Avoid stack overflow in std::vector (PR 94540)
    
    The std::__uninitialized_default_n algorithm used by std::vector creates
    an initial object as a local variable then copies that into the
    destination range. If the object is too large for the stack this
    crashes. We should create the first object directly into the
    destination and then copy it from there.
    
    This doesn't fix the bug for C++98, because in that case the initial
    value is created as a default argument of the vector constructor i.e. in
    the user's code, not inside libstdc++. We can't prevent that.
    
            PR libstdc++/94540
            * include/bits/stl_uninitialized.h (__uninitialized_default_1<true>):
            Construct the first value at *__first instead of on the stack.
            (__uninitialized_default_n_1<true>): Likewise.
            Improve comments on several of the non-standard algorithms.
            * testsuite/20_util/specialized_algorithms/uninitialized_default/94540.cc:
            New test.
            * testsuite/20_util/specialized_algorithms/uninitialized_default_n/94540.cc:
            New test.
            * testsuite/20_util/specialized_algorithms/uninitialized_value_construct/94540.cc:
            New test.
            * testsuite/20_util/specialized_algorithms/uninitialized_value_construct_n/94540.cc:
            New test.
            * testsuite/23_containers/vector/cons/94540.cc: New test.
    
    (cherry picked from commit 632183ddcc8f3aead8b4fc63c4ab59a42ef9ad00)

diff --git a/libstdc++-v3/include/bits/stl_uninitialized.h b/libstdc++-v3/include/bits/stl_uninitialized.h
index 5f75f69d3a2..72abb6e5917 100644
--- a/libstdc++-v3/include/bits/stl_uninitialized.h
+++ b/libstdc++-v3/include/bits/stl_uninitialized.h
@@ -549,7 +549,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	  typedef typename iterator_traits<_ForwardIterator>::value_type
 	    _ValueType;
 
-	  std::fill(__first, __last, _ValueType());
+	  if (__first == __last)
+	    return;
+
+	  typename iterator_traits<_ForwardIterator>::value_type* __val
+	    = std::__addressof(*__first);
+	  std::_Construct(__val);
+	  if (++__first != __last)
+	    std::fill(__first, __last, *__val);
 	}
     };
 
@@ -582,16 +589,20 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
         static _ForwardIterator
         __uninit_default_n(_ForwardIterator __first, _Size __n)
         {
-	  typedef typename iterator_traits<_ForwardIterator>::value_type
-	    _ValueType;
-
-	  return std::fill_n(__first, __n, _ValueType());
+	  if (__n > 0)
+	    {
+	      typename iterator_traits<_ForwardIterator>::value_type* __val
+		= std::__addressof(*__first);
+	      std::_Construct(__val);
+	      ++__first;
+	      __first = std::fill_n(__first, __n - 1, *__val);
+	    }
+	  return __first;
 	}
     };
 
   // __uninitialized_default
-  // Fills [first, last) with std::distance(first, last) default
-  // constructed value_types(s).
+  // Fills [first, last) with value-initialized value_types.
   template<typename _ForwardIterator>
     inline void
     __uninitialized_default(_ForwardIterator __first,
@@ -608,7 +619,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     }
 
   // __uninitialized_default_n
-  // Fills [first, first + n) with n default constructed value_type(s).
+  // Fills [first, first + n) with value-initialized value_types.
   template<typename _ForwardIterator, typename _Size>
     inline _ForwardIterator
     __uninitialized_default_n(_ForwardIterator __first, _Size __n)
@@ -625,8 +636,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
 
   // __uninitialized_default_a
-  // Fills [first, last) with std::distance(first, last) default
-  // constructed value_types(s), constructed with the allocator alloc.
+  // Fills [first, last) with value_types constructed by the allocator
+  // alloc, with no arguments passed to the construct call.
   template<typename _ForwardIterator, typename _Allocator>
     void
     __uninitialized_default_a(_ForwardIterator __first,
@@ -656,8 +667,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
 
   // __uninitialized_default_n_a
-  // Fills [first, first + n) with n default constructed value_types(s),
-  // constructed with the allocator alloc.
+  // Fills [first, first + n) with value_types constructed by the allocator
+  // alloc, with no arguments passed to the construct call.
   template<typename _ForwardIterator, typename _Size, typename _Allocator>
     _ForwardIterator
     __uninitialized_default_n_a(_ForwardIterator __first, _Size __n, 
@@ -678,6 +689,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	}
     }
 
+  // __uninitialized_default_n_a specialization for std::allocator,
+  // which ignores the allocator and value-initializes the elements.
   template<typename _ForwardIterator, typename _Size, typename _Tp>
     inline _ForwardIterator
     __uninitialized_default_n_a(_ForwardIterator __first, _Size __n, 
@@ -749,8 +762,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     };
 
   // __uninitialized_default_novalue
-  // Fills [first, last) with std::distance(first, last) default-initialized
-  // value_types(s).
+  // Fills [first, last) with default-initialized value_types.
   template<typename _ForwardIterator>
     inline void
     __uninitialized_default_novalue(_ForwardIterator __first,
@@ -764,8 +776,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	__uninit_default_novalue(__first, __last);
     }
 
-  // __uninitialized_default_n
-  // Fills [first, first + n) with n default-initialized value_type(s).
+  // __uninitialized_default_novalue_n
+  // Fills [first, first + n) with default-initialized value_types.
   template<typename _ForwardIterator, typename _Size>
     inline _ForwardIterator
     __uninitialized_default_novalue_n(_ForwardIterator __first, _Size __n)
diff --git a/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_default/94540.cc b/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_default/94540.cc
new file mode 100644
index 00000000000..c55d2aa88fd
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_default/94540.cc
@@ -0,0 +1,34 @@
+// Copyright (C) 2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+// { dg-do run { target { c++11 && { ! simulator } } } }
+
+#include <memory>
+#include <testsuite_hooks.h>
+
+// Assume that 9MB is larger than the stack limit.
+struct X { char data[9*1024*1024]; };
+
+static_assert( std::is_trivial<X>::value, "" );
+
+int main()
+{
+  auto mem = new char[sizeof(X) * 2];
+  auto p = reinterpret_cast<X*>(mem);
+  std::__uninitialized_default(p, p + 2);
+  delete[] mem;
+}
diff --git a/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_default_n/94540.cc b/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_default_n/94540.cc
new file mode 100644
index 00000000000..948a3a08413
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_default_n/94540.cc
@@ -0,0 +1,34 @@
+// Copyright (C) 2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+// { dg-do run { target { c++11 && { ! simulator } } } }
+
+#include <memory>
+#include <testsuite_hooks.h>
+
+// Assume that 9MB is larger than the stack limit.
+struct X { char data[9*1024*1024]; };
+
+static_assert( std::is_trivial<X>::value, "" );
+
+int main()
+{
+  auto mem = new char[sizeof(X) * 2];
+  auto p = reinterpret_cast<X*>(mem);
+  std::__uninitialized_default_n(p, 2);
+  delete[] mem;
+}
diff --git a/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_value_construct/94540.cc b/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_value_construct/94540.cc
new file mode 100644
index 00000000000..9fc5e5dd6fd
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_value_construct/94540.cc
@@ -0,0 +1,35 @@
+// Copyright (C) 2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+// { dg-options "-std=gnu++17" }
+// { dg-do run { target { c++17 && { ! simulator } } } }
+
+#include <memory>
+#include <testsuite_hooks.h>
+
+// Assume that 9MB is larger than the stack limit.
+struct X { char data[9*1024*1024]; };
+
+static_assert( std::is_trivial_v<X> );
+
+int main()
+{
+  auto mem = new char[sizeof(X) * 2];
+  auto p = reinterpret_cast<X*>(mem);
+  std::uninitialized_value_construct(p, p + 2);
+  delete[] mem;
+}
diff --git a/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_value_construct_n/94540.cc b/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_value_construct_n/94540.cc
new file mode 100644
index 00000000000..39d092028c9
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_value_construct_n/94540.cc
@@ -0,0 +1,34 @@
+// Copyright (C) 2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+// { dg-options "-std=gnu++17" }
+// { dg-do run { target { c++17 && { ! simulator } } } }
+
+#include <memory>
+#include <testsuite_hooks.h>
+
+// Assume that 9MB is larger than the stack limit.
+struct X { char data[9*1024*1024]; };
+
+static_assert( std::is_trivial_v<X> );
+
+int main()
+{
+  auto mem = new char[sizeof(X) * 2];
+  std::uninitialized_value_construct_n(reinterpret_cast<X*>(mem), 2);
+  delete[] mem;
+}
diff --git a/libstdc++-v3/testsuite/23_containers/vector/cons/94540.cc b/libstdc++-v3/testsuite/23_containers/vector/cons/94540.cc
new file mode 100644
index 00000000000..6a1b7f43ec6
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/vector/cons/94540.cc
@@ -0,0 +1,35 @@
+// Copyright (C) 2020 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING3.  If not see
+// <http://www.gnu.org/licenses/>.
+
+// { dg-do run { target { c++11 && { ! simulator } } } }
+
+#include <vector>
+#include <testsuite_hooks.h>
+
+// Assume that 9MB is larger than the stack limit.
+struct X { char data[9*1024*1024]; };
+
+static_assert( std::is_trivial<X>::value, "" );
+
+int main()
+{
+  std::vector<X> v(1);
+  VERIFY( v.size() == 1 );
+  v.clear();
+  v.resize(2);
+  VERIFY( v.size() == 2 );
+}

commit b272bc0fbf84454cae8c02e7404cfb23641380cd
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Thu Dec 15 09:52:48 2022 +0000

    libstdc++: Fix self-move for std::weak_ptr [PR108118]
    
    I think an alternative fix would be something like:
    
      _M_ptr = std::exchange(rhs._M_ptr, nullptr);
      _M_refcount = std::move(rhs._M_refcount);
    
    The standard's move-and-swap implementation generates smaller code at
    all levels except -O0 and -Og, so it seems simplest to just do what the
    standard says.
    
    libstdc++-v3/ChangeLog:
    
            PR libstdc++/108118
            * include/bits/shared_ptr_base.h (weak_ptr::operator=):
            Implement as move-and-swap exactly as specified in the standard.
            * testsuite/20_util/weak_ptr/cons/self_move.cc: New test.
    
    (cherry picked from commit 92eb0adc14a5f84acce7e5bc780b81b1544b24aa)

diff --git a/libstdc++-v3/include/bits/shared_ptr_base.h b/libstdc++-v3/include/bits/shared_ptr_base.h
index 792d8344664..c66d895997d 100644
--- a/libstdc++-v3/include/bits/shared_ptr_base.h
+++ b/libstdc++-v3/include/bits/shared_ptr_base.h
@@ -1700,9 +1700,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       __weak_ptr&
       operator=(__weak_ptr&& __r) noexcept
       {
-	_M_ptr = __r._M_ptr;
-	_M_refcount = std::move(__r._M_refcount);
-	__r._M_ptr = nullptr;
+	__weak_ptr(std::move(__r)).swap(*this);
 	return *this;
       }
 
diff --git a/libstdc++-v3/testsuite/20_util/weak_ptr/cons/self_move.cc b/libstdc++-v3/testsuite/20_util/weak_ptr/cons/self_move.cc
new file mode 100644
index 00000000000..c890d2ba94d
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/weak_ptr/cons/self_move.cc
@@ -0,0 +1,19 @@
+// { dg-do run { target c++11 } }
+
+#include <memory>
+#include <testsuite_hooks.h>
+
+void
+test_self_move()
+{
+  std::shared_ptr<int> sp(new int(66));
+  std::weak_ptr<int> wp(sp);
+  wp = std::move(wp); // PR libstdc++/108118
+  std::shared_ptr<int> sp2(wp);
+  VERIFY(sp2 == sp);
+}
+
+int main()
+{
+  test_self_move();
+}

commit 291df257830e4ff877c716cfe6430c03677d9606
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Mon May 15 21:41:56 2023 +0100

    libstdc++: Document removal of implicit allocator rebinding extensions
    
    Traditionally libstdc++ allowed containers to be
    instantiated with allocator's that have the wrong value type, implicitly
    rebinding the allocator to the container's value type. Since C++20 that
    has been explicitly ill-formed, so the extension is no longer supported
    in strict modes (e.g. -std=c++17) and in C++20 and later.
    
    libstdc++-v3/ChangeLog:
    
            * doc/xml/manual/evolution.xml: Document removal of implicit
            allocator rebinding extensions in strict mode and for C++20.
            * doc/html/*: Regenerate.
    
    (cherry picked from commit 8cbaf679a3c1875c5475bd1cb0fb86fb9d03b2d4)

diff --git a/libstdc++-v3/doc/html/manual/api.html b/libstdc++-v3/doc/html/manual/api.html
index 359dcc4f213..8f0b17e858a 100644
--- a/libstdc++-v3/doc/html/manual/api.html
+++ b/libstdc++-v3/doc/html/manual/api.html
@@ -368,6 +368,11 @@ now defaults to zero.
   For the non-default <code class="option">--enable-symvers=gnu-versioned-namespace</code>
   configuration, the shared library SONAME has been changed to
   <code class="filename">libstdc++.so.8</code>.
+</p><p>
+  The extension allowing containers to be instantiated with an allocator
+  that doesn't match the container's value type is no longer allowed in
+  strict (<code class="option">-std=c++NN</code>) modes, only in
+  <code class="option">-std=gnu++NN</code> modes.
 </p></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="api.rel_91"></a><code class="constant">9</code></h3></div></div></div><p>
   C++17 header
   <code class="filename">&lt;memory_resource&gt;</code>
@@ -423,4 +428,8 @@ now defaults to zero.
   and
   <code class="filename">&lt;stop_token&gt;</code>
   added.
+</p><p>
+  The extension allowing containers to be instantiated with an allocator
+  that doesn't match the container's value type is no longer allowed in
+  C++20 mode, even in non-strict <code class="option">-std=gnu++20</code> mode.
 </p></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="abi.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="appendix_porting.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="backwards.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">ABI Policy and Guidelines </td><td width="20%" align="center"><a accesskey="h" href="../index.html">Home</a></td><td width="40%" align="right" valign="top"> Backwards Compatibility</td></tr></table></div></body></html>
\ No newline at end of file
diff --git a/libstdc++-v3/doc/xml/manual/evolution.xml b/libstdc++-v3/doc/xml/manual/evolution.xml
index 0394f7efb7b..f7bf8bb2b71 100644
--- a/libstdc++-v3/doc/xml/manual/evolution.xml
+++ b/libstdc++-v3/doc/xml/manual/evolution.xml
@@ -911,6 +911,13 @@ now defaults to zero.
   <filename>libstdc++.so.8</filename>.
 </para>
 
+<para>
+  The extension allowing containers to be instantiated with an allocator
+  that doesn't match the container's value type is no longer allowed in
+  strict (<option>-std=c++NN</option>) modes, only in
+  <option>-std=gnu++NN</option> modes.
+</para>
+
 </section>
 
 <section xml:id="api.rel_91"><info><title><constant>9</constant></title></info>
@@ -994,6 +1001,12 @@ now defaults to zero.
   added.
 </para>
 
+<para>
+  The extension allowing containers to be instantiated with an allocator
+  that doesn't match the container's value type is no longer allowed in
+  C++20 mode, even in non-strict <option>-std=gnu++20</option> mode.
+</para>
+
 </section>
 
 </section>

commit f11b715ba891ecc936888cc5d4d6a3fab192b5f6
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Mon Oct 11 13:28:32 2021 +0100

    libstdc++: Fix std::numeric_limits::lowest() test for strict modes
    
    This test uses std::is_integral to decide whether we are testing an
    integral or floating-point type. But that fails for __int128 because
    is_integral<__int128> is false in strict modes. By using
    numeric_limits::is_integer instead we get the right answer for all types
    that have a numeric_limits specialization.
    
    We can also simplify the test by removing the unnecessary tag
    dispatching.
    
    libstdc++-v3/ChangeLog:
    
            * testsuite/18_support/numeric_limits/lowest.cc: Use
            numeric_limits<T>::is_integer instead of is_integral<T>::value.
    
    (cherry picked from commit 45ba5426c129993704a73e6ace4016eaa950d7ee)

diff --git a/libstdc++-v3/testsuite/18_support/numeric_limits/lowest.cc b/libstdc++-v3/testsuite/18_support/numeric_limits/lowest.cc
index 918a4494d60..33015409365 100644
--- a/libstdc++-v3/testsuite/18_support/numeric_limits/lowest.cc
+++ b/libstdc++-v3/testsuite/18_support/numeric_limits/lowest.cc
@@ -23,30 +23,20 @@
 // 18.2.1.1 template class numeric_limits
 
 #include <limits>
-#include <type_traits>
 #include <testsuite_hooks.h>
 
 template<typename T>
   void
-  do_test(std::true_type)
+  do_test()
   {
     T limits_min = std::numeric_limits<T>::min();
-    VERIFY( std::numeric_limits<T>::lowest() == limits_min );
-  }
-
-template<typename T>
-  void
-  do_test(std::false_type)
-  {
     T limits_max = std::numeric_limits<T>::max();
-    VERIFY( std::numeric_limits<T>::lowest() == -limits_max );
+    if (std::numeric_limits<T>::is_integer)
+      VERIFY( std::numeric_limits<T>::lowest() == limits_min );
+    else
+      VERIFY( std::numeric_limits<T>::lowest() == -limits_max );
   }
 
-template<typename Tp>
-  void
-  do_test()
-  { do_test<Tp>(typename std::is_integral<Tp>::type()); }
-
 void test01()
 {
   do_test<char>();

commit 2aeef75d1cb2b88db67b3ba5fc0278fa449b83a2
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sat Jun 24 00:18:21 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 0d054fa2ec3..cbffb8130b6 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230623
+20230624
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 0498257dcd9..9e55b4e96cc 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,156 @@
+2023-06-23  Jonathan Wakely  <jwakely@redhat.com>
+
+	Backported from master:
+	2021-10-11  Jonathan Wakely  <jwakely@redhat.com>
+
+	* testsuite/18_support/numeric_limits/lowest.cc: Use
+	numeric_limits<T>::is_integer instead of is_integral<T>::value.
+
+2023-06-23  Jonathan Wakely  <jwakely@redhat.com>
+
+	Backported from master:
+	2023-06-01  Jonathan Wakely  <jwakely@redhat.com>
+
+	* doc/xml/manual/evolution.xml: Document removal of implicit
+	allocator rebinding extensions in strict mode and for C++20.
+	* doc/html/*: Regenerate.
+
+2023-06-23  Jonathan Wakely  <jwakely@redhat.com>
+
+	Backported from master:
+	2022-12-16  Jonathan Wakely  <jwakely@redhat.com>
+
+	PR libstdc++/108118
+	* include/bits/shared_ptr_base.h (weak_ptr::operator=):
+	Implement as move-and-swap exactly as specified in the standard.
+	* testsuite/20_util/weak_ptr/cons/self_move.cc: New test.
+
+2023-06-23  Jonathan Wakely  <jwakely@redhat.com>
+
+	Backported from master:
+	2020-06-17  Jonathan Wakely  <jwakely@redhat.com>
+
+	PR libstdc++/94540
+	* include/bits/stl_uninitialized.h (__uninitialized_default_1<true>):
+	Construct the first value at *__first instead of on the stack.
+	(__uninitialized_default_n_1<true>): Likewise.
+	Improve comments on several of the non-standard algorithms.
+	* testsuite/20_util/specialized_algorithms/uninitialized_default/94540.cc:
+	New test.
+	* testsuite/20_util/specialized_algorithms/uninitialized_default_n/94540.cc:
+	New test.
+	* testsuite/20_util/specialized_algorithms/uninitialized_value_construct/94540.cc:
+	New test.
+	* testsuite/20_util/specialized_algorithms/uninitialized_value_construct_n/94540.cc:
+	New test.
+	* testsuite/23_containers/vector/cons/94540.cc: New test.
+
+2023-06-23  Jonathan Wakely  <jwakely@redhat.com>
+
+	Backported from master:
+	2022-08-22  Jonathan Wakely  <jwakely@redhat.com>
+
+	PR libstdc++/106607
+	* include/bits/regex_compiler.tcc (_Compiler::_M_cur_int_value):
+	Use built-ins to check for integer overflow in back-reference
+	number.
+	* testsuite/28_regex/basic_regex/106607.cc: New test.
+
+2023-06-23  Jonathan Wakely  <jwakely@redhat.com>
+
+	Backported from master:
+	2021-09-28  Jonathan Wakely  <jwakely@redhat.com>
+
+	* include/bits/regex.h (basic_regex, swap): Add noexcept to
+	non-throwing functions.
+	* include/bits/regex_automaton.h (_State_base, _State)
+	(_NFA_base): Likewise.
+	* include/bits/regex_compiler.h (_Compiler): Likewise.
+	* include/bits/regex_error.h (regex_error::code()): Likewise.
+	* include/bits/regex_scanner.h (_Scanner): Likewise.
+
+2023-06-23  Jonathan Wakely  <jwakely@redhat.com>
+
+	Backported from master:
+	2021-12-14  Jonathan Wakely  <jwakely@redhat.com>
+
+	PR libstdc++/102447
+	* include/bits/regex_compiler.h (_Compiler::_BracketState): New
+	class.
+	(_Compiler::_BrackeyMatcher): New alias template.
+	(_Compiler::_M_expression_term): Change pair<bool, CharT>
+	parameter to _BracketState. Process first character for
+	ECMAScript syntax as well as POSIX.
+	* include/bits/regex_compiler.tcc
+	(_Compiler::_M_insert_bracket_matcher): Pass _BracketState.
+	(_Compiler::_M_expression_term): Use _BracketState to store
+	state between calls. Improve handling of dashes in ranges.
+	* testsuite/28_regex/algorithms/regex_match/cstring_bracket_01.cc:
+	Add more tests for ranges containing dashes. Check invalid
+	ranges with character class at the beginning.
+
+2023-06-23  Jonathan Wakely  <jwakely@redhat.com>
+
+	Backported from master:
+	2021-09-29  Jonathan Wakely  <jwakely@redhat.com>
+
+	* include/bits/regex_compiler.h (_Compiler::_S_validate): New
+	function.
+	* include/bits/regex_compiler.tcc (_Compiler::_Compiler): Use
+	_S_validate to check flags.
+	* include/bits/regex_error.h (_S_grammar): New error code for
+	internal use.
+	* testsuite/28_regex/basic_regex/ctors/grammar.cc: New test.
+
+2023-06-23  Jonathan Wakely  <jwakely@redhat.com>
+
+	Backported from master:
+	2021-09-28  Jonathan Wakely  <jwakely@redhat.com>
+
+	* include/bits/regex_compiler.tcc: Add line break in empty while
+	statement.
+	* include/bits/regex_executor.tcc: Avoid unused parameter
+	warning.
+
+2023-06-23  Jonathan Wakely  <jwakely@redhat.com>
+
+	Backported from master:
+	2021-12-13  Jonathan Wakely  <jwakely@redhat.com>
+
+	PR libstdc++/103664
+	* include/bits/regex.h (__regex_replace): Declare.
+	(regex_replace): Use it.
+	* include/bits/regex.tcc (__regex_replace): Replace regex_replace
+	definition with __regex_replace.
+	* testsuite/28_regex/algorithms/regex_replace/char/103664.cc: New test.
+
+2023-06-23  Jonathan Wakely  <jwakely@redhat.com>
+
+	Backported from master:
+	2021-09-29  Jonathan Wakely  <jwakely@redhat.com>
+
+	PR libstdc++/84110
+	* include/bits/regex_error.h (regex_constants::_S_null): New
+	error code for internal use.
+	* include/bits/regex_scanner.tcc (_Scanner::_M_scan_normal()):
+	Check for null character.
+	* testsuite/28_regex/basic_regex/84110.cc: New test.
+
+2023-06-23  Jonathan Wakely  <jwakely@redhat.com>
+
+	Backported from master:
+	2020-09-11  Jonathan Wakely  <jwakely@redhat.com>
+
+	* include/bits/regex_error.h (__throw_regex_error): Fix
+	parameter declaration and use reserved attribute names.
+
+2023-06-23  Christophe Lyon  <christophe.lyon@linaro.org>
+
+	Backported from master:
+	2020-09-11  Christophe Lyon  <christophe.lyon@linaro.org>
+
+	* include/bits/regex_error.h: Avoid warning with -fno-exceptions.
+
 2023-05-21  Iain Sandoe  <iain@sandoe.co.uk>
 
 	* include/bits/fs_path.h: Rename __null_terminated to __nul_terminated

commit 6829464a9b4b45e2b5de690633ed61ed4bbe4f20
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sun Jun 25 00:17:58 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index cbffb8130b6..2ee91bf4891 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230624
+20230625

commit 678cab115de2c01391d90977417c44f2e437d6e9
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Mon Jun 26 00:18:28 2023 +0000

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 2ee91bf4891..2cf61a4ffbf 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20230625
+20230626

commit ab134ecb05c6cf1d7a0aee58e7649a93a87c9874
Author: Iain Buclaw <ibuclaw@gdcproject.org>
Date:   Mon Jun 26 03:24:27 2023 +0200

    d: Suboptimal codegen for __builtin_expect(cond, false)
    
    Since PR96435, both boolean objects and expressions have been evaluated
    in the following way.
    
        (*(ubyte*)&obj_or_expr) & 1
    
    It has been noted that sometimes this can cause the back-end to optimize
    in non-obvious ways - in particular with __builtin_expect.
    
    This @safe feature is now restricted to just when reading the value of a
    bool field that comes from a union.
    
            PR d/110359
    
    gcc/d/ChangeLog:
    
            * d-convert.cc (convert_for_rvalue): Only apply the @safe boolean
            conversion to boolean fields of a union.
            (convert_for_condition): Call convert_for_rvalue in the default case.
    
    gcc/testsuite/ChangeLog:
    
            * gdc.dg/pr110359.d: New test.
    
    (cherry picked from commit ab98db1e8c1b997414539f41b7fb814019497d8d)

diff --git a/gcc/d/d-convert.cc b/gcc/d/d-convert.cc
index 2cfc2c8cc19..04923e1a29c 100644
--- a/gcc/d/d-convert.cc
+++ b/gcc/d/d-convert.cc
@@ -609,7 +609,7 @@ convert_expr (tree exp, Type *etype, Type *totype)
   return result ? result : convert (build_ctype (totype), exp);
 }
 
-/* Return a TREE represenwation of EXPR, whose type has been converted from
+/* Return a TREE representation of EXPR, whose type has been converted from
  * ETYPE to TOTYPE, and is being used in an rvalue context.  */
 
 tree
@@ -625,20 +625,27 @@ convert_for_rvalue (tree expr, Type *etype, Type *totype)
     case Tbool:
       /* If casting from bool, the result is either 0 or 1, any other value
 	 violates @safe code, so enforce that it is never invalid.  */
-      if (CONSTANT_CLASS_P (expr))
-	result = d_truthvalue_conversion (expr);
-      else
+      for (tree ref = expr; TREE_CODE (ref) == COMPONENT_REF;
+	   ref = TREE_OPERAND (ref, 0))
 	{
-	  /* Reinterpret the boolean as an integer and test the first bit.
-	     The generated code should end up being equivalent to:
+	  /* If the expression is a field that's part of a union, reinterpret
+	     the boolean as an integer and test the first bit.  The generated
+	     code should end up being equivalent to:
 		*cast(ubyte *)&expr & 1;  */
-	  machine_mode bool_mode = TYPE_MODE (TREE_TYPE (expr));
-	  tree mtype = lang_hooks.types.type_for_mode (bool_mode, 1);
-	  result = fold_build2 (BIT_AND_EXPR, mtype,
-				build_vconvert (mtype, expr),
-				build_one_cst (mtype));
+	  if (TREE_CODE (TREE_TYPE (TREE_OPERAND (ref, 0))) == UNION_TYPE)
+	    {
+	      machine_mode bool_mode = TYPE_MODE (TREE_TYPE (expr));
+	      tree mtype = lang_hooks.types.type_for_mode (bool_mode, 1);
+	      result = fold_build2 (BIT_AND_EXPR, mtype,
+				    build_vconvert (mtype, expr),
+				    build_one_cst (mtype));
+	      break;
+	    }
 	}
 
+      if (result == NULL_TREE)
+	result = d_truthvalue_conversion (expr);
+
       result = convert (build_ctype (tbtype), result);
       break;
     }
@@ -826,7 +833,7 @@ convert_for_condition (tree expr, Type *type)
       }
 
     default:
-      result = expr;
+      result = convert_for_rvalue (expr, type, type);
       break;
     }
 
diff --git a/gcc/testsuite/gdc.dg/pr110359.d b/gcc/testsuite/gdc.dg/pr110359.d
new file mode 100644
index 00000000000..bf69201d9a5
--- /dev/null
+++ b/gcc/testsuite/gdc.dg/pr110359.d
@@ -0,0 +1,22 @@
+// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110359
+// { dg-do compile }
+// { dg-options "-fdump-tree-original" }
+double pow(in double x, in ulong p)
+{
+    import gcc.builtins : __builtin_expect;
+    if (__builtin_expect(p == 0, false))
+        return 1;
+    if (__builtin_expect(p == 1, false))
+        return x;
+
+    double s = x;
+    double v = 1;
+    for (ulong i = p; i > 1; i >>= 1)
+    {
+        v = (i & 0x1) ? s * v : v;
+        s = s * s;
+    }
+    return v * s;
+}
+// { dg-final { scan-tree-dump "if \\(__builtin_expect \\(p == 0, 0\\) != 0\\)" "original" } }
+// { dg-final { scan-tree-dump "if \\(__builtin_expect \\(p == 1, 0\\) != 0\\)" "original" } }
