diff -Nrcpad gcc-13-20250626/LAST_UPDATED gcc-13-20250703/LAST_UPDATED
*** gcc-13-20250626/LAST_UPDATED	Thu Jun 26 22:32:40 2025
--- gcc-13-20250703/LAST_UPDATED	Thu Jul  3 22:33:34 2025
***************
*** 1 ****
! Obtained from git: releases/gcc-13 revision 2abf837326e4ab1d92867b77922103c58a618057
--- 1 ----
! Obtained from git: releases/gcc-13 revision f3689dc2061481fa789dbf7b6ab55a8e5f52f198
diff -Nrcpad gcc-13-20250626/MD5SUMS gcc-13-20250703/MD5SUMS
*** gcc-13-20250626/MD5SUMS	Thu Jun 26 22:32:43 2025
--- gcc-13-20250703/MD5SUMS	Thu Jul  3 22:33:40 2025
***************
*** 1,5 ****
  # This file contains the MD5 checksums of the files in the
! # gcc-13-20250626.tar.xz tarball.
  #
  # Besides verifying that all files in the tarball were correctly expanded,
  # it also can be used to determine if any files have changed since the
--- 1,5 ----
  # This file contains the MD5 checksums of the files in the
! # gcc-13-20250703.tar.xz tarball.
  #
  # Besides verifying that all files in the tarball were correctly expanded,
  # it also can be used to determine if any files have changed since the
*************** d32239bcb673463ab874e80d47fae504  COPYIN
*** 21,27 ****
  fd4ecdf5d672efe2b0e409aca9cf9446  ChangeLog.jit
  09538b708302f1735f6fa05b622ecf5e  ChangeLog.tree-ssa
  24ab760126489e69436a43185dc3d202  INSTALL/README
! 44802b91f39db0b5154645f3fb005ebb  LAST_UPDATED
  81b3330d422f3ce1ef8b720dfae35068  MAINTAINERS
  2b61ddbd876fa839639a7ca551773426  Makefile.def
  5d2d6a74f897f8158d37f5f2ec6877ce  Makefile.in
--- 21,27 ----
  fd4ecdf5d672efe2b0e409aca9cf9446  ChangeLog.jit
  09538b708302f1735f6fa05b622ecf5e  ChangeLog.tree-ssa
  24ab760126489e69436a43185dc3d202  INSTALL/README
! 9be9f2b789cc741cdee5718ad440fedd  LAST_UPDATED
  81b3330d422f3ce1ef8b720dfae35068  MAINTAINERS
  2b61ddbd876fa839639a7ca551773426  Makefile.def
  5d2d6a74f897f8158d37f5f2ec6877ce  Makefile.in
*************** a22e70b3f29292d0e628450f4bb11e62  fixinc
*** 475,481 ****
  a916467b91076e631dd8edb7424769c7  gcc/COPYING.LIB
  d32239bcb673463ab874e80d47fae504  gcc/COPYING3
  6a6a8e020838b23406c81b19c1d46df6  gcc/COPYING3.LIB
! 73a4582e385219f9d6c4fc8082a30bdb  gcc/ChangeLog
  a3b63c675afa7a655cc2bfa8a907af79  gcc/ChangeLog-1997
  d9a88529352a010253c2e8fb1ed6023b  gcc/ChangeLog-1998
  240f08f81cb4699e8b49347db38233db  gcc/ChangeLog-1999
--- 475,481 ----
  a916467b91076e631dd8edb7424769c7  gcc/COPYING.LIB
  d32239bcb673463ab874e80d47fae504  gcc/COPYING3
  6a6a8e020838b23406c81b19c1d46df6  gcc/COPYING3.LIB
! 46384d0ef937687684158aaa05d82c0b  gcc/ChangeLog
  a3b63c675afa7a655cc2bfa8a907af79  gcc/ChangeLog-1997
  d9a88529352a010253c2e8fb1ed6023b  gcc/ChangeLog-1998
  240f08f81cb4699e8b49347db38233db  gcc/ChangeLog-1999
*************** fb3fadb88e1d2b3b640cfaaa5ff11780  gcc/Ch
*** 510,516 ****
  3eb07e0b2e542409bf73d359f7f65609  gcc/ChangeLog.ptr
  e13638e26743ba41e6011b76cc00d9a9  gcc/ChangeLog.tree-ssa
  739ab47f6425bcea1d05e4fc0542de54  gcc/ChangeLog.tuples
! cd3791b2a00ec42fc90a1fcc438515c1  gcc/DATESTAMP
  d41d8cd98f00b204e9800998ecf8427e  gcc/DEV-PHASE
  eb92e1ff5e982ca07e173e0eb286d243  gcc/FSFChangeLog
  30e1e33411566388b3164558482dc5e6  gcc/FSFChangeLog.10
--- 510,516 ----
  3eb07e0b2e542409bf73d359f7f65609  gcc/ChangeLog.ptr
  e13638e26743ba41e6011b76cc00d9a9  gcc/ChangeLog.tree-ssa
  739ab47f6425bcea1d05e4fc0542de54  gcc/ChangeLog.tuples
! 45104949e2410cde3cfde741ec6a013f  gcc/DATESTAMP
  d41d8cd98f00b204e9800998ecf8427e  gcc/DEV-PHASE
  eb92e1ff5e982ca07e173e0eb286d243  gcc/FSFChangeLog
  30e1e33411566388b3164558482dc5e6  gcc/FSFChangeLog.10
*************** d69e0fff19957a7b29ee08926fc6f3cf  gcc/ad
*** 782,788 ****
  29e1f3d1ec783849cfedc4ba5b3f86d2  gcc/ada/gcc-interface/ada.h
  67dc9599090345bd6fc9fed0361f76ee  gcc/ada/gcc-interface/config-lang.in
  df2ffb467ff9812983d01da40295ec68  gcc/ada/gcc-interface/cuintp.cc
! 6dba8ed83dcf439bd6eef93dfb9a45ec  gcc/ada/gcc-interface/decl.cc
  2e46e3864371bc11eae92e2f030fe9c3  gcc/ada/gcc-interface/gadaint.h
  1e23461a8b089b3f96b0eec67b96b60d  gcc/ada/gcc-interface/gigi.h
  9f177b1d16ab7e6e558ee0eccca943ff  gcc/ada/gcc-interface/lang-specs.h
--- 782,788 ----
  29e1f3d1ec783849cfedc4ba5b3f86d2  gcc/ada/gcc-interface/ada.h
  67dc9599090345bd6fc9fed0361f76ee  gcc/ada/gcc-interface/config-lang.in
  df2ffb467ff9812983d01da40295ec68  gcc/ada/gcc-interface/cuintp.cc
! 3b4c69b7437bb1d9995a98fdc583817a  gcc/ada/gcc-interface/decl.cc
  2e46e3864371bc11eae92e2f030fe9c3  gcc/ada/gcc-interface/gadaint.h
  1e23461a8b089b3f96b0eec67b96b60d  gcc/ada/gcc-interface/gigi.h
  9f177b1d16ab7e6e558ee0eccca943ff  gcc/ada/gcc-interface/lang-specs.h
*************** aba5829381a2a8991e36ebb8d4eb9761  gcc/cp
*** 5171,5177 ****
  f46ba3abf12a9521b0a8ac2aac5e8373  gcc/cp/std-name-hint.h
  bde75ae2e2dc98ce0d7ebbb2e49e70c1  gcc/cp/tree.cc
  48f7db9af3b30491ed4f238605782993  gcc/cp/type-utils.h
! bd758da929d27a010b0a933dbc9ab2dd  gcc/cp/typeck.cc
  b08fff9701626891fd78d4b60a5b2b83  gcc/cp/typeck2.cc
  d1622a9e8d6f8df6c5834932b9488b97  gcc/cp/vtable-class-hierarchy.cc
  2597401b7544997a7f6e4811a977c2c8  gcc/cppbuiltin.cc
--- 5171,5177 ----
  f46ba3abf12a9521b0a8ac2aac5e8373  gcc/cp/std-name-hint.h
  bde75ae2e2dc98ce0d7ebbb2e49e70c1  gcc/cp/tree.cc
  48f7db9af3b30491ed4f238605782993  gcc/cp/type-utils.h
! 7bce1786f14c03fec1b20835c6d63c01  gcc/cp/typeck.cc
  b08fff9701626891fd78d4b60a5b2b83  gcc/cp/typeck2.cc
  d1622a9e8d6f8df6c5834932b9488b97  gcc/cp/vtable-class-hierarchy.cc
  2597401b7544997a7f6e4811a977c2c8  gcc/cppbuiltin.cc
*************** db0ccc0edfede8aba0098ae504276e86  gcc/gi
*** 5756,5762 ****
  2e82b4bd416d82267e23cfb6b62145d3  gcc/gimple-builder.h
  dcb207c1736268c66a622256d89d2336  gcc/gimple-expr.cc
  029271620b653993e15dfe20ddd2d37b  gcc/gimple-expr.h
! 0d4a2f003e7841c11e2a6c1b5e122669  gcc/gimple-fold.cc
  9a9d95793deb7de9860fc0d1215b3390  gcc/gimple-fold.h
  7cf98e471595ea406079ac821d418500  gcc/gimple-harden-conditionals.cc
  ab5c0e8e80c5a594037aa3a03ad791c9  gcc/gimple-if-to-switch.cc
--- 5756,5762 ----
  2e82b4bd416d82267e23cfb6b62145d3  gcc/gimple-builder.h
  dcb207c1736268c66a622256d89d2336  gcc/gimple-expr.cc
  029271620b653993e15dfe20ddd2d37b  gcc/gimple-expr.h
! c30c322635ac78dc841b9ec4efbb7c71  gcc/gimple-fold.cc
  9a9d95793deb7de9860fc0d1215b3390  gcc/gimple-fold.h
  7cf98e471595ea406079ac821d418500  gcc/gimple-harden-conditionals.cc
  ab5c0e8e80c5a594037aa3a03ad791c9  gcc/gimple-if-to-switch.cc
*************** b829ed0032c899e107be2db349c913f3  gcc/ta
*** 7637,7643 ****
  811da275a2b9d3186a6decf96c01b0ed  gcc/targhooks.cc
  edb193a32070c4a7626fb75382def9b9  gcc/targhooks.h
  f39fcaa8197187283ccfed40107b426d  gcc/testsuite/.gitattributes
! 5c9c49a2f64dc991f3a8859af3606ee4  gcc/testsuite/ChangeLog
  862f04afbd87da2cc6bc432c3f28430f  gcc/testsuite/ChangeLog-1993-2007
  029a5d8dacd25eb5d4711452ac448e5b  gcc/testsuite/ChangeLog-2008
  13ac28c41d51b66b4ec40dba6bd50f39  gcc/testsuite/ChangeLog-2009
--- 7637,7643 ----
  811da275a2b9d3186a6decf96c01b0ed  gcc/targhooks.cc
  edb193a32070c4a7626fb75382def9b9  gcc/targhooks.h
  f39fcaa8197187283ccfed40107b426d  gcc/testsuite/.gitattributes
! 579d963c6fad465e03cfb7f76b7c821a  gcc/testsuite/ChangeLog
  862f04afbd87da2cc6bc432c3f28430f  gcc/testsuite/ChangeLog-1993-2007
  029a5d8dacd25eb5d4711452ac448e5b  gcc/testsuite/ChangeLog-2008
  13ac28c41d51b66b4ec40dba6bd50f39  gcc/testsuite/ChangeLog-2009
*************** ce5771924fa5fd60b270c30c11bee489  gcc/te
*** 25189,25194 ****
--- 25189,25196 ----
  290161573b66c49ae4261f07f77681d3  gcc/testsuite/g++.dg/parse/parser-pr28152-2.C
  a0fee4f3ee4678b54afd993b619baa05  gcc/testsuite/g++.dg/parse/parser-pr28152.C
  19f7d11d9ad101a38756eab150921947  gcc/testsuite/g++.dg/parse/pr101783.C
+ 732ccde523003692267913067f6a0ccd  gcc/testsuite/g++.dg/parse/pr120471.C
+ 225e1d7f8cf80186eac35ff37acc9379  gcc/testsuite/g++.dg/parse/pr120940.C
  2dde7d845edb3fc1b6b06c1f7c1d71f6  gcc/testsuite/g++.dg/parse/pr16696-permissive.C
  f8326578679fecd658e1bec2d3ed7654  gcc/testsuite/g++.dg/parse/pr16696.C
  29f6ba15da1283765b5179abe6707d09  gcc/testsuite/g++.dg/parse/pr18770.C
*************** ad6c0b4132032f21f64bfdd4836d3313  gcc/te
*** 28308,28313 ****
--- 28310,28316 ----
  59f2687e6719ef7d3d19b4de0e99a075  gcc/testsuite/g++.dg/ubsan/pr105729.C
  06fb5e3c91f4d1b4f58ee978dd2b4b30  gcc/testsuite/g++.dg/ubsan/pr116449.C
  a9c7210a5fb28a26cd54ad5ce0872a53  gcc/testsuite/g++.dg/ubsan/pr117259.C
+ a4c08c025f777efea858788766890b26  gcc/testsuite/g++.dg/ubsan/pr120471.C
  a654df71119821a4303cc9fe0501191b  gcc/testsuite/g++.dg/ubsan/pr59250.C
  420a6623146bb014dc1310134356d81f  gcc/testsuite/g++.dg/ubsan/pr59306.C
  79755a51c3cbb97ff48bd411272f6b08  gcc/testsuite/g++.dg/ubsan/pr59331.C
*************** ece1d03dfdd44a22781b77ed9ec271d4  gcc/te
*** 28668,28673 ****
--- 28671,28677 ----
  c32e2d9c26f73ceab75448129f154a62  gcc/testsuite/g++.dg/warn/Wduplicated-branches5.C
  c1c94fbed68712c556c47675075fab08  gcc/testsuite/g++.dg/warn/Wduplicated-branches6.C
  df34a3119747a72018c056305c89abd6  gcc/testsuite/g++.dg/warn/Wduplicated-branches7.C
+ b78135999b9fbdc92326bfae8b355202  gcc/testsuite/g++.dg/warn/Wduplicated-branches9.C
  53e8ba692e810326b135e28115da516a  gcc/testsuite/g++.dg/warn/Wduplicated-cond1.C
  aee46bcb7031162dcee9c8ebe1228c6f  gcc/testsuite/g++.dg/warn/Wduplicated-cond2.C
  3fd71ef4467ff2d96bedfb8624c9f6c9  gcc/testsuite/g++.dg/warn/Wduplicated-cond3.C
*************** fd304d08c4ca43544588bd14358a9c0a  gcc/te
*** 95990,95995 ****
--- 95994,96000 ----
  6c87692ce5565e68f354b3b1cb842c39  gcc/testsuite/gnat.dg/sso18.adb
  ff784f7bca69d0717e740273960b0387  gcc/testsuite/gnat.dg/sso2.adb
  ccf43eb5df39869bb23ff9110d3b93cb  gcc/testsuite/gnat.dg/sso2.ads
+ 2ba1a49876e7f91ccde7f7d0288debb0  gcc/testsuite/gnat.dg/sso20.adb
  6fe64945c0d0238672cdece04341c316  gcc/testsuite/gnat.dg/sso3.adb
  cce4578d630a50acb2e3a4f2535af90b  gcc/testsuite/gnat.dg/sso4.adb
  6547028813699cf5a1bebf9380db3b22  gcc/testsuite/gnat.dg/sso5.adb
*************** ef15621f3fcf286ff9b897cc3ef0d498  gcc/tr
*** 100491,100497 ****
  658e45ca3c1c387fbd4e8bf835de1acd  gcc/tree-ssa-propagate.h
  58c0ef78644b94b752f3d6d91823c3f9  gcc/tree-ssa-reassoc.cc
  3d6728ab6aa97921854f86b5d2116c3d  gcc/tree-ssa-reassoc.h
! 043efbe0ee23033d49aed6bcec082b3b  gcc/tree-ssa-sccvn.cc
  1c663c39e61b7e64cbea685db2598475  gcc/tree-ssa-sccvn.h
  0dd72fccd9280ac160f5ac770517ee10  gcc/tree-ssa-scopedtables.cc
  bdda02f8f5872266cc26122c45c7d248  gcc/tree-ssa-scopedtables.h
--- 100496,100502 ----
  658e45ca3c1c387fbd4e8bf835de1acd  gcc/tree-ssa-propagate.h
  58c0ef78644b94b752f3d6d91823c3f9  gcc/tree-ssa-reassoc.cc
  3d6728ab6aa97921854f86b5d2116c3d  gcc/tree-ssa-reassoc.h
! f242dd217d813b8a7e504a36b4aa24d3  gcc/tree-ssa-sccvn.cc
  1c663c39e61b7e64cbea685db2598475  gcc/tree-ssa-sccvn.h
  0dd72fccd9280ac160f5ac770517ee10  gcc/tree-ssa-scopedtables.cc
  bdda02f8f5872266cc26122c45c7d248  gcc/tree-ssa-scopedtables.h
diff -Nrcpad gcc-13-20250626/gcc/ChangeLog gcc-13-20250703/gcc/ChangeLog
*** gcc-13-20250626/gcc/ChangeLog	Thu Jun 26 22:32:20 2025
--- gcc-13-20250703/gcc/ChangeLog	Thu Jul  3 22:32:06 2025
***************
*** 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 -Nrcpad gcc-13-20250626/gcc/DATESTAMP gcc-13-20250703/gcc/DATESTAMP
*** gcc-13-20250626/gcc/DATESTAMP	Thu Jun 26 22:32:20 2025
--- gcc-13-20250703/gcc/DATESTAMP	Thu Jul  3 22:32:06 2025
***************
*** 1 ****
! 20250626
--- 1 ----
! 20250703
diff -Nrcpad gcc-13-20250626/gcc/ada/gcc-interface/decl.cc gcc-13-20250703/gcc/ada/gcc-interface/decl.cc
*** gcc-13-20250626/gcc/ada/gcc-interface/decl.cc	Thu Jun 26 22:32:20 2025
--- gcc-13-20250703/gcc/ada/gcc-interface/decl.cc	Thu Jul  3 22:32:07 2025
*************** gnat_to_gnu_component_type (Entity_Id gn
*** 5277,5283 ****
    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;
    unsigned int max_align;
  
    /* If an alignment is specified, use it as a cap on the component type
--- 5277,5283 ----
    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_component;
    unsigned int max_align;
  
    /* If an alignment is specified, use it as a cap on the component type
*************** gnat_to_gnu_component_type (Entity_Id gn
*** 5298,5313 ****
        && !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;
      }
    else
!     has_packed_components = 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_Component_Size_Clause (gnat_array), NULL, NULL);
  
    /* If the component type is a RECORD_TYPE that has a self-referential size,
--- 5298,5319 ----
        && !TYPE_FAT_POINTER_P (gnu_type)
        && tree_fits_uhwi_p (TYPE_SIZE (gnu_type)))
      {
!       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_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_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,
diff -Nrcpad gcc-13-20250626/gcc/cp/typeck.cc gcc-13-20250703/gcc/cp/typeck.cc
*** gcc-13-20250626/gcc/cp/typeck.cc	Thu Jun 26 22:32:21 2025
--- gcc-13-20250703/gcc/cp/typeck.cc	Thu Jul  3 22:32:09 2025
*************** cp_build_array_ref (location_t loc, tree
*** 3961,3973 ****
        }
  
      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);
        protected_set_expr_location (ret, loc);
        return ret;
  
--- 3961,4089 ----
        }
  
      case COND_EXPR:
!       tree op0, op1, op2;
!       op0 = TREE_OPERAND (array, 0);
!       op1 = 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
! 	     (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 -Nrcpad gcc-13-20250626/gcc/gimple-fold.cc gcc-13-20250703/gcc/gimple-fold.cc
*** gcc-13-20250626/gcc/gimple-fold.cc	Thu Jun 26 22:32:21 2025
--- gcc-13-20250703/gcc/gimple-fold.cc	Thu Jul  3 22:32:09 2025
*************** fold_const_aggregate_ref_1 (tree t, tree
*** 8339,8357 ****
        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;
- 
        /* Out of bound array access.  Value is undefined, but don't fold.  */
        if (maybe_lt (offset, 0))
  	return NULL_TREE;
  
        tem = fold_ctor_reference (TREE_TYPE (t), ctor, offset, size, base);
        if (tem)
--- 8339,8359 ----
        base = get_ref_base_and_extent (t, &offset, &size, &max_size, &reverse);
        ctor = get_base_constructor (base, &offset, valueize);
  
+       /* 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)
*************** fold_const_aggregate_ref_1 (tree t, tree
*** 8371,8377 ****
  	      && offset.is_constant (&coffset)
  	      && (coffset % BITS_PER_UNIT != 0
  		  || csize % BITS_PER_UNIT != 0)
- 	      && !reverse
  	      && BYTES_BIG_ENDIAN == WORDS_BIG_ENDIAN)
  	    {
  	      poly_int64 bitoffset;
--- 8373,8378 ----
diff -Nrcpad gcc-13-20250626/gcc/testsuite/ChangeLog gcc-13-20250703/gcc/testsuite/ChangeLog
*** gcc-13-20250626/gcc/testsuite/ChangeLog	Thu Jun 26 22:32:22 2025
--- gcc-13-20250703/gcc/testsuite/ChangeLog	Thu Jul  3 22:32:11 2025
***************
*** 1,3 ****
--- 1,7 ----
+ 2025-06-27  Eric Botcazou  <ebotcazou@adacore.com>
+ 
+ 	* gnat.dg/sso20.adb: New test.
+ 
  2025-06-13  Georg-Johann Lay  <avr@gjlay.de>
  
  	Backported from master:
diff -Nrcpad gcc-13-20250626/gcc/testsuite/g++.dg/parse/pr120471.C gcc-13-20250703/gcc/testsuite/g++.dg/parse/pr120471.C
*** gcc-13-20250626/gcc/testsuite/g++.dg/parse/pr120471.C	Thu Jan  1 00:00:00 1970
--- gcc-13-20250703/gcc/testsuite/g++.dg/parse/pr120471.C	Thu Jul  3 22:32:12 2025
***************
*** 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 -Nrcpad gcc-13-20250626/gcc/testsuite/g++.dg/parse/pr120940.C gcc-13-20250703/gcc/testsuite/g++.dg/parse/pr120940.C
*** gcc-13-20250626/gcc/testsuite/g++.dg/parse/pr120940.C	Thu Jan  1 00:00:00 1970
--- gcc-13-20250703/gcc/testsuite/g++.dg/parse/pr120940.C	Thu Jul  3 22:32:12 2025
***************
*** 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 -Nrcpad gcc-13-20250626/gcc/testsuite/g++.dg/ubsan/pr120471.C gcc-13-20250703/gcc/testsuite/g++.dg/ubsan/pr120471.C
*** gcc-13-20250626/gcc/testsuite/g++.dg/ubsan/pr120471.C	Thu Jan  1 00:00:00 1970
--- gcc-13-20250703/gcc/testsuite/g++.dg/ubsan/pr120471.C	Thu Jul  3 22:32:12 2025
***************
*** 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);
+ }
diff -Nrcpad gcc-13-20250626/gcc/testsuite/g++.dg/warn/Wduplicated-branches9.C gcc-13-20250703/gcc/testsuite/g++.dg/warn/Wduplicated-branches9.C
*** gcc-13-20250626/gcc/testsuite/g++.dg/warn/Wduplicated-branches9.C	Thu Jan  1 00:00:00 1970
--- gcc-13-20250703/gcc/testsuite/g++.dg/warn/Wduplicated-branches9.C	Thu Jul  3 22:32:12 2025
***************
*** 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];
+ }
diff -Nrcpad gcc-13-20250626/gcc/testsuite/gnat.dg/sso20.adb gcc-13-20250703/gcc/testsuite/gnat.dg/sso20.adb
*** gcc-13-20250626/gcc/testsuite/gnat.dg/sso20.adb	Thu Jan  1 00:00:00 1970
--- gcc-13-20250703/gcc/testsuite/gnat.dg/sso20.adb	Thu Jul  3 22:32:51 2025
***************
*** 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 -Nrcpad gcc-13-20250626/gcc/tree-ssa-sccvn.cc gcc-13-20250703/gcc/tree-ssa-sccvn.cc
*** gcc-13-20250626/gcc/tree-ssa-sccvn.cc	Thu Jun 26 22:32:31 2025
--- gcc-13-20250703/gcc/tree-ssa-sccvn.cc	Thu Jul  3 22:32:54 2025
*************** fully_constant_vn_reference_p (vn_refere
*** 1576,1581 ****
--- 1576,1583 ----
  	      ++i;
  	      break;
  	    }
+ 	  if (operands[i].reverse)
+ 	    return NULL_TREE;
  	  if (known_eq (operands[i].off, -1))
  	    return NULL_TREE;
  	  off += operands[i].off;
