commit 306cdb4df729079d7bd924e0023693181163e2e3
Author: Richard Biener <rguenther@suse.de>
Date:   Fri May 23 13:15:18 2025

    Bump BASE-VER.
    
            * BASE-VER: Set to 14.3.1.

diff --git a/gcc/BASE-VER b/gcc/BASE-VER
index 32f02f10ebe..6dfe8b1298c 100644
--- a/gcc/BASE-VER
+++ b/gcc/BASE-VER
@@ -1 +1 @@
-14.3.0
+14.3.1

commit 98d5b27b53f0a227ce2f30d21fb96989a2b8aa5c
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sat May 24 02:22:28 2025

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 809477a289d..cc6fc26c514 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20250523
+20250524

commit a6f18c2a9d50edc263539ba0a64653a8a00d6d89
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sun May 25 02:22:15 2025

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index cc6fc26c514..87d53b31150 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20250524
+20250525

commit f644e21ee364405213a8609bbd8371c27fdb69d9
Author: Michael J. Eager <eager@eagercon.com>
Date:   Sat May 24 23:54:55 2025

    MicroBlaze does not support speculative execution (CVE-2017-5753)
    
    gcc/
            PR target/86772
            Tracking CVE-2017-5753
            * config/microblaze/microblaze.cc (TARGET_HAVE_SPECULATION_SAFE_VALUE):
            Define to speculation_save_value_not_needed

diff --git a/gcc/config/microblaze/microblaze.cc b/gcc/config/microblaze/microblaze.cc
index 98ec6116ffd..26eb007b844 100644
--- a/gcc/config/microblaze/microblaze.cc
+++ b/gcc/config/microblaze/microblaze.cc
@@ -239,6 +239,10 @@ section *sdata2_section;
 #define TARGET_HAVE_TLS true
 #endif
 
+/* MicroBlaze does not do speculative execution.  */
+#undef  TARGET_HAVE_SPECULATION_SAFE_VALUE
+#define TARGET_HAVE_SPECULATION_SAFE_VALUE speculation_safe_value_not_needed
+
 /* Return truth value if a CONST_DOUBLE is ok to be a legitimate constant.  */
 static bool
 microblaze_const_double_ok (rtx op, machine_mode mode)

commit 9c21d7eaf8383749d1a9cd266709ec9ed04e3a00
Author: Harald Anlauf <anlauf@gmx.de>
Date:   Thu Aug 29 22:17:07 2024

    Fortran: default-initialization of derived-type function results [PR98454]
    
    gcc/fortran/ChangeLog:
    
            PR fortran/98454
            * resolve.cc (resolve_symbol): Add default-initialization of
            non-allocatable, non-pointer derived-type function results.
    
    gcc/testsuite/ChangeLog:
    
            PR fortran/98454
            * gfortran.dg/alloc_comp_class_4.f03: Remove bogus pattern.
            * gfortran.dg/pdt_26.f03: Adjust expected count.
            * gfortran.dg/derived_result_3.f90: New test.
    
    (cherry picked from commit b222122d4e93de2238041a01b1886c7dfd9944da)

diff --git a/gcc/fortran/resolve.cc b/gcc/fortran/resolve.cc
index 4f4decd1bc3..4d8484a36f1 100644
--- a/gcc/fortran/resolve.cc
+++ b/gcc/fortran/resolve.cc
@@ -17140,6 +17140,9 @@ skip_interfaces:
 	/* Mark the result symbol to be referenced, when it has allocatable
 	   components.  */
 	sym->result->attr.referenced = 1;
+      else if (a->function && !a->pointer && !a->allocatable && sym->result)
+	/* Default initialization for function results.  */
+	apply_default_init (sym->result);
     }
 
   if (sym->ts.type == BT_CLASS && sym->ns == gfc_current_ns
diff --git a/gcc/testsuite/gfortran.dg/alloc_comp_class_4.f03 b/gcc/testsuite/gfortran.dg/alloc_comp_class_4.f03
index 3118b552a30..4a55d73b245 100644
--- a/gcc/testsuite/gfortran.dg/alloc_comp_class_4.f03
+++ b/gcc/testsuite/gfortran.dg/alloc_comp_class_4.f03
@@ -71,7 +71,7 @@ contains
     allocatable :: t_init
   end function
 
-  type(t) function static_t_init() ! { dg-warning "not set" }
+  type(t) function static_t_init()
   end function
 end module test_pr58586_mod
 
diff --git a/gcc/testsuite/gfortran.dg/derived_result_3.f90 b/gcc/testsuite/gfortran.dg/derived_result_3.f90
new file mode 100644
index 00000000000..4b28f7e28c9
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/derived_result_3.f90
@@ -0,0 +1,158 @@
+! { dg-do run }
+! PR fortran/98454 - default-initialization of derived-type function results
+
+program test
+  implicit none
+  type t
+     integer :: unit = -1
+  end type t
+  type u
+     integer, allocatable :: unit(:)
+  end type u
+  type(t) :: x, x3(3)
+  type(u) :: y, y4(4)
+
+  ! Scalar function result, DT with default initializer
+  x = t(42)
+  if (x% unit /= 42) stop 1
+  x = g()
+  if (x% unit /= -1) stop 2
+  x = t(42)
+  x = f()
+  if (x% unit /= -1) stop 3
+  x = t(42)
+  x = h()
+  if (x% unit /= -1) stop 4
+  x = t(42)
+  x = k()
+  if (x% unit /= -1) stop 5
+
+  ! Array function result, DT with default initializer
+  x3 = t(13)
+  if (any (x3% unit /= 13)) stop 11
+  x3 = f3()
+  if (any (x3% unit /= -1)) stop 12
+  x3 = t(13)
+  x3 = g3()
+  if (any (x3% unit /= -1)) stop 13
+  x3 = t(13)
+  x3 = h3()
+  if (any (x3% unit /= -1)) stop 14
+  x3 = t(13)
+  x3 = k3()
+  if (any (x3% unit /= -1)) stop 15
+
+  ! Scalar function result, DT with allocatable component
+  y = u()
+  if (allocated (y% unit)) stop 21
+  allocate (y% unit(42))
+  y = m()
+  if (allocated (y% unit)) stop 22
+  allocate (y% unit(42))
+  y = n()
+  if (allocated (y% unit)) stop 23
+  allocate (y% unit(42))
+  y = o()
+  if (allocated (y% unit)) stop 24
+  allocate (y% unit(42))
+  y = p()
+  if (allocated (y% unit)) stop 25
+
+  ! Array function result, DT with allocatable component
+  y4 = u()
+  if (allocated (y4(1)% unit)) stop 31
+  allocate (y4(1)% unit(42))
+  y4 = m4()
+  if (allocated (y4(1)% unit)) stop 32
+  y4 = u()
+  allocate (y4(1)% unit(42))
+  y4 = n4()
+  if (allocated (y4(1)% unit)) stop 33
+
+  y4 = u()
+  allocate (y4(1)% unit(42))
+  y4 = o4()
+  if (allocated (y4(1)% unit)) stop 34
+  y4 = u()
+  allocate (y4(1)% unit(42))
+  y4 = p4()
+  if (allocated (y4(1)% unit)) stop 35
+
+contains
+
+  ! Function result not referenced within function body
+  function f()
+    type(t) :: f
+  end function f
+
+  function k() result (f)
+    type(t) :: f
+  end function k
+
+  ! Function result referenced within function body
+  function g()
+    type(t) :: g
+    if (g% unit /= -1) stop 41
+  end function g
+
+  function h() result (g)
+    type(t) :: g
+    if (g% unit /= -1) stop 42
+  end function h
+
+  ! Function result not referenced within function body
+  function f3 ()
+    type(t) :: f3(3)
+  end function f3
+
+  function k3() result (f3)
+    type(t) :: f3(3)
+  end function k3
+
+  ! Function result referenced within function body
+  function g3()
+    type(t) :: g3(3)
+    if (any (g3% unit /= -1)) stop 43
+  end function g3
+
+  function h3() result (g3)
+    type(t) :: g3(3)
+    if (any (g3% unit /= -1)) stop 44
+  end function h3
+
+  function m()
+    type(u) :: m
+  end function m
+
+  function n() result (f)
+    type(u) :: f
+  end function n
+
+  function o()
+    type(u) :: o
+    if (allocated (o% unit)) stop 71
+  end function o
+
+  function p() result (f)
+    type(u) :: f
+    if (allocated (f% unit)) stop 72
+  end function p
+
+  function m4()
+    type(u) :: m4(4)
+  end function m4
+
+  function n4() result (f)
+    type(u) :: f(4)
+  end function n4
+
+  function o4()
+    type(u) :: o4(4)
+    if (allocated (o4(1)% unit)) stop 73
+  end function o4
+
+  function p4() result (f)
+    type(u) :: f(4)
+    if (allocated (f(1)% unit)) stop 74
+  end function p4
+end
diff --git a/gcc/testsuite/gfortran.dg/pdt_26.f03 b/gcc/testsuite/gfortran.dg/pdt_26.f03
index 59ddcfb6cc4..b7e3bb600b4 100644
--- a/gcc/testsuite/gfortran.dg/pdt_26.f03
+++ b/gcc/testsuite/gfortran.dg/pdt_26.f03
@@ -43,4 +43,4 @@ program test_pdt
   if (any (c(1)%foo .ne. [13,15,17])) STOP 2
 end program test_pdt
 ! { dg-final { scan-tree-dump-times "__builtin_free" 8 "original" } }
-! { dg-final { scan-tree-dump-times "__builtin_malloc" 8 "original" } }
+! { dg-final { scan-tree-dump-times "__builtin_malloc" 9 "original" } }

commit 0100ea2b4eb1c83972e0db07503a7cfe8a38932e
Author: Harald Anlauf <anlauf@gmx.de>
Date:   Thu May 15 21:07:07 2025

    Fortran: default-initialization and functions returning derived type [PR85750]
    
    Functions with non-pointer, non-allocatable result and of derived type did
    not always get initialized although the type had default-initialization,
    and a derived type component had the allocatable or pointer attribute.
    Rearrange the logic when to apply default-initialization.
    
            PR fortran/85750
    
    gcc/fortran/ChangeLog:
    
            * resolve.cc (resolve_symbol): Reorder conditions when to apply
            default-initializers.
    
    gcc/testsuite/ChangeLog:
    
            * gfortran.dg/alloc_comp_auto_array_3.f90: Adjust scan counts.
            * gfortran.dg/alloc_comp_class_3.f03: Remove bogus warnings.
            * gfortran.dg/alloc_comp_class_4.f03: Likewise.
            * gfortran.dg/allocate_with_source_14.f03: Adjust scan count.
            * gfortran.dg/derived_constructor_comps_6.f90: Likewise.
            * gfortran.dg/derived_result_5.f90: New test.
    
    (cherry picked from commit d31ab498b12ebbe4f50acb2aa240ff92c73f310c)

diff --git a/gcc/fortran/resolve.cc b/gcc/fortran/resolve.cc
index 4d8484a36f1..10a9e58b287 100644
--- a/gcc/fortran/resolve.cc
+++ b/gcc/fortran/resolve.cc
@@ -17134,15 +17134,16 @@ skip_interfaces:
 	  || (a->dummy && !a->pointer && a->intent == INTENT_OUT
 	      && sym->ns->proc_name->attr.if_source != IFSRC_IFBODY))
 	apply_default_init (sym);
+      else if (a->function && !a->pointer && !a->allocatable && !a->use_assoc
+	       && sym->result)
+	/* Default initialization for function results.  */
+	apply_default_init (sym->result);
       else if (a->function && sym->result && a->access != ACCESS_PRIVATE
 	       && (sym->ts.u.derived->attr.alloc_comp
 		   || sym->ts.u.derived->attr.pointer_comp))
 	/* Mark the result symbol to be referenced, when it has allocatable
 	   components.  */
 	sym->result->attr.referenced = 1;
-      else if (a->function && !a->pointer && !a->allocatable && sym->result)
-	/* Default initialization for function results.  */
-	apply_default_init (sym->result);
     }
 
   if (sym->ts.type == BT_CLASS && sym->ns == gfc_current_ns
diff --git a/gcc/testsuite/gfortran.dg/alloc_comp_auto_array_3.f90 b/gcc/testsuite/gfortran.dg/alloc_comp_auto_array_3.f90
index 2af089e84e8..d0751f3d3eb 100644
--- a/gcc/testsuite/gfortran.dg/alloc_comp_auto_array_3.f90
+++ b/gcc/testsuite/gfortran.dg/alloc_comp_auto_array_3.f90
@@ -25,6 +25,6 @@ contains
     allocate (array(1)%bigarr)
   end function
 end
-! { dg-final { scan-tree-dump-times "builtin_malloc" 3 "original" } }
+! { dg-final { scan-tree-dump-times "builtin_malloc" 4 "original" } }
 ! { dg-final { scan-tree-dump-times "builtin_free" 3 "original" } }
-! { dg-final { scan-tree-dump-times "while \\(1\\)" 4 "original" } }
+! { dg-final { scan-tree-dump-times "while \\(1\\)" 5 "original" } }
diff --git a/gcc/testsuite/gfortran.dg/alloc_comp_class_3.f03 b/gcc/testsuite/gfortran.dg/alloc_comp_class_3.f03
index 0753e33d535..8202d783621 100644
--- a/gcc/testsuite/gfortran.dg/alloc_comp_class_3.f03
+++ b/gcc/testsuite/gfortran.dg/alloc_comp_class_3.f03
@@ -45,11 +45,10 @@ contains
     type(c), value :: d
   end subroutine
 
-  type(c) function c_init()  ! { dg-warning "not set" }
+  type(c) function c_init()
   end function
 
   subroutine sub(d)
     type(u), value :: d
   end subroutine
 end program test_pr58586
-
diff --git a/gcc/testsuite/gfortran.dg/alloc_comp_class_4.f03 b/gcc/testsuite/gfortran.dg/alloc_comp_class_4.f03
index 4a55d73b245..9ff38e3fb7c 100644
--- a/gcc/testsuite/gfortran.dg/alloc_comp_class_4.f03
+++ b/gcc/testsuite/gfortran.dg/alloc_comp_class_4.f03
@@ -51,14 +51,14 @@ contains
     type(t), value :: d
   end subroutine
 
-  type(c) function c_init() ! { dg-warning "not set" }
+  type(c) function c_init()
   end function
 
   class(c) function c_init2() ! { dg-warning "not set" }
     allocatable :: c_init2
   end function
 
-  type(c) function d_init(this) ! { dg-warning "not set" }
+  type(c) function d_init(this)
     class(d) :: this
   end function
 
@@ -102,4 +102,3 @@ program test_pr58586
   call add_c(oe%init())
   deallocate(oe)
 end program
-
diff --git a/gcc/testsuite/gfortran.dg/allocate_with_source_14.f03 b/gcc/testsuite/gfortran.dg/allocate_with_source_14.f03
index fd2db7439fe..36c1245ccdd 100644
--- a/gcc/testsuite/gfortran.dg/allocate_with_source_14.f03
+++ b/gcc/testsuite/gfortran.dg/allocate_with_source_14.f03
@@ -210,5 +210,5 @@ program main
   call v%free()
   deallocate(av)
 end program
-! { dg-final { scan-tree-dump-times "__builtin_malloc" 22 "original" } }
+! { dg-final { scan-tree-dump-times "__builtin_malloc" 23 "original" } }
 ! { dg-final { scan-tree-dump-times "__builtin_free" 29 "original" } }
diff --git a/gcc/testsuite/gfortran.dg/derived_constructor_comps_6.f90 b/gcc/testsuite/gfortran.dg/derived_constructor_comps_6.f90
index bdfa47b1df5..406e031456f 100644
--- a/gcc/testsuite/gfortran.dg/derived_constructor_comps_6.f90
+++ b/gcc/testsuite/gfortran.dg/derived_constructor_comps_6.f90
@@ -129,5 +129,5 @@ contains
     prt_spec = name
   end function new_prt_spec3
 end program main
-! { dg-final { scan-tree-dump-times "__builtin_malloc" 15 "original" } }
+! { dg-final { scan-tree-dump-times "__builtin_malloc" 16 "original" } }
 ! { dg-final { scan-tree-dump-times "__builtin_free" 33 "original" } }
diff --git a/gcc/testsuite/gfortran.dg/derived_result_5.f90 b/gcc/testsuite/gfortran.dg/derived_result_5.f90
new file mode 100644
index 00000000000..1ba4d19dc44
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/derived_result_5.f90
@@ -0,0 +1,123 @@
+! { dg-do run }
+! { dg-additional-options "-O2 -Wreturn-type" }
+!
+! PR fortran/85750 - default-initialization and functions returning derived type
+
+module bar
+  implicit none
+  type ilist
+    integer          :: count = 42
+    integer, pointer :: ptr(:) => null()
+  end type ilist
+
+  type jlist
+    real, allocatable :: a(:)
+    integer           :: count = 23
+  end type jlist
+
+contains
+
+  function make_list(i)
+    integer,     intent(in)   :: i
+    type(ilist), dimension(2) :: make_list
+    make_list(i)%count = i
+  end function make_list
+
+  function make_list_res(i) result(list)
+    integer,     intent(in)   :: i
+    type(ilist), dimension(2) :: list
+    list(i)%count = i
+  end function make_list_res
+
+  function make_jlist(i)
+    integer,     intent(in)   :: i
+    type(jlist), dimension(2) :: make_jlist
+    make_jlist(i)%count = i
+  end function make_jlist
+
+  function make_jlist_res(i) result(list)
+    integer,     intent(in)   :: i
+    type(jlist), dimension(2) :: list
+    list(i)%count = i
+  end function make_jlist_res
+
+  function empty_ilist()
+    type(ilist), dimension(2) :: empty_ilist
+  end function
+
+  function empty_jlist()
+    type(jlist), dimension(2) :: empty_jlist
+  end function
+
+  function empty_ilist_res() result (res)
+    type(ilist), dimension(2) :: res
+  end function
+
+  function empty_jlist_res() result (res)
+    type(jlist), dimension(2) :: res
+  end function
+
+end module bar
+
+program foo
+  use bar
+  implicit none
+  type(ilist)              :: mylist(2) = ilist(count=-2)
+  type(jlist), allocatable :: yourlist(:)
+
+  mylist = ilist(count=-1)
+  if (any (mylist%count /= [-1,-1])) stop 1
+  mylist = empty_ilist()
+  if (any (mylist%count /= [42,42])) stop 2
+  mylist = ilist(count=-1)
+  mylist = empty_ilist_res()
+  if (any (mylist%count /= [42,42])) stop 3
+
+  allocate(yourlist(1:2))
+  if (any (yourlist%count /= [23,23])) stop 4
+  yourlist = jlist(count=-1)
+  if (any (yourlist%count /= [-1,-1])) stop 5
+  yourlist = empty_jlist()
+  if (any (yourlist%count /= [23,23])) stop 6
+  yourlist = jlist(count=-1)
+  yourlist = empty_jlist_res()
+  if (any (yourlist%count /= [23,23])) stop 7
+
+  mylist = make_list(1)
+  if (any (mylist%count /= [1,42])) stop 11
+  mylist = make_list(2)
+  if (any (mylist%count /= [42,2])) stop 12
+  mylist = (make_list(1))
+  if (any (mylist%count /= [1,42])) stop 13
+  mylist = [make_list(2)]
+  if (any (mylist%count /= [42,2])) stop 14
+
+  mylist = make_list_res(1)
+  if (any (mylist%count /= [1,42])) stop 21
+  mylist = make_list_res(2)
+  if (any (mylist%count /= [42,2])) stop 22
+  mylist = (make_list_res(1))
+  if (any (mylist%count /= [1,42])) stop 23
+  mylist = [make_list_res(2)]
+  if (any (mylist%count /= [42,2])) stop 24
+
+  yourlist = make_jlist(1)
+  if (any (yourlist%count /= [1,23])) stop 31
+  yourlist = make_jlist(2)
+  if (any (yourlist%count /= [23,2])) stop 32
+  yourlist = (make_jlist(1))
+  if (any (yourlist%count /= [1,23])) stop 33
+  yourlist = [make_jlist(2)]
+  if (any (yourlist%count /= [23,2])) stop 34
+
+  yourlist = make_jlist_res(1)
+  if (any (yourlist%count /= [1,23])) stop 41
+  yourlist = make_jlist_res(2)
+  if (any (yourlist%count /= [23,2])) stop 42
+  yourlist = (make_jlist_res(1))
+  if (any (yourlist%count /= [1,23])) stop 43
+  yourlist = [make_jlist_res(2)]
+  if (any (yourlist%count /= [23,2])) stop 44
+
+  deallocate (yourlist)
+end program foo

commit 7d5979a65577cfb80d18e101e8b8bd1b1240ae4b
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Mon May 26 02:21:16 2025

    Daily bump.

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 314b0a65fd2..541b6babe73 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,10 @@
+2025-05-25  Michael J. Eager  <eager@eagercon.com>
+
+	PR target/86772
+	Tracking CVE-2017-5753
+	* config/microblaze/microblaze.cc (TARGET_HAVE_SPECULATION_SAFE_VALUE):
+	Define to speculation_save_value_not_needed
+
 2025-05-23  Release Manager
 
 	* GCC 14.3.0 released.
diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 87d53b31150..dbf258be4a2 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20250525
+20250526
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 4ccbea18878..12ead9dfc79 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,21 @@
+2025-05-25  Harald Anlauf  <anlauf@gmx.de>
+
+	Backported from master:
+	2025-05-15  Harald Anlauf  <anlauf@gmx.de>
+
+	PR fortran/85750
+	* resolve.cc (resolve_symbol): Reorder conditions when to apply
+	default-initializers.
+
+2025-05-25  Harald Anlauf  <anlauf@gmx.de>
+
+	Backported from master:
+	2024-08-30  Harald Anlauf  <anlauf@gmx.de>
+
+	PR fortran/98454
+	* resolve.cc (resolve_symbol): Add default-initialization of
+	non-allocatable, non-pointer derived-type function results.
+
 2025-05-23  Release Manager
 
 	* GCC 14.3.0 released.
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 64d04634e7c..23d940b9d1b 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,26 @@
+2025-05-25  Harald Anlauf  <anlauf@gmx.de>
+
+	Backported from master:
+	2025-05-15  Harald Anlauf  <anlauf@gmx.de>
+
+	PR fortran/85750
+	* gfortran.dg/alloc_comp_auto_array_3.f90: Adjust scan counts.
+	* gfortran.dg/alloc_comp_class_3.f03: Remove bogus warnings.
+	* gfortran.dg/alloc_comp_class_4.f03: Likewise.
+	* gfortran.dg/allocate_with_source_14.f03: Adjust scan count.
+	* gfortran.dg/derived_constructor_comps_6.f90: Likewise.
+	* gfortran.dg/derived_result_5.f90: New test.
+
+2025-05-25  Harald Anlauf  <anlauf@gmx.de>
+
+	Backported from master:
+	2024-08-30  Harald Anlauf  <anlauf@gmx.de>
+
+	PR fortran/98454
+	* gfortran.dg/alloc_comp_class_4.f03: Remove bogus pattern.
+	* gfortran.dg/pdt_26.f03: Adjust expected count.
+	* gfortran.dg/derived_result_3.f90: New test.
+
 2025-05-23  Release Manager
 
 	* GCC 14.3.0 released.

commit e326152845584d78410963e5c3d31cdbdf8f50fe
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Thu Nov 28 10:51:16 2024

    gimple-fold: Avoid ICEs with bogus declarations like const attribute no snprintf [PR117358]
    
    When one puts incorrect const or pure attributes on declarations of various
    C APIs which have corresponding builtins (vs. what they actually do), we can
    get tons of ICEs in gimple-fold.cc.
    
    The following patch fixes it by giving up gimple_fold_builtin_* folding
    if the functions don't have gimple_vdef (or for pure functions like
    bcmp/strchr/strstr gimple_vuse) when in SSA form (during gimplification
    they will surely have both of those NULL even when declared correctly,
    yet it is highly desirable to fold them).
    
    Or shall I replace
    !gimple_vdef (stmt) && gimple_in_ssa_p (cfun)
    tests with
    (gimple_call_flags (stmt) & (ECF_CONST | ECF_PURE | ECF_NOVOPS)) != 0
    and
    !gimple_vuse (stmt) && gimple_in_ssa_p (cfun)
    with
    (gimple_call_flags (stmt) & (ECF_CONST | ECF_NOVOPS)) != 0
    ?
    
    2024-11-28  Jakub Jelinek  <jakub@redhat.com>
    
            PR tree-optimization/117358
            * gimple-fold.cc (gimple_fold_builtin_memory_op): Punt if stmt has no
            vdef in ssa form.
            (gimple_fold_builtin_bcmp): Punt if stmt has no vuse in ssa form.
            (gimple_fold_builtin_bcopy): Punt if stmt has no vdef in ssa form.
            (gimple_fold_builtin_bzero): Likewise.
            (gimple_fold_builtin_memset): Likewise.  Use return false instead of
            return NULL_TREE.
            (gimple_fold_builtin_strcpy): Punt if stmt has no vdef in ssa form.
            (gimple_fold_builtin_strncpy): Likewise.
            (gimple_fold_builtin_strchr): Punt if stmt has no vuse in ssa form.
            (gimple_fold_builtin_strstr): Likewise.
            (gimple_fold_builtin_strcat): Punt if stmt has no vdef in ssa form.
            (gimple_fold_builtin_strcat_chk): Likewise.
            (gimple_fold_builtin_strncat): Likewise.
            (gimple_fold_builtin_strncat_chk): Likewise.
            (gimple_fold_builtin_string_compare): Likewise.
            (gimple_fold_builtin_fputs): Likewise.
            (gimple_fold_builtin_memory_chk): Likewise.
            (gimple_fold_builtin_stxcpy_chk): Likewise.
            (gimple_fold_builtin_stxncpy_chk): Likewise.
            (gimple_fold_builtin_stpcpy): Likewise.
            (gimple_fold_builtin_snprintf_chk): Likewise.
            (gimple_fold_builtin_sprintf_chk): Likewise.
            (gimple_fold_builtin_sprintf): Likewise.
            (gimple_fold_builtin_snprintf): Likewise.
            (gimple_fold_builtin_fprintf): Likewise.
            (gimple_fold_builtin_printf): Likewise.
            (gimple_fold_builtin_realloc): Likewise.
    
            * gcc.c-torture/compile/pr117358.c: New test.
    
    (cherry picked from commit 29032dfa57629d1713a97b17a785273823993a91)

diff --git a/gcc/gimple-fold.cc b/gcc/gimple-fold.cc
index 3548c914482..0d90bab595f 100644
--- a/gcc/gimple-fold.cc
+++ b/gcc/gimple-fold.cc
@@ -936,6 +936,8 @@ gimple_fold_builtin_memory_op (gimple_stmt_iterator *gsi,
 	}
       goto done;
     }
+  else if (!gimple_vdef (stmt) && gimple_in_ssa_p (cfun))
+    return false;
   else
     {
       /* We cannot (easily) change the type of the copy if it is a storage
@@ -1377,6 +1379,8 @@ gimple_fold_builtin_bcmp (gimple_stmt_iterator *gsi)
   /* Transform bcmp (a, b, len) into memcmp (a, b, len).  */
 
   gimple *stmt = gsi_stmt (*gsi);
+  if (!gimple_vuse (stmt) && gimple_in_ssa_p (cfun))
+    return false;
   tree a = gimple_call_arg (stmt, 0);
   tree b = gimple_call_arg (stmt, 1);
   tree len = gimple_call_arg (stmt, 2);
@@ -1403,6 +1407,8 @@ gimple_fold_builtin_bcopy (gimple_stmt_iterator *gsi)
      len) into memmove (dest, src, len).  */
 
   gimple *stmt = gsi_stmt (*gsi);
+  if (!gimple_vdef (stmt) && gimple_in_ssa_p (cfun))
+    return false;
   tree src = gimple_call_arg (stmt, 0);
   tree dest = gimple_call_arg (stmt, 1);
   tree len = gimple_call_arg (stmt, 2);
@@ -1428,6 +1434,8 @@ gimple_fold_builtin_bzero (gimple_stmt_iterator *gsi)
   /* Transform bzero (dest, len) into memset (dest, 0, len).  */
 
   gimple *stmt = gsi_stmt (*gsi);
+  if (!gimple_vdef (stmt) && gimple_in_ssa_p (cfun))
+    return false;
   tree dest = gimple_call_arg (stmt, 0);
   tree len = gimple_call_arg (stmt, 1);
 
@@ -1457,6 +1465,9 @@ gimple_fold_builtin_memset (gimple_stmt_iterator *gsi, tree c, tree len)
       return true;
     }
 
+  if (!gimple_vdef (stmt) && gimple_in_ssa_p (cfun))
+    return false;
+
   if (! tree_fits_uhwi_p (len))
     return false;
 
@@ -1479,20 +1490,20 @@ gimple_fold_builtin_memset (gimple_stmt_iterator *gsi, tree c, tree len)
   if ((!INTEGRAL_TYPE_P (etype)
        && !POINTER_TYPE_P (etype))
       || TREE_CODE (etype) == BITINT_TYPE)
-    return NULL_TREE;
+    return false;
 
   if (! var_decl_component_p (var))
-    return NULL_TREE;
+    return false;
 
   length = tree_to_uhwi (len);
   if (GET_MODE_SIZE (SCALAR_INT_TYPE_MODE (etype)) != length
       || (GET_MODE_PRECISION (SCALAR_INT_TYPE_MODE (etype))
 	  != GET_MODE_BITSIZE (SCALAR_INT_TYPE_MODE (etype)))
       || get_pointer_alignment (dest) / BITS_PER_UNIT < length)
-    return NULL_TREE;
+    return false;
 
   if (length > HOST_BITS_PER_WIDE_INT / BITS_PER_UNIT)
-    return NULL_TREE;
+    return false;
 
   if (!type_has_mode_precision_p (etype))
     etype = lang_hooks.types.type_for_mode (SCALAR_INT_TYPE_MODE (etype),
@@ -2106,7 +2117,7 @@ gimple_fold_builtin_strcpy (gimple_stmt_iterator *gsi,
       return false;
     }
 
-  if (!len)
+  if (!len || (!gimple_vdef (stmt) && gimple_in_ssa_p (cfun)))
     return false;
 
   len = fold_convert_loc (loc, size_type_node, len);
@@ -2181,7 +2192,7 @@ gimple_fold_builtin_strncpy (gimple_stmt_iterator *gsi,
 
   /* OK transform into builtin memcpy.  */
   tree fn = builtin_decl_implicit (BUILT_IN_MEMCPY);
-  if (!fn)
+  if (!fn || (!gimple_vdef (stmt) && gimple_in_ssa_p (cfun)))
     return false;
 
   len = fold_convert_loc (loc, size_type_node, len);
@@ -2235,7 +2246,7 @@ gimple_fold_builtin_strchr (gimple_stmt_iterator *gsi, bool is_strrchr)
       return true;
     }
 
-  if (!integer_zerop (c))
+  if (!integer_zerop (c) || (!gimple_vuse (stmt) && gimple_in_ssa_p (cfun)))
     return false;
 
   /* Transform strrchr (s, 0) to strchr (s, 0) when optimizing for size.  */
@@ -2333,6 +2344,9 @@ gimple_fold_builtin_strstr (gimple_stmt_iterator *gsi)
       return true;
     }
 
+  if (!gimple_vuse (stmt) && gimple_in_ssa_p (cfun))
+    return false;
+
   /* Transform strstr (x, "c") into strchr (x, 'c').  */
   if (q[1] == '\0')
     {
@@ -2385,6 +2399,9 @@ gimple_fold_builtin_strcat (gimple_stmt_iterator *gsi, tree dst, tree src)
   if (!optimize_bb_for_speed_p (gimple_bb (stmt)))
     return false;
 
+  if (!gimple_vdef (stmt) && gimple_in_ssa_p (cfun))
+    return false;
+
   /* See if we can store by pieces into (dst + strlen(dst)).  */
   tree newdst;
   tree strlen_fn = builtin_decl_implicit (BUILT_IN_STRLEN);
@@ -2454,7 +2471,6 @@ gimple_fold_builtin_strcat_chk (gimple_stmt_iterator *gsi)
   tree fn;
   const char *p;
 
-
   p = c_getstr (src);
   /* If the SRC parameter is "", return DEST.  */
   if (p && *p == '\0')
@@ -2466,6 +2482,9 @@ gimple_fold_builtin_strcat_chk (gimple_stmt_iterator *gsi)
   if (! tree_fits_uhwi_p (size) || ! integer_all_onesp (size))
     return false;
 
+  if (!gimple_vdef (stmt) && gimple_in_ssa_p (cfun))
+    return false;
+
   /* If __builtin_strcat_chk is used, assume strcat is available.  */
   fn = builtin_decl_explicit (BUILT_IN_STRCAT);
   if (!fn)
@@ -2556,7 +2575,7 @@ gimple_fold_builtin_strncat (gimple_stmt_iterator *gsi)
 
   /* If the replacement _DECL isn't initialized, don't do the
      transformation.  */
-  if (!fn)
+  if (!fn || (!gimple_vdef (stmt) && gimple_in_ssa_p (cfun)))
     return false;
 
   /* Otherwise, emit a call to strcat.  */
@@ -2588,6 +2607,9 @@ gimple_fold_builtin_strncat_chk (gimple_stmt_iterator *gsi)
       return true;
     }
 
+  if (!gimple_vdef (stmt) && gimple_in_ssa_p (cfun))
+    return false;
+
   if (! integer_all_onesp (size))
     {
       tree src_len = c_strlen (src, 1);
@@ -2678,6 +2700,9 @@ gimple_fold_builtin_string_compare (gimple_stmt_iterator *gsi)
       return true;
     }
 
+  if (!gimple_vuse (stmt) && gimple_in_ssa_p (cfun))
+    return false;
+
   /* Initially set to the number of characters, including the terminating
      nul if each array has one.   LENx == strnlen (Sx, LENx) implies that
      the array Sx is not terminated by a nul.
@@ -2970,7 +2995,7 @@ gimple_fold_builtin_fputs (gimple_stmt_iterator *gsi,
 	const char *p = c_getstr (arg0);
 	if (p != NULL)
 	  {
-	    if (!fn_fputc)
+	    if (!fn_fputc || (!gimple_vdef (stmt) && gimple_in_ssa_p (cfun)))
 	      return false;
 
 	    gimple *repl
@@ -2989,7 +3014,7 @@ gimple_fold_builtin_fputs (gimple_stmt_iterator *gsi,
 	  return false;
 	/* New argument list transforming fputs(string, stream) to
 	   fwrite(string, 1, len, stream).  */
-	if (!fn_fwrite)
+	if (!fn_fwrite || (!gimple_vdef (stmt) && gimple_in_ssa_p (cfun)))
 	  return false;
 
 	gimple *repl
@@ -3040,6 +3065,9 @@ gimple_fold_builtin_memory_chk (gimple_stmt_iterator *gsi,
 	}
     }
 
+  if (!gimple_vdef (stmt) && gimple_in_ssa_p (cfun))
+    return false;
+
   tree maxlen = get_maxval_strlen (len, SRK_INT_VALUE);
   if (! integer_all_onesp (size)
       && !known_lower (stmt, len, size)
@@ -3138,6 +3166,9 @@ gimple_fold_builtin_stxcpy_chk (gimple_stmt_iterator *gsi,
       return true;
     }
 
+  if (!gimple_vdef (stmt) && gimple_in_ssa_p (cfun))
+    return false;
+
   tree maxlen = get_maxval_strlen (src, SRK_STRLENMAX);
   if (! integer_all_onesp (size))
     {
@@ -3231,7 +3262,7 @@ gimple_fold_builtin_stxncpy_chk (gimple_stmt_iterator *gsi,
   /* If __builtin_st{r,p}ncpy_chk is used, assume st{r,p}ncpy is available.  */
   fn = builtin_decl_explicit (fcode == BUILT_IN_STPNCPY_CHK && !ignore
 			      ? BUILT_IN_STPNCPY : BUILT_IN_STRNCPY);
-  if (!fn)
+  if (!fn || (!gimple_vdef (stmt) && gimple_in_ssa_p (cfun)))
     return false;
 
   gcall *repl = gimple_build_call (fn, 3, dest, src, len);
@@ -3252,6 +3283,9 @@ gimple_fold_builtin_stpcpy (gimple_stmt_iterator *gsi)
   tree src = gimple_call_arg (stmt, 1);
   tree fn, lenp1;
 
+  if (!gimple_vdef (stmt) && gimple_in_ssa_p (cfun))
+    return false;
+
   /* If the result is unused, replace stpcpy with strcpy.  */
   if (gimple_call_lhs (stmt) == NULL_TREE)
     {
@@ -3369,7 +3403,7 @@ gimple_fold_builtin_snprintf_chk (gimple_stmt_iterator *gsi,
      available.  */
   fn = builtin_decl_explicit (fcode == BUILT_IN_VSNPRINTF_CHK
 			      ? BUILT_IN_VSNPRINTF : BUILT_IN_SNPRINTF);
-  if (!fn)
+  if (!fn || (!gimple_vdef (stmt) && gimple_in_ssa_p (cfun)))
     return false;
 
   /* Replace the called function and the first 5 argument by 3 retaining
@@ -3456,7 +3490,7 @@ gimple_fold_builtin_sprintf_chk (gimple_stmt_iterator *gsi,
   /* If __builtin_{,v}sprintf_chk is used, assume {,v}sprintf is available.  */
   fn = builtin_decl_explicit (fcode == BUILT_IN_VSPRINTF_CHK
 			      ? BUILT_IN_VSPRINTF : BUILT_IN_SPRINTF);
-  if (!fn)
+  if (!fn || (!gimple_vdef (stmt) && gimple_in_ssa_p (cfun)))
     return false;
 
   /* Replace the called function and the first 4 argument by 2 retaining
@@ -3505,7 +3539,7 @@ gimple_fold_builtin_sprintf (gimple_stmt_iterator *gsi)
     return false;
 
   tree fn = builtin_decl_implicit (BUILT_IN_STRCPY);
-  if (!fn)
+  if (!fn || (!gimple_vdef (stmt) && gimple_in_ssa_p (cfun)))
     return false;
 
   /* If the format doesn't contain % args or %%, use strcpy.  */
@@ -3618,7 +3652,8 @@ gimple_fold_builtin_snprintf (gimple_stmt_iterator *gsi)
   tree orig = NULL_TREE;
   const char *fmt_str = NULL;
 
-  if (gimple_call_num_args (stmt) > 4)
+  if (gimple_call_num_args (stmt) > 4
+      || (!gimple_vdef (stmt) && gimple_in_ssa_p (cfun)))
     return false;
 
   if (gimple_call_num_args (stmt) == 4)
@@ -3776,6 +3811,9 @@ gimple_fold_builtin_fprintf (gimple_stmt_iterator *gsi,
   if (!init_target_chars ())
     return false;
 
+  if (!gimple_vdef (stmt) && gimple_in_ssa_p (cfun))
+    return false;
+
   /* If the format doesn't contain % args or %%, use strcpy.  */
   if (strchr (fmt_str, target_percent) == NULL)
     {
@@ -3855,6 +3893,9 @@ gimple_fold_builtin_printf (gimple_stmt_iterator *gsi, tree fmt,
   if (gimple_call_lhs (stmt) != NULL_TREE)
     return false;
 
+  if (!gimple_vdef (stmt) && gimple_in_ssa_p (cfun))
+    return false;
+
   /* Check whether the format is a literal string constant.  */
   fmt_str = c_getstr (fmt);
   if (fmt_str == NULL)
@@ -4096,6 +4137,9 @@ gimple_fold_builtin_realloc (gimple_stmt_iterator *gsi)
   tree arg = gimple_call_arg (stmt, 0);
   tree size = gimple_call_arg (stmt, 1);
 
+  if (!gimple_vdef (stmt) && gimple_in_ssa_p (cfun))
+    return false;
+
   if (operand_equal_p (arg, null_pointer_node, 0))
     {
       tree fn_malloc = builtin_decl_implicit (BUILT_IN_MALLOC);
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr117358.c b/gcc/testsuite/gcc.c-torture/compile/pr117358.c
new file mode 100644
index 00000000000..023284aff96
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/compile/pr117358.c
@@ -0,0 +1,17 @@
+/* PR tree-optimization/117358 */
+
+char a;
+/* This attribute is bogus, snprintf isn't const.  Just verify we don't ICE on it.  */
+int __attribute__((const)) snprintf (char *, __SIZE_TYPE__, const char *, ...);
+
+long
+foo (long d) 
+{ 
+  return snprintf (&a, d, ""); 
+}
+
+int
+bar (void) 
+{ 
+  return foo (1); 
+}

commit cfd7c674139097d12546d034f7869e272457aa56
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Wed Feb 5 13:16:17 2025

    cselib: For CALL_INSNs to const/pure fns invalidate memory below sp [PR117239]
    
    The following testcase is miscompiled on x86_64 during postreload.
    After reload (with IPA-RA figuring out the calls don't modify any
    registers but %rax for return value) postreload sees
    (insn 14 12 15 2 (set (mem:DI (plus:DI (reg/f:DI 7 sp)
                    (const_int 16 [0x10])) [0  S8 A64])
            (reg:DI 1 dx [orig:105 q+16 ] [105])) "pr117239.c":18:7 95 {*movdi_internal}
         (nil))
    (call_insn/i 15 14 16 2 (set (reg:SI 0 ax)
            (call (mem:QI (symbol_ref:DI ("baz") [flags 0x3]  <function_decl 0x7ffb2e2bdf00 r>) [0 baz S1 A8])
                (const_int 24 [0x18]))) "pr117239.c":18:7 1476 {*call_value}
         (expr_list:REG_CALL_DECL (symbol_ref:DI ("baz") [flags 0x3]  <function_decl 0x7ffb2e2bdf00 baz>)
            (expr_list:REG_EH_REGION (const_int 0 [0])
                (nil)))
        (nil))
    (insn 16 15 18 2 (parallel [
                (set (reg/f:DI 7 sp)
                    (plus:DI (reg/f:DI 7 sp)
                        (const_int 24 [0x18])))
                (clobber (reg:CC 17 flags))
            ]) "pr117239.c":18:7 285 {*adddi_1}
         (expr_list:REG_ARGS_SIZE (const_int 0 [0])
            (nil)))
    ...
    (call_insn/i 19 18 21 2 (set (reg:SI 0 ax)
            (call (mem:QI (symbol_ref:DI ("foo") [flags 0x3]  <function_decl 0x7ffb2e2bdb00 l>) [0 foo S1 A8])
                (const_int 0 [0]))) "pr117239.c":19:3 1476 {*call_value}
         (expr_list:REG_CALL_DECL (symbol_ref:DI ("foo") [flags 0x3]  <function_decl 0x7ffb2e2bdb00 foo>)
            (expr_list:REG_EH_REGION (const_int 0 [0])
                (nil)))
        (nil))
    (insn 21 19 26 2 (parallel [
                (set (reg/f:DI 7 sp)
                    (plus:DI (reg/f:DI 7 sp)
                        (const_int -24 [0xffffffffffffffe8])))
                (clobber (reg:CC 17 flags))
            ]) "pr117239.c":19:3 discrim 1 285 {*adddi_1}
         (expr_list:REG_ARGS_SIZE (const_int 24 [0x18])
            (nil)))
    (insn 26 21 24 2 (set (mem:DI (plus:DI (reg/f:DI 7 sp)
                    (const_int 16 [0x10])) [0  S8 A64])
            (reg:DI 1 dx [orig:105 q+16 ] [105])) "pr117239.c":19:3 discrim 1 95 {*movdi_internal}
         (nil))
    i.e.
            movq    %rdx, 16(%rsp)
            call    baz
            addq    $24, %rsp
    ...
            call    foo
            subq    $24, %rsp
            movq    %rdx, 16(%rsp)
    Now, postreload uses cselib and cselib remembered that %rdx value has been
    stored into 16(%rsp).  Both baz and foo are pure calls.  If they weren't,
    when processing those CALL_INSNs cselib would invalidate all MEMs
          if (RTL_LOOPING_CONST_OR_PURE_CALL_P (insn)
              || !(RTL_CONST_OR_PURE_CALL_P (insn)))
            cselib_invalidate_mem (callmem);
    where callmem is (mem:BLK (scratch)).  But they are pure, so instead the
    code just invalidates the argument slots from CALL_INSN_FUNCTION_USAGE.
    The calls actually clobber more than that, even const/pure calls clobber
    all memory below the stack pointer.  And that is something that hasn't been
    invalidated.  In this failing testcase, the call to baz is not a big deal,
    we don't have anything remembered in memory below %rsp at that call.
    But then we increment %rsp by 24, so the %rsp+16 is now 8 bytes below stack
    and do the call to foo.  And that call now actually, not just in theory,
    clobbers the memory below the stack pointer (in particular overwrites it
    with the return value).  But cselib does not invalidate.  Then %rsp
    is decremented again (in preparation for another call, to bar) and cselib
    is processing store of %rdx (which IPA-RA says has not been modified by
    either baz or foo calls) to %rsp + 16, and it sees the memory already has
    that value, so the store is useless, let's remove it.
    But it is not, the call to foo has changed it, so it needs to be stored
    again.
    
    The following patch adds targetted invalidation of memory below stack
    pointer (or on SPARC memory below stack pointer + 2047 when stack bias is
    used, or on PA memory above stack pointer instead).
    It does so only in !ACCUMULATE_OUTGOING_ARGS or cfun->calls_alloca functions,
    because in other functions the stack pointer should be constant from
    the end of prologue till start of epilogue and so nothing should be stored
    within the function below the stack pointer.
    
    Now, memory below stack pointer is special, except for functions using
    alloca/VLAs I believe no addressable memory should be there, it should be
    purely outgoing function argument area, if we take address of some automatic
    variable, it should live all the time above the outgoing function argument
    area.  So on top of just trying to flush memory below stack pointer
    (represented by %rsp - PTRDIFF_MAX with PTRDIFF_MAX size on most arches),
    the patch tries to optimize and only invalidate memory that has address
    clearly derived from stack pointer (memory with other bases is not
    invalidated) and if we can prove (we see same SP_DERIVED_VALUE_P bases in
    both VALUEs) it is above current stack, also don't call
    canon_anti_dependence which might just give up in certain cases.
    
    I've gathered statistics from x86_64-linux and i686-linux
    bootstraps/regtests.  During -m64 compilations from those, there were
    3718396 + 42634 + 27761 cases of processing MEMs in cselib_invalidate_mem
    (callmem[1]) calls, the first number is number of MEMs not invalidated
    because of the optimization, i.e.
    +             if (sp_derived_base == NULL_RTX)
    +               {
    +                 has_mem = true;
    +                 num_mems++;
    +                 p = &(*p)->next;
    +                 continue;
    +               }
    in the patch, the second number is number of MEMs not invalidated because
    canon_anti_dependence returned false and finally the last number is number
    of MEMs actually invalidated (so that is what hasn't been invalidated
    before).  During -m32 compilations the numbers were
    1422412 + 39354 + 16509 with the same meaning.
    
    Note, when there is no red zone, in theory even the sp = sp + incr
    instruction invalidates memory below the new stack pointer, as signal
    can come and overwrite the memory.  So maybe we should be invalidating
    something at those instructions as well.  But in leaf functions we certainly
    can have even addressable automatic vars in the red zone (which would make
    it harder to distinguish), on the other side aren't normally storing
    anything below the red zone, and in non-leaf it should normally be just the
    outgoing arguments area.
    
    2025-02-05  Jakub Jelinek  <jakub@redhat.com>
    
            PR rtl-optimization/117239
            * cselib.cc: Include predict.h.
            (callmem): Change type from rtx to rtx[2].
            (cselib_preserve_only_values): Use callmem[0] rather than callmem.
            (cselib_invalidate_mem): Optimize and don't try to invalidate
            for the mem_rtx == callmem[1] case MEMs which clearly can't be
            below the stack pointer.
            (cselib_process_insn): Use callmem[0] rather than callmem.
            For const/pure calls also call cselib_invalidate_mem (callmem[1])
            in !ACCUMULATE_OUTGOING_ARGS or cfun->calls_alloca functions.
            (cselib_init): Initialize callmem[0] rather than callmem and also
            initialize callmem[1].
    
            * gcc.dg/pr117239.c: New test.
    
    (cherry picked from commit 886ce970eb096bb302228c891f0c8a889c79ad40)

diff --git a/gcc/cselib.cc b/gcc/cselib.cc
index 212d8a6c485..2382e994ebc 100644
--- a/gcc/cselib.cc
+++ b/gcc/cselib.cc
@@ -33,6 +33,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "cselib.h"
 #include "function-abi.h"
 #include "alias.h"
+#include "predict.h"
 
 /* A list of cselib_val structures.  */
 struct elt_list
@@ -248,8 +249,9 @@ static unsigned int *used_regs;
 static unsigned int n_used_regs;
 
 /* We pass this to cselib_invalidate_mem to invalidate all of
-   memory for a non-const call instruction.  */
-static GTY(()) rtx callmem;
+   memory for a non-const call instruction and memory below stack pointer
+   for const/pure calls.  */
+static GTY(()) rtx callmem[2];
 
 /* Set by discard_useless_locs if it deleted the last location of any
    value.  */
@@ -808,7 +810,7 @@ cselib_preserve_only_values (void)
   for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)
     cselib_invalidate_regno (i, reg_raw_mode[i]);
 
-  cselib_invalidate_mem (callmem);
+  cselib_invalidate_mem (callmem[0]);
 
   remove_useless_values ();
 
@@ -2600,6 +2602,8 @@ cselib_invalidate_mem (rtx mem_rtx)
       struct elt_loc_list **p = &v->locs;
       bool had_locs = v->locs != NULL;
       rtx_insn *setting_insn = v->locs ? v->locs->setting_insn : NULL;
+      rtx sp_base = NULL_RTX;
+      HOST_WIDE_INT sp_off = 0;
 
       while (*p)
 	{
@@ -2614,6 +2618,114 @@ cselib_invalidate_mem (rtx mem_rtx)
 	      p = &(*p)->next;
 	      continue;
 	    }
+
+	  /* When invalidating memory below the stack pointer for const/pure
+	     calls and alloca/VLAs aren't used, attempt to optimize.  Values
+	     stored into area sometimes below the stack pointer shouldn't be
+	     addressable and should be stored just through stack pointer
+	     derived expressions, so don't invalidate MEMs not using stack
+	     derived addresses, or if the MEMs clearly aren't below the stack
+	     pointer.  This isn't a fully conservative approach, the hope is
+	     that invalidating more MEMs than this isn't actually needed.  */
+	  if (mem_rtx == callmem[1]
+	      && num_mems < param_max_cselib_memory_locations
+	      && GET_CODE (XEXP (x, 0)) == VALUE
+	      && !cfun->calls_alloca)
+	    {
+	      cselib_val *v2 = CSELIB_VAL_PTR (XEXP (x, 0));
+	      rtx x_base = NULL_RTX;
+	      HOST_WIDE_INT x_off = 0;
+	      if (SP_DERIVED_VALUE_P (v2->val_rtx))
+		x_base = v2->val_rtx;
+	      else
+		for (struct elt_loc_list *l = v2->locs; l; l = l->next)
+		  if (GET_CODE (l->loc) == PLUS
+		      && GET_CODE (XEXP (l->loc, 0)) == VALUE
+		      && SP_DERIVED_VALUE_P (XEXP (l->loc, 0))
+		      && CONST_INT_P (XEXP (l->loc, 1)))
+		    {
+		      x_base = XEXP (l->loc, 0);
+		      x_off = INTVAL (XEXP (l->loc, 1));
+		      break;
+		    }
+	      /* If x_base is NULL here, don't invalidate x as its address
+		 isn't derived from sp such that it could be in outgoing
+		 argument area of some call in !ACCUMULATE_OUTGOING_ARGS
+		 function.  */
+	      if (x_base)
+		{
+		  if (sp_base == NULL_RTX)
+		    {
+		      if (cselib_val *v3
+			  = cselib_lookup_1 (stack_pointer_rtx, Pmode, 0,
+					     VOIDmode))
+			{
+			  if (SP_DERIVED_VALUE_P (v3->val_rtx))
+			    sp_base = v3->val_rtx;
+			  else
+			    for (struct elt_loc_list *l = v3->locs;
+				 l; l = l->next)
+			      if (GET_CODE (l->loc) == PLUS
+				  && GET_CODE (XEXP (l->loc, 0)) == VALUE
+				  && SP_DERIVED_VALUE_P (XEXP (l->loc, 0))
+				  && CONST_INT_P (XEXP (l->loc, 1)))
+				{
+				  sp_base = XEXP (l->loc, 0);
+				  sp_off = INTVAL (XEXP (l->loc, 1));
+				  break;
+				}
+			}
+		      if (sp_base == NULL_RTX)
+			sp_base = pc_rtx;
+		    }
+		  /* Otherwise, if x_base and sp_base are the same,
+		     we know that x_base + x_off is the x's address and
+		     sp_base + sp_off is current value of stack pointer,
+		     so try to determine if x is certainly not below stack
+		     pointer.  */
+		  if (sp_base == x_base)
+		    {
+		      if (STACK_GROWS_DOWNWARD)
+			{
+			  HOST_WIDE_INT off = sp_off;
+#ifdef STACK_ADDRESS_OFFSET
+			  /* On SPARC take stack pointer bias into account as
+			     well.  */
+			  off += (STACK_ADDRESS_OFFSET
+				  - FIRST_PARM_OFFSET (current_function_decl));
+#endif
+			  if (x_off >= off)
+			    /* x is at or above the current stack pointer,
+			       no need to invalidate it.  */
+			    x_base = NULL_RTX;
+			}
+		      else
+			{
+			  HOST_WIDE_INT sz;
+			  enum machine_mode mode = GET_MODE (x);
+			  if ((MEM_SIZE_KNOWN_P (x)
+			       && MEM_SIZE (x).is_constant (&sz))
+			      || (mode != BLKmode
+				  && GET_MODE_SIZE (mode).is_constant (&sz)))
+			    if (x_off < sp_off
+				&& ((HOST_WIDE_INT) ((unsigned HOST_WIDE_INT)
+						     x_off + sz) <= sp_off))
+			      /* x's end is below or at the current stack
+				 pointer in !STACK_GROWS_DOWNWARD target,
+				 no need to invalidate it.  */
+			      x_base = NULL_RTX;
+			 }
+		    }
+		}
+	      if (x_base == NULL_RTX)
+		{
+		  has_mem = true;
+		  num_mems++;
+		  p = &(*p)->next;
+		  continue;
+		}
+	    }
+
 	  if (num_mems < param_max_cselib_memory_locations
 	      && ! canon_anti_dependence (x, false, mem_rtx,
 					  GET_MODE (mem_rtx), mem_addr))
@@ -3166,14 +3278,24 @@ cselib_process_insn (rtx_insn *insn)
 	 as if they were regular functions.  */
       if (RTL_LOOPING_CONST_OR_PURE_CALL_P (insn)
 	  || !(RTL_CONST_OR_PURE_CALL_P (insn)))
-	cselib_invalidate_mem (callmem);
+	cselib_invalidate_mem (callmem[0]);
       else
-	/* For const/pure calls, invalidate any argument slots because
-	   they are owned by the callee.  */
-	for (x = CALL_INSN_FUNCTION_USAGE (insn); x; x = XEXP (x, 1))
-	  if (GET_CODE (XEXP (x, 0)) == USE
-	      && MEM_P (XEXP (XEXP (x, 0), 0)))
-	    cselib_invalidate_mem (XEXP (XEXP (x, 0), 0));
+	{
+	  /* For const/pure calls, invalidate any argument slots because
+	     they are owned by the callee.  */
+	  for (x = CALL_INSN_FUNCTION_USAGE (insn); x; x = XEXP (x, 1))
+	    if (GET_CODE (XEXP (x, 0)) == USE
+		&& MEM_P (XEXP (XEXP (x, 0), 0)))
+	      cselib_invalidate_mem (XEXP (XEXP (x, 0), 0));
+	  /* And invalidate memory below the stack (or above for
+	     !STACK_GROWS_DOWNWARD), as even const/pure call can invalidate
+	     that.  Do this only if !ACCUMULATE_OUTGOING_ARGS or if
+	     cfun->calls_alloca, otherwise the stack pointer shouldn't be
+	     changing in the middle of the function and nothing should be
+	     stored below the stack pointer.  */
+	  if (!ACCUMULATE_OUTGOING_ARGS || cfun->calls_alloca)
+	    cselib_invalidate_mem (callmem[1]);
+	}
     }
 
   cselib_record_sets (insn);
@@ -3226,8 +3348,31 @@ cselib_init (int record_what)
 
   /* (mem:BLK (scratch)) is a special mechanism to conflict with everything,
      see canon_true_dependence.  This is only created once.  */
-  if (! callmem)
-    callmem = gen_rtx_MEM (BLKmode, gen_rtx_SCRATCH (VOIDmode));
+  if (! callmem[0])
+    callmem[0] = gen_rtx_MEM (BLKmode, gen_rtx_SCRATCH (VOIDmode));
+  /* Similarly create a MEM representing roughly everything below
+     the stack for STACK_GROWS_DOWNWARD targets or everything above
+     it otherwise.  Do this only when !ACCUMULATE_OUTGOING_ARGS or
+     if cfun->calls_alloca, otherwise the stack pointer shouldn't be
+     changing in the middle of the function and nothing should be stored
+     below the stack pointer.  */
+  if (!callmem[1] && (!ACCUMULATE_OUTGOING_ARGS || cfun->calls_alloca))
+    {
+      if (STACK_GROWS_DOWNWARD)
+	{
+	  unsigned HOST_WIDE_INT off = -(GET_MODE_MASK (Pmode) >> 1);
+#ifdef STACK_ADDRESS_OFFSET
+	  /* On SPARC take stack pointer bias into account as well.  */
+	  off += (STACK_ADDRESS_OFFSET
+		  - FIRST_PARM_OFFSET (current_function_decl)));
+#endif
+	  callmem[1] = plus_constant (Pmode, stack_pointer_rtx, off);
+	}
+      else
+	callmem[1] = stack_pointer_rtx;
+      callmem[1] = gen_rtx_MEM (BLKmode, callmem[1]);
+      set_mem_size (callmem[1], GET_MODE_MASK (Pmode) >> 1);
+    }
 
   cselib_nregs = max_reg_num ();
 
diff --git a/gcc/testsuite/gcc.dg/pr117239.c b/gcc/testsuite/gcc.dg/pr117239.c
new file mode 100644
index 00000000000..0ff33d19677
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr117239.c
@@ -0,0 +1,42 @@
+/* PR rtl-optimization/117239 */
+/* { dg-do run } */
+/* { dg-options "-fno-inline -O2" } */
+/* { dg-additional-options "-fschedule-insns" { target i?86-*-* x86_64-*-* } } */
+
+int a, b, c = 1, d;
+
+int
+foo (void)
+{
+  return a;
+}
+
+struct A {
+  int e, f, g, h;
+  short i;
+  int j;
+};
+
+void
+bar (int x, struct A y)
+{
+  if (y.j == 1)
+    c = 0;
+}
+
+int
+baz (struct A x)
+{
+  return b;
+}
+
+int
+main ()
+{
+  struct A k = { 0, 0, 0, 0, 0, 1 };
+  d = baz (k);
+  bar (foo (), k);
+  if (c != 0)
+    __builtin_abort ();
+  return 0;
+}

commit 5499c332a60a6928274796af0667d40719bf0715
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Wed Feb 5 14:06:42 2025

    cselib: Fix up previous patch for SPARC [PR117239]
    
    Sorry, our CI bot just notified me I broke SPARC build.  There are two
     #ifdef STACK_ADDRESS_OFFSET
    guarded snippets and the macro is only defined on SPARC target, so I didn't
    notice there was a syntax error.
    
    Fixed thusly.
    
    2025-02-05  Jakub Jelinek  <jakub@redhat.com>
    
            PR rtl-optimization/117239
            * cselib.cc (cselib_init): Remove spurious closing paren in
            the #ifdef STACK_ADDRESS_OFFSET specific code.
    
    (cherry picked from commit 6094801d6fd7849d2d95ce78f7c6ef01686b9f63)

diff --git a/gcc/cselib.cc b/gcc/cselib.cc
index 2382e994ebc..f0a8f2c7f8f 100644
--- a/gcc/cselib.cc
+++ b/gcc/cselib.cc
@@ -3364,7 +3364,7 @@ cselib_init (int record_what)
 #ifdef STACK_ADDRESS_OFFSET
 	  /* On SPARC take stack pointer bias into account as well.  */
 	  off += (STACK_ADDRESS_OFFSET
-		  - FIRST_PARM_OFFSET (current_function_decl)));
+		  - FIRST_PARM_OFFSET (current_function_decl));
 #endif
 	  callmem[1] = plus_constant (Pmode, stack_pointer_rtx, off);
 	}

commit 4b9f2877e334b4108c33259753acfdd27820b4f5
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Thu Feb 27 08:48:18 2025

    alias: Perform offset arithmetics in poly_offset_int rather than poly_int64 [PR118819]
    
    This PR is about ubsan error on the c - cx1 + cy1 evaluation in the first
    hunk.
    
    The following patch hopefully fixes that by doing the additions/subtractions
    in poly_offset_int rather than poly_int64 and then converting back to poly_int64.
    If it doesn't fit, -1 is returned (which means it is unknown if there is a conflict
    or not).
    
    2025-02-27  Jakub Jelinek  <jakub@redhat.com>
    
            PR middle-end/118819
            * alias.cc (memrefs_conflict_p): Perform arithmetics on c, xsize and
            ysize in poly_offset_int and return -1 if it is not representable in
            poly_int64.
    
    (cherry picked from commit b570f48c3dfb9ca3d640467cff67e569904009d4)

diff --git a/gcc/alias.cc b/gcc/alias.cc
index 808e2095d9b..fab7161f694 100644
--- a/gcc/alias.cc
+++ b/gcc/alias.cc
@@ -2533,19 +2533,39 @@ memrefs_conflict_p (poly_int64 xsize, rtx x, poly_int64 ysize, rtx y,
 	    return memrefs_conflict_p (xsize, x1, ysize, y1, c);
 	  if (poly_int_rtx_p (x1, &cx1))
 	    {
+	      poly_offset_int co = c;
+	      co -= cx1;
 	      if (poly_int_rtx_p (y1, &cy1))
-		return memrefs_conflict_p (xsize, x0, ysize, y0,
-					   c - cx1 + cy1);
+		{
+		  co += cy1;
+		  if (!co.to_shwi (&c))
+		    return -1;
+		  return memrefs_conflict_p (xsize, x0, ysize, y0, c);
+		}
+	      else if (!co.to_shwi (&c))
+		return -1;
 	      else
-		return memrefs_conflict_p (xsize, x0, ysize, y, c - cx1);
+		return memrefs_conflict_p (xsize, x0, ysize, y, c);
 	    }
 	  else if (poly_int_rtx_p (y1, &cy1))
-	    return memrefs_conflict_p (xsize, x, ysize, y0, c + cy1);
+	    {
+	      poly_offset_int co = c;
+	      co += cy1;
+	      if (!co.to_shwi (&c))
+		return -1;
+	      return memrefs_conflict_p (xsize, x, ysize, y0, c);
+	    }
 
 	  return -1;
 	}
       else if (poly_int_rtx_p (x1, &cx1))
-	return memrefs_conflict_p (xsize, x0, ysize, y, c - cx1);
+	{
+	  poly_offset_int co = c;
+	  co -= cx1;
+	  if (!co.to_shwi (&c))
+	    return -1;
+	  return memrefs_conflict_p (xsize, x0, ysize, y, c);
+	}
     }
   else if (GET_CODE (y) == PLUS)
     {
@@ -2561,7 +2581,13 @@ memrefs_conflict_p (poly_int64 xsize, rtx x, poly_int64 ysize, rtx y,
 
       poly_int64 cy1;
       if (poly_int_rtx_p (y1, &cy1))
-	return memrefs_conflict_p (xsize, x, ysize, y0, c + cy1);
+	{
+	  poly_offset_int co = c;
+	  co += cy1;
+	  if (!co.to_shwi (&c))
+	    return -1;
+	  return memrefs_conflict_p (xsize, x, ysize, y0, c);
+	}
       else
 	return -1;
     }
@@ -2614,8 +2640,16 @@ memrefs_conflict_p (poly_int64 xsize, rtx x, poly_int64 ysize, rtx y,
 	  if (maybe_gt (xsize, 0))
 	    xsize = -xsize;
 	  if (maybe_ne (xsize, 0))
-	    xsize += sc + 1;
-	  c -= sc + 1;
+	    {
+	      poly_offset_int xsizeo = xsize;
+	      xsizeo += sc + 1;
+	      if (!xsizeo.to_shwi (&xsize))
+		return -1;
+	    }
+	  poly_offset_int co = c;
+	  co -= sc + 1;
+	  if (!co.to_shwi (&c))
+	    return -1;
 	  return memrefs_conflict_p (xsize, canon_rtx (XEXP (x, 0)),
 				     ysize, y, c);
 	}
@@ -2629,8 +2663,16 @@ memrefs_conflict_p (poly_int64 xsize, rtx x, poly_int64 ysize, rtx y,
 	  if (maybe_gt (ysize, 0))
 	    ysize = -ysize;
 	  if (maybe_ne (ysize, 0))
-	    ysize += sc + 1;
-	  c += sc + 1;
+	    {
+	      poly_offset_int ysizeo = ysize;
+	      ysizeo += sc + 1;
+	      if (!ysizeo.to_shwi (&ysize))
+		return -1;
+	    }
+	  poly_offset_int co = c;
+	  co += sc + 1;
+	  if (!co.to_shwi (&c))
+	    return -1;
 	  return memrefs_conflict_p (xsize, x,
 				     ysize, canon_rtx (XEXP (y, 0)), c);
 	}
@@ -2641,7 +2683,11 @@ memrefs_conflict_p (poly_int64 xsize, rtx x, poly_int64 ysize, rtx y,
       poly_int64 cx, cy;
       if (poly_int_rtx_p (x, &cx) && poly_int_rtx_p (y, &cy))
 	{
-	  c += cy - cx;
+	  poly_offset_int co = c;
+	  co += cy;
+	  co -= cx;
+	  if (!co.to_shwi (&c))
+	    return -1;
 	  return offset_overlap_p (c, xsize, ysize);
 	}
 

commit 1dd54c5ad3930e27c4206ec3c08f4baecd9b4543
Author: Stefan Schulze Frielinghaus <stefansf@gcc.gnu.org>
Date:   Wed May 14 09:22:00 2025

    s390: Fix tf_to_fprx2
    
    Insn tf_to_fprx2 moves a TF value into a floating-point register pair.
    For alternative 0, the input is a vector register, however, in the else
    case instruction ldr is emitted which expects floating-point register
    operands only.  Thus, this works only for vector registers which overlap
    with floating-point registers.  Replace ldr with vlr so that the
    remaining vector registers are dealt with, too.  Emitting a vlr instead
    of a ldr is fine since the destination register %v0 is part of a
    floating-point register pair which means that the low half of %v0 is
    ignored in the end anyway and therefore may be clobbered.
    
    gcc/ChangeLog:
    
            * config/s390/vector.md: Fix tf_to_fprx2 by using vlr instead of
            ldr.
    
    (cherry picked from commit 8519b8ba9dd9567a5f90966351c1e758dbf511a4)

diff --git a/gcc/config/s390/vector.md b/gcc/config/s390/vector.md
index 35defb7043a..a79f21b05c7 100644
--- a/gcc/config/s390/vector.md
+++ b/gcc/config/s390/vector.md
@@ -938,7 +938,7 @@
       else
 	{
 	  reg_pair += 2;  // get rid of prefix %f
-	  snprintf (buf, sizeof (buf), "ldr\t%%f0,%%f1;vpdi\t%%%%v%s,%%v1,%%%%v%s,5", reg_pair, reg_pair);
+	  snprintf (buf, sizeof (buf), "vlr\t%%v0,%%v1;vpdi\t%%%%v%s,%%v1,%%%%v%s,5", reg_pair, reg_pair);
 	  output_asm_insn (buf, operands);
 	  return "";
 	}

commit fb04c0409f668bcb4248ccfcdb512fb743b87d8e
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Tue May 27 02:23:19 2025

    Daily bump.

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 541b6babe73..5796ada5214 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,83 @@
+2025-05-26  Stefan Schulze Frielinghaus  <stefansf@gcc.gnu.org>
+
+	Backported from master:
+	2025-05-14  Stefan Schulze Frielinghaus  <stefansf@gcc.gnu.org>
+
+	* config/s390/vector.md: Fix tf_to_fprx2 by using vlr instead of
+	ldr.
+
+2025-05-26  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2025-02-27  Jakub Jelinek  <jakub@redhat.com>
+
+	PR middle-end/118819
+	* alias.cc (memrefs_conflict_p): Perform arithmetics on c, xsize and
+	ysize in poly_offset_int and return -1 if it is not representable in
+	poly_int64.
+
+2025-05-26  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2025-02-05  Jakub Jelinek  <jakub@redhat.com>
+
+	PR rtl-optimization/117239
+	* cselib.cc (cselib_init): Remove spurious closing paren in
+	the #ifdef STACK_ADDRESS_OFFSET specific code.
+
+2025-05-26  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2025-02-05  Jakub Jelinek  <jakub@redhat.com>
+
+	PR rtl-optimization/117239
+	* cselib.cc: Include predict.h.
+	(callmem): Change type from rtx to rtx[2].
+	(cselib_preserve_only_values): Use callmem[0] rather than callmem.
+	(cselib_invalidate_mem): Optimize and don't try to invalidate
+	for the mem_rtx == callmem[1] case MEMs which clearly can't be
+	below the stack pointer.
+	(cselib_process_insn): Use callmem[0] rather than callmem.
+	For const/pure calls also call cselib_invalidate_mem (callmem[1])
+	in !ACCUMULATE_OUTGOING_ARGS or cfun->calls_alloca functions.
+	(cselib_init): Initialize callmem[0] rather than callmem and also
+	initialize callmem[1].
+
+2025-05-26  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2024-11-28  Jakub Jelinek  <jakub@redhat.com>
+
+	PR tree-optimization/117358
+	* gimple-fold.cc (gimple_fold_builtin_memory_op): Punt if stmt has no
+	vdef in ssa form.
+	(gimple_fold_builtin_bcmp): Punt if stmt has no vuse in ssa form.
+	(gimple_fold_builtin_bcopy): Punt if stmt has no vdef in ssa form.
+	(gimple_fold_builtin_bzero): Likewise.
+	(gimple_fold_builtin_memset): Likewise.  Use return false instead of
+	return NULL_TREE.
+	(gimple_fold_builtin_strcpy): Punt if stmt has no vdef in ssa form.
+	(gimple_fold_builtin_strncpy): Likewise.
+	(gimple_fold_builtin_strchr): Punt if stmt has no vuse in ssa form.
+	(gimple_fold_builtin_strstr): Likewise.
+	(gimple_fold_builtin_strcat): Punt if stmt has no vdef in ssa form.
+	(gimple_fold_builtin_strcat_chk): Likewise.
+	(gimple_fold_builtin_strncat): Likewise.
+	(gimple_fold_builtin_strncat_chk): Likewise.
+	(gimple_fold_builtin_string_compare): Likewise.
+	(gimple_fold_builtin_fputs): Likewise.
+	(gimple_fold_builtin_memory_chk): Likewise.
+	(gimple_fold_builtin_stxcpy_chk): Likewise.
+	(gimple_fold_builtin_stxncpy_chk): Likewise.
+	(gimple_fold_builtin_stpcpy): Likewise.
+	(gimple_fold_builtin_snprintf_chk): Likewise.
+	(gimple_fold_builtin_sprintf_chk): Likewise.
+	(gimple_fold_builtin_sprintf): Likewise.
+	(gimple_fold_builtin_snprintf): Likewise.
+	(gimple_fold_builtin_fprintf): Likewise.
+	(gimple_fold_builtin_printf): Likewise.
+	(gimple_fold_builtin_realloc): Likewise.
+
 2025-05-25  Michael J. Eager  <eager@eagercon.com>
 
 	PR target/86772
diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index dbf258be4a2..ed9a6b1f3e6 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20250526
+20250527
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 23d940b9d1b..66360e6b9e9 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,19 @@
+2025-05-26  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2025-02-05  Jakub Jelinek  <jakub@redhat.com>
+
+	PR rtl-optimization/117239
+	* gcc.dg/pr117239.c: New test.
+
+2025-05-26  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2024-11-28  Jakub Jelinek  <jakub@redhat.com>
+
+	PR tree-optimization/117358
+	* gcc.c-torture/compile/pr117358.c: New test.
+
 2025-05-25  Harald Anlauf  <anlauf@gmx.de>
 
 	Backported from master:

commit b380d260ba56b30cba7681c43e1b699d05152cdc
Author: Georg-Johann Lay <avr@gjlay.de>
Date:   Tue May 27 09:43:57 2025

    AVR: target/120441 - Fix f7_exp for |x| ≥ 512.
    
    f7_exp limited exponents to 512, but 1023 * ln2 ≈ 709,
    hence 1024 is a correct limit.
    
    libgcc/config/avr/libf7/
            PR target/120441
            * libf7.c (f7_exp): Limit aa->expo to 10 (not to 9).
    
    (cherry picked from commit 672569cee76a1927d14b5eb754a5ff0b9cee1bc8)

diff --git a/libgcc/config/avr/libf7/libf7.c b/libgcc/config/avr/libf7/libf7.c
index 375becb854c..eb27dc7385d 100644
--- a/libgcc/config/avr/libf7/libf7.c
+++ b/libgcc/config/avr/libf7/libf7.c
@@ -1639,10 +1639,10 @@ void f7_exp (f7_t *cc, const f7_t *aa)
     return f7_set_nan (cc);
 
   /* The maximal exponent of 2 for a double is 1023, hence we may limit
-     to  |A| < 1023 * ln2 ~ 709.  We limit to  1024 ~ 1.99 * 2^9  */
+     to  |A| < 1023 * ln2 ~ 709.  We limit to  1024 = 2^10  */
 
   if (f7_class_inf (a_class)
-      || (f7_class_nonzero (a_class) && aa->expo >= 9))
+      || (f7_class_nonzero (a_class) && aa->expo >= 10))
     {
       if (f7_class_sign (a_class))
 	return f7_clr (cc);

commit 85f466ed0d4da336fadd01e43d764326cbabdecb
Author: Patrick Palka <ppalka@redhat.com>
Date:   Thu May 15 17:07:53 2025

    c++: unifying specializations of non-primary tmpls [PR120161]
    
    Here unification of P=Wrap<int>::type, A=Wrap<long>::type wrongly
    succeeds ever since r14-4112 which made the RECORD_TYPE case of unify
    no longer recurse into template arguments for non-primary templates
    (since they're a non-deduced context) and so the int/long mismatch that
    makes the two types distinct goes unnoticed.
    
    In the case of (comparing specializations of) a non-primary template,
    unify should still go on to compare the types directly before returning
    success.
    
            PR c++/120161
    
    gcc/cp/ChangeLog:
    
            * pt.cc (unify) <case RECORD_TYPE>: When comparing specializations
            of a non-primary template, still perform a type comparison.
    
    gcc/testsuite/ChangeLog:
    
            * g++.dg/template/unify13.C: New test.
    
    Reviewed-by: Jason Merrill <jason@redhat.com>
    (cherry picked from commit 0c430503f2849ebb20105695b8ad40d43d797c7b)

diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc
index 65fa85b0610..fb9b407c453 100644
--- a/gcc/cp/pt.cc
+++ b/gcc/cp/pt.cc
@@ -25299,10 +25299,10 @@ unify (tree tparms, tree targs, tree parm, tree arg, int strict,
 			  INNERMOST_TEMPLATE_ARGS (CLASSTYPE_TI_ARGS (parm)),
 			  INNERMOST_TEMPLATE_ARGS (CLASSTYPE_TI_ARGS (t)),
 			  UNIFY_ALLOW_NONE, explain_p);
-	  else
-	    return unify_success (explain_p);
+	  gcc_checking_assert (t == arg);
 	}
-      else if (!same_type_ignoring_top_level_qualifiers_p (parm, arg))
+
+      if (!same_type_ignoring_top_level_qualifiers_p (parm, arg))
 	return unify_type_mismatch (explain_p, parm, arg);
       return unify_success (explain_p);
 
diff --git a/gcc/testsuite/g++.dg/template/unify13.C b/gcc/testsuite/g++.dg/template/unify13.C
new file mode 100644
index 00000000000..ec7ca9d17a4
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/unify13.C
@@ -0,0 +1,18 @@
+// PR c++/120161
+
+template<class T, class U>
+struct mp_list { };
+
+template<class T>
+struct Wrap { struct type { }; };
+
+struct A : mp_list<Wrap<int>::type, void>
+         , mp_list<Wrap<long>::type, void> { };
+
+template<class U>
+void f(mp_list<Wrap<int>::type, U>*);
+
+int main() {
+  A a;
+  f(&a);
+}

commit 4035c5bb55ea3ae9e249a7aebaf08039346a3e16
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Wed May 28 02:22:29 2025

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index ed9a6b1f3e6..4044138c536 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20250527
+20250528
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 14599c44fb8..56acd079690 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,12 @@
+2025-05-27  Patrick Palka  <ppalka@redhat.com>
+
+	Backported from master:
+	2025-05-15  Patrick Palka  <ppalka@redhat.com>
+
+	PR c++/120161
+	* pt.cc (unify) <case RECORD_TYPE>: When comparing specializations
+	of a non-primary template, still perform a type comparison.
+
 2025-05-23  Release Manager
 
 	* GCC 14.3.0 released.
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 66360e6b9e9..7e4bb673cfb 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,11 @@
+2025-05-27  Patrick Palka  <ppalka@redhat.com>
+
+	Backported from master:
+	2025-05-15  Patrick Palka  <ppalka@redhat.com>
+
+	PR c++/120161
+	* g++.dg/template/unify13.C: New test.
+
 2025-05-26  Jakub Jelinek  <jakub@redhat.com>
 
 	Backported from master:
diff --git a/libgcc/config/avr/libf7/ChangeLog b/libgcc/config/avr/libf7/ChangeLog
index e8474b76d1e..c7dc1d93868 100644
--- a/libgcc/config/avr/libf7/ChangeLog
+++ b/libgcc/config/avr/libf7/ChangeLog
@@ -1,3 +1,11 @@
+2025-05-27  Georg-Johann Lay  <avr@gjlay.de>
+
+	Backported from master:
+	2025-05-27  Georg-Johann Lay  <avr@gjlay.de>
+
+	PR target/120441
+	* libf7.c (f7_exp): Limit aa->expo to 10 (not to 9).
+
 2025-05-23  Release Manager
 
 	* GCC 14.3.0 released.

commit a153c6f9345a3f6cc8094020510121e9a7d9780a
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Thu May 29 02:22:59 2025

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 4044138c536..939851372b3 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20250528
+20250529

commit 7f564d0d8caa32c38cb8efd89c1bb5bf631ef041
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Fri May 30 02:23:53 2025

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 939851372b3..ac274333576 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20250529
+20250530

commit 004bbbb523c9530f94ae3d64d4c9967ff90388bc
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Thu Apr 17 10:57:18 2025

    s390: Use match_scratch instead of scratch in define_split [PR119834]
    
    The following testcase ICEs since r15-1579 (addition of late combiner),
    because *clrmem_short can't be split.
    The problem is that the define_insn uses
       (use (match_operand 1 "nonmemory_operand" "n,a,a,a"))
       (use (match_operand 2 "immediate_operand" "X,R,X,X"))
       (clobber (match_scratch:P 3 "=X,X,X,&a"))
    and define_split assumed that if operands[1] is const_int_operand,
    match_scratch will be always scratch, and it will be reg only if
    it was the last alternative where operands[1] is a reg.
    The pattern doesn't guarantee it though, of course RA will not try to
    uselessly assign a reg there if it is not needed, but during RA
    on the testcase below we match the last alternative, but then comes
    late combiner and propagates const_int 3 into operands[1].  And that
    matches fine, match_scratch matches either scratch or reg and the constraint
    in that case is X for the first variant, so still just fine.  But we won't
    split that because the splitters only expect scratch.
    
    The following patch fixes it by using match_scratch instead of scratch,
    so that it accepts either.
    
    2025-04-17  Jakub Jelinek  <jakub@redhat.com>
    
            PR target/119834
            * config/s390/s390.md (define_split after *cpymem_short): Use
            (clobber (match_scratch N)) instead of (clobber (scratch)).  Use
            (match_dup 4) and operands[4] instead of (match_dup 3) and operands[3]
            in the last of those.
            (define_split after *clrmem_short): Use (clobber (match_scratch N))
            instead of (clobber (scratch)).
            (define_split after *cmpmem_short): Likewise.
    
            * g++.target/s390/pr119834.C: New test.
    
    (cherry picked from commit 22fe83d6fc9f59311241c981bcad58b61e2056d4)

diff --git a/gcc/config/s390/s390.md b/gcc/config/s390/s390.md
index 72e05be9b18..c364880af0a 100644
--- a/gcc/config/s390/s390.md
+++ b/gcc/config/s390/s390.md
@@ -3392,7 +3392,7 @@
         (match_operand:BLK 1 "memory_operand" ""))
    (use (match_operand 2 "const_int_operand" ""))
    (use (match_operand 3 "immediate_operand" ""))
-   (clobber (scratch))]
+   (clobber (match_scratch 4))]
   "reload_completed"
   [(parallel
     [(set (match_dup 0) (match_dup 1))
@@ -3404,7 +3404,7 @@
         (match_operand:BLK 1 "memory_operand" ""))
    (use (match_operand 2 "register_operand" ""))
    (use (match_operand 3 "memory_operand" ""))
-   (clobber (scratch))]
+   (clobber (match_scratch 4))]
   "reload_completed"
   [(parallel
     [(unspec [(match_dup 2) (match_dup 3)
@@ -3418,14 +3418,14 @@
         (match_operand:BLK 1 "memory_operand" ""))
    (use (match_operand 2 "register_operand" ""))
    (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
-   (clobber (scratch))]
+   (clobber (match_scratch 3))]
   "TARGET_Z10 && reload_completed"
   [(parallel
     [(unspec [(match_dup 2) (const_int 0)
-              (label_ref (match_dup 3))] UNSPEC_EXECUTE)
+	      (label_ref (match_dup 4))] UNSPEC_EXECUTE)
      (set (match_dup 0) (match_dup 1))
      (use (const_int 1))])]
-  "operands[3] = gen_label_rtx ();")
+  "operands[4] = gen_label_rtx ();")
 
 (define_split
   [(set (match_operand:BLK 0 "memory_operand" "")
@@ -3644,7 +3644,7 @@
         (const_int 0))
    (use (match_operand 1 "const_int_operand" ""))
    (use (match_operand 2 "immediate_operand" ""))
-   (clobber (scratch))
+   (clobber (match_scratch 3))
    (clobber (reg:CC CC_REGNUM))]
   "reload_completed"
   [(parallel
@@ -3658,7 +3658,7 @@
         (const_int 0))
    (use (match_operand 1 "register_operand" ""))
    (use (match_operand 2 "memory_operand" ""))
-   (clobber (scratch))
+   (clobber (match_scratch 3))
    (clobber (reg:CC CC_REGNUM))]
   "reload_completed"
   [(parallel
@@ -3674,7 +3674,7 @@
         (const_int 0))
    (use (match_operand 1 "register_operand" ""))
    (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
-   (clobber (scratch))
+   (clobber (match_scratch 2))
    (clobber (reg:CC CC_REGNUM))]
   "TARGET_Z10 && reload_completed"
   [(parallel
@@ -3839,7 +3839,7 @@
                      (match_operand:BLK 1 "memory_operand" "")))
    (use (match_operand 2 "const_int_operand" ""))
    (use (match_operand 3 "immediate_operand" ""))
-   (clobber (scratch))]
+   (clobber (match_scratch 4))]
   "reload_completed"
   [(parallel
     [(set (reg:CCU CC_REGNUM) (compare:CCU (match_dup 0) (match_dup 1)))
@@ -3852,7 +3852,7 @@
                      (match_operand:BLK 1 "memory_operand" "")))
    (use (match_operand 2 "register_operand" ""))
    (use (match_operand 3 "memory_operand" ""))
-   (clobber (scratch))]
+   (clobber (match_scratch 4))]
   "reload_completed"
   [(parallel
     [(unspec [(match_dup 2) (match_dup 3)
@@ -3867,7 +3867,7 @@
                      (match_operand:BLK 1 "memory_operand" "")))
    (use (match_operand 2 "register_operand" ""))
    (use (const:BLK (unspec:BLK [(const_int 0)] UNSPEC_INSN)))
-   (clobber (scratch))]
+   (clobber (match_scratch 3))]
   "TARGET_Z10 && reload_completed"
   [(parallel
     [(unspec [(match_dup 2) (const_int 0)
diff --git a/gcc/testsuite/g++.target/s390/pr119834.C b/gcc/testsuite/g++.target/s390/pr119834.C
new file mode 100644
index 00000000000..66c0a69a1c1
--- /dev/null
+++ b/gcc/testsuite/g++.target/s390/pr119834.C
@@ -0,0 +1,76 @@
+// PR target/119834
+// { dg-do compile { target c++11 } }
+// { dg-options "-O2 -march=z900" }
+
+int *a;
+struct A;
+struct B {
+  A begin ();
+  A end ();
+  operator bool * ();
+  void operator++ ();
+};
+template <typename T>
+auto operator| (int, T x) -> decltype (x (0));
+struct A : B { bool a; };
+struct C { A operator () (int); };
+enum D {} d;
+int e;
+void foo ();
+struct E {
+  template <typename T>
+  T *garply ()
+  {
+    if (d)
+      return 0;
+    if (e)
+      foo ();
+    return reinterpret_cast<T *> (f);
+  }
+  template <typename>
+  void bar (long x, bool)
+  {
+    if (&g - f)
+      __builtin_memset (a, 0, x);
+    f += x;
+  }
+  template <typename T>
+  T *baz (T *x, long y, bool z = true)
+  {
+    if (d)
+      return nullptr;
+    bar<T> ((char *)x + y - f, z);
+    return x;
+  }
+  template <typename T>
+  void qux (T x) { baz (x, x->j); }
+  char *f, g;
+} *h;
+struct F {
+  template <typename T>
+  int corge (T x) { x.freddy (this); return 0; }
+  template <typename T>
+  int boo (T x) { corge (x); return 0; }
+} i;
+template <typename T>
+struct G {
+  template <typename U> friend T operator+ (U, G);
+  template <typename U>
+  void waldo (F *x, G y, U z) { x->boo (z + y); }
+  template <typename... Ts>
+  void plugh (E *y, Ts... z) { T *x = y->garply<T> (); x->thud (y, z...); }
+};
+template <typename T> using H = G<T>;
+struct I {
+  static constexpr unsigned j = 2;
+  void thud (E *x, A y) { x->qux (this); for (auto g : y) ; }
+};
+H<I> k;
+struct J {
+  void freddy (F *) { C a; auto b = 0 | a; k.plugh (h, b); }
+};
+H<J> l;
+struct K {
+  void freddy () { l.waldo (&i, l, this); }
+};
+void grault () { K m; m.freddy (); }

commit f4def864a27c41025bbed0d086fa4628921fec28
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Fri May 30 14:35:12 2025

    testsuite: Add testcase for GCC 13 branch s390 bug [PR120480]
    
    This got broken with r13-9727 and fixed with either of
    r13-9729 or r13-9728.
    
    2025-05-30  Jakub Jelinek  <jakub@redhat.com>
    
            PR target/120480
            * gcc.dg/pr120480.c: New test.
    
    (cherry picked from commit c13d5b939fee565047394475952878dc5394fb74)

diff --git a/gcc/testsuite/gcc.dg/pr120480.c b/gcc/testsuite/gcc.dg/pr120480.c
new file mode 100644
index 00000000000..cf7b47a1151
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr120480.c
@@ -0,0 +1,11 @@
+/* PR target/120480 */
+/* { dg-do compile } */
+/* { dg-options "-O0" } */
+
+struct S { int a, b, c; } s;
+
+void
+foo (void)
+{
+  struct S t = s;
+}

commit 5c72c410dd18a7f809ee90273f1cc8fbe8827d56
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sat May 31 02:24:12 2025

    Daily bump.

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 5796ada5214..adde1e3b090 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,17 @@
+2025-05-30  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2025-04-17  Jakub Jelinek  <jakub@redhat.com>
+
+	PR target/119834
+	* config/s390/s390.md (define_split after *cpymem_short): Use
+	(clobber (match_scratch N)) instead of (clobber (scratch)).  Use
+	(match_dup 4) and operands[4] instead of (match_dup 3) and operands[3]
+	in the last of those.
+	(define_split after *clrmem_short): Use (clobber (match_scratch N))
+	instead of (clobber (scratch)).
+	(define_split after *cmpmem_short): Likewise.
+
 2025-05-26  Stefan Schulze Frielinghaus  <stefansf@gcc.gnu.org>
 
 	Backported from master:
diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index ac274333576..e844ed6f555 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20250530
+20250531
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 7e4bb673cfb..7a0e53823a2 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,19 @@
+2025-05-30  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2025-05-30  Jakub Jelinek  <jakub@redhat.com>
+
+	PR target/120480
+	* gcc.dg/pr120480.c: New test.
+
+2025-05-30  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2025-04-17  Jakub Jelinek  <jakub@redhat.com>
+
+	PR target/119834
+	* g++.target/s390/pr119834.C: New test.
+
 2025-05-27  Patrick Palka  <ppalka@redhat.com>
 
 	Backported from master:

commit abab6fed80e06432468e9d7441375f19ce5ed9a4
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sun Jun 1 02:24:11 2025

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index e844ed6f555..42f5016bedf 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20250531
+20250601

commit e02b12e7248f8209ebad35d6df214d3421ed8020
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Mon Jun 2 02:22:10 2025

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 42f5016bedf..5646e6e7423 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20250601
+20250602

commit 6e10db3be0193514d8a67d1367d8fbe639e03b6a
Author: Jason Merrill <jason@redhat.com>
Date:   Sat May 31 00:27:45 2025

    c++: lambda this capture and requires [PR120123]
    
    We shouldn't need to be within the lambda body to look through it to the
    enclosing non-static member function.
    
    This change is a small subset of r16-970.
    
            PR c++/120123
    
    gcc/cp/ChangeLog:
    
            * lambda.cc (nonlambda_method_basetype): Look through lambdas
            even when current_class_ref is null.
    
    gcc/testsuite/ChangeLog:
    
            * g++.dg/cpp2a/concepts-lambda24.C: New test.

diff --git a/gcc/cp/lambda.cc b/gcc/cp/lambda.cc
index 5c97f0f6fd3..dfaf79692cd 100644
--- a/gcc/cp/lambda.cc
+++ b/gcc/cp/lambda.cc
@@ -1002,12 +1002,9 @@ current_nonlambda_function (void)
 tree
 nonlambda_method_basetype (void)
 {
-  if (!current_class_ref)
-    return NULL_TREE;
-
   tree type = current_class_type;
   if (!type || !LAMBDA_TYPE_P (type))
-    return type;
+    return current_class_ref ? type : NULL_TREE;
 
   while (true)
     {
diff --git a/gcc/testsuite/g++.dg/cpp2a/concepts-lambda24.C b/gcc/testsuite/g++.dg/cpp2a/concepts-lambda24.C
new file mode 100644
index 00000000000..28f56ca2335
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp2a/concepts-lambda24.C
@@ -0,0 +1,13 @@
+// PR c++/120123
+// { dg-do compile { target c++20 } }
+
+struct H {
+    void member(int) {}
+    void call() {
+        [this]() {
+            [this](const auto& v)
+                requires requires { /*this->*/member(v); }
+            { return member(v); }(0);
+        };
+    }
+};

commit 42e99e057bd7cea8be374e1a47f0dfbf77974f88
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Tue Jun 3 02:23:56 2025

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 5646e6e7423..42c54799b73 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20250602
+20250603
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 56acd079690..233f9ed881a 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,9 @@
+2025-06-02  Jason Merrill  <jason@redhat.com>
+
+	PR c++/120123
+	* lambda.cc (nonlambda_method_basetype): Look through lambdas
+	even when current_class_ref is null.
+
 2025-05-27  Patrick Palka  <ppalka@redhat.com>
 
 	Backported from master:
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 7a0e53823a2..d5ee8b038d9 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2025-06-02  Jason Merrill  <jason@redhat.com>
+
+	PR c++/120123
+	* g++.dg/cpp2a/concepts-lambda24.C: New test.
+
 2025-05-30  Jakub Jelinek  <jakub@redhat.com>
 
 	Backported from master:

commit e87f1871cfd5d0dd0860fe525ea5ec435d037ea0
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Wed Jun 4 02:26:17 2025

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 42c54799b73..932c2dd9fa2 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20250603
+20250604

commit 3a2454f578c208d5944a076800201c4452a4ef52
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Thu Jun 5 02:25:26 2025

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 932c2dd9fa2..520e78d7696 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20250604
+20250605

commit 317ff8a8eadfaae6d484dc328277ade42b352342
Author: Eric Botcazou <ebotcazou@adacore.com>
Date:   Thu Jun 5 13:20:26 2025

    Fix crash with constant initializer caused by IPA
    
    The testcase compiled with -O2 -gnatn makes the compiler crash in
    vect_can_force_dr_alignment_p during SLP vectorization:
    
      if (decl_in_symtab_p (decl)
          && !symtab_node::get (decl)->can_increase_alignment_p ())
        return false;
    
    because symtab_node::get (decl) returns a null node.  The phenomenon occurs
    for a pair of twin symbols listed like so in .cgraph:
    
    Opt7_Pkg.T12b/17 (Opt7_Pkg.T12b)
      Type: variable definition analyzed
      Visibility: semantic_interposition external public artificial
      Aux: @0x44d45e0
      References:
      Referring: opt7_pkg__enum_name_table/13 (addr) opt7_pkg__enum_name_table/13
    (addr)
      Availability: not-ready
      Varpool flags: initialized read-only const-value-known
    
    Opt7_Pkg.T8b/16 (Opt7_Pkg.T8b)
      Type: variable definition analyzed
      Visibility: semantic_interposition external public artificial
      Aux: @0x7f9fda3fff00
      References:
      Referring: opt7_pkg__enum_name_table/13 (addr) opt7_pkg__enum_name_table/13
    (addr)
      Availability: not-ready
      Varpool flags: initialized read-only const-value-known
    
    with:
    
    opt7_pkg__enum_name_table/13 (Opt7_Pkg.Enum_Name_Table)
      Type: variable definition analyzed
      Visibility: semantic_interposition external public
      Aux: @0x44d45e0
      References: Opt7_Pkg.T8b/16 (addr) Opt7_Pkg.T8b/16 (addr) Opt7_Pkg.T12b/17
    (addr) Opt7_Pkg.T12b/17 (addr)
      Referring: opt7_pkg__image/2 (read) opt7_pkg__image/2 (read)
    opt7_pkg__image/2 (read) opt7_pkg__image/2 (read) opt7_pkg__image/2 (read)
    opt7_pkg__image/2 (read) opt7_pkg__image/2 (read) opt7_pkg__image/2 (read)
      Availability: not-ready
      Varpool flags: initialized read-only const-value-known
    
    being the crux of the matter.
    
    What happens is that symtab_remove_unreachable_nodes leaves the last symbol
    in kind of a limbo state: in .remove_symbols, we have:
    
    opt7_pkg__enum_name_table/13 (Opt7_Pkg.Enum_Name_Table)
      Type: variable
      Body removed by symtab_remove_unreachable_nodes
      Visibility: externally_visible semantic_interposition external public
      References:
      Referring: opt7_pkg__image/2 (read) opt7_pkg__image/2 (read)
      Availability: not_available
      Varpool flags: initialized read-only const-value-known
    
    This means that the "body" (DECL_INITIAL) of the symbol has been disregarded
    during reachability analysis, causing the first two symbols to be discarded:
    
    Reclaiming variables: Opt7_Pkg.T12b/17 Opt7_Pkg.T8b/16
    
    but the DECL_INITIAL is explicitly preserved for later constant folding,
    which makes it possible to retrofit the DECLs corresponding to the first
    two symbols in the GIMPLE IR and ultimately leads to the crash.
    
    gcc/
            * tree-vect-data-refs.cc (vect_can_force_dr_alignment_p): Return
            false if the variable has no symtab node.
    
    gcc/testsuite/
            * gnat.dg/specs/opt7.ads: New test.
            * gnat.dg/specs/opt7_pkg.ads: New helper.
            * gnat.dg/specs/opt7_pkg.adb: Likewise.

diff --git a/gcc/testsuite/gnat.dg/specs/opt7.ads b/gcc/testsuite/gnat.dg/specs/opt7.ads
new file mode 100644
index 00000000000..ee151f082a8
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/specs/opt7.ads
@@ -0,0 +1,15 @@
+-- { dg-do compile }
+-- { dg-options "-O2 -gnatn" }
+
+with Opt7_Pkg; use Opt7_Pkg;
+
+package Opt7 is
+
+  type Rec is record
+    E : Enum;
+  end record;
+
+  function Image (R : Rec) return String is
+    (if R.E = A then Image (R.E) else "");
+
+end Opt7;
diff --git a/gcc/testsuite/gnat.dg/specs/opt7_pkg.adb b/gcc/testsuite/gnat.dg/specs/opt7_pkg.adb
new file mode 100644
index 00000000000..1c9d79bb872
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/specs/opt7_pkg.adb
@@ -0,0 +1,15 @@
+package body Opt7_Pkg is
+
+  type Constant_String_Access is access constant String;
+
+  type Enum_Name is array (Enum) of Constant_String_Access;
+
+  Enum_Name_Table : constant Enum_Name :=
+    (A => new String'("A"), B => new String'("B"));
+
+  function Image (E : Enum) return String is
+  begin
+    return Enum_Name_Table (E).all;
+  end Image;
+
+end Opt7_Pkg;
diff --git a/gcc/testsuite/gnat.dg/specs/opt7_pkg.ads b/gcc/testsuite/gnat.dg/specs/opt7_pkg.ads
new file mode 100644
index 00000000000..2dd271b63ad
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/specs/opt7_pkg.ads
@@ -0,0 +1,9 @@
+-- { dg-excess-errors "no code generated" }
+
+package Opt7_Pkg is
+
+  type Enum is (A, B);
+
+  function Image (E : Enum) return String with Inline;
+
+end Opt7_Pkg;
diff --git a/gcc/tree-vect-data-refs.cc b/gcc/tree-vect-data-refs.cc
index cae154af6dd..dff6db794b0 100644
--- a/gcc/tree-vect-data-refs.cc
+++ b/gcc/tree-vect-data-refs.cc
@@ -7058,7 +7058,8 @@ vect_can_force_dr_alignment_p (const_tree decl, poly_uint64 alignment)
     return false;
 
   if (decl_in_symtab_p (decl)
-      && !symtab_node::get (decl)->can_increase_alignment_p ())
+      && (!symtab_node::get (decl)
+	  || !symtab_node::get (decl)->can_increase_alignment_p ()))
     return false;
 
   if (TREE_STATIC (decl))

commit d0c4f654354a7e4324a18d06860d1af4963fb658
Author: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Date:   Tue Dec 10 00:56:13 2024

    libstdc++: fix compile error when converting std::weak_ptr<T[]>
    
    A std::weak_ptr<T[]> can be converted to a compatible
    std::weak_ptr<U[]>. This is implemented by having suitable converting
    constructors to std::weak_ptr which dispatch to the __weak_ptr base
    class (implementation detail).
    
    In __weak_ptr<T[]>, lock() is supposed to return a __shared_ptr<T[]>,
    not a __shared_ptr<element_type> (that is, __shared_ptr<T>).
    
    Unfortunately the return type of lock() and the type of the returned
    __shared_ptr were mismatching and that was causing a compile error: when
    converting a __weak_ptr<T[]> to a __weak_ptr<U[]> through __weak_ptr's
    converting constructor, the code calls lock(), and that simply fails to
    build.
    
    Fix it by removing the usage of element_type inside lock(), and using
    _Tp instead.
    
    Note that std::weak_ptr::lock() itself was already correct; the one in
    __weak_ptr was faulty (and that is the one called by __weak_ptr's
    converting constructors).
    
    libstdc++-v3/ChangeLog:
    
            * include/bits/shared_ptr_base.h (lock): Fixed a compile error
            when calling lock() on a weak_ptr<T[]>, by removing an
            erroneous usage of element_type from within lock().
            * testsuite/20_util/shared_ptr/requirements/explicit_instantiation/1.cc:
            Add more tests for array types.
            * testsuite/20_util/weak_ptr/requirements/explicit_instantiation/1.cc:
            Likewise.
            * testsuite/20_util/shared_ptr/requirements/1.cc: New test.
            * testsuite/20_util/weak_ptr/requirements/1.cc: New test.
    
    (cherry picked from commit df0e6509bf74421ea68a2e025300bcd6ca63722f)

diff --git a/libstdc++-v3/include/bits/shared_ptr_base.h b/libstdc++-v3/include/bits/shared_ptr_base.h
index 3d0b74ba1c6..397763f2723 100644
--- a/libstdc++-v3/include/bits/shared_ptr_base.h
+++ b/libstdc++-v3/include/bits/shared_ptr_base.h
@@ -2069,7 +2069,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
       __shared_ptr<_Tp, _Lp>
       lock() const noexcept
-      { return __shared_ptr<element_type, _Lp>(*this, std::nothrow); }
+      { return __shared_ptr<_Tp, _Lp>(*this, std::nothrow); }
 
       long
       use_count() const noexcept
diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/requirements/1.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/requirements/1.cc
new file mode 100644
index 00000000000..8ddb5d220ac
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/shared_ptr/requirements/1.cc
@@ -0,0 +1,33 @@
+// { dg-do compile { target c++11 } }
+// { dg-require-effective-target hosted }
+
+#include <memory>
+#include <testsuite_tr1.h>
+
+using namespace __gnu_test;
+
+void
+test01()
+{
+  std::shared_ptr<ClassType> ptr;
+  std::shared_ptr<const ClassType> ptr2 = ptr;
+
+#if __cpp_lib_shared_ptr_arrays >= 201611L
+  std::shared_ptr<ClassType[10]> ptr_array;
+  std::shared_ptr<ClassType[]> ptr_array2 = ptr_array;
+  std::shared_ptr<ClassType const []> ptr_array3 = ptr_array;
+#endif
+}
+
+void
+test02()
+{
+  std::shared_ptr<IncompleteClass> ptr;
+  std::shared_ptr<const IncompleteClass> ptr2 = ptr;
+
+#if __cpp_lib_shared_ptr_arrays >= 201611L
+  std::shared_ptr<IncompleteClass[10]> ptr_array;
+  std::shared_ptr<IncompleteClass[]> ptr_array2 = ptr_array;
+  std::shared_ptr<IncompleteClass const []> ptr_array3 = ptr_array;
+#endif
+}
diff --git a/libstdc++-v3/testsuite/20_util/shared_ptr/requirements/explicit_instantiation/1.cc b/libstdc++-v3/testsuite/20_util/shared_ptr/requirements/explicit_instantiation/1.cc
index 94bc8c7adfe..48f162d4072 100644
--- a/libstdc++-v3/testsuite/20_util/shared_ptr/requirements/explicit_instantiation/1.cc
+++ b/libstdc++-v3/testsuite/20_util/shared_ptr/requirements/explicit_instantiation/1.cc
@@ -28,3 +28,15 @@ template class std::shared_ptr<int>;
 template class std::shared_ptr<void>;
 template class std::shared_ptr<ClassType>;
 template class std::shared_ptr<IncompleteClass>;
+
+#if __cpp_lib_shared_ptr_arrays >= 201611L
+template class std::shared_ptr<ClassType []>;
+template class std::shared_ptr<ClassType [42]>;
+template class std::shared_ptr<ClassType const []>;
+template class std::shared_ptr<ClassType const [42]>;
+
+template class std::shared_ptr<IncompleteClass []>;
+template class std::shared_ptr<IncompleteClass [42]>;
+template class std::shared_ptr<IncompleteClass const []>;
+template class std::shared_ptr<IncompleteClass const [42]>;
+#endif
diff --git a/libstdc++-v3/testsuite/20_util/weak_ptr/requirements/1.cc b/libstdc++-v3/testsuite/20_util/weak_ptr/requirements/1.cc
new file mode 100644
index 00000000000..04ea837d85a
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/weak_ptr/requirements/1.cc
@@ -0,0 +1,33 @@
+// { dg-do compile { target c++11 } }
+// { dg-require-effective-target hosted }
+
+#include <memory>
+#include <testsuite_tr1.h>
+
+using namespace __gnu_test;
+
+void
+test01()
+{
+  std::weak_ptr<ClassType> ptr;
+  std::weak_ptr<const ClassType> ptr2 = ptr;
+
+#if __cpp_lib_shared_ptr_arrays >= 201611L
+  std::weak_ptr<ClassType[10]> ptr_array;
+  std::weak_ptr<ClassType[]> ptr_array2 = ptr_array;
+  std::weak_ptr<ClassType const []> ptr_array3 = ptr_array;
+#endif
+}
+
+void
+test02()
+{
+  std::weak_ptr<IncompleteClass> ptr;
+  std::weak_ptr<const IncompleteClass> ptr2 = ptr;
+
+#if __cpp_lib_shared_ptr_arrays >= 201611L
+  std::weak_ptr<IncompleteClass[10]> ptr_array;
+  std::weak_ptr<IncompleteClass[]> ptr_array2 = ptr_array;
+  std::weak_ptr<IncompleteClass const []> ptr_array3 = ptr_array;
+#endif
+}
diff --git a/libstdc++-v3/testsuite/20_util/weak_ptr/requirements/explicit_instantiation/1.cc b/libstdc++-v3/testsuite/20_util/weak_ptr/requirements/explicit_instantiation/1.cc
index b32ff6ea284..b51a614693c 100644
--- a/libstdc++-v3/testsuite/20_util/weak_ptr/requirements/explicit_instantiation/1.cc
+++ b/libstdc++-v3/testsuite/20_util/weak_ptr/requirements/explicit_instantiation/1.cc
@@ -28,3 +28,15 @@ template class std::weak_ptr<int>;
 template class std::weak_ptr<void>;
 template class std::weak_ptr<ClassType>;
 template class std::weak_ptr<IncompleteClass>;
+
+#if __cpp_lib_shared_ptr_arrays >= 201611L
+template class std::weak_ptr<ClassType []>;
+template class std::weak_ptr<ClassType [42]>;
+template class std::weak_ptr<ClassType const []>;
+template class std::weak_ptr<ClassType const [42]>;
+
+template class std::weak_ptr<IncompleteClass []>;
+template class std::weak_ptr<IncompleteClass [42]>;
+template class std::weak_ptr<IncompleteClass const []>;
+template class std::weak_ptr<IncompleteClass const [42]>;
+#endif

commit cf7cb901d7ba3e5d7475d774c42dc5609f91b558
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Fri Jun 6 02:24:04 2025

    Daily bump.

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index adde1e3b090..de534a66c31 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@
+2025-06-05  Eric Botcazou  <ebotcazou@adacore.com>
+
+	* tree-vect-data-refs.cc (vect_can_force_dr_alignment_p): Return
+	false if the variable has no symtab node.
+
 2025-05-30  Jakub Jelinek  <jakub@redhat.com>
 
 	Backported from master:
diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 520e78d7696..c6de4e34998 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20250605
+20250606
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index d5ee8b038d9..89e6da052e2 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2025-06-05  Eric Botcazou  <ebotcazou@adacore.com>
+
+	* gnat.dg/specs/opt7.ads: New test.
+	* gnat.dg/specs/opt7_pkg.ads: New helper.
+	* gnat.dg/specs/opt7_pkg.adb: Likewise.
+
 2025-06-02  Jason Merrill  <jason@redhat.com>
 
 	PR c++/120123
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index 9a126107f5e..c4bf363c695 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,18 @@
+2025-06-05  Giuseppe D'Angelo  <giuseppe.dangelo@kdab.com>
+
+	Backported from master:
+	2025-03-14  Giuseppe D'Angelo  <giuseppe.dangelo@kdab.com>
+
+	* include/bits/shared_ptr_base.h (lock): Fixed a compile error
+	when calling lock() on a weak_ptr<T[]>, by removing an
+	erroneous usage of element_type from within lock().
+	* testsuite/20_util/shared_ptr/requirements/explicit_instantiation/1.cc:
+	Add more tests for array types.
+	* testsuite/20_util/weak_ptr/requirements/explicit_instantiation/1.cc:
+	Likewise.
+	* testsuite/20_util/shared_ptr/requirements/1.cc: New test.
+	* testsuite/20_util/weak_ptr/requirements/1.cc: New test.
+
 2025-05-23  Release Manager
 
 	* GCC 14.3.0 released.

commit efdddc8d6a0d175eb2c74a7feb7758bd04f69b11
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sat Jun 7 02:24:23 2025

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index c6de4e34998..a3a91b55b0f 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20250606
+20250607

commit 4a82b78552a62a90ac2b82893c2f6b99e59c0bc5
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sun Jun 8 02:22:41 2025

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index a3a91b55b0f..800deb1dc5a 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20250607
+20250608

commit e1a6f6dd2d3f1bccd1a471509bd94b4a48688be7
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Mon Jun 9 02:23:11 2025

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 800deb1dc5a..d0f154b4f06 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20250608
+20250609

commit 4a46af97f5e2bb8d6ac2af0735d25d0c8464723c
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Tue Jun 10 02:24:17 2025

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index d0f154b4f06..52988ae3b03 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20250609
+20250610

commit e1cbf566970f02a7ac110df58c412be11604b278
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Tue May 20 11:53:41 2025

    libstdc++: Fix incorrect links to archived SGI STL docs
    
    In r8-7777-g25949ee33201f2 I updated some URLs to point to copies of the
    SGI STL docs in the Wayback Machine, because the original pags were no
    longer hosted on sgi.com. However, I incorrectly assumed that if one
    archived page was at https://web.archive.org/web/20171225062613/... then
    all the other pages would be too. Apparently that's not how the Wayback
    Machine works, and each page is archived on a different date. That meant
    that some of our links were redirecting to archived copies of the
    announcement that the SGI STL docs have gone away.
    
    This fixes each URL to refer to a correctly archived copy of the
    original docs.
    
    libstdc++-v3/ChangeLog:
    
            * doc/xml/faq.xml: Update URL for archived SGI STL docs.
            * doc/xml/manual/containers.xml: Likewise.
            * doc/xml/manual/extensions.xml: Likewise.
            * doc/xml/manual/using.xml: Likewise.
            * doc/xml/manual/utilities.xml: Likewise.
            * doc/html/*: Regenerate.
    
    (cherry picked from commit 501e6e786652748ff0ad9a322f74b9b47970031f)

diff --git a/libstdc++-v3/doc/html/faq.html b/libstdc++-v3/doc/html/faq.html
index bbe716d5e23..62213793933 100644
--- a/libstdc++-v3/doc/html/faq.html
+++ b/libstdc++-v3/doc/html/faq.html
@@ -796,7 +796,7 @@
     Libstdc++-v3 incorporates a lot of code from
     <a class="link" href="https://web.archive.org/web/20171225062613/http://www.sgi.com/tech/stl/" target="_top">the SGI STL</a>
     (the final merge was from
-    <a class="link" href="https://web.archive.org/web/20171225062613/http://www.sgi.com/tech/stl/whats_new.html" target="_top">release 3.3</a>).
+    <a class="link" href="https://web.archive.org/web/20171206110416/http://www.sgi.com/tech/stl/whats_new.html" target="_top">release 3.3</a>).
     The code in libstdc++ contains many fixes and changes compared to the
     original SGI code.
     </p><p>
diff --git a/libstdc++-v3/doc/html/manual/containers.html b/libstdc++-v3/doc/html/manual/containers.html
index 7035a949074..dcd609a6000 100644
--- a/libstdc++-v3/doc/html/manual/containers.html
+++ b/libstdc++-v3/doc/html/manual/containers.html
@@ -11,7 +11,7 @@
      Yes it is, at least using the <a class="link" href="using_dual_abi.html" title="Dual ABI">old
      ABI</a>, and that's okay.  This is a decision that we preserved
      when we imported SGI's STL implementation.  The following is
-     quoted from <a class="link" href="https://web.archive.org/web/20171225062613/http://www.sgi.com/tech/stl/FAQ.html" target="_top">their FAQ</a>:
+     quoted from <a class="link" href="https://web.archive.org/web/20161222192301/http://www.sgi.com/tech/stl/FAQ.html" target="_top">their FAQ</a>:
    </p><div class="blockquote"><blockquote class="blockquote"><p>
        The size() member function, for list and slist, takes time
        proportional to the number of elements in the list.  This was a
diff --git a/libstdc++-v3/doc/html/manual/ext_numerics.html b/libstdc++-v3/doc/html/manual/ext_numerics.html
index 9b864e1dcf4..c3a5623d175 100644
--- a/libstdc++-v3/doc/html/manual/ext_numerics.html
+++ b/libstdc++-v3/doc/html/manual/ext_numerics.html
@@ -14,7 +14,7 @@
    The operation functor must be associative.
 </p><p>The <code class="code">iota</code> function wins the award for Extension With the
    Coolest Name (the name comes from Ken Iverson's APL language.)  As
-   described in the <a class="link" href="https://web.archive.org/web/20171225062613/http://www.sgi.com/tech/stl/iota.html" target="_top">SGI
+   described in the <a class="link" href="https://web.archive.org/web/20170201044840/http://www.sgi.com/tech/stl/iota.html" target="_top">SGI
    documentation</a>, it "assigns sequentially increasing values to a range.
    That is, it assigns <code class="code">value</code> to <code class="code">*first</code>,
    <code class="code">value + 1</code> to<code class="code"> *(first + 1)</code> and so on."
diff --git a/libstdc++-v3/doc/html/manual/ext_sgi.html b/libstdc++-v3/doc/html/manual/ext_sgi.html
index ae2062954f4..2310857804b 100644
--- a/libstdc++-v3/doc/html/manual/ext_sgi.html
+++ b/libstdc++-v3/doc/html/manual/ext_sgi.html
@@ -28,12 +28,12 @@
       and sets.
    </p><p>Each of the associative containers map, multimap, set, and multiset
       have a counterpart which uses a
-      <a class="link" href="https://web.archive.org/web/20171225062613/http://www.sgi.com/tech/stl/HashFunction.html" target="_top">hashing
+      <a class="link" href="https://web.archive.org/web/20171230172024/http://www.sgi.com/tech/stl/HashFunction.html" target="_top">hashing
       function</a> to do the arranging, instead of a strict weak ordering
       function.  The classes take as one of their template parameters a
       function object that will return the hash value; by default, an
       instantiation of
-      <a class="link" href="https://web.archive.org/web/20171225062613/http://www.sgi.com/tech/stl/hash.html" target="_top">hash</a>.
+      <a class="link" href="https://web.archive.org/web/20171230172200/http://www.sgi.com/tech/stl/hash.html" target="_top">hash</a>.
       You should specialize this functor for your class, or define your own,
       before trying to use one of the hashing classes.
    </p><p>The hashing classes support all the usual associative container
diff --git a/libstdc++-v3/doc/html/manual/using_concurrency.html b/libstdc++-v3/doc/html/manual/using_concurrency.html
index f99cca414ec..a75adbf0f22 100644
--- a/libstdc++-v3/doc/html/manual/using_concurrency.html
+++ b/libstdc++-v3/doc/html/manual/using_concurrency.html
@@ -40,7 +40,7 @@ The standard places requirements on the library to ensure that no data
 races are caused by the library itself or by programs which use the
 library correctly (as described below).
 The C++11 memory model and library requirements are a more formal version
-of the <a class="link" href="https://web.archive.org/web/20171225062613/http://www.sgi.com/tech/stl/thread_safety.html" target="_top">SGI STL</a> definition of thread safety, which the library used
+of the <a class="link" href="https://web.archive.org/web/20171221154911/http://www.sgi.com/tech/stl/thread_safety.html" target="_top">SGI STL</a> definition of thread safety, which the library used
 prior to the 2011 standard.
 </p><p>The library strives to be thread-safe when all of the following
 	 conditions are met:
@@ -243,10 +243,10 @@ gcc version 4.1.2 20070925 (Red Hat 4.1.2-33)
       threaded and non-threaded code), see Chapter 17.
    </p><p>Two excellent pages to read when working with the Standard C++
       containers and threads are
-      <a class="link" href="https://web.archive.org/web/20171225062613/http://www.sgi.com/tech/stl/thread_safety.html" target="_top">SGI's
-      https://web.archive.org/web/20171225062613/http://www.sgi.com/tech/stl/thread_safety.html</a> and
-      <a class="link" href="https://web.archive.org/web/20171225062613/http://www.sgi.com/tech/stl/Allocators.html" target="_top">SGI's
-      https://web.archive.org/web/20171225062613/http://www.sgi.com/tech/stl/Allocators.html</a>.
+      <a class="link" href="https://web.archive.org/web/20171221154911/http://www.sgi.com/tech/stl/thread_safety.html" target="_top">SGI's
+      https://web.archive.org/web/20171221154911/http://www.sgi.com/tech/stl/thread_safety.html</a> and
+      <a class="link" href="https://web.archive.org/web/20171108142526/http://www.sgi.com/tech/stl/Allocators.html" target="_top">SGI's
+      https://web.archive.org/web/20171108142526/http://www.sgi.com/tech/stl/Allocators.html</a>.
    </p><p><span class="emphasis"><em>However, please ignore all discussions about the user-level
       configuration of the lock implementation inside the STL
       container-memory allocator on those pages.  For the sake of this
diff --git a/libstdc++-v3/doc/html/manual/utilities.html b/libstdc++-v3/doc/html/manual/utilities.html
index 15c9a9d170a..1216b72ad3e 100644
--- a/libstdc++-v3/doc/html/manual/utilities.html
+++ b/libstdc++-v3/doc/html/manual/utilities.html
@@ -11,6 +11,6 @@
       get slightly the wrong idea.  In the interest of not reinventing
       the wheel, we will refer you to the introduction to the functor
       concept written by SGI as part of their STL, in
-      <a class="link" href="https://web.archive.org/web/20171225062613/http://www.sgi.com/tech/stl/functors.html" target="_top">their
-      https://web.archive.org/web/20171225062613/http://www.sgi.com/tech/stl/functors.html</a>.
+      <a class="link" href="https://web.archive.org/web/20171209002754/http://www.sgi.com/tech/stl/functors.html" target="_top">their
+      https://web.archive.org/web/20171209002754/http://www.sgi.com/tech/stl/functors.html</a>.
    </p></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="concept_checking.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="std_contents.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="pairs.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Concept Checking </td><td width="20%" align="center"><a accesskey="h" href="../index.html">Home</a></td><td width="40%" align="right" valign="top"> Pairs</td></tr></table></div></body></html>
\ No newline at end of file
diff --git a/libstdc++-v3/doc/xml/faq.xml b/libstdc++-v3/doc/xml/faq.xml
index 9359dd09bef..805dc7b5cd1 100644
--- a/libstdc++-v3/doc/xml/faq.xml
+++ b/libstdc++-v3/doc/xml/faq.xml
@@ -1130,7 +1130,7 @@
     Libstdc++-v3 incorporates a lot of code from
     <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="https://web.archive.org/web/20171225062613/http://www.sgi.com/tech/stl/">the SGI STL</link>
     (the final merge was from
-    <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="https://web.archive.org/web/20171225062613/http://www.sgi.com/tech/stl/whats_new.html">release 3.3</link>).
+    <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="https://web.archive.org/web/20171206110416/http://www.sgi.com/tech/stl/whats_new.html">release 3.3</link>).
     The code in libstdc++ contains many fixes and changes compared to the
     original SGI code.
     </para>
diff --git a/libstdc++-v3/doc/xml/manual/containers.xml b/libstdc++-v3/doc/xml/manual/containers.xml
index 6d9a3874924..1758762b882 100644
--- a/libstdc++-v3/doc/xml/manual/containers.xml
+++ b/libstdc++-v3/doc/xml/manual/containers.xml
@@ -28,7 +28,7 @@
      Yes it is, at least using the <link linkend="manual.intro.using.abi">old
      ABI</link>, and that's okay.  This is a decision that we preserved
      when we imported SGI's STL implementation.  The following is
-     quoted from <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="https://web.archive.org/web/20171225062613/http://www.sgi.com/tech/stl/FAQ.html">their FAQ</link>:
+     quoted from <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="https://web.archive.org/web/20161222192301/http://www.sgi.com/tech/stl/FAQ.html">their FAQ</link>:
    </para>
    <blockquote>
      <para>
diff --git a/libstdc++-v3/doc/xml/manual/extensions.xml b/libstdc++-v3/doc/xml/manual/extensions.xml
index d0460b0d90c..a8b7088ff25 100644
--- a/libstdc++-v3/doc/xml/manual/extensions.xml
+++ b/libstdc++-v3/doc/xml/manual/extensions.xml
@@ -227,12 +227,12 @@ extensions, be aware of two things:
    </para>
    <para>Each of the associative containers map, multimap, set, and multiset
       have a counterpart which uses a
-      <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="https://web.archive.org/web/20171225062613/http://www.sgi.com/tech/stl/HashFunction.html">hashing
+      <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="https://web.archive.org/web/20171230172024/http://www.sgi.com/tech/stl/HashFunction.html">hashing
       function</link> to do the arranging, instead of a strict weak ordering
       function.  The classes take as one of their template parameters a
       function object that will return the hash value; by default, an
       instantiation of
-      <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="https://web.archive.org/web/20171225062613/http://www.sgi.com/tech/stl/hash.html">hash</link>.
+      <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="https://web.archive.org/web/20171230172200/http://www.sgi.com/tech/stl/hash.html">hash</link>.
       You should specialize this functor for your class, or define your own,
       before trying to use one of the hashing classes.
    </para>
@@ -394,7 +394,7 @@ get_temporary_buffer(5, (int*)0);
 </para>
 <para>The <code>iota</code> function wins the award for Extension With the
    Coolest Name (the name comes from Ken Iverson's APL language.)  As
-   described in the <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="https://web.archive.org/web/20171225062613/http://www.sgi.com/tech/stl/iota.html">SGI
+   described in the <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="https://web.archive.org/web/20170201044840/http://www.sgi.com/tech/stl/iota.html">SGI
    documentation</link>, it "assigns sequentially increasing values to a range.
    That is, it assigns <code>value</code> to <code>*first</code>,
    <code>value + 1</code> to<code> *(first + 1)</code> and so on."
diff --git a/libstdc++-v3/doc/xml/manual/using.xml b/libstdc++-v3/doc/xml/manual/using.xml
index 46b36ba7a7c..0587f9ae50d 100644
--- a/libstdc++-v3/doc/xml/manual/using.xml
+++ b/libstdc++-v3/doc/xml/manual/using.xml
@@ -1929,7 +1929,7 @@ The standard places requirements on the library to ensure that no data
 races are caused by the library itself or by programs which use the
 library correctly (as described below).
 The C++11 memory model and library requirements are a more formal version
-of the <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="https://web.archive.org/web/20171225062613/http://www.sgi.com/tech/stl/thread_safety.html">SGI STL</link> definition of thread safety, which the library used
+of the <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="https://web.archive.org/web/20171221154911/http://www.sgi.com/tech/stl/thread_safety.html">SGI STL</link> definition of thread safety, which the library used
 prior to the 2011 standard.
 </para>
 
@@ -2214,10 +2214,10 @@ gcc version 4.1.2 20070925 (Red Hat 4.1.2-33)
    </para>
    <para>Two excellent pages to read when working with the Standard C++
       containers and threads are
-      <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="https://web.archive.org/web/20171225062613/http://www.sgi.com/tech/stl/thread_safety.html">SGI's
-      https://web.archive.org/web/20171225062613/http://www.sgi.com/tech/stl/thread_safety.html</link> and
-      <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="https://web.archive.org/web/20171225062613/http://www.sgi.com/tech/stl/Allocators.html">SGI's
-      https://web.archive.org/web/20171225062613/http://www.sgi.com/tech/stl/Allocators.html</link>.
+      <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="https://web.archive.org/web/20171221154911/http://www.sgi.com/tech/stl/thread_safety.html">SGI's
+      https://web.archive.org/web/20171221154911/http://www.sgi.com/tech/stl/thread_safety.html</link> and
+      <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="https://web.archive.org/web/20171108142526/http://www.sgi.com/tech/stl/Allocators.html">SGI's
+      https://web.archive.org/web/20171108142526/http://www.sgi.com/tech/stl/Allocators.html</link>.
    </para>
    <para><emphasis>However, please ignore all discussions about the user-level
       configuration of the lock implementation inside the STL
diff --git a/libstdc++-v3/doc/xml/manual/utilities.xml b/libstdc++-v3/doc/xml/manual/utilities.xml
index e155c8c3943..c2e013e3416 100644
--- a/libstdc++-v3/doc/xml/manual/utilities.xml
+++ b/libstdc++-v3/doc/xml/manual/utilities.xml
@@ -22,8 +22,8 @@
       get slightly the wrong idea.  In the interest of not reinventing
       the wheel, we will refer you to the introduction to the functor
       concept written by SGI as part of their STL, in
-      <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="https://web.archive.org/web/20171225062613/http://www.sgi.com/tech/stl/functors.html">their
-      https://web.archive.org/web/20171225062613/http://www.sgi.com/tech/stl/functors.html</link>.
+      <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="https://web.archive.org/web/20171209002754/http://www.sgi.com/tech/stl/functors.html">their
+      https://web.archive.org/web/20171209002754/http://www.sgi.com/tech/stl/functors.html</link>.
    </para>
 </section>
 

commit 253e6efeb2fe64c8cdf06307d954666ad110deb3
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Wed Jun 11 02:24:54 2025

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 52988ae3b03..a3ea83c2661 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20250610
+20250611
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index c4bf363c695..bd13b97e6d9 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,15 @@
+2025-06-10  Jonathan Wakely  <jwakely@redhat.com>
+
+	Backported from master:
+	2025-05-20  Jonathan Wakely  <jwakely@redhat.com>
+
+	* doc/xml/faq.xml: Update URL for archived SGI STL docs.
+	* doc/xml/manual/containers.xml: Likewise.
+	* doc/xml/manual/extensions.xml: Likewise.
+	* doc/xml/manual/using.xml: Likewise.
+	* doc/xml/manual/utilities.xml: Likewise.
+	* doc/html/*: Regenerate.
+
 2025-06-05  Giuseppe D'Angelo  <giuseppe.dangelo@kdab.com>
 
 	Backported from master:

commit b5d386495b3f8e638acaab3f7f2ada2c7a3d0f55
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Wed May 28 16:19:18 2025

    libstdc++: Make system_clock::to_time_t always_inline [PR99832]
    
    For some 32-bit targets Glibc supports changing the size of time_t to be
    64 bits by defining _TIME_BITS=64. That causes an ABI change which
    would affect std::chrono::system_clock::to_time_t. Because to_time_t is
    not a function template, its mangled name does not depend on the return
    type, so it has the same mangled name whether it returns a 32-bit time_t
    or a 64-bit time_t. On targets where the size of time_t can be selected
    at preprocessing time, that can cause ODR violations, e.g. the linker
    selects a definition of to_time_t that returns a 32-bit value but a
    caller expects 64-bit and so reads 32 bits of garbage from the stack.
    
    This commit adds always_inline to to_time_t so that all callers inline
    the conversion to time_t, and will do so using whatever type time_t
    happens to be in that translation unit.
    
    Existing objects compiled before this change will either have inlined
    the function anyway (which is likely if compiled with any optimization
    enabled) or will contain a COMDAT definition of the inline function and
    so still be able to find it at link-time.
    
    The attribute is also added to system_clock::from_time_t, because that's
    an equally simple function and it seems reasonable for them to both be
    always inlined.
    
    libstdc++-v3/ChangeLog:
    
            PR libstdc++/99832
            * include/bits/chrono.h (system_clock::to_time_t): Add
            always_inline attribute to be agnostic to the underlying type of
            time_t.
            (system_clock::from_time_t): Add always_inline for consistency
            with to_time_t.
            * testsuite/20_util/system_clock/99832.cc: New test.
    
    (cherry picked from commit d045eb13b0b42870a1f081895df3901112a358f0)

diff --git a/libstdc++-v3/include/bits/chrono.h b/libstdc++-v3/include/bits/chrono.h
index 0773867da71..a7157628a0a 100644
--- a/libstdc++-v3/include/bits/chrono.h
+++ b/libstdc++-v3/include/bits/chrono.h
@@ -1239,6 +1239,7 @@ _GLIBCXX_BEGIN_INLINE_ABI_NAMESPACE(_V2)
       now() noexcept;
 
       // Map to C API
+      [[__gnu__::__always_inline__]]
       static std::time_t
       to_time_t(const time_point& __t) noexcept
       {
@@ -1246,6 +1247,7 @@ _GLIBCXX_BEGIN_INLINE_ABI_NAMESPACE(_V2)
 			   (__t.time_since_epoch()).count());
       }
 
+      [[__gnu__::__always_inline__]]
       static time_point
       from_time_t(std::time_t __t) noexcept
       {
diff --git a/libstdc++-v3/testsuite/20_util/system_clock/99832.cc b/libstdc++-v3/testsuite/20_util/system_clock/99832.cc
new file mode 100644
index 00000000000..693d4d647d9
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/system_clock/99832.cc
@@ -0,0 +1,14 @@
+// { dg-options "-O0 -g0" }
+// { dg-do compile { target c++20 } }
+// { dg-final { scan-assembler-not "system_clock9to_time_t" } }
+
+// Bug libstdc++/99832
+// std::chrono::system_clock::to_time_t needs ABI tag for 32-bit time_t
+
+#include <chrono>
+
+std::time_t
+test_pr99832(std::chrono::system_clock::time_point t)
+{
+  return std::chrono::system_clock::to_time_t(t);
+}

commit 627c08f72b4ebcbda321643622eb9c249f57869b
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Mon Apr 29 19:16:29 2024

    libstdc++: Tweak localized formatting for floating-point types
    
    libstdc++-v3/ChangeLog:
    
            * include/std/format (__formatter_fp::_M_localize): Add comments
            and micro-optimize string copy.
    
    (cherry picked from commit 99b8be43d7c548db127ee4f4d0918c55edc68b3f)

diff --git a/libstdc++-v3/include/std/format b/libstdc++-v3/include/std/format
index 604f4cde3c4..84f21281387 100644
--- a/libstdc++-v3/include/std/format
+++ b/libstdc++-v3/include/std/format
@@ -1831,25 +1831,28 @@ namespace __format
 	if (__grp.empty() && __point == __dot)
 	  return __lstr; // Locale uses '.' and no grouping.
 
-	size_t __d = __str.find(__dot);
-	size_t __e = min(__d, __str.find(__exp));
+	size_t __d = __str.find(__dot); // Index of radix character (if any).
+	size_t __e = min(__d, __str.find(__exp)); // First of radix or exponent
 	if (__e == __str.npos)
 	  __e = __str.size();
-	const size_t __r = __str.size() - __e;
+	const size_t __r = __str.size() - __e; // Length of remainder.
 	auto __overwrite = [&](_CharT* __p, size_t) {
+	  // Apply grouping to the digits before the radix or exponent.
 	  auto __end = std::__add_grouping(__p, __np.thousands_sep(),
 					   __grp.data(), __grp.size(),
 					   __str.data(), __str.data() + __e);
-	  if (__r)
+	  if (__r) // If there's a fractional part or exponent
 	    {
 	      if (__d != __str.npos)
 		{
-		  *__end = __point;
+		  *__end = __point; // Add the locale's radix character.
 		  ++__end;
 		  ++__e;
 		}
-	      if (__r > 1)
-		__end += __str.copy(__end, __str.npos, __e);
+	      const size_t __rlen = __str.size() - __e;
+	      // Append fractional digits and/or exponent:
+	      char_traits<_CharT>::copy(__end, __str.data() + __e, __rlen);
+	      __end += __rlen;
 	    }
 	  return (__end - __p);
 	};

commit c92bc1e435e48e85fecf08dafe9d62a30a46a773
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Wed Jun 4 19:22:28 2025

    libstdc++: Fix std::format thousands separators when sign present [PR120548]
    
    The leading sign character should be skipped when deciding whether to
    insert thousands separators into a floating-point format.
    
    libstdc++-v3/ChangeLog:
    
            PR libstdc++/120548
            * include/std/format (__formatter_fp::_M_localize): Do not
            include a leading sign character in the string to be grouped.
            * testsuite/std/format/functions/format.cc: Check grouping when
            sign is present in the output.
    
    Reviewed-by: Tomasz Kamiński <tkaminsk@redhat.com>
    (cherry picked from commit 2c3559839d70df6311da18fd93237050405580c3)

diff --git a/libstdc++-v3/include/std/format b/libstdc++-v3/include/std/format
index 84f21281387..ada62c26bca 100644
--- a/libstdc++-v3/include/std/format
+++ b/libstdc++-v3/include/std/format
@@ -1838,9 +1838,16 @@ namespace __format
 	const size_t __r = __str.size() - __e; // Length of remainder.
 	auto __overwrite = [&](_CharT* __p, size_t) {
 	  // Apply grouping to the digits before the radix or exponent.
-	  auto __end = std::__add_grouping(__p, __np.thousands_sep(),
+	  int __off = 0;
+	  if (auto __c = __str.front(); __c == '-' || __c == '+' || __c == ' ')
+	    {
+	      *__p = __c;
+	      __off = 1;
+	    }
+	  auto __end = std::__add_grouping(__p + __off, __np.thousands_sep(),
 					   __grp.data(), __grp.size(),
-					   __str.data(), __str.data() + __e);
+					   __str.data() + __off,
+					   __str.data() + __e);
 	  if (__r) // If there's a fractional part or exponent
 	    {
 	      if (__d != __str.npos)
diff --git a/libstdc++-v3/testsuite/std/format/functions/format.cc b/libstdc++-v3/testsuite/std/format/functions/format.cc
index d6575dabb6b..677c0d1fe99 100644
--- a/libstdc++-v3/testsuite/std/format/functions/format.cc
+++ b/libstdc++-v3/testsuite/std/format/functions/format.cc
@@ -256,6 +256,16 @@ test_locale()
   s = std::format(eloc, "{0:Le} {0:Lf} {0:Lg}", -nan);
   VERIFY( s == "-nan -nan -nan" );
 
+  // PR libstdc++/120548 format confuses a negative sign for a thousands digit
+  s = std::format(bloc, "{:L}", -123.45);
+  VERIFY( s == "-123.45" );
+  s = std::format(bloc, "{:-L}", -876543.21);
+  VERIFY( s == "-876,543.21" );
+  s = std::format(bloc, "{:+L}", 333.22);
+  VERIFY( s == "+333.22" );
+  s = std::format(bloc, "{: L}", 999.44);
+  VERIFY( s == " 999.44" );
+
   // Restore
   std::locale::global(cloc);
 }

commit f30f1c70553ddbe688f812c474406dd863549597
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Thu Jun 12 02:24:37 2025

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index a3ea83c2661..b1bf7be3549 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20250611
+20250612
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index bd13b97e6d9..6a76947d89a 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,35 @@
+2025-06-11  Jonathan Wakely  <jwakely@redhat.com>
+
+	Backported from master:
+	2025-06-05  Jonathan Wakely  <jwakely@redhat.com>
+
+	PR libstdc++/120548
+	* include/std/format (__formatter_fp::_M_localize): Do not
+	include a leading sign character in the string to be grouped.
+	* testsuite/std/format/functions/format.cc: Check grouping when
+	sign is present in the output.
+
+2025-06-11  Jonathan Wakely  <jwakely@redhat.com>
+
+	Backported from master:
+	2024-09-14  Jonathan Wakely  <jwakely@redhat.com>
+
+	* include/std/format (__formatter_fp::_M_localize): Add comments
+	and micro-optimize string copy.
+
+2025-06-11  Jonathan Wakely  <jwakely@redhat.com>
+
+	Backported from master:
+	2025-06-04  Jonathan Wakely  <jwakely@redhat.com>
+
+	PR libstdc++/99832
+	* include/bits/chrono.h (system_clock::to_time_t): Add
+	always_inline attribute to be agnostic to the underlying type of
+	time_t.
+	(system_clock::from_time_t): Add always_inline for consistency
+	with to_time_t.
+	* testsuite/20_util/system_clock/99832.cc: New test.
+
 2025-06-10  Jonathan Wakely  <jwakely@redhat.com>
 
 	Backported from master:

commit 8cafd5800e20bf4eb67b818d5ab8ec43dfb5dd32
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Fri Jun 13 02:23:25 2025

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index b1bf7be3549..c544224c344 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20250612
+20250613

commit 46c2de7a8560d1fcaaeaf986d90b23d70cf48dd7
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Tue May 20 08:21:14 2025

    tree-chrec: Use signed_type_for in convert_affine_scev
    
    On s390x-linux I've run into the gcc.dg/torture/bitint-27.c test ICEing in
    build_nonstandard_integer_type called from convert_affine_scev (not sure
    why it doesn't trigger on x86_64/aarch64).
    The problem is clear, when ct is a BITINT_TYPE with some large
    TYPE_PRECISION, build_nonstandard_integer_type won't really work on it.
    
    The patch fixes it similarly what has been done for GCC 14 in various
    other spots.
    
    2025-05-20  Jakub Jelinek  <jakub@redhat.com>
    
            * tree-chrec.cc (convert_affine_scev): Use signed_type_for instead of
            build_nonstandard_integer_type.
    
    (cherry picked from commit e38027c8ff449ffadaca449004bb891b9094ad00)

diff --git a/gcc/tree-chrec.cc b/gcc/tree-chrec.cc
index 9b272074a2e..d4b308e1717 100644
--- a/gcc/tree-chrec.cc
+++ b/gcc/tree-chrec.cc
@@ -1490,7 +1490,7 @@ convert_affine_scev (class loop *loop, tree type,
   new_step = *step;
   if (TYPE_PRECISION (step_type) > TYPE_PRECISION (ct) && TYPE_UNSIGNED (ct))
     {
-      tree signed_ct = build_nonstandard_integer_type (TYPE_PRECISION (ct), 0);
+      tree signed_ct = signed_type_for (ct);
       new_step = chrec_convert (signed_ct, new_step, at_stmt,
                                 use_overflow_semantics);
     }

commit 9148510b2c75c71dfd7e2145fa203102fe2138e4
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Thu Jun 5 15:47:19 2025

    real: Fix up real_from_integer [PR120547]
    
    The function has 2 problems, one is _BitInt specific and the other is
    most likely also reproduceable only with it.
    
    The first issue is that I've missed updating the function for _BitInt,
    maxbitlen as MAX_BITSIZE_MODE_ANY_INT + HOST_BITS_PER_WIDE_INT
    obviously isn't guaranteed to be larger than any integral type we might
    want to convert at compile time from wide_int to REAL_VALUE_FORMAT.
    Just using len instead of it works fine, at least when used after
    HOST_BITS_PER_WIDE_INT is added to it and it is truncated to multiples
    of HOST_BITS_PER_WIDE_INT.
    
    The other bug is that if the value has too many significant bits (formerly
    maxbitlen - cnt_l_z, now len - cnt_l_z), the code just shifts it right and
    adds the shift count to the future exponent.  That isn't correct for
    rounding as the testcase attempts to show, the internal real format has more
    bits than any precision in supported format, but we still need to
    distinguish bewtween values exactly half way between representable floating
    point values (those should be rounded to even) and the case when we've
    shifted away some non-zero bits, so the value was tiny bit larger than half
    way and then we should round up.
    
    The patch uses something like e.g. soft-fp uses in these cases, right shift
    with sticky bit in the least significant bit.
    
    2025-06-05  Jakub Jelinek  <jakub@redhat.com>
    
            PR middle-end/120547
            * real.cc (real_from_integer): Remove maxbitlen variable, use
            len instead of that.  When shifting right, or in 1 if any of the
            shifted away bits are non-zero.  Formatting fix.
    
            * gcc.dg/bitint-123.c: New test.
    
    (cherry picked from commit ea9ea72e448e391d4be781b74956a0190f93afc8)

diff --git a/gcc/real.cc b/gcc/real.cc
index 4a6a6e76a99..4d88a416cb7 100644
--- a/gcc/real.cc
+++ b/gcc/real.cc
@@ -2230,7 +2230,6 @@ real_from_integer (REAL_VALUE_TYPE *r, format_helper fmt,
     {
       unsigned int len = val_in.get_precision ();
       int i, j, e = 0;
-      int maxbitlen = MAX_BITSIZE_MODE_ANY_INT + HOST_BITS_PER_WIDE_INT;
       const unsigned int realmax = (SIGNIFICAND_BITS / HOST_BITS_PER_WIDE_INT
 				    * HOST_BITS_PER_WIDE_INT);
 
@@ -2238,12 +2237,6 @@ real_from_integer (REAL_VALUE_TYPE *r, format_helper fmt,
       r->cl = rvc_normal;
       r->sign = wi::neg_p (val_in, sgn);
 
-      /* We have to ensure we can negate the largest negative number.  */
-      wide_int val = wide_int::from (val_in, maxbitlen, sgn);
-
-      if (r->sign)
-	val = -val;
-
       /* Ensure a multiple of HOST_BITS_PER_WIDE_INT, ceiling, as elt
 	 won't work with precisions that are not a multiple of
 	 HOST_BITS_PER_WIDE_INT.  */
@@ -2252,7 +2245,13 @@ real_from_integer (REAL_VALUE_TYPE *r, format_helper fmt,
       /* Ensure we can represent the largest negative number.  */
       len += 1;
 
-      len = len/HOST_BITS_PER_WIDE_INT * HOST_BITS_PER_WIDE_INT;
+      len = len / HOST_BITS_PER_WIDE_INT * HOST_BITS_PER_WIDE_INT;
+
+      /* We have to ensure we can negate the largest negative number.  */
+      wide_int val = wide_int::from (val_in, len, sgn);
+
+      if (r->sign)
+	val = -val;
 
       /* Cap the size to the size allowed by real.h.  */
       if (len > realmax)
@@ -2260,14 +2259,18 @@ real_from_integer (REAL_VALUE_TYPE *r, format_helper fmt,
 	  HOST_WIDE_INT cnt_l_z;
 	  cnt_l_z = wi::clz (val);
 
-	  if (maxbitlen - cnt_l_z > realmax)
+	  if (len - cnt_l_z > realmax)
 	    {
-	      e = maxbitlen - cnt_l_z - realmax;
+	      e = len - cnt_l_z - realmax;
 
 	      /* This value is too large, we must shift it right to
 		 preserve all the bits we can, and then bump the
-		 exponent up by that amount.  */
-	      val = wi::lrshift (val, e);
+		 exponent up by that amount, but or in 1 if any of
+		 the shifted out bits are non-zero.  */
+	      if (wide_int::from (val, e, UNSIGNED) != 0)
+		val = wi::set_bit (wi::lrshift (val, e), 0);
+	      else
+		val = wi::lrshift (val, e);
 	    }
 	  len = realmax;
 	}
diff --git a/gcc/testsuite/gcc.dg/bitint-123.c b/gcc/testsuite/gcc.dg/bitint-123.c
new file mode 100644
index 00000000000..4d019a98fdf
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/bitint-123.c
@@ -0,0 +1,26 @@
+/* PR middle-end/120547 */
+/* { dg-do run { target bitint } } */
+/* { dg-options "-O2" } */
+/* { dg-add-options float64 } */
+/* { dg-require-effective-target float64 } */
+
+#define CHECK(x, y) \
+  if ((_Float64) x != (_Float64) y				\
+      || (_Float64) (x + 1) != (_Float64) (y + 1))		\
+    __builtin_abort ()
+
+int
+main ()
+{
+  unsigned long long a = 0x20000000000001ULL << 7;
+  volatile unsigned long long b = a;
+  CHECK (a, b);
+#if __BITINT_MAXWIDTH__ >= 4096
+  unsigned _BitInt(4096) c = ((unsigned _BitInt(4096)) 0x20000000000001ULL) << 253;
+  volatile unsigned _BitInt(4096) d = c;
+  CHECK (c, d);
+  unsigned _BitInt(4096) e = ((unsigned _BitInt(4096)) 0x20000000000001ULL) << 931;
+  volatile unsigned _BitInt(4096) f = e;
+  CHECK (e, f);
+#endif
+}

commit 7dbf4964b80eaa5f047be24949e294b8b25a2419
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Thu Jun 12 20:22:39 2025

    recip: Reset range info when replacing sqrt with rsqrt [PR120638]
    
    This pass reuses a SSA_NAME on the lhs of sqrt etc. call as lhs
    of .RSQRT etc. call.  The following testcase is miscompiled since my recent
    ranger cast changes, because we compute (correct) range for sqrtf argument
    as well as result but then recip pass keeps using that range for the .RQSRT
    call which returns 1. / sqrt, so the function then returns 0.5f
    unconditionally.
    Note, on foo this is a regression from GCC 15, but on bar it regressed
    already with the r14-536 change.
    
    2025-06-12  Jakub Jelinek  <jakub@redhat.com>
    
            PR tree-optimization/120638
            * tree-ssa-math-opts.cc (pass_cse_reciprocals::execute): Call
            reset_flow_sensitive_info on arg1.
    
            * gcc.dg/pr120638.c: New test.
    
    (cherry picked from commit 8804e5b5b127b27d099d0c361fa2161d0b13edef)

diff --git a/gcc/testsuite/gcc.dg/pr120638.c b/gcc/testsuite/gcc.dg/pr120638.c
new file mode 100644
index 00000000000..4a057a02847
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr120638.c
@@ -0,0 +1,31 @@
+/* PR tree-optimization/120638 */
+/* { dg-do run } */
+/* { dg-options "-O2 -ffast-math" } */
+
+extern float sqrtf (float x);
+
+__attribute__((noipa)) float
+foo (unsigned int s)
+{
+  return 0.5f / sqrtf (1.f + s);
+}
+
+__attribute__((noipa)) float
+bar (float s)
+{
+  if (s < 0.0 || s > 65535.0f)
+    __builtin_unreachable ();
+  return 0.5f / sqrtf (1.f + s);
+}
+
+int
+main ()
+{
+  if (__builtin_fabsf (foo (3) - 0.25f) > 0.00390625f
+      || __builtin_fabsf (foo (15) - 0.125f) > 0.00390625f
+      || __builtin_fabsf (foo (63) - 0.0625f) > 0.00390625f
+      || __builtin_fabsf (bar (3.0f) - 0.25f) > 0.00390625f
+      || __builtin_fabsf (bar (15.0f) - 0.125f) > 0.00390625f
+      || __builtin_fabsf (bar (63.0f) - 0.0625f) > 0.00390625f)
+    __builtin_abort ();
+}
diff --git a/gcc/tree-ssa-math-opts.cc b/gcc/tree-ssa-math-opts.cc
index 60cc0c2a3eb..92ea322de03 100644
--- a/gcc/tree-ssa-math-opts.cc
+++ b/gcc/tree-ssa-math-opts.cc
@@ -1052,6 +1052,7 @@ pass_cse_reciprocals::execute (function *fun)
 		    continue;
 
 		  gimple_replace_ssa_lhs (call, arg1);
+		  reset_flow_sensitive_info (arg1);
 		  if (gimple_call_internal_p (call) != (ifn != IFN_LAST))
 		    {
 		      auto_vec<tree, 4> args;

commit ef18d9570a48bab3d3c54e5d3f72b0611c891035
Author: Richard Earnshaw <rearnsha@arm.com>
Date:   Thu Mar 20 15:42:59 2025

    opcodes: fix wrong code in expand_binop_directly [PR117811]
    
    If expand_binop_directly fails to add a REG_EQUAL note it tries to
    unwind and restart.  But it can unwind too far if expand_binop changed
    some of the operands before calling it.  We don't need to unwind that
    far anyway since we should end up taking exactly the same route next
    time, just without a target rtx.
    
    To fix this we remove LAST from the argument list and let the callers
    (all in expand_binop) do their own unwinding if the call fails.
    Instead we unwind just as far as the entry to expand_binop_directly
    and recurse within this function instead of all the way back up.
    
    gcc/ChangeLog:
    
            PR middle-end/117811
            * optabs.cc (expand_binop_directly): Remove LAST as an argument,
            instead record the last insn on entry.  Only delete insns if
            we need to restart and restart by calling ourself, not expand_binop.
            (expand_binop): Update callers to expand_binop_directly.  If it
            fails to expand the operation, delete back to LAST.
    
    gcc/testsuite:
    
            PR middle-end/117811
            * gcc.dg/torture/pr117811.c: New test.
    
    (cherry picked from commit 7679b826840c58343d72d05922355b646db4bdcc)

diff --git a/gcc/optabs.cc b/gcc/optabs.cc
index ce91f94ed43..84446f566d7 100644
--- a/gcc/optabs.cc
+++ b/gcc/optabs.cc
@@ -1368,8 +1368,7 @@ avoid_expensive_constant (machine_mode mode, optab binoptab,
 static rtx
 expand_binop_directly (enum insn_code icode, machine_mode mode, optab binoptab,
 		       rtx op0, rtx op1,
-		       rtx target, int unsignedp, enum optab_methods methods,
-		       rtx_insn *last)
+		       rtx target, int unsignedp, enum optab_methods methods)
 {
   machine_mode xmode0 = insn_data[(int) icode].operand[1].mode;
   machine_mode xmode1 = insn_data[(int) icode].operand[2].mode;
@@ -1379,6 +1378,7 @@ expand_binop_directly (enum insn_code icode, machine_mode mode, optab binoptab,
   rtx_insn *pat;
   rtx xop0 = op0, xop1 = op1;
   bool canonicalize_op1 = false;
+  rtx_insn *last = get_last_insn ();
 
   /* If it is a commutative operator and the modes would match
      if we would swap the operands, we can save the conversions.  */
@@ -1443,10 +1443,7 @@ expand_binop_directly (enum insn_code icode, machine_mode mode, optab binoptab,
       tmp_mode = insn_data[(int) icode].operand[0].mode;
       if (VECTOR_MODE_P (mode)
 	  && maybe_ne (GET_MODE_NUNITS (tmp_mode), 2 * GET_MODE_NUNITS (mode)))
-	{
-	  delete_insns_since (last);
-	  return NULL_RTX;
-	}
+	return NULL_RTX;
     }
   else
     tmp_mode = mode;
@@ -1466,14 +1463,14 @@ expand_binop_directly (enum insn_code icode, machine_mode mode, optab binoptab,
 			       ops[1].value, ops[2].value, mode0))
 	{
 	  delete_insns_since (last);
-	  return expand_binop (mode, binoptab, op0, op1, NULL_RTX,
-			       unsignedp, methods);
+	  return expand_binop_directly (icode, mode, binoptab, op0, op1,
+					NULL_RTX, unsignedp, methods);
 	}
 
       emit_insn (pat);
       return ops[0].value;
     }
-  delete_insns_since (last);
+
   return NULL_RTX;
 }
 
@@ -1542,9 +1539,10 @@ expand_binop (machine_mode mode, optab binoptab, rtx op0, rtx op1,
       if (icode != CODE_FOR_nothing)
 	{
 	  temp = expand_binop_directly (icode, mode, binoptab, op0, op1,
-					target, unsignedp, methods, last);
+					target, unsignedp, methods);
 	  if (temp)
 	    return temp;
+	  delete_insns_since (last);
 	}
     }
 
@@ -1570,9 +1568,10 @@ expand_binop (machine_mode mode, optab binoptab, rtx op0, rtx op1,
 			       NULL_RTX, unsignedp, OPTAB_DIRECT);
 
       temp = expand_binop_directly (icode, int_mode, otheroptab, op0, newop1,
-				    target, unsignedp, methods, last);
+				    target, unsignedp, methods);
       if (temp)
 	return temp;
+      delete_insns_since (last);
     }
 
   /* If this is a multiply, see if we can do a widening operation that
@@ -1636,9 +1635,10 @@ expand_binop (machine_mode mode, optab binoptab, rtx op0, rtx op1,
 	  if (vop1)
 	    {
 	      temp = expand_binop_directly (icode, mode, otheroptab, op0, vop1,
-					    target, unsignedp, methods, last);
+					    target, unsignedp, methods);
 	      if (temp)
 		return temp;
+	      delete_insns_since (last);
 	    }
 	}
     }
diff --git a/gcc/testsuite/gcc.dg/torture/pr117811.c b/gcc/testsuite/gcc.dg/torture/pr117811.c
new file mode 100644
index 00000000000..13d7e134780
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr117811.c
@@ -0,0 +1,27 @@
+/* { dg-do run } */
+
+#include <string.h>
+
+typedef int v4 __attribute__((vector_size (4 * sizeof (int))));
+
+void __attribute__((noclone,noinline)) do_shift (v4 *vec, int shift)
+{
+  v4 t = *vec;
+
+  if (shift > 0)
+  {
+    t = t >> shift;
+  }
+
+  *vec = t;
+}
+
+int main ()
+{
+  v4 vec =  {0x1000000, 0x2000, 0x300, 0x40};
+  v4 vec2 = {0x100000,  0x200,  0x30,  0x4};
+  do_shift (&vec, 4);
+  if (memcmp (&vec, &vec2, sizeof (v4)) != 0)
+    __builtin_abort ();
+  return 0;
+}

commit ddf8b0e06f27667b689dbd970d6c4ab0f088d671
Author: Georg-Johann Lay <avr@gjlay.de>
Date:   Thu Jun 12 10:07:37 2025

    Fix test case for PR117811 which failed for int < 32 bit.
    
            PR middle-end/117811
            PR testsuite/52641
    gcc/testsuite/
            * gcc.dg/torture/pr117811.c: Fix for int < 32 bit.
    
    (cherry picked from commit 07f229c2d7ee6b604e5a86092e675d5d36c1ba4e)

diff --git a/gcc/testsuite/gcc.dg/torture/pr117811.c b/gcc/testsuite/gcc.dg/torture/pr117811.c
index 13d7e134780..05e8622f25e 100644
--- a/gcc/testsuite/gcc.dg/torture/pr117811.c
+++ b/gcc/testsuite/gcc.dg/torture/pr117811.c
@@ -18,8 +18,13 @@ void __attribute__((noclone,noinline)) do_shift (v4 *vec, int shift)
 
 int main ()
 {
+#if __SIZEOF_INT__ >= 4
   v4 vec =  {0x1000000, 0x2000, 0x300, 0x40};
   v4 vec2 = {0x100000,  0x200,  0x30,  0x4};
+#else
+  v4 vec =  {0x4000, 0x2000, 0x300, 0x40};
+  v4 vec2 = {0x400,  0x200,  0x30,  0x4};
+#endif
   do_shift (&vec, 4);
   if (memcmp (&vec, &vec2, sizeof (v4)) != 0)
     __builtin_abort ();

commit b7f8f67a07a17c0b39a06b0b85917c8fb04212ce
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sat Jun 14 02:24:47 2025

    Daily bump.

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index de534a66c31..c914b28ba6b 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,42 @@
+2025-06-13  Richard Earnshaw  <rearnsha@arm.com>
+
+	Backported from master:
+	2025-03-25  Richard Earnshaw  <rearnsha@arm.com>
+
+	PR middle-end/117811
+	* optabs.cc (expand_binop_directly): Remove LAST as an argument,
+	instead record the last insn on entry.  Only delete insns if
+	we need to restart and restart by calling ourself, not expand_binop.
+	(expand_binop): Update callers to expand_binop_directly.  If it
+	fails to expand the operation, delete back to LAST.
+
+2025-06-13  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2025-06-12  Jakub Jelinek  <jakub@redhat.com>
+
+	PR tree-optimization/120638
+	* tree-ssa-math-opts.cc (pass_cse_reciprocals::execute): Call
+	reset_flow_sensitive_info on arg1.
+
+2025-06-13  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2025-06-05  Jakub Jelinek  <jakub@redhat.com>
+
+	PR middle-end/120547
+	* real.cc (real_from_integer): Remove maxbitlen variable, use
+	len instead of that.  When shifting right, or in 1 if any of the
+	shifted away bits are non-zero.  Formatting fix.
+
+2025-06-13  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2025-05-20  Jakub Jelinek  <jakub@redhat.com>
+
+	* tree-chrec.cc (convert_affine_scev): Use signed_type_for instead of
+	build_nonstandard_integer_type.
+
 2025-06-05  Eric Botcazou  <ebotcazou@adacore.com>
 
 	* tree-vect-data-refs.cc (vect_can_force_dr_alignment_p): Return
diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index c544224c344..b440a372cfd 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20250613
+20250614
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 89e6da052e2..b8c474ae5c6 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,36 @@
+2025-06-13  Georg-Johann Lay  <avr@gjlay.de>
+
+	Backported from master:
+	2025-06-12  Georg-Johann Lay  <avr@gjlay.de>
+
+	PR middle-end/117811
+	PR testsuite/52641
+	* gcc.dg/torture/pr117811.c: Fix for int < 32 bit.
+
+2025-06-13  Richard Earnshaw  <rearnsha@arm.com>
+
+	Backported from master:
+	2025-03-25  Richard Earnshaw  <rearnsha@arm.com>
+
+	PR middle-end/117811
+	* gcc.dg/torture/pr117811.c: New test.
+
+2025-06-13  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2025-06-12  Jakub Jelinek  <jakub@redhat.com>
+
+	PR tree-optimization/120638
+	* gcc.dg/pr120638.c: New test.
+
+2025-06-13  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2025-06-05  Jakub Jelinek  <jakub@redhat.com>
+
+	PR middle-end/120547
+	* gcc.dg/bitint-123.c: New test.
+
 2025-06-05  Eric Botcazou  <ebotcazou@adacore.com>
 
 	* gnat.dg/specs/opt7.ads: New test.

commit 23324900818ea9bd32512eedb25becf7ee3d7e8e
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sun Jun 15 02:23:51 2025

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index b440a372cfd..caed742bd6e 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20250614
+20250615

commit 9a61acc73ff93aed2ba30ffbb8b0adbd2bb0f6ba
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Mon Jun 16 02:23:36 2025

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index caed742bd6e..6597a2bbdbd 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20250615
+20250616

commit cb7784fd04deec1f94c20536709847786f2a90e6
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Tue Jun 17 02:24:20 2025

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 6597a2bbdbd..aaa22e3d56a 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20250616
+20250617

commit 73725df1ed001a5efb7363f62976402db6b6ff92
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Wed Jun 18 02:26:23 2025

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index aaa22e3d56a..016543e4365 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20250617
+20250618

commit 4744e90e87d0318f43d8e4461446f4ccf0f9e50d
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Thu Jun 19 02:26:17 2025

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 016543e4365..2aac90aa126 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20250618
+20250619

commit 153160c3f59c01ab864726abce66b4c3a0f2d909
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Wed Jun 18 08:07:22 2025

    dfp, real: Fix up FLOAT_EXPR/FIX_TRUNC_EXPR constant folding between dfp and large _BitInt [PR120631]
    
    The following testcase shows that while at runtime we handle conversions
    between _Decimal{64,128} and large _BitInt correctly, at compile time we
    mishandle them in both directions, in one direction we end up in ICE in
    decimal_from_integer callee because the char buffer is too short for the
    needed number of decimal digits, in the conversion of dfp to large _BitInt
    we return 0 in the wide_int.
    
    The following patch fixes the ICE by using larger buffer (XALLOCAVEC
    allocated, it will be never larger than 65536 / 3 bytes) in the larger
    _BitInt case, and the other direction by setting exponent to exp % 19
    and instead multiplying the result by needed powers of 10^19 (10^19 chosen
    as largest power of ten that can fit into UHWI).
    
    2025-06-18  Jakub Jelinek  <jakub@redhat.com>
    
            PR middle-end/120631
            * real.cc (decimal_from_integer): Add digits argument, if larger than
            256, use XALLOCAVEC allocated buffer.
            (real_from_integer): Pass val_in's precision divided by 3 to
            decimal_from_integer.
            * dfp.cc (decimal_real_to_integer): For precision > 128 if finite
            and exponent is large, decrease exponent and multiply resulting
            wide_int by powers of 10^19.
    
            * gcc.dg/dfp/bitint-9.c: New test.
    
    (cherry picked from commit f3002d664d1137844c714645a841a48ab57d0eaa)

diff --git a/gcc/dfp.cc b/gcc/dfp.cc
index 98437c6777a..ebd98974523 100644
--- a/gcc/dfp.cc
+++ b/gcc/dfp.cc
@@ -619,11 +619,21 @@ decimal_real_to_integer (const REAL_VALUE_TYPE *r, bool *fail, int precision)
   decNumber dn, dn2, dn3;
   REAL_VALUE_TYPE to;
   char string[256];
+  int scale = 0;
 
   decContextDefault (&set, DEC_INIT_DECIMAL128);
   set.traps = 0;
   set.round = DEC_ROUND_DOWN;
   decimal128ToNumber ((const decimal128 *) r->sig, &dn);
+  if (precision > 128 && decNumberIsFinite (&dn) && dn.exponent > 19)
+    {
+      /* libdecNumber doesn't really handle too large integers.
+	 So when precision is large and exponent as well, trim the
+	 exponent and adjust the resulting wide_int by multiplying
+	 it multiple times with 10^19.  */
+      scale = dn.exponent / 19;
+      dn.exponent %= 19;
+    }
 
   decNumberToIntegralValue (&dn2, &dn, &set);
   decNumberZero (&dn3);
@@ -633,7 +643,44 @@ decimal_real_to_integer (const REAL_VALUE_TYPE *r, bool *fail, int precision)
      function.  */
   decNumberToString (&dn, string);
   real_from_string (&to, string);
-  return real_to_integer (&to, fail, precision);
+  bool failp = false;
+  wide_int w = real_to_integer (&to, &failp, precision);
+  if (failp)
+    *fail = true;
+  if (scale && !failp)
+    {
+      wide_int wm = wi::uhwi (HOST_WIDE_INT_UC (10000000000000000000),
+			      w.get_precision ());
+      bool isneg = wi::neg_p (w);
+      if (isneg)
+	w = -w;
+      enum wi::overflow_type ovf = wi::OVF_NONE;
+      do
+	{
+	  if (scale & 1)
+	    {
+	      w = wi::umul (w, wm, &ovf);
+	      if (ovf)
+		break;
+	    }
+	  scale >>= 1;
+	  if (!scale)
+	    break;
+	  wm = wi::umul (wm, wm, &ovf);
+	}
+      while (!ovf);
+      if (ovf)
+	{
+	  *fail = true;
+	  if (isneg)
+	    return wi::set_bit_in_zero (precision - 1, precision);
+	  else
+	    return ~wi::set_bit_in_zero (precision - 1, precision);
+	}
+      if (isneg)
+	w = -w;
+    }
+  return w;
 }
 
 /* Perform the decimal floating point operation described by CODE.
diff --git a/gcc/real.cc b/gcc/real.cc
index 4d88a416cb7..87ec92d1778 100644
--- a/gcc/real.cc
+++ b/gcc/real.cc
@@ -101,7 +101,7 @@ static int do_compare (const REAL_VALUE_TYPE *, const REAL_VALUE_TYPE *, int);
 static void do_fix_trunc (REAL_VALUE_TYPE *, const REAL_VALUE_TYPE *);
 
 static unsigned long rtd_divmod (REAL_VALUE_TYPE *, REAL_VALUE_TYPE *);
-static void decimal_from_integer (REAL_VALUE_TYPE *);
+static void decimal_from_integer (REAL_VALUE_TYPE *, int);
 static void decimal_integer_string (char *, const REAL_VALUE_TYPE *,
 				    size_t);
 
@@ -2309,7 +2309,9 @@ real_from_integer (REAL_VALUE_TYPE *r, format_helper fmt,
     }
 
   if (fmt.decimal_p ())
-    decimal_from_integer (r);
+    /* We need at most one decimal digits for each 3 bits of input
+       precision.  */
+    decimal_from_integer (r, val_in.get_precision () / 3);
   if (fmt)
     real_convert (r, fmt, r);
 }
@@ -2364,12 +2366,21 @@ decimal_integer_string (char *str, const REAL_VALUE_TYPE *r_orig,
 /* Convert a real with an integral value to decimal float.  */
 
 static void
-decimal_from_integer (REAL_VALUE_TYPE *r)
+decimal_from_integer (REAL_VALUE_TYPE *r, int digits)
 {
   char str[256];
 
-  decimal_integer_string (str, r, sizeof (str) - 1);
-  decimal_real_from_string (r, str);
+  if (digits <= 256)
+    {
+      decimal_integer_string (str, r, sizeof (str) - 1);
+      decimal_real_from_string (r, str);
+    }
+  else
+    {
+      char *s = XALLOCAVEC (char, digits);
+      decimal_integer_string (s, r, digits - 1);
+      decimal_real_from_string (r, s);
+    }
 }
 
 /* Returns 10**2**N.  */
diff --git a/gcc/testsuite/gcc.dg/dfp/bitint-9.c b/gcc/testsuite/gcc.dg/dfp/bitint-9.c
new file mode 100644
index 00000000000..72155a01247
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/dfp/bitint-9.c
@@ -0,0 +1,29 @@
+/* PR middle-end/120631 */
+/* { dg-do run { target bitint } } */
+/* { dg-options "-O2" } */
+
+#if __BITINT_MAXWIDTH__ >= 2048
+_Decimal128 a = 123456789135792468012345678900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.0dl;
+_BitInt(2048) b = 123456789135792468012345678900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000wb;
+_Decimal64 c = 123456789135790000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.0dd;
+_BitInt(1536) d = 123456789135790000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000wb;
+#endif
+
+int
+main ()
+{
+#if __BITINT_MAXWIDTH__ >= 2048
+  if (a != b || (_BitInt(2048)) a != b || c != d || (_BitInt(1536)) c != d)
+    __builtin_abort ();
+  _Decimal128 e = 123456789135792468012345678900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.0dl;
+  _BitInt(2048) f = 123456789135792468012345678900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000wb;
+  _Decimal128 g = 123456789135792468012345678900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000wb;
+  _BitInt(2048) h = 123456789135792468012345678900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.0dl;
+  _Decimal64 i = 123456789135790000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.0dd;
+  _BitInt(1536) j = 123456789135790000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000wb;
+  _Decimal64 k = 123456789135790000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000wb;
+  _BitInt(1536) l = 123456789135790000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.0dd;
+  if (e != g || f != h || i != k || j != l)
+    __builtin_abort ();
+#endif
+}

commit e3cf9e55e394de211617333bbc3419c248d3e6b6
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Thu Jun 19 08:57:27 2025

    dfp: Further decimal_real_to_integer fixes [PR120631]
    
    Unfortunately, the following further testcase shows that there aren't
    problems only with very large precisions and large exponents, but pretty
    much anything larger than 64-bits.  After all, before _BitInt support dfp
    didn't even have {,unsigned }__int128 <-> _Decimal{32,64,128,64x} support,
    and the testcase again shows some of the conversions yielding zeros.
    While the pr120631.c test worked even without the earlier patch.
    
    So, this patch assumes 64-bit precision at most is ok and for anything
    larger it just uses exponent 0 and multiplies afterwards.
    
    2025-06-19  Jakub Jelinek  <jakub@redhat.com>
    
            PR middle-end/120631
            * dfp.cc (decimal_real_to_integer): Use result multiplication not just
            when precision > 128 and dn.exponent > 19, but when precision > 64
            and dn.exponent > 0.
    
            * gcc.dg/dfp/bitint-10.c: New test.
            * gcc.dg/dfp/pr120631.c: New test.
    
    (cherry picked from commit e2eb9da5546b5e2fccb86586cda3beee8f69f5c9)

diff --git a/gcc/dfp.cc b/gcc/dfp.cc
index ebd98974523..592693bd99c 100644
--- a/gcc/dfp.cc
+++ b/gcc/dfp.cc
@@ -625,14 +625,14 @@ decimal_real_to_integer (const REAL_VALUE_TYPE *r, bool *fail, int precision)
   set.traps = 0;
   set.round = DEC_ROUND_DOWN;
   decimal128ToNumber ((const decimal128 *) r->sig, &dn);
-  if (precision > 128 && decNumberIsFinite (&dn) && dn.exponent > 19)
+  if (precision > 64 && decNumberIsFinite (&dn) && dn.exponent > 0)
     {
       /* libdecNumber doesn't really handle too large integers.
 	 So when precision is large and exponent as well, trim the
 	 exponent and adjust the resulting wide_int by multiplying
-	 it multiple times with 10^19.  */
-      scale = dn.exponent / 19;
-      dn.exponent %= 19;
+	 it multiple times with powers of ten.  */
+      scale = dn.exponent;
+      dn.exponent = 0;
     }
 
   decNumberToIntegralValue (&dn2, &dn, &set);
@@ -649,13 +649,42 @@ decimal_real_to_integer (const REAL_VALUE_TYPE *r, bool *fail, int precision)
     *fail = true;
   if (scale && !failp)
     {
-      wide_int wm = wi::uhwi (HOST_WIDE_INT_UC (10000000000000000000),
-			      w.get_precision ());
       bool isneg = wi::neg_p (w);
       if (isneg)
 	w = -w;
       enum wi::overflow_type ovf = wi::OVF_NONE;
-      do
+      unsigned HOST_WIDE_INT pow10s[] = {
+	HOST_WIDE_INT_UC (10),
+	HOST_WIDE_INT_UC (100),
+	HOST_WIDE_INT_UC (1000),
+	HOST_WIDE_INT_UC (10000),
+	HOST_WIDE_INT_UC (100000),
+	HOST_WIDE_INT_UC (1000000),
+	HOST_WIDE_INT_UC (10000000),
+	HOST_WIDE_INT_UC (100000000),
+	HOST_WIDE_INT_UC (1000000000),
+	HOST_WIDE_INT_UC (10000000000),
+	HOST_WIDE_INT_UC (100000000000),
+	HOST_WIDE_INT_UC (1000000000000),
+	HOST_WIDE_INT_UC (10000000000000),
+	HOST_WIDE_INT_UC (100000000000000),
+	HOST_WIDE_INT_UC (1000000000000000),
+	HOST_WIDE_INT_UC (10000000000000000),
+	HOST_WIDE_INT_UC (100000000000000000),
+	HOST_WIDE_INT_UC (1000000000000000000),
+	HOST_WIDE_INT_UC (10000000000000000000),
+      };
+      int s = scale % 19;
+      if (s)
+	{
+	  wide_int wm = wi::uhwi (pow10s[s - 1], w.get_precision ());
+	  w = wi::umul (w, wm, &ovf);
+	  if (ovf)
+	    scale = 0;
+	}
+      scale /= 19;
+      wide_int wm = wi::uhwi (pow10s[18], w.get_precision ());
+      while (scale)
 	{
 	  if (scale & 1)
 	    {
@@ -667,8 +696,9 @@ decimal_real_to_integer (const REAL_VALUE_TYPE *r, bool *fail, int precision)
 	  if (!scale)
 	    break;
 	  wm = wi::umul (wm, wm, &ovf);
+	  if (ovf)
+	    break;
 	}
-      while (!ovf);
       if (ovf)
 	{
 	  *fail = true;
diff --git a/gcc/testsuite/gcc.dg/dfp/bitint-10.c b/gcc/testsuite/gcc.dg/dfp/bitint-10.c
new file mode 100644
index 00000000000..b48f0ea6c27
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/dfp/bitint-10.c
@@ -0,0 +1,49 @@
+/* PR middle-end/120631 */
+/* { dg-do run { target bitint } } */
+/* { dg-options "-O2" } */
+
+#if __BITINT_MAXWIDTH__ >= 128
+_Decimal128 a = 123456789135792468012345678900000000000.0dl;
+_BitInt(128) b = 123456789135792468012345678900000000000wb;
+_Decimal64 c = 12345678913579000000000000000000000000.0dd;
+_BitInt(127) d = 12345678913579000000000000000000000000wb;
+#endif
+#if __BITINT_MAXWIDTH__ >= 256
+_Decimal128 m = 1234567891357924680123456789000000000000000000000000000000000000000000000000.0dl;
+_BitInt(256) n = 1234567891357924680123456789000000000000000000000000000000000000000000000000wb;
+_Decimal64 o = 1234567891357900000000000000000000000000000000000000000000000000000000000000.0dd;
+_BitInt(255) p = 1234567891357900000000000000000000000000000000000000000000000000000000000000wb;
+#endif
+
+int
+main ()
+{
+#if __BITINT_MAXWIDTH__ >= 128
+  if (a != b || (_BitInt(128)) a != b || c != d || (_BitInt(127)) c != d)
+    __builtin_abort ();
+  _Decimal128 e = 123456789135792468012345678900000000000.0dl;
+  _BitInt(128) f = 123456789135792468012345678900000000000wb;
+  _Decimal128 g = 123456789135792468012345678900000000000wb;
+  _BitInt(128) h = 123456789135792468012345678900000000000.0dl;
+  _Decimal64 i = 12345678913579000000000000000000000000.0dd;
+  _BitInt(128) j = 12345678913579000000000000000000000000wb;
+  _Decimal64 k = 12345678913579000000000000000000000000wb;
+  _BitInt(128) l = 12345678913579000000000000000000000000.0dd;
+  if (e != g || f != h || i != k || j != l)
+    __builtin_abort ();
+#endif
+#if __BITINT_MAXWIDTH__ >= 256
+  if (m != n || (_BitInt(256)) m != n || o != p || (_BitInt(255)) o != p)
+    __builtin_abort ();
+  _Decimal128 q = 1234567891357924680123456789000000000000000000000000000000000000000000000000.0dl;
+  _BitInt(256) r = 1234567891357924680123456789000000000000000000000000000000000000000000000000wb;
+  _Decimal128 s = 1234567891357924680123456789000000000000000000000000000000000000000000000000wb;
+  _BitInt(256) t = 1234567891357924680123456789000000000000000000000000000000000000000000000000.0dl;
+  _Decimal64 u = 1234567891357900000000000000000000000000000000000000000000000000000000000000.0dd;
+  _BitInt(255) v = 1234567891357900000000000000000000000000000000000000000000000000000000000000wb;
+  _Decimal64 w = 1234567891357900000000000000000000000000000000000000000000000000000000000000wb;
+  _BitInt(255) x = 1234567891357900000000000000000000000000000000000000000000000000000000000000.0dd;
+  if (q != s || r != t || u != w || v != x)
+    __builtin_abort ();
+#endif
+}
diff --git a/gcc/testsuite/gcc.dg/dfp/pr120631.c b/gcc/testsuite/gcc.dg/dfp/pr120631.c
new file mode 100644
index 00000000000..2085ff7ba5a
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/dfp/pr120631.c
@@ -0,0 +1,25 @@
+/* PR middle-end/120631 */
+/* { dg-do run } */
+/* { dg-options "-O2" } */
+
+_Decimal64 a = 1234567891357900000.0dd;
+long long b = 1234567891357900000LL;
+_Decimal32 c = 1234567000000000000.0df;
+long long d = 1234567000000000000LL;
+
+int
+main ()
+{
+  if (a != b || (long long) a != b || c != d || (long long) c != d)
+    __builtin_abort ();
+  _Decimal64 e = 1234567891357900000.0dd;
+  long long f = 1234567891357900000LL;
+  _Decimal64 g = 1234567891357900000LL;
+  long long h = 1234567891357900000.0dd;
+  _Decimal32 i = 1234567000000000000.0df;
+  long long j = 1234567000000000000LL;
+  _Decimal32 k = 1234567000000000000LL;
+  long long l = 1234567000000000000.0df;
+  if (e != g || f != h || i != k || j != l)
+    __builtin_abort ();
+}

commit 9578e7eafa53c5236747f8de0aad007a1405f91b
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Fri Jun 20 02:27:41 2025

    Daily bump.

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index c914b28ba6b..69f9e3cac63 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,27 @@
+2025-06-19  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2025-06-19  Jakub Jelinek  <jakub@redhat.com>
+
+	PR middle-end/120631
+	* dfp.cc (decimal_real_to_integer): Use result multiplication not just
+	when precision > 128 and dn.exponent > 19, but when precision > 64
+	and dn.exponent > 0.
+
+2025-06-19  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2025-06-18  Jakub Jelinek  <jakub@redhat.com>
+
+	PR middle-end/120631
+	* real.cc (decimal_from_integer): Add digits argument, if larger than
+	256, use XALLOCAVEC allocated buffer.
+	(real_from_integer): Pass val_in's precision divided by 3 to
+	decimal_from_integer.
+	* dfp.cc (decimal_real_to_integer): For precision > 128 if finite
+	and exponent is large, decrease exponent and multiply resulting
+	wide_int by powers of 10^19.
+
 2025-06-13  Richard Earnshaw  <rearnsha@arm.com>
 
 	Backported from master:
diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 2aac90aa126..48356deb7cf 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20250619
+20250620
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index b8c474ae5c6..4a2c4c3d713 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,20 @@
+2025-06-19  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2025-06-19  Jakub Jelinek  <jakub@redhat.com>
+
+	PR middle-end/120631
+	* gcc.dg/dfp/bitint-10.c: New test.
+	* gcc.dg/dfp/pr120631.c: New test.
+
+2025-06-19  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2025-06-18  Jakub Jelinek  <jakub@redhat.com>
+
+	PR middle-end/120631
+	* gcc.dg/dfp/bitint-9.c: New test.
+
 2025-06-13  Georg-Johann Lay  <avr@gjlay.de>
 
 	Backported from master:

commit 638e90e5e8000b6b6b320b02229310c63c441b9f
Author: Richard Biener <rguenther@suse.de>
Date:   Wed Sep 11 13:54:33 2024

    tree-optimization/116674 - vectorizable_simd_clone_call and re-analysis
    
    When SLP analysis scraps an instance because it fails to analyze we
    can end up calling vectorizable_* in analysis mode on a node that
    was analyzed during the analysis of that instance again.
    vectorizable_simd_clone_call wasn't expecting that and instead
    guarded analysis/transform code on populated data structures.
    The following changes it so it survives re-analysis.
    
            PR tree-optimization/116674
            * tree-vect-stmts.cc (vectorizable_simd_clone_call): Support
            re-analysis.
    
            * g++.dg/vect/pr116674.cc: New testcase.
    
    (cherry picked from commit 09a514fbb67caf7e33a6ceddf524ee21024c33c5)

diff --git a/gcc/testsuite/g++.dg/vect/pr116674.cc b/gcc/testsuite/g++.dg/vect/pr116674.cc
new file mode 100644
index 00000000000..1c13f12290b
--- /dev/null
+++ b/gcc/testsuite/g++.dg/vect/pr116674.cc
@@ -0,0 +1,85 @@
+// { dg-do compile }
+// { dg-require-effective-target c++11 }
+// { dg-additional-options "-Ofast" }
+// { dg-additional-options "-march=x86-64-v3" { target { x86_64-*-* i?86-*-* } } }
+
+namespace std {
+    typedef int a;
+    template <typename> struct b;
+    template <typename> class aa {};
+    template <typename c> c d(c e, c) { return e; }
+    template <typename c> struct b<aa<c>> {
+	using f = c;
+	using g = c *;
+	template <typename h> using j = aa<h>;
+    };
+} // namespace std
+namespace l {
+    template <typename ab> struct m : std::b<ab> {
+	typedef std::b<ab> n;
+	typedef typename n::f &q;
+	template <typename c> struct ac { typedef typename n::j<c> ad; };
+    };
+} // namespace l
+namespace std {
+    template <typename c, typename ab> struct o {
+	typedef typename l::m<ab>::ac<c>::ad ae;
+	typedef typename l::m<ae>::g g;
+	struct p {
+	    g af;
+	};
+	struct ag : p {
+	    ag(ae) {}
+	};
+	typedef ab u;
+	o(a, u e) : ah(e) {}
+	ag ah;
+    };
+    template <typename c, typename ab = aa<c>> class r : o<c, ab> {
+	typedef o<c, ab> s;
+	typedef typename s::ae ae;
+	typedef l::m<ae> w;
+
+    public:
+	c f;
+	typedef typename w::q q;
+	typedef a t;
+	typedef ab u;
+	r(t x, u e = u()) : s(ai(x, e), e) {}
+	q operator[](t x) { return *(this->ah.af + x); }
+	t ai(t x, u) { return x; }
+    };
+    extern "C" __attribute__((__simd__)) double exp(double);
+} // namespace std
+using namespace std;
+int ak;
+double v, y;
+void am(double, int an, double, double, double, double, double, double, double,
+	double, double, double, int, double, double, double, double,
+	r<double> ap, double, double, double, double, double, double, double,
+	double, r<double> ar, r<double> as, double, double, r<double> at,
+	r<double> au, r<double> av, double, double) {
+    double ba;
+    for (int k;;)
+      for (int i; i < an; ++i) {
+	  y = i;
+	  v = d(y, 25.0);
+	  ba = exp(v);
+	  ar[i * (ak + 1)] = ba;
+	  as[i * (ak + 1)] = ar[i * (ak + 1)];
+	  if (k && ap[k]) {
+	      at[i * (ak + 1)] = av[i * (ak + 1)] = as[i * (ak + 1)];
+	      au[i * (ak + 1)] = ar[i * (ak + 1)];
+	  } else {
+	      au[i * (ak + 1)] = ba;
+	      at[i * (ak + 1)] = av[i * (ak + 1)] = k;
+	  }
+      }
+}
+void b(int bc) {
+    double bd, be, bf, bg, bh, ao, ap, bn, bo, bp, bq, br, bs, bt, bu, bv, bw, bx,
+    by, aq, ar, as, bz, ca, at, au, av, cb, aw;
+    int bi;
+    am(bh, bc, bi, bi, bi, bi, bv, bw, bx, by, bu, bt, bi, ao, bn, bo, bp, ap, bq,
+       br, bs, bd, be, bf, bg, aq, ar, as, bz, ca, at, au, av, cb, aw);
+}
diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc
index 307d989fbe3..ecac53bbbeb 100644
--- a/gcc/tree-vect-stmts.cc
+++ b/gcc/tree-vect-stmts.cc
@@ -3945,6 +3945,8 @@ vectorizable_simd_clone_call (vec_info *vinfo, stmt_vec_info stmt_info,
 
   vec<tree>& simd_clone_info = (slp_node ? SLP_TREE_SIMD_CLONE_INFO (slp_node)
 				: STMT_VINFO_SIMD_CLONE_INFO (stmt_info));
+  if (!vec_stmt)
+    simd_clone_info.truncate (0);
   arginfo.reserve (nargs, true);
   auto_vec<slp_tree> slp_op;
   slp_op.safe_grow_cleared (nargs);
@@ -3993,10 +3995,10 @@ vectorizable_simd_clone_call (vec_info *vinfo, stmt_vec_info stmt_info,
 
       /* For linear arguments, the analyze phase should have saved
 	 the base and step in {STMT_VINFO,SLP_TREE}_SIMD_CLONE_INFO.  */
-      if (i * 3 + 4 <= simd_clone_info.length ()
+      if (vec_stmt
+	  && i * 3 + 4 <= simd_clone_info.length ()
 	  && simd_clone_info[i * 3 + 2])
 	{
-	  gcc_assert (vec_stmt);
 	  thisarginfo.linear_step = tree_to_shwi (simd_clone_info[i * 3 + 2]);
 	  thisarginfo.op = simd_clone_info[i * 3 + 1];
 	  thisarginfo.simd_lane_linear
@@ -4051,7 +4053,7 @@ vectorizable_simd_clone_call (vec_info *vinfo, stmt_vec_info stmt_info,
   unsigned group_size = slp_node ? SLP_TREE_LANES (slp_node) : 1;
   unsigned int badness = 0;
   struct cgraph_node *bestn = NULL;
-  if (simd_clone_info.exists ())
+  if (vec_stmt)
     bestn = cgraph_node::get (simd_clone_info[0]);
   else
     for (struct cgraph_node *n = node->simd_clones; n != NULL;

commit 1a006539b736fa1a01f1659ad9ed214772089528
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sat Jun 21 02:24:00 2025

    Daily bump.

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 69f9e3cac63..2faa9cd4e4a 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,12 @@
+2025-06-20  Richard Biener  <rguenther@suse.de>
+
+	Backported from master:
+	2024-09-11  Richard Biener  <rguenther@suse.de>
+
+	PR tree-optimization/116674
+	* tree-vect-stmts.cc (vectorizable_simd_clone_call): Support
+	re-analysis.
+
 2025-06-19  Jakub Jelinek  <jakub@redhat.com>
 
 	Backported from master:
diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 48356deb7cf..51152be9a3a 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20250620
+20250621
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 4a2c4c3d713..9df44ef6c08 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,11 @@
+2025-06-20  Richard Biener  <rguenther@suse.de>
+
+	Backported from master:
+	2024-09-11  Richard Biener  <rguenther@suse.de>
+
+	PR tree-optimization/116674
+	* g++.dg/vect/pr116674.cc: New testcase.
+
 2025-06-19  Jakub Jelinek  <jakub@redhat.com>
 
 	Backported from master:

commit b73e3af567427fa394a1a4d78c2f562f8753738d
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sun Jun 22 02:23:27 2025

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 51152be9a3a..9ab4803a623 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20250621
+20250622

commit b588d028e85c879452aad962de7d3b71a6b524f0
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Mon Jun 23 02:23:52 2025

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 9ab4803a623..29fc2394183 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20250622
+20250623

commit 0cbd82f8d224031b09afe1fa392ead6d3f07a9c8
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Tue Jun 24 02:24:14 2025

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 29fc2394183..8bb1cc74550 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20250623
+20250624

commit 675844ec088a5c19081201cbc4750f64ecb0a21b
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Wed Jun 25 02:25:48 2025

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 8bb1cc74550..9acd59f73a9 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20250624
+20250625

commit 11b03928bab9a52e4ec43a3d5a0ab85e5a8ee67a
Author: Haochen Jiang <haochen.jiang@intel.com>
Date:   Tue Jun 17 08:08:38 2025

    i386: Remove CLDEMOTE for clients
    
    CLDEMOTE is not enabled on clients according to SDM. SDM only mentioned
    it will be enabled on Xeon and Atom servers, not clients. Remove them
    since Alder Lake (where it is introduced).
    
    gcc/ChangeLog:
    
            * config/i386/i386.h (PTA_ALDERLAKE): Use PTA_GOLDMONT_PLUS
            as base to remove PTA_CLDEMOTE.
            (PTA_SIERRAFOREST): Add PTA_CLDEMOTE since PTA_ALDERLAKE
            does not include that anymore.
            * doc/invoke.texi: Update texi file.

diff --git a/gcc/config/i386/i386.h b/gcc/config/i386/i386.h
index 2fc82b175e6..6a833fd8dbd 100644
--- a/gcc/config/i386/i386.h
+++ b/gcc/config/i386/i386.h
@@ -2415,12 +2415,14 @@ constexpr wide_int_bitmask PTA_GOLDMONT_PLUS = PTA_GOLDMONT | PTA_RDPID
   | PTA_SGX | PTA_PTWRITE;
 constexpr wide_int_bitmask PTA_TREMONT = PTA_GOLDMONT_PLUS | PTA_CLWB
   | PTA_GFNI | PTA_MOVDIRI | PTA_MOVDIR64B | PTA_CLDEMOTE | PTA_WAITPKG;
-constexpr wide_int_bitmask PTA_ALDERLAKE = PTA_TREMONT | PTA_ADX | PTA_AVX
+constexpr wide_int_bitmask PTA_ALDERLAKE = PTA_GOLDMONT_PLUS | PTA_CLWB
+  | PTA_GFNI | PTA_MOVDIRI | PTA_MOVDIR64B | PTA_WAITPKG | PTA_ADX | PTA_AVX
   | PTA_AVX2 | PTA_BMI | PTA_BMI2 | PTA_F16C | PTA_FMA | PTA_LZCNT
   | PTA_PCONFIG | PTA_PKU | PTA_VAES | PTA_VPCLMULQDQ | PTA_SERIALIZE
   | PTA_HRESET | PTA_KL | PTA_WIDEKL | PTA_AVXVNNI;
-constexpr wide_int_bitmask PTA_SIERRAFOREST = PTA_ALDERLAKE | PTA_AVXIFMA
-  | PTA_AVXVNNIINT8 | PTA_AVXNECONVERT | PTA_CMPCCXADD | PTA_ENQCMD | PTA_UINTR;
+constexpr wide_int_bitmask PTA_SIERRAFOREST = PTA_ALDERLAKE | PTA_CLDEMOTE
+  | PTA_AVXIFMA | PTA_AVXVNNIINT8 | PTA_AVXNECONVERT | PTA_CMPCCXADD
+  | PTA_ENQCMD | PTA_UINTR;
 constexpr wide_int_bitmask PTA_GRANITERAPIDS = PTA_SAPPHIRERAPIDS | PTA_AMX_FP16
   | PTA_PREFETCHI;
 constexpr wide_int_bitmask PTA_GRANITERAPIDS_D = PTA_GRANITERAPIDS
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 64728fead51..d8ff23447f4 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -34514,37 +34514,36 @@ VPCLMULQDQ, AVX512BITALG, RDPID and AVX512VPOPCNTDQ instruction set support.
 Intel Alder Lake/Raptor Lake/Meteor Lake/Gracemont CPU with 64-bit extensions,
 MOVBE, MMX, SSE, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW,
 PCLMUL, RDRND, XSAVE, XSAVEC, XSAVES, XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX,
-GFNI-SSE, CLWB, MOVDIRI, MOVDIR64B, CLDEMOTE, WAITPKG, ADCX, AVX, AVX2, BMI,
-BMI2, F16C, FMA, LZCNT, PCONFIG, PKU, VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL,
-WIDEKL and AVX-VNNI instruction set support.
+GFNI-SSE, CLWB, MOVDIRI, MOVDIR64B, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C,
+FMA, LZCNT, PCONFIG, PKU, VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL and
+AVX-VNNI instruction set support.
 
 @item arrowlake
 Intel Arrow Lake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
 SSSE3, SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND, XSAVE, XSAVEC,
 XSAVES, XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX, GFNI-SSE, CLWB, MOVDIRI,
-MOVDIR64B, CLDEMOTE, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA, LZCNT,
-PCONFIG, PKU, VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL, AVX-VNNI,
-UINTR, AVXIFMA, AVXVNNIINT8, AVXNECONVERT and CMPCCXADD instruction set
-support.
+MOVDIR64B, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA, LZCNT, PCONFIG, PKU,
+VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL, AVX-VNNI, UINTR, AVXIFMA,
+AVXVNNIINT8, AVXNECONVERT and CMPCCXADD instruction set support.
 
 @item arrowlake-s
 @itemx lunarlake
 Intel Arrow Lake S/Lunar Lake CPU with 64-bit extensions, MOVBE, MMX, SSE,
 SSE2, SSE3, SSSE3, SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND,
 XSAVE, XSAVEC, XSAVES, XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX, GFNI-SSE, CLWB,
-MOVDIRI, MOVDIR64B, CLDEMOTE, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA,
-LZCNT, PCONFIG, PKU, VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL, AVX-VNNI,
-UINTR, AVXIFMA, AVXVNNIINT8, AVXNECONVERT, CMPCCXADD, AVXVNNIINT16, SHA512,
-SM3 and SM4 instruction set support.
+MOVDIRI, MOVDIR64B, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA, LZCNT,
+PCONFIG, PKU, VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL, AVX-VNNI, UINTR,
+AVXIFMA, AVXVNNIINT8, AVXNECONVERT, CMPCCXADD, AVXVNNIINT16, SHA512, SM3 and
+SM4 instruction set support.
 
 @item pantherlake
 Intel Panther Lake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
 SSSE3, SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND, XSAVE, XSAVEC,
 XSAVES, XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX, GFNI-SSE, CLWB, MOVDIRI,
-MOVDIR64B, CLDEMOTE, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA, LZCNT,
-PCONFIG, PKU, VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL, AVX-VNNI,
-UINTR, AVXIFMA, AVXVNNIINT8, AVXNECONVERT, CMPCCXADD, AVXVNNIINT16, SHA512,
-SM3, SM4 and PREFETCHI instruction set support.
+MOVDIR64B, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA, LZCNT, PCONFIG, PKU,
+VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL, AVX-VNNI, UINTR, AVXIFMA,
+AVXVNNIINT8, AVXNECONVERT, CMPCCXADD, AVXVNNIINT16, SHA512, SM3, SM4 and
+PREFETCHI instruction set support.
 
 @item sapphirerapids
 @itemx emeraldrapids

commit 3dc96635f365553920607f18100bfce767df46c7
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Thu Jun 26 02:25:14 2025

    Daily bump.

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 2faa9cd4e4a..d585dde9dad 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,11 @@
+2025-06-25  Haochen Jiang  <haochen.jiang@intel.com>
+
+	* config/i386/i386.h (PTA_ALDERLAKE): Use PTA_GOLDMONT_PLUS
+	as base to remove PTA_CLDEMOTE.
+	(PTA_SIERRAFOREST): Add PTA_CLDEMOTE since PTA_ALDERLAKE
+	does not include that anymore.
+	* doc/invoke.texi: Update texi file.
+
 2025-06-20  Richard Biener  <rguenther@suse.de>
 
 	Backported from master:
diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 9acd59f73a9..efcd83eefd6 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20250625
+20250626

commit c846f9d5d6ff7b8a634004f33392cd8bc5760e20
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Fri Jun 27 02:26:46 2025

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index efcd83eefd6..b128998250b 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20250626
+20250627

commit 570b63276f6434df59c52da36b1581eb8b516762
Author: Eric Botcazou <ebotcazou@adacore.com>
Date:   Fri Jun 27 23:47:49 2025

    Fix misoptimization of CONSTRUCTOR with reverse SSO
    
    fold_ctor_reference already punts on a CONSTRUCTOR whose type has reverse
    storage order, but it can be invoked in a couple of places on a CONSTRUCTOR
    with native storage order that has been wrapped in a VIEW_CONVERT_EXPR to a
    type with reverse storage order; this would require a post adjustment that
    does not currently exist, thus yield wrong code for this admittedly quite
    pathological (but supported) case.
    
    gcc/
            * gimple-fold.cc (fold_const_aggregate_ref_1) <COMPONENT_REF>:
            Bail out immediately if the reference has reverse storage order.
            * tree-ssa-sccvn.cc (fully_constant_vn_reference_p): Likewise.
    gcc/testsuite/
            * gnat.dg/sso20.adb: New test.

diff --git a/gcc/gimple-fold.cc b/gcc/gimple-fold.cc
index 0d90bab595f..026dac45ded 100644
--- a/gcc/gimple-fold.cc
+++ b/gcc/gimple-fold.cc
@@ -8444,19 +8444,21 @@ fold_const_aggregate_ref_1 (tree t, tree (*valueize) (tree))
       base = get_ref_base_and_extent (t, &offset, &size, &max_size, &reverse);
       ctor = get_base_constructor (base, &offset, valueize);
 
-      /* Empty constructor.  Always fold to 0.  */
-      if (ctor == error_mark_node)
-	return build_zero_cst (TREE_TYPE (t));
-      /* We do not know precise address.  */
-      if (!known_size_p (max_size) || maybe_ne (max_size, size))
-	return NULL_TREE;
       /* We cannot determine ctor.  */
       if (!ctor)
 	return NULL_TREE;
-
+      /* Empty constructor.  Always fold to 0.  */
+      if (ctor == error_mark_node)
+	return build_zero_cst (TREE_TYPE (t));
+      /* We do not know precise access.  */
+      if (!known_size_p (max_size) || maybe_ne (max_size, size))
+	return NULL_TREE;
       /* Out of bound array access.  Value is undefined, but don't fold.  */
       if (maybe_lt (offset, 0))
 	return NULL_TREE;
+      /* Access with reverse storage order.  */
+      if (reverse)
+	return NULL_TREE;
 
       tem = fold_ctor_reference (TREE_TYPE (t), ctor, offset, size, base);
       if (tem)
@@ -8476,7 +8478,6 @@ fold_const_aggregate_ref_1 (tree t, tree (*valueize) (tree))
 	      && offset.is_constant (&coffset)
 	      && (coffset % BITS_PER_UNIT != 0
 		  || csize % BITS_PER_UNIT != 0)
-	      && !reverse
 	      && BYTES_BIG_ENDIAN == WORDS_BIG_ENDIAN)
 	    {
 	      poly_int64 bitoffset;
diff --git a/gcc/testsuite/gnat.dg/sso20.adb b/gcc/testsuite/gnat.dg/sso20.adb
new file mode 100644
index 00000000000..34980d35d87
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/sso20.adb
@@ -0,0 +1,29 @@
+--  { dg-do run }
+--  { dg-options "-O" }
+
+with Ada.Unchecked_Conversion;
+with Interfaces;  use Interfaces;
+with System;      use System;
+
+procedure SSO20 is
+
+  type Bytes_Ref is array (1 .. 4) of Unsigned_8
+    with Convention => Ada_Pass_By_Reference;
+
+  type U32_BE is record
+    Value : Unsigned_32;
+  end record
+    with
+      Pack,
+      Bit_Order            => High_Order_First,
+      Scalar_Storage_Order => High_Order_First;
+
+  function Conv is new Ada.Unchecked_Conversion (Bytes_Ref, U32_BE);
+
+  function Value (B : Bytes_Ref) return Unsigned_32 is (Conv (B).Value);
+
+begin
+  if Value ((16#11#, 16#22#, 16#33#, 16#44#)) /= 16#11223344# then
+     raise Program_Error;
+  end if;
+end;
diff --git a/gcc/tree-ssa-sccvn.cc b/gcc/tree-ssa-sccvn.cc
index debfd1d0435..209c8a1d76b 100644
--- a/gcc/tree-ssa-sccvn.cc
+++ b/gcc/tree-ssa-sccvn.cc
@@ -1592,6 +1592,8 @@ fully_constant_vn_reference_p (vn_reference_t ref)
 	      ++i;
 	      break;
 	    }
+	  if (operands[i].reverse)
+	    return NULL_TREE;
 	  if (known_eq (operands[i].off, -1))
 	    return NULL_TREE;
 	  off += operands[i].off;

commit 0048071865dfe24d0b4973d3087678f7fd2f41e3
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sat Jun 28 02:27:19 2025

    Daily bump.

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index d585dde9dad..f891157a62b 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2025-06-27  Eric Botcazou  <ebotcazou@adacore.com>
+
+	* gimple-fold.cc (fold_const_aggregate_ref_1) <COMPONENT_REF>:
+	Bail out immediately if the reference has reverse storage order.
+	* tree-ssa-sccvn.cc (fully_constant_vn_reference_p): Likewise.
+
 2025-06-25  Haochen Jiang  <haochen.jiang@intel.com>
 
 	* config/i386/i386.h (PTA_ALDERLAKE): Use PTA_GOLDMONT_PLUS
diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index b128998250b..89bcad6c215 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20250627
+20250628
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 9df44ef6c08..6cbaf041da5 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2025-06-27  Eric Botcazou  <ebotcazou@adacore.com>
+
+	* gnat.dg/sso20.adb: New test.
+
 2025-06-20  Richard Biener  <rguenther@suse.de>
 
 	Backported from master:

commit 183b21bae4c30927856af6a305bc1c038f15631f
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sun Jun 29 02:24:03 2025

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 89bcad6c215..b64dbd127a1 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20250628
+20250629

commit 4d4a14b50f3cf0c172351d328402a46827876a32
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Mon Jun 30 02:24:22 2025

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index b64dbd127a1..258e00165ab 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20250629
+20250630

commit b30bba9852cd9f3cec1a0ab6dd521c4acf9283c1
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Tue Jul 1 02:23:45 2025

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 258e00165ab..ac92899c888 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20250630
+20250701

commit 01e2490ab404ea1ee4e2299528e7b90152146f1e
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Wed Jul 2 02:23:11 2025

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index ac92899c888..46e9463b427 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20250701
+20250702

commit d054cef9c3fc7f4b6f3e4c86e547d2aab5652a1b
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Thu Jul 3 02:22:11 2025

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 46e9463b427..695297928f6 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20250702
+20250703

commit 72b828227f8faf8f0a85735a5c27545378cf20c5
Author: Richard Sandiford <richard.sandiford@arm.com>
Date:   Thu Jul 3 09:12:42 2025

    aarch64: Incorrect removal of ZA restore [PR120624]
    
    The PCS defines a lazy save scheme for managing ZA across normal
    "private-ZA" functions.  GCC currently uses this scheme for calls
    to all private-ZA functions (rather than using caller-save).
    
    Therefore, before a sequence of calls to private-ZA functions, GCC emits
    code to set up a lazy save.  After the sequence of calls, GCC emits code
    to check whether lazy save was committed and restore the ZA contents
    if so.
    
    These sequences are emitted by the mode-switching pass, in an attempt
    to reduce the number of redundant saves and restores.
    
    The lazy save scheme also means that, before a function can use ZA,
    it must first conditionally store the old contents of ZA to the caller's
    lazy save buffer, if any.
    
    This all creates some relatively complex dependencies between
    setup code, save/restore code, and normal reads from and writes to ZA.
    These dependencies are modelled using special fake hard registers:
    
        ;; Sometimes we use placeholder instructions to mark where later
        ;; ABI-related lowering is needed.  These placeholders read and
        ;; write this register.  Instructions that depend on the lowering
        ;; read the register.
        (LOWERING_REGNUM 87)
    
        ;; Represents the contents of the current function's TPIDR2 block,
        ;; in abstract form.
        (TPIDR2_BLOCK_REGNUM 88)
    
        ;; Holds the value that the current function wants PSTATE.ZA to be.
        ;; The actual value can sometimes vary, because it does not track
        ;; changes to PSTATE.ZA that happen during a lazy save and restore.
        ;; Those effects are instead tracked by ZA_SAVED_REGNUM.
        (SME_STATE_REGNUM 89)
    
        ;; Instructions write to this register if they set TPIDR2_EL0 to a
        ;; well-defined value.  Instructions read from the register if they
        ;; depend on the result of such writes.
        ;;
        ;; The register does not model the architected TPIDR2_ELO, just the
        ;; current function's management of it.
        (TPIDR2_SETUP_REGNUM 90)
    
        ;; Represents the property "has an incoming lazy save been committed?".
        (ZA_FREE_REGNUM 91)
    
        ;; Represents the property "are the current function's ZA contents
        ;; stored in the lazy save buffer, rather than in ZA itself?".
        (ZA_SAVED_REGNUM 92)
    
        ;; Represents the contents of the current function's ZA state in
        ;; abstract form.  At various times in the function, these contents
        ;; might be stored in ZA itself, or in the function's lazy save buffer.
        ;;
        ;; The contents persist even when the architected ZA is off.  Private-ZA
        ;; functions have no effect on its contents.
        (ZA_REGNUM 93)
    
    Every normal read from ZA and write to ZA depends on SME_STATE_REGNUM,
    in order to sequence the code with the initial setup of ZA and
    with the lazy save scheme.
    
    The code to restore ZA after a call involves several instructions,
    including conditional control flow.  It is initially represented as
    a single define_insn and is split late, after shrink-wrapping and
    prologue/epilogue insertion.
    
    The split form of the restore instruction includes a conditional call
    to __arm_tpidr2_restore:
    
    (define_insn "aarch64_tpidr2_restore"
      [(set (reg:DI ZA_SAVED_REGNUM)
            (unspec:DI [(reg:DI R0_REGNUM)] UNSPEC_TPIDR2_RESTORE))
       (set (reg:DI SME_STATE_REGNUM)
            (unspec:DI [(reg:DI SME_STATE_REGNUM)] UNSPEC_TPIDR2_RESTORE))
      ...
    )
    
    The write to SME_STATE_REGNUM indicates the end of the region where
    ZA_REGNUM might differ from the real contents of ZA.  In other words,
    it is the point at which normal reads from ZA and writes to ZA
    can safely take place.
    
    To finally get to the point, the problem in this PR was that the
    unsplit aarch64_restore_za pattern was missing this change to
    SME_STATE_REGNUM.  It could therefore be deleted as dead before
    it had chance to be split.  The split form had the correct dataflow,
    but the unsplit form didn't.
    
    Unfortunately, the tests for this code tended to use calls and asms
    to model regions of ZA usage, and those don't seem to be affected
    in the same way.
    
    gcc/
            PR target/120624
            * config/aarch64/aarch64.md (SME_STATE_REGNUM): Expand on comments.
            * config/aarch64/aarch64-sme.md (aarch64_restore_za): Also set
            SME_STATE_REGNUM
    
    gcc/testsuite/
            PR target/120624
            * gcc.target/aarch64/sme/za_state_7.c: New test.
    
    (cherry picked from commit 8546265e2ee386ea8a4b2f9150ddfed32c9d15ea)

diff --git a/gcc/config/aarch64/aarch64-sme.md b/gcc/config/aarch64/aarch64-sme.md
index 78ad2fc699f..aa824cfe0dd 100644
--- a/gcc/config/aarch64/aarch64-sme.md
+++ b/gcc/config/aarch64/aarch64-sme.md
@@ -373,6 +373,8 @@
 		    (reg:DI SME_STATE_REGNUM)
 		    (reg:DI TPIDR2_SETUP_REGNUM)
 		    (reg:DI ZA_SAVED_REGNUM)] UNSPEC_RESTORE_ZA))
+   (set (reg:DI SME_STATE_REGNUM)
+	(unspec:DI [(reg:DI SME_STATE_REGNUM)] UNSPEC_TPIDR2_RESTORE))
    (clobber (reg:DI R0_REGNUM))
    (clobber (reg:DI R14_REGNUM))
    (clobber (reg:DI R15_REGNUM))
diff --git a/gcc/config/aarch64/aarch64.md b/gcc/config/aarch64/aarch64.md
index 6a481059bf0..72b7cfdec7c 100644
--- a/gcc/config/aarch64/aarch64.md
+++ b/gcc/config/aarch64/aarch64.md
@@ -132,6 +132,14 @@
     ;; The actual value can sometimes vary, because it does not track
     ;; changes to PSTATE.ZA that happen during a lazy save and restore.
     ;; Those effects are instead tracked by ZA_SAVED_REGNUM.
+    ;;
+    ;; Sequences also write to this register if they synchronize the
+    ;; actual contents of ZA and PSTATE.ZA with the current function's
+    ;; ZA_REGNUM and SME_STATE_REGNUM.  Conceptually, these extra writes
+    ;; do not change the value of SME_STATE_REGNUM.  They simply act as
+    ;; sequencing points.  They means that all direct accesses to ZA can
+    ;; depend only on ZA_REGNUM and SME_STATE_REGNUM, rather than also
+    ;; depending on ZA_SAVED_REGNUM etc.
     (SME_STATE_REGNUM 88)
 
     ;; Instructions write to this register if they set TPIDR2_EL0 to a
diff --git a/gcc/testsuite/gcc.target/aarch64/sme/za_state_7.c b/gcc/testsuite/gcc.target/aarch64/sme/za_state_7.c
new file mode 100644
index 00000000000..38bc1347159
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/sme/za_state_7.c
@@ -0,0 +1,21 @@
+// { dg-options "-O -fno-optimize-sibling-calls -fomit-frame-pointer" }
+
+#include <arm_sme.h>
+
+void callee();
+
+__arm_new("za") __arm_locally_streaming int test()
+{
+  svbool_t all = svptrue_b8();
+  svint8_t expected = svindex_s8(1, 1);
+  svwrite_hor_za8_m(0, 0, all, expected);
+
+  callee();
+
+  svint8_t actual = svread_hor_za8_m(svdup_s8(0), all, 0, 0);
+  return svptest_any(all, svcmpne(all, expected, actual));
+}
+
+// { dg-final { scan-assembler {\tbl\t__arm_tpidr2_save\n} } }
+// { dg-final { scan-assembler {\tbl\t__arm_tpidr2_restore\n} } }
+// { dg-final { scan-assembler-times {\tsmstart\tza\n} 2 } }

commit d21bfd170f939625abee3e230a6d41d7e1529ed3
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Tue Jul 1 15:28:10 2025

    c++: Fix up cp_build_array_ref COND_EXPR handling [PR120471]
    
    The following testcase is miscompiled since the introduction of UBSan,
    cp_build_array_ref COND_EXPR handling replaces
    (cond ? a : b)[idx] with cond ? a[idx] : b[idx], but if there are
    SAVE_EXPRs inside of idx, they will be evaluated just in one of the
    branches and the other uses uninitialized temporaries.
    
    Fixed by keeping doing what it did if idx doesn't have side effects
    and is invariant.  Otherwise if op1/op2 are ARRAY_TYPE arrays with
    invariant addresses or pointers with invariant values, use
    SAVE_EXPR <op0>, SAVE_EXPR <idx>, SAVE_EXPR <op0> as a new condition
    and SAVE_EXPR <idx> instead of idx for the recursive calls.
    Otherwise punt, but if op1/op2 are ARRAY_TYPE, furthermore call
    cp_default_conversion on array, so that COND_EXPR with ARRAY_TYPE doesn't
    survive in the IL until expansion.
    
    2025-07-01  Jakub Jelinek  <jakub@redhat.com>
    
            PR c++/120471
    gcc/cp/
            * typeck.cc (cp_build_array_ref) <case COND_EXPR>: If idx is not
            INTEGER_CST, don't optimize the case (but cp_default_conversion on
            array early if it has ARRAY_TYPE) or use
            SAVE_EXPR <op0>, SAVE_EXPR <idx>, SAVE_EXPR <op0> as new op0 depending
            on flag_strong_eval_order and whether op1 and op2 are arrays with
            invariant address or tree invariant pointers.  Formatting fixes.
    gcc/testsuite/
            * g++.dg/ubsan/pr120471.C: New test.
            * g++.dg/parse/pr120471.C: New test.
    
    (cherry picked from commit 988e87b66882875b14a6cab11c17516863c74a63)

diff --git a/gcc/cp/typeck.cc b/gcc/cp/typeck.cc
index 0db294a552e..93c69c5ebad 100644
--- a/gcc/cp/typeck.cc
+++ b/gcc/cp/typeck.cc
@@ -3967,13 +3967,129 @@ cp_build_array_ref (location_t loc, tree array, tree idx,
       }
 
     case COND_EXPR:
-      ret = build_conditional_expr
-	       (loc, TREE_OPERAND (array, 0),
-	       cp_build_array_ref (loc, TREE_OPERAND (array, 1), idx,
-				   complain),
-	       cp_build_array_ref (loc, TREE_OPERAND (array, 2), idx,
-				   complain),
-	       complain);
+      tree op0, op1, op2;
+      op0 = TREE_OPERAND (array, 0);
+      op1 = TREE_OPERAND (array, 1);
+      op2 = TREE_OPERAND (array, 1);
+      if (TREE_SIDE_EFFECTS (idx) || !tree_invariant_p (idx))
+	{
+	  /* If idx could possibly have some SAVE_EXPRs, turning
+	     (op0 ? op1 : op2)[idx] into
+	     op0 ? op1[idx] : op2[idx] can lead into temporaries
+	     initialized in one conditional path and uninitialized
+	     uses of them in the other path.
+	     And if idx is a really large expression, evaluating it
+	     twice is also not optimal.
+	     On the other side, op0 must be sequenced before evaluation
+	     of op1 and op2 and for C++17 op0, op1 and op2 must be
+	     sequenced before idx.
+	     If idx is INTEGER_CST, we can just do the optimization
+	     without any SAVE_EXPRs, if op1 and op2 are both ARRAY_TYPE
+	     VAR_DECLs or COMPONENT_REFs thereof (so their address
+	     is constant or relative to frame), optimize into
+	     (SAVE_EXPR <op0>, SAVE_EXPR <idx>, SAVE_EXPR <op0>)
+	     ? op1[SAVE_EXPR <idx>] : op2[SAVE_EXPR <idx>]
+	     Otherwise avoid this optimization.  */
+	  if (flag_strong_eval_order == 2)
+	    {
+	      if (TREE_CODE (TREE_TYPE (array)) == ARRAY_TYPE)
+		{
+		  tree xop1 = op1;
+		  tree xop2 = op2;
+		  while (xop1 && handled_component_p (xop1))
+		    {
+		      switch (TREE_CODE (xop1))
+			{
+			case ARRAY_REF:
+			case ARRAY_RANGE_REF:
+			  if (!tree_invariant_p (TREE_OPERAND (xop1, 1))
+			      || TREE_OPERAND (xop1, 2) != NULL_TREE
+			      || TREE_OPERAND (xop1, 3) != NULL_TREE)
+			    {
+			      xop1 = NULL_TREE;
+			      continue;
+			    }
+			  break;
+
+			case COMPONENT_REF:
+			  if (TREE_OPERAND (xop1, 2) != NULL_TREE)
+			    {
+			      xop1 = NULL_TREE;
+			      continue;
+			    }
+			  break;
+
+			default:
+			  break;
+			}
+		      xop1 = TREE_OPERAND (xop1, 0);
+		    }
+		  if (xop1)
+		    STRIP_ANY_LOCATION_WRAPPER (xop1);
+		  while (xop2 && handled_component_p (xop2))
+		    {
+		      switch (TREE_CODE (xop2))
+			{
+			case ARRAY_REF:
+			case ARRAY_RANGE_REF:
+			  if (!tree_invariant_p (TREE_OPERAND (xop2, 1))
+			      || TREE_OPERAND (xop2, 2) != NULL_TREE
+			      || TREE_OPERAND (xop2, 3) != NULL_TREE)
+			    {
+			      xop2 = NULL_TREE;
+			      continue;
+			    }
+			  break;
+
+			case COMPONENT_REF:
+			  if (TREE_OPERAND (xop2, 2) != NULL_TREE)
+			    {
+			      xop2 = NULL_TREE;
+			      continue;
+			    }
+			  break;
+
+			default:
+			  break;
+			}
+		      xop2 = TREE_OPERAND (xop2, 0);
+		    }
+		  if (xop2)
+		    STRIP_ANY_LOCATION_WRAPPER (xop2);
+
+		  if (!xop1
+		      || !xop2
+		      || !(CONSTANT_CLASS_P (xop1)
+			   || decl_address_invariant_p (xop1))
+		      || !(CONSTANT_CLASS_P (xop2)
+			   || decl_address_invariant_p (xop2)))
+		    {
+		      /* Force default conversion on array if
+			 we can't optimize this and array is ARRAY_TYPE
+			 COND_EXPR, we can't leave COND_EXPRs with
+			 ARRAY_TYPE in the IL.  */
+		      array = cp_default_conversion (array, complain);
+		      if (error_operand_p (array))
+			return error_mark_node;
+		      break;
+		    }
+		}
+	      else if (!POINTER_TYPE_P (TREE_TYPE (array))
+		       || !tree_invariant_p (op1)
+		       || !tree_invariant_p (op2))
+		break;
+	    }
+	  if (TREE_SIDE_EFFECTS (idx))
+	    {
+	      idx = save_expr (idx);
+	      op0 = save_expr (op0);
+	      tree tem = build_compound_expr (loc, op0, idx);
+	      op0 = build_compound_expr (loc, tem, op0);
+	    }
+	}
+      op1 = cp_build_array_ref (loc, op1, idx, complain);
+      op2 = cp_build_array_ref (loc, op2, idx, complain);
+      ret = build_conditional_expr (loc, op0, op1, op2, complain);
       protected_set_expr_location (ret, loc);
       return ret;
 
diff --git a/gcc/testsuite/g++.dg/parse/pr120471.C b/gcc/testsuite/g++.dg/parse/pr120471.C
new file mode 100644
index 00000000000..ad47e380404
--- /dev/null
+++ b/gcc/testsuite/g++.dg/parse/pr120471.C
@@ -0,0 +1,42 @@
+// PR c++/120471
+// { dg-do compile }
+
+extern int a1[], a2[], a3[], a4[];
+
+int corge (int);
+
+int
+foo (int p)
+{
+  return (p ? a1 : a2)[1];
+}
+
+int
+bar (int p, int q)
+{
+  return (p ? a1 : a2)[q];
+}
+
+int
+garply (int p, int q)
+{
+  return (p ? a1 : a2)[corge (q)];
+}
+
+int
+baz (int p, int q)
+{
+  return (p ? q ? a1 : a2 : q ? a3 : a4)[1];
+}
+
+int
+qux (int p, int q, int r)
+{
+  return (p ? q ? a1 : a2 : q ? a3 : a4)[r];
+}
+
+int
+fred (int p, int q, int r)
+{
+  return (p ? q ? a1 : a2 : q ? a3 : a4)[corge (r)];
+}
diff --git a/gcc/testsuite/g++.dg/ubsan/pr120471.C b/gcc/testsuite/g++.dg/ubsan/pr120471.C
new file mode 100644
index 00000000000..31b781f9aa7
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ubsan/pr120471.C
@@ -0,0 +1,21 @@
+// PR c++/120471
+// { dg-do run }
+// { dg-options "-fsanitize=undefined" }
+
+volatile int b[1], a[1];
+
+void
+foo (int x)
+{
+  volatile int c = 21;
+  volatile int v = (x % 2 ? b : a)[c % 3];
+  if (v != 0)
+    __builtin_abort ();
+}
+
+int
+main ()
+{
+  foo (1);
+  foo (2);
+}

commit a58d7df7cf96d0eda885e6dc245c9053330198b4
Author: Eric Botcazou <ebotcazou@adacore.com>
Date:   Tue May 27 13:32:18 2025

    ada: Fix wrong conversion of controlled array with representation change
    
    The problem is that a temporary is created for the conversion because of the
    representation change, and it is finalized without having been initialized.
    
    gcc/ada/ChangeLog:
    
            * exp_ch4.adb (Handle_Changed_Representation): Alphabetize local
            variables.  Set the No_Finalize_Actions flag on the assignment.

diff --git a/gcc/ada/exp_ch4.adb b/gcc/ada/exp_ch4.adb
index e4a40414872..c2a8bb61f3d 100644
--- a/gcc/ada/exp_ch4.adb
+++ b/gcc/ada/exp_ch4.adb
@@ -11438,11 +11438,12 @@ package body Exp_Ch4 is
       -----------------------------------
 
       procedure Handle_Changed_Representation is
-         Temp : Entity_Id;
-         Decl : Node_Id;
-         Odef : Node_Id;
-         N_Ix : Node_Id;
          Cons : List_Id;
+         Decl : Node_Id;
+         N_Ix : Node_Id;
+         Odef : Node_Id;
+         Stmt : Node_Id;
+         Temp : Entity_Id;
 
       begin
          --  Nothing else to do if no change of representation
@@ -11585,19 +11586,24 @@ package body Exp_Ch4 is
                 Defining_Identifier => Temp,
                 Object_Definition   => Odef);
 
-            Set_No_Initialization (Decl, True);
+            --  The temporary need not be initialized
+
+            Set_No_Initialization (Decl);
+
+            Stmt :=
+              Make_Assignment_Statement (Loc,
+                Name       => New_Occurrence_Of (Temp, Loc),
+                Expression => Relocate_Node (N));
+
+            --  And, therefore, cannot be finalized
+
+            Set_No_Finalize_Actions (Stmt);
 
             --  Insert required actions. It is essential to suppress checks
             --  since we have suppressed default initialization, which means
             --  that the variable we create may have no discriminants.
 
-            Insert_Actions (N,
-              New_List (
-                Decl,
-                Make_Assignment_Statement (Loc,
-                  Name       => New_Occurrence_Of (Temp, Loc),
-                  Expression => Relocate_Node (N))),
-                Suppress => All_Checks);
+            Insert_Actions (N, New_List (Decl, Stmt), Suppress => All_Checks);
 
             Rewrite (N, New_Occurrence_Of (Temp, Loc));
             return;

commit 4f2863c82b203a0791307b1c7eabc4b32d054070
Author: Eric Botcazou <ebotcazou@adacore.com>
Date:   Fri May 2 01:30:56 2025

    ada: Fix missing error on too large Component_Size not multiple of storage unit
    
    This is a small regression introduced a few years ago.
    
    gcc/ada/ChangeLog:
    
            * gcc-interface/decl.cc (gnat_to_gnu_component_type): Validate the
            Component_Size like the size of a type only if the component type
            is actually packed.

diff --git a/gcc/ada/gcc-interface/decl.cc b/gcc/ada/gcc-interface/decl.cc
index 53b5e596218..f5e24fb832e 100644
--- a/gcc/ada/gcc-interface/decl.cc
+++ b/gcc/ada/gcc-interface/decl.cc
@@ -5328,7 +5328,7 @@ gnat_to_gnu_component_type (Entity_Id gnat_array, bool definition,
   const bool is_bit_packed = Is_Bit_Packed_Array (gnat_array);
   tree gnu_type = gnat_to_gnu_type (gnat_type);
   tree gnu_comp_size;
-  bool has_packed_components;
+  bool has_packed_component;
   unsigned int max_align;
 
   /* If an alignment is specified, use it as a cap on the component type
@@ -5349,16 +5349,22 @@ gnat_to_gnu_component_type (Entity_Id gnat_array, bool definition,
       && !TYPE_FAT_POINTER_P (gnu_type)
       && tree_fits_uhwi_p (TYPE_SIZE (gnu_type)))
     {
-      gnu_type = make_packable_type (gnu_type, false, max_align);
-      has_packed_components = true;
+      tree gnu_packable_type = make_packable_type (gnu_type, false, max_align);
+      if (gnu_packable_type != gnu_type)
+	{
+	  gnu_type = gnu_packable_type;
+	  has_packed_component = true;
+	}
+      else
+	has_packed_component = false;
     }
   else
-    has_packed_components = is_bit_packed;
+    has_packed_component = is_bit_packed;
 
   /* Get and validate any specified Component_Size.  */
   gnu_comp_size
     = validate_size (Component_Size (gnat_array), gnu_type, gnat_array,
-		     has_packed_components ? TYPE_DECL : VAR_DECL, true,
+		     has_packed_component ? TYPE_DECL : VAR_DECL, true,
 		     Has_Component_Size_Clause (gnat_array), NULL, NULL);
 
   /* If the component type is a RECORD_TYPE that has a self-referential size,

commit a9b70e4c95c8881520b789c76169e5f8a7f385cc
Author: Eric Botcazou <ebotcazou@adacore.com>
Date:   Thu Jul 3 20:02:43 2025

    Ada: Remove left-overs of front-end exception mechanism
    
    It was removed from the compiler a few releases ago.
    
    gcc/ada/
            * gcc-interface/Makefile.in (gnatlib-sjlj): Delete.
            (gnatlib-zcx): Do not modify Frontend_Exceptions constant.
            * libgnat/system-linux-loongarch.ads (Frontend_Exceptions): Delete.

diff --git a/gcc/ada/gcc-interface/Makefile.in b/gcc/ada/gcc-interface/Makefile.in
index 0666fc00bb8..c1a6bbbf5b5 100644
--- a/gcc/ada/gcc-interface/Makefile.in
+++ b/gcc/ada/gcc-interface/Makefile.in
@@ -822,35 +822,6 @@ gnatlib-shared:
 	     PICFLAG_FOR_TARGET="$(PICFLAG_FOR_TARGET)" \
 	     $(GNATLIB_SHARED)
 
-# When building a SJLJ runtime for VxWorks, we need to ensure that the extra
-# linker options needed for ZCX are not passed to prevent the inclusion of
-# useless objects and potential troubles from the presence of extra symbols
-# and references in some configurations.  The inhibition is performed by
-# commenting the pragma instead of deleting the line, as the latter might
-# result in getting multiple blank lines, hence possible style check errors.
-gnatlib-sjlj:
-	$(MAKE) $(FLAGS_TO_PASS) \
-	     EH_MECHANISM="" \
-	     MULTISUBDIR="$(MULTISUBDIR)" \
-	     THREAD_KIND="$(THREAD_KIND)" \
-	     LN_S="$(LN_S)" \
-	     ../stamp-gnatlib1-$(RTSDIR)
-	sed \
-	  -e 's/Frontend_Exceptions.*/Frontend_Exceptions       : constant Boolean := True;/' \
-	  -e 's/ZCX_By_Default.*/ZCX_By_Default            : constant Boolean := False;/' \
-	  $(RTSDIR)/system.ads > $(RTSDIR)/s.ads
-	$(MV) $(RTSDIR)/s.ads $(RTSDIR)/system.ads
-	$(MAKE) $(FLAGS_TO_PASS) \
-	     EH_MECHANISM="" \
-	     GNATLIBFLAGS="$(GNATLIBFLAGS)" \
-	     GNATLIBCFLAGS="$(GNATLIBCFLAGS)" \
-	     GNATLIBCFLAGS_FOR_C="$(GNATLIBCFLAGS_FOR_C)" \
-	     FORCE_DEBUG_ADAFLAGS="$(FORCE_DEBUG_ADAFLAGS)" \
-	     MULTISUBDIR="$(MULTISUBDIR)" \
-	     THREAD_KIND="$(THREAD_KIND)" \
-	     LN_S="$(LN_S)" \
-	     gnatlib
-
 gnatlib-zcx:
 	$(MAKE) $(FLAGS_TO_PASS) \
 	     EH_MECHANISM="-gcc" \
@@ -859,7 +830,6 @@ gnatlib-zcx:
 	     LN_S="$(LN_S)" \
 	     ../stamp-gnatlib1-$(RTSDIR)
 	sed \
-	  -e 's/Frontend_Exceptions.*/Frontend_Exceptions       : constant Boolean := False;/' \
 	  -e 's/ZCX_By_Default.*/ZCX_By_Default            : constant Boolean := True;/' \
 	  $(RTSDIR)/system.ads > $(RTSDIR)/s.ads
 	$(MV) $(RTSDIR)/s.ads $(RTSDIR)/system.ads
diff --git a/gcc/ada/libgnat/system-linux-loongarch.ads b/gcc/ada/libgnat/system-linux-loongarch.ads
index d44724df305..79269d20839 100644
--- a/gcc/ada/libgnat/system-linux-loongarch.ads
+++ b/gcc/ada/libgnat/system-linux-loongarch.ads
@@ -139,7 +139,6 @@ private
    Always_Compatible_Rep     : constant Boolean := False;
    Suppress_Standard_Library : constant Boolean := False;
    Use_Ada_Main_Program_Name : constant Boolean := False;
-   Frontend_Exceptions       : constant Boolean := False;
    ZCX_By_Default            : constant Boolean := True;
 
 end System;

commit f88883db50e3a41af53f87e94cd31e86f63126b8
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Thu Jul 3 22:39:39 2025

    c++: Fix a pasto in the PR120471 fix [PR120940]
    
    No idea how this slipped in, I'm terribly sorry.
    Strangely nothing in the testsuite has caught this, so I've added
    a new test for that.
    
    2025-07-03  Jakub Jelinek  <jakub@redhat.com>
    
            PR c++/120940
            * typeck.cc (cp_build_array_ref): Fix a pasto.
    
            * g++.dg/parse/pr120940.C: New test.
            * g++.dg/warn/Wduplicated-branches9.C: New test.
    
    (cherry picked from commit dc90649466a54ab61926d88500a05f59a55cb055)

diff --git a/gcc/cp/typeck.cc b/gcc/cp/typeck.cc
index 93c69c5ebad..b97caeea643 100644
--- a/gcc/cp/typeck.cc
+++ b/gcc/cp/typeck.cc
@@ -3970,7 +3970,7 @@ cp_build_array_ref (location_t loc, tree array, tree idx,
       tree op0, op1, op2;
       op0 = TREE_OPERAND (array, 0);
       op1 = TREE_OPERAND (array, 1);
-      op2 = TREE_OPERAND (array, 1);
+      op2 = TREE_OPERAND (array, 2);
       if (TREE_SIDE_EFFECTS (idx) || !tree_invariant_p (idx))
 	{
 	  /* If idx could possibly have some SAVE_EXPRs, turning
diff --git a/gcc/testsuite/g++.dg/parse/pr120940.C b/gcc/testsuite/g++.dg/parse/pr120940.C
new file mode 100644
index 00000000000..5da36b2f88a
--- /dev/null
+++ b/gcc/testsuite/g++.dg/parse/pr120940.C
@@ -0,0 +1,18 @@
+// PR c++/120940
+// { dg-do run }
+
+int a[8] = { 1, 2, 3, 4, 5, 6, 7, 8 };
+int b[8] = { 9, 10, 11, 12, 13, 14, 15, 16 };
+
+__attribute__((noipa)) int
+foo (int x, int y)
+{
+  return (x ? a : b)[y];
+}
+
+int
+main ()
+{
+  if (foo (1, 4) != 5 || foo (0, 6) != 15)
+    __builtin_abort ();
+}
diff --git a/gcc/testsuite/g++.dg/warn/Wduplicated-branches9.C b/gcc/testsuite/g++.dg/warn/Wduplicated-branches9.C
new file mode 100644
index 00000000000..f9fafcd467b
--- /dev/null
+++ b/gcc/testsuite/g++.dg/warn/Wduplicated-branches9.C
@@ -0,0 +1,11 @@
+// PR c++/120940
+// { dg-do compile }
+// { dg-options "-Wduplicated-branches" }
+
+static char a[16][8], b[16][8];
+
+char *
+foo (int x, int y)
+{
+  return (x ? a : b)[y];
+}

commit e086e745a245e482d3c330c9b1d4ca929e01a220
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Fri Jul 4 02:24:18 2025

    Daily bump.

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index f891157a62b..b88368450c0 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,13 @@
+2025-07-03  Richard Sandiford  <richard.sandiford@arm.com>
+
+	Backported from master:
+	2025-06-12  Richard Sandiford  <richard.sandiford@arm.com>
+
+	PR target/120624
+	* config/aarch64/aarch64.md (SME_STATE_REGNUM): Expand on comments.
+	* config/aarch64/aarch64-sme.md (aarch64_restore_za): Also set
+	SME_STATE_REGNUM
+
 2025-06-27  Eric Botcazou  <ebotcazou@adacore.com>
 
 	* gimple-fold.cc (fold_const_aggregate_ref_1) <COMPONENT_REF>:
diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 695297928f6..f38cdfd1ac9 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20250703
+20250704
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index f8213df6324..c6a62849029 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,3 +1,20 @@
+2025-07-03  Eric Botcazou  <ebotcazou@adacore.com>
+
+	* gcc-interface/Makefile.in (gnatlib-sjlj): Delete.
+	(gnatlib-zcx): Do not modify Frontend_Exceptions constant.
+	* libgnat/system-linux-loongarch.ads (Frontend_Exceptions): Delete.
+
+2025-07-03  Eric Botcazou  <ebotcazou@adacore.com>
+
+	* gcc-interface/decl.cc (gnat_to_gnu_component_type): Validate the
+	Component_Size like the size of a type only if the component type
+	is actually packed.
+
+2025-07-03  Eric Botcazou  <ebotcazou@adacore.com>
+
+	* exp_ch4.adb (Handle_Changed_Representation): Alphabetize local
+	variables.  Set the No_Finalize_Actions flag on the assignment.
+
 2025-05-23  Release Manager
 
 	* GCC 14.3.0 released.
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 233f9ed881a..b94a14c582b 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,24 @@
+2025-07-03  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2025-07-03  Jakub Jelinek  <jakub@redhat.com>
+
+	PR c++/120940
+	* typeck.cc (cp_build_array_ref): Fix a pasto.
+
+2025-07-03  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2025-07-01  Jakub Jelinek  <jakub@redhat.com>
+
+	PR c++/120471
+	* typeck.cc (cp_build_array_ref) <case COND_EXPR>: If idx is not
+	INTEGER_CST, don't optimize the case (but cp_default_conversion on
+	array early if it has ARRAY_TYPE) or use
+	SAVE_EXPR <op0>, SAVE_EXPR <idx>, SAVE_EXPR <op0> as new op0 depending
+	on flag_strong_eval_order and whether op1 and op2 are arrays with
+	invariant address or tree invariant pointers.  Formatting fixes.
+
 2025-06-02  Jason Merrill  <jason@redhat.com>
 
 	PR c++/120123
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 6cbaf041da5..217018de03e 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,29 @@
+2025-07-03  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2025-07-03  Jakub Jelinek  <jakub@redhat.com>
+
+	PR c++/120940
+	* g++.dg/parse/pr120940.C: New test.
+	* g++.dg/warn/Wduplicated-branches9.C: New test.
+
+2025-07-03  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2025-07-01  Jakub Jelinek  <jakub@redhat.com>
+
+	PR c++/120471
+	* g++.dg/ubsan/pr120471.C: New test.
+	* g++.dg/parse/pr120471.C: New test.
+
+2025-07-03  Richard Sandiford  <richard.sandiford@arm.com>
+
+	Backported from master:
+	2025-06-12  Richard Sandiford  <richard.sandiford@arm.com>
+
+	PR target/120624
+	* gcc.target/aarch64/sme/za_state_7.c: New test.
+
 2025-06-27  Eric Botcazou  <ebotcazou@adacore.com>
 
 	* gnat.dg/sso20.adb: New test.

commit cee3aa8335bfed433c50a2837b07662fa8296c2b
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sat Jul 5 02:24:28 2025

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index f38cdfd1ac9..93909f8b31a 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20250704
+20250705

commit d640bd8728064a1a0d4de61a95ea95bbd0494821
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sun Jul 6 02:24:59 2025

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 93909f8b31a..0f0154fadad 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20250705
+20250706

commit 75e6bf06e9d65e0f35c723c4f660426739121b2e
Author: Georg-Johann Lay <avr@gjlay.de>
Date:   Sun Jul 6 19:52:32 2025

    AVR: Add support for AVR32DAxxS, AVR64DAxxS, AVR128DAxxS devices.
    
    gcc/
            * config/avr/avr-mcus.def (avr32da28s, avr32da32s, avr32da48s)
            (avr64da28s, avr64da32s, avr64da48s avr64da64s)
            (avr128da28s, avr128da32s, avr128da48s, avr128da64s): Add devices.
            * doc/avr-mmcu.texi: Rebuild.

diff --git a/gcc/config/avr/avr-mcus.def b/gcc/config/avr/avr-mcus.def
index d8512ab3a67..9d90cfa8d32 100644
--- a/gcc/config/avr/avr-mcus.def
+++ b/gcc/config/avr/avr-mcus.def
@@ -313,6 +313,10 @@ AVR_MCU ("avr64da28",        ARCH_AVRXMEGA2, AVR_ISA_FLMAP, "__AVR_AVR64DA28__",
 AVR_MCU ("avr64da32",        ARCH_AVRXMEGA2, AVR_ISA_FLMAP, "__AVR_AVR64DA32__",   0x6000, 0x0, 0x10000, 0)
 AVR_MCU ("avr64da48",        ARCH_AVRXMEGA2, AVR_ISA_FLMAP, "__AVR_AVR64DA48__",   0x6000, 0x0, 0x10000, 0)
 AVR_MCU ("avr64da64",        ARCH_AVRXMEGA2, AVR_ISA_FLMAP, "__AVR_AVR64DA64__",   0x6000, 0x0, 0x10000, 0)
+AVR_MCU ("avr64da28s",       ARCH_AVRXMEGA2, AVR_ISA_FLMAP, "__AVR_AVR64DA28S__",  0x6000, 0x0, 0x10000, 0)
+AVR_MCU ("avr64da32s",       ARCH_AVRXMEGA2, AVR_ISA_FLMAP, "__AVR_AVR64DA32S__",  0x6000, 0x0, 0x10000, 0)
+AVR_MCU ("avr64da48s",       ARCH_AVRXMEGA2, AVR_ISA_FLMAP, "__AVR_AVR64DA48S__",  0x6000, 0x0, 0x10000, 0)
+AVR_MCU ("avr64da64s",       ARCH_AVRXMEGA2, AVR_ISA_FLMAP, "__AVR_AVR64DA64S__",  0x6000, 0x0, 0x10000, 0)
 AVR_MCU ("avr64db28",        ARCH_AVRXMEGA2, AVR_ISA_FLMAP, "__AVR_AVR64DB28__",   0x6000, 0x0, 0x10000, 0)
 AVR_MCU ("avr64db32",        ARCH_AVRXMEGA2, AVR_ISA_FLMAP, "__AVR_AVR64DB32__",   0x6000, 0x0, 0x10000, 0)
 AVR_MCU ("avr64db48",        ARCH_AVRXMEGA2, AVR_ISA_FLMAP, "__AVR_AVR64DB48__",   0x6000, 0x0, 0x10000, 0)
@@ -389,6 +393,9 @@ AVR_MCU ("avr16du32",        ARCH_AVRXMEGA3, AVR_ISA_NONE,  "__AVR_AVR16DU32__",
 AVR_MCU ("avr32da28",        ARCH_AVRXMEGA3, AVR_ISA_NONE,  "__AVR_AVR32DA28__",   0x7000, 0x0, 0x8000, 0x8000)
 AVR_MCU ("avr32da32",        ARCH_AVRXMEGA3, AVR_ISA_NONE,  "__AVR_AVR32DA32__",   0x7000, 0x0, 0x8000, 0x8000)
 AVR_MCU ("avr32da48",        ARCH_AVRXMEGA3, AVR_ISA_NONE,  "__AVR_AVR32DA48__",   0x7000, 0x0, 0x8000, 0x8000)
+AVR_MCU ("avr32da28s",       ARCH_AVRXMEGA3, AVR_ISA_NONE,  "__AVR_AVR32DA28S__",  0x7000, 0x0, 0x8000, 0x8000)
+AVR_MCU ("avr32da32s",       ARCH_AVRXMEGA3, AVR_ISA_NONE,  "__AVR_AVR32DA32S__",  0x7000, 0x0, 0x8000, 0x8000)
+AVR_MCU ("avr32da48s",       ARCH_AVRXMEGA3, AVR_ISA_NONE,  "__AVR_AVR32DA48S__",  0x7000, 0x0, 0x8000, 0x8000)
 AVR_MCU ("avr32db28",        ARCH_AVRXMEGA3, AVR_ISA_NONE,  "__AVR_AVR32DB28__",   0x7000, 0x0, 0x8000, 0x8000)
 AVR_MCU ("avr32db32",        ARCH_AVRXMEGA3, AVR_ISA_NONE,  "__AVR_AVR32DB32__",   0x7000, 0x0, 0x8000, 0x8000)
 AVR_MCU ("avr32db48",        ARCH_AVRXMEGA3, AVR_ISA_NONE,  "__AVR_AVR32DB48__",   0x7000, 0x0, 0x8000, 0x8000)
@@ -427,6 +434,10 @@ AVR_MCU ("avr128da28",       ARCH_AVRXMEGA4, AVR_ISA_FLMAP, "__AVR_AVR128DA28__"
 AVR_MCU ("avr128da32",       ARCH_AVRXMEGA4, AVR_ISA_FLMAP, "__AVR_AVR128DA32__",  0x4000, 0x0, 0x20000, 0)
 AVR_MCU ("avr128da48",       ARCH_AVRXMEGA4, AVR_ISA_FLMAP, "__AVR_AVR128DA48__",  0x4000, 0x0, 0x20000, 0)
 AVR_MCU ("avr128da64",       ARCH_AVRXMEGA4, AVR_ISA_FLMAP, "__AVR_AVR128DA64__",  0x4000, 0x0, 0x20000, 0)
+AVR_MCU ("avr128da28s",      ARCH_AVRXMEGA4, AVR_ISA_FLMAP, "__AVR_AVR128DA28S__", 0x4000, 0x0, 0x20000, 0)
+AVR_MCU ("avr128da32s",      ARCH_AVRXMEGA4, AVR_ISA_FLMAP, "__AVR_AVR128DA32S__", 0x4000, 0x0, 0x20000, 0)
+AVR_MCU ("avr128da48s",      ARCH_AVRXMEGA4, AVR_ISA_FLMAP, "__AVR_AVR128DA48S__", 0x4000, 0x0, 0x20000, 0)
+AVR_MCU ("avr128da64s",      ARCH_AVRXMEGA4, AVR_ISA_FLMAP, "__AVR_AVR128DA64S__", 0x4000, 0x0, 0x20000, 0)
 AVR_MCU ("avr128db28",       ARCH_AVRXMEGA4, AVR_ISA_FLMAP, "__AVR_AVR128DB28__",  0x4000, 0x0, 0x20000, 0)
 AVR_MCU ("avr128db32",       ARCH_AVRXMEGA4, AVR_ISA_FLMAP, "__AVR_AVR128DB32__",  0x4000, 0x0, 0x20000, 0)
 AVR_MCU ("avr128db48",       ARCH_AVRXMEGA4, AVR_ISA_FLMAP, "__AVR_AVR128DB48__",  0x4000, 0x0, 0x20000, 0)
diff --git a/gcc/doc/avr-mmcu.texi b/gcc/doc/avr-mmcu.texi
index b9013502d2f..28c1f9aad47 100644
--- a/gcc/doc/avr-mmcu.texi
+++ b/gcc/doc/avr-mmcu.texi
@@ -50,15 +50,15 @@
 
 @item @anchor{avrxmega2}avrxmega2
 ``XMEGA'' devices with more than 8@tie{}KiB and up to 64@tie{}KiB of program memory.
-@*@var{mcu}@tie{}= @code{atxmega8e5}, @code{atxmega16a4}, @code{atxmega16a4u}, @code{atxmega16c4}, @code{atxmega16d4}, @code{atxmega16e5}, @code{atxmega32a4}, @code{atxmega32a4u}, @code{atxmega32c3}, @code{atxmega32c4}, @code{atxmega32d3}, @code{atxmega32d4}, @code{atxmega32e5}, @code{avr64da28}, @code{avr64da32}, @code{avr64da48}, @code{avr64da64}, @code{avr64db28}, @code{avr64db32}, @code{avr64db48}, @code{avr64db64}, @code{avr64dd14}, @code{avr64dd20}, @code{avr64dd28}, @code{avr64dd32}, @code{avr64du28}, @code{avr64du32}, @code{avr64ea28}, @code{avr64ea32}, @code{avr64ea48}, @code{avr64sd28}, @code{avr64sd32}, @code{avr64sd48}.
+@*@var{mcu}@tie{}= @code{atxmega8e5}, @code{atxmega16a4}, @code{atxmega16a4u}, @code{atxmega16c4}, @code{atxmega16d4}, @code{atxmega16e5}, @code{atxmega32a4}, @code{atxmega32a4u}, @code{atxmega32c3}, @code{atxmega32c4}, @code{atxmega32d3}, @code{atxmega32d4}, @code{atxmega32e5}, @code{avr64da28}, @code{avr64da28s}, @code{avr64da32}, @code{avr64da32s}, @code{avr64da48}, @code{avr64da48s}, @code{avr64da64}, @code{avr64da64s}, @code{avr64db28}, @code{avr64db32}, @code{avr64db48}, @code{avr64db64}, @code{avr64dd14}, @code{avr64dd20}, @code{avr64dd28}, @code{avr64dd32}, @code{avr64du28}, @code{avr64du32}, @code{avr64ea28}, @code{avr64ea32}, @code{avr64ea48}, @code{avr64sd28}, @code{avr64sd32}, @code{avr64sd48}.
 
 @item @anchor{avrxmega3}avrxmega3
 ``XMEGA'' devices with up to 64@tie{}KiB of combined program memory and RAM, and with program memory visible in the RAM address space.
-@*@var{mcu}@tie{}= @code{attiny202}, @code{attiny204}, @code{attiny212}, @code{attiny214}, @code{attiny402}, @code{attiny404}, @code{attiny406}, @code{attiny412}, @code{attiny414}, @code{attiny416}, @code{attiny416auto}, @code{attiny417}, @code{attiny424}, @code{attiny426}, @code{attiny427}, @code{attiny804}, @code{attiny806}, @code{attiny807}, @code{attiny814}, @code{attiny816}, @code{attiny817}, @code{attiny824}, @code{attiny826}, @code{attiny827}, @code{attiny1604}, @code{attiny1606}, @code{attiny1607}, @code{attiny1614}, @code{attiny1616}, @code{attiny1617}, @code{attiny1624}, @code{attiny1626}, @code{attiny1627}, @code{attiny3214}, @code{attiny3216}, @code{attiny3217}, @code{attiny3224}, @code{attiny3226}, @code{attiny3227}, @code{atmega808}, @code{atmega809}, @code{atmega1608}, @code{atmega1609}, @code{atmega3208}, @code{atmega3209}, @code{atmega4808}, @code{atmega4809}, @code{avr16dd14}, @code{avr16dd20}, @code{avr16dd28}, @code{avr16dd32}, @code{avr16du14}, @code{avr16du20}, @code{avr16du28}, @code{avr16du32}, @code{avr16ea28}, @code{avr16ea32}, @code{avr16ea48}, @code{avr16eb14}, @code{avr16eb20}, @code{avr16eb28}, @code{avr16eb32}, @code{avr32da28}, @code{avr32da32}, @code{avr32da48}, @code{avr32db28}, @code{avr32db32}, @code{avr32db48}, @code{avr32dd14}, @code{avr32dd20}, @code{avr32dd28}, @code{avr32dd32}, @code{avr32du14}, @code{avr32du20}, @code{avr32du28}, @code{avr32du32}, @code{avr32ea28}, @code{avr32ea32}, @code{avr32ea48}, @code{avr32sd20}, @code{avr32sd28}, @code{avr32sd32}.
+@*@var{mcu}@tie{}= @code{attiny202}, @code{attiny204}, @code{attiny212}, @code{attiny214}, @code{attiny402}, @code{attiny404}, @code{attiny406}, @code{attiny412}, @code{attiny414}, @code{attiny416}, @code{attiny416auto}, @code{attiny417}, @code{attiny424}, @code{attiny426}, @code{attiny427}, @code{attiny804}, @code{attiny806}, @code{attiny807}, @code{attiny814}, @code{attiny816}, @code{attiny817}, @code{attiny824}, @code{attiny826}, @code{attiny827}, @code{attiny1604}, @code{attiny1606}, @code{attiny1607}, @code{attiny1614}, @code{attiny1616}, @code{attiny1617}, @code{attiny1624}, @code{attiny1626}, @code{attiny1627}, @code{attiny3214}, @code{attiny3216}, @code{attiny3217}, @code{attiny3224}, @code{attiny3226}, @code{attiny3227}, @code{atmega808}, @code{atmega809}, @code{atmega1608}, @code{atmega1609}, @code{atmega3208}, @code{atmega3209}, @code{atmega4808}, @code{atmega4809}, @code{avr16dd14}, @code{avr16dd20}, @code{avr16dd28}, @code{avr16dd32}, @code{avr16du14}, @code{avr16du20}, @code{avr16du28}, @code{avr16du32}, @code{avr16ea28}, @code{avr16ea32}, @code{avr16ea48}, @code{avr16eb14}, @code{avr16eb20}, @code{avr16eb28}, @code{avr16eb32}, @code{avr32da28}, @code{avr32da28s}, @code{avr32da32}, @code{avr32da32s}, @code{avr32da48}, @code{avr32da48s}, @code{avr32db28}, @code{avr32db32}, @code{avr32db48}, @code{avr32dd14}, @code{avr32dd20}, @code{avr32dd28}, @code{avr32dd32}, @code{avr32du14}, @code{avr32du20}, @code{avr32du28}, @code{avr32du32}, @code{avr32ea28}, @code{avr32ea32}, @code{avr32ea48}, @code{avr32sd20}, @code{avr32sd28}, @code{avr32sd32}.
 
 @item @anchor{avrxmega4}avrxmega4
 ``XMEGA'' devices with more than 64@tie{}KiB and up to 128@tie{}KiB of program memory.
-@*@var{mcu}@tie{}= @code{atxmega64a3}, @code{atxmega64a3u}, @code{atxmega64a4u}, @code{atxmega64b1}, @code{atxmega64b3}, @code{atxmega64c3}, @code{atxmega64d3}, @code{atxmega64d4}, @code{avr128da28}, @code{avr128da32}, @code{avr128da48}, @code{avr128da64}, @code{avr128db28}, @code{avr128db32}, @code{avr128db48}, @code{avr128db64}.
+@*@var{mcu}@tie{}= @code{atxmega64a3}, @code{atxmega64a3u}, @code{atxmega64a4u}, @code{atxmega64b1}, @code{atxmega64b3}, @code{atxmega64c3}, @code{atxmega64d3}, @code{atxmega64d4}, @code{avr128da28}, @code{avr128da28s}, @code{avr128da32}, @code{avr128da32s}, @code{avr128da48}, @code{avr128da48s}, @code{avr128da64}, @code{avr128da64s}, @code{avr128db28}, @code{avr128db32}, @code{avr128db48}, @code{avr128db64}.
 
 @item @anchor{avrxmega5}avrxmega5
 ``XMEGA'' devices with more than 64@tie{}KiB and up to 128@tie{}KiB of program memory and more than 64@tie{}KiB of RAM.

commit b5988eae0575211f1904b645daa7ac8fbae1968f
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Mon Jul 7 02:23:59 2025

    Daily bump.

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index b88368450c0..333137d97ae 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,10 @@
+2025-07-06  Georg-Johann Lay  <avr@gjlay.de>
+
+	* config/avr/avr-mcus.def (avr32da28s, avr32da32s, avr32da48s)
+	(avr64da28s, avr64da32s, avr64da48s avr64da64s)
+	(avr128da28s, avr128da32s, avr128da48s, avr128da64s): Add devices.
+	* doc/avr-mmcu.texi: Rebuild.
+
 2025-07-03  Richard Sandiford  <richard.sandiford@arm.com>
 
 	Backported from master:
diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 0f0154fadad..d4353d1e2c9 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20250706
+20250707

commit 7a136f96aed46139e3a3980ee5a32ea292bea67c
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Tue Jul 8 02:25:25 2025

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index d4353d1e2c9..7475f8cf1b4 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20250707
+20250708

commit df38d72f321807bf3b62eff3b4f14cded7796246
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Wed Jul 9 02:26:11 2025

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 7475f8cf1b4..fc3b54747ad 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20250708
+20250709

commit e96631f6c621c07581417a92e5460a085b62336b
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Thu Jul 10 02:26:29 2025

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index fc3b54747ad..12032cec602 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20250709
+20250710

commit 4058ce097eae89ee86a9fbe4debe2cec2882d904
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Fri Jul 11 02:24:09 2025

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 12032cec602..26b40b2ae3e 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20250710
+20250711

commit b0ac044caa97c0931ba7fa9b3c80a9b4e08401c9
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sat Jul 12 02:24:07 2025

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 26b40b2ae3e..e177aad4afb 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20250711
+20250712

commit 9d0e74f18d847d2964d0baf6d59a73f85a4e0f78
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sun Jul 13 02:29:29 2025

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index e177aad4afb..7bcb4c48a18 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20250712
+20250713

commit 0991c0daa9d47d4d1b81d00459ad6264734b441a
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Mon Jul 14 02:21:38 2025

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 7bcb4c48a18..eaad3526d83 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20250713
+20250714

commit 8ea12b87ec867ac07ffc0449a5cb5d8108a88527
Author: Haochen Jiang <haochen.jiang@intel.com>
Date:   Fri Jul 11 10:16:52 2025

    i386: Remove KEYLOCKER related feature since Panther Lake and Clearwater Forest
    
    According to July 2025 SDM, Key locker will no longer be supported on
    hardware 2025 onwards. This means for Panther Lake and Clearwater Forest,
    the feature will not be enabled. Remove them from those two platforms.
    
    gcc/ChangeLog:
    
            * config/i386/i386.h (PTA_PANTHERLAKE): Revmoe KL and WIDEKL.
            (PTA_CLEARWATERFOREST): Ditto.
            * doc/invoke.texi: Revise documentation.

diff --git a/gcc/config/i386/i386.h b/gcc/config/i386/i386.h
index 6a833fd8dbd..2aed6a2b773 100644
--- a/gcc/config/i386/i386.h
+++ b/gcc/config/i386/i386.h
@@ -2432,10 +2432,11 @@ constexpr wide_int_bitmask PTA_ARROWLAKE = PTA_ALDERLAKE | PTA_AVXIFMA
   | PTA_AVXVNNIINT8 | PTA_AVXNECONVERT | PTA_CMPCCXADD | PTA_UINTR;
 constexpr wide_int_bitmask PTA_ARROWLAKE_S = PTA_ARROWLAKE | PTA_AVXVNNIINT16
   | PTA_SHA512 | PTA_SM3 | PTA_SM4;
-constexpr wide_int_bitmask PTA_CLEARWATERFOREST = PTA_SIERRAFOREST
-  | PTA_AVXVNNIINT16 | PTA_SHA512 | PTA_SM3 | PTA_SM4 | PTA_USER_MSR
-  | PTA_PREFETCHI;
-constexpr wide_int_bitmask PTA_PANTHERLAKE = PTA_ARROWLAKE_S | PTA_PREFETCHI;
+constexpr wide_int_bitmask PTA_CLEARWATERFOREST =
+  (PTA_SIERRAFOREST & (~(PTA_KL | PTA_WIDEKL))) | PTA_AVXVNNIINT16 | PTA_SHA512
+  | PTA_SM3 | PTA_SM4 | PTA_USER_MSR | PTA_PREFETCHI;
+constexpr wide_int_bitmask PTA_PANTHERLAKE =
+  (PTA_ARROWLAKE_S & (~(PTA_KL | PTA_WIDEKL))) | PTA_PREFETCHI;
 constexpr wide_int_bitmask PTA_KNM = PTA_KNL | PTA_AVX5124VNNIW
   | PTA_AVX5124FMAPS | PTA_AVX512VPOPCNTDQ;
 
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index d8ff23447f4..6e68691a37d 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -34541,9 +34541,9 @@ Intel Panther Lake CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,
 SSSE3, SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND, XSAVE, XSAVEC,
 XSAVES, XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX, GFNI-SSE, CLWB, MOVDIRI,
 MOVDIR64B, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA, LZCNT, PCONFIG, PKU,
-VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL, AVX-VNNI, UINTR, AVXIFMA,
-AVXVNNIINT8, AVXNECONVERT, CMPCCXADD, AVXVNNIINT16, SHA512, SM3, SM4 and
-PREFETCHI instruction set support.
+VAES, VPCLMULQDQ, SERIALIZE, HRESET, AVX-VNNI, UINTR, AVXIFMA, AVXVNNIINT8,
+AVXNECONVERT, CMPCCXADD, AVXVNNIINT16, SHA512, SM3, SM4 and PREFETCHI
+instruction set support.
 
 @item sapphirerapids
 @itemx emeraldrapids
@@ -34632,9 +34632,9 @@ Intel Clearwater Forest CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2,
 SSE3, SSSE3, SSE4.1, SSE4.2, POPCNT, AES, PREFETCHW, PCLMUL, RDRND, XSAVE,
 XSAVEC, XSAVES, XSAVEOPT, FSGSBASE, PTWRITE, RDPID, SGX, GFNI-SSE, CLWB,
 MOVDIRI, MOVDIR64B, CLDEMOTE, WAITPKG, ADCX, AVX, AVX2, BMI, BMI2, F16C, FMA,
-LZCNT, PCONFIG, PKU, VAES, VPCLMULQDQ, SERIALIZE, HRESET, KL, WIDEKL, AVX-VNNI,
-ENQCMD, UINTR, AVXIFMA, AVXVNNIINT8, AVXNECONVERT, CMPCCXADD, AVXVNNIINT16,
-SHA512, SM3, SM4, USER_MSR and PREFETCHI instruction set support.
+LZCNT, PCONFIG, PKU, VAES, VPCLMULQDQ, SERIALIZE, HRESET, AVX-VNNI, ENQCMD,
+UINTR, AVXIFMA, AVXVNNIINT8, AVXNECONVERT, CMPCCXADD, AVXVNNIINT16, SHA512,
+SM3, SM4, USER_MSR and PREFETCHI instruction set support.
 
 @item knl
 Intel Knights Landing CPU with 64-bit extensions, MOVBE, MMX, SSE, SSE2, SSE3,

commit 14a5b2162e4614a87829c9ea3103b0884baf1c07
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Tue Jul 15 02:22:24 2025

    Daily bump.

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 333137d97ae..06458ff3c7b 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2025-07-14  Haochen Jiang  <haochen.jiang@intel.com>
+
+	* config/i386/i386.h (PTA_PANTHERLAKE): Revmoe KL and WIDEKL.
+	(PTA_CLEARWATERFOREST): Ditto.
+	* doc/invoke.texi: Revise documentation.
+
 2025-07-06  Georg-Johann Lay  <avr@gjlay.de>
 
 	* config/avr/avr-mcus.def (avr32da28s, avr32da32s, avr32da48s)
diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index eaad3526d83..5c2a452f007 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20250714
+20250715

commit 746767afe3ed6edf0d17740dbcf660936c9e9c1b
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Wed Jul 16 02:21:56 2025

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 5c2a452f007..c02c887d37e 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20250715
+20250716

commit 4ba8f2102fec5e04df28e912036283b67aff6c07
Author: Paul Thomas <pault@gcc.gnu.org>
Date:   Wed Jul 16 07:16:57 2025

    Fortran: Fix ICE in ASSOCIATE with user defined operator [PR121060]
    
    2025-07-16  Paul Thomas  <pault@gcc.gnu.org>
    
    gcc/fortran
            PR fortran/121060
            * interface.cc (matching_typebound_op): Defer determination of
            specific procedure until resolution by returning NULL.
    
    gcc/testsuite/
            PR fortran/121060
            * gfortran.dg/associate_75.f90: New test.
    
    (cherry picked from commit 82e912344d28cf1a69e5f8e047203ea7eb625302)

diff --git a/gcc/fortran/interface.cc b/gcc/fortran/interface.cc
index 25f27f83458..a3f0a5306f5 100644
--- a/gcc/fortran/interface.cc
+++ b/gcc/fortran/interface.cc
@@ -4622,6 +4622,13 @@ matching_typebound_op (gfc_expr** tb_base,
 		gfc_actual_arglist* argcopy;
 		bool matches;
 
+		/* If expression matching comes here during parsing, eg. when
+		   parsing ASSOCIATE, generic TBPs have not yet been resolved
+		   and g->specific will not have been set. Wait for expression
+		   resolution by returning NULL.  */
+		if (!g->specific && !gfc_current_ns->resolved)
+		  return NULL;
+
 		gcc_assert (g->specific);
 		if (g->specific->error)
 		  continue;
diff --git a/gcc/testsuite/gfortran.dg/associate_75.f90 b/gcc/testsuite/gfortran.dg/associate_75.f90
new file mode 100644
index 00000000000..c7c461a5cb6
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/associate_75.f90
@@ -0,0 +1,50 @@
+! { dg-do run }
+!
+! Test fix for PR121060.
+!
+! Contributed by Damian Rouson  <damian@archaeologic.codes>
+!
+module subdomain_m
+  implicit none
+
+  type subdomain_t 
+    real :: s_ = 99.
+  contains
+    generic :: operator(.laplacian.) => laplacian
+    procedure laplacian
+  end type
+
+contains
+
+  function laplacian(rhs)
+    class(subdomain_t), intent(in) :: rhs
+    type(subdomain_t) laplacian
+    laplacian%s_ = rhs%s_ + 42
+  end function
+
+end module
+
+  use subdomain_m
+  implicit none
+
+  type operands_t
+    real :: s_
+  end type
+
+  type(subdomain_t) phi
+  type(operands_t) operands
+
+  associate(laplacian_phi => .laplacian. phi) ! ICE because specific not found.
+    operands = approximates(laplacian_phi%s_)
+  end associate
+
+  if (int (operands%s_) /= 42) stop 1
+contains
+
+  function approximates(actual)
+    real actual 
+    type(operands_t) approximates
+    approximates%s_ = actual - 99
+  end function
+
+end

commit 8f88e1bc14deebb9fab160d3fb72ec9bfd1de7fe
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Thu Jul 17 02:21:55 2025

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index c02c887d37e..fc3196f0a51 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20250716
+20250717
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 12ead9dfc79..0bc582b384c 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,12 @@
+2025-07-16  Paul Thomas  <pault@gcc.gnu.org>
+
+	Backported from master:
+	2025-07-16  Paul Thomas  <pault@gcc.gnu.org>
+
+	PR fortran/121060
+	* interface.cc (matching_typebound_op): Defer determination of
+	specific procedure until resolution by returning NULL.
+
 2025-05-25  Harald Anlauf  <anlauf@gmx.de>
 
 	Backported from master:
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 217018de03e..02dd9ee62b5 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,11 @@
+2025-07-16  Paul Thomas  <pault@gcc.gnu.org>
+
+	Backported from master:
+	2025-07-16  Paul Thomas  <pault@gcc.gnu.org>
+
+	PR fortran/121060
+	* gfortran.dg/associate_75.f90: New test.
+
 2025-07-03  Jakub Jelinek  <jakub@redhat.com>
 
 	Backported from master:

commit d7dd08411bc3b4e8431174d036021ecf482e7d61
Author: Jason Merrill <jason@redhat.com>
Date:   Thu Jul 17 15:46:35 2025

    c++: constexpr array testcase [PR87097]
    
    This seems to have been fixed by r15-7260 for PR118285, but is sufficiently
    different to merit its own test.
    
            PR c++/87097
    
    gcc/testsuite/ChangeLog:
    
            * g++.dg/cpp0x/constexpr-array29.C: New test.

diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-array29.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-array29.C
new file mode 100644
index 00000000000..714d050b503
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-array29.C
@@ -0,0 +1,13 @@
+// PR c++/87097
+// { dg-do compile { target c++11 } }
+
+struct A {
+  constexpr A() : data() {}
+  struct X { int n; };
+  X data[2];
+};
+
+static_assert((A(), true), "");
+static_assert(A().data[0].n == 0, "");
+static_assert(A().data[1].n == 0, "");
+constexpr A x;

commit 4d929cd27e66c7d9c519cbcd77f12e1d58e85689
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Tue Jul 1 11:17:06 2025

    x86-64: Add RDI clobber to tls_global_dynamic_64 patterns
    
    *tls_global_dynamic_64_<mode> uses RDI as the __tls_get_addr argument.
    Add RDI clobber to tls_global_dynamic_64 patterns to show it.
    
            PR target/120908
            * config/i386/i386.cc (legitimize_tls_address): Pass RDI to
            gen_tls_global_dynamic_64.
            * config/i386/i386.md (*tls_global_dynamic_64_<mode>): Add RDI
            clobber and use it to generate LEA.
            (@tls_global_dynamic_64_<mode>): Add a clobber.
    
    Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
    (cherry picked from commit 7710d513a552f1fa1b7485ec6b318bafaa6d4cd7)

diff --git a/gcc/config/i386/i386.cc b/gcc/config/i386/i386.cc
index 2e1a31d0540..94e29fa4321 100644
--- a/gcc/config/i386/i386.cc
+++ b/gcc/config/i386/i386.cc
@@ -12218,11 +12218,12 @@ legitimize_tls_address (rtx x, enum tls_model model, bool for_mov)
 	  if (TARGET_64BIT)
 	    {
 	      rtx rax = gen_rtx_REG (Pmode, AX_REG);
+	      rtx rdi = gen_rtx_REG (Pmode, DI_REG);
 	      rtx_insn *insns;
 
 	      start_sequence ();
 	      emit_call_insn
-		(gen_tls_global_dynamic_64 (Pmode, rax, x, caddr));
+		(gen_tls_global_dynamic_64 (Pmode, rax, x, caddr, rdi));
 	      insns = get_insns ();
 	      end_sequence ();
 
diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md
index 78d75138721..def39d1a729 100644
--- a/gcc/config/i386/i386.md
+++ b/gcc/config/i386/i386.md
@@ -21114,7 +21114,8 @@
 	 (match_operand 3)))
    (unspec:P [(match_operand 1 "tls_symbolic_operand")
 	      (reg:P SP_REG)]
-	     UNSPEC_TLS_GD)]
+	     UNSPEC_TLS_GD)
+   (clobber (match_operand:P 4 "register_operand" "=D"))]
   "TARGET_64BIT"
 {
   if (!TARGET_X32)
@@ -21131,7 +21132,7 @@
        Use data16 prefix instead, which doesn't have this problem.  */
     fputs ("\tdata16", asm_out_file);
   output_asm_insn
-    ("lea{q}\t{%E1@tlsgd(%%rip), %%rdi|rdi, %E1@tlsgd[rip]}", operands);
+    ("lea{q}\t{%E1@tlsgd(%%rip), %q4|%q4, %E1@tlsgd[rip]}", operands);
   if (TARGET_SUN_TLS || flag_plt || !HAVE_AS_IX86_TLS_GET_ADDR_GOT)
     fputs (ASM_SHORT "0x6666\n", asm_out_file);
   else
@@ -21178,7 +21179,8 @@
 	   (const_int 0)))
      (unspec:P [(match_operand 1 "tls_symbolic_operand")
 		(reg:P SP_REG)]
-	       UNSPEC_TLS_GD)])]
+	       UNSPEC_TLS_GD)
+     (clobber (match_operand:P 3 "register_operand"))])]
   "TARGET_64BIT"
   "ix86_tls_descriptor_calls_expanded_in_cfun = true;")
 

commit 59db34888d289dae8fae2bcbf5e435be53da0edc
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Thu Jul 3 04:54:39 2025

    x86-64: Add RDI clobber to 64-bit dynamic TLS patterns
    
    *tls_global_dynamic_64_largepic, *tls_local_dynamic_64_<mode> and
    *tls_local_dynamic_base_64_largepic use RDI as the __tls_get_addr
    argument.  Add RDI clobber to these patterns to show it.
    
    gcc/
    
            PR target/120908
            * config/i386/i386.cc (legitimize_tls_address): Pass RDI to
            gen_tls_local_dynamic_64.
            * config/i386/i386.md (*tls_global_dynamic_64_largepic): Add
            RDI clobber and use it to generate LEA.
            (*tls_local_dynamic_64_<mode>): Likewise.
            (*tls_local_dynamic_base_64_largepic): Likewise.
            (@tls_local_dynamic_64_<mode>): Add a clobber.
    
    gcc/testsuite/
    
            PR target/120908
            * gcc.target/i386/pr120908.c: New test.
    
    Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
    (cherry picked from commit d8d5e2a8031e74f08f61ccdd727476f97940c5a6)

diff --git a/gcc/config/i386/i386.cc b/gcc/config/i386/i386.cc
index 94e29fa4321..edb51f2a9b2 100644
--- a/gcc/config/i386/i386.cc
+++ b/gcc/config/i386/i386.cc
@@ -12273,12 +12273,13 @@ legitimize_tls_address (rtx x, enum tls_model model, bool for_mov)
 	  if (TARGET_64BIT)
 	    {
 	      rtx rax = gen_rtx_REG (Pmode, AX_REG);
+	      rtx rdi = gen_rtx_REG (Pmode, DI_REG);
 	      rtx_insn *insns;
 	      rtx eqv;
 
 	      start_sequence ();
 	      emit_call_insn
-		(gen_tls_local_dynamic_base_64 (Pmode, rax, caddr));
+		(gen_tls_local_dynamic_base_64 (Pmode, rax, caddr, rdi));
 	      insns = get_insns ();
 	      end_sequence ();
 
diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md
index def39d1a729..b02057c5f0f 100644
--- a/gcc/config/i386/i386.md
+++ b/gcc/config/i386/i386.md
@@ -21156,14 +21156,15 @@
 	 (match_operand 4)))
    (unspec:DI [(match_operand 1 "tls_symbolic_operand")
 	       (reg:DI SP_REG)]
-	      UNSPEC_TLS_GD)]
+	      UNSPEC_TLS_GD)
+   (clobber (match_operand:DI 5 "register_operand" "=D"))]
   "TARGET_64BIT && ix86_cmodel == CM_LARGE_PIC && !TARGET_PECOFF
    && GET_CODE (operands[3]) == CONST
    && GET_CODE (XEXP (operands[3], 0)) == UNSPEC
    && XINT (XEXP (operands[3], 0), 1) == UNSPEC_PLTOFF"
 {
   output_asm_insn
-    ("lea{q}\t{%E1@tlsgd(%%rip), %%rdi|rdi, %E1@tlsgd[rip]}", operands);
+    ("lea{q}\t{%E1@tlsgd(%%rip), %5|%5, %E1@tlsgd[rip]}", operands);
   output_asm_insn ("movabs{q}\t{%3, %%rax|rax, %3}", operands);
   output_asm_insn ("add{q}\t{%2, %%rax|rax, %2}", operands);
   return "call\t{*%%rax|rax}";
@@ -21231,11 +21232,12 @@
 	(call:P
 	 (mem:QI (match_operand 1 "constant_call_address_operand" "Bz"))
 	 (match_operand 2)))
-   (unspec:P [(reg:P SP_REG)] UNSPEC_TLS_LD_BASE)]
+   (unspec:P [(reg:P SP_REG)] UNSPEC_TLS_LD_BASE)
+   (clobber (match_operand:P 3 "register_operand" "=D"))]
   "TARGET_64BIT"
 {
   output_asm_insn
-    ("lea{q}\t{%&@tlsld(%%rip), %%rdi|rdi, %&@tlsld[rip]}", operands);
+    ("lea{q}\t{%&@tlsld(%%rip), %q3|%q3, %&@tlsld[rip]}", operands);
   if (TARGET_SUN_TLS)
     return "call\t%p1@plt";
   if (flag_plt || !HAVE_AS_IX86_TLS_GET_ADDR_GOT)
@@ -21251,14 +21253,15 @@
 	 (mem:QI (plus:DI (match_operand:DI 1 "register_operand" "b")
 			  (match_operand:DI 2 "immediate_operand" "i")))
 	 (match_operand 3)))
-   (unspec:DI [(reg:DI SP_REG)] UNSPEC_TLS_LD_BASE)]
+   (unspec:DI [(reg:DI SP_REG)] UNSPEC_TLS_LD_BASE)
+   (clobber (match_operand:DI 4 "register_operand" "=D"))]
   "TARGET_64BIT && ix86_cmodel == CM_LARGE_PIC && !TARGET_PECOFF
    && GET_CODE (operands[2]) == CONST
    && GET_CODE (XEXP (operands[2], 0)) == UNSPEC
    && XINT (XEXP (operands[2], 0), 1) == UNSPEC_PLTOFF"
 {
   output_asm_insn
-    ("lea{q}\t{%&@tlsld(%%rip), %%rdi|rdi, %&@tlsld[rip]}", operands);
+    ("lea{q}\t{%&@tlsld(%%rip), %4|%4, %&@tlsld[rip]}", operands);
   output_asm_insn ("movabs{q}\t{%2, %%rax|rax, %2}", operands);
   output_asm_insn ("add{q}\t{%1, %%rax|rax, %1}", operands);
   return "call\t{*%%rax|rax}";
@@ -21272,7 +21275,8 @@
 	   (call:P
 	    (mem:QI (match_operand 1))
 	    (const_int 0)))
-      (unspec:P [(reg:P SP_REG)] UNSPEC_TLS_LD_BASE)])]
+      (unspec:P [(reg:P SP_REG)] UNSPEC_TLS_LD_BASE)
+      (clobber (match_operand:P 2 "register_operand"))])]
   "TARGET_64BIT"
   "ix86_tls_descriptor_calls_expanded_in_cfun = true;")
 
diff --git a/gcc/testsuite/gcc.target/i386/pr120908.c b/gcc/testsuite/gcc.target/i386/pr120908.c
new file mode 100644
index 00000000000..10e5a46d8d4
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr120908.c
@@ -0,0 +1,16 @@
+/* { dg-do compile { target { lp64 && fpic } } } */
+/* { dg-options "-O2 -fpic -mtls-dialect=gnu -mcmodel=large" } */
+
+extern __thread long bar1;
+long *
+foo1 (void)
+{
+  return &bar1;
+}
+
+static __thread long bar2;
+long *
+foo2 (void)
+{
+  return &bar2;
+}

commit 67f1618144301e0e3df29840869610295852238f
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Fri Jul 18 02:22:58 2025

    Daily bump.

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 06458ff3c7b..7123d039812 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,29 @@
+2025-07-17  H.J. Lu  <hjl.tools@gmail.com>
+
+	Backported from master:
+	2025-07-03  H.J. Lu  <hjl.tools@gmail.com>
+
+	PR target/120908
+	* config/i386/i386.cc (legitimize_tls_address): Pass RDI to
+	gen_tls_local_dynamic_64.
+	* config/i386/i386.md (*tls_global_dynamic_64_largepic): Add
+	RDI clobber and use it to generate LEA.
+	(*tls_local_dynamic_64_<mode>): Likewise.
+	(*tls_local_dynamic_base_64_largepic): Likewise.
+	(@tls_local_dynamic_64_<mode>): Add a clobber.
+
+2025-07-17  H.J. Lu  <hjl.tools@gmail.com>
+
+	Backported from master:
+	2025-07-02  H.J. Lu  <hjl.tools@gmail.com>
+
+	PR target/120908
+	* config/i386/i386.cc (legitimize_tls_address): Pass RDI to
+	gen_tls_global_dynamic_64.
+	* config/i386/i386.md (*tls_global_dynamic_64_<mode>): Add RDI
+	clobber and use it to generate LEA.
+	(@tls_global_dynamic_64_<mode>): Add a clobber.
+
 2025-07-14  Haochen Jiang  <haochen.jiang@intel.com>
 
 	* config/i386/i386.h (PTA_PANTHERLAKE): Revmoe KL and WIDEKL.
diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index fc3196f0a51..9866b70f901 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20250717
+20250718
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 02dd9ee62b5..da60f4efc79 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,16 @@
+2025-07-17  H.J. Lu  <hjl.tools@gmail.com>
+
+	Backported from master:
+	2025-07-03  H.J. Lu  <hjl.tools@gmail.com>
+
+	PR target/120908
+	* gcc.target/i386/pr120908.c: New test.
+
+2025-07-17  Jason Merrill  <jason@redhat.com>
+
+	PR c++/87097
+	* g++.dg/cpp0x/constexpr-array29.C: New test.
+
 2025-07-16  Paul Thomas  <pault@gcc.gnu.org>
 
 	Backported from master:

commit d51d503af7db6e4d8ca40e29d9250850f25aee1a
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Fri Jul 18 09:20:30 2025

    gimple-fold: Fix up big endian _BitInt adjustment [PR121131]
    
    The following testcase ICEs because SCALAR_INT_TYPE_MODE of course
    doesn't work for large BITINT_TYPE types which have BLKmode.
    native_encode* as well as e.g. r14-8276 use in cases like these
    GET_MODE_SIZE (SCALAR_INT_TYPE_MODE ()) and TREE_INT_CST_LOW (TYPE_SIZE_UNIT
    ()) for the BLKmode ones.
    In this case, it wants bits rather than bytes, so I've used
    GET_MODE_BITSIZE like before and TYPE_SIZE otherwise.
    
    Furthermore, the patch only computes encoding_size for big endian
    targets, for little endian we don't really adjust anything, so there
    is no point computing it.
    
    2025-07-18  Jakub Jelinek  <jakub@redhat.com>
    
            PR tree-optimization/121131
            * gimple-fold.cc (fold_nonarray_ctor_reference): Use
            TREE_INT_CST_LOW (TYPE_SIZE ()) instead of
            GET_MODE_BITSIZE (SCALAR_INT_TYPE_MODE ()) for BLKmode BITINT_TYPEs.
            Don't compute encoding_size at all for little endian targets.
    
            * gcc.dg/bitint-124.c: New test.
    
    (cherry picked from commit 90955b2f61f787ebc446f0a105b5f49672388d89)

diff --git a/gcc/gimple-fold.cc b/gcc/gimple-fold.cc
index 026dac45ded..cc84d392a83 100644
--- a/gcc/gimple-fold.cc
+++ b/gcc/gimple-fold.cc
@@ -8243,10 +8243,17 @@ fold_nonarray_ctor_reference (tree type, tree ctor,
 	    {
 	      if (BYTES_BIG_ENDIAN != WORDS_BIG_ENDIAN)
 		return NULL_TREE;
-	      const unsigned int encoding_size
-		= GET_MODE_BITSIZE (SCALAR_INT_TYPE_MODE (TREE_TYPE (cfield)));
 	      if (BYTES_BIG_ENDIAN)
-		inner_offset += encoding_size - wi::to_offset (field_size);
+		{
+		  tree ctype = TREE_TYPE (cfield);
+		  unsigned int encoding_size;
+		  if (TYPE_MODE (ctype) != BLKmode)
+		    encoding_size
+		      = GET_MODE_BITSIZE (SCALAR_INT_TYPE_MODE (ctype));
+		  else
+		    encoding_size = TREE_INT_CST_LOW (TYPE_SIZE (ctype));
+		  inner_offset += encoding_size - wi::to_offset (field_size);
+		}
 	    }
 
 	  return fold_ctor_reference (type, cval,
diff --git a/gcc/testsuite/gcc.dg/bitint-124.c b/gcc/testsuite/gcc.dg/bitint-124.c
new file mode 100644
index 00000000000..160a1e3394a
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/bitint-124.c
@@ -0,0 +1,30 @@
+/* PR tree-optimization/121131 */
+/* { dg-do run { target bitint } } */
+/* { dg-options "-O2" } */
+
+#if __BITINT_MAXWIDTH__ >= 156
+struct A { _BitInt(156) b : 135; };
+
+static inline _BitInt(156)
+foo (struct A *x)
+{
+  return x[1].b;
+}
+
+__attribute__((noipa)) _BitInt(156)
+bar (void)
+{
+  struct A a[] = { 1, 1, -13055525270329736316393717310914023773847wb,
+		   1, 1, 1, 1, 1, 1, 1, 1, 1 };
+  return foo (&a[1]);
+}
+#endif
+
+int
+main ()
+{
+#if __BITINT_MAXWIDTH__ >= 156
+  if (bar () != -13055525270329736316393717310914023773847wb)
+    __builtin_abort ();
+#endif
+}

commit 63832e7372180298a1bb4774878750441a62af02
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sat Jul 19 02:24:51 2025

    Daily bump.

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 7123d039812..c24acb7738a 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,14 @@
+2025-07-18  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2025-07-18  Jakub Jelinek  <jakub@redhat.com>
+
+	PR tree-optimization/121131
+	* gimple-fold.cc (fold_nonarray_ctor_reference): Use
+	TREE_INT_CST_LOW (TYPE_SIZE ()) instead of
+	GET_MODE_BITSIZE (SCALAR_INT_TYPE_MODE ()) for BLKmode BITINT_TYPEs.
+	Don't compute encoding_size at all for little endian targets.
+
 2025-07-17  H.J. Lu  <hjl.tools@gmail.com>
 
 	Backported from master:
diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 9866b70f901..c64e4865ca8 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20250718
+20250719
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index da60f4efc79..9e620fa0214 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,11 @@
+2025-07-18  Jakub Jelinek  <jakub@redhat.com>
+
+	Backported from master:
+	2025-07-18  Jakub Jelinek  <jakub@redhat.com>
+
+	PR tree-optimization/121131
+	* gcc.dg/bitint-124.c: New test.
+
 2025-07-17  H.J. Lu  <hjl.tools@gmail.com>
 
 	Backported from master:

commit 72524864fe825d1f5a5b6e1feb9adcc9711450d4
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Sun Jul 20 02:24:00 2025

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index c64e4865ca8..eafd44957d2 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20250719
+20250720

commit 813176b5b0cb314311ce45c3770aa98906f00fd4
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Mon Jul 21 02:21:58 2025

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index eafd44957d2..b1af684c290 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20250720
+20250721

commit f924db6ae964f5b87aebf9e9182ac2b16e54fa30
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Tue Jul 22 02:23:13 2025

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index b1af684c290..7578d8939d6 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20250721
+20250722

commit 845085856185560952331626fbca3a1414cc3adb
Author: Haochen Gui <guihaoc@gcc.gnu.org>
Date:   Thu Aug 15 07:45:35 2024

    rs6000: Add TARGET_FLOAT128_HW guard for quad-precision insns
    
    gcc/
            * config/rs6000/rs6000.md (floatti<mode>2, floatunsti<mode>2,
            fix_trunc<mode>ti2): Add guard TARGET_FLOAT128_HW.
            * config/rs6000/vsx.md (xsxexpqp_<IEEE128:mode>_<V2DI_DI:mode>,
            xsxsigqp_<IEEE128:mode>_<VEC_TI:mode>, xsiexpqpf_<mode>,
            xsiexpqp_<IEEE128:mode>_<V2DI_DI:mode>, xscmpexpqp_<code>_<mode>,
            *xscmpexpqp, xststdcnegqp_<mode>): Replace guard TARGET_P9_VECTOR
            with TARGET_FLOAT128_HW.
    
    gcc/testsuite/
            * gcc.target/powerpc/float128-cmp2-runnable.c: Replace
            ppc_float128_sw with ppc_float128_hw and remove p9vector_hw.
    
    (cherry picked from commit bf891fcabca7a59ce71e85c8f2eea2bfabbffe59)

diff --git a/gcc/config/rs6000/rs6000.md b/gcc/config/rs6000/rs6000.md
index 74b87f926d7..bbbd7041a19 100644
--- a/gcc/config/rs6000/rs6000.md
+++ b/gcc/config/rs6000/rs6000.md
@@ -6897,7 +6897,7 @@
 (define_insn "floatti<mode>2"
   [(set (match_operand:IEEE128 0 "vsx_register_operand" "=v")
 	(float:IEEE128 (match_operand:TI 1 "vsx_register_operand" "v")))]
-  "TARGET_POWER10"
+  "TARGET_POWER10 && TARGET_FLOAT128_HW"
 {
   return  "xscvsqqp %0,%1";
 }
@@ -6906,7 +6906,7 @@
 (define_insn "floatunsti<mode>2"
   [(set (match_operand:IEEE128 0 "vsx_register_operand" "=v")
 	(unsigned_float:IEEE128 (match_operand:TI 1 "vsx_register_operand" "v")))]
-  "TARGET_POWER10"
+  "TARGET_POWER10 && TARGET_FLOAT128_HW"
 {
   return  "xscvuqqp %0,%1";
 }
@@ -6915,7 +6915,7 @@
 (define_insn "fix_trunc<mode>ti2"
   [(set (match_operand:TI 0 "vsx_register_operand" "=v")
 	(fix:TI (match_operand:IEEE128 1 "vsx_register_operand" "v")))]
-  "TARGET_POWER10"
+  "TARGET_POWER10 && TARGET_FLOAT128_HW"
 {
   return  "xscvqpsqz %0,%1";
 }
diff --git a/gcc/config/rs6000/vsx.md b/gcc/config/rs6000/vsx.md
index 7a9c19ac903..8665ee7f6df 100644
--- a/gcc/config/rs6000/vsx.md
+++ b/gcc/config/rs6000/vsx.md
@@ -5132,7 +5132,7 @@
 	(unspec:V2DI_DI
 	  [(match_operand:IEEE128 1 "altivec_register_operand" "v")]
 	 UNSPEC_VSX_SXEXPDP))]
-  "TARGET_P9_VECTOR"
+  "TARGET_FLOAT128_HW"
   "xsxexpqp %0,%1"
   [(set_attr "type" "vecmove")])
 
@@ -5151,7 +5151,7 @@
 	(unspec:VEC_TI [(match_operand:IEEE128 1
 			    "altivec_register_operand" "v")]
 	 UNSPEC_VSX_SXSIG))]
-  "TARGET_P9_VECTOR"
+  "TARGET_FLOAT128_HW"
   "xsxsigqp %0,%1"
   [(set_attr "type" "vecmove")])
 
@@ -5171,7 +5171,7 @@
 	 [(match_operand:IEEE128 1 "altivec_register_operand" "v")
 	  (match_operand:DI 2 "altivec_register_operand" "v")]
 	 UNSPEC_VSX_SIEXPQP))]
-  "TARGET_P9_VECTOR"
+  "TARGET_FLOAT128_HW"
   "xsiexpqp %0,%1,%2"
   [(set_attr "type" "vecmove")])
 
@@ -5183,7 +5183,7 @@
 			 (match_operand:V2DI_DI 2
 			  "altivec_register_operand" "v")]
 	 UNSPEC_VSX_SIEXPQP))]
-  "TARGET_P9_VECTOR"
+  "TARGET_FLOAT128_HW"
   "xsiexpqp %0,%1,%2"
   [(set_attr "type" "vecmove")])
 
@@ -5253,7 +5253,7 @@
    (set (match_operand:SI 0 "register_operand" "=r")
 	(CMP_TEST:SI (match_dup 3)
 		     (const_int 0)))]
-  "TARGET_P9_VECTOR"
+  "TARGET_FLOAT128_HW"
 {
   if (<CODE> == UNORDERED && !HONOR_NANS (<MODE>mode))
     {
@@ -5271,7 +5271,7 @@
 		          (match_operand:IEEE128 2 "altivec_register_operand" "v")]
 	  UNSPEC_VSX_SCMPEXPQP)
 	 (match_operand:SI 3 "zero_constant" "j")))]
-  "TARGET_P9_VECTOR"
+  "TARGET_FLOAT128_HW"
   "xscmpexpqp %0,%1,%2"
   [(set_attr "type" "fpcompare")])
 
@@ -5329,7 +5329,7 @@
    (set (match_operand:SI 0 "register_operand" "=r")
 	(lt:SI (match_dup 2)
 	       (const_int 0)))]
-  "TARGET_P9_VECTOR"
+  "TARGET_FLOAT128_HW"
 {
   operands[2] = gen_reg_rtx (CCFPmode);
 })
diff --git a/gcc/testsuite/gcc.target/powerpc/float128-cmp2-runnable.c b/gcc/testsuite/gcc.target/powerpc/float128-cmp2-runnable.c
index d376a3ca68e..f48aa089b05 100644
--- a/gcc/testsuite/gcc.target/powerpc/float128-cmp2-runnable.c
+++ b/gcc/testsuite/gcc.target/powerpc/float128-cmp2-runnable.c
@@ -1,6 +1,5 @@
 /* { dg-do run } */
-/* { dg-require-effective-target ppc_float128_sw } */
-/* { dg-require-effective-target p9vector_hw } */
+/* { dg-require-effective-target ppc_float128_hw } */
 /* { dg-options "-O2 -mdejagnu-cpu=power9 " } */
 
 #define NAN_Q __builtin_nanq ("")

commit 8b44888de9ce3b19a1bce7cbbfb3a9f3c2e78c9d
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Wed Jul 23 02:24:47 2025

    Daily bump.

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index c24acb7738a..6a872430049 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,16 @@
+2025-07-22  Haochen Gui  <guihaoc@gcc.gnu.org>
+
+	Backported from master:
+	2024-08-15  Haochen Gui  <guihaoc@gcc.gnu.org>
+
+	* config/rs6000/rs6000.md (floatti<mode>2, floatunsti<mode>2,
+	fix_trunc<mode>ti2): Add guard TARGET_FLOAT128_HW.
+	* config/rs6000/vsx.md (xsxexpqp_<IEEE128:mode>_<V2DI_DI:mode>,
+	xsxsigqp_<IEEE128:mode>_<VEC_TI:mode>, xsiexpqpf_<mode>,
+	xsiexpqp_<IEEE128:mode>_<V2DI_DI:mode>, xscmpexpqp_<code>_<mode>,
+	*xscmpexpqp, xststdcnegqp_<mode>): Replace guard TARGET_P9_VECTOR
+	with TARGET_FLOAT128_HW.
+
 2025-07-18  Jakub Jelinek  <jakub@redhat.com>
 
 	Backported from master:
diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 7578d8939d6..bd609e4dd0c 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20250722
+20250723
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 9e620fa0214..21dc96e2620 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,11 @@
+2025-07-22  Haochen Gui  <guihaoc@gcc.gnu.org>
+
+	Backported from master:
+	2024-08-15  Haochen Gui  <guihaoc@gcc.gnu.org>
+
+	* gcc.target/powerpc/float128-cmp2-runnable.c: Replace
+	ppc_float128_sw with ppc_float128_hw and remove p9vector_hw.
+
 2025-07-18  Jakub Jelinek  <jakub@redhat.com>
 
 	Backported from master:

commit 7434daf7031b511ebd26c2e1fc9549875d33dc63
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Thu Jul 24 02:26:04 2025

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index bd609e4dd0c..50c0c835e4c 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20250723
+20250724

commit 8be9bec735ad39e4cebacb31401b3707b0d0732f
Author: GCC Administrator <gccadmin@gcc.gnu.org>
Date:   Fri Jul 25 02:24:14 2025

    Daily bump.

diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 50c0c835e4c..b55d394f011 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20250724
+20250725
