[gcc r15-2364] Add config file so b4 uses inbox.sourceware.org automatically

2024-07-28 Thread Jonathan Wakely via Gcc-cvs
https://gcc.gnu.org/g:dad2eb3ac2d11daea4528c445546f4d8e0c701cc

commit r15-2364-gdad2eb3ac2d11daea4528c445546f4d8e0c701cc
Author: Jonathan Wakely 
Date:   Thu May 23 16:42:55 2024 +0100

Add config file so b4 uses inbox.sourceware.org automatically

This makes b4 use inbox.sourceware.org instead of the default host
lore.kernel.org, so that every b4 user doesn't have to configure this
themselves.

ChangeLog:

* .b4-config: New file.

Diff:
---
 .b4-config | 4 
 1 file changed, 4 insertions(+)

diff --git a/.b4-config b/.b4-config
new file mode 100644
index ..eec2261deb6a
--- /dev/null
+++ b/.b4-config
@@ -0,0 +1,4 @@
+[b4]
+midmask = https://inbox.sourceware.org/%s
+linkmask = https://inbox.sourceware.org/%s
+send-series-to = gcc-patc...@gcc.gnu.org


[gcc/devel/fortran_unsigned] gcc: stop adding -fno-common for checking builds

2024-07-28 Thread Thomas Kテカnig via Gcc-cvs
https://gcc.gnu.org/g:e6431eaa7867b0a55aa3a118ed3f5408f1dd0cbf

commit e6431eaa7867b0a55aa3a118ed3f5408f1dd0cbf
Author: Sam James 
Date:   Sat Jul 20 01:21:59 2024 +0100

gcc: stop adding -fno-common for checking builds

Originally added in r0-44646-g204250d2fcd084 and r0-44627-gfd350d241fecf6 
whic
moved -fno-common from all builds to just checking builds.

Since r10-4867-g6271dd984d7f92, GCC defaults to -fno-common. There's no need
to pass it specially for checking builds.

We could keep it for older bootstrap compilers with checking but I don't see
much value in that, it was already just a bonus before.

gcc/ChangeLog:
* Makefile.in (NOCOMMON_FLAG): Delete.
(GCC_WARN_CFLAGS): Drop NOCOMMON_FLAG.
(GCC_WARN_CXXFLAGS): Drop NOCOMMON_FLAG.
* configure.ac: Ditto.
* configure: Regenerate.

gcc/d/ChangeLog:
* Make-lang.in (WARN_DFLAGS): Drop NOCOMMON_FLAG.

Diff:
---
 gcc/Makefile.in| 8 ++--
 gcc/configure  | 8 ++--
 gcc/configure.ac   | 3 ---
 gcc/d/Make-lang.in | 2 +-
 4 files changed, 5 insertions(+), 16 deletions(-)

diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index f4bb4a88cf31..4fc86ed7938b 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -185,10 +185,6 @@ C_LOOSE_WARN = @c_loose_warn@
 STRICT_WARN = @strict_warn@
 C_STRICT_WARN = @c_strict_warn@
 
-# This is set by --enable-checking.  The idea is to catch forgotten
-# "extern" tags in header files.
-NOCOMMON_FLAG = @nocommon_flag@
-
 NOEXCEPTION_FLAGS = @noexception_flags@
 
 ALIASING_FLAGS = @aliasing_flags@
@@ -215,8 +211,8 @@ VALGRIND_DRIVER_DEFINES = @valgrind_path_defines@
 .-warn = $(STRICT_WARN)
 build-warn = $(STRICT_WARN)
 rtl-ssa-warn = $(STRICT_WARN)
-GCC_WARN_CFLAGS = $(LOOSE_WARN) $(C_LOOSE_WARN) $($(@D)-warn) $(if 
$(filter-out $(STRICT_WARN),$($(@D)-warn)),,$(C_STRICT_WARN)) $(NOCOMMON_FLAG) 
$($@-warn)
-GCC_WARN_CXXFLAGS = $(LOOSE_WARN) $($(@D)-warn) $(NOCOMMON_FLAG) $($@-warn)
+GCC_WARN_CFLAGS = $(LOOSE_WARN) $(C_LOOSE_WARN) $($(@D)-warn) $(if 
$(filter-out $(STRICT_WARN),$($(@D)-warn)),,$(C_STRICT_WARN)) $($@-warn)
+GCC_WARN_CXXFLAGS = $(LOOSE_WARN) $($(@D)-warn) $($@-warn)
 
 # 1 2 3 ... 
 one_to__0:=1 2 3 4 5 6 7 8 9
diff --git a/gcc/configure b/gcc/configure
index 4faae0fa5fb8..01acca7fb5cc 100755
--- a/gcc/configure
+++ b/gcc/configure
@@ -862,7 +862,6 @@ valgrind_command
 valgrind_path_defines
 valgrind_path
 TREECHECKING
-nocommon_flag
 noexception_flags
 warn_cxxflags
 warn_cflags
@@ -7605,17 +7604,14 @@ do
 done
 IFS="$ac_save_IFS"
 
-nocommon_flag=""
 if test x$ac_checking != x ; then
 
 $as_echo "#define CHECKING_P 1" >>confdefs.h
 
-  nocommon_flag=-fno-common
 else
   $as_echo "#define CHECKING_P 0" >>confdefs.h
 
 fi
-
 if test x$ac_extra_checking != x ; then
 
 $as_echo "#define ENABLE_EXTRA_CHECKING 1" >>confdefs.h
@@ -21410,7 +21406,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 21413 "configure"
+#line 21409 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -21516,7 +21512,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 21519 "configure"
+#line 21515 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
diff --git a/gcc/configure.ac b/gcc/configure.ac
index 3da1eaa70646..3f20c107b6aa 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -697,16 +697,13 @@ do
 done
 IFS="$ac_save_IFS"
 
-nocommon_flag=""
 if test x$ac_checking != x ; then
   AC_DEFINE(CHECKING_P, 1,
 [Define to 0/1 if you want more run-time sanity checks.  This one gets a grab
 bag of miscellaneous but relatively cheap checks.])
-  nocommon_flag=-fno-common
 else
   AC_DEFINE(CHECKING_P, 0)
 fi
-AC_SUBST(nocommon_flag)
 if test x$ac_extra_checking != x ; then
   AC_DEFINE(ENABLE_EXTRA_CHECKING, 1,
 [Define to 0/1 if you want extra run-time checking that might affect code
diff --git a/gcc/d/Make-lang.in b/gcc/d/Make-lang.in
index eaea6e039cf7..077668faae64 100644
--- a/gcc/d/Make-lang.in
+++ b/gcc/d/Make-lang.in
@@ -55,7 +55,7 @@ CHECKING_DFLAGS = -frelease
 else
 CHECKING_DFLAGS =
 endif
-WARN_DFLAGS = -Wall -Wdeprecated $(NOCOMMON_FLAG)
+WARN_DFLAGS = -Wall -Wdeprecated
 
 # D front-end doesn't use exceptions, but it does require RTTI.
 NOEXCEPTION_DFLAGS = $(filter-out -fno-rtti, $(NOEXCEPTION_FLAGS))


[gcc/devel/fortran_unsigned] [PR rtl-optimization/115877] Fix livein computation for ext-dce

2024-07-28 Thread Thomas Kテカnig via Gcc-cvs
https://gcc.gnu.org/g:81e528bfffa44566ca6c93aae4acb407144fd241

commit 81e528bfffa44566ca6c93aae4acb407144fd241
Author: Jeff Law 
Date:   Sun Jul 21 07:36:37 2024 -0600

[PR rtl-optimization/115877] Fix livein computation for ext-dce

So I'm not yet sure how I'm going to break everything down, but this is easy
enough to break out as 1/N of ext-dce fixes/improvements.

When handling uses in an insn, we first determine what bits are set in the
destination which is represented in DST_MASK.  Then we use that to refine 
what
bits are live in the source operands.

In the source operand handling section we *modify* DST_MASK if the source
operand is a SUBREG (ugh!).  So if the first operand is a SUBREG, then we 
can
incorrectly compute which bit groups are live in the second operand, 
especially
if it is a SUBREG as well.

This was seen when testing a larger set of patches on the rl78 port
(builtin-arith-overflow-p-7 & pr71631 execution failures), so no new test 
for
this bugfix.

Run through my tester (in conjunction with other ext-dce changes) on the
various cross targets.  Run individually through a bootstrap and regression
test cycle on x86_64 as well.

Pushing to the trunk.

PR rtl-optimization/115877
gcc/
* ext-dce.cc (ext_dce_process_uses): Restore the value of DST_MASK
for reach operand.

Diff:
---
 gcc/ext-dce.cc | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/gcc/ext-dce.cc b/gcc/ext-dce.cc
index 6d4b8858ec63..b4450e42ed16 100644
--- a/gcc/ext-dce.cc
+++ b/gcc/ext-dce.cc
@@ -591,8 +591,10 @@ ext_dce_process_uses (rtx_insn *insn, rtx obj, bitmap 
live_tmp)
 making things live.  Breaking from this loop will cause
 the iterator to work on sub-rtxs, so it is safe to break
 if we see something we don't know how to handle.  */
+ unsigned HOST_WIDE_INT save_mask = dst_mask;
  for (;;)
{
+ dst_mask = save_mask;
  /* Strip an outer paradoxical subreg.  The bits outside
 the inner mode are don't cares.  So we can just strip
 and process the inner object.  */


[gcc/devel/fortran_unsigned] [PR rtl-optimization/115877][2/n] Improve liveness computation for constant initialization

2024-07-28 Thread Thomas Kテカnig via Gcc-cvs
https://gcc.gnu.org/g:3514d03e8ba53f76b672baf7935b0258ac9609b5

commit 3514d03e8ba53f76b672baf7935b0258ac9609b5
Author: Jeff Law 
Date:   Sun Jul 21 08:41:28 2024 -0600

[PR rtl-optimization/115877][2/n] Improve liveness computation for constant 
initialization

While debugging pr115877, I noticed we were failing to remove the 
destination
register from LIVENOW bitmap when it was set to a constant value.  ie  (set
(dest) (const_int)).  This was a trivial oversight in
safe_for_live_propagation.

I don't have an example of this affecting code generation, but it certainly
could.  More importantly, by making LIVENOW more accurate it's easier to 
debug
when LIVENOW differs from expectations.

As with the prior patch this has been tested as part of a larger patchset 
with
the crosses as well as individually on x86_64.

Pushing to the trunk,

PR rtl-optimization/115877
gcc/
* ext-dce.cc (safe_for_live_propagation): Handle RTX_CONST_OBJ.

Diff:
---
 gcc/ext-dce.cc | 1 +
 1 file changed, 1 insertion(+)

diff --git a/gcc/ext-dce.cc b/gcc/ext-dce.cc
index b4450e42ed16..cbecfc53dba7 100644
--- a/gcc/ext-dce.cc
+++ b/gcc/ext-dce.cc
@@ -69,6 +69,7 @@ safe_for_live_propagation (rtx_code code)
   switch (GET_RTX_CLASS (code))
 {
   case RTX_OBJ:
+  case RTX_CONST_OBJ:
return true;
 
   case RTX_COMPARE:


[gcc/devel/fortran_unsigned] Daily bump.

2024-07-28 Thread Thomas Kテカnig via Gcc-cvs
https://gcc.gnu.org/g:89dc810dc5bcb0a86ac0d091f6a47fdc4b36010d

commit 89dc810dc5bcb0a86ac0d091f6a47fdc4b36010d
Author: GCC Administrator 
Date:   Mon Jul 22 00:16:38 2024 +

Daily bump.

Diff:
---
 gcc/ChangeLog   | 25 +
 gcc/DATESTAMP   |  2 +-
 gcc/d/ChangeLog |  4 
 gcc/fortran/ChangeLog   | 10 ++
 gcc/testsuite/ChangeLog |  5 +
 5 files changed, 45 insertions(+), 1 deletion(-)

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index b626dbdc0980..61fc57be9492 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,28 @@
+2024-07-21  Jeff Law  
+
+   PR rtl-optimization/115877
+   * ext-dce.cc (safe_for_live_propagation): Handle RTX_CONST_OBJ.
+
+2024-07-21  Jeff Law  
+
+   PR rtl-optimization/115877
+   * ext-dce.cc (ext_dce_process_uses): Restore the value of DST_MASK
+   for reach operand.
+
+2024-07-21  Sam James  
+
+   * Makefile.in (NOCOMMON_FLAG): Delete.
+   (GCC_WARN_CFLAGS): Drop NOCOMMON_FLAG.
+   (GCC_WARN_CXXFLAGS): Drop NOCOMMON_FLAG.
+   * configure.ac: Ditto.
+   * configure: Regenerate.
+
+2024-07-21  Oleg Endo  
+
+   * config/sh/sh.md (mov_neg_si_t): Allow insn and split after
+   register allocation.
+   (*treg_noop_move): New insn.
+
 2024-07-20  Andi Kleen  
 
Revert:
diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index d1ac33f77fb9..01bbf6ed5e1f 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20240721
+20240722
diff --git a/gcc/d/ChangeLog b/gcc/d/ChangeLog
index 5688ce07f8bc..e1bfdde4a0c6 100644
--- a/gcc/d/ChangeLog
+++ b/gcc/d/ChangeLog
@@ -1,3 +1,7 @@
+2024-07-21  Sam James  
+
+   * Make-lang.in (WARN_DFLAGS): Drop NOCOMMON_FLAG.
+
 2024-06-05  Kewen Lin  
Iain Buclaw  
 
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index d730b07bd678..0940f731cd6a 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,3 +1,13 @@
+2024-07-21  Paul Thomas  
+
+   PR fortran/59104
+   * gfortran.h : Add decl_order to gfc_symbol.
+   * symbol.cc : Add static next_decl_order..
+   (gfc_set_sym_referenced): Set symbol decl_order.
+   * trans-decl.cc : Include dependency.h.
+   (decl_order): Replace symbol declared_at.lb->location with
+   decl_order.
+
 2024-07-19  Harald Anlauf  
 
PR fortran/103115
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 078945ff981d..ee66c12a6fa3 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2024-07-21  Paul Thomas  
+
+   PR fortran/59104
+   * gfortran.dg/dependent_decls_3.f90: New test.
+
 2024-07-20  Andrew MacLeod  
 
* gcc.dg/pr116003.c: Require bitint575 target.


[gcc/devel/fortran_unsigned] Fortran: Fix regression caused by r14-10477 [PR59104]

2024-07-28 Thread Thomas Kテカnig via Gcc-cvs
https://gcc.gnu.org/g:a1b441efc42938b7b2b14e9f23b1ec351d2da098

commit a1b441efc42938b7b2b14e9f23b1ec351d2da098
Author: Paul Thomas 
Date:   Sun Jul 21 17:48:47 2024 +0100

Fortran: Fix regression caused by r14-10477 [PR59104]

2024-07-21  Paul Thomas  

gcc/fortran
PR fortran/59104
* gfortran.h : Add decl_order to gfc_symbol.
* symbol.cc : Add static next_decl_order..
(gfc_set_sym_referenced): Set symbol decl_order.
* trans-decl.cc : Include dependency.h.
(decl_order): Replace symbol declared_at.lb->location with
decl_order.

gcc/testsuite/
PR fortran/59104
* gfortran.dg/dependent_decls_3.f90: New test.

Diff:
---
 gcc/fortran/gfortran.h  |  3 +++
 gcc/fortran/symbol.cc   |  6 ++
 gcc/fortran/trans-decl.cc   |  2 +-
 gcc/testsuite/gfortran.dg/dependent_decls_3.f90 | 26 +
 4 files changed, 36 insertions(+), 1 deletion(-)

diff --git a/gcc/fortran/gfortran.h b/gcc/fortran/gfortran.h
index 3e20821cceae..f922bf3bb991 100644
--- a/gcc/fortran/gfortran.h
+++ b/gcc/fortran/gfortran.h
@@ -1893,6 +1893,9 @@ typedef struct gfc_symbol
  points to C and B's is NULL.  */
   struct gfc_common_head* common_head;
 
+  /* Make sure initialization code is generated in the correct order.  */
+  int decl_order;
+
   gfc_namelist *namelist, *namelist_tail;
 
   /* The tlink field is used in the front end to carry the module
diff --git a/gcc/fortran/symbol.cc b/gcc/fortran/symbol.cc
index 2f326492d5fb..a8479b862e39 100644
--- a/gcc/fortran/symbol.cc
+++ b/gcc/fortran/symbol.cc
@@ -96,6 +96,9 @@ const mstring dtio_procs[] =
 minit ("_dtio_unformatted_write", DTIO_WUF),
 };
 
+/* This is to make sure the backend generates setup code in the correct
+   order.  */
+static int next_decl_order = 1;
 
 gfc_namespace *gfc_current_ns;
 gfc_namespace *gfc_global_ns_list;
@@ -940,6 +943,9 @@ gfc_set_sym_referenced (gfc_symbol *sym)
 return;
 
   sym->attr.referenced = 1;
+
+  /* Remember the declaration order.  */
+  sym->decl_order = next_decl_order++;
 }
 
 
diff --git a/gcc/fortran/trans-decl.cc b/gcc/fortran/trans-decl.cc
index 436a4051c057..7593decc6f04 100644
--- a/gcc/fortran/trans-decl.cc
+++ b/gcc/fortran/trans-decl.cc
@@ -842,7 +842,7 @@ gfc_allocate_lang_decl (tree decl)
 static bool
 decl_order (gfc_symbol *sym1, gfc_symbol *sym2)
 {
-  if (sym1->declared_at.lb->location > sym2->declared_at.lb->location)
+  if (sym1->decl_order > sym2->decl_order)
 return true;
   else
 return false;
diff --git a/gcc/testsuite/gfortran.dg/dependent_decls_3.f90 
b/gcc/testsuite/gfortran.dg/dependent_decls_3.f90
new file mode 100644
index ..93862b8ccdca
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/dependent_decls_3.f90
@@ -0,0 +1,26 @@
+! { dg-do run }
+!
+! Fix a regression caused by the fix for PR59104.
+!
+! Contributed by Harald Anlauf  
+!
+program p
+  implicit none
+  integer, parameter :: nx = 64, ny = 32
+  real   :: x(nx,ny), s(nx/2,ny), d(nx/2,ny)
+
+  s = 0.0
+  d = 0.0
+  call sub (x,s,d)
+  if (sum(s) .ne. 256) stop 1
+  if (sum(d) .ne. 256) stop 2  ! Stopped with sum(d) == 0.
+contains
+  subroutine sub  (v, w, d)
+real, intent(in)  :: v(:,:)
+real, intent(out), dimension (size (v,dim=1)/4,size (v,dim=2)/2) :: w, d
+w = 1.0
+d = 1.0
+if (any (shape (w) .ne. [nx/4, ny/2])) stop 3
+if (any (shape (d) .ne. [nx/4, ny/2])) print *, shape (d)  ! Printed "0 0" 
here
+  end subroutine sub
+end


[gcc/devel/fortran_unsigned] RISC-V: Rearrange the test helper files for vector .SAT_*

2024-07-28 Thread Thomas Kテカnig via Gcc-cvs
https://gcc.gnu.org/g:8c5b1ea8d17207cdcd27bc2fbf7e0b5193d415bc

commit 8c5b1ea8d17207cdcd27bc2fbf7e0b5193d415bc
Author: Pan Li 
Date:   Sat Jul 20 10:43:44 2024 +0800

RISC-V: Rearrange the test helper files for vector .SAT_*

Rearrange the test help header files,  as well as align the name
conventions.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/binop/vec_sat_binary.h: Move to...
* gcc.target/riscv/rvv/autovec/binop/vec_sat_binary_vvv_run.h: 
...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_binary_scalar.h: Move 
to...
* gcc.target/riscv/rvv/autovec/binop/vec_sat_binary_vvx_run.h: 
...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_binary_vx.h: Move to...
* gcc.target/riscv/rvv/autovec/binop/vec_sat_binary_vx_run.h: 
...here.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-1.c: Adjust
the include file names.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-10.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-11.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-12.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-13.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-14.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-15.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-16.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-17.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-18.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-19.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-2.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-20.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-21.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-22.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-23.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-24.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-25.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-26.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-27.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-28.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-29.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-3.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-30.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-31.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-32.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-4.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-5.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-6.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-7.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-8.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-9.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-1.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-10.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-11.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-12.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-13.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-14.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-15.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-16.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-17.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-18.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-19.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-2.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-20.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-21.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-22.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-23.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-24.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-25.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-26.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-27.c: Ditto.
* gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add-run-28.c: Ditto.
   

[gcc/devel/fortran_unsigned] testsuite: powerpc: fix dg-do run typo

2024-07-28 Thread Thomas Kテカnig via Gcc-cvs
https://gcc.gnu.org/g:4eb0e778e3b3a4096df3deaca625709cb209c7b4

commit 4eb0e778e3b3a4096df3deaca625709cb209c7b4
Author: Sam James 
Date:   Sun Jul 21 20:36:08 2024 -0500

testsuite: powerpc: fix dg-do run typo

'dg-run' is not a valid dejagnu directive, 'dg-do run' is needed here
for the test to be executed.

PR target/108699

gcc/testsuite/ChangeLog:

* gcc.target/powerpc/pr108699.c: Fix 'dg-run' typo.

Signed-off-by: Sam James 

Diff:
---
 gcc/testsuite/gcc.target/powerpc/pr108699.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/testsuite/gcc.target/powerpc/pr108699.c 
b/gcc/testsuite/gcc.target/powerpc/pr108699.c
index f02bac130cc7..beb8b601fd51 100644
--- a/gcc/testsuite/gcc.target/powerpc/pr108699.c
+++ b/gcc/testsuite/gcc.target/powerpc/pr108699.c
@@ -1,4 +1,4 @@
-/* { dg-run } */
+/* { dg-do run } */
 /* { dg-options "-O2 -ftree-vectorize -fno-vect-cost-model" } */
 
 #define N 16


[gcc/devel/fortran_unsigned] middle-end: Implement conditonal store vectorizer pattern [PR115531]

2024-07-28 Thread Thomas Kテカnig via Gcc-cvs
https://gcc.gnu.org/g:f60e18d0c8a64f26dd87cbf3c91975f19953379d

commit f60e18d0c8a64f26dd87cbf3c91975f19953379d
Author: Tamar Christina 
Date:   Mon Jul 22 10:26:14 2024 +0100

middle-end: Implement conditonal store vectorizer pattern [PR115531]

This adds a conditional store optimization for the vectorizer as a pattern.
The vectorizer already supports modifying memory accesses because of the 
pattern
based gather/scatter recognition.

Doing it in the vectorizer allows us to still keep the ability to vectorize 
such
loops for architectures that don't have MASK_STORE support, whereas doing 
this
in ifcvt makes us commit to MASK_STORE.

Concretely for this loop:

void foo1 (char *restrict a, int *restrict b, int *restrict c, int n, int 
stride)
{
  if (stride <= 1)
return;

  for (int i = 0; i < n; i++)
{
  int res = c[i];
  int t = b[i+stride];
  if (a[i] != 0)
res = t;
  c[i] = res;
}
}

today we generate:

.L3:
ld1bz29.s, p7/z, [x0, x5]
ld1wz31.s, p7/z, [x2, x5, lsl 2]
ld1wz30.s, p7/z, [x1, x5, lsl 2]
cmpne   p15.b, p6/z, z29.b, #0
sel z30.s, p15, z30.s, z31.s
st1wz30.s, p7, [x2, x5, lsl 2]
add x5, x5, x4
whilelo p7.s, w5, w3
b.any   .L3

which in gimple is:

  vect_res_18.9_68 = .MASK_LOAD (vectp_c.7_65, 32B, loop_mask_67);
  vect_t_20.12_74 = .MASK_LOAD (vectp.10_72, 32B, loop_mask_67);
  vect__9.15_77 = .MASK_LOAD (vectp_a.13_75, 8B, loop_mask_67);
  mask__34.16_79 = vect__9.15_77 != { 0, ... };
  vect_res_11.17_80 = VEC_COND_EXPR ;
  .MASK_STORE (vectp_c.18_81, 32B, loop_mask_67, vect_res_11.17_80);

A MASK_STORE is already conditional, so there's no need to perform the load 
of
the old values and the VEC_COND_EXPR.  This patch makes it so we generate:

  vect_res_18.9_68 = .MASK_LOAD (vectp_c.7_65, 32B, loop_mask_67);
  vect__9.15_77 = .MASK_LOAD (vectp_a.13_75, 8B, loop_mask_67);
  mask__34.16_79 = vect__9.15_77 != { 0, ... };
  .MASK_STORE (vectp_c.18_81, 32B, mask__34.16_79, vect_res_18.9_68);

which generates:

.L3:
ld1bz30.s, p7/z, [x0, x5]
ld1wz31.s, p7/z, [x1, x5, lsl 2]
cmpne   p7.b, p7/z, z30.b, #0
st1wz31.s, p7, [x2, x5, lsl 2]
add x5, x5, x4
whilelo p7.s, w5, w3
b.any   .L3

gcc/ChangeLog:

PR tree-optimization/115531
* tree-vect-patterns.cc (vect_cond_store_pattern_same_ref): New.
(vect_recog_cond_store_pattern): New.
(vect_vect_recog_func_ptrs): Use it.
* target.def (conditional_operation_is_expensive): New.
* doc/tm.texi: Regenerate.
* doc/tm.texi.in: Document it.
* targhooks.cc (default_conditional_operation_is_expensive): New.
* targhooks.h (default_conditional_operation_is_expensive): New.

Diff:
---
 gcc/doc/tm.texi   |   7 ++
 gcc/doc/tm.texi.in|   2 +
 gcc/target.def|  12 
 gcc/targhooks.cc  |   8 +++
 gcc/targhooks.h   |   1 +
 gcc/tree-vect-patterns.cc | 159 ++
 6 files changed, 189 insertions(+)

diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi
index f10d9a59c667..c7535d07f4dd 100644
--- a/gcc/doc/tm.texi
+++ b/gcc/doc/tm.texi
@@ -6449,6 +6449,13 @@ The default implementation returns a 
@code{MODE_VECTOR_INT} with the
 same size and number of elements as @var{mode}, if such a mode exists.
 @end deftypefn
 
+@deftypefn {Target Hook} bool 
TARGET_VECTORIZE_CONDITIONAL_OPERATION_IS_EXPENSIVE (unsigned @var{ifn})
+This hook returns true if masked operation @var{ifn} (really of
+type @code{internal_fn}) should be considered more expensive to use than
+implementing the same operation without masking.  GCC can then try to use
+unconditional operations instead with extra selects.
+@end deftypefn
+
 @deftypefn {Target Hook} bool TARGET_VECTORIZE_EMPTY_MASK_IS_EXPENSIVE 
(unsigned @var{ifn})
 This hook returns true if masked internal function @var{ifn} (really of
 type @code{internal_fn}) should be considered expensive when the mask is
diff --git a/gcc/doc/tm.texi.in b/gcc/doc/tm.texi.in
index 24596eb2f6b4..64cea3b1edaf 100644
--- a/gcc/doc/tm.texi.in
+++ b/gcc/doc/tm.texi.in
@@ -4290,6 +4290,8 @@ address;  but often a machine-dependent strategy can 
generate better code.
 
 @hook TARGET_VECTORIZE_GET_MASK_MODE
 
+@hook TARGET_VECTORIZE_CONDITIONAL_OPERATION_IS_EXPENSIVE
+
 @hook TARGET_VECTORIZE_EMPTY_MASK_IS_EXPENSIVE
 
 @hook TARGET_VECTORIZE_CREATE_COSTS
diff --git a/gcc/target.def b/gcc/target.def
index ce4d1ecd58be..3de1aad4c84d 100644
--- a/gcc/target.def
+++ b/gcc/target.def
@@ -2033,6 +2033,18 @@ same size and

[gcc/devel/fortran_unsigned] AArch64: implement TARGET_VECTORIZE_CONDITIONAL_OPERATION_IS_EXPENSIVE [PR115531].

2024-07-28 Thread Thomas Kテカnig via Gcc-cvs
https://gcc.gnu.org/g:6a5ba2f4bc9d176efe46603369bb8c8ed4132ca4

commit 6a5ba2f4bc9d176efe46603369bb8c8ed4132ca4
Author: Tamar Christina 
Date:   Mon Jul 22 10:28:19 2024 +0100

AArch64: implement TARGET_VECTORIZE_CONDITIONAL_OPERATION_IS_EXPENSIVE  
[PR115531].

This implements the new target hook indicating that for AArch64 when 
possible
we prefer masked operations for any type vs doing LOAD + SELECT or
SELECT + STORE.

Thanks,
Tamar

gcc/ChangeLog:

PR tree-optimization/115531
* config/aarch64/aarch64.cc
(aarch64_conditional_operation_is_expensive): New.
(TARGET_VECTORIZE_CONDITIONAL_OPERATION_IS_EXPENSIVE): New.

gcc/testsuite/ChangeLog:

PR tree-optimization/115531
* gcc.dg/vect/vect-conditional_store_1.c: New test.
* gcc.dg/vect/vect-conditional_store_2.c: New test.
* gcc.dg/vect/vect-conditional_store_3.c: New test.
* gcc.dg/vect/vect-conditional_store_4.c: New test.

Diff:
---
 gcc/config/aarch64/aarch64.cc  | 12 ++
 .../gcc.dg/vect/vect-conditional_store_1.c | 24 +++
 .../gcc.dg/vect/vect-conditional_store_2.c | 24 +++
 .../gcc.dg/vect/vect-conditional_store_3.c | 24 +++
 .../gcc.dg/vect/vect-conditional_store_4.c | 28 ++
 5 files changed, 112 insertions(+)

diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc
index 0d41a193ec18..89eb66348f77 100644
--- a/gcc/config/aarch64/aarch64.cc
+++ b/gcc/config/aarch64/aarch64.cc
@@ -28211,6 +28211,15 @@ aarch64_gen_adjusted_ldpstp (rtx *operands, bool load,
   return true;
 }
 
+/* Implement TARGET_VECTORIZE_CONDITIONAL_OPERATION_IS_EXPENSIVE.  Assume that
+   predicated operations when available are beneficial.  */
+
+static bool
+aarch64_conditional_operation_is_expensive (unsigned)
+{
+  return false;
+}
+
 /* Implement TARGET_VECTORIZE_EMPTY_MASK_IS_EXPENSIVE.  Assume for now that
it isn't worth branching around empty masked ops (including masked
stores).  */
@@ -30898,6 +30907,9 @@ aarch64_libgcc_floating_mode_supported_p
 #define TARGET_VECTORIZE_RELATED_MODE aarch64_vectorize_related_mode
 #undef TARGET_VECTORIZE_GET_MASK_MODE
 #define TARGET_VECTORIZE_GET_MASK_MODE aarch64_get_mask_mode
+#undef TARGET_VECTORIZE_CONDITIONAL_OPERATION_IS_EXPENSIVE
+#define TARGET_VECTORIZE_CONDITIONAL_OPERATION_IS_EXPENSIVE \
+  aarch64_conditional_operation_is_expensive
 #undef TARGET_VECTORIZE_EMPTY_MASK_IS_EXPENSIVE
 #define TARGET_VECTORIZE_EMPTY_MASK_IS_EXPENSIVE \
   aarch64_empty_mask_is_expensive
diff --git a/gcc/testsuite/gcc.dg/vect/vect-conditional_store_1.c 
b/gcc/testsuite/gcc.dg/vect/vect-conditional_store_1.c
new file mode 100644
index ..03128b1f19b2
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/vect-conditional_store_1.c
@@ -0,0 +1,24 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target vect_int } */
+/* { dg-require-effective-target vect_masked_store } */
+
+/* { dg-additional-options "-mavx2" { target avx2 } } */
+/* { dg-additional-options "-march=armv9-a" { target aarch64-*-* } } */
+
+void foo1 (char *restrict a, int *restrict b, int *restrict c, int n, int 
stride)
+{
+  if (stride <= 1)
+return;
+
+  for (int i = 0; i < n; i++)
+{
+  int res = c[i];
+  int t = b[i+stride];
+  if (a[i] != 0)
+res = t;
+  c[i] = res;
+}
+}
+
+/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" } } */
+/* { dg-final { scan-tree-dump-not "VEC_COND_EXPR " "vect" { target 
aarch64-*-* } } } */
diff --git a/gcc/testsuite/gcc.dg/vect/vect-conditional_store_2.c 
b/gcc/testsuite/gcc.dg/vect/vect-conditional_store_2.c
new file mode 100644
index ..a03898793c0b
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/vect-conditional_store_2.c
@@ -0,0 +1,24 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target vect_int } */
+/* { dg-require-effective-target vect_masked_store } */
+
+/* { dg-additional-options "-mavx2" { target avx2 } } */
+/* { dg-additional-options "-march=armv9-a" { target aarch64-*-* } } */
+
+void foo2 (char *restrict a, int *restrict b, int *restrict c, int n, int 
stride)
+{
+  if (stride <= 1)
+return;
+
+  for (int i = 0; i < n; i++)
+{
+  int res = c[i];
+  int t = b[i+stride];
+  if (a[i] != 0)
+t = res;
+  c[i] = t;
+}
+}
+
+/* { dg-final { scan-tree-dump "LOOP VECTORIZED" "vect" } } */
+/* { dg-final { scan-tree-dump-not "VEC_COND_EXPR " "vect" { target 
aarch64-*-* } } } */
diff --git a/gcc/testsuite/gcc.dg/vect/vect-conditional_store_3.c 
b/gcc/testsuite/gcc.dg/vect/vect-conditional_store_3.c
new file mode 100644
index ..8a898755c1ca
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/vect-conditional_store_3.c
@@ -0,0 +1,24 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target vect_int } */
+/* { dg-require-e

[gcc/devel/fortran_unsigned] Fix Rejects allocatable coarray passed as a dummy argument [88624]

2024-07-28 Thread Thomas Kテカnig via Gcc-cvs
https://gcc.gnu.org/g:067ada0bfa02f39bc26324f59fe3158c6c6c8969

commit 067ada0bfa02f39bc26324f59fe3158c6c6c8969
Author: Andre Vehreschild 
Date:   Thu Jul 11 10:07:12 2024 +0200

Fix Rejects allocatable coarray passed as a dummy argument [88624]

Coarray parameters of procedures/functions need to be dereffed, because
they are references to the descriptor but the routine expected the
descriptor directly.

PR fortran/88624

gcc/fortran/ChangeLog:

* trans-expr.cc (gfc_conv_procedure_call): Treat
pointers/references (e.g. from parameters) correctly by derefing
them.

gcc/testsuite/ChangeLog:

* gfortran.dg/coarray/dummy_1.f90: Add calling function trough
function.
* gfortran.dg/pr88624.f90: New test.

Diff:
---
 gcc/fortran/trans-expr.cc | 35 +++
 gcc/testsuite/gfortran.dg/coarray/dummy_1.f90 |  2 ++
 gcc/testsuite/gfortran.dg/pr88624.f90 | 21 
 3 files changed, 48 insertions(+), 10 deletions(-)

diff --git a/gcc/fortran/trans-expr.cc b/gcc/fortran/trans-expr.cc
index d431ed5bdea7..9b61b66d6f46 100644
--- a/gcc/fortran/trans-expr.cc
+++ b/gcc/fortran/trans-expr.cc
@@ -,16 +,26 @@ gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym,
   && CLASS_DATA (fsym)->attr.codimension
   && !CLASS_DATA (fsym)->attr.allocatable)))
{
- tree caf_decl, caf_type;
+ tree caf_decl, caf_type, caf_desc = NULL_TREE;
  tree offset, tmp2;
 
  caf_decl = gfc_get_tree_for_caf_expr (e);
  caf_type = TREE_TYPE (caf_decl);
-
- if (GFC_DESCRIPTOR_TYPE_P (caf_type)
- && (GFC_TYPE_ARRAY_AKIND (caf_type) == GFC_ARRAY_ALLOCATABLE
- || GFC_TYPE_ARRAY_AKIND (caf_type) == GFC_ARRAY_POINTER))
-   tmp = gfc_conv_descriptor_token (caf_decl);
+ if (POINTER_TYPE_P (caf_type)
+ && GFC_DESCRIPTOR_TYPE_P (TREE_TYPE (caf_type)))
+   caf_desc = TREE_TYPE (caf_type);
+ else if (GFC_DESCRIPTOR_TYPE_P (caf_type))
+   caf_desc = caf_type;
+
+ if (caf_desc
+ && (GFC_TYPE_ARRAY_AKIND (caf_desc) == GFC_ARRAY_ALLOCATABLE
+ || GFC_TYPE_ARRAY_AKIND (caf_desc) == GFC_ARRAY_POINTER))
+   {
+ tmp = POINTER_TYPE_P (TREE_TYPE (caf_decl))
+ ? build_fold_indirect_ref (caf_decl)
+ : caf_decl;
+ tmp = gfc_conv_descriptor_token (tmp);
+   }
  else if (DECL_LANG_SPECIFIC (caf_decl)
   && GFC_DECL_TOKEN (caf_decl) != NULL_TREE)
tmp = GFC_DECL_TOKEN (caf_decl);
@@ -7799,8 +7809,8 @@ gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym,
 
  vec_safe_push (stringargs, tmp);
 
- if (GFC_DESCRIPTOR_TYPE_P (caf_type)
- && GFC_TYPE_ARRAY_AKIND (caf_type) == GFC_ARRAY_ALLOCATABLE)
+ if (caf_desc
+ && GFC_TYPE_ARRAY_AKIND (caf_desc) == GFC_ARRAY_ALLOCATABLE)
offset = build_int_cst (gfc_array_index_type, 0);
  else if (DECL_LANG_SPECIFIC (caf_decl)
   && GFC_DECL_CAF_OFFSET (caf_decl) != NULL_TREE)
@@ -7810,8 +7820,13 @@ gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym,
  else
offset = build_int_cst (gfc_array_index_type, 0);
 
- if (GFC_DESCRIPTOR_TYPE_P (caf_type))
-   tmp = gfc_conv_descriptor_data_get (caf_decl);
+ if (caf_desc)
+   {
+ tmp = POINTER_TYPE_P (TREE_TYPE (caf_decl))
+ ? build_fold_indirect_ref (caf_decl)
+ : caf_decl;
+ tmp = gfc_conv_descriptor_data_get (tmp);
+   }
  else
{
  gcc_assert (POINTER_TYPE_P (caf_type));
diff --git a/gcc/testsuite/gfortran.dg/coarray/dummy_1.f90 
b/gcc/testsuite/gfortran.dg/coarray/dummy_1.f90
index 33e95853ad4a..c437b2a10fc4 100644
--- a/gcc/testsuite/gfortran.dg/coarray/dummy_1.f90
+++ b/gcc/testsuite/gfortran.dg/coarray/dummy_1.f90
@@ -66,5 +66,7 @@
 if (lcobound(A, dim=1) /= 2) STOP 13
 if (ucobound(A, dim=1) /= 3) STOP 14
 if (lcobound(A, dim=2) /= 5) STOP 15
+
+call sub4(A)  ! Check PR88624 is fixed.
   end subroutine sub5
   end
diff --git a/gcc/testsuite/gfortran.dg/pr88624.f90 
b/gcc/testsuite/gfortran.dg/pr88624.f90
new file mode 100644
index ..e88ac907c6fc
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr88624.f90
@@ -0,0 +1,21 @@
+!{ dg-do compile }
+!{ dg-options "-fcoarray=lib" }
+
+! Check that PR fortran/88624 is fixed.
+! Contributed by Modrzejewski  
+! Reduced to the essence of the issue.
+
+program test 
+  implicit none 
+  integer, dimension(:), allocatable :: x[:] 
+  call g(x) 
+contains 
+  subroutine g(x) 
+integer, dimension(:), allocatable :: x[:] 
+call g2(x) 
+  end su

[gcc/devel/fortran_unsigned] Fix hash of WIDEN_*_EXPR

2024-07-28 Thread Thomas Kテカnig via Gcc-cvs
https://gcc.gnu.org/g:8ea8acf54495c11348e104ecc5a5353e33359aa6

commit 8ea8acf54495c11348e104ecc5a5353e33359aa6
Author: Richard Biener 
Date:   Mon Jul 22 11:07:28 2024 +0200

Fix hash of WIDEN_*_EXPR

We're hashing operand 2 to the temporary hash.

* fold-const.cc (operand_compare::hash_operand): Fix hash
of WIDEN_*_EXPR.

Diff:
---
 gcc/fold-const.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/fold-const.cc b/gcc/fold-const.cc
index 83c32dd10d4a..8908e7381e72 100644
--- a/gcc/fold-const.cc
+++ b/gcc/fold-const.cc
@@ -4123,7 +4123,7 @@ operand_compare::hash_operand (const_tree t, 
inchash::hash &hstate,
hash_operand (TREE_OPERAND (t, 0), one, flags);
hash_operand (TREE_OPERAND (t, 1), two, flags);
hstate.add_commutative (one, two);
-   hash_operand (TREE_OPERAND (t, 2), two, flags);
+   hash_operand (TREE_OPERAND (t, 2), hstate, flags);
return;
  }


[gcc/devel/fortran_unsigned] [NFC][PR rtl-optimization/115877] Avoid setting irrelevant bit groups as live in ext-dce

2024-07-28 Thread Thomas Kテカnig via Gcc-cvs
https://gcc.gnu.org/g:5a3562e3873d5b6ce6fce30ae84e6f80b047ed1b

commit 5a3562e3873d5b6ce6fce30ae84e6f80b047ed1b
Author: Jeff Law 
Date:   Mon Jul 22 08:45:10 2024 -0600

[NFC][PR rtl-optimization/115877] Avoid setting irrelevant bit groups as 
live in ext-dce

Another patch to refine liveness computations.  This should be NFC and is
designed to help debugging.

In simplest terms the patch avoids setting bit groups outside the size of a
pseudo as live.  Consider a HImode pseudo, bits 16..63 for such a pseudo 
don't
really have meaning, yet we often set bit groups related to bits 16.63 on in
the liveness bitmaps.

This makes debugging harder than it needs to be by simply having larger 
bitmaps
to verify when walking through the code in a debugger.

This has been bootstrapped and regression tested on x86_64.  It's also been
tested on the crosses in my tester without regressions.

Pushing to the trunk,

PR rtl-optimization/115877
gcc/
* ext-dce.cc (group_limit): New function.
(mark_reg_live): Likewise.
(ext_dce_process_sets): Use new functions.
(ext_dce_process_uses): Likewise.
(ext_dce_init): Likewise.

Diff:
---
 gcc/ext-dce.cc | 64 +++---
 1 file changed, 57 insertions(+), 7 deletions(-)

diff --git a/gcc/ext-dce.cc b/gcc/ext-dce.cc
index cbecfc53dba7..44f64e2d18cf 100644
--- a/gcc/ext-dce.cc
+++ b/gcc/ext-dce.cc
@@ -48,6 +48,57 @@ static bool modify;
bit 16..31
bit 32..BITS_PER_WORD-1  */
 
+/* For the given REG, return the number of bit groups implied by the
+   size of the REG's mode, up to a maximum of 4 (number of bit groups
+   tracked by this pass).
+
+   For partial integer and variable sized modes also return 4.  This
+   could possibly be refined for something like PSI mode, but it
+   does not seem worth the effort.  */
+
+static int
+group_limit (const_rtx reg)
+{
+  machine_mode mode = GET_MODE (reg);
+
+  if (!GET_MODE_BITSIZE (mode).is_constant ())
+return 4;
+
+  int size = GET_MODE_SIZE (mode).to_constant ();
+
+  size = exact_log2 (size);
+
+  if (size < 0)
+return 4;
+
+  size++;
+  return (size > 4 ? 4 : size);
+}
+
+/* Make all bit groups live for REGNO in bitmap BMAP.  For hard regs,
+   we assume all groups are live.  For a pseudo we consider the size
+   of the pseudo to avoid creating unnecessarily live chunks of data.  */
+
+static void
+make_reg_live (bitmap bmap, int regno)
+{
+  int limit;
+
+  /* For pseudos we can use the mode to limit how many bit groups
+ are marked as live since a pseudo only has one mode.  Hard
+ registers have to be handled more conservatively.  */
+  if (regno > FIRST_PSEUDO_REGISTER)
+{
+  rtx reg = regno_reg_rtx[regno];
+  limit = group_limit (reg);
+}
+  else
+limit = 4;
+
+  for (int i = 0; i < limit; i++)
+bitmap_set_bit (bmap, regno * 4 + i);
+}
+
 /* Note this pass could be used to narrow memory loads too.  It's
not clear if that's profitable or not in general.  */
 
@@ -196,7 +247,8 @@ ext_dce_process_sets (rtx_insn *insn, rtx obj, bitmap 
live_tmp)
 
  /* Transfer all the LIVENOW bits for X into LIVE_TMP.  */
  HOST_WIDE_INT rn = REGNO (SUBREG_REG (x));
- for (HOST_WIDE_INT i = 4 * rn; i < 4 * rn + 4; i++)
+ int limit = group_limit (SUBREG_REG (x));
+ for (HOST_WIDE_INT i = 4 * rn; i < 4 * rn + limit; i++)
if (bitmap_bit_p (livenow, i))
  bitmap_set_bit (live_tmp, i);
 
@@ -260,7 +312,8 @@ ext_dce_process_sets (rtx_insn *insn, rtx obj, bitmap 
live_tmp)
  /* Transfer the appropriate bits from LIVENOW into
 LIVE_TMP.  */
  HOST_WIDE_INT rn = REGNO (x);
- for (HOST_WIDE_INT i = 4 * rn; i < 4 * rn + 4; i++)
+ int limit = group_limit (x);
+ for (HOST_WIDE_INT i = 4 * rn; i < 4 * rn + limit; i++)
if (bitmap_bit_p (livenow, i))
  bitmap_set_bit (live_tmp, i);
 
@@ -692,7 +745,7 @@ ext_dce_process_uses (rtx_insn *insn, rtx obj, bitmap 
live_tmp)
   /* If we have a register reference that is not otherwise handled,
 just assume all the chunks are live.  */
   else if (REG_P (x))
-   bitmap_set_range (livenow, REGNO (x) * 4, 4);
+   bitmap_set_range (livenow, REGNO (x) * 4, group_limit (x));
 }
 }
 
@@ -819,10 +872,7 @@ ext_dce_init (void)
   unsigned i;
   bitmap_iterator bi;
   EXECUTE_IF_SET_IN_BITMAP (refs, 0, i, bi)
-{
-  for (int j = 0; j < 4; j++)
-   bitmap_set_bit (&livein[EXIT_BLOCK], i * 4 + j);
-}
+make_reg_live (&livein[EXIT_BLOCK], i);
 
   livenow = BITMAP_ALLOC (NULL);
   all_blocks = BITMAP_ALLOC (NULL);


[gcc/devel/fortran_unsigned] constify inchash

2024-07-28 Thread Thomas Kテカnig via Gcc-cvs
https://gcc.gnu.org/g:0231dbacb563c2e9e0825d40952c10a529f746d6

commit 0231dbacb563c2e9e0825d40952c10a529f746d6
Author: Richard Biener 
Date:   Mon Jul 22 11:09:03 2024 +0200

constify inchash

The following constifies parts of inchash.

* inchash.h (inchash::end): Make const.
(inchash::merge): Take const reference hash argument.
(inchash::add_commutative): Likewise.

Diff:
---
 gcc/inchash.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/gcc/inchash.h b/gcc/inchash.h
index e88f9b5eac18..82f50eb0f258 100644
--- a/gcc/inchash.h
+++ b/gcc/inchash.h
@@ -46,7 +46,7 @@ class hash
   }
 
   /* End incremential hashing and provide the final value.  */
-  hashval_t end ()
+  hashval_t end () const
   {
 return val;
   }
@@ -109,7 +109,7 @@ class hash
   }
 
   /* Hash in state from other inchash OTHER.  */
-  void merge (hash &other)
+  void merge (const hash &other)
   {
 merge_hash (other.val);
   }
@@ -136,7 +136,7 @@ class hash
  based on their value. This is useful for hashing commutative
  expressions, so that A+B and B+A get the same hash.  */
 
-  void add_commutative (hash &a, hash &b)
+  void add_commutative (const hash &a, const hash &b)
   {
 if (a.end() > b.end())
   {


[gcc/devel/fortran_unsigned] aarch64: Tighten aarch64_simd_mem_operand_p [PR115969]

2024-07-28 Thread Thomas Kテカnig via Gcc-cvs
https://gcc.gnu.org/g:aab585a37c84e99a04c3b159e97517ae36ee9cde

commit aab585a37c84e99a04c3b159e97517ae36ee9cde
Author: Richard Sandiford 
Date:   Mon Jul 22 16:42:15 2024 +0100

aarch64: Tighten aarch64_simd_mem_operand_p [PR115969]

aarch64_simd_mem_operand_p checked for a memory with a POST_INC
or REG address, but it didn't check what kind of register was
being used.  This meant that it allowed DImode FPRs as well as GPRs.

I wondered about rewriting it to use aarch64_classify_address,
but this one-line fix seemed simpler.  The structure then mirrors
the existing early exit in aarch64_classify_address itself:

  /* On LE, for AdvSIMD, don't support anything other than POST_INC or
 REG addressing.  */
  if (advsimd_struct_p
  && TARGET_SIMD
  && !BYTES_BIG_ENDIAN
  && (code != POST_INC && code != REG))
return false;

gcc/
PR target/115969
* config/aarch64/aarch64.cc (aarch64_simd_mem_operand_p): Require
the operand to be a legitimate memory_operand.

gcc/testsuite/
PR target/115969
* gcc.target/aarch64/pr115969.c: New test.

Diff:
---
 gcc/config/aarch64/aarch64.cc   | 5 +++--
 gcc/testsuite/gcc.target/aarch64/pr115969.c | 8 
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc
index 89eb66348f77..9e51236ce9fa 100644
--- a/gcc/config/aarch64/aarch64.cc
+++ b/gcc/config/aarch64/aarch64.cc
@@ -23377,8 +23377,9 @@ aarch64_endian_lane_rtx (machine_mode mode, unsigned 
int n)
 bool
 aarch64_simd_mem_operand_p (rtx op)
 {
-  return MEM_P (op) && (GET_CODE (XEXP (op, 0)) == POST_INC
-   || REG_P (XEXP (op, 0)));
+  return (MEM_P (op)
+ && (GET_CODE (XEXP (op, 0)) == POST_INC || REG_P (XEXP (op, 0)))
+ && memory_operand (op, VOIDmode));
 }
 
 /* Return true if OP is a valid MEM operand for an SVE LD1R instruction.  */
diff --git a/gcc/testsuite/gcc.target/aarch64/pr115969.c 
b/gcc/testsuite/gcc.target/aarch64/pr115969.c
new file mode 100644
index ..ea46626e617c
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/pr115969.c
@@ -0,0 +1,8 @@
+/* { dg-options "-O2" } */
+
+#define vec8 __attribute__((vector_size(8)))
+vec8 int f(int *a)
+{
+asm("":"+w"(a));
+return (vec8 int){a[0], a[0]};
+}


[gcc/devel/fortran_unsigned] rtl-ssa: Add debug routines for def_splay_tree

2024-07-28 Thread Thomas Kテカnig via Gcc-cvs
https://gcc.gnu.org/g:59041534f03903e828d4ada1b879af2dd1b536fb

commit 59041534f03903e828d4ada1b879af2dd1b536fb
Author: Richard Sandiford 
Date:   Mon Jul 22 16:42:16 2024 +0100

rtl-ssa: Add debug routines for def_splay_tree

This patch adds debug routines for def_splay_tree, which I found
useful while debugging PR116009.

gcc/
* rtl-ssa/accesses.h (rtl_ssa::pp_def_splay_tree): Declare.
(dump, debug): Add overloads for def_splay_tree.
* rtl-ssa/accesses.cc (rtl_ssa::pp_def_splay_tree): New function.
(dump, debug): Add overloads for def_splay_tree.

Diff:
---
 gcc/rtl-ssa/accesses.cc | 15 +++
 gcc/rtl-ssa/accesses.h  |  3 +++
 2 files changed, 18 insertions(+)

diff --git a/gcc/rtl-ssa/accesses.cc b/gcc/rtl-ssa/accesses.cc
index 5cc05cb4be7f..c77a1ff7ea76 100644
--- a/gcc/rtl-ssa/accesses.cc
+++ b/gcc/rtl-ssa/accesses.cc
@@ -1745,6 +1745,13 @@ rtl_ssa::pp_def_lookup (pretty_printer *pp, def_lookup 
dl)
   pp_def_mux (pp, dl.mux);
 }
 
+// Print TREE to PP.
+void
+rtl_ssa::pp_def_splay_tree (pretty_printer *pp, def_splay_tree tree)
+{
+  tree.print (pp, pp_def_node);
+}
+
 // Dump RESOURCE to FILE.
 void
 dump (FILE *file, resource_info resource)
@@ -1787,6 +1794,13 @@ dump (FILE *file, def_lookup result)
   dump_using (file, pp_def_lookup, result);
 }
 
+// Print TREE to FILE.
+void
+dump (FILE *file, def_splay_tree tree)
+{
+  dump_using (file, pp_def_splay_tree, tree);
+}
+
 // Debug interfaces to the dump routines above.
 void debug (const resource_info &x) { dump (stderr, x); }
 void debug (const access_info *x) { dump (stderr, x); }
@@ -1794,3 +1808,4 @@ void debug (const access_array &x) { dump (stderr, x); }
 void debug (const def_node *x) { dump (stderr, x); }
 void debug (const def_mux &x) { dump (stderr, x); }
 void debug (const def_lookup &x) { dump (stderr, x); }
+void debug (const def_splay_tree &x) { dump (stderr, x); }
diff --git a/gcc/rtl-ssa/accesses.h b/gcc/rtl-ssa/accesses.h
index 27810a02063f..7d0d7bcfb500 100644
--- a/gcc/rtl-ssa/accesses.h
+++ b/gcc/rtl-ssa/accesses.h
@@ -1052,6 +1052,7 @@ void pp_accesses (pretty_printer *, access_array,
 void pp_def_node (pretty_printer *, const def_node *);
 void pp_def_mux (pretty_printer *, def_mux);
 void pp_def_lookup (pretty_printer *, def_lookup);
+void pp_def_splay_tree (pretty_printer *, def_splay_tree);
 
 }
 
@@ -1063,6 +1064,7 @@ void dump (FILE *, rtl_ssa::access_array,
 void dump (FILE *, const rtl_ssa::def_node *);
 void dump (FILE *, rtl_ssa::def_mux);
 void dump (FILE *, rtl_ssa::def_lookup);
+void dump (FILE *, rtl_ssa::def_splay_tree);
 
 void DEBUG_FUNCTION debug (const rtl_ssa::resource_info *);
 void DEBUG_FUNCTION debug (const rtl_ssa::access_info *);
@@ -1070,3 +1072,4 @@ void DEBUG_FUNCTION debug (const rtl_ssa::access_array);
 void DEBUG_FUNCTION debug (const rtl_ssa::def_node *);
 void DEBUG_FUNCTION debug (const rtl_ssa::def_mux &);
 void DEBUG_FUNCTION debug (const rtl_ssa::def_lookup &);
+void DEBUG_FUNCTION debug (const rtl_ssa::def_splay_tree &);


[gcc/devel/fortran_unsigned] rtl-ssa: Avoid using a stale splay tree root [PR116009]

2024-07-28 Thread Thomas Kテカnig via Gcc-cvs
https://gcc.gnu.org/g:082e0faa06b32f765cceb989453d7736ddaee878

commit 082e0faa06b32f765cceb989453d7736ddaee878
Author: Richard Sandiford 
Date:   Mon Jul 22 16:42:16 2024 +0100

rtl-ssa: Avoid using a stale splay tree root [PR116009]

In the fix for PR115928, I'd failed to notice that "root" was used
later in the function, so needed to be updated.

gcc/
PR rtl-optimization/116009
* rtl-ssa/accesses.cc (function_info::add_def): Set the root
local variable after removing the old clobber group.

gcc/testsuite/
PR rtl-optimization/116009
* gcc.c-torture/compile/pr116009.c: New test.

Diff:
---
 gcc/rtl-ssa/accesses.cc|  3 ++-
 gcc/testsuite/gcc.c-torture/compile/pr116009.c | 23 +++
 2 files changed, 25 insertions(+), 1 deletion(-)

diff --git a/gcc/rtl-ssa/accesses.cc b/gcc/rtl-ssa/accesses.cc
index c77a1ff7ea76..0bba8391b002 100644
--- a/gcc/rtl-ssa/accesses.cc
+++ b/gcc/rtl-ssa/accesses.cc
@@ -946,7 +946,8 @@ function_info::add_def (def_info *def)
  prev = split_clobber_group (group, insn);
  next = prev->next_def ();
  tree.remove_root ();
- last->set_splay_root (tree.root ());
+ root = tree.root ();
+ last->set_splay_root (root);
}
   // COMPARISON is < 0 if DEF comes before ROOT or > 0 if DEF comes
   // after ROOT.
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr116009.c 
b/gcc/testsuite/gcc.c-torture/compile/pr116009.c
new file mode 100644
index ..6a888d450f4c
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/compile/pr116009.c
@@ -0,0 +1,23 @@
+int tt, tt1;
+int y6;
+void ff(void);
+int ttt;
+void g(int var) {
+  do  {
+int t1 = var == 45 || var == 3434;
+if (tt != 0)
+if (t1)
+ff();
+if (tt < 0)
+break;
+if (t1)
+  ff();
+if (tt < 0)
+break;
+ff();
+if (tt1)
+var = y6;
+if (t1)
+  ff();
+} while(1);
+}


[gcc/devel/fortran_unsigned] Compare loop bounds in ipa-icf

2024-07-28 Thread Thomas Kテカnig via Gcc-cvs
https://gcc.gnu.org/g:0b5b178caea0417ff23d0609b1416e3f3e4f6689

commit 0b5b178caea0417ff23d0609b1416e3f3e4f6689
Author: Jan Hubicka 
Date:   Mon Jul 22 18:01:57 2024 +0200

Compare loop bounds in ipa-icf

Hi,
this testcase shows another poblem with missing comparators for metadata
in ICF. With value ranges available to loop optimizations during early
opts we can estimate number of iterations based on guarding condition that
can be split away by the fnsplit pass. This patch disables ICF when
number of iteraitons does not match.

Bootstrapped/regtesed x86_64-linux, will commit it shortly

gcc/ChangeLog:

PR ipa/115277
* ipa-icf-gimple.cc (func_checker::compare_loops): compare loop
bounds.

gcc/testsuite/ChangeLog:

* gcc.c-torture/compile/pr115277.c: New test.

Diff:
---
 gcc/ipa-icf-gimple.cc  |  4 
 gcc/testsuite/gcc.c-torture/compile/pr115277.c | 28 ++
 2 files changed, 32 insertions(+)

diff --git a/gcc/ipa-icf-gimple.cc b/gcc/ipa-icf-gimple.cc
index c25eb24710f6..4c3174b68b67 100644
--- a/gcc/ipa-icf-gimple.cc
+++ b/gcc/ipa-icf-gimple.cc
@@ -543,6 +543,10 @@ func_checker::compare_loops (basic_block bb1, basic_block 
bb2)
 return return_false_with_msg ("unroll");
   if (!compare_variable_decl (l1->simduid, l2->simduid))
 return return_false_with_msg ("simduid");
+  if ((l1->any_upper_bound != l2->any_upper_bound)
+  || (l1->any_upper_bound
+ && (l1->nb_iterations_upper_bound != l2->nb_iterations_upper_bound)))
+return return_false_with_msg ("nb_iterations_upper_bound");
 
   return true;
 }
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr115277.c 
b/gcc/testsuite/gcc.c-torture/compile/pr115277.c
new file mode 100644
index ..27449eb254f8
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/compile/pr115277.c
@@ -0,0 +1,28 @@
+int array[1000];
+void
+test (int a)
+{
+if (__builtin_expect (a > 3, 1))
+return;
+for (int i = 0; i < a; i++)
+array[i]=i;
+}
+void
+test2 (int a)
+{
+if (__builtin_expect (a > 10, 1))
+return;
+for (int i = 0; i < a; i++)
+array[i]=i;
+}
+int
+main()
+{
+test(1);
+test(2);
+test(3);
+test2(10);
+if (array[9] != 9)
+__builtin_abort ();
+return 0;
+}


[gcc/devel/fortran_unsigned] Fix accounting of offsets in unadjusted_ptr_and_unit_offset

2024-07-28 Thread Thomas Kテカnig via Gcc-cvs
https://gcc.gnu.org/g:d9c73e23ed096c8c786f2206df29d8ea3ab54038

commit d9c73e23ed096c8c786f2206df29d8ea3ab54038
Author: Jan Hubicka 
Date:   Mon Jul 22 18:05:26 2024 +0200

Fix accounting of offsets in unadjusted_ptr_and_unit_offset

unadjusted_ptr_and_unit_offset accidentally throws away the offset computed 
by
get_addr_base_and_unit_offset. Instead of passing extra_offset it passes 
offset.

PR ipa/114207

gcc/ChangeLog:

* ipa-prop.cc (unadjusted_ptr_and_unit_offset): Fix accounting of 
offsets in ADDR_EXPR.

gcc/testsuite/ChangeLog:

* gcc.c-torture/execute/pr114207.c: New test.

Diff:
---
 gcc/ipa-prop.cc|  4 ++--
 gcc/testsuite/gcc.c-torture/execute/pr114207.c | 23 +++
 2 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/gcc/ipa-prop.cc b/gcc/ipa-prop.cc
index 7d7cb3835d2b..99ebd6229ec4 100644
--- a/gcc/ipa-prop.cc
+++ b/gcc/ipa-prop.cc
@@ -1370,9 +1370,9 @@ unadjusted_ptr_and_unit_offset (tree op, tree *ret, 
poly_int64 *offset_ret)
 {
   if (TREE_CODE (op) == ADDR_EXPR)
{
- poly_int64 extra_offset = 0;
+ poly_int64 extra_offset;
  tree base = get_addr_base_and_unit_offset (TREE_OPERAND (op, 0),
-&offset);
+&extra_offset);
  if (!base)
{
  base = get_base_address (TREE_OPERAND (op, 0));
diff --git a/gcc/testsuite/gcc.c-torture/execute/pr114207.c 
b/gcc/testsuite/gcc.c-torture/execute/pr114207.c
new file mode 100644
index ..052fa85e9fc6
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/execute/pr114207.c
@@ -0,0 +1,23 @@
+#include 
+#include 
+
+struct S {
+int a, b;
+};
+
+__attribute__((noinline))
+void foo (struct S *s) {
+struct S ss = (struct S) {
+.a = s->b,
+.b = s->a
+};
+*s = ss;
+}
+
+int main() {
+  struct S s = {6, 12};
+  foo(&s);
+  if (s.a != 12 || s.b != 6)
+__builtin_abort ();
+  return 0;
+}


[gcc/devel/fortran_unsigned] Fix modref_eaf_analysis::analyze_ssa_name handling of values dereferenced to function call parameter

2024-07-28 Thread Thomas Kテカnig via Gcc-cvs
https://gcc.gnu.org/g:14f605f17b8ee8e8a2dc3b4292420ea5f5d2cf8d

commit 14f605f17b8ee8e8a2dc3b4292420ea5f5d2cf8d
Author: Jan Hubicka 
Date:   Mon Jul 22 18:08:08 2024 +0200

Fix modref_eaf_analysis::analyze_ssa_name handling of values dereferenced 
to function call parameters

modref_eaf_analysis::analyze_ssa_name misinterprets EAF flags.  If 
dereferenced
parameter is passed (to map_iterator in the testcase) it can be returned
indirectly which in turn makes it to escape into the next function call.

PR ipa/115033

gcc/ChangeLog:

* ipa-modref.cc (modref_eaf_analysis::analyze_ssa_name): Fix 
checking of
EAF flags when analysing values dereferenced as function parameters.

gcc/testsuite/ChangeLog:

* gcc.c-torture/execute/pr115033.c: New test.

Diff:
---
 gcc/ipa-modref.cc  |  6 +++--
 gcc/testsuite/gcc.c-torture/execute/pr115033.c | 35 ++
 2 files changed, 39 insertions(+), 2 deletions(-)

diff --git a/gcc/ipa-modref.cc b/gcc/ipa-modref.cc
index a5adce8ea396..f994388a96ab 100644
--- a/gcc/ipa-modref.cc
+++ b/gcc/ipa-modref.cc
@@ -2571,8 +2571,10 @@ modref_eaf_analysis::analyze_ssa_name (tree name, bool 
deferred)
int call_flags = deref_flags
(gimple_call_arg_flags (call, i), ignore_stores);
if (!ignore_retval && !(call_flags & EAF_UNUSED)
-   && !(call_flags & EAF_NOT_RETURNED_DIRECTLY)
-   && !(call_flags & EAF_NOT_RETURNED_INDIRECTLY))
+   && (call_flags & (EAF_NOT_RETURNED_DIRECTLY
+ | EAF_NOT_RETURNED_INDIRECTLY))
+   != (EAF_NOT_RETURNED_DIRECTLY
+   | EAF_NOT_RETURNED_INDIRECTLY))
  merge_call_lhs_flags (call, i, name, false, true);
if (ecf_flags & (ECF_CONST | ECF_NOVOPS))
  m_lattice[index].merge_direct_load ();
diff --git a/gcc/testsuite/gcc.c-torture/execute/pr115033.c 
b/gcc/testsuite/gcc.c-torture/execute/pr115033.c
new file mode 100644
index ..3e79367d401c
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/execute/pr115033.c
@@ -0,0 +1,35 @@
+
+typedef struct func
+{
+  int *a;
+}func;
+__attribute__((noinline))
+void ff(struct func *t)
+{
+  *(t->a) = 0;
+}
+
+
+typedef struct mapped_iterator {
+  func F;
+}mapped_iterator;
+
+__attribute__((noinline))
+mapped_iterator map_iterator(func F) {
+  mapped_iterator t = {F};
+  return t;
+}
+
+void map_to_vector(func *F) {
+  mapped_iterator t = map_iterator(*F);
+  ff(&t.F);
+}
+int main() {
+  int resultIsStatic = 1;
+  func t ={&resultIsStatic};
+  map_to_vector(&t);
+
+  if (resultIsStatic)
+__builtin_trap();
+  __builtin_exit(0);
+}


[gcc/devel/fortran_unsigned] [4/n][PR rtl-optimization/115877] Correct SUBREG handling in a destination

2024-07-28 Thread Thomas Kテカnig via Gcc-cvs
https://gcc.gnu.org/g:f357bfdb41779139e1658433bffa9e7dbee534c5

commit f357bfdb41779139e1658433bffa9e7dbee534c5
Author: Jeff Law 
Date:   Mon Jul 22 10:11:57 2024 -0600

[4/n][PR rtl-optimization/115877] Correct SUBREG handling in a destination

If we encounter something during SET handling that we can not handle, the 
safe
thing to do is to ignore the destination and continue the loop.

We've actually been trying to do slightly better with SUBREG destinations by
iterating into SUBREG_REG.  It turns out that wasn't working as expected.

The problem is once we "continue" we lose the state that we were inside the 
SET
and thus we ended up ignoring the destination completely rather than 
tracking
the SUBREG_REG object.  This could be fixed by restarting SET processing, 
but I
just don't see this as all that important to handle.  So rather than leave 
the
code as-is, not working per design, I'm twiddling it to use the common 'skip
subrtxs and continue' idiom used elsewhere.

This is a prerequisite for another patch in this series.  Specifically I 
have a
patch that explicitly tracks if we skipped a destination rather than trying 
to
imply it from the state of LIVE_TMP.  So this is probably NFC right now, but
that's a short-lived NFC.

Bootstrapped and regression tested on x86 and also run as part of a larger 
kit
on the crosses in my tester.

PR rtl-optimization/115877
gcc/
* ext-dce.cc (ext_dce_process_sets): More correctly handle SUBREG
destinations.

Diff:
---
 gcc/ext-dce.cc | 13 ++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/gcc/ext-dce.cc b/gcc/ext-dce.cc
index 44f64e2d18cf..21feabd9ce31 100644
--- a/gcc/ext-dce.cc
+++ b/gcc/ext-dce.cc
@@ -270,11 +270,18 @@ ext_dce_process_sets (rtx_insn *insn, rtx obj, bitmap 
live_tmp)
= GET_MODE_MASK (GET_MODE_INNER (GET_MODE (x)));
  if (SUBREG_P (x))
{
- /* If we have a SUBREG that is too wide, just continue the loop
-and let the iterator go down into SUBREG_REG.  */
+ /* If we have a SUBREG destination that is too wide, just
+skip the destination rather than continuing this iterator.
+While continuing would be better, we'd need to strip the
+subreg and restart within the SET processing rather than
+the top of the loop which just complicates the flow even
+more.  */
  if (!is_a  (GET_MODE (SUBREG_REG (x)), 
&outer_mode)
  || GET_MODE_BITSIZE (outer_mode) > 64)
-   continue;
+   {
+ iter.skip_subrtxes ();
+ continue;
+   }
 
  /* We can safely strip a paradoxical subreg.  The inner mode will
 be narrower than the outer mode.  We'll clear fewer bits in


[gcc/devel/fortran_unsigned] Add -mcpu=power11 support.

2024-07-28 Thread Thomas Kテカnig via Gcc-cvs
https://gcc.gnu.org/g:2a3e29507eafc2d5c9119ea138c3d6257e89e459

commit 2a3e29507eafc2d5c9119ea138c3d6257e89e459
Author: Michael Meissner 
Date:   Mon Jul 22 12:20:43 2024 -0400

Add -mcpu=power11 support.

This patch adds the power11 option to the -mcpu= and -mtune= switches.

This patch treats the power11 like a power10 in terms of costs and 
reassociation
width.

This patch issues a ".machine power11" to the assembly file if you use
-mcpu=power11.

This patch defines _ARCH_PWR11 if the user uses -mcpu=power11.

This patch allows GCC to be configured with the --with-cpu=power11 and
--with-tune=power11 options.

This patch passes -mpwr11 to the assembler if the user uses -mcpu=power11.

This patch adds support for using "power11" in the __builtin_cpu_is built-in
function.

2024-07-22  Michael Meissner  

gcc/

* config.gcc (powerpc*-*-*): Add support for power11.
* config/rs6000/aix71.h (ASM_CPU_SPEC): Add support for 
-mcpu=power11.
* config/rs6000/aix72.h (ASM_CPU_SPEC): Likewise.
* config/rs6000/aix73.h (ASM_CPU_SPEC): Likewise.
* config/rs6000/driver-rs6000.cc (asm_names): Likewise.
* config/rs6000/ppc-auxv.h (PPC_PLATFORM_POWER11): New define.
* config/rs6000/rs6000-builtin.cc (cpu_is_info): Add power11.
* config/rs6000/rs6000-c.cc (rs6000_target_modify_macros): Define
_ARCH_PWR11 if -mcpu=power11.
* config/rs6000/rs6000-cpus.def (POWER11_MASKS_SERVER): New define.
(POWERPC_MASKS): Add power11.
(power11 cpu): Add power11 definition.
* config/rs6000/rs6000-opts.h (PROCESSOR_POWER11): Add power11 
processor.
* config/rs6000/rs6000-string.cc (expand_compare_loop): Likewise.
* config/rs6000/rs6000-tables.opt: Regenerate.
* config/rs6000/rs6000.cc (rs6000_option_override_internal): Add 
power11
support.
(rs6000_machine_from_flags): Likewise.
(rs6000_reassociation_width): Likewise.
(rs6000_adjust_cost): Likewise.
(rs6000_issue_rate): Likewise.
(rs6000_sched_reorder): Likewise.
(rs6000_sched_reorder2): Likewise.
(rs6000_register_move_cost): Likewise.
(rs6000_opt_masks): Likewise.
* config/rs6000/rs6000.h (ASM_CPU_SPEC): Likewise.
* config/rs6000/rs6000.md (cpu attribute): Add power11.
* config/rs6000/rs6000.opt (-mpower11): Add internal power11 flag.
* doc/invoke.texi (RS/6000 and PowerPC Options): Document 
-mcpu=power11.
* config/rs6000/power10.md (all reservations): Add power11 support.

gcc/testsuite/

* gcc.target/powerpc/power11-1.c: New test.
* gcc.target/powerpc/power11-2.c: Likewise.
* gcc.target/powerpc/power11-3.c: Likewise.

Diff:
---
 gcc/config.gcc   |   4 +-
 gcc/config/rs6000/aix71.h|   1 +
 gcc/config/rs6000/aix72.h|   1 +
 gcc/config/rs6000/aix73.h|   1 +
 gcc/config/rs6000/driver-rs6000.cc   |   2 +
 gcc/config/rs6000/power10.md | 144 +--
 gcc/config/rs6000/ppc-auxv.h |   3 +-
 gcc/config/rs6000/rs6000-builtin.cc  |   1 +
 gcc/config/rs6000/rs6000-c.cc|   2 +
 gcc/config/rs6000/rs6000-cpus.def|   5 +
 gcc/config/rs6000/rs6000-opts.h  |   1 +
 gcc/config/rs6000/rs6000-string.cc   |   1 +
 gcc/config/rs6000/rs6000-tables.opt  |  11 +-
 gcc/config/rs6000/rs6000.cc  |  32 --
 gcc/config/rs6000/rs6000.h   |   1 +
 gcc/config/rs6000/rs6000.md  |   2 +-
 gcc/config/rs6000/rs6000.opt |   6 ++
 gcc/doc/invoke.texi  |   2 +-
 gcc/testsuite/gcc.target/powerpc/power11-1.c |  13 +++
 gcc/testsuite/gcc.target/powerpc/power11-2.c |  19 
 gcc/testsuite/gcc.target/powerpc/power11-3.c |   9 ++
 21 files changed, 171 insertions(+), 90 deletions(-)

diff --git a/gcc/config.gcc b/gcc/config.gcc
index bc45615741b1..7453ade07826 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -533,7 +533,7 @@ powerpc*-*-*)
extra_headers="${extra_headers} ppu_intrinsics.h spu2vmx.h vec_types.h 
si2vmx.h"
extra_headers="${extra_headers} amo.h"
case x$with_cpu in
-   
xpowerpc64|xdefault64|x6[23]0|x970|xG5|xpower[3456789]|xpower10|xpower6x|xrs64a|xcell|xa2|xe500mc64|xe5500|xe6500)
+   
xpowerpc64|xdefault64|x6[23]0|x970|xG5|xpower[3456789]|xpower1[01]|xpower6x|xrs64a|xcell|xa2|xe500mc64|xe5500|xe6500)
cpu_is_64bit=yes
;;
esac
@@ -5641,7 +5641,7 @@ case "${target}" in
eval "with_$which=405"

[gcc/devel/fortran_unsigned] Fix modref's iteraction with store merging

2024-07-28 Thread Thomas Kテカnig via Gcc-cvs
https://gcc.gnu.org/g:087a28832a28543872386e6e98692e1b9ea93bdf

commit 087a28832a28543872386e6e98692e1b9ea93bdf
Author: Jan Hubicka 
Date:   Mon Jul 22 19:00:39 2024 +0200

Fix modref's iteraction with store merging

Hi,
this patch fixes wrong code in case store-merging introduces load of 
function
parameter that was previously write-only (which happens for bitfields).
Without this, the whole store-merged area is consdered to be killed.

PR ipa/111613

gcc/ChangeLog:

* ipa-modref.cc (analyze_parms): Do not preserve EAF_NO_DIRECT_READ 
and
EAF_NO_INDIRECT_READ from past flags.

gcc/testsuite/ChangeLog:

* gcc.c-torture/pr111613.c: New test.

Diff:
---
 gcc/ipa-modref.cc  |  3 +++
 gcc/testsuite/gcc.c-torture/pr111613.c | 29 +
 2 files changed, 32 insertions(+)

diff --git a/gcc/ipa-modref.cc b/gcc/ipa-modref.cc
index f994388a96ab..53a2e35133da 100644
--- a/gcc/ipa-modref.cc
+++ b/gcc/ipa-modref.cc
@@ -3004,6 +3004,9 @@ analyze_parms (modref_summary *summary, 
modref_summary_lto *summary_lto,
 (past, ecf_flags,
  VOID_TYPE_P (TREE_TYPE
  (TREE_TYPE (current_function_decl;
+ /* Store merging can produce reads when combining together multiple
+bitfields.  See PR111613.  */
+ past &= ~(EAF_NO_DIRECT_READ | EAF_NO_INDIRECT_READ);
  if (dump_file && (flags | past) != flags && !(flags & EAF_UNUSED))
{
  fprintf (dump_file,
diff --git a/gcc/testsuite/gcc.c-torture/pr111613.c 
b/gcc/testsuite/gcc.c-torture/pr111613.c
new file mode 100644
index ..1ea1c4dec072
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/pr111613.c
@@ -0,0 +1,29 @@
+#include 
+#include 
+
+struct bitfield {
+   unsigned int field1 : 1;
+   unsigned int field2 : 1;
+   unsigned int field3 : 1;
+};
+
+__attribute__((noinline)) static void
+set_field1_and_field2(struct bitfield *b) {
+   b->field1 = 1;
+   b->field2 = 1;
+}
+
+__attribute__((noinline)) static struct bitfield *
+new_bitfield(void) {
+   struct bitfield *b = (struct bitfield *)malloc(sizeof(*b));
+   b->field3 = 1;
+   set_field1_and_field2(b);
+   return b;
+}
+
+int main(void) {
+   struct bitfield *b = new_bitfield();
+   if (b->field3 != 1)
+   __builtin_abort ();
+   return 0;
+}


[gcc/devel/fortran_unsigned] c++: Some cp-tree.def comment fixes

2024-07-28 Thread Thomas Kテカnig via Gcc-cvs
https://gcc.gnu.org/g:a0f900eae9843f9a2687daf1f068077c2412b364

commit a0f900eae9843f9a2687daf1f068077c2412b364
Author: Jakub Jelinek 
Date:   Mon Jul 22 19:47:17 2024 +0200

c++: Some cp-tree.def comment fixes

While reading the fold expression and concept tree comments, I found
various spots referring to non-existent macros etc.

The following patch attempts to sync that with what is actually implemented.

2024-07-22  Jakub Jelinek  

* cp-tree.def (UNARY_LEFT_FOLD_EXPR): Use FOLD_EXPR_MODIFY_P instead
of FOLD_EXPR_MOD_P or FOLDEXPR_MOD_P in the comment.  Comment
formatting fixes.
(ATOMIC_CONSTEXPR): Use CONSTR_INFO instead of ATOMIC_CONSTR_INFO
and ATOMIC_CONSTR_MAP instead of ATOMIC_CONSTR_PARMS in the comment.
Comment formatting fixes.
(CONJ_CONSTR): Remove comment about third operand.  Use CONSTR_INFO
instead of CONJ_CONSTR_INFO and DISJ_CONSTR_INFO.
(CHECK_CONSTR): Use CHECK_CONSTR_ARGS instead of
CHECK_CONSTR_ARGUMENTS.

Diff:
---
 gcc/cp/cp-tree.def | 23 +++
 1 file changed, 11 insertions(+), 12 deletions(-)

diff --git a/gcc/cp/cp-tree.def b/gcc/cp/cp-tree.def
index 3a7ac29636da..a0a47c3950fa 100644
--- a/gcc/cp/cp-tree.def
+++ b/gcc/cp/cp-tree.def
@@ -412,17 +412,17 @@ DEFTREECODE (ARGUMENT_PACK_SELECT, 
"argument_pack_select", tcc_exceptional, 0)
 /* Fold expressions allow the expansion of a template argument pack
over a binary operator.
 
-   FOLD_EXPR_MOD_P is true when the fold operation is a compound assignment
+   FOLD_EXPR_MODIFY_P is true when the fold operation is a compound assignment
operator.
 
FOLD_EXPR_OP is an INTEGER_CST storing the tree code for the folded
-   expression. Note that when FOLDEXPR_MOD_P is true, the operator is
+   expression.  Note that when FOLD_EXPR_MODIFY_P is true, the operator is
a compound assignment operator for that kind of expression.
 
FOLD_EXPR_PACK is an expression containing an unexpanded parameter pack;
when expanded, each term becomes an argument of the folded expression.
 
-   In a BINARY_FOLD_EXPRESSION, FOLD_EXPR_INIT is the non-pack argument. */
+   In a BINARY_FOLD_EXPRESSION, FOLD_EXPR_INIT is the non-pack argument.  */
 DEFTREECODE (UNARY_LEFT_FOLD_EXPR, "unary_left_fold_expr", tcc_expression, 2)
 DEFTREECODE (UNARY_RIGHT_FOLD_EXPR, "unary_right_fold_expr", tcc_expression, 2)
 DEFTREECODE (BINARY_LEFT_FOLD_EXPR, "binary_left_fold_expr", tcc_expression, 3)
@@ -518,24 +518,23 @@ DEFTREECODE (NESTED_REQ, "nested_req", tcc_expression, 1)
 
 /* Constraints are modeled as kinds of expressions.
The operands of a constraint can be either types or expressions.
-   Unlike expressions, constraints do not have a type. */
+   Unlike expressions, constraints do not have a type.  */
 
 /* An atomic constraint evaluates an expression E. The operand of the
-   constraint is its parameter mapping. The actual expression is stored
+   constraint is its parameter mapping.  The actual expression is stored
in the context.
 
-   ATOMIC_CONSTR_INFO provides source info to support diagnostics.
+   CONSTR_INFO provides source info to support diagnostics.
ATOMIC_CONSTR_EXPR has the expression to be evaluated.
-   ATOMIC_CONSTR_PARMS is the parameter mapping for the atomic constraint
+   ATOMIC_CONSTR_MAP is the parameter mapping for the atomic constraint
and is stored in the type field.  */
 DEFTREECODE (ATOMIC_CONSTR, "atomic_constr", tcc_expression, 1)
 
 /* The conjunction and disjunction of two constraints, respectively.
-   Operands are accessed using TREE_OPERAND. The third operand provides
-   source info for diagnostics.
+   Operands are accessed using TREE_OPERAND.
 
-   CONJ_CONSTR_INFO and DISJ_CONSTR_INFO provide access to the source
-   information of constraints, which is stored in the TREE_TYPE.  */
+   CONSTR_INFO provides access to the source information of constraints,
+   which is stored in the TREE_TYPE.  */
 DEFTREECODE (CONJ_CONSTR, "conj_constr", tcc_expression, 2)
 DEFTREECODE (DISJ_CONSTR, "disj_constr", tcc_expression, 2)
 
@@ -544,7 +543,7 @@ DEFTREECODE (DISJ_CONSTR, "disj_constr", tcc_expression, 2)
and a sequence of template arguments.
 
CHECK_CONSTR_CONCEPT has the concept definition
-   CHECK_CONSTR_ARGUMENTS are the template arguments */
+   CHECK_CONSTR_ARGS are the template arguments.   */
 DEFTREECODE (CHECK_CONSTR, "check_constr", tcc_expression, 2)
 
 /* The co_await expression is used to support coroutines.


[gcc/devel/fortran_unsigned] Fix handling of ICF_NOVOPS in ipa-modref

2024-07-28 Thread Thomas Kテカnig via Gcc-cvs
https://gcc.gnu.org/g:5179dda44a6279ad0156b2c8414235325843197b

commit 5179dda44a6279ad0156b2c8414235325843197b
Author: Jan Hubicka 
Date:   Mon Jul 22 23:01:50 2024 +0200

Fix handling of ICF_NOVOPS in ipa-modref

As shown in somewhat convoluted testcase, ipa-modref is mistreating
ECF_NOVOPS as "having no side effects".  This come from time when
modref cared only about memory accesses and thus it was possible to
shortcut on it.

This patch removes (hopefully) all those bad shortcuts.
Bootstrapped/regtested x86_64-linux, comitted.

gcc/ChangeLog:

PR ipa/109985

* ipa-modref.cc (modref_summary::useful_p): Fix handling of 
ECF_NOVOPS.
(modref_access_analysis::process_fnspec): Likevise.
(modref_access_analysis::analyze_call): Likevise.
(propagate_unknown_call): Likevise.
(modref_propagate_in_scc): Likevise.
(modref_propagate_flags_in_scc): Likewise.
(ipa_merge_modref_summary_after_inlining): Likewise.

Diff:
---
 gcc/ipa-modref.cc | 36 +---
 1 file changed, 21 insertions(+), 15 deletions(-)

diff --git a/gcc/ipa-modref.cc b/gcc/ipa-modref.cc
index 53a2e35133da..f6a758b5f427 100644
--- a/gcc/ipa-modref.cc
+++ b/gcc/ipa-modref.cc
@@ -334,7 +334,7 @@ modref_summary::useful_p (int ecf_flags, bool check_flags)
   if (check_flags
   && remove_useless_eaf_flags (static_chain_flags, ecf_flags, false))
 return true;
-  if (ecf_flags & (ECF_CONST | ECF_NOVOPS))
+  if (ecf_flags & ECF_CONST)
 return ((!side_effects || !nondeterministic)
&& (ecf_flags & ECF_LOOPING_CONST_OR_PURE));
   if (loads && !loads->every_base)
@@ -1263,7 +1263,7 @@ modref_access_analysis::merge_call_side_effects
   int flags = gimple_call_flags (call);
 
   /* Nothing to do for non-looping cont functions.  */
-  if ((flags & (ECF_CONST | ECF_NOVOPS))
+  if ((flags & ECF_CONST)
   && !(flags & ECF_LOOPING_CONST_OR_PURE))
 return false;
 
@@ -1276,7 +1276,7 @@ modref_access_analysis::merge_call_side_effects
   /* Merge side effects and non-determinism.
  PURE/CONST flags makes functions deterministic and if there is
  no LOOPING_CONST_OR_PURE they also have no side effects.  */
-  if (!(flags & (ECF_CONST | ECF_NOVOPS | ECF_PURE))
+  if (!(flags & (ECF_CONST | ECF_PURE))
   || (flags & ECF_LOOPING_CONST_OR_PURE))
 {
   if (!m_summary->side_effects && callee_summary->side_effects)
@@ -1465,7 +1465,7 @@ modref_access_analysis::process_fnspec (gcall *call)
 
   /* PURE/CONST flags makes functions deterministic and if there is
  no LOOPING_CONST_OR_PURE they also have no side effects.  */
-  if (!(flags & (ECF_CONST | ECF_NOVOPS | ECF_PURE))
+  if (!(flags & (ECF_CONST | ECF_PURE))
   || (flags & ECF_LOOPING_CONST_OR_PURE)
   || (cfun->can_throw_non_call_exceptions
  && stmt_could_throw_p (cfun, call)))
@@ -1604,12 +1604,12 @@ modref_access_analysis::analyze_call (gcall *stmt)
   print_gimple_stmt (dump_file, stmt, 0);
 }
 
-  if ((flags & (ECF_CONST | ECF_NOVOPS))
+  if ((flags & ECF_CONST)
   && !(flags & ECF_LOOPING_CONST_OR_PURE))
 {
   if (dump_file)
fprintf (dump_file,
-" - ECF_CONST | ECF_NOVOPS, ignoring all stores and all loads "
+" - ECF_CONST, ignoring all stores and all loads "
 "except for args.\n");
   return;
 }
@@ -1624,7 +1624,13 @@ modref_access_analysis::analyze_call (gcall *stmt)
   if (dump_file)
fprintf (dump_file, gimple_call_internal_p (stmt)
 ? " - Internal call" : " - Indirect call.\n");
-  process_fnspec (stmt);
+  if (flags & ECF_NOVOPS)
+{
+ set_side_effects ();
+ set_nondeterministic ();
+}
+  else
+   process_fnspec (stmt);
   return;
 }
   /* We only need to handle internal calls in IPA mode.  */
@@ -4568,7 +4574,7 @@ propagate_unknown_call (cgraph_node *node,
   return changed;
 }
 
-  if (!(ecf_flags & (ECF_CONST | ECF_NOVOPS | ECF_PURE))
+  if (!(ecf_flags & (ECF_CONST | ECF_PURE))
   || (ecf_flags & ECF_LOOPING_CONST_OR_PURE)
   || nontrivial_scc)
 {
@@ -4782,7 +4788,7 @@ modref_propagate_in_scc (cgraph_node *component_node)
  struct cgraph_node *callee;
 
  if (!callee_edge->inline_failed
-|| ((flags & (ECF_CONST | ECF_NOVOPS))
+|| ((flags & ECF_CONST)
 && !(flags & ECF_LOOPING_CONST_OR_PURE)))
continue;
 
@@ -5205,8 +5211,8 @@ modref_propagate_flags_in_scc (cgraph_node 
*component_node)
{
  escape_summary *sum = escape_summaries->get (e);
 
- if (!sum || (e->indirect_info->ecf_flags
-  & (ECF_CONST | ECF_NOVOPS)))
+ if (!sum || ((e->indirect_info->ecf_flags & ECF_CONST)
+ && !(e->indirect_info->ecf_flags & 

[gcc/devel/fortran_unsigned] Daily bump.

2024-07-28 Thread Thomas Kテカnig via Gcc-cvs
https://gcc.gnu.org/g:53cc3f61b5ff4fc9070a98f2af11976acfacdc91

commit 53cc3f61b5ff4fc9070a98f2af11976acfacdc91
Author: GCC Administrator 
Date:   Tue Jul 23 00:19:00 2024 +

Daily bump.

Diff:
---
 gcc/ChangeLog   | 131 +
 gcc/DATESTAMP   |   2 +-
 gcc/cp/ChangeLog|  13 +++
 gcc/fortran/ChangeLog   |   7 ++
 gcc/testsuite/ChangeLog | 247 
 5 files changed, 399 insertions(+), 1 deletion(-)

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 61fc57be9492..353ce3b6e2a8 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,134 @@
+2024-07-22  Jan Hubicka  
+
+   PR ipa/109985
+   * ipa-modref.cc (modref_summary::useful_p): Fix handling of ECF_NOVOPS.
+   (modref_access_analysis::process_fnspec): Likevise.
+   (modref_access_analysis::analyze_call): Likevise.
+   (propagate_unknown_call): Likevise.
+   (modref_propagate_in_scc): Likevise.
+   (modref_propagate_flags_in_scc): Likewise.
+   (ipa_merge_modref_summary_after_inlining): Likewise.
+
+2024-07-22  Jan Hubicka  
+
+   PR ipa/111613
+   * ipa-modref.cc (analyze_parms): Do not preserve EAF_NO_DIRECT_READ and
+   EAF_NO_INDIRECT_READ from past flags.
+
+2024-07-22  Michael Meissner  
+
+   * config.gcc (powerpc*-*-*): Add support for power11.
+   * config/rs6000/aix71.h (ASM_CPU_SPEC): Add support for -mcpu=power11.
+   * config/rs6000/aix72.h (ASM_CPU_SPEC): Likewise.
+   * config/rs6000/aix73.h (ASM_CPU_SPEC): Likewise.
+   * config/rs6000/driver-rs6000.cc (asm_names): Likewise.
+   * config/rs6000/ppc-auxv.h (PPC_PLATFORM_POWER11): New define.
+   * config/rs6000/rs6000-builtin.cc (cpu_is_info): Add power11.
+   * config/rs6000/rs6000-c.cc (rs6000_target_modify_macros): Define
+   _ARCH_PWR11 if -mcpu=power11.
+   * config/rs6000/rs6000-cpus.def (POWER11_MASKS_SERVER): New define.
+   (POWERPC_MASKS): Add power11.
+   (power11 cpu): Add power11 definition.
+   * config/rs6000/rs6000-opts.h (PROCESSOR_POWER11): Add power11 
processor.
+   * config/rs6000/rs6000-string.cc (expand_compare_loop): Likewise.
+   * config/rs6000/rs6000-tables.opt: Regenerate.
+   * config/rs6000/rs6000.cc (rs6000_option_override_internal): Add power11
+   support.
+   (rs6000_machine_from_flags): Likewise.
+   (rs6000_reassociation_width): Likewise.
+   (rs6000_adjust_cost): Likewise.
+   (rs6000_issue_rate): Likewise.
+   (rs6000_sched_reorder): Likewise.
+   (rs6000_sched_reorder2): Likewise.
+   (rs6000_register_move_cost): Likewise.
+   (rs6000_opt_masks): Likewise.
+   * config/rs6000/rs6000.h (ASM_CPU_SPEC): Likewise.
+   * config/rs6000/rs6000.md (cpu attribute): Add power11.
+   * config/rs6000/rs6000.opt (-mpower11): Add internal power11 flag.
+   * doc/invoke.texi (RS/6000 and PowerPC Options): Document -mcpu=power11.
+   * config/rs6000/power10.md (all reservations): Add power11 support.
+
+2024-07-22  Jeff Law  
+
+   PR rtl-optimization/115877
+   * ext-dce.cc (ext_dce_process_sets): More correctly handle SUBREG
+   destinations.
+
+2024-07-22  Jan Hubicka  
+
+   PR ipa/115033
+   * ipa-modref.cc (modref_eaf_analysis::analyze_ssa_name): Fix checking of
+   EAF flags when analysing values dereferenced as function parameters.
+
+2024-07-22  Jan Hubicka  
+
+   PR ipa/114207
+   * ipa-prop.cc (unadjusted_ptr_and_unit_offset): Fix accounting of 
offsets in ADDR_EXPR.
+
+2024-07-22  Jan Hubicka  
+
+   PR ipa/115277
+   * ipa-icf-gimple.cc (func_checker::compare_loops): compare loop
+   bounds.
+
+2024-07-22  Richard Sandiford  
+
+   PR rtl-optimization/116009
+   * rtl-ssa/accesses.cc (function_info::add_def): Set the root
+   local variable after removing the old clobber group.
+
+2024-07-22  Richard Sandiford  
+
+   * rtl-ssa/accesses.h (rtl_ssa::pp_def_splay_tree): Declare.
+   (dump, debug): Add overloads for def_splay_tree.
+   * rtl-ssa/accesses.cc (rtl_ssa::pp_def_splay_tree): New function.
+   (dump, debug): Add overloads for def_splay_tree.
+
+2024-07-22  Richard Sandiford  
+
+   PR target/115969
+   * config/aarch64/aarch64.cc (aarch64_simd_mem_operand_p): Require
+   the operand to be a legitimate memory_operand.
+
+2024-07-22  Jeff Law  
+
+   PR rtl-optimization/115877
+   * ext-dce.cc (group_limit): New function.
+   (mark_reg_live): Likewise.
+   (ext_dce_process_sets): Use new functions.
+   (ext_dce_process_uses): Likewise.
+   (ext_dce_init): Likewise.
+
+2024-07-22  Richard Biener  
+
+   * fold-const.cc (operand_compare::hash_operand): Fix hash
+   of WIDEN_*_EXPR.
+
+2024-07-22  Richard Biener  
+
+   * inchash.h (inchash::end): Make const.
+   (inchash::merge): Take const reference hash argument.
+   (inchash::add_commutative): Likewise.
+
+2024-07-22 

[gcc/devel/fortran_unsigned] RISC-V: Implement the .SAT_TRUNC for scalar

2024-07-28 Thread Thomas Kテカnig via Gcc-cvs
https://gcc.gnu.org/g:46e5eb062eda5bfdd0b416c32983769091b75947

commit 46e5eb062eda5bfdd0b416c32983769091b75947
Author: Pan Li 
Date:   Mon Jul 1 16:36:35 2024 +0800

RISC-V: Implement the .SAT_TRUNC for scalar

This patch would like to implement the simple .SAT_TRUNC pattern
in the riscv backend. Aka:

Form 1:
  #define DEF_SAT_U_TRUC_FMT_1(NT, WT) \
  NT __attribute__((noinline)) \
  sat_u_truc_##WT##_to_##NT##_fmt_1 (WT x) \
  {\
bool overflow = x > (WT)(NT)(-1);  \
return ((NT)x) | (NT)-overflow;\
  }

DEF_SAT_U_TRUC_FMT_1(uint32_t, uint64_t)

Before this patch:
__attribute__((noinline))
uint8_t sat_u_truc_uint16_t_to_uint8_t_fmt_1 (uint16_t x)
{
  _Bool overflow;
  unsigned char _1;
  unsigned char _2;
  unsigned char _3;
  uint8_t _6;

;;   basic block 2, loop depth 0
;;pred:   ENTRY
  overflow_5 = x_4(D) > 255;
  _1 = (unsigned char) x_4(D);
  _2 = (unsigned char) overflow_5;
  _3 = -_2;
  _6 = _1 | _3;
  return _6;
;;succ:   EXIT

}

After this patch:
__attribute__((noinline))
uint8_t sat_u_truc_uint16_t_to_uint8_t_fmt_1 (uint16_t x)
{
  uint8_t _6;

;;   basic block 2, loop depth 0
;;pred:   ENTRY
  _6 = .SAT_TRUNC (x_4(D)); [tail call]
  return _6;
;;succ:   EXIT

}

The below tests suites are passed for this patch
1. The rv64gcv fully regression test.
2. The rv64gcv build with glibc

gcc/ChangeLog:

* config/riscv/iterators.md (ANYI_DOUBLE_TRUNC): Add new iterator
for int double truncation.
(ANYI_DOUBLE_TRUNCATED): Add new attr for int double truncation.
(anyi_double_truncated): Ditto but for lowercase.
* config/riscv/riscv-protos.h (riscv_expand_ustrunc): Add new
func decl for expanding ustrunc
* config/riscv/riscv.cc (riscv_expand_ustrunc): Add new func
impl to expand ustrunc.
* config/riscv/riscv.md (ustrunc2): 
Impl
the new pattern ustrunc2 for int.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/sat_arith.h: Add test helper macro.
* gcc.target/riscv/sat_arith_data.h: New test.
* gcc.target/riscv/sat_u_trunc-1.c: New test.
* gcc.target/riscv/sat_u_trunc-2.c: New test.
* gcc.target/riscv/sat_u_trunc-3.c: New test.
* gcc.target/riscv/sat_u_trunc-run-1.c: New test.
* gcc.target/riscv/sat_u_trunc-run-2.c: New test.
* gcc.target/riscv/sat_u_trunc-run-3.c: New test.
* gcc.target/riscv/scalar_sat_unary.h: New test.

Signed-off-by: Pan Li 

Diff:
---
 gcc/config/riscv/iterators.md  | 10 
 gcc/config/riscv/riscv-protos.h|  1 +
 gcc/config/riscv/riscv.cc  | 40 
 gcc/config/riscv/riscv.md  | 10 
 gcc/testsuite/gcc.target/riscv/sat_arith.h | 16 +++
 gcc/testsuite/gcc.target/riscv/sat_arith_data.h| 56 ++
 gcc/testsuite/gcc.target/riscv/sat_u_trunc-1.c | 17 +++
 gcc/testsuite/gcc.target/riscv/sat_u_trunc-2.c | 20 
 gcc/testsuite/gcc.target/riscv/sat_u_trunc-3.c | 19 
 gcc/testsuite/gcc.target/riscv/sat_u_trunc-run-1.c | 16 +++
 gcc/testsuite/gcc.target/riscv/sat_u_trunc-run-2.c | 16 +++
 gcc/testsuite/gcc.target/riscv/sat_u_trunc-run-3.c | 16 +++
 gcc/testsuite/gcc.target/riscv/scalar_sat_unary.h  | 22 +
 13 files changed, 259 insertions(+)

diff --git a/gcc/config/riscv/iterators.md b/gcc/config/riscv/iterators.md
index d61ed53a8b1b..734da041f0cb 100644
--- a/gcc/config/riscv/iterators.md
+++ b/gcc/config/riscv/iterators.md
@@ -65,6 +65,16 @@
 ;; Iterator for hardware-supported integer modes.
 (define_mode_iterator ANYI [QI HI SI (DI "TARGET_64BIT")])
 
+(define_mode_iterator ANYI_DOUBLE_TRUNC [HI SI (DI "TARGET_64BIT")])
+
+(define_mode_attr ANYI_DOUBLE_TRUNCATED [
+  (HI "QI") (SI "HI") (DI "SI")
+])
+
+(define_mode_attr anyi_double_truncated [
+  (HI "qi") (SI "hi") (DI "si")
+])
+
 ;; Iterator for hardware-supported floating-point modes.
 (define_mode_iterator ANYF [(SF "TARGET_HARD_FLOAT || TARGET_ZFINX")
(DF "TARGET_DOUBLE_FLOAT || TARGET_ZDINX")
diff --git a/gcc/config/riscv/riscv-protos.h b/gcc/config/riscv/riscv-protos.h
index 7c0ea1b445b1..ce5e38d3dbbf 100644
--- a/gcc/config/riscv/riscv-protos.h
+++ b/gcc/config/riscv/riscv-protos.h
@@ -135,6 +135,7 @@ riscv_zcmp_valid_stack_adj_bytes_p (HOST_WIDE_INT, int);
 extern void riscv_legitimize_poly_move (machine_mode, rtx, rtx, rtx);
 extern void riscv_expand_usadd (rtx, rtx, rtx);
 extern void riscv_expand_ussub (rtx, rtx, rtx);
+extern void riscv_ex

[gcc/devel/fortran_unsigned] c++/coroutines: correct passing *this to promise type [PR104981]

2024-07-28 Thread Thomas Kテカnig via Gcc-cvs
https://gcc.gnu.org/g:78f1f323ffbd45edf3faafb8f66b76f627c5b460

commit 78f1f323ffbd45edf3faafb8f66b76f627c5b460
Author: Patrick Palka 
Date:   Mon Jul 22 21:30:49 2024 -0400

c++/coroutines: correct passing *this to promise type [PR104981]

When passing *this to the promise type ctor (or to its operator new)
(as per [dcl.fct.def.coroutine]/4), we add an explicit cast to lvalue
reference.  But this is unnecessary since *this is already always an
lvalue.  And doing so means we need to call convert_from_reference
afterward to lower the reference expression to an implicit dereference,
which we're currently neglecting to do and which causes overload
resolution to get confused when computing argument conversions.

So this patch removes this unneeded reference cast when passing *this
to the promise ctor, and removes both the cast and implicit deref when
passing *this to operator new, for consistency.  While we're here, use
cp_build_fold_indirect_ref instead of directly building INDIRECT_REF.

PR c++/104981
PR c++/115550

gcc/cp/ChangeLog:

* coroutines.cc (morph_fn_to_coro): Remove unneeded calls
to convert_to_reference and convert_from_reference when
passing *this.  Use cp_build_fold_indirect_ref instead
of directly building INDIRECT_REF.

gcc/testsuite/ChangeLog:

* g++.dg/coroutines/pr104981-preview-this.C: New test.
* g++.dg/coroutines/pr115550-preview-this.C: New test.

Reviewed-by: Iain Sandoe 
Reviewed-by: Jason Merrill 

Diff:
---
 gcc/cp/coroutines.cc   | 18 ++---
 .../g++.dg/coroutines/pr104981-preview-this.C  | 34 
 .../g++.dg/coroutines/pr115550-preview-this.C  | 47 ++
 3 files changed, 84 insertions(+), 15 deletions(-)

diff --git a/gcc/cp/coroutines.cc b/gcc/cp/coroutines.cc
index f350fc33e9b4..e8f028df3adb 100644
--- a/gcc/cp/coroutines.cc
+++ b/gcc/cp/coroutines.cc
@@ -4620,13 +4620,8 @@ morph_fn_to_coro (tree orig, tree *resumer, tree 
*destroyer)
  if (parm_i->this_ptr || parm_i->lambda_cobj)
{
  /* We pass a reference to *this to the allocator lookup.  */
- tree tt = TREE_TYPE (TREE_TYPE (arg));
- tree this_ref = build1 (INDIRECT_REF, tt, arg);
- tt = cp_build_reference_type (tt, false);
- this_ref = convert_to_reference (tt, this_ref, CONV_STATIC,
-  LOOKUP_NORMAL , NULL_TREE,
-  tf_warning_or_error);
- vec_safe_push (args, convert_from_reference (this_ref));
+ tree this_ref = cp_build_fold_indirect_ref (arg);
+ vec_safe_push (args, this_ref);
}
  else
vec_safe_push (args, convert_from_reference (arg));
@@ -4845,14 +4840,7 @@ morph_fn_to_coro (tree orig, tree *resumer, tree 
*destroyer)
  if (parm.this_ptr || parm.lambda_cobj)
{
  /* We pass a reference to *this to the param preview.  */
- tree tt = TREE_TYPE (arg);
- gcc_checking_assert (POINTER_TYPE_P (tt));
- tree ct = TREE_TYPE (tt);
- tree this_ref = build1 (INDIRECT_REF, ct, arg);
- tree rt = cp_build_reference_type (ct, false);
- this_ref = convert_to_reference (rt, this_ref, CONV_STATIC,
-  LOOKUP_NORMAL, NULL_TREE,
-  tf_warning_or_error);
+ tree this_ref = cp_build_fold_indirect_ref (arg);
  vec_safe_push (promise_args, this_ref);
}
  else if (parm.rv_ref)
diff --git a/gcc/testsuite/g++.dg/coroutines/pr104981-preview-this.C 
b/gcc/testsuite/g++.dg/coroutines/pr104981-preview-this.C
new file mode 100644
index ..81eb963db4a5
--- /dev/null
+++ b/gcc/testsuite/g++.dg/coroutines/pr104981-preview-this.C
@@ -0,0 +1,34 @@
+// PR c++/104981 - ICE from convert_to_base when passing *this to promise ctor
+
+#include 
+
+class Base {};
+
+struct PromiseType;
+
+struct Result {
+ using promise_type = PromiseType;
+};
+
+struct PromiseType {
+  PromiseType(const Base& parser, auto&&...) {}
+
+  Result get_return_object() { return {}; }
+
+  static std::suspend_never initial_suspend() { return {}; }
+  static std::suspend_always final_suspend() noexcept { return {}; }
+  [[noreturn]] static void unhandled_exception() { throw; }
+
+  void return_value(int) {}
+};
+
+struct Derived : Base {
+  Result f() {
+   co_return 42;
+  }
+};
+
+int main() {
+  Derived d;
+  d.f();
+}
diff --git a/gcc/testsuite/g++.dg/coroutines/pr115550-preview-this.C 
b/gcc/testsuite/g++.dg/coroutines/pr115550-preview-this.C
new file mode 100644
index ..f62c07096b61
--- /dev/null
+++ b/gcc/testsuite/g++.dg/coroutines/pr115550-

[gcc/devel/fortran_unsigned] [powerpc] [testsuite] reorder dg directives [PR106069]

2024-07-28 Thread Thomas Kテカnig via Gcc-cvs
https://gcc.gnu.org/g:5b224c1d75382064c98da0ee73af741c4f96d275

commit 5b224c1d75382064c98da0ee73af741c4f96d275
Author: Alexandre Oliva 
Date:   Mon Jul 22 23:09:24 2024 -0300

[powerpc] [testsuite] reorder dg directives [PR106069]

The dg-do directive appears after dg-require-effective-target in
g++.target/powerpc/pr106069.C.  That doesn't work the way that was
presumably intended.  Both of these directives set dg-do-what, but
dg-do does so fully and unconditionally, overriding any decisions
recorded there by earlier directives.  Reorder the directives more
canonically, so that both take effect.


for  gcc/testsuite/ChangeLog

PR target/106069
* g++.target/powerpc/pr106069.C: Reorder dg directives.

Diff:
---
 gcc/testsuite/g++.target/powerpc/pr106069.C | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/testsuite/g++.target/powerpc/pr106069.C 
b/gcc/testsuite/g++.target/powerpc/pr106069.C
index 537207d2fe83..826379a4479a 100644
--- a/gcc/testsuite/g++.target/powerpc/pr106069.C
+++ b/gcc/testsuite/g++.target/powerpc/pr106069.C
@@ -1,6 +1,6 @@
+/* { dg-do run } */
 /* { dg-options "-O -fno-tree-forwprop -maltivec" } */
 /* { dg-require-effective-target vmx_hw } */
-/* { dg-do run } */
 
 typedef __attribute__ ((altivec (vector__))) unsigned native_simd_type;


[gcc/devel/fortran_unsigned] [5/n][PR rtl-optimization/115877] Fix handling of input/output operands

2024-07-28 Thread Thomas Kテカnig via Gcc-cvs
https://gcc.gnu.org/g:aa6cfa75bcdd8637f270d1a91ae8ee382e4bf0b8

commit aa6cfa75bcdd8637f270d1a91ae8ee382e4bf0b8
Author: Jeff Law 
Date:   Mon Jul 22 21:48:28 2024 -0600

[5/n][PR rtl-optimization/115877] Fix handling of input/output operands

So in this patch we're correcting a failure to mark objects live in 
scenarios
like

(set (dest) (plus (dest) (src))

When handling set pseudos, we transfer the liveness information from LIVENOW
into LIVE_TMP.  LIVE_TMP is subsequently used to narrow what bit groups are
live for the inputs.

The first time we process the block we may not have DEST in the LIVENOW set 
(it
may be live across the loop, but not live after the loop).  Thus we can 
totally
miss making certain objects live, resulting in incorrect code.

The fix is pretty simple.  If LIVE_TMP is empty, then we should go ahead and
mark all the bit groups for the set object in LIVE_TMP.  This also removes 
an
invalid gcc_assert on the state of the liveness bitmaps.

This showed up on pru, rl78 and/or msp430 in the testsuite.  So no new test.

Bootstrapped and regression tested on x86_64 and also run through my tester 
on
all the cross platforms.

Pushing to the trunk.

PR rtl-optimization/115877
gcc/
* ext-dce.cc (ext_dce_process_sets): Reasonably handle input/output
operands.
(ext_dce_rd_transfer_n): Drop bogus assertion.

Diff:
---
 gcc/ext-dce.cc | 31 ++-
 1 file changed, 26 insertions(+), 5 deletions(-)

diff --git a/gcc/ext-dce.cc b/gcc/ext-dce.cc
index 21feabd9ce31..c56dfb505b88 100644
--- a/gcc/ext-dce.cc
+++ b/gcc/ext-dce.cc
@@ -245,13 +245,25 @@ ext_dce_process_sets (rtx_insn *insn, rtx obj, bitmap 
live_tmp)
  continue;
}
 
- /* Transfer all the LIVENOW bits for X into LIVE_TMP.  */
+ /* LIVE_TMP contains the set groups that are live-out and set in
+this insn.  It is used to narrow the groups live-in for the
+inputs of this insn.
+
+The simple thing to do is mark all the groups as live, but
+that will significantly inhibit optimization.
+
+We also need to be careful in the case where we have an in-out
+operand.  If we're not careful we'd clear LIVE_TMP
+incorrectly.  */
  HOST_WIDE_INT rn = REGNO (SUBREG_REG (x));
  int limit = group_limit (SUBREG_REG (x));
  for (HOST_WIDE_INT i = 4 * rn; i < 4 * rn + limit; i++)
if (bitmap_bit_p (livenow, i))
  bitmap_set_bit (live_tmp, i);
 
+ if (bitmap_empty_p (live_tmp))
+   make_reg_live (live_tmp, rn);
+
  /* The mode of the SUBREG tells us how many bits we can
 clear.  */
  machine_mode mode = GET_MODE (x);
@@ -316,14 +328,25 @@ ext_dce_process_sets (rtx_insn *insn, rtx obj, bitmap 
live_tmp)
  /* Now handle the actual object that was changed.  */
  if (REG_P (x))
{
- /* Transfer the appropriate bits from LIVENOW into
-LIVE_TMP.  */
+ /* LIVE_TMP contains the set groups that are live-out and set in
+this insn.  It is used to narrow the groups live-in for the
+inputs of this insn.
+
+The simple thing to do is mark all the groups as live, but
+that will significantly inhibit optimization.
+
+We also need to be careful in the case where we have an in-out
+operand.  If we're not careful we'd clear LIVE_TMP
+incorrectly.  */
  HOST_WIDE_INT rn = REGNO (x);
  int limit = group_limit (x);
  for (HOST_WIDE_INT i = 4 * rn; i < 4 * rn + limit; i++)
if (bitmap_bit_p (livenow, i))
  bitmap_set_bit (live_tmp, i);
 
+ if (bitmap_empty_p (live_tmp))
+   make_reg_live (live_tmp, rn);
+
  /* Now clear the bits known written by this instruction.
 Note that BIT need not be a power of two, consider a
 ZERO_EXTRACT destination.  */
@@ -935,8 +958,6 @@ ext_dce_rd_transfer_n (int bb_index)
  the generic dataflow code that something changed.  */
   if (!bitmap_equal_p (&livein[bb_index], livenow))
 {
-  gcc_assert (!bitmap_intersect_compl_p (&livein[bb_index], livenow));
-
   bitmap_copy (&livein[bb_index], livenow);
   return true;
 }


[gcc/devel/fortran_unsigned] i386: Change prefetchi output template

2024-07-28 Thread Thomas Kテカnig via Gcc-cvs
https://gcc.gnu.org/g:150f5707ca5506917504631d60cd0b060019a778

commit 150f5707ca5506917504631d60cd0b060019a778
Author: Haochen Jiang 
Date:   Mon Jul 22 14:06:18 2024 +0800

i386: Change prefetchi output template

For prefetchi instructions, RIP-relative address is explicitly mentioned
for operand and assembler obeys that rule strictly. This makes
instruction like:

prefetchit0 bar

got illegal for assembler, which should be a broad usage for prefetchi.

Change to %a to explicitly add (%rip) after function label to make it
legal in assembler so that it could pass to linker to get the real address.

gcc/ChangeLog:

* config/i386/i386.md (prefetchi): Change to %a.

gcc/testsuite/ChangeLog:

* gcc.target/i386/prefetchi-1.c: Check (%rip).

Diff:
---
 gcc/config/i386/i386.md | 2 +-
 gcc/testsuite/gcc.target/i386/prefetchi-1.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md
index 90d3aa450f05..6207036a2a01 100644
--- a/gcc/config/i386/i386.md
+++ b/gcc/config/i386/i386.md
@@ -28004,7 +28004,7 @@
   "TARGET_PREFETCHI && TARGET_64BIT"
 {
   static const char * const patterns[2] = {
-"prefetchit1\t%0", "prefetchit0\t%0"
+"prefetchit1\t%a0", "prefetchit0\t%a0"
   };
 
   int locality = INTVAL (operands[1]);
diff --git a/gcc/testsuite/gcc.target/i386/prefetchi-1.c 
b/gcc/testsuite/gcc.target/i386/prefetchi-1.c
index 80f25e70e8e3..03dfdc55e86c 100644
--- a/gcc/testsuite/gcc.target/i386/prefetchi-1.c
+++ b/gcc/testsuite/gcc.target/i386/prefetchi-1.c
@@ -1,7 +1,7 @@
 /* { dg-do compile { target { ! ia32 } } } */
 /* { dg-options "-mprefetchi -O2" } */
-/* { dg-final { scan-assembler-times "\[ \\t\]+prefetchit0\[ \\t\]+" 2 } } */
-/* { dg-final { scan-assembler-times "\[ \\t\]+prefetchit1\[ \\t\]+" 2 } } */
+/* { dg-final { scan-assembler-times "\[ \\t\]+prefetchit0\[ 
\\t\]+bar\\(%rip\\)" 2 } } */
+/* { dg-final { scan-assembler-times "\[ \\t\]+prefetchit1\[ 
\\t\]+bar\\(%rip\\)" 2 } } */
 
 #include 


[gcc/devel/fortran_unsigned] rs6000: Consider explicitly set options in target option parsing [PR115713]

2024-07-28 Thread Thomas Kテカnig via Gcc-cvs
https://gcc.gnu.org/g:a5013a17cbf984c4db9f9e518816a5fe42e4a1ba

commit a5013a17cbf984c4db9f9e518816a5fe42e4a1ba
Author: Kewen Lin 
Date:   Tue Jul 23 00:48:00 2024 -0500

rs6000: Consider explicitly set options in target option parsing [PR115713]

In rs6000_inner_target_options, when enabling VSX we enable
altivec and disable -mavoid-indexed-addresses implicitly,
but it doesn't consider the case that the options altivec
and avoid-indexed-addresses can be explicitly disabled.  As
the test case in PR115713#c1 shows, with target attribute
"no-altivec,vsx", it results in that VSX unexpectedly set
altivec flag and there isn't an expected error.

This patch is to avoid the automatic enablement when they
are explicitly specified.  With this change, an existing
test case ppc-target-4.c also requires an adjustment by
specifying explicit altivec in target attribute (since it
requires altivec feature and command line is specifying
no-altivec).

PR target/115713

gcc/ChangeLog:

* config/rs6000/rs6000.cc (rs6000_inner_target_options): Avoid to
enable altivec or disable avoid-indexed-addresses automatically
when they get specified explicitly.

gcc/testsuite/ChangeLog:

* gcc.target/powerpc/pr115713-1.c: New test.
* gcc.target/powerpc/ppc-target-4.c: Adjust by specifying altivec
in target attribute.

Diff:
---
 gcc/config/rs6000/rs6000.cc |  7 +--
 gcc/testsuite/gcc.target/powerpc/ppc-target-4.c |  2 +-
 gcc/testsuite/gcc.target/powerpc/pr115713-1.c   | 20 
 3 files changed, 26 insertions(+), 3 deletions(-)

diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc
index 019bb7ccc380..ce888d3caa65 100644
--- a/gcc/config/rs6000/rs6000.cc
+++ b/gcc/config/rs6000/rs6000.cc
@@ -24669,8 +24669,11 @@ rs6000_inner_target_options (tree args, bool attr_p)
  {
if (mask == OPTION_MASK_VSX)
  {
-   mask |= OPTION_MASK_ALTIVEC;
-   TARGET_AVOID_XFORM = 0;
+   if (!(rs6000_isa_flags_explicit
+ & OPTION_MASK_ALTIVEC))
+ mask |= OPTION_MASK_ALTIVEC;
+   if (!OPTION_SET_P (TARGET_AVOID_XFORM))
+ TARGET_AVOID_XFORM = 0;
  }
  }
 
diff --git a/gcc/testsuite/gcc.target/powerpc/ppc-target-4.c 
b/gcc/testsuite/gcc.target/powerpc/ppc-target-4.c
index 43a98b353cf7..db9ba500e0e1 100644
--- a/gcc/testsuite/gcc.target/powerpc/ppc-target-4.c
+++ b/gcc/testsuite/gcc.target/powerpc/ppc-target-4.c
@@ -18,7 +18,7 @@
 #error "__VSX__ should not be defined."
 #endif
 
-#pragma GCC target("vsx")
+#pragma GCC target("altivec,vsx")
 #include 
 #pragma GCC reset_options
 
diff --git a/gcc/testsuite/gcc.target/powerpc/pr115713-1.c 
b/gcc/testsuite/gcc.target/powerpc/pr115713-1.c
new file mode 100644
index ..1b93a78682a0
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/pr115713-1.c
@@ -0,0 +1,20 @@
+/* { dg-do compile } */
+/* Force power7 to avoid possible error message on AltiVec ABI change.  */
+/* { dg-options "-mdejagnu-cpu=power7" } */
+
+/* Verify there is an error message for incompatible -maltivec and -mvsx
+   even when they are specified by target attributes.  */
+
+int __attribute__ ((target ("no-altivec,vsx")))
+test1 (void)
+{
+  /* { dg-error "'-mvsx' and '-mno-altivec' are incompatible" "" { target 
*-*-* } .-1 } */
+  return 0;
+}
+
+int __attribute__ ((target ("vsx,no-altivec")))
+test2 (void)
+{
+  /* { dg-error "'-mvsx' and '-mno-altivec' are incompatible" "" { target 
*-*-* } .-1 } */
+  return 0;
+}


[gcc/devel/fortran_unsigned] rs6000: Escalate warning to error for VSX with explicit no-altivec etc.

2024-07-28 Thread Thomas Kテカnig via Gcc-cvs
https://gcc.gnu.org/g:8237d37d294b70c81ae95f72c1e2c814cf1369f2

commit 8237d37d294b70c81ae95f72c1e2c814cf1369f2
Author: Kewen Lin 
Date:   Tue Jul 23 00:47:49 2024 -0500

rs6000: Escalate warning to error for VSX with explicit no-altivec etc.

As the discussion in PR115688, for now when users specify
-mvsx and -mno-altivec explicitly, compiler emits warning
rather than error, but considering both options are given
explicitly, emitting hard error should be better.

So this patch is to escalate some related warning to error
when both are incompatible.

PR target/115713

gcc/ChangeLog:

* config/rs6000/rs6000.cc (rs6000_option_override_internal): Emit 
error
messages when explicit VSX encounters explicit soft-float, 
no-altivec
or avoid-indexed-addresses.

gcc/testsuite/ChangeLog:

* gcc.target/powerpc/warn-1.c: Move to ...
* gcc.target/powerpc/error-1.c: ... here.  Adjust dg-warning with
dg-error and remove ineffective scan.

Diff:
---
 gcc/config/rs6000/rs6000.cc| 41 --
 .../gcc.target/powerpc/{warn-1.c => error-1.c} |  3 +-
 2 files changed, 24 insertions(+), 20 deletions(-)

diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc
index eddd2adbab59..019bb7ccc380 100644
--- a/gcc/config/rs6000/rs6000.cc
+++ b/gcc/config/rs6000/rs6000.cc
@@ -3830,32 +3830,37 @@ rs6000_option_override_internal (bool global_init_p)
   /* Add some warnings for VSX.  */
   if (TARGET_VSX)
 {
-  const char *msg = NULL;
+  bool explicit_vsx_p = rs6000_isa_flags_explicit & OPTION_MASK_VSX;
   if (!TARGET_HARD_FLOAT)
{
- if (rs6000_isa_flags_explicit & OPTION_MASK_VSX)
-   msg = N_("%<-mvsx%> requires hardware floating point");
- else
+ if (explicit_vsx_p)
{
- rs6000_isa_flags &= ~ OPTION_MASK_VSX;
- rs6000_isa_flags_explicit |= OPTION_MASK_VSX;
+ if (rs6000_isa_flags_explicit & OPTION_MASK_SOFT_FLOAT)
+   error ("%<-mvsx%> and %<-msoft-float%> are incompatible");
+ else
+   warning (0, N_("%<-mvsx%> requires hardware floating-point"));
}
+ rs6000_isa_flags &= ~OPTION_MASK_VSX;
+ rs6000_isa_flags_explicit |= OPTION_MASK_VSX;
}
   else if (TARGET_AVOID_XFORM > 0)
-   msg = N_("%<-mvsx%> needs indexed addressing");
-  else if (!TARGET_ALTIVEC && (rs6000_isa_flags_explicit
-  & OPTION_MASK_ALTIVEC))
-{
- if (rs6000_isa_flags_explicit & OPTION_MASK_VSX)
-   msg = N_("%<-mvsx%> and %<-mno-altivec%> are incompatible");
+   {
+ if (explicit_vsx_p && OPTION_SET_P (TARGET_AVOID_XFORM))
+   error ("%<-mvsx%> and %<-mavoid-indexed-addresses%>"
+  " are incompatible");
  else
-   msg = N_("%<-mno-altivec%> disables vsx");
-}
-
-  if (msg)
+   warning (0, N_("%<-mvsx%> needs indexed addressing"));
+ rs6000_isa_flags &= ~OPTION_MASK_VSX;
+ rs6000_isa_flags_explicit |= OPTION_MASK_VSX;
+   }
+  else if (!TARGET_ALTIVEC
+  && (rs6000_isa_flags_explicit & OPTION_MASK_ALTIVEC))
{
- warning (0, msg);
- rs6000_isa_flags &= ~ OPTION_MASK_VSX;
+ if (explicit_vsx_p)
+   error ("%<-mvsx%> and %<-mno-altivec%> are incompatible");
+ else
+   warning (0, N_("%<-mno-altivec%> disables vsx"));
+ rs6000_isa_flags &= ~OPTION_MASK_VSX;
  rs6000_isa_flags_explicit |= OPTION_MASK_VSX;
}
 }
diff --git a/gcc/testsuite/gcc.target/powerpc/warn-1.c 
b/gcc/testsuite/gcc.target/powerpc/error-1.c
similarity index 70%
rename from gcc/testsuite/gcc.target/powerpc/warn-1.c
rename to gcc/testsuite/gcc.target/powerpc/error-1.c
index 76ac0c4e26e5..d38eba8bb8ad 100644
--- a/gcc/testsuite/gcc.target/powerpc/warn-1.c
+++ b/gcc/testsuite/gcc.target/powerpc/error-1.c
@@ -3,7 +3,7 @@
 /* { dg-require-effective-target powerpc_vsx_ok } */
 /* { dg-options "-O -mvsx -mno-altivec" } */
 
-/* { dg-warning "'-mvsx' and '-mno-altivec' are incompatible" "" { target 
*-*-* } 0 } */
+/* { dg-error "'-mvsx' and '-mno-altivec' are incompatible" "" { target *-*-* 
} 0 } */
 
 double
 foo (double *x, double *y)
@@ -16,4 +16,3 @@ foo (double *x, double *y)
   return z[0] * z[1];
 }
 
-/* { dg-final { scan-assembler-not "xsadddp" } } */


[gcc/devel/fortran_unsigned] rs6000: Update option set in rs6000_inner_target_options [PR115713]

2024-07-28 Thread Thomas Kテカnig via Gcc-cvs
https://gcc.gnu.org/g:21a8e13ba60e91190bcdc9bc18ef222e8144bd5b

commit 21a8e13ba60e91190bcdc9bc18ef222e8144bd5b
Author: Kewen Lin 
Date:   Tue Jul 23 00:48:14 2024 -0500

rs6000: Update option set in rs6000_inner_target_options [PR115713]

When function rs6000_inner_target_options parsing target
options, it updates the explicit option set information for
rs6000_opt_masks by rs6000_isa_flags_explicit, but it misses
to update that information for rs6000_opt_vars, and it can
result in some unexpected consequence as the associated test
case shows.  This patch is to fix rs6000_inner_target_options
to update the option set for rs6000_opt_vars as well.

PR target/115713

gcc/ChangeLog:

* config/rs6000/rs6000.cc (rs6000_inner_target_options): Update 
option
set information for rs6000_opt_vars.

gcc/testsuite/ChangeLog:

* gcc.target/powerpc/pr115713-2.c: New test.

Diff:
---
 gcc/config/rs6000/rs6000.cc   |  3 ++-
 gcc/testsuite/gcc.target/powerpc/pr115713-2.c | 22 ++
 2 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc
index ce888d3caa65..85211565eb4c 100644
--- a/gcc/config/rs6000/rs6000.cc
+++ b/gcc/config/rs6000/rs6000.cc
@@ -24694,7 +24694,8 @@ rs6000_inner_target_options (tree args, bool attr_p)
if (strcmp (r, rs6000_opt_vars[i].name) == 0)
  {
size_t j = rs6000_opt_vars[i].global_offset;
-   *((int *) ((char *)&global_options + j)) = !invert;
+   *((int *) ((char *) &global_options + j)) = !invert;
+   *((int *) ((char *) &global_options_set + j)) = 1;
error_p = false;
not_valid_p = false;
break;
diff --git a/gcc/testsuite/gcc.target/powerpc/pr115713-2.c 
b/gcc/testsuite/gcc.target/powerpc/pr115713-2.c
new file mode 100644
index ..47b39c0fabaf
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/pr115713-2.c
@@ -0,0 +1,22 @@
+/* { dg-do compile } */
+/* Force power7 to avoid possible error message on AltiVec ABI change.  */
+/* { dg-options "-mdejagnu-cpu=power7" } */
+
+/* Verify there is an error message for -mvsx incompatible with
+   -mavoid-indexed-addresses even when they are specified by
+   target attributes.  */
+
+int __attribute__ ((target ("avoid-indexed-addresses,vsx")))
+test1 (void)
+{
+  /* { dg-error "'-mvsx' and '-mavoid-indexed-addresses' are incompatible" "" 
{ target *-*-* } .-1 } */
+  return 0;
+}
+
+int __attribute__ ((target ("vsx,avoid-indexed-addresses")))
+test2 (void)
+{
+  /* { dg-error "'-mvsx' and '-mavoid-indexed-addresses' are incompatible" "" 
{ target *-*-* } .-1 } */
+  return 0;
+}
+


[gcc/devel/fortran_unsigned] Relax ix86_hardreg_mov_ok after split1.

2024-07-28 Thread Thomas Kテカnig via Gcc-cvs
https://gcc.gnu.org/g:a3fd4dc978b35efed5a4da1c0a1dfbb4cb6e7e92

commit a3fd4dc978b35efed5a4da1c0a1dfbb4cb6e7e92
Author: liuhongt 
Date:   Mon Jul 22 11:36:59 2024 +0800

Relax ix86_hardreg_mov_ok after split1.

ix86_hardreg_mov_ok is added by r11-5066-gbe39636d9f68c4

>The solution proposed here is to have the x86 backend/recog prevent
>early RTL passes composing instructions (that set likely_spilled hard
>registers) that they (combine) can't simplify, until after reload.
>We allow sets from pseudo registers, immediate constants and memory
>accesses, but anything more complicated is performed via a temporary
>pseudo.  Not only does this simplify things for the register allocator,
>but any remaining register-to-register moves are easily cleaned up
>by the late optimization passes after reload, such as peephole2 and
>cprop_hardreg.

The restriction is mainly for rtl optimization passes before pass_combine.

But split1 splits

```
(insn 17 13 18 2 (set (reg/i:V4SI 20 xmm0)
(vec_merge:V4SI (const_vector:V4SI [
(const_int -1 [0x]) repeated x4
])
(const_vector:V4SI [
(const_int 0 [0]) repeated x4
])
(unspec:QI [
(reg:V4SF 106)
(reg:V4SF 102)
(const_int 0 [0])
] UNSPEC_PCMP))) "/app/example.cpp":20:1 2929 
{*avx_cmpv4sf3_1}
 (expr_list:REG_DEAD (reg:V4SF 102)
(expr_list:REG_DEAD (reg:V4SF 106)
(nil
```

into:
```
(insn 23 13 24 2 (set (reg:V4SF 107)
(unspec:V4SF [
(reg:V4SF 106)
(reg:V4SF 102)
(const_int 0 [0])
] UNSPEC_PCMP)) "/app/example.cpp":20:1 -1
 (nil))
(insn 24 23 18 2 (set (reg/i:V4SI 20 xmm0)
(subreg:V4SI (reg:V4SF 107) 0)) "/app/example.cpp":20:1 -1
 (nil))
```

There're many splitters generating MOV insn with SUBREG and would have
same problem.
Instead of changing those splitters one by one, the patch relaxes
ix86_hard_mov_ok to allow mov subreg to hard register after
split1. ix86_pre_reload_split () is used to replace
!reload_completed && ira_in_progress.

gcc/ChangeLog:

* config/i386/i386.cc (ix86_hardreg_mov_ok): Relax mov subreg
to hard register after split1.

gcc/testsuite/ChangeLog:

* g++.target/i386/pr115982.C: New test.

Diff:
---
 gcc/config/i386/i386.cc  |  5 ++---
 gcc/testsuite/g++.target/i386/pr115982.C | 11 +++
 2 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/gcc/config/i386/i386.cc b/gcc/config/i386/i386.cc
index 9c2ebe74fc92..77c441893b40 100644
--- a/gcc/config/i386/i386.cc
+++ b/gcc/config/i386/i386.cc
@@ -20212,7 +20212,7 @@ ix86_class_likely_spilled_p (reg_class_t rclass)
 }
 
 /* Return true if a set of DST by the expression SRC should be allowed.
-   This prevents complex sets of likely_spilled hard regs before reload.  */
+   This prevents complex sets of likely_spilled hard regs before split1.  */
 
 bool
 ix86_hardreg_mov_ok (rtx dst, rtx src)
@@ -20224,8 +20224,7 @@ ix86_hardreg_mov_ok (rtx dst, rtx src)
   ? standard_sse_constant_p (src, GET_MODE (dst))
   : x86_64_immediate_operand (src, GET_MODE (dst)))
   && ix86_class_likely_spilled_p (REGNO_REG_CLASS (REGNO (dst)))
-  && !reload_completed
-  && !lra_in_progress)
+  && ix86_pre_reload_split ())
 return false;
   return true;
 }
diff --git a/gcc/testsuite/g++.target/i386/pr115982.C 
b/gcc/testsuite/g++.target/i386/pr115982.C
new file mode 100644
index ..4b91618405d5
--- /dev/null
+++ b/gcc/testsuite/g++.target/i386/pr115982.C
@@ -0,0 +1,11 @@
+/* { dg-do compile } */
+/* { dg-options "-mavx512vl -O2" } */
+
+typedef float VF __attribute__((__vector_size__(16)));
+typedef int VI __attribute__((__vector_size__(16)));
+
+VI
+foo (VF x)
+{
+  return !x;
+}


[gcc/devel/fortran_unsigned] [v2] rtl-optimization/116002 - cselib hash is bad

2024-07-28 Thread Thomas Kテカnig via Gcc-cvs
https://gcc.gnu.org/g:e818585e264728859ec375efca66998ff232ef9d

commit e818585e264728859ec375efca66998ff232ef9d
Author: Richard Biener 
Date:   Fri Jul 19 16:23:51 2024 +0200

[v2] rtl-optimization/116002 - cselib hash is bad

The following addresses the bad hash function of cselib which uses
integer plus for merging.  This causes a huge number of collisions
for the testcase in the PR and thus very large compile-time.

The following rewrites it to use inchash, eliding duplicate mixing
of RTX code and mode in some cases and more consistently avoiding
a return value of zero as well as treating zero as fatal.  An
important part is to preserve mixing of hashes of commutative
operators as commutative.

For cselib_hash_plus_const_int this removes the apparent attempt
of making sure to hash the same as a PLUS as cselib_hash_rtx makes
sure to dispatch to cselib_hash_plus_const_int consistently.

This reduces compile-time for the testcase in the PR from unknown
to 22s and for a reduced testcase from 73s to 9s.  There's another
pending patchset to improve the speed of inchash mixing, but it's
not in the profile for this testcase (PTA pops up now).

The generated code is equal.  I've also compared cc1 builds
with and without the patch and they are now commparing equal
after retaining commutative hashing for commutative operators.

PR rtl-optimization/116002
* cselib.cc (cselib_hash_rtx): Use inchash to get proper mixing.
Consistently avoid a zero return value when hashing successfully.
Consistently treat a zero hash value from recursing as fatal.
Use hashval_t where appropriate.
(cselib_hash_plus_const_int): Likewise.
(new_cselib_val): Use hashval_t.
(cselib_lookup_1): Likewise.

Diff:
---
 gcc/cselib.cc | 224 --
 1 file changed, 122 insertions(+), 102 deletions(-)

diff --git a/gcc/cselib.cc b/gcc/cselib.cc
index cbaab7d515cc..7beaca424244 100644
--- a/gcc/cselib.cc
+++ b/gcc/cselib.cc
@@ -51,7 +51,7 @@ static void unchain_one_value (cselib_val *);
 static void unchain_one_elt_list (struct elt_list **);
 static void unchain_one_elt_loc_list (struct elt_loc_list **);
 static void remove_useless_values (void);
-static unsigned int cselib_hash_rtx (rtx, int, machine_mode);
+static hashval_t cselib_hash_rtx (rtx, int, machine_mode);
 static cselib_val *new_cselib_val (unsigned int, machine_mode, rtx);
 static void add_mem_for_addr (cselib_val *, cselib_val *, rtx);
 static cselib_val *cselib_lookup_mem (rtx, int);
@@ -1244,7 +1244,7 @@ cselib_redundant_set_p (rtx set)
 /* Helper function for cselib_hash_rtx.  Arguments like for cselib_hash_rtx,
except that it hashes (plus:P x c).  */
 
-static unsigned int
+static hashval_t
 cselib_hash_plus_const_int (rtx x, HOST_WIDE_INT c, int create,
machine_mode memmode)
 {
@@ -1266,14 +1266,13 @@ cselib_hash_plus_const_int (rtx x, HOST_WIDE_INT c, int 
create,
   if (c == 0)
 return e->hash;
 
-  unsigned hash = (unsigned) PLUS + (unsigned) GET_MODE (x);
-  hash += e->hash;
-  unsigned int tem_hash = (unsigned) CONST_INT + (unsigned) VOIDmode;
-  tem_hash += ((unsigned) CONST_INT << 7) + (unsigned HOST_WIDE_INT) c;
-  if (tem_hash == 0)
-tem_hash = (unsigned int) CONST_INT;
-  hash += tem_hash;
-  return hash ? hash : 1 + (unsigned int) PLUS;
+  inchash::hash hash;
+  hash.add_int (PLUS);
+  hash.add_int (GET_MODE (x));
+  hash.merge_hash (e->hash);
+  hash.add_hwi (c);
+
+  return hash.end () ? hash.end () : 1 + (unsigned int) PLUS;
 }
 
 /* Hash an rtx.  Return 0 if we couldn't hash the rtx.
@@ -1298,7 +1297,7 @@ cselib_hash_plus_const_int (rtx x, HOST_WIDE_INT c, int 
create,
If the mode is important in any context, it must be checked specifically
in a comparison anyway, since relying on hash differences is unsafe.  */
 
-static unsigned int
+static hashval_t
 cselib_hash_rtx (rtx x, int create, machine_mode memmode)
 {
   cselib_val *e;
@@ -1306,10 +1305,11 @@ cselib_hash_rtx (rtx x, int create, machine_mode 
memmode)
   int i, j;
   enum rtx_code code;
   const char *fmt;
-  unsigned int hash = 0;
+  inchash::hash hash;
 
   code = GET_CODE (x);
-  hash += (unsigned) code + (unsigned) GET_MODE (x);
+  hash.add_int (code);
+  hash.add_int (GET_MODE (x));
 
   switch (code)
 {
@@ -1326,19 +1326,16 @@ cselib_hash_rtx (rtx x, int create, machine_mode 
memmode)
   return e->hash;
 
 case DEBUG_EXPR:
-  hash += ((unsigned) DEBUG_EXPR << 7)
- + DEBUG_TEMP_UID (DEBUG_EXPR_TREE_DECL (x));
-  return hash ? hash : (unsigned int) DEBUG_EXPR;
+  hash.add_int (DEBUG_TEMP_UID (DEBUG_EXPR_TREE_DECL (x)));
+  return hash.end () ? hash.end() : (unsigned int) DEBUG_EXPR;
 
 case DEBUG_IMPLICIT_PTR:
-  hash += ((unsigned) DEBUG_IMPLICIT_PTR << 7)
-  

[gcc/devel/fortran_unsigned] c++: Remove CHECK_CONSTR

2024-07-28 Thread Thomas Kテカnig via Gcc-cvs
https://gcc.gnu.org/g:6d116bc5f958054fca819ab38d40e1abefd74b2d

commit 6d116bc5f958054fca819ab38d40e1abefd74b2d
Author: Jakub Jelinek 
Date:   Tue Jul 23 10:39:08 2024 +0200

c++: Remove CHECK_CONSTR

On Mon, Jul 22, 2024 at 11:48:51AM -0400, Patrick Palka wrote:
> FWIW this tree code seems to be a vestige of the initial Concepts TS
> implementation and is effectively unused, we can remove it outright.

Here is a patch which removes that.

2024-07-23  Jakub Jelinek  

* cp-tree.def (CHECK_CONSTR): Remove.
* cp-tree.h (CHECK_CONSTR_CONCEPT, CHECK_CONSTR_ARGS): Remove.
* cp-objcp-common.cc (cp_common_init_ts): Don't handle CHECK_CONSTR.
* tree.cc (cp_tree_equal): Likewise.
* error.cc (dump_expr): Likewise.
* cxx-pretty-print.cc (cxx_pretty_printer::expression): Likewise.
(pp_cxx_check_constraint): Remove.
(pp_cxx_constraint): Don't handle CHECK_CONSTR.

Diff:
---
 gcc/cp/cp-objcp-common.cc  |  1 -
 gcc/cp/cp-tree.def |  8 
 gcc/cp/cp-tree.h   |  8 
 gcc/cp/cxx-pretty-print.cc | 28 
 gcc/cp/error.cc|  1 -
 gcc/cp/tree.cc |  5 -
 6 files changed, 51 deletions(-)

diff --git a/gcc/cp/cp-objcp-common.cc b/gcc/cp/cp-objcp-common.cc
index 86e0b49d46b8..cd379514991d 100644
--- a/gcc/cp/cp-objcp-common.cc
+++ b/gcc/cp/cp-objcp-common.cc
@@ -701,7 +701,6 @@ cp_common_init_ts (void)
   MARK_TS_EXP (UNARY_RIGHT_FOLD_EXPR);
 
   /* Constraints.  */
-  MARK_TS_EXP (CHECK_CONSTR);
   MARK_TS_EXP (COMPOUND_REQ);
   MARK_TS_EXP (CONJ_CONSTR);
   MARK_TS_EXP (DISJ_CONSTR);
diff --git a/gcc/cp/cp-tree.def b/gcc/cp/cp-tree.def
index a0a47c3950fa..18f75108c7bd 100644
--- a/gcc/cp/cp-tree.def
+++ b/gcc/cp/cp-tree.def
@@ -538,14 +538,6 @@ DEFTREECODE (ATOMIC_CONSTR, "atomic_constr", 
tcc_expression, 1)
 DEFTREECODE (CONJ_CONSTR, "conj_constr", tcc_expression, 2)
 DEFTREECODE (DISJ_CONSTR, "disj_constr", tcc_expression, 2)
 
-/* A check constraint represents the checking of a concept
-   C. It has two operands: the template defining the concept
-   and a sequence of template arguments.
-
-   CHECK_CONSTR_CONCEPT has the concept definition
-   CHECK_CONSTR_ARGS are the template arguments.   */
-DEFTREECODE (CHECK_CONSTR, "check_constr", tcc_expression, 2)
-
 /* The co_await expression is used to support coroutines.
 
   Op 0 is the cast expresssion (potentially modified by the
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index 609d8941cf72..76ac9c31763c 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -1723,14 +1723,6 @@ check_constraint_info (tree t)
 #define ATOMIC_CONSTR_EXPR(NODE) \
   CONSTR_EXPR (ATOMIC_CONSTR_CHECK (NODE))
 
-/* The concept of a concept check. */
-#define CHECK_CONSTR_CONCEPT(NODE) \
-  TREE_OPERAND (TREE_CHECK (NODE, CHECK_CONSTR), 0)
-
-/* The template arguments of a concept check. */
-#define CHECK_CONSTR_ARGS(NODE) \
-  TREE_OPERAND (TREE_CHECK (NODE, CHECK_CONSTR), 1)
-
 /* Whether a PARM_DECL represents a local parameter in a
requires-expression.  */
 #define CONSTRAINT_VAR_P(NODE) \
diff --git a/gcc/cp/cxx-pretty-print.cc b/gcc/cp/cxx-pretty-print.cc
index 806aebff174b..e690354e08e9 100644
--- a/gcc/cp/cxx-pretty-print.cc
+++ b/gcc/cp/cxx-pretty-print.cc
@@ -1257,7 +1257,6 @@ cxx_pretty_printer::expression (tree t)
   break;
 
 case ATOMIC_CONSTR:
-case CHECK_CONSTR:
 case CONJ_CONSTR:
 case DISJ_CONSTR:
   pp_cxx_constraint (this, t);
@@ -2815,29 +2814,6 @@ pp_cxx_nested_requirement (cxx_pretty_printer *pp, tree 
t)
   pp_cxx_semicolon (pp);
 }
 
-void
-pp_cxx_check_constraint (cxx_pretty_printer *pp, tree t)
-{
-  tree decl = CHECK_CONSTR_CONCEPT (t);
-  tree tmpl = DECL_TI_TEMPLATE (decl);
-  tree args = CHECK_CONSTR_ARGS (t);
-  tree id = build_nt (TEMPLATE_ID_EXPR, tmpl, args);
-
-  if (TREE_CODE (decl) == CONCEPT_DECL)
-pp->expression (id);
-  else if (VAR_P (decl))
-pp->expression (id);
-  else if (TREE_CODE (decl) == FUNCTION_DECL)
-{
-  tree call = build_vl_exp (CALL_EXPR, 2);
-  TREE_OPERAND (call, 0) = integer_two_node;
-  TREE_OPERAND (call, 1) = id;
-  pp->expression (call);
-}
-  else
-gcc_unreachable ();
-}
-
 /* Output the "[with ...]" clause for a parameter mapping of an atomic
constraint.   */
 
@@ -2917,10 +2893,6 @@ pp_cxx_constraint (cxx_pretty_printer *pp, tree t)
   pp_cxx_atomic_constraint (pp, t);
   break;
 
-case CHECK_CONSTR:
-  pp_cxx_check_constraint (pp, t);
-  break;
-
 case CONJ_CONSTR:
   pp_cxx_conjunction (pp, t);
   break;
diff --git a/gcc/cp/error.cc b/gcc/cp/error.cc
index 6d99cb277038..d80bac822ba2 100644
--- a/gcc/cp/error.cc
+++ b/gcc/cp/error.cc
@@ -3095,7 +3095,6 @@ dump_expr (cxx_pretty_printer *pp, tree t, int flags)
   break;
 
 case ATOMIC_CONSTR:
-case CHECK_CONSTR:
 case CONJ_CONSTR:
 case DISJ_CONSTR:
 

[gcc/devel/fortran_unsigned] ssa: Fix up maybe_rewrite_mem_ref_base complex type handling [PR116034]

2024-07-28 Thread Thomas Kテカnig via Gcc-cvs
https://gcc.gnu.org/g:caad1323a23c3933a9a29205f3602616cec0e879

commit caad1323a23c3933a9a29205f3602616cec0e879
Author: Jakub Jelinek 
Date:   Tue Jul 23 10:50:29 2024 +0200

ssa: Fix up maybe_rewrite_mem_ref_base complex type handling [PR116034]

The folding into REALPART_EXPR is correct, used only when the mem_offset
is zero, but for IMAGPART_EXPR it didn't check the exact offset value (just
that it is not 0).
The following patch fixes that by using IMAGPART_EXPR only if the offset
is right and using BITFIELD_REF or whatever else otherwise.

2024-07-23  Jakub Jelinek  
Andrew Pinski  

PR tree-optimization/116034
* tree-ssa.cc (maybe_rewrite_mem_ref_base): Only use IMAGPART_EXPR
if MEM_REF offset is equal to element type size.

* gcc.dg/pr116034.c: New test.

Diff:
---
 gcc/testsuite/gcc.dg/pr116034.c | 22 ++
 gcc/tree-ssa.cc |  5 -
 2 files changed, 26 insertions(+), 1 deletion(-)

diff --git a/gcc/testsuite/gcc.dg/pr116034.c b/gcc/testsuite/gcc.dg/pr116034.c
new file mode 100644
index ..9a31de034246
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr116034.c
@@ -0,0 +1,22 @@
+/* PR tree-optimization/116034 */
+/* { dg-do run } */
+/* { dg-options "-O1 -fno-strict-aliasing" } */
+
+int g;
+
+static inline int
+foo (_Complex unsigned short c)
+{
+  __builtin_memmove (&g, 1 + (char *) &c, 2);
+  return g;
+}
+
+int
+main ()
+{
+  if (__SIZEOF_SHORT__ == 2
+  && __CHAR_BIT__ == 8
+  && (foo (__BYTE_ORDER__ != __ORDER_BIG_ENDIAN__ ? 0x100 : 1)
+ != (__BYTE_ORDER__ != __ORDER_BIG_ENDIAN__ ? 1 : 0x100)))
+__builtin_abort ();
+}
diff --git a/gcc/tree-ssa.cc b/gcc/tree-ssa.cc
index 27ab9cfac823..f4fa4e98c5d0 100644
--- a/gcc/tree-ssa.cc
+++ b/gcc/tree-ssa.cc
@@ -1506,7 +1506,10 @@ maybe_rewrite_mem_ref_base (tree *tp, bitmap 
suitable_for_renaming)
}
   else if (TREE_CODE (TREE_TYPE (sym)) == COMPLEX_TYPE
   && useless_type_conversion_p (TREE_TYPE (*tp),
-TREE_TYPE (TREE_TYPE (sym
+TREE_TYPE (TREE_TYPE (sym)))
+  && (integer_zerop (TREE_OPERAND (*tp, 1))
+  || tree_int_cst_equal (TREE_OPERAND (*tp, 1),
+ TYPE_SIZE_UNIT (TREE_TYPE (*tp)
{
  *tp = build1 (integer_zerop (TREE_OPERAND (*tp, 1))
? REALPART_EXPR : IMAGPART_EXPR,


[gcc/devel/fortran_unsigned] libstdc++: Do not use isatty on avr [PR115482]

2024-07-28 Thread Thomas Kテカnig via Libstdc++-cvs
https://gcc.gnu.org/g:d5bc313be01f12b92bb90404657b669f3a6509d1

commit d5bc313be01f12b92bb90404657b669f3a6509d1
Author: Detlef Vollmann 
Date:   Tue Jul 23 09:25:22 2024 +0100

libstdc++: Do not use isatty on avr [PR115482]

avrlibc has an incomplete unistd.h that doesn't have isatty.
So building libstdc++ fails when compiling c++23/print.cc.
As a workaround I added a check for AVR.

libstdc++-v3/ChangeLog:

PR libstdc++/115482
* src/c++23/print.cc (__open_terminal) [__AVR__]: Do not use
isatty.

Diff:
---
 libstdc++-v3/src/c++23/print.cc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libstdc++-v3/src/c++23/print.cc b/libstdc++-v3/src/c++23/print.cc
index 99a19cd45002..558dc149d125 100644
--- a/libstdc++-v3/src/c++23/print.cc
+++ b/libstdc++-v3/src/c++23/print.cc
@@ -75,7 +75,7 @@ namespace
 #ifdef _WIN32
if (int fd = ::_fileno(f); fd >= 0)
  return check_for_console((void*)_get_osfhandle(fd));
-#elifdef _GLIBCXX_HAVE_UNISTD_H
+#elif defined _GLIBCXX_HAVE_UNISTD_H && ! defined __AVR__
if (int fd = (::fileno)(f); fd >= 0 && ::isatty(fd))
  return f;
 #endif
@@ -100,7 +100,7 @@ namespace
 #ifdef _WIN32
 if (auto fb = dynamic_cast(sb))
   return check_for_console(fb->native_handle());
-#elifdef _GLIBCXX_HAVE_UNISTD_H
+#elif defined _GLIBCXX_HAVE_UNISTD_H && ! defined __AVR__
 if (auto fb = dynamic_cast(sb))
   if (int fd = fb->native_handle(); fd >= 0 && ::isatty(fd))
return ::fdopen(::dup(fd), "w"); // Caller must call fclose.


[gcc/devel/fortran_unsigned] libstdc++: Use [[maybe_unused]] attribute in src/c++23/print.cc

2024-07-28 Thread Thomas Kテカnig via Gcc-cvs
https://gcc.gnu.org/g:81073bc4fddfd31a8823d8ededeb47e32b6401dc

commit 81073bc4fddfd31a8823d8ededeb47e32b6401dc
Author: Jonathan Wakely 
Date:   Tue Jul 23 10:08:52 2024 +0100

libstdc++: Use [[maybe_unused]] attribute in src/c++23/print.cc

This avoids some warnings when the preprocessor conditions are not met.

libstdc++-v3/ChangeLog:

* src/c++23/print.cc (__open_terminal): Use [[maybe_unused]] on
parameter.

Diff:
---
 libstdc++-v3/src/c++23/print.cc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libstdc++-v3/src/c++23/print.cc b/libstdc++-v3/src/c++23/print.cc
index 558dc149d125..8ba714059672 100644
--- a/libstdc++-v3/src/c++23/print.cc
+++ b/libstdc++-v3/src/c++23/print.cc
@@ -67,7 +67,7 @@ namespace
   // This returns intptr_t that is either a Windows HANDLE
   // or 1 + a POSIX file descriptor. A zero return indicates failure.
   void*
-  __open_terminal(FILE* f)
+  __open_terminal([[maybe_unused]] FILE* f)
   {
 #ifndef _GLIBCXX_USE_STDIO_PURE
 if (f)
@@ -85,7 +85,7 @@ namespace
   }
 
   void*
-  __open_terminal(std::streambuf* sb)
+  __open_terminal([[maybe_unused]] std::streambuf* sb)
   {
 #if ! defined _GLIBCXX_USE_STDIO_PURE && defined __cpp_rtti
 using namespace __gnu_cxx;


[gcc/devel/fortran_unsigned] testsuite: Disable finite math only for test [PR115826]

2024-07-28 Thread Thomas Kテカnig via Gcc-cvs
https://gcc.gnu.org/g:6d68404e8c1b24ce70a09fb3aa138f6dec52873a

commit 6d68404e8c1b24ce70a09fb3aa138f6dec52873a
Author: Torbjörn SVENSSON 
Date:   Mon Jul 15 12:10:12 2024 +0200

testsuite: Disable finite math only for test  [PR115826]

As the test case requires +-Inf and NaN to work and -ffast-math is added
by default for arm-none-eabi, re-enable non-finite math.

gcc/testsuite/ChangeLog:

PR testsuite/115826
* gcc.dg/vect/tsvc/vect-tsvc-s1281.c: Use -fno-finite-math-only.

Signed-off-by: Torbjörn SVENSSON 

Diff:
---
 gcc/testsuite/gcc.dg/vect/tsvc/vect-tsvc-s1281.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/gcc/testsuite/gcc.dg/vect/tsvc/vect-tsvc-s1281.c 
b/gcc/testsuite/gcc.dg/vect/tsvc/vect-tsvc-s1281.c
index dba95a819737..3e619a3fa5aa 100644
--- a/gcc/testsuite/gcc.dg/vect/tsvc/vect-tsvc-s1281.c
+++ b/gcc/testsuite/gcc.dg/vect/tsvc/vect-tsvc-s1281.c
@@ -4,6 +4,9 @@
 /* { dg-additional-options "--param vect-epilogues-nomask=0" } */
 /* { dg-require-effective-target vect_float } */
 
+/* This test requires +-Inf and NaN, so disable finite-math-only */
+/* { dg-additional-options "-fno-finite-math-only" } */
+
 #include "tsvc.h"
 
 real_t s1281(struct args_t * func_args)


[gcc/devel/fortran_unsigned] tree-optimization/116002 - PTA solving slow with degenerate graph

2024-07-28 Thread Thomas Kテカnig via Gcc-cvs
https://gcc.gnu.org/g:b448b3b695f5d3c86a6bee3ce8522f261869dbb0

commit b448b3b695f5d3c86a6bee3ce8522f261869dbb0
Author: Richard Biener 
Date:   Tue Jul 23 10:29:58 2024 +0200

tree-optimization/116002 - PTA solving slow with degenerate graph

When the constraint graph consists of N nodes with only complex
constraints and no copy edges we have to be lucky to arrive at
a constraint solving order that requires the optimal number of
iterations.  What happens in the testcase is that we bottle-neck
on computing the visitation order but propagate changes only
very slowly.  Luckily the testcase complex constraints are
all copy-with-offset and those do provide a way to order
visitation.  The following adds this which reduces the iteration
count to one.

PR tree-optimization/116002
* tree-ssa-structalias.cc (topo_visit): Also consider
SCALAR = SCALAR complex constraints as edges.

Diff:
---
 gcc/tree-ssa-structalias.cc | 12 
 1 file changed, 12 insertions(+)

diff --git a/gcc/tree-ssa-structalias.cc b/gcc/tree-ssa-structalias.cc
index 330e64e65da1..65f9132a94fd 100644
--- a/gcc/tree-ssa-structalias.cc
+++ b/gcc/tree-ssa-structalias.cc
@@ -1908,6 +1908,18 @@ topo_visit (constraint_graph_t graph, vec 
&topo_order,
  topo_visit (graph, topo_order, visited, k);
   }
 
+  /* Also consider copy with offset complex constraints as implicit edges.  */
+  for (auto c : graph->complex[n])
+{
+  /* Constraints are ordered so that SCALAR = SCALAR appear first.  */
+  if (c->lhs.type != SCALAR || c->rhs.type != SCALAR)
+   break;
+  gcc_checking_assert (c->rhs.var == n);
+  unsigned k = find (c->lhs.var);
+  if (!bitmap_bit_p (visited, k))
+   topo_visit (graph, topo_order, visited, k);
+}
+
   topo_order.quick_push (n);
 }


[gcc/devel/fortran_unsigned] report message for operator %a on unaddressible operand

2024-07-28 Thread Thomas Kテカnig via Gcc-cvs
https://gcc.gnu.org/g:e2441359f7d1d493c18cdf63098d4646c8ee4c58

commit e2441359f7d1d493c18cdf63098d4646c8ee4c58
Author: Jiufu Guo 
Date:   Tue Jul 23 13:34:20 2024 +0800

report message for operator %a on unaddressible operand

Hi,

For PR96866, when printing asm code for modifier "%a", an addressable
operand is required.  While the constraint "X" allow any kind of
operand even which is hard to get the address directly. e.g. extern
symbol whose address is in TOC.
An error message would be reported to indicate the invalid asm operand.

Compare with previous version, test case is updated with -mno-pcrel.

Bootstrap®test pass on ppc64{,le}.
Is this ok for trunk?

BR,
Jeff(Jiufu Guo)

PR target/96866

gcc/ChangeLog:

* config/rs6000/rs6000.cc (print_operand_address): Emit message for
unsupported operand.

gcc/testsuite/ChangeLog:

* gcc.target/powerpc/pr96866-1.c: New test.
* gcc.target/powerpc/pr96866-2.c: New test.

Diff:
---
 gcc/config/rs6000/rs6000.cc  |  7 ++-
 gcc/testsuite/gcc.target/powerpc/pr96866-1.c | 18 ++
 gcc/testsuite/gcc.target/powerpc/pr96866-2.c | 13 +
 3 files changed, 37 insertions(+), 1 deletion(-)

diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc
index 85211565eb4c..0bcc6a2d0ab6 100644
--- a/gcc/config/rs6000/rs6000.cc
+++ b/gcc/config/rs6000/rs6000.cc
@@ -14706,7 +14706,12 @@ print_operand_address (FILE *file, rtx x)
fprintf (file, "@%s(%s)", SMALL_DATA_RELOC,
 reg_names[SMALL_DATA_REG]);
   else
-   gcc_assert (!TARGET_TOC);
+   {
+ /* Do not support getting address directly from TOC, emit error.
+No more work is needed for !TARGET_TOC. */
+ if (TARGET_TOC)
+   output_operand_lossage ("%%a requires an address of memory");
+   }
 }
   else if (GET_CODE (x) == PLUS && REG_P (XEXP (x, 0))
   && REG_P (XEXP (x, 1)))
diff --git a/gcc/testsuite/gcc.target/powerpc/pr96866-1.c 
b/gcc/testsuite/gcc.target/powerpc/pr96866-1.c
new file mode 100644
index ..72e59a19753a
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/pr96866-1.c
@@ -0,0 +1,18 @@
+/* The "%a" modifier can't get the address of extern symbol directly from TOC
+   with -fPIC, even the symbol is propagated for "X" constraint under -O2. */
+/* { dg-options "-fPIC -O2 -mno-pcrel" } */
+
+/* It's to verify no ICE here, ignore error messages about invalid 'asm'.  */
+/* { dg-excess-errors "pr96866-1.c" } */
+
+int x[2];
+
+int __attribute__ ((noipa))
+f1 (void)
+{
+  int n;
+  int *p = x;
+  *p++;
+  __asm__ volatile("ld %0, %a1" : "=r"(n) : "X"(p));
+  return n;
+}
diff --git a/gcc/testsuite/gcc.target/powerpc/pr96866-2.c 
b/gcc/testsuite/gcc.target/powerpc/pr96866-2.c
new file mode 100644
index ..72bb15fa04f4
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/pr96866-2.c
@@ -0,0 +1,13 @@
+/* The "%a" modifier can't get the address of extern symbol directly from TOC
+   with -fPIC. */
+/* { dg-options "-fPIC -O2 -mno-pcrel" } */
+
+/* It's to verify no ICE here, ignore error messages about invalid 'asm'.  */
+/* { dg-excess-errors "pr96866-2.c" } */
+
+void
+f (void)
+{
+  extern int x;
+  __asm__ volatile("#%a0" ::"X"(&x));
+}


[gcc/devel/fortran_unsigned] install.texi (gcn): Suggest newer commit for Newlib

2024-07-28 Thread Thomas Kテカnig via Gcc-cvs
https://gcc.gnu.org/g:b53a1fd4561c0533e31cbe5089f595dcb0e0b562

commit b53a1fd4561c0533e31cbe5089f595dcb0e0b562
Author: Tobias Burnus 
Date:   Tue Jul 23 12:41:40 2024 +0200

install.texi (gcn): Suggest newer commit for Newlib

Newlib 4.4.0 lacks two commits: 7dd4eb1db (2024-03-25) to fix device console
output for GFX10/GFX11 and ed50a50b9 (2024-04-04) to make the added lock.h
compilable with C++. This commit mentiones now also the second commit.

gcc/ChangeLog:

* doc/install.texi (amdgcn-x-amdhsa): Suggest newer git version
for newlib.

Diff:
---
 gcc/doc/install.texi | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/gcc/doc/install.texi b/gcc/doc/install.texi
index b54569925837..dda623f4410a 100644
--- a/gcc/doc/install.texi
+++ b/gcc/doc/install.texi
@@ -3952,9 +3952,9 @@ Instead of GNU Binutils, you will need to install LLVM 
15, or later, and copy
 by specifying a @code{--with-multilib-list=} that does not list @code{gfx1100}
 and @code{gfx1103}.
 
-Use Newlib (4.3.0 or newer; 4.4.0 contains some improvements and git commit
-7dd4eb1db (2024-03-25, post-4.4.0) fixes device console output for GFX10 and
-GFX11 devices).
+Use Newlib (4.3.0 or newer; 4.4.0 contains some improvements and git commits
+7dd4eb1db and ed50a50b9 (2024-04-04, post-4.4.0) fix device console output
+for GFX10 and GFX11 devices).
 
 To run the binaries, install the HSA Runtime from the
 @uref{https://rocm.docs.amd.com/,,ROCm Platform}, and use


[gcc/devel/fortran_unsigned] cp/coroutines: add a test for PR c++/103953

2024-07-28 Thread Thomas Kテカnig via Gcc-cvs
https://gcc.gnu.org/g:168abf43add49d7b1494411ce778e5d1b206a59f

commit 168abf43add49d7b1494411ce778e5d1b206a59f
Author: Arsen Arsenović 
Date:   Tue Jul 23 13:01:03 2024 +0200

cp/coroutines: add a test for PR c++/103953

This PR seems to have been fixed by a fix for a seemingly unrelated PR.
Lets add a regression test to make sure it stays fixed.

PR c++/103953 - Leak of coroutine return object

PR c++/103953

gcc/testsuite/ChangeLog:

* g++.dg/coroutines/torture/pr103953.C: New test.

Reviewed-by: Iain Sandoe 

Diff:
---
 gcc/testsuite/g++.dg/coroutines/torture/pr103953.C | 75 ++
 1 file changed, 75 insertions(+)

diff --git a/gcc/testsuite/g++.dg/coroutines/torture/pr103953.C 
b/gcc/testsuite/g++.dg/coroutines/torture/pr103953.C
new file mode 100644
index ..da559f8fa0d1
--- /dev/null
+++ b/gcc/testsuite/g++.dg/coroutines/torture/pr103953.C
@@ -0,0 +1,75 @@
+// { dg-do run }
+// https://gcc.gnu.org/PR103953
+#include 
+#include 
+
+static int ctor_dtor_count = 0;
+
+struct task {
+struct promise_type;
+
+using handle_type = std::coroutine_handle;
+
+task(handle_type h) : handle(h) {
+ctor_dtor_count++;
+}
+task(const task & t) : handle(t.handle) {
+ctor_dtor_count++;
+}
+task(task && t) : handle(std::move(t.handle)) {
+ctor_dtor_count++;
+}
+~task() {
+   if (--ctor_dtor_count < 0)
+   __builtin_abort ();
+}
+
+struct promise_type {
+auto get_return_object() {
+return task{handle_type::from_promise(*this)};
+}
+
+auto initial_suspend() {
+return std::suspend_always {};
+}
+
+auto unhandled_exception() {}
+
+auto final_suspend() noexcept {
+return std::suspend_always{};
+}
+
+void return_void() {}
+};
+
+   handle_type handle;
+
+   void await_resume() {
+   handle.resume();
+   }
+
+   auto await_suspend(handle_type) {
+   return handle;
+   }
+
+   auto await_ready() {
+   return false;
+   }
+};
+
+int main() {
+{
+   task coroutine_A = []() ->task {
+   co_return;
+   }();
+
+   task coroutine_B = [&coroutine_A]() ->task {
+   co_await coroutine_A;
+   }();
+
+   coroutine_B.handle.resume();
+}
+
+if (ctor_dtor_count != 0)
+   __builtin_abort ();
+}


[gcc/devel/fortran_unsigned] PR modula2/116048 ICE when encountering wrong kind of qualident

2024-07-28 Thread Thomas Kテカnig via Gcc-cvs
https://gcc.gnu.org/g:b1b2c26c374435f081a59aae149a6661dfd70eb8

commit b1b2c26c374435f081a59aae149a6661dfd70eb8
Author: Gaius Mulley 
Date:   Tue Jul 23 15:54:16 2024 +0100

PR modula2/116048 ICE when encountering wrong kind of qualident

Following on from PR-115957 further ICEs can be generated by using the
wrong kind of qualident symbol.  For example using a variable instead of
a type or using a type instead of a const.  This fix tracks the expected
qualident kind state when parsing const, type and variable declarations.
If the error is unrecoverable then a detailed message explaining the
context of the qualident (and why the seen qualident is wrong) is
generated.

gcc/m2/ChangeLog:

PR modula2/116048
* Make-lang.in (GM2-COMP-BOOT-DEFS): Add M2StateCheck.def.
(GM2-COMP-BOOT-MODS): Add M2StateCheck.mod.
(GM2-COMP-DEFS): Add M2StateCheck.def.
(GM2-COMP-MODS): Add M2StateCheck.mod.
* gm2-compiler/M2Quads.mod (StartBuildWith): Generate
unrecoverable error is the qualident type is NulSym.
Replace MetaError1 with MetaErrorT1 and position the error
to the qualident.
* gm2-compiler/P3Build.bnf (M2StateCheck): Import procedures.
(seenError): New variable.
(WasNoError): Remove variable.
(BlockState): New variable.
(ErrorString): Rewrite using seenError.
(CompilationUnit): Ditto.
(QualidentCheck): New rule.
(ConstantDeclaration): Bookend with InclConst and ExclConst.
(Constructor): Add InclConstructor, ExclConstructor and call
CheckQualident.
(ConstActualParameters): Call PushState, PopState, InclConstFunc
and CheckQualident.
(TypeDeclaration): Bookend with InclType and ExclType.
(SimpleType): Call QualidentCheck.
(CaseTag): Ditto.
(OptReturnType): Ditto.
(VariableDeclaration): Bookend with InclVar and ExclVar.
(Designator): Call QualidentCheck.
(Formal;Type): Ditto.
* gm2-compiler/PCBuild.bnf (M2StateCheck): Import procedures.
(ConstantDeclaration): Rewrite using InclConst and ExclConst.
(Constructor): Bookend with InclConstructor and ExclConstructor.
Call CheckQualident.
(ConstructorOrConstActualParameters): Rewrite and cal
l CheckQualident.
(ConstActualParameters): Bookend with PushState PopState.
Call InclConstFunc and CheckQualident.
* gm2-gcc/init.cc (_M2_M2StateCheck_init): New declaration.
(_M2_P3Build_init): New declaration.
(init_PerCompilationInit): Call _M2_M2StateCheck_init and
_M2_P3Build_init.
* gm2-compiler/M2StateCheck.def: New file.
* gm2-compiler/M2StateCheck.mod: New file.

gcc/testsuite/ChangeLog:

PR modula2/116048
* gm2/errors/fail/errors-fail.exp: Remove -Wstudents
and add -Wuninit-variable-checking=all.
Replace gm2_init_pim with gm2_init_iso.
* gm2/errors/fail/testfio.mod: Modify test code to
provoke an error in the first basic block.
* gm2/errors/fail/testparam.mod: Ditto.
* gm2/errors/fail/array1.mod: Ditto.
* gm2/errors/fail/badtype.mod: New test.
* gm2/errors/fail/badvar.mod: New test.

Signed-off-by: Gaius Mulley 

Diff:
---
 gcc/m2/Make-lang.in   |   4 +
 gcc/m2/gm2-compiler/M2Quads.mod   |  45 ++--
 gcc/m2/gm2-compiler/M2StateCheck.def  | 154 
 gcc/m2/gm2-compiler/M2StateCheck.mod  | 344 ++
 gcc/m2/gm2-compiler/P3Build.bnf   |  65 +++--
 gcc/m2/gm2-compiler/PCBuild.bnf   |  45 ++--
 gcc/m2/gm2-gcc/init.cc|   4 +
 gcc/testsuite/gm2/errors/fail/array1.mod  |   5 +
 gcc/testsuite/gm2/errors/fail/badtype.mod |  10 +
 gcc/testsuite/gm2/errors/fail/badvar.mod  |  10 +
 gcc/testsuite/gm2/errors/fail/errors-fail.exp |   2 +-
 gcc/testsuite/gm2/errors/fail/testfio.mod |   8 +
 gcc/testsuite/gm2/errors/fail/testparam.mod   |   5 +
 13 files changed, 645 insertions(+), 56 deletions(-)

diff --git a/gcc/m2/Make-lang.in b/gcc/m2/Make-lang.in
index daa7ef6747a5..2bd60ca29393 100644
--- a/gcc/m2/Make-lang.in
+++ b/gcc/m2/Make-lang.in
@@ -808,6 +808,7 @@ GM2-COMP-BOOT-DEFS = \
M2Size.def \
M2StackAddress.def \
M2StackWord.def \
+   M2StateCheck.def \
M2Students.def \
M2Swig.def \
M2SymInit.def \
@@ -882,6 +883,7 @@ GM2-COMP-BOOT-MODS = \
M2Size.mod \
M2StackAddress.mod \
M2StackWord.mod \
+   M2StateCheck.mod \
M2Students.mod \
M2Swig.mod \
M2SymInit.mod \
@@ -1090,6 +1092,7 @@ GM2-COMP-DEFS = \
M2Size.def \
M2StackA

[gcc/devel/fortran_unsigned] c++: missing SFINAE during alias CTAD [PR115296]

2024-07-28 Thread Thomas Kテカnig via Gcc-cvs
https://gcc.gnu.org/g:b4b4e9f51b37e5e12f81da5fa0a8fa6db2b3614a

commit b4b4e9f51b37e5e12f81da5fa0a8fa6db2b3614a
Author: Patrick Palka 
Date:   Tue Jul 23 11:37:31 2024 -0400

c++: missing SFINAE during alias CTAD [PR115296]

During the alias CTAD transformation, if substitution failed for some
guide we should just silently discard the guide.  We currently do
discard the guide, but not silently, as in the below testcase which
we diagnose forming a too-large array type when transforming the
user-defined deduction guides.

This patch fixes this by using complain=tf_none instead of
tf_warning_or_error throughout alias_ctad_tweaks.

PR c++/115296

gcc/cp/ChangeLog:

* pt.cc (alias_ctad_tweaks): Use complain=tf_none instead of
tf_warning_or_error.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/class-deduction-alias23.C: New test.

Reviewed-by: Jason Merrill 

Diff:
---
 gcc/cp/pt.cc |  2 +-
 gcc/testsuite/g++.dg/cpp2a/class-deduction-alias23.C | 19 +++
 2 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc
index 108e929b8ee6..8cc5e21c520d 100644
--- a/gcc/cp/pt.cc
+++ b/gcc/cp/pt.cc
@@ -30287,7 +30287,7 @@ alias_ctad_tweaks (tree tmpl, tree uguides)
  (INNERMOST_TEMPLATE_PARMS (fullatparms)));
 }
 
-  tsubst_flags_t complain = tf_warning_or_error;
+  tsubst_flags_t complain = tf_none;
   tree aguides = NULL_TREE;
   tree atparms = INNERMOST_TEMPLATE_PARMS (fullatparms);
   unsigned natparms = TREE_VEC_LENGTH (atparms);
diff --git a/gcc/testsuite/g++.dg/cpp2a/class-deduction-alias23.C 
b/gcc/testsuite/g++.dg/cpp2a/class-deduction-alias23.C
new file mode 100644
index ..117212c67de7
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp2a/class-deduction-alias23.C
@@ -0,0 +1,19 @@
+// PR c++/115296
+// { dg-do compile { target c++20 } }
+
+using size_t = decltype(sizeof(0));
+
+template
+struct span { span(T); };
+
+template
+span(T(&)[N]) -> span; // { dg-bogus "array exceeds maximum" }
+
+template
+requires (sizeof(T[N]) != 42) // { dg-bogus "array exceeds maximum" }
+span(T*) -> span;
+
+template
+using array_view = span;
+
+array_view x = 0;


[gcc/devel/fortran_unsigned] C++: Support clang compatible [[musttail]] (PR83324)

2024-07-28 Thread Thomas Kテカnig via Gcc-cvs
https://gcc.gnu.org/g:4428d8452a382996e31bda21a49cb8175efb6644

commit 4428d8452a382996e31bda21a49cb8175efb6644
Author: Andi Kleen 
Date:   Tue Jan 23 23:44:48 2024 -0800

C++: Support clang compatible [[musttail]] (PR83324)

This patch implements a clang compatible [[musttail]] attribute for
returns.

musttail is useful as an alternative to computed goto for interpreters.
With computed goto the interpreter function usually ends up very big
which causes problems with register allocation and other per function
optimizations not scaling. With musttail the interpreter can be instead
written as a sequence of smaller functions that call each other. To
avoid unbounded stack growth this requires forcing a sibling call, which
this attribute does. It guarantees an error if the call cannot be tail
called which allows the programmer to fix it instead of risking a stack
overflow. Unlike computed goto it is also type-safe.

It turns out that David Malcolm had already implemented middle/backend
support for a musttail attribute back in 2016, but it wasn't exposed
to any frontend other than a special plugin.

This patch adds a [[gnu::musttail]] attribute for C++ that can be added
to return statements. The return statement must be a direct call
(it does not follow dependencies), which is similar to what clang
implements. It then uses the existing must tail infrastructure.

For compatibility it also detects clang::musttail

Passes bootstrap and full test

gcc/c-family/ChangeLog:

* c-attribs.cc (set_musttail_on_return): New function.
* c-common.h (set_musttail_on_return): Declare new function.

gcc/cp/ChangeLog:

PR c/83324
* cp-tree.h (AGGR_INIT_EXPR_MUST_TAIL): Add.
* parser.cc (cp_parser_statement): Handle musttail.
(cp_parser_jump_statement): Dito.
* pt.cc (tsubst_expr): Copy CALL_EXPR_MUST_TAIL_CALL.
* semantics.cc (simplify_aggr_init_expr): Handle musttail.

Diff:
---
 gcc/c-family/c-attribs.cc | 20 
 gcc/c-family/c-common.h   |  1 +
 gcc/cp/cp-tree.h  |  4 
 gcc/cp/parser.cc  | 32 +---
 gcc/cp/pt.cc  |  9 -
 gcc/cp/semantics.cc   |  1 +
 6 files changed, 63 insertions(+), 4 deletions(-)

diff --git a/gcc/c-family/c-attribs.cc b/gcc/c-family/c-attribs.cc
index 5adc7b775eaf..685f212683f4 100644
--- a/gcc/c-family/c-attribs.cc
+++ b/gcc/c-family/c-attribs.cc
@@ -672,6 +672,26 @@ attribute_takes_identifier_p (const_tree attr_id)
 return targetm.attribute_takes_identifier_p (attr_id);
 }
 
+/* Set a musttail attribute MUSTTAIL_P on return expression RETVAL
+   at LOC.  */
+
+void
+set_musttail_on_return (tree retval, location_t loc, bool musttail_p)
+{
+  if (retval && musttail_p)
+{
+  tree t = retval;
+  if (TREE_CODE (t) == TARGET_EXPR)
+   t = TARGET_EXPR_INITIAL (t);
+  if (TREE_CODE (t) != CALL_EXPR)
+   error_at (loc, "cannot tail-call: return value must be a call");
+  else
+   CALL_EXPR_MUST_TAIL_CALL (t) = 1;
+}
+  else if (musttail_p && !retval)
+error_at (loc, "cannot tail-call: return value must be a call");
+}
+
 /* Verify that argument value POS at position ARGNO to attribute NAME
applied to function FN (which is either a function declaration or function
type) refers to a function parameter at position POS and the expected type
diff --git a/gcc/c-family/c-common.h b/gcc/c-family/c-common.h
index adee822a3ae0..2510ee4dbc9d 100644
--- a/gcc/c-family/c-common.h
+++ b/gcc/c-family/c-common.h
@@ -1648,6 +1648,7 @@ extern tree handle_noreturn_attribute (tree *, tree, 
tree, int, bool *);
 extern tree handle_musttail_attribute (tree *, tree, tree, int, bool *);
 extern bool has_attribute (location_t, tree, tree, tree (*)(tree));
 extern tree build_attr_access_from_parms (tree, bool);
+extern void set_musttail_on_return (tree, location_t, bool);
 
 /* In c-format.cc.  */
 extern bool valid_format_string_type_p (tree);
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index 856699de82f2..e2cec2f2c16c 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -4228,6 +4228,10 @@ templated_operator_saved_lookups (tree t)
 #define AGGR_INIT_FROM_THUNK_P(NODE) \
   (AGGR_INIT_EXPR_CHECK (NODE)->base.protected_flag)
 
+/* Nonzero means that the call was marked musttail.  */
+#define AGGR_INIT_EXPR_MUST_TAIL(NODE) \
+  (AGGR_INIT_EXPR_CHECK (NODE)->base.static_flag)
+
 /* AGGR_INIT_EXPR accessors.  These are equivalent to the CALL_EXPR
accessors, except for AGGR_INIT_EXPR_SLOT (which takes the place of
CALL_EXPR_STATIC_CHAIN).  */
diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc
index efd5d6f29a71..1fa0780944b6 100644
--- a/gcc/cp/parser.cc
+++ b/gcc/cp/parser.cc
@@ -2467,7 +2467,7 @@ static tree cp_parser_perform_range_for_lookup
 static tree cp_parser

[gcc/devel/fortran_unsigned] C: Implement musttail attribute for returns

2024-07-28 Thread Thomas Kテカnig via Gcc-cvs
https://gcc.gnu.org/g:f5a65389e32b50b9069e7132498294b092c0f258

commit f5a65389e32b50b9069e7132498294b092c0f258
Author: Andi Kleen 
Date:   Wed Jan 24 07:44:23 2024 -0800

C: Implement musttail attribute for returns

Implement a C23 clang compatible musttail attribute similar to the earlier
C++ implementation in the C parser.

gcc/c/ChangeLog:

PR c/83324
* c-parser.cc (struct attr_state): Define with musttail_p.
(c_parser_statement_after_labels): Handle [[musttail]].
(c_parser_std_attribute): Dito.
(c_parser_handle_musttail): Dito.
(c_parser_compound_statement_nostart): Dito.
(c_parser_all_labels): Dito.
(c_parser_statement): Dito.
* c-tree.h (c_finish_return): Add musttail_p flag.
* c-typeck.cc (c_finish_return): Handle musttail_p flag.

Diff:
---
 gcc/c/c-parser.cc | 71 +--
 gcc/c/c-tree.h|  2 +-
 gcc/c/c-typeck.cc |  7 --
 3 files changed, 64 insertions(+), 16 deletions(-)

diff --git a/gcc/c/c-parser.cc b/gcc/c/c-parser.cc
index 12c5ed5d92c7..9b9284b1ba4d 100644
--- a/gcc/c/c-parser.cc
+++ b/gcc/c/c-parser.cc
@@ -1621,6 +1621,12 @@ struct omp_for_parse_data {
   bool fail : 1;
 };
 
+struct attr_state
+{
+  /* True if we parsed a musttail attribute for return.  */
+  bool musttail_p;
+};
+
 static bool c_parser_nth_token_starts_std_attributes (c_parser *,
  unsigned int);
 static tree c_parser_std_attribute_specifier_sequence (c_parser *);
@@ -1665,7 +1671,8 @@ static location_t c_parser_compound_statement_nostart 
(c_parser *);
 static void c_parser_label (c_parser *, tree);
 static void c_parser_statement (c_parser *, bool *, location_t * = NULL);
 static void c_parser_statement_after_labels (c_parser *, bool *,
-vec * = NULL);
+vec * = NULL,
+attr_state = {});
 static tree c_parser_c99_block_statement (c_parser *, bool *,
  location_t * = NULL);
 static void c_parser_if_statement (c_parser *, bool *, vec *);
@@ -6982,6 +6989,29 @@ c_parser_handle_directive_omp_attributes (tree &attrs,
 }
 }
 
+/* Check if STD_ATTR contains a musttail attribute and remove if it
+   precedes a return.  PARSER is the parser and ATTR is the output
+   attr_state.  */
+
+static tree
+c_parser_handle_musttail (c_parser *parser, tree std_attrs, attr_state &attr)
+{
+  if (c_parser_next_token_is_keyword (parser, RID_RETURN))
+{
+  if (lookup_attribute ("gnu", "musttail", std_attrs))
+   {
+ std_attrs = remove_attribute ("gnu", "musttail", std_attrs);
+ attr.musttail_p = true;
+   }
+  if (lookup_attribute ("clang", "musttail", std_attrs))
+   {
+ std_attrs = remove_attribute ("clang", "musttail", std_attrs);
+ attr.musttail_p = true;
+   }
+}
+  return std_attrs;
+}
+
 /* Parse a compound statement except for the opening brace.  This is
used for parsing both compound statements and statement expressions
(which follow different paths to handling the opening).  */
@@ -6998,6 +7028,7 @@ c_parser_compound_statement_nostart (c_parser *parser)
   bool in_omp_loop_block
 = omp_for_parse_state ? omp_for_parse_state->want_nested_loop : false;
   tree sl = NULL_TREE;
+  attr_state a = {};
 
   if (c_parser_next_token_is (parser, CPP_CLOSE_BRACE))
 {
@@ -7138,7 +7169,10 @@ c_parser_compound_statement_nostart (c_parser *parser)
= c_parser_nth_token_starts_std_attributes (parser, 1);
   tree std_attrs = NULL_TREE;
   if (have_std_attrs)
-   std_attrs = c_parser_std_attribute_specifier_sequence (parser);
+   {
+ std_attrs = c_parser_std_attribute_specifier_sequence (parser);
+ std_attrs = c_parser_handle_musttail (parser, std_attrs, a);
+   }
   if (c_parser_next_token_is_keyword (parser, RID_CASE)
  || c_parser_next_token_is_keyword (parser, RID_DEFAULT)
  || (c_parser_next_token_is (parser, CPP_NAME)
@@ -7286,7 +7320,7 @@ c_parser_compound_statement_nostart (c_parser *parser)
  last_stmt = true;
  mark_valid_location_for_stdc_pragma (false);
  if (!omp_for_parse_state)
-   c_parser_statement_after_labels (parser, NULL);
+   c_parser_statement_after_labels (parser, NULL, NULL, a);
  else
{
  /* In canonical loop nest form, nested loops can only appear
@@ -7328,15 +7362,20 @@ c_parser_compound_statement_nostart (c_parser *parser)
 /* Parse all consecutive labels, possibly preceded by standard
attributes.  In this context, a statement is required, not a
declaration, so attributes must be followed by a statement that is
-   not just a semicolon.  */
+   not just a semicolon.  Returns an attr

[gcc/devel/fortran_unsigned] c++: normalizing ttp constraints [PR115656]

2024-07-28 Thread Thomas Kテカnig via Gcc-cvs
https://gcc.gnu.org/g:275063836c30229a055861ddbcd725324e91a833

commit 275063836c30229a055861ddbcd725324e91a833
Author: Patrick Palka 
Date:   Tue Jul 23 13:16:14 2024 -0400

c++: normalizing ttp constraints [PR115656]

Here we normalize the constraint same_as for the first
time during ttp coercion of B / UU, specifically constraint subsumption
checking.  During this normalization the set of in-scope template
parameters i.e. current_template_parms is empty, which we rely on
during normalization of the ttp constraints since we pass in_decl=NULL_TREE
to norm_info.  And this tricks the satisfaction cache into thinking that
the satisfaction value of same_as is independent of its template
parameters, and we incorrectly conflate the satisfaction value with
T = bool vs T = long and accept the specialization A.

Since is_compatible_template_arg rewrites the ttp's constraints to
be in terms of the argument template's parameters, and since it's
the only caller of weakly_subsumes, the latter funcion can instead
pass in_decl=tmpl to avoid relying on current_template_parms.  This
patch implements this, and in turns renames weakly_subsumes to
ttp_subsumes to reflect that this predicate is now hardcoded for this
one caller.

PR c++/115656

gcc/cp/ChangeLog:

* constraint.cc (weakly_subsumes): Pass in_decl=tmpl to
get_normalized_constraints_from_info.  Rename to ...
(ttp_subsumes): ... this.
* cp-tree.h (weakly_subsumes): Rename to ...
(ttp_subsumes): ... this.
* pt.cc (is_compatible_template_arg): Adjust after renaming.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/concepts-ttp7.C: New test.

Reviewed-by: Jason Merrill 

Diff:
---
 gcc/cp/constraint.cc   |  9 +
 gcc/cp/cp-tree.h   |  2 +-
 gcc/cp/pt.cc   |  2 +-
 gcc/testsuite/g++.dg/cpp2a/concepts-ttp7.C | 12 
 4 files changed, 19 insertions(+), 6 deletions(-)

diff --git a/gcc/cp/constraint.cc b/gcc/cp/constraint.cc
index afd5435cc3ed..7fce78f508e9 100644
--- a/gcc/cp/constraint.cc
+++ b/gcc/cp/constraint.cc
@@ -3328,13 +3328,14 @@ strictly_subsumes (tree ci, tree tmpl)
   return subsumes (n1, n2) && !subsumes (n2, n1);
 }
 
-/* Returns true when the constraints in CI subsume the
-   associated constraints of TMPL.  */
+/* Returns true when the template template parameter constraints in CI
+   subsume the associated constraints of the template template argument
+   TMPL.  */
 
 bool
-weakly_subsumes (tree ci, tree tmpl)
+ttp_subsumes (tree ci, tree tmpl)
 {
-  tree n1 = get_normalized_constraints_from_info (ci, NULL_TREE);
+  tree n1 = get_normalized_constraints_from_info (ci, tmpl);
   tree n2 = get_normalized_constraints_from_decl (tmpl);
 
   return subsumes (n1, n2);
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index 76ac9c31763c..856699de82f2 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -8609,7 +8609,7 @@ extern tree find_template_parameters  (tree, 
tree);
 extern bool equivalent_constraints  (tree, tree);
 extern bool equivalently_constrained(tree, tree);
 extern bool strictly_subsumes  (tree, tree);
-extern bool weakly_subsumes(tree, tree);
+extern bool ttp_subsumes   (tree, tree);
 extern int more_constrained (tree, tree);
 extern bool at_least_as_constrained (tree, tree);
 extern bool constraints_equivalent_p(tree, tree);
diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc
index 8cc5e21c520d..393913294b50 100644
--- a/gcc/cp/pt.cc
+++ b/gcc/cp/pt.cc
@@ -8482,7 +8482,7 @@ is_compatible_template_arg (tree parm, tree arg, tree 
args)
 return false;
 }
 
-  return weakly_subsumes (parm_cons, arg);
+  return ttp_subsumes (parm_cons, arg);
 }
 
 // Convert a placeholder argument into a binding to the original
diff --git a/gcc/testsuite/g++.dg/cpp2a/concepts-ttp7.C 
b/gcc/testsuite/g++.dg/cpp2a/concepts-ttp7.C
new file mode 100644
index ..2ce884b995c7
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp2a/concepts-ttp7.C
@@ -0,0 +1,12 @@
+// PR c++/115656
+// { dg-do compile { target c++20 } }
+
+template concept same_as = __is_same(T, U);
+
+template T, template> class UU>
+struct A { };
+
+template> class B;
+
+A a1;
+A a2; // { dg-error "constraint failure" }


[gcc/devel/fortran_unsigned] Add tests for C/C++ musttail attributes

2024-07-28 Thread Thomas Kテカnig via Gcc-cvs
https://gcc.gnu.org/g:102bf56bb2127ee326b6e7f846c4bdd33155178c

commit 102bf56bb2127ee326b6e7f846c4bdd33155178c
Author: Andi Kleen 
Date:   Tue Jan 23 23:54:56 2024 -0800

Add tests for C/C++ musttail attributes

Some adopted from the existing C musttail plugin tests.
Also extends the ability to query the sibcall capabilities of the
target.

gcc/testsuite/ChangeLog:

* lib/target-supports.exp:
(check_effective_target_struct_tail_call): New function.
* c-c++-common/musttail1.c: New test.
* c-c++-common/musttail12.c: New test.
* c-c++-common/musttail13.c: New test.
* c-c++-common/musttail2.c: New test.
* c-c++-common/musttail3.c: New test.
* c-c++-common/musttail4.c: New test.
* c-c++-common/musttail5.c: New test.
* c-c++-common/musttail7.c: New test.
* c-c++-common/musttail8.c: New test.
* g++.dg/musttail10.C: New test.
* g++.dg/musttail11.C: New test.
* g++.dg/musttail6.C: New test.
* g++.dg/musttail9.C: New test.

Diff:
---
 gcc/testsuite/c-c++-common/musttail1.c  | 14 
 gcc/testsuite/c-c++-common/musttail12.c | 15 +
 gcc/testsuite/c-c++-common/musttail13.c |  5 +++
 gcc/testsuite/c-c++-common/musttail2.c  | 33 ++
 gcc/testsuite/c-c++-common/musttail3.c  | 29 
 gcc/testsuite/c-c++-common/musttail4.c  | 17 ++
 gcc/testsuite/c-c++-common/musttail5.c  | 28 +++
 gcc/testsuite/c-c++-common/musttail7.c  | 14 
 gcc/testsuite/c-c++-common/musttail8.c  | 17 ++
 gcc/testsuite/g++.dg/musttail10.C   | 40 ++
 gcc/testsuite/g++.dg/musttail11.C   | 33 ++
 gcc/testsuite/g++.dg/musttail6.C| 60 +
 gcc/testsuite/g++.dg/musttail9.C| 10 ++
 gcc/testsuite/lib/target-supports.exp   | 12 +++
 14 files changed, 327 insertions(+)

diff --git a/gcc/testsuite/c-c++-common/musttail1.c 
b/gcc/testsuite/c-c++-common/musttail1.c
new file mode 100644
index ..74efcc2a0bc6
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/musttail1.c
@@ -0,0 +1,14 @@
+/* { dg-do compile { target { tail_call && { c || c++11 } } } } */
+/* { dg-additional-options "-fdelayed-branch" { target sparc*-*-* } } */
+
+int __attribute__((noinline,noclone,noipa))
+callee (int i)
+{
+  return i * i;
+}
+
+int __attribute__((noinline,noclone,noipa))
+caller (int i)
+{
+  [[gnu::musttail]] return callee (i + 1);
+}
diff --git a/gcc/testsuite/c-c++-common/musttail12.c 
b/gcc/testsuite/c-c++-common/musttail12.c
new file mode 100644
index ..4140bcd00950
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/musttail12.c
@@ -0,0 +1,15 @@
+/* { dg-do compile { target { struct_tail_call && { c || c++11 } } } } */
+/* { dg-additional-options "-fdelayed-branch" { target sparc*-*-* } } */
+
+struct str
+{
+  int a, b;
+};
+struct str
+cstruct (int x)
+{
+  if (x < 10)
+L:
+[[gnu::musttail]] return cstruct (x + 1);
+  return ((struct str){ x, 0 });
+}
diff --git a/gcc/testsuite/c-c++-common/musttail13.c 
b/gcc/testsuite/c-c++-common/musttail13.c
new file mode 100644
index ..6bd212fbeb8f
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/musttail13.c
@@ -0,0 +1,5 @@
+/* { dg-do compile { target { c || c++11 } } } */
+void f(void)
+{
+  [[gnu::musttail]] return; /* { dg-error "cannot tail-call.*return value must 
be a call" } */
+}
diff --git a/gcc/testsuite/c-c++-common/musttail2.c 
b/gcc/testsuite/c-c++-common/musttail2.c
new file mode 100644
index ..86f2c3d77404
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/musttail2.c
@@ -0,0 +1,33 @@
+/* { dg-do compile { target { tail_call && { c || c++11 } } } } */
+
+struct box { char field[256]; int i; };
+
+int __attribute__((noinline,noclone,noipa))
+test_2_callee (int i, struct box b)
+{
+  if (b.field[0])
+return 5;
+  return i * i;
+}
+
+int __attribute__((noinline,noclone,noipa))
+test_2_caller (int i)
+{
+  struct box b;
+  [[gnu::musttail]] return test_2_callee (i + 1, b); /* { dg-error "cannot 
tail-call: " } */
+}
+
+extern void setjmp (void);
+void
+test_3 (void)
+{
+  [[gnu::musttail]] return setjmp (); /* { dg-error "cannot tail-call: " } */
+}
+
+extern float f7(void);
+
+int
+test_6 (void)
+{
+  [[gnu::musttail]] return f7(); /* { dg-error "cannot tail-call: " } */
+}
diff --git a/gcc/testsuite/c-c++-common/musttail3.c 
b/gcc/testsuite/c-c++-common/musttail3.c
new file mode 100644
index ..ea9589c59ef2
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/musttail3.c
@@ -0,0 +1,29 @@
+/* { dg-do compile { target { tail_call && { c || c++11 } } } } */
+
+extern int foo2 (int x, ...);
+
+struct str
+{
+  int a, b;
+};
+
+struct str
+cstruct (int x)
+{
+  if (x < 10)
+[[clang::musttail]] return cstruct (x + 1);
+  return ((struct str){ x, 0 });
+}
+
+int
+foo (int x)
+{
+  if (x < 10)
+

[gcc/devel/fortran_unsigned] Add documentation for musttail attribute

2024-07-28 Thread Thomas Kテカnig via Gcc-cvs
https://gcc.gnu.org/g:ff65486d2ea0ed7d97081785dbef1f1f1cc2abda

commit ff65486d2ea0ed7d97081785dbef1f1f1cc2abda
Author: Andi Kleen 
Date:   Tue Jan 23 23:38:23 2024 -0800

Add documentation for musttail attribute

gcc/ChangeLog:

PR c/83324
* doc/extend.texi: Document [[musttail]]

Diff:
---
 gcc/doc/extend.texi | 25 +++--
 1 file changed, 23 insertions(+), 2 deletions(-)

diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
index 4b77599380b5..b0273927b256 100644
--- a/gcc/doc/extend.texi
+++ b/gcc/doc/extend.texi
@@ -9921,7 +9921,7 @@ same manner as the @code{deprecated} attribute.
 @section Statement Attributes
 @cindex Statement Attributes
 
-GCC allows attributes to be set on null statements.  @xref{Attribute Syntax},
+GCC allows attributes to be set on statements.  @xref{Attribute Syntax},
 for details of the exact syntax for using attributes.  Other attributes are
 available for functions (@pxref{Function Attributes}), variables
 (@pxref{Variable Attributes}), labels (@pxref{Label Attributes}), enumerators
@@ -9978,6 +9978,25 @@ foo (int x, int y)
 @code{y} is not actually incremented and the compiler can but does not
 have to optimize it to just @code{return 42 + 42;}.
 
+@cindex @code{musttail} statement attribute
+@item musttail
+
+The @code{gnu::musttail} or @code{clang::musttail} attribute
+can be applied to a @code{return} statement with a return-value expression
+that is a function call.  It asserts that the call must be a tail call that
+does not allocate extra stack space, so it is safe to use tail recursion
+to implement long running loops.
+
+@smallexample
+[[gnu::musttail]] return foo();
+@end smallexample
+
+If the compiler cannot generate a @code{musttail} tail call it will report
+an error. On some targets tail calls may never be supported.
+Tail calls cannot reference locals in memory, which may affect
+builds without optimization when passing small structures, or passing
+or returning large structures. Enabling -O1 or -O2 can improve
+the success of tail calls.
 @end table
 
 @node Attribute Syntax
@@ -10101,7 +10120,9 @@ the constant expression, if present.
 
 @subsubheading Statement Attributes
 In GNU C, an attribute specifier list may appear as part of a null
-statement.  The attribute goes before the semicolon.
+statement. The attribute goes before the semicolon.
+Some attributes in new style syntax are also supported
+on non-null statements.
 
 @subsubheading Type Attributes


[gcc/devel/fortran_unsigned] doc: add missing @option for musttail

2024-07-28 Thread Thomas Kテカnig via Gcc-cvs
https://gcc.gnu.org/g:74cdc9a4d85fe521aaf5cc6556b4438e5aa58a9f

commit 74cdc9a4d85fe521aaf5cc6556b4438e5aa58a9f
Author: Marek Polacek 
Date:   Tue Jul 23 16:32:20 2024 -0400

doc: add missing @option for musttail

gcc/ChangeLog:

* doc/extend.texi: Add missing @option.

Diff:
---
 gcc/doc/extend.texi | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
index b0273927b256..66c99ef7a667 100644
--- a/gcc/doc/extend.texi
+++ b/gcc/doc/extend.texi
@@ -9995,8 +9995,8 @@ If the compiler cannot generate a @code{musttail} tail 
call it will report
 an error. On some targets tail calls may never be supported.
 Tail calls cannot reference locals in memory, which may affect
 builds without optimization when passing small structures, or passing
-or returning large structures. Enabling -O1 or -O2 can improve
-the success of tail calls.
+or returning large structures.  Enabling @option{-O1} or @option{-O2} can
+improve the success of tail calls.
 @end table
 
 @node Attribute Syntax


[gcc/devel/fortran_unsigned] RISC-V: Fix snafu in SI mode splitters patch

2024-07-28 Thread Thomas Kテカnig via Gcc-cvs
https://gcc.gnu.org/g:e13081bf2db7d755a8de99cb67eb395dc2f1decb

commit e13081bf2db7d755a8de99cb67eb395dc2f1decb
Author: Vineet Gupta 
Date:   Tue Jul 23 15:12:11 2024 -0700

RISC-V: Fix snafu in SI mode splitters patch

SPEC2017 perlbench for RISC-V was broke as runtime output mismatch
failure.

> 3830:  mbox2: 
dWshe3Aa1EULre4CT5O/ErYFrk+o/EOoebA1kTVjQVQQH2EjT5fHcYnwjj2MdBmZu5y3Ce4Ei4QQZo/SNrry9g
>mbox2: 
uuWPimQiU0D4UrwFP+LS0lFNph4qL43WV1A6T3tHleatIOUaHixhrJU9NoA2lc9KjwYpdEL0lNTXkvo8ymNHzA
>   ^
> 3832:  mbox3: 
8f4jdv6GIf0lX3DcdwRdEm6/aZwnmGX6n86GzCvmkwTKFXQjwlwVHc8jy8XlcyiIPr3yXTkgVOiP3cRYvyYQPg
>mbox3: 
9xQySgP6qbhfxl8Usu1WfGA5UhStB5AN31wueGM6OF4Jp59DkqJPu6ksGblOU5u0nQapQC1e9oYIs16a2mq2NA
>   ^
> specdiff run completed

Edwin bisected this to 273f16a125c4 ("[v3][RISC-V] Handle bit
manipulation of SImode values") which had the operands swapped in one
of the new splitters introduced.

No test as reducer narrows it to down to the exact test introduced by
the original commit.

gcc/ChangeLog:
* config/riscv/bitmanip.md: Fix splitter.

Reported-by: Edwin Lu 
Signed-off-by: Vineet Gupta 

Diff:
---
 gcc/config/riscv/bitmanip.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/config/riscv/bitmanip.md b/gcc/config/riscv/bitmanip.md
index f403ba8dbbad..d262430485e7 100644
--- a/gcc/config/riscv/bitmanip.md
+++ b/gcc/config/riscv/bitmanip.md
@@ -675,7 +675,7 @@
   "#"
   "&& reload_completed"
[(set (match_dup 4) (match_dup 2))
-(set (match_dup 4) (and:DI (not:DI (match_dup 4)) (match_dup 1)))
+(set (match_dup 4) (and:DI (not:DI (match_dup 1)) (match_dup 4)))
 (set (match_dup 0) (any_or:DI (ashift:DI (const_int 1) (match_dup 5)) 
(match_dup 3)))]
   { operands[5] = gen_lowpart (QImode, operands[4]); }
   [(set_attr "type" "bitmanip")])


[gcc/devel/fortran_unsigned] Output CodeView type information for references

2024-07-28 Thread Thomas Kテカnig via Gcc-cvs
https://gcc.gnu.org/g:98fa2f48b5f91a6ac2bb8329de53a456da1015f2

commit 98fa2f48b5f91a6ac2bb8329de53a456da1015f2
Author: Mark Harmstone 
Date:   Sat Jul 20 20:12:30 2024 +0100

Output CodeView type information for references

Translates DW_TAG_reference_type DIEs into LF_POINTER types.

gcc/
* dwarf2codeview.cc (get_type_num_reference_type): New function.
(get_type_num_array_type): Add DW_TAG_reference_type to switch.
(get_type_num): Handle DW_TAG_reference_type DIEs.
* dwarf2codeview.h (CV_PTR_MODE_LVREF): Define.

Diff:
---
 gcc/dwarf2codeview.cc | 44 
 gcc/dwarf2codeview.h  |  1 +
 2 files changed, 45 insertions(+)

diff --git a/gcc/dwarf2codeview.cc b/gcc/dwarf2codeview.cc
index c174f3204803..23175204acd3 100644
--- a/gcc/dwarf2codeview.cc
+++ b/gcc/dwarf2codeview.cc
@@ -2293,6 +2293,45 @@ get_type_num_pointer_type (dw_die_ref type, bool 
in_struct)
   return ct->num;
 }
 
+/* Process a DW_TAG_reference_type DIE, add a new LF_POINTER type, and return
+   its number.  */
+
+static uint32_t
+get_type_num_reference_type (dw_die_ref type, bool in_struct)
+{
+  uint32_t base_type_num, byte_size;
+  dw_die_ref base_type;
+  codeview_custom_type *ct;
+
+  byte_size = get_AT_unsigned (type, DW_AT_byte_size);
+  if (byte_size != 4 && byte_size != 8)
+return 0;
+
+  base_type = get_AT_ref (type, DW_AT_type);
+
+  base_type_num = get_type_num (base_type, in_struct, false);
+  if (base_type_num == 0)
+return 0;
+
+  ct = (codeview_custom_type *) xmalloc (sizeof (codeview_custom_type));
+
+  ct->next = NULL;
+  ct->kind = LF_POINTER;
+  ct->lf_pointer.base_type = base_type_num;
+  ct->lf_pointer.attributes = CV_PTR_MODE_LVREF;
+
+  if (byte_size == 4)
+ct->lf_pointer.attributes |= CV_PTR_NEAR32;
+  else
+ct->lf_pointer.attributes |= CV_PTR_64;
+
+  ct->lf_pointer.attributes |= byte_size << 13;
+
+  add_custom_type (ct);
+
+  return ct->num;
+}
+
 /* Process a DW_TAG_const_type DIE, adding an LF_MODIFIER type and returning
its number.  */
 
@@ -3024,6 +3063,7 @@ get_type_num_array_type (dw_die_ref type, bool in_struct)
case DW_TAG_class_type:
case DW_TAG_union_type:
case DW_TAG_pointer_type:
+   case DW_TAG_reference_type:
  size = get_AT_unsigned (t, DW_AT_byte_size);
  break;
 
@@ -3151,6 +3191,10 @@ get_type_num (dw_die_ref type, bool in_struct, bool 
no_fwd_ref)
   num = get_type_num_pointer_type (type, in_struct);
   break;
 
+case DW_TAG_reference_type:
+  num = get_type_num_reference_type (type, in_struct);
+  break;
+
 case DW_TAG_const_type:
   num = get_type_num_const_type (type, in_struct);
   break;
diff --git a/gcc/dwarf2codeview.h b/gcc/dwarf2codeview.h
index 8fd3632e524c..7d4e3ab1db43 100644
--- a/gcc/dwarf2codeview.h
+++ b/gcc/dwarf2codeview.h
@@ -55,6 +55,7 @@ along with GCC; see the file COPYING3.  If not see
 /* LF_POINTER attributes.  */
 #define CV_PTR_NEAR32  0x0a
 #define CV_PTR_64  0x0c
+#define CV_PTR_MODE_LVREF  0x20
 
 /* LF_MODIFIER values.  */
 #define MOD_const  0x1


[gcc/devel/fortran_unsigned] Output CodeView type information for rvalue references

2024-07-28 Thread Thomas Kテカnig via Gcc-cvs
https://gcc.gnu.org/g:713ec9f62ba4321b8f82aad47d3f2960ef92a935

commit 713ec9f62ba4321b8f82aad47d3f2960ef92a935
Author: Mark Harmstone 
Date:   Sat Jul 20 20:18:14 2024 +0100

Output CodeView type information for rvalue references

Translates DW_TAG_rvalue_reference_type DIEs into LF_POINTER types.

gcc/
* dwarf2codeview.cc (get_type_num_reference_type): Handle rvalue 
refs.
(get_type_num_array_type): Add DW_TAG_rvalue_reference_type to 
switch.
(get_type_num): Handle DW_TAG_rvalue_reference_type DIEs.
* dwarf2codeview.h (CV_PTR_MODE_RVREF): Define.

Diff:
---
 gcc/dwarf2codeview.cc | 15 ++-
 gcc/dwarf2codeview.h  |  1 +
 2 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/gcc/dwarf2codeview.cc b/gcc/dwarf2codeview.cc
index 23175204acd3..b16c6960f63e 100644
--- a/gcc/dwarf2codeview.cc
+++ b/gcc/dwarf2codeview.cc
@@ -2293,11 +2293,11 @@ get_type_num_pointer_type (dw_die_ref type, bool 
in_struct)
   return ct->num;
 }
 
-/* Process a DW_TAG_reference_type DIE, add a new LF_POINTER type, and return
-   its number.  */
+/* Process a DW_TAG_reference_type or DW_TAG_rvalue_reference_type DIE, add a
+   new LF_POINTER type, and return its number.  */
 
 static uint32_t
-get_type_num_reference_type (dw_die_ref type, bool in_struct)
+get_type_num_reference_type (dw_die_ref type, bool in_struct, bool rvref)
 {
   uint32_t base_type_num, byte_size;
   dw_die_ref base_type;
@@ -2318,7 +2318,7 @@ get_type_num_reference_type (dw_die_ref type, bool 
in_struct)
   ct->next = NULL;
   ct->kind = LF_POINTER;
   ct->lf_pointer.base_type = base_type_num;
-  ct->lf_pointer.attributes = CV_PTR_MODE_LVREF;
+  ct->lf_pointer.attributes = rvref ? CV_PTR_MODE_RVREF : CV_PTR_MODE_LVREF;
 
   if (byte_size == 4)
 ct->lf_pointer.attributes |= CV_PTR_NEAR32;
@@ -3064,6 +3064,7 @@ get_type_num_array_type (dw_die_ref type, bool in_struct)
case DW_TAG_union_type:
case DW_TAG_pointer_type:
case DW_TAG_reference_type:
+   case DW_TAG_rvalue_reference_type:
  size = get_AT_unsigned (t, DW_AT_byte_size);
  break;
 
@@ -3192,7 +3193,11 @@ get_type_num (dw_die_ref type, bool in_struct, bool 
no_fwd_ref)
   break;
 
 case DW_TAG_reference_type:
-  num = get_type_num_reference_type (type, in_struct);
+  num = get_type_num_reference_type (type, in_struct, false);
+  break;
+
+case DW_TAG_rvalue_reference_type:
+  num = get_type_num_reference_type (type, in_struct, true);
   break;
 
 case DW_TAG_const_type:
diff --git a/gcc/dwarf2codeview.h b/gcc/dwarf2codeview.h
index 7d4e3ab1db43..8ede1b295294 100644
--- a/gcc/dwarf2codeview.h
+++ b/gcc/dwarf2codeview.h
@@ -56,6 +56,7 @@ along with GCC; see the file COPYING3.  If not see
 #define CV_PTR_NEAR32  0x0a
 #define CV_PTR_64  0x0c
 #define CV_PTR_MODE_LVREF  0x20
+#define CV_PTR_MODE_RVREF  0x80
 
 /* LF_MODIFIER values.  */
 #define MOD_const  0x1


[gcc/devel/fortran_unsigned] Daily bump.

2024-07-28 Thread Thomas Kテカnig via Libstdc++-cvs
https://gcc.gnu.org/g:1bc9314f8b837da7a68912142387d924791e5de4

commit 1bc9314f8b837da7a68912142387d924791e5de4
Author: GCC Administrator 
Date:   Wed Jul 24 00:18:20 2024 +

Daily bump.

Diff:
---
 gcc/ChangeLog   | 111 ++
 gcc/DATESTAMP   |   2 +-
 gcc/c-family/ChangeLog  |   5 +++
 gcc/c/ChangeLog |  13 ++
 gcc/cp/ChangeLog|  45 +++
 gcc/m2/ChangeLog|  45 +++
 gcc/testsuite/ChangeLog | 114 
 libstdc++-v3/ChangeLog  |  11 +
 8 files changed, 345 insertions(+), 1 deletion(-)

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 353ce3b6e2a8..b75dfdbd1095 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,114 @@
+2024-07-23  Mark Harmstone  
+
+   * dwarf2codeview.cc (get_type_num_reference_type): Handle rvalue refs.
+   (get_type_num_array_type): Add DW_TAG_rvalue_reference_type to switch.
+   (get_type_num): Handle DW_TAG_rvalue_reference_type DIEs.
+   * dwarf2codeview.h (CV_PTR_MODE_RVREF): Define.
+
+2024-07-23  Mark Harmstone  
+
+   * dwarf2codeview.cc (get_type_num_reference_type): New function.
+   (get_type_num_array_type): Add DW_TAG_reference_type to switch.
+   (get_type_num): Handle DW_TAG_reference_type DIEs.
+   * dwarf2codeview.h (CV_PTR_MODE_LVREF): Define.
+
+2024-07-23  Vineet Gupta  
+
+   * config/riscv/bitmanip.md: Fix splitter.
+
+2024-07-23  Marek Polacek  
+
+   * doc/extend.texi: Add missing @option.
+
+2024-07-23  Andi Kleen  
+
+   PR c/83324
+   * doc/extend.texi: Document [[musttail]]
+
+2024-07-23  Tobias Burnus  
+
+   * doc/install.texi (amdgcn-x-amdhsa): Suggest newer git version
+   for newlib.
+
+2024-07-23  Jiufu Guo  
+
+   PR target/96866
+   * config/rs6000/rs6000.cc (print_operand_address): Emit message for
+   unsupported operand.
+
+2024-07-23  Richard Biener  
+
+   PR tree-optimization/116002
+   * tree-ssa-structalias.cc (topo_visit): Also consider
+   SCALAR = SCALAR complex constraints as edges.
+
+2024-07-23  Jakub Jelinek  
+   Andrew Pinski  
+
+   PR tree-optimization/116034
+   * tree-ssa.cc (maybe_rewrite_mem_ref_base): Only use IMAGPART_EXPR
+   if MEM_REF offset is equal to element type size.
+
+2024-07-23  Richard Biener  
+
+   PR rtl-optimization/116002
+   * cselib.cc (cselib_hash_rtx): Use inchash to get proper mixing.
+   Consistently avoid a zero return value when hashing successfully.
+   Consistently treat a zero hash value from recursing as fatal.
+   Use hashval_t where appropriate.
+   (cselib_hash_plus_const_int): Likewise.
+   (new_cselib_val): Use hashval_t.
+   (cselib_lookup_1): Likewise.
+
+2024-07-23  liuhongt  
+
+   * config/i386/i386.cc (ix86_hardreg_mov_ok): Relax mov subreg
+   to hard register after split1.
+
+2024-07-23  Kewen Lin  
+
+   PR target/115713
+   * config/rs6000/rs6000.cc (rs6000_inner_target_options): Update option
+   set information for rs6000_opt_vars.
+
+2024-07-23  Kewen Lin  
+
+   PR target/115713
+   * config/rs6000/rs6000.cc (rs6000_inner_target_options): Avoid to
+   enable altivec or disable avoid-indexed-addresses automatically
+   when they get specified explicitly.
+
+2024-07-23  Kewen Lin  
+
+   PR target/115713
+   * config/rs6000/rs6000.cc (rs6000_option_override_internal): Emit error
+   messages when explicit VSX encounters explicit soft-float, no-altivec
+   or avoid-indexed-addresses.
+
+2024-07-23  Haochen Jiang  
+
+   * config/i386/i386.md (prefetchi): Change to %a.
+
+2024-07-23  Jeff Law  
+
+   PR rtl-optimization/115877
+   * ext-dce.cc (ext_dce_process_sets): Reasonably handle input/output
+   operands.
+   (ext_dce_rd_transfer_n): Drop bogus assertion.
+
+2024-07-23  Pan Li  
+
+   * config/riscv/iterators.md (ANYI_DOUBLE_TRUNC): Add new iterator
+   for int double truncation.
+   (ANYI_DOUBLE_TRUNCATED): Add new attr for int double truncation.
+   (anyi_double_truncated): Ditto but for lowercase.
+   * config/riscv/riscv-protos.h (riscv_expand_ustrunc): Add new
+   func decl for expanding ustrunc
+   * config/riscv/riscv.cc (riscv_expand_ustrunc): Add new func
+   impl to expand ustrunc.
+   * config/riscv/riscv.md (ustrunc2): Impl
+   the new pattern ustrunc2 for int.
+
 2024-07-22  Jan Hubicka  
 
PR ipa/109985
diff --git a/gcc/DATESTAMP b/gcc/DATESTAMP
index 833d506febb5..d050dd677216 100644
--- a/gcc/DATESTAMP
+++ b/gcc/DATESTAMP
@@ -1 +1 @@
-20240723
+20240724
diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog
index ea24fcfbe956..daca845240e4 100644
--- a/gcc/c-family/ChangeLog
+++ b/gcc/c-family/ChangeLog
@@ -1,3 +1,8 @@
+2024-07-23  Andi Kleen  
+
+   * c-attribs.cc (set_musttail_on_return): New function.
+   * c-common.h (set_m

[gcc/devel/fortran_unsigned] [PR rtl-optimization/115877][6/n] Add testcase from pr115877

2024-07-28 Thread Thomas Kテカnig via Gcc-cvs
https://gcc.gnu.org/g:73948d0d4ec3b7866df9e141ac49acfb86768149

commit 73948d0d4ec3b7866df9e141ac49acfb86768149
Author: Jeff Law 
Date:   Tue Jul 23 19:11:04 2024 -0600

[PR rtl-optimization/115877][6/n] Add testcase from pr115877

This just adds the testcase from pr115877.  It's working now on the trunk.  
I'm
not done with cleanups/bugfixing, but there's no reason to not have the
testcase installed at this point.

PR rtl-optimization/115877
gcc/testsuite
* gcc.dg/torture/pr115877.c: New test.

Diff:
---
 gcc/testsuite/gcc.dg/torture/pr115877.c | 20 
 1 file changed, 20 insertions(+)

diff --git a/gcc/testsuite/gcc.dg/torture/pr115877.c 
b/gcc/testsuite/gcc.dg/torture/pr115877.c
new file mode 100644
index ..432b1280b177
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr115877.c
@@ -0,0 +1,20 @@
+/* { dg-do run { target int128 } } */
+
+char a[16];
+unsigned short u;
+
+__int128
+foo (int i)
+{
+  i -= (unsigned short) ~u;
+  a[(unsigned short) i] = 1;
+  return i;
+}
+
+int
+main ()
+{
+  __int128 x = foo (0);
+  if (x != -0x)
+__builtin_abort();
+}


[gcc/devel/fortran_unsigned] Internal-fn: Only allow modes describe types for internal fn[PR115961]

2024-07-28 Thread Thomas Kテカnig via Gcc-cvs
https://gcc.gnu.org/g:984eaee93bc70992a2993ab0f54f18419bc4b864

commit 984eaee93bc70992a2993ab0f54f18419bc4b864
Author: Pan Li 
Date:   Thu Jul 18 17:23:36 2024 +0800

Internal-fn: Only allow modes describe types for internal fn[PR115961]

The direct_internal_fn_supported_p has no restrictions for the type
modes.  For example the bitfield like below will be recog as .SAT_TRUNC.

struct e
{
  unsigned pre : 12;
  unsigned a : 4;
};

__attribute__((noipa))
void bug (e * v, unsigned def, unsigned use) {
  e & defE = *v;
  defE.a = min_u (use + 1, 0xf);
}

This patch would like to add checks for the direct_internal_fn_supported_p,
and only allows the tree types describled by modes.

The below test suites are passed for this patch:
1. The rv64gcv fully regression tests.
2. The x86 bootstrap tests.
3. The x86 fully regression tests.

PR target/115961

gcc/ChangeLog:

* internal-fn.cc (type_strictly_matches_mode_p): Add new func
impl to check type strictly matches mode or not.
(type_pair_strictly_matches_mode_p): Ditto but for tree type
pair.
(direct_internal_fn_supported_p): Add above check for the tree
type pair.

gcc/testsuite/ChangeLog:

* g++.dg/torture/pr115961-run-1.C: New test.

Signed-off-by: Pan Li 

Diff:
---
 gcc/internal-fn.cc| 32 +++
 gcc/testsuite/g++.dg/torture/pr115961-run-1.C | 32 +++
 2 files changed, 64 insertions(+)

diff --git a/gcc/internal-fn.cc b/gcc/internal-fn.cc
index 95946bfd6839..8a2e07f2f965 100644
--- a/gcc/internal-fn.cc
+++ b/gcc/internal-fn.cc
@@ -4164,6 +4164,35 @@ direct_internal_fn_optab (internal_fn fn)
   gcc_unreachable ();
 }
 
+/* Return true if TYPE's mode has the same format as TYPE, and if there is
+   a 1:1 correspondence between the values that the mode can store and the
+   values that the type can store.  */
+
+static bool
+type_strictly_matches_mode_p (const_tree type)
+{
+  if (VECTOR_TYPE_P (type))
+return VECTOR_MODE_P (TYPE_MODE (type));
+
+  if (INTEGRAL_TYPE_P (type))
+return type_has_mode_precision_p (type);
+
+  if (SCALAR_FLOAT_TYPE_P (type) || COMPLEX_FLOAT_TYPE_P (type))
+return true;
+
+  return false;
+}
+
+/* Returns true if both types of TYPE_PAIR strictly match their modes,
+   else returns false.  */
+
+static bool
+type_pair_strictly_matches_mode_p (tree_pair type_pair)
+{
+  return type_strictly_matches_mode_p (type_pair.first)
+&& type_strictly_matches_mode_p (type_pair.second);
+}
+
 /* Return true if FN is supported for the types in TYPES when the
optimization type is OPT_TYPE.  The types are those associated with
the "type0" and "type1" fields of FN's direct_internal_fn_info
@@ -4173,6 +4202,9 @@ bool
 direct_internal_fn_supported_p (internal_fn fn, tree_pair types,
optimization_type opt_type)
 {
+  if (!type_pair_strictly_matches_mode_p (types))
+return false;
+
   switch (fn)
 {
 #define DEF_INTERNAL_FN(CODE, FLAGS, FNSPEC) \
diff --git a/gcc/testsuite/g++.dg/torture/pr115961-run-1.C 
b/gcc/testsuite/g++.dg/torture/pr115961-run-1.C
new file mode 100644
index ..787f7245457d
--- /dev/null
+++ b/gcc/testsuite/g++.dg/torture/pr115961-run-1.C
@@ -0,0 +1,32 @@
+/* PR target/115961 */
+/* { dg-do run } */
+
+struct e
+{
+  unsigned pre : 12;
+  unsigned a : 4;
+};
+
+static unsigned min_u (unsigned a, unsigned b)
+{
+  return (b < a) ? b : a;
+}
+
+__attribute__((noipa))
+void bug (e * v, unsigned def, unsigned use) {
+  e & defE = *v;
+  defE.a = min_u (use + 1, 0xf);
+}
+
+__attribute__((noipa, optimize(0)))
+int main(void)
+{
+  e v = { 0xded, 3 };
+
+  bug(&v, 32, 33);
+
+  if (v.a != 0xf)
+__builtin_abort ();
+
+  return 0;
+}


[gcc/devel/fortran_unsigned] x86: Don't enable APX_F in 32-bit mode

2024-07-28 Thread Thomas Kテカnig via Gcc-cvs
https://gcc.gnu.org/g:18dd6a050f175ac59c343ba9f0dcfd9bb0e25619

commit 18dd6a050f175ac59c343ba9f0dcfd9bb0e25619
Author: Lingling Kong 
Date:   Wed Jul 24 14:52:47 2024 +0800

x86: Don't enable APX_F in 32-bit mode

gcc/ChangeLog:

PR target/115978
* config/i386/driver-i386.cc (host_detect_local_cpu):  Enable
APX_F only for 64-bit codegen.
* config/i386/i386-options.cc (DEF_PTA):  Skip PTA_APX_F if
not in 64-bit mode.

gcc/testsuite/ChangeLog:

PR target/115978
* gcc.target/i386/pr115978-1.c: New test.
* gcc.target/i386/pr115978-2.c: Ditto.

Diff:
---
 gcc/config/i386/driver-i386.cc |  3 ++-
 gcc/config/i386/i386-options.cc|  3 ++-
 gcc/testsuite/gcc.target/i386/pr115978-1.c | 22 ++
 gcc/testsuite/gcc.target/i386/pr115978-2.c |  6 ++
 4 files changed, 32 insertions(+), 2 deletions(-)

diff --git a/gcc/config/i386/driver-i386.cc b/gcc/config/i386/driver-i386.cc
index 11470eaea125..445f5640155a 100644
--- a/gcc/config/i386/driver-i386.cc
+++ b/gcc/config/i386/driver-i386.cc
@@ -900,7 +900,8 @@ const char *host_detect_local_cpu (int argc, const char 
**argv)
if (has_feature (isa_names_table[i].feature))
  {
if (codegen_x86_64
-   || isa_names_table[i].feature != FEATURE_UINTR)
+   || (isa_names_table[i].feature != FEATURE_UINTR
+   && isa_names_table[i].feature != FEATURE_APX_F))
  options = concat (options, " ",
isa_names_table[i].option, NULL);
  }
diff --git a/gcc/config/i386/i386-options.cc b/gcc/config/i386/i386-options.cc
index 059ef3ae6ad4..1c8f7835af2b 100644
--- a/gcc/config/i386/i386-options.cc
+++ b/gcc/config/i386/i386-options.cc
@@ -2351,7 +2351,8 @@ ix86_option_override_internal (bool main_args_p,
 #define DEF_PTA(NAME) \
if (((processor_alias_table[i].flags & PTA_ ## NAME) != 0) \
&& PTA_ ## NAME != PTA_64BIT \
-   && (TARGET_64BIT || PTA_ ## NAME != PTA_UINTR) \
+   && (TARGET_64BIT || (PTA_ ## NAME != PTA_UINTR \
+&& PTA_ ## NAME != PTA_APX_F))\
&& !TARGET_EXPLICIT_ ## NAME ## _P (opts)) \
  SET_TARGET_ ## NAME (opts);
 #include "i386-isa.def"
diff --git a/gcc/testsuite/gcc.target/i386/pr115978-1.c 
b/gcc/testsuite/gcc.target/i386/pr115978-1.c
new file mode 100644
index ..18a1c5f153a3
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr115978-1.c
@@ -0,0 +1,22 @@
+/* { dg-do run } */
+/* { dg-options "-O2 -march=native" } */
+
+int
+main ()
+{
+  if (__builtin_cpu_supports ("apxf"))
+{
+#ifdef __x86_64__
+# ifndef __APX_F__
+  __builtin_abort ();
+# endif
+#else
+# ifdef __APX_F__
+  __builtin_abort ();
+# endif
+#endif
+  return 0;
+}
+
+  return 0;
+}
diff --git a/gcc/testsuite/gcc.target/i386/pr115978-2.c 
b/gcc/testsuite/gcc.target/i386/pr115978-2.c
new file mode 100644
index ..900d6eb096ad
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr115978-2.c
@@ -0,0 +1,6 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -march=native -mno-apxf" } */
+
+#ifdef __APX_F__
+# error APX_F should be disabled
+#endif


[gcc/devel/fortran_unsigned] RISC-V: Disable Zba optimization pattern if XTheadMemIdx is enabled

2024-07-28 Thread Thomas Kテカnig via Gcc-cvs
https://gcc.gnu.org/g:a0c89d90d3bd8ac6aeb4ef4d70caef7f6a60ff8d

commit a0c89d90d3bd8ac6aeb4ef4d70caef7f6a60ff8d
Author: Christoph Müllner 
Date:   Tue Jul 23 14:48:02 2024 +0200

RISC-V: Disable Zba optimization pattern if XTheadMemIdx is enabled

It is possible that the Zba optimization pattern zero_extendsidi2_bitmanip
matches for a XTheadMemIdx INSN with the effect of emitting an invalid
instruction as reported in PR116035.

The pattern above is used to emit a zext.w instruction to zero-extend
SI mode registers to DI mode.  A similar functionality can be achieved
by XTheadBb's th.extu instruction.  And indeed, we have the equivalent
pattern in thead.md (zero_extendsidi2_th_extu).  However, that pattern
depends on !TARGET_XTHEADMEMIDX.  To compensate for that, there are
specific patterns that ensure that zero-extension instruction can still
be emitted (th_memidx_bb_zero_extendsidi2 and friends).

While we could implement something similar (th_memidx_zba_zero_extendsidi2)
it would only make sense, if there existed real HW that does implement Zba
and XTheadMemIdx, but not XTheadBb.  Unless such a machine exists, let's
simply disable zero_extendsidi2_bitmanip if XTheadMemIdx is available.

PR target/116035

gcc/ChangeLog:

* config/riscv/bitmanip.md: Disable zero_extendsidi2_bitmanip
for XTheadMemIdx.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/pr116035-1.c: New test.
* gcc.target/riscv/pr116035-2.c: New test.

Reported-by: Patrick O'Neill 
Signed-off-by: Christoph Müllner 

Diff:
---
 gcc/config/riscv/bitmanip.md|  2 +-
 gcc/testsuite/gcc.target/riscv/pr116035-1.c | 29 +
 gcc/testsuite/gcc.target/riscv/pr116035-2.c | 26 ++
 3 files changed, 56 insertions(+), 1 deletion(-)

diff --git a/gcc/config/riscv/bitmanip.md b/gcc/config/riscv/bitmanip.md
index d262430485e7..9fc5215d6e35 100644
--- a/gcc/config/riscv/bitmanip.md
+++ b/gcc/config/riscv/bitmanip.md
@@ -22,7 +22,7 @@
 (define_insn "*zero_extendsidi2_bitmanip"
   [(set (match_operand:DI 0 "register_operand" "=r,r")
(zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "r,m")))]
-  "TARGET_64BIT && TARGET_ZBA"
+  "TARGET_64BIT && TARGET_ZBA && !TARGET_XTHEADMEMIDX"
   "@
zext.w\t%0,%1
lwu\t%0,%1"
diff --git a/gcc/testsuite/gcc.target/riscv/pr116035-1.c 
b/gcc/testsuite/gcc.target/riscv/pr116035-1.c
new file mode 100644
index ..bc45941ff8f0
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/pr116035-1.c
@@ -0,0 +1,29 @@
+/* { dg-do compile } */
+/* { dg-skip-if "" { *-*-* } { "-O0" "-O1" "-Og" "-Os" "-Oz" } } */
+/* { dg-options "-march=rv64g_zba_xtheadmemidx" { target { rv64 } } } */
+/* { dg-options "-march=rv32g_zba_xtheadmemidx" { target { rv32 } } } */
+
+void a(long);
+unsigned b[11];
+void c()
+{
+  for (int d = 0; d < 11; ++d)
+a(b[d]);
+}
+
+#if __riscv_xlen == 64
+unsigned long zext64_32(unsigned int u32)
+{
+  /* Missed optimization for Zba+XTheadMemIdx.  */
+  return u32; //zext.w a0, a0
+}
+#endif
+
+/* { dg-final { scan-assembler "th.lwuia\t\[a-x0-9\]+,\\(\[a-x0-9\]+\\),4,0" { 
target rv64 } } } */
+/* { dg-final { scan-assembler "th.lwia\t\[a-x0-9\]+,\\(\[a-x0-9\]+\\),4,0" { 
target rv32 } } } */
+
+/* { dg-final { scan-assembler-not "lwu\t\[a-x0-9\]+,\(\[a-x0-9\]+\),4,0" } } 
*/
+
+/* Missed optimizations for Zba+XTheadMemIdx.  */
+/* { dg-final { scan-assembler "zext.w\t" { target rv64 xfail rv64 } } } */
+
diff --git a/gcc/testsuite/gcc.target/riscv/pr116035-2.c 
b/gcc/testsuite/gcc.target/riscv/pr116035-2.c
new file mode 100644
index ..2c1a96948605
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/pr116035-2.c
@@ -0,0 +1,26 @@
+/* { dg-do compile } */
+/* { dg-skip-if "" { *-*-* } { "-O0" "-O1" "-Og" "-Os" "-Oz" } } */
+/* { dg-options "-march=rv64g_xtheadbb_xtheadmemidx" { target { rv64 } } } */
+/* { dg-options "-march=rv32g_xtheadbb_xtheadmemidx" { target { rv32 } } } */
+
+void a(long);
+unsigned b[11];
+void c()
+{
+  for (int d = 0; d < 11; ++d)
+a(b[d]);
+}
+
+#if __riscv_xlen == 64
+unsigned long zext64_32(unsigned int u32)
+{
+return u32; //th.extu a0, a0, 31, 0
+}
+#endif
+
+/* { dg-final { scan-assembler "th.lwuia\t\[a-x0-9\]+,\\(\[a-x0-9\]+\\),4,0" { 
target { rv64 } } } } */
+/* { dg-final { scan-assembler "th.lwia\t\[a-x0-9\]+,\\(\[a-x0-9\]+\\),4,0" { 
target { rv32 } } } } */
+
+/* { dg-final { scan-assembler-not "lwu\t\[a-x0-9\]+,\\(\[a-x0-9\]+\\),4,0" } 
} */
+
+/* { dg-final { scan-assembler "th.extu\t" { target rv64 } } } */


[gcc/devel/fortran_unsigned] [MAINTAINERS] Update email and move to DCO

2024-07-28 Thread Thomas Kテカnig via Gcc-cvs
https://gcc.gnu.org/g:75f31ee1a00ef2ccac8d78854cf3295b6ac2ca19

commit 75f31ee1a00ef2ccac8d78854cf3295b6ac2ca19
Author: Matthew Malcomson 
Date:   Tue Jul 23 14:56:41 2024 +0100

[MAINTAINERS] Update email and move to DCO

* MAINTAINERS: Update my email address.

Signed-off-by: Matthew Malcomson 

Diff:
---
 MAINTAINERS | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index 200a223b431f..542d058d727c 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -636,7 +636,7 @@ Luis Machadoluisgpm 

 Ziga Mahkovec   ziga
 Vladimir Makarovvmakarov
 David Malcolm   dmalcolm
-Matthew Malcomson   matmal01
+Matthew Malcomson   matmal01
 Mikhail Maltsev miyuki  
 Jose E. Marchesijemarch 
 Stamatis Markianos-Wright   stammark
@@ -922,6 +922,7 @@ Jeff Law

 Jeff Law
 Jeff Law
 H.J. Lu 
+Matthew Malcomson   
 Immad Mir   
 Gaius Mulley
 Andrew Pinski   


[gcc/devel/fortran_unsigned] libstdc++: Clean up @diff@ markup in some I/O tests

2024-07-28 Thread Thomas Kテカnig via Libstdc++-cvs
https://gcc.gnu.org/g:2fab7daf202d5df7318191a835caeb2fbc342e31

commit 2fab7daf202d5df7318191a835caeb2fbc342e31
Author: Jonathan Wakely 
Date:   Mon Jul 22 13:00:26 2024 +0100

libstdc++: Clean up @diff@ markup in some I/O tests

We have a number of 27_io/* tests with comments like this:

// @require@ %-*.tst
// @diff@ %-*.tst %-*.txt

It seems that these declare required data files used by the test and a
post-test action to compare the test output with the expected result.
We do have tests that depend on some *.tst and/or *.txt files that are
copied from testsuite/data into each test's working directory before it
runs, so the comments are related to those dependencies.  However,
nothing in the current test framework actually makes use of these
comments. Currently, every test gets a fresh copy of every *.tst and
*.txt file in the testsuite/data directory, whether the test actually
requires them or not.

This change is the first in a series to clean up this unused markup in
the tests. This first step is to just remove all @require@ and @diff@
comments where they seem to serve no purpose at all. These tests do not
open any of the *.tst or *.txt files that are copied into the test's
working directory from the testsuite/data directory, so they don't
"require" any of those files, and there's no need to "diff" them after
the test runs.

libstdc++-v3/ChangeLog:

* testsuite/27_io/basic_filebuf/close/char/4879.cc: Remove
@require@ and @diff@ comments.
* testsuite/27_io/basic_filebuf/close/char/9964.cc: Likewise.
* testsuite/27_io/basic_filebuf/open/char/3.cc: Likewise.
* testsuite/27_io/basic_filebuf/open/char/9507.cc: Likewise.
* testsuite/27_io/basic_filebuf/sbumpc/char/1-out.cc: Likewise.
* testsuite/27_io/basic_filebuf/sbumpc/char/2-out.cc: Likewise.
* testsuite/27_io/basic_filebuf/sgetc/char/1-out.cc: Likewise.
* testsuite/27_io/basic_filebuf/sgetc/char/2-out.cc: Likewise.
* testsuite/27_io/basic_filebuf/sgetn/char/1-out.cc: Likewise.
* testsuite/27_io/basic_filebuf/sgetn/char/2-out.cc: Likewise.
* testsuite/27_io/basic_filebuf/snextc/char/2-out.cc: Likewise.
* testsuite/27_io/basic_filebuf/sputbackc/char/1-io.cc:
Likewise.
* testsuite/27_io/basic_filebuf/sputbackc/char/1-out.cc:
Likewise.
* testsuite/27_io/basic_filebuf/sputbackc/char/2-io.cc:
Likewise.
* testsuite/27_io/basic_filebuf/sputbackc/char/2-out.cc:
Likewise.
* testsuite/27_io/basic_filebuf/sputc/char/1-out.cc: Likewise.
* testsuite/27_io/basic_filebuf/sputc/char/2-out.cc: Likewise.
* testsuite/27_io/basic_filebuf/sputn/char/1-out.cc: Likewise.
* testsuite/27_io/basic_filebuf/sputn/char/2-out.cc: Likewise.
* testsuite/27_io/basic_filebuf/sungetc/char/1-io.cc: Likewise.
* testsuite/27_io/basic_filebuf/sungetc/char/1-out.cc: Likewise.
* testsuite/27_io/basic_filebuf/sungetc/char/2-io.cc: Likewise.
* testsuite/27_io/basic_filebuf/sungetc/char/2-out.cc: Likewise.
* testsuite/27_io/basic_filebuf/sputc/char/1-io.cc: Likewise.
Remove unused variable.
* testsuite/27_io/basic_filebuf/sputn/char/2-io.cc: Likewise.
* testsuite/27_io/basic_ofstream/cons/char/1.cc: Remove
@require@ and @diff@ comments. Remove unused variables.
* testsuite/27_io/basic_ofstream/rdbuf/char/2832.cc: Remove
* testsuite/27_io/ios_base/sync_with_stdio/2.cc: Likewise.

Diff:
---
 libstdc++-v3/testsuite/27_io/basic_filebuf/close/char/4879.cc  |  4 +---
 libstdc++-v3/testsuite/27_io/basic_filebuf/close/char/9964.cc  |  4 +---
 libstdc++-v3/testsuite/27_io/basic_filebuf/open/char/3.cc  |  4 +---
 libstdc++-v3/testsuite/27_io/basic_filebuf/open/char/9507.cc   |  4 +---
 .../testsuite/27_io/basic_filebuf/sbumpc/char/1-out.cc |  5 +
 .../testsuite/27_io/basic_filebuf/sbumpc/char/2-out.cc |  5 +
 libstdc++-v3/testsuite/27_io/basic_filebuf/sgetc/char/1-out.cc |  5 +
 libstdc++-v3/testsuite/27_io/basic_filebuf/sgetc/char/2-out.cc |  5 +
 libstdc++-v3/testsuite/27_io/basic_filebuf/sgetn/char/1-out.cc |  5 +
 libstdc++-v3/testsuite/27_io/basic_filebuf/sgetn/char/2-out.cc |  5 +
 .../testsuite/27_io/basic_filebuf/snextc/char/2-out.cc |  5 +
 .../testsuite/27_io/basic_filebuf/sputbackc/char/1-io.cc   |  5 +
 .../testsuite/27_io/basic_filebuf/sputbackc/char/1-out.cc  |  5 +
 .../testsuite/27_io/basic_filebuf/sputbackc/char/2-io.cc   |  5 +
 .../testsuite/27_io/basic_filebuf/sputbackc/char/2-out.cc  |  5 +
 libstdc++-v3/testsuite/27_io/basic_filebuf/sputc/char/1-io.cc  |  6 +-
 libstdc++-v3/t

[gcc/devel/fortran_unsigned] libstdc++: Replace @require@ markup in some I/O tests

2024-07-28 Thread Thomas Kテカnig via Libstdc++-cvs
https://gcc.gnu.org/g:e56026cec6a1834861a855da5f29b513bc5f7bfe

commit e56026cec6a1834861a855da5f29b513bc5f7bfe
Author: Jonathan Wakely 
Date:   Wed Jul 17 13:27:19 2024 +0100

libstdc++: Replace @require@ markup in some I/O tests

We can replace the @require@ markup with { dg-additional-files ... }
directives, so that the required files are explicitly named and are
explicitly copied into place for tests that require it. This will allow
a later change to remove the "Copy all required data files" step in the
proc libstdc++_init in testsuite/lib/libstdc++.exp that is marked TODO.
This commit uses dg-additional-files for a subset of the files that
contain @require@.

Also remove the @diff@ markup where appears to be copy & pasted from
other test files, and so serves no purpose. For example, there is no
output file created by 27_io/basic_ifstream/cons/char/1.cc so there is
nothing for @diff@ to compare. Maybe the purpose was to check that
reading the .tst file with an ifstream doesn't change it, but we've
survived without doing those comparisons for many years so I think we
can remove those cases of @diff@ markup.

libstdc++-v3/ChangeLog:

* testsuite/27_io/basic_filebuf/close/char/2.cc: Remove
@require@ and @diff@ markup. Use dg-additional-files. Remove
unused variable.
* testsuite/27_io/basic_filebuf/close/char/3.cc: Remove
@require@ and @diff@ markup. Use dg-additional-files.
* testsuite/27_io/basic_filebuf/close/char/4.cc: Likewise.
* testsuite/27_io/basic_filebuf/close/char/5.cc: Likewise.
* testsuite/27_io/basic_filebuf/in_avail/char/1.cc: Likewise.
* testsuite/27_io/basic_filebuf/is_open/char/1.cc: Likewise.
* testsuite/27_io/basic_filebuf/open/char/1.cc: Likewise.
* testsuite/27_io/basic_filebuf/open/char/2.cc: Likewise.
* testsuite/27_io/basic_filebuf/sbumpc/char/1-in.cc: Likewise.
* testsuite/27_io/basic_filebuf/sbumpc/char/1-io.cc: Likewise.
* testsuite/27_io/basic_filebuf/sbumpc/char/2-in.cc: Likewise.
* testsuite/27_io/basic_filebuf/sbumpc/char/2-io.cc: Likewise.
* testsuite/27_io/basic_filebuf/seekoff/char/1-in.cc: Likewise.
* testsuite/27_io/basic_filebuf/seekoff/char/1-out.cc: Likewise.
* testsuite/27_io/basic_filebuf/seekoff/char/2-in.cc: Likewise.
* testsuite/27_io/basic_filebuf/seekoff/char/2-out.cc: Likewise.
* testsuite/27_io/basic_filebuf/seekpos/char/1-in.cc: Likewise.
* testsuite/27_io/basic_filebuf/seekpos/char/1-out.cc: Likewise.
* testsuite/27_io/basic_filebuf/seekpos/char/2-in.cc: Likewise.
* testsuite/27_io/basic_filebuf/seekpos/char/2-out.cc: Likewise.
* testsuite/27_io/basic_filebuf/sgetc/char/1-in.cc: Likewise.
* testsuite/27_io/basic_filebuf/sgetc/char/1-io.cc: Likewise.
* testsuite/27_io/basic_filebuf/sgetc/char/2-in.cc: Likewise.
* testsuite/27_io/basic_filebuf/sgetc/char/2-io.cc: Likewise.
* testsuite/27_io/basic_filebuf/sgetn/char/1-in.cc: Likewise.
* testsuite/27_io/basic_filebuf/sgetn/char/1-io.cc: Likewise.
* testsuite/27_io/basic_filebuf/sgetn/char/2-in.cc: Likewise.
* testsuite/27_io/basic_filebuf/sgetn/char/2-io.cc: Likewise.
* testsuite/27_io/basic_filebuf/snextc/char/1-in.cc: Likewise.
* testsuite/27_io/basic_filebuf/snextc/char/1-io.cc: Likewise.
* testsuite/27_io/basic_filebuf/snextc/char/1-out.cc: Likewise.
* testsuite/27_io/basic_filebuf/snextc/char/2-in.cc: Likewise.
* testsuite/27_io/basic_filebuf/snextc/char/2-io.cc: Likewise.
* testsuite/27_io/basic_filebuf/sputbackc/char/1-in.cc:
Likewise.
* testsuite/27_io/basic_filebuf/sputbackc/char/2-in.cc:
Likewise.
* testsuite/27_io/basic_filebuf/sputc/char/1-in.cc: Likewise.
* testsuite/27_io/basic_filebuf/sputc/char/2-in.cc: Likewise.
* testsuite/27_io/basic_filebuf/sputc/char/2-io.cc: Likewise.
* testsuite/27_io/basic_filebuf/sputn/char/1-in.cc: Likewise.
* testsuite/27_io/basic_filebuf/sputn/char/1-io.cc: Likewise.
Remove unused variable.
* testsuite/27_io/basic_filebuf/sputn/char/2-in.cc: Remove
@require@ and @diff@ markup. Use dg-additional-files.
* testsuite/27_io/basic_filebuf/sungetc/char/1-in.cc: Likewise.
* testsuite/27_io/basic_filebuf/sungetc/char/2-in.cc: Likewise.
* testsuite/27_io/basic_ifstream/cons/char/1.cc: Likewise.
* testsuite/27_io/basic_ifstream/open/char/1.cc: Likewise.
* testsuite/27_io/basic_ifstream/rdbuf/char/2832.cc: Likewise.
* testsuite/27_io/basic_istream/readsome/char/67

[gcc/devel/fortran_unsigned] libstdc++: Use dg-additional-files in some I/O tests

2024-07-28 Thread Thomas Kテカnig via Libstdc++-cvs
https://gcc.gnu.org/g:815d1e048ac50f718e351fba0b2ef11319fab1dd

commit 815d1e048ac50f718e351fba0b2ef11319fab1dd
Author: Jonathan Wakely 
Date:   Mon Jul 22 14:01:43 2024 +0100

libstdc++: Use dg-additional-files in some I/O tests

Use the dg-additional-files directive to declare files that need to be
copied into the test's working directory. This is currently redundant
(as all .tst and .txt files are copied for all tests) but is a step
towards not copying all files.

libstdc++-v3/ChangeLog:

* testsuite/27_io/basic_filebuf/imbue/char/2.cc: Use
dg-additional-files.
* testsuite/27_io/basic_filebuf/imbue/wchar_t/2.cc: Likewise.
* testsuite/27_io/basic_filebuf/open/char/path.cc: Likewise.
* testsuite/27_io/basic_filebuf/pbackfail/char/9761.cc:
Likewise.
* testsuite/27_io/basic_filebuf/seekoff/char/3-in.cc: Likewise.
* testsuite/27_io/basic_filebuf/seekoff/char/3-io.cc: Likewise.
* testsuite/27_io/basic_filebuf/seekpos/char/3-in.cc: Likewise.
* testsuite/27_io/basic_filebuf/seekpos/char/3-io.cc: Likewise.
* testsuite/27_io/basic_filebuf/setbuf/char/1.cc: Likewise.
* testsuite/27_io/basic_filebuf/sgetn/char/3.cc: Likewise.
* testsuite/27_io/basic_filebuf/underflow/10096.cc: Likewise.
* testsuite/27_io/basic_fstream/cons/char/path.cc: Likewise.
* testsuite/27_io/basic_fstream/open/char/path.cc: Likewise.
* testsuite/27_io/basic_ifstream/assign/1.cc: Likewise.
* testsuite/27_io/basic_ifstream/cons/move.cc: Likewise.
* testsuite/27_io/basic_ifstream/cons/char/path.cc: Likewise.
* testsuite/27_io/basic_ifstream/open/char/path.cc: Likewise.
* testsuite/27_io/basic_ifstream/open/wchar_t/1.cc: Likewise.
* testsuite/27_io/objects/char/10.cc: Likewise.
* testsuite/27_io/objects/char/12048-1.cc: Likewise.
* testsuite/27_io/objects/char/12048-2.cc: Likewise.
* testsuite/27_io/objects/char/12048-3.cc: Likewise.
* testsuite/27_io/objects/char/12048-4.cc: Likewise.
* testsuite/27_io/objects/char/12048-5.cc: Likewise.
* testsuite/27_io/objects/wchar_t/12048-1.cc: Likewise.
* testsuite/27_io/objects/wchar_t/12048-2.cc: Likewise.
* testsuite/27_io/objects/wchar_t/12048-3.cc: Likewise.
* testsuite/27_io/objects/wchar_t/12048-4.cc: Likewise.
* testsuite/27_io/objects/wchar_t/12048-5.cc: Likewise.
* testsuite/ext/stdio_sync_filebuf/char/12048-1.cc: Likewise.
* testsuite/ext/stdio_sync_filebuf/char/12048-2.cc: Likewise.
* testsuite/ext/stdio_sync_filebuf/char/12048-3.cc: Likewise.
* testsuite/ext/stdio_sync_filebuf/char/12048-4.cc: Likewise.
* testsuite/ext/stdio_sync_filebuf/wchar_t/12948-1.cc: Likewise.
* testsuite/ext/stdio_sync_filebuf/wchar_t/12948-2.cc: Likewise.
* testsuite/ext/stdio_sync_filebuf/wchar_t/12948-3.cc: Likewise.
* testsuite/ext/stdio_sync_filebuf/wchar_t/12948-4.cc: Likewise.

Diff:
---
 libstdc++-v3/testsuite/27_io/basic_filebuf/imbue/char/2.cc| 4 +++-
 libstdc++-v3/testsuite/27_io/basic_filebuf/imbue/wchar_t/2.cc | 1 +
 libstdc++-v3/testsuite/27_io/basic_filebuf/open/char/path.cc  | 1 +
 libstdc++-v3/testsuite/27_io/basic_filebuf/pbackfail/char/9761.cc | 1 +
 libstdc++-v3/testsuite/27_io/basic_filebuf/seekoff/char/3-in.cc   | 3 ++-
 libstdc++-v3/testsuite/27_io/basic_filebuf/seekoff/char/3-io.cc   | 3 ++-
 libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/char/3-in.cc   | 1 +
 libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/char/3-io.cc   | 1 +
 libstdc++-v3/testsuite/27_io/basic_filebuf/setbuf/char/1.cc   | 1 +
 libstdc++-v3/testsuite/27_io/basic_filebuf/sgetn/char/3.cc| 1 +
 libstdc++-v3/testsuite/27_io/basic_filebuf/underflow/10096.cc | 1 +
 libstdc++-v3/testsuite/27_io/basic_fstream/cons/char/path.cc  | 1 +
 libstdc++-v3/testsuite/27_io/basic_fstream/open/char/path.cc  | 1 +
 libstdc++-v3/testsuite/27_io/basic_ifstream/assign/1.cc   | 3 ++-
 libstdc++-v3/testsuite/27_io/basic_ifstream/cons/char/path.cc | 1 +
 libstdc++-v3/testsuite/27_io/basic_ifstream/cons/move.cc  | 3 ++-
 libstdc++-v3/testsuite/27_io/basic_ifstream/open/char/path.cc | 1 +
 libstdc++-v3/testsuite/27_io/basic_ifstream/open/wchar_t/1.cc | 3 ++-
 libstdc++-v3/testsuite/27_io/objects/char/10.cc   | 1 +
 libstdc++-v3/testsuite/27_io/objects/char/12048-1.cc  | 1 +
 libstdc++-v3/testsuite/27_io/objects/char/12048-2.cc  | 1 +
 libstdc++-v3/testsuite/27_io/objects/char/12048-3.cc  | 1 +
 libstdc++-v3/testsuite/27_io/objects/char/12048-4.cc  | 1 +
 libstdc++-v3/testsuite/27_io/objects/char/12048-5.cc  | 1 +

[gcc/devel/fortran_unsigned] libstdc++: Add file-io-diff to replace @diff@ markup in I/O tests

2024-07-28 Thread Thomas Kテカnig via Libstdc++-cvs
https://gcc.gnu.org/g:5552c6fc01f5b9402ca48a7ffa548aa9fb1d4387

commit 5552c6fc01f5b9402ca48a7ffa548aa9fb1d4387
Author: Jonathan Wakely 
Date:   Mon Jul 22 14:39:57 2024 +0100

libstdc++: Add file-io-diff to replace @diff@ markup in I/O tests

This adds a new dg-final action to compare two files after a test has
run, so that we can verify that fstream operations produce the expected
results. With this change, all uses of @diff@ that seem potentially
useful have been converted to actually compare the files and FAIL if
they differ.

The file-io-diff action can take two arguments naming the files to be
compared, or for convenience it can take a single string and will
compare STR.tst and STR.txt, as that's how it's commonly used.

Additionally, all remaining uses of @require@ are converted to
dg-additional-files directives, so that the TODO in libstdc++.exp can
be resolved.

libstdc++-v3/ChangeLog:

* testsuite/27_io/basic_filebuf/close/char/1.cc: Remove
@require@ and @diff@. Use dg-final file-io-diff action.
* testsuite/27_io/basic_istream/extractors_other/char/2.cc:
Likewise.
* testsuite/27_io/basic_istream/extractors_other/wchar_t/2.cc:
Likewise.
* testsuite/27_io/basic_istream/get/char/2.cc: Likewise.
* testsuite/27_io/basic_istream/get/wchar_t/2.cc: Likewise.
* testsuite/27_io/basic_istream/ignore/char/3.cc: Likewise.
* testsuite/27_io/basic_istream/ignore/wchar_t/3.cc: Likewise.
* testsuite/27_io/basic_istream/peek/char/6414.cc: Likewise.
* testsuite/27_io/basic_istream/peek/wchar_t/6414.cc: Likewise.
* testsuite/27_io/basic_istream/seekg/char/fstream.cc: Likewise.
* testsuite/27_io/basic_istream/seekg/wchar_t/fstream.cc:
Likewise.
* testsuite/27_io/basic_istream/tellg/char/fstream.cc: Likewise.
* testsuite/27_io/basic_istream/tellg/wchar_t/fstream.cc:
Likewise.
* testsuite/27_io/basic_ofstream/open/char/1.cc: Likewise.
* testsuite/27_io/basic_ostream/inserters_other/char/1.cc:
Likewise.
* testsuite/27_io/basic_ostream/inserters_other/wchar_t/1.cc:
Likewise.
* testsuite/27_io/ios_base/sync_with_stdio/1.cc: Likewise.
* testsuite/27_io/basic_ostream/inserters_other/char/2.cc:
Likewise. Check file positions.
* testsuite/27_io/basic_ostream/inserters_other/wchar_t/2.cc:
Likewise.
* testsuite/lib/libstdc++.exp (file-io-diff): New proc.

Diff:
---
 .../testsuite/27_io/basic_filebuf/close/char/1.cc  |  6 ++--
 .../27_io/basic_istream/extractors_other/char/2.cc |  9 --
 .../basic_istream/extractors_other/wchar_t/2.cc|  9 --
 .../testsuite/27_io/basic_istream/get/char/2.cc|  8 --
 .../testsuite/27_io/basic_istream/get/wchar_t/2.cc |  8 --
 .../testsuite/27_io/basic_istream/ignore/char/3.cc |  8 --
 .../27_io/basic_istream/ignore/wchar_t/3.cc|  8 --
 .../27_io/basic_istream/peek/char/6414.cc  |  9 --
 .../27_io/basic_istream/peek/wchar_t/6414.cc   |  9 --
 .../27_io/basic_istream/seekg/char/fstream.cc  | 10 +--
 .../27_io/basic_istream/seekg/wchar_t/fstream.cc   | 12 +---
 .../27_io/basic_istream/tellg/char/fstream.cc  | 10 +--
 .../27_io/basic_istream/tellg/wchar_t/fstream.cc   | 10 +--
 .../testsuite/27_io/basic_ofstream/open/char/1.cc  |  5 ++--
 .../27_io/basic_ostream/inserters_other/char/1.cc  |  8 --
 .../27_io/basic_ostream/inserters_other/char/2.cc  |  7 +++--
 .../basic_ostream/inserters_other/wchar_t/1.cc |  8 --
 .../basic_ostream/inserters_other/wchar_t/2.cc |  7 +++--
 .../testsuite/27_io/ios_base/sync_with_stdio/1.cc  |  5 ++--
 libstdc++-v3/testsuite/lib/libstdc++.exp   | 32 ++
 20 files changed, 131 insertions(+), 57 deletions(-)

diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/close/char/1.cc 
b/libstdc++-v3/testsuite/27_io/basic_filebuf/close/char/1.cc
index e2b336a711d6..d9e9c53e3e6e 100644
--- a/libstdc++-v3/testsuite/27_io/basic_filebuf/close/char/1.cc
+++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/close/char/1.cc
@@ -15,14 +15,14 @@
 // with this library; see the file COPYING3.  If not see
 // .
 
-// 27.8.1.3 filebuf member functions
-// @require@ %-*.tst %-*.txt
-// @diff@ %-*.tst %-*.txt
+// C++98 27.8.1.3 filebuf member functions
 
 // various tests for filebuf::open() and filebuf::close() including
 // the non-portable functionality in the libstdc++-v3 IO library
 
 // { dg-require-fileio "" }
+// { dg-additional-files "filebuf_members-1.tst filebuf_members-1.txt" }
+// { dg-final { file-io-diff "filebuf_members-1" } }
 
 #include 
 #include 
diff --git 
a/libstdc++-v3/testsuite/27_io/basic_istream/extractors_

[gcc/devel/fortran_unsigned] libstdc++: Use dg-additional-files in some algorithm tests

2024-07-28 Thread Thomas Kテカnig via Libstdc++-cvs
https://gcc.gnu.org/g:8d9ff68d69fc4209feede3bcd43c4021f0167bc4

commit 8d9ff68d69fc4209feede3bcd43c4021f0167bc4
Author: Jonathan Wakely 
Date:   Mon Jul 22 14:01:43 2024 +0100

libstdc++: Use dg-additional-files in some algorithm tests

Use the dg-additional-files directive to declare files that need to be
copied into the test's working directory. This is currently redundant
(as all .tst and .txt files are copied for all tests) but is a step
towards not copying all files.

libstdc++-v3/ChangeLog:

* testsuite/25_algorithms/advance/istreambuf_iterators/char/2.cc:
Use dg-additional-files.
* testsuite/25_algorithms/advance/istreambuf_iterators/wchar_t/2.cc:
Likewise.
* testsuite/25_algorithms/copy/streambuf_iterators/char/4.cc:
Likewise.
* testsuite/25_algorithms/copy/streambuf_iterators/wchar_t/4.cc:
Likewise.
* testsuite/25_algorithms/copy_n/istreambuf_iterator/2.cc:
Likewise.
* testsuite/25_algorithms/copy_n/istreambuf_iterator/deque.cc:
Likewise.
* testsuite/25_algorithms/find/istreambuf_iterators/char/2.cc:
Likewise.
* testsuite/25_algorithms/find/istreambuf_iterators/wchar_t/2.cc:
Likewise.

Diff:
---
 .../testsuite/25_algorithms/advance/istreambuf_iterators/char/2.cc   | 1 +
 .../testsuite/25_algorithms/advance/istreambuf_iterators/wchar_t/2.cc| 1 +
 libstdc++-v3/testsuite/25_algorithms/copy/streambuf_iterators/char/4.cc  | 1 +
 .../testsuite/25_algorithms/copy/streambuf_iterators/wchar_t/4.cc| 1 +
 libstdc++-v3/testsuite/25_algorithms/copy_n/istreambuf_iterator/2.cc | 1 +
 libstdc++-v3/testsuite/25_algorithms/copy_n/istreambuf_iterator/deque.cc | 1 +
 libstdc++-v3/testsuite/25_algorithms/find/istreambuf_iterators/char/2.cc | 1 +
 .../testsuite/25_algorithms/find/istreambuf_iterators/wchar_t/2.cc   | 1 +
 8 files changed, 8 insertions(+)

diff --git 
a/libstdc++-v3/testsuite/25_algorithms/advance/istreambuf_iterators/char/2.cc 
b/libstdc++-v3/testsuite/25_algorithms/advance/istreambuf_iterators/char/2.cc
index 1a0635c0ccaa..c5414d4975dc 100644
--- 
a/libstdc++-v3/testsuite/25_algorithms/advance/istreambuf_iterators/char/2.cc
+++ 
b/libstdc++-v3/testsuite/25_algorithms/advance/istreambuf_iterators/char/2.cc
@@ -16,6 +16,7 @@
 // .
 
 // { dg-require-fileio "" }
+// { dg-additional-files "istream_unformatted-1.txt" }
 
 #include 
 #include 
diff --git 
a/libstdc++-v3/testsuite/25_algorithms/advance/istreambuf_iterators/wchar_t/2.cc
 
b/libstdc++-v3/testsuite/25_algorithms/advance/istreambuf_iterators/wchar_t/2.cc
index 823e275da19f..c2fd748cbf09 100644
--- 
a/libstdc++-v3/testsuite/25_algorithms/advance/istreambuf_iterators/wchar_t/2.cc
+++ 
b/libstdc++-v3/testsuite/25_algorithms/advance/istreambuf_iterators/wchar_t/2.cc
@@ -16,6 +16,7 @@
 // .
 
 // { dg-require-fileio "" }
+// { dg-additional-files "istream_unformatted-1.txt" }
 
 #include 
 #include 
diff --git 
a/libstdc++-v3/testsuite/25_algorithms/copy/streambuf_iterators/char/4.cc 
b/libstdc++-v3/testsuite/25_algorithms/copy/streambuf_iterators/char/4.cc
index 67888797047b..3d1c7c7595d8 100644
--- a/libstdc++-v3/testsuite/25_algorithms/copy/streambuf_iterators/char/4.cc
+++ b/libstdc++-v3/testsuite/25_algorithms/copy/streambuf_iterators/char/4.cc
@@ -27,6 +27,7 @@
 #include 
 
 // { dg-require-fileio "" }
+// { dg-additional-files "istream_unformatted-1.txt" }
 
 // In the occasion of libstdc++/25482
 void test01()
diff --git 
a/libstdc++-v3/testsuite/25_algorithms/copy/streambuf_iterators/wchar_t/4.cc 
b/libstdc++-v3/testsuite/25_algorithms/copy/streambuf_iterators/wchar_t/4.cc
index e1adccfdd216..8d380052313d 100644
--- a/libstdc++-v3/testsuite/25_algorithms/copy/streambuf_iterators/wchar_t/4.cc
+++ b/libstdc++-v3/testsuite/25_algorithms/copy/streambuf_iterators/wchar_t/4.cc
@@ -18,6 +18,7 @@
 // .
 
 // { dg-require-fileio "" }
+// { dg-additional-files "istream_unformatted-1.txt" }
 
 #include 
 #include 
diff --git 
a/libstdc++-v3/testsuite/25_algorithms/copy_n/istreambuf_iterator/2.cc 
b/libstdc++-v3/testsuite/25_algorithms/copy_n/istreambuf_iterator/2.cc
index 5179d78b455d..a437bedb420b 100644
--- a/libstdc++-v3/testsuite/25_algorithms/copy_n/istreambuf_iterator/2.cc
+++ b/libstdc++-v3/testsuite/25_algorithms/copy_n/istreambuf_iterator/2.cc
@@ -1,5 +1,6 @@
 // { dg-do run { target c++11 } }
 // { dg-require-fileio "" }
+// { dg-additional-files "istream_unformatted-1.txt" }
 
 // Copyright (C) 2020-2024 Free Software Foundation, Inc.
 //
diff --git 
a/libstdc++-v3/testsuite/25_algorithms/copy_n/istreambuf_iterator/deque.cc 
b/libstdc++-v3/testsuite/25_algorithms/copy_n/istreambuf_iterator/deque.cc
index 14f58998fefa..1353282f6a04 100644
--- a/libstdc++-v3/testsuite/25_algorithms/copy_n/istreambuf_iterator

[gcc/devel/fortran_unsigned] libstdc++: Use dg-additional-files in some non-I/O tests

2024-07-28 Thread Thomas Kテカnig via Libstdc++-cvs
https://gcc.gnu.org/g:6aec3ce1386d21e20b759efe28c09c4c8d8dbd28

commit 6aec3ce1386d21e20b759efe28c09c4c8d8dbd28
Author: Jonathan Wakely 
Date:   Mon Jul 22 15:15:16 2024 +0100

libstdc++: Use dg-additional-files in some non-I/O tests

libstdc++-v3/ChangeLog:

* testsuite/20_util/hash/chi2_q_document_words.cc: Use
dg-additional-files for input text.
* testsuite/performance/ext/pb_ds/all_text_find.cc: Likewise.
* testsuite/performance/ext/pb_ds/multimap_text_find.hpp:
Likewise.
* testsuite/performance/ext/pb_ds/multimap_text_insert.hpp:
Likewise.
* testsuite/performance/ext/pb_ds/multimap_text_insert_mem.hpp:
Likewise.
* testsuite/performance/ext/pb_ds/priority_queue_text_join.cc:
Likewise.
* testsuite/performance/ext/pb_ds/priority_queue_text_modify.hpp: 
Likewise.
* testsuite/performance/ext/pb_ds/priority_queue_text_pop_mem.cc: 
Likewise.
* testsuite/performance/ext/pb_ds/priority_queue_text_push.cc:
Likewise.
* testsuite/performance/ext/pb_ds/priority_queue_text_push_pop.cc: 
Likewise.
* testsuite/performance/ext/pb_ds/tree_text_insert.cc: Likewise.
* testsuite/performance/ext/pb_ds/tree_text_lor_find.cc:
Likewise.

Diff:
---
 libstdc++-v3/testsuite/20_util/hash/chi2_q_document_words.cc| 2 ++
 libstdc++-v3/testsuite/performance/ext/pb_ds/all_text_find.cc   | 2 ++
 libstdc++-v3/testsuite/performance/ext/pb_ds/multimap_text_find.hpp | 2 ++
 libstdc++-v3/testsuite/performance/ext/pb_ds/multimap_text_insert.hpp   | 2 ++
 .../testsuite/performance/ext/pb_ds/multimap_text_insert_mem.hpp| 2 ++
 .../testsuite/performance/ext/pb_ds/priority_queue_text_join.cc | 2 ++
 .../testsuite/performance/ext/pb_ds/priority_queue_text_modify.hpp  | 2 ++
 .../testsuite/performance/ext/pb_ds/priority_queue_text_pop_mem.cc  | 2 ++
 .../testsuite/performance/ext/pb_ds/priority_queue_text_push.cc | 2 ++
 .../testsuite/performance/ext/pb_ds/priority_queue_text_push_pop.cc | 2 ++
 libstdc++-v3/testsuite/performance/ext/pb_ds/tree_text_insert.cc| 2 ++
 libstdc++-v3/testsuite/performance/ext/pb_ds/tree_text_lor_find.cc  | 2 ++
 12 files changed, 24 insertions(+)

diff --git a/libstdc++-v3/testsuite/20_util/hash/chi2_q_document_words.cc 
b/libstdc++-v3/testsuite/20_util/hash/chi2_q_document_words.cc
index a6ebc0011eba..3c77527c27ce 100644
--- a/libstdc++-v3/testsuite/20_util/hash/chi2_q_document_words.cc
+++ b/libstdc++-v3/testsuite/20_util/hash/chi2_q_document_words.cc
@@ -19,6 +19,8 @@
 // along with this library; see the file COPYING3.  If not see
 // .
 
+// { dg-additional-files "thirty_years_among_the_dead_preproc.txt" }
+
 #include "chi2_quality.h"
 
 // Tests chi^2 for a set of words taken from a document written in English.
diff --git a/libstdc++-v3/testsuite/performance/ext/pb_ds/all_text_find.cc 
b/libstdc++-v3/testsuite/performance/ext/pb_ds/all_text_find.cc
index 13c73a76647d..df822c3d5f78 100644
--- a/libstdc++-v3/testsuite/performance/ext/pb_ds/all_text_find.cc
+++ b/libstdc++-v3/testsuite/performance/ext/pb_ds/all_text_find.cc
@@ -29,6 +29,8 @@
 // purpose. It is provided "as is" without express or implied
 // warranty.
 
+// { dg-additional-files "thirty_years_among_the_dead_preproc.txt" }
+
 /**
  * @file text_find_timing_test.cpp
  * Contains test for finding text.
diff --git 
a/libstdc++-v3/testsuite/performance/ext/pb_ds/multimap_text_find.hpp 
b/libstdc++-v3/testsuite/performance/ext/pb_ds/multimap_text_find.hpp
index 18e383ea17c6..dbaaf04a1b64 100644
--- a/libstdc++-v3/testsuite/performance/ext/pb_ds/multimap_text_find.hpp
+++ b/libstdc++-v3/testsuite/performance/ext/pb_ds/multimap_text_find.hpp
@@ -29,6 +29,8 @@
 // purpose. It is provided "as is" without express or implied
 // warranty.
 
+// { dg-additional-files "thirty_years_among_the_dead_preproc.txt" }
+
 /**
  * @file multimap_text_find_timing_test.cpp
  * Contains test for inserting text words.
diff --git 
a/libstdc++-v3/testsuite/performance/ext/pb_ds/multimap_text_insert.hpp 
b/libstdc++-v3/testsuite/performance/ext/pb_ds/multimap_text_insert.hpp
index 737be39a154b..2c86b52f30a2 100644
--- a/libstdc++-v3/testsuite/performance/ext/pb_ds/multimap_text_insert.hpp
+++ b/libstdc++-v3/testsuite/performance/ext/pb_ds/multimap_text_insert.hpp
@@ -29,6 +29,8 @@
 // purpose. It is provided "as is" without express or implied
 // warranty.
 
+// { dg-additional-files "thirty_years_among_the_dead_preproc.txt" }
+
 /**
  * @file multimap_text_insert_timing_test.cpp
  * Contains test for inserting text words.
diff --git 
a/libstdc++-v3/testsuite/performance/ext/pb_ds/multimap_text_insert_mem.hpp 
b/libstdc++-v3/testsuite/performance/ext/pb_ds/multimap_text_insert_mem.hpp
index 9ce235381bd8..ab755312c69a 100644
--- a/libstdc++-v

[gcc/devel/fortran_unsigned] libstdc++: Stop copying all data files into test directory

2024-07-28 Thread Thomas Kテカnig via Libstdc++-cvs
https://gcc.gnu.org/g:64789c1b0d105ed73c3deecc6da0935042c15a7c

commit 64789c1b0d105ed73c3deecc6da0935042c15a7c
Author: Jonathan Wakely 
Date:   Mon Jul 22 14:07:32 2024 +0100

libstdc++: Stop copying all data files into test directory

This removes the TODO in libstdc++_init, so that we don't copy all *.tst
and *.txt files from testsuite/data into every test's working directory.
Instead, only the necessary files declared with dg-additional-files are
copied.

libstdc++-v3/ChangeLog:

* testsuite/lib/libstdc++.exp (libstdc++_init): Do not copy all
data files into test directory.

Diff:
---
 libstdc++-v3/testsuite/lib/libstdc++.exp | 5 -
 1 file changed, 5 deletions(-)

diff --git a/libstdc++-v3/testsuite/lib/libstdc++.exp 
b/libstdc++-v3/testsuite/lib/libstdc++.exp
index ef511949c7bc..4bf88e72d051 100644
--- a/libstdc++-v3/testsuite/lib/libstdc++.exp
+++ b/libstdc++-v3/testsuite/lib/libstdc++.exp
@@ -158,11 +158,6 @@ proc libstdc++_init { testfile } {
 global dg-do-what-default
 set dg-do-what-default run
 
-# Copy all required data files.
-# TODO: Use dg-additional-files in individual tests instead of doing this.
-v3-copy-files [glob -nocomplain "$srcdir/data/*.tst"]
-v3-copy-files [glob -nocomplain "$srcdir/data/*.txt"]
-
 set ld_library_path_tmp ""
 
 # Locate libgcc.a so we don't need to account for different values of


[gcc/devel/fortran_unsigned] libstdc++: Rename tests [PR12048]

2024-07-28 Thread Thomas Kテカnig via Libstdc++-cvs
https://gcc.gnu.org/g:218aaec86650ec6cae2fc54fdfcedc5abccc55dd

commit 218aaec86650ec6cae2fc54fdfcedc5abccc55dd
Author: Jonathan Wakely 
Date:   Mon Jul 22 15:50:19 2024 +0100

libstdc++: Rename tests [PR12048]

These have the wrong PR number in the filenames.

libstdc++-v3/ChangeLog:

PR libstdc++/12048
* testsuite/ext/stdio_sync_filebuf/wchar_t/12948-1.cc: Move to...
* testsuite/ext/stdio_sync_filebuf/wchar_t/12048-1.cc: ...here.
* testsuite/ext/stdio_sync_filebuf/wchar_t/12948-2.cc: Move to...
* testsuite/ext/stdio_sync_filebuf/wchar_t/12048-2.cc: ...here.
* testsuite/ext/stdio_sync_filebuf/wchar_t/12948-3.cc: Move to...
* testsuite/ext/stdio_sync_filebuf/wchar_t/12048-3.cc: ...here.
* testsuite/ext/stdio_sync_filebuf/wchar_t/12948-4.cc: Move to...
* testsuite/ext/stdio_sync_filebuf/wchar_t/12048-4.cc: ...here.

Diff:
---
 .../testsuite/ext/stdio_sync_filebuf/wchar_t/{12948-1.cc => 12048-1.cc}   | 0
 .../testsuite/ext/stdio_sync_filebuf/wchar_t/{12948-2.cc => 12048-2.cc}   | 0
 .../testsuite/ext/stdio_sync_filebuf/wchar_t/{12948-3.cc => 12048-3.cc}   | 0
 .../testsuite/ext/stdio_sync_filebuf/wchar_t/{12948-4.cc => 12048-4.cc}   | 0
 4 files changed, 0 insertions(+), 0 deletions(-)

diff --git a/libstdc++-v3/testsuite/ext/stdio_sync_filebuf/wchar_t/12948-1.cc 
b/libstdc++-v3/testsuite/ext/stdio_sync_filebuf/wchar_t/12048-1.cc
similarity index 100%
rename from libstdc++-v3/testsuite/ext/stdio_sync_filebuf/wchar_t/12948-1.cc
rename to libstdc++-v3/testsuite/ext/stdio_sync_filebuf/wchar_t/12048-1.cc
diff --git a/libstdc++-v3/testsuite/ext/stdio_sync_filebuf/wchar_t/12948-2.cc 
b/libstdc++-v3/testsuite/ext/stdio_sync_filebuf/wchar_t/12048-2.cc
similarity index 100%
rename from libstdc++-v3/testsuite/ext/stdio_sync_filebuf/wchar_t/12948-2.cc
rename to libstdc++-v3/testsuite/ext/stdio_sync_filebuf/wchar_t/12048-2.cc
diff --git a/libstdc++-v3/testsuite/ext/stdio_sync_filebuf/wchar_t/12948-3.cc 
b/libstdc++-v3/testsuite/ext/stdio_sync_filebuf/wchar_t/12048-3.cc
similarity index 100%
rename from libstdc++-v3/testsuite/ext/stdio_sync_filebuf/wchar_t/12948-3.cc
rename to libstdc++-v3/testsuite/ext/stdio_sync_filebuf/wchar_t/12048-3.cc
diff --git a/libstdc++-v3/testsuite/ext/stdio_sync_filebuf/wchar_t/12948-4.cc 
b/libstdc++-v3/testsuite/ext/stdio_sync_filebuf/wchar_t/12048-4.cc
similarity index 100%
rename from libstdc++-v3/testsuite/ext/stdio_sync_filebuf/wchar_t/12948-4.cc
rename to libstdc++-v3/testsuite/ext/stdio_sync_filebuf/wchar_t/12048-4.cc


[gcc/devel/fortran_unsigned] aarch64: Fuse CMP+CSEL and CMP+CSET for -mcpu=neoverse-v2

2024-07-28 Thread Thomas Kテカnig via Gcc-cvs
https://gcc.gnu.org/g:7be99ec9261afa37188017925eba8ae7530188a3

commit 7be99ec9261afa37188017925eba8ae7530188a3
Author: Jennifer Schmitz 
Date:   Mon Jul 22 23:24:45 2024 -0700

aarch64: Fuse CMP+CSEL and CMP+CSET for -mcpu=neoverse-v2

According to the Neoverse V2 Software Optimization Guide (section 4.14), the
instruction pairs CMP+CSEL and CMP+CSET can be fused, which had not been
implemented so far. This patch implements and tests the two fusion pairs.

The patch was bootstrapped and regtested on aarch64-linux-gnu, no 
regression.
There was also no non-noise impact on SPEC CPU2017 benchmark.
OK for mainline?

Signed-off-by: Jennifer Schmitz 

gcc/

* config/aarch64/aarch64.cc (aarch_macro_fusion_pair_p): Implement
fusion logic.
* config/aarch64/aarch64-fusion-pairs.def (cmp+csel): New entry.
(cmp+cset): Likewise.
* config/aarch64/tuning_models/neoversev2.h: Enable logic in
field fusible_ops.

gcc/testsuite/

* gcc.target/aarch64/cmp_csel_fuse.c: New test.
* gcc.target/aarch64/cmp_cset_fuse.c: Likewise.

Diff:
---
 gcc/config/aarch64/aarch64-fusion-pairs.def  |  2 ++
 gcc/config/aarch64/aarch64.cc| 19 +
 gcc/config/aarch64/tuning_models/neoversev2.h|  5 +++-
 gcc/testsuite/gcc.target/aarch64/cmp_csel_fuse.c | 34 
 gcc/testsuite/gcc.target/aarch64/cmp_cset_fuse.c | 31 +
 5 files changed, 90 insertions(+), 1 deletion(-)

diff --git a/gcc/config/aarch64/aarch64-fusion-pairs.def 
b/gcc/config/aarch64/aarch64-fusion-pairs.def
index 9a43b0c80657..bf5e85ba8fe1 100644
--- a/gcc/config/aarch64/aarch64-fusion-pairs.def
+++ b/gcc/config/aarch64/aarch64-fusion-pairs.def
@@ -37,5 +37,7 @@ AARCH64_FUSION_PAIR ("aes+aesmc", AES_AESMC)
 AARCH64_FUSION_PAIR ("alu+branch", ALU_BRANCH)
 AARCH64_FUSION_PAIR ("alu+cbz", ALU_CBZ)
 AARCH64_FUSION_PAIR ("addsub_2reg_const1", ADDSUB_2REG_CONST1)
+AARCH64_FUSION_PAIR ("cmp+csel", CMP_CSEL)
+AARCH64_FUSION_PAIR ("cmp+cset", CMP_CSET)
 
 #undef AARCH64_FUSION_PAIR
diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc
index 9e51236ce9fa..db598ebf2c79 100644
--- a/gcc/config/aarch64/aarch64.cc
+++ b/gcc/config/aarch64/aarch64.cc
@@ -27348,6 +27348,25 @@ aarch_macro_fusion_pair_p (rtx_insn *prev, rtx_insn 
*curr)
   && reg_referenced_p (SET_DEST (prev_set), PATTERN (curr)))
 return true;
 
+  /* FUSE CMP and CSEL.  */
+  if (aarch64_fusion_enabled_p (AARCH64_FUSE_CMP_CSEL)
+  && prev_set && curr_set
+  && GET_CODE (SET_SRC (prev_set)) == COMPARE
+  && GET_CODE (SET_SRC (curr_set)) == IF_THEN_ELSE
+  && REG_P (XEXP (SET_SRC (curr_set), 1))
+  && REG_P (XEXP (SET_SRC (curr_set), 2))
+  && reg_referenced_p (SET_DEST (prev_set), PATTERN (curr)))
+return true;
+
+  /* Fuse CMP and CSET.  */
+  if (aarch64_fusion_enabled_p (AARCH64_FUSE_CMP_CSET)
+  && prev_set && curr_set
+  && GET_CODE (SET_SRC (prev_set)) == COMPARE
+  && GET_RTX_CLASS (GET_CODE (SET_SRC (curr_set))) == RTX_COMPARE
+  && REG_P (SET_DEST (curr_set))
+  && reg_referenced_p (SET_DEST (prev_set), PATTERN (curr)))
+return true;
+
   /* Fuse flag-setting ALU instructions and conditional branch.  */
   if (aarch64_fusion_enabled_p (AARCH64_FUSE_ALU_BRANCH)
   && any_condjump_p (curr))
diff --git a/gcc/config/aarch64/tuning_models/neoversev2.h 
b/gcc/config/aarch64/tuning_models/neoversev2.h
index f76e4ef358f7..ae99fab22d80 100644
--- a/gcc/config/aarch64/tuning_models/neoversev2.h
+++ b/gcc/config/aarch64/tuning_models/neoversev2.h
@@ -221,7 +221,10 @@ static const struct tune_params neoversev2_tunings =
 2 /* store_pred.  */
   }, /* memmov_cost.  */
   5, /* issue_rate  */
-  (AARCH64_FUSE_AES_AESMC | AARCH64_FUSE_CMP_BRANCH), /* fusible_ops  */
+  (AARCH64_FUSE_AES_AESMC
+   | AARCH64_FUSE_CMP_BRANCH
+   | AARCH64_FUSE_CMP_CSEL
+   | AARCH64_FUSE_CMP_CSET), /* fusible_ops  */
   "32:16", /* function_align.  */
   "4", /* jump_align.  */
   "32:16", /* loop_align.  */
diff --git a/gcc/testsuite/gcc.target/aarch64/cmp_csel_fuse.c 
b/gcc/testsuite/gcc.target/aarch64/cmp_csel_fuse.c
new file mode 100644
index ..f5e511e46737
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/cmp_csel_fuse.c
@@ -0,0 +1,34 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -mcpu=neoverse-v2" } */
+/* { dg-final { check-function-bodies "**" "" } } */
+
+/*
+** f1:
+** ...
+** cmp w[0-9]+, w[0-9]+
+** cselw[0-9]+, w[0-9]+, w[0-9]+, le
+** ret
+*/
+int f1 (int a, int b, int c)
+{
+  int cmp = a > b;
+  int add1 = c + 3;
+  int add2 = c + 8;
+  return cmp ? add1 : add2;
+}
+
+/*
+** f2:
+** ...
+** cmp x[0-9]+, x[0-9]+
+** cselx[0-9]+, x[0-9]+, x[0-9]+, le
+** ret
+*/
+long long f2 (long long a, long long b, long long c)
+{
+  long long cmp = a 

[gcc/devel/fortran_unsigned] Revert "aarch64: Fuse CMP+CSEL and CMP+CSET for -mcpu=neoverse-v2"

2024-07-28 Thread Thomas Kテカnig via Gcc-cvs
https://gcc.gnu.org/g:5a6cc54ce068be40a8d4c1608963cb3644510a4d

commit 5a6cc54ce068be40a8d4c1608963cb3644510a4d
Author: Kyrylo Tkachov 
Date:   Wed Jul 24 17:25:43 2024 +0530

Revert "aarch64: Fuse CMP+CSEL and CMP+CSET for -mcpu=neoverse-v2"

This reverts commit 4c5eb66e701bc9f3bf1298269f52559b10d63a09.

Diff:
---
 gcc/config/aarch64/aarch64-fusion-pairs.def  |  2 --
 gcc/config/aarch64/aarch64.cc| 19 -
 gcc/config/aarch64/tuning_models/neoversev2.h|  5 +---
 gcc/testsuite/gcc.target/aarch64/cmp_csel_fuse.c | 34 
 gcc/testsuite/gcc.target/aarch64/cmp_cset_fuse.c | 31 -
 5 files changed, 1 insertion(+), 90 deletions(-)

diff --git a/gcc/config/aarch64/aarch64-fusion-pairs.def 
b/gcc/config/aarch64/aarch64-fusion-pairs.def
index bf5e85ba8fe1..9a43b0c80657 100644
--- a/gcc/config/aarch64/aarch64-fusion-pairs.def
+++ b/gcc/config/aarch64/aarch64-fusion-pairs.def
@@ -37,7 +37,5 @@ AARCH64_FUSION_PAIR ("aes+aesmc", AES_AESMC)
 AARCH64_FUSION_PAIR ("alu+branch", ALU_BRANCH)
 AARCH64_FUSION_PAIR ("alu+cbz", ALU_CBZ)
 AARCH64_FUSION_PAIR ("addsub_2reg_const1", ADDSUB_2REG_CONST1)
-AARCH64_FUSION_PAIR ("cmp+csel", CMP_CSEL)
-AARCH64_FUSION_PAIR ("cmp+cset", CMP_CSET)
 
 #undef AARCH64_FUSION_PAIR
diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc
index db598ebf2c79..9e51236ce9fa 100644
--- a/gcc/config/aarch64/aarch64.cc
+++ b/gcc/config/aarch64/aarch64.cc
@@ -27348,25 +27348,6 @@ aarch_macro_fusion_pair_p (rtx_insn *prev, rtx_insn 
*curr)
   && reg_referenced_p (SET_DEST (prev_set), PATTERN (curr)))
 return true;
 
-  /* FUSE CMP and CSEL.  */
-  if (aarch64_fusion_enabled_p (AARCH64_FUSE_CMP_CSEL)
-  && prev_set && curr_set
-  && GET_CODE (SET_SRC (prev_set)) == COMPARE
-  && GET_CODE (SET_SRC (curr_set)) == IF_THEN_ELSE
-  && REG_P (XEXP (SET_SRC (curr_set), 1))
-  && REG_P (XEXP (SET_SRC (curr_set), 2))
-  && reg_referenced_p (SET_DEST (prev_set), PATTERN (curr)))
-return true;
-
-  /* Fuse CMP and CSET.  */
-  if (aarch64_fusion_enabled_p (AARCH64_FUSE_CMP_CSET)
-  && prev_set && curr_set
-  && GET_CODE (SET_SRC (prev_set)) == COMPARE
-  && GET_RTX_CLASS (GET_CODE (SET_SRC (curr_set))) == RTX_COMPARE
-  && REG_P (SET_DEST (curr_set))
-  && reg_referenced_p (SET_DEST (prev_set), PATTERN (curr)))
-return true;
-
   /* Fuse flag-setting ALU instructions and conditional branch.  */
   if (aarch64_fusion_enabled_p (AARCH64_FUSE_ALU_BRANCH)
   && any_condjump_p (curr))
diff --git a/gcc/config/aarch64/tuning_models/neoversev2.h 
b/gcc/config/aarch64/tuning_models/neoversev2.h
index ae99fab22d80..f76e4ef358f7 100644
--- a/gcc/config/aarch64/tuning_models/neoversev2.h
+++ b/gcc/config/aarch64/tuning_models/neoversev2.h
@@ -221,10 +221,7 @@ static const struct tune_params neoversev2_tunings =
 2 /* store_pred.  */
   }, /* memmov_cost.  */
   5, /* issue_rate  */
-  (AARCH64_FUSE_AES_AESMC
-   | AARCH64_FUSE_CMP_BRANCH
-   | AARCH64_FUSE_CMP_CSEL
-   | AARCH64_FUSE_CMP_CSET), /* fusible_ops  */
+  (AARCH64_FUSE_AES_AESMC | AARCH64_FUSE_CMP_BRANCH), /* fusible_ops  */
   "32:16", /* function_align.  */
   "4", /* jump_align.  */
   "32:16", /* loop_align.  */
diff --git a/gcc/testsuite/gcc.target/aarch64/cmp_csel_fuse.c 
b/gcc/testsuite/gcc.target/aarch64/cmp_csel_fuse.c
deleted file mode 100644
index f5e511e46737..
--- a/gcc/testsuite/gcc.target/aarch64/cmp_csel_fuse.c
+++ /dev/null
@@ -1,34 +0,0 @@
-/* { dg-do compile } */
-/* { dg-options "-O2 -mcpu=neoverse-v2" } */
-/* { dg-final { check-function-bodies "**" "" } } */
-
-/*
-** f1:
-** ...
-** cmp w[0-9]+, w[0-9]+
-** cselw[0-9]+, w[0-9]+, w[0-9]+, le
-** ret
-*/
-int f1 (int a, int b, int c)
-{
-  int cmp = a > b;
-  int add1 = c + 3;
-  int add2 = c + 8;
-  return cmp ? add1 : add2;
-}
-
-/*
-** f2:
-** ...
-** cmp x[0-9]+, x[0-9]+
-** cselx[0-9]+, x[0-9]+, x[0-9]+, le
-** ret
-*/
-long long f2 (long long a, long long b, long long c)
-{
-  long long cmp = a > b;
-  long long add1 = c + 3;
-  long long add2 = c + 8;
-  return cmp ? add1 : add2;
-}
-
diff --git a/gcc/testsuite/gcc.target/aarch64/cmp_cset_fuse.c 
b/gcc/testsuite/gcc.target/aarch64/cmp_cset_fuse.c
deleted file mode 100644
index 04f1ce2773ba..
--- a/gcc/testsuite/gcc.target/aarch64/cmp_cset_fuse.c
+++ /dev/null
@@ -1,31 +0,0 @@
-/* { dg-do compile } */
-/* { dg-options "-O2 -mcpu=neoverse-v2" } */
-/* { dg-final { check-function-bodies "**" "" } } */
-
-/*
-** f1:
-** cmp w[0-9]+, w[0-9]+
-** csetw[0-9]+, gt
-** ...
-*/
-int g;
-int f1 (int a, int b)
-{
-  int cmp = a > b;
-  g = cmp + 1;
-  return cmp;
-}
-
-/*
-** f2:
-** cmp x[0-9]+, x[0-9]+
-** csetx[0-9]+, gt
-** ...
-*/
-long long h;
-long long f2 (long long a, long long b)
-{
-  long long cmp = a > b;
-  h = cmp + 1;
-  return cmp;
-}

[gcc/devel/fortran_unsigned] tree-optimization/116057 - wrong code with CCP and vector CTORs

2024-07-28 Thread Thomas Kテカnig via Gcc-cvs
https://gcc.gnu.org/g:2c8986cc98fac56857989a692901c505c0f6ec01

commit 2c8986cc98fac56857989a692901c505c0f6ec01
Author: Richard Biener 
Date:   Wed Jul 24 13:16:35 2024 +0200

tree-optimization/116057 - wrong code with CCP and vector CTORs

The following fixes an issue with CCPs likely_value when faced with
a vector CTOR containing undef SSA names and constants.  This should
be classified as CONSTANT and not UNDEFINED.

PR tree-optimization/116057
* tree-ssa-ccp.cc (likely_value): Also walk CTORs in stmt
operands to look for constants.

* gcc.dg/torture/pr116057.c: New testcase.

Diff:
---
 gcc/testsuite/gcc.dg/torture/pr116057.c | 20 
 gcc/tree-ssa-ccp.cc | 11 +++
 2 files changed, 31 insertions(+)

diff --git a/gcc/testsuite/gcc.dg/torture/pr116057.c 
b/gcc/testsuite/gcc.dg/torture/pr116057.c
new file mode 100644
index ..a7021c8e746e
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr116057.c
@@ -0,0 +1,20 @@
+/* { dg-do run } */
+/* { dg-additional-options "-Wno-psabi" } */
+
+#define vect8 __attribute__((vector_size(8)))
+
+vect8 int __attribute__((noipa))
+f(int a)
+{
+  int b;
+  vect8 int t={1,1};
+  if(a) return t;
+  return (vect8 int){0, b};
+}
+
+int main ()
+{
+  if (f(0)[0] != 0)
+__builtin_abort ();
+  return 0;
+}
diff --git a/gcc/tree-ssa-ccp.cc b/gcc/tree-ssa-ccp.cc
index de83d26d311a..44711018e0ef 100644
--- a/gcc/tree-ssa-ccp.cc
+++ b/gcc/tree-ssa-ccp.cc
@@ -762,6 +762,17 @@ likely_value (gimple *stmt)
continue;
   if (is_gimple_min_invariant (op))
has_constant_operand = true;
+  else if (TREE_CODE (op) == CONSTRUCTOR)
+   {
+ unsigned j;
+ tree val;
+ FOR_EACH_CONSTRUCTOR_VALUE (CONSTRUCTOR_ELTS (op), j, val)
+   if (CONSTANT_CLASS_P (val))
+ {
+   has_constant_operand = true;
+   break;
+ }
+   }
 }
 
   if (has_constant_operand)


[gcc/devel/fortran_unsigned] modula2: Improve error message to include symbol name.

2024-07-28 Thread Thomas Kテカnig via Gcc-cvs
https://gcc.gnu.org/g:43d803bcb2325cc6659c39c4d264e5ce9c396f60

commit 43d803bcb2325cc6659c39c4d264e5ce9c396f60
Author: Gaius Mulley 
Date:   Wed Jul 24 14:26:39 2024 +0100

modula2: Improve error message to include symbol name.

gcc/m2/ChangeLog:

* gm2-compiler/M2StateCheck.mod (GenerateError): Add
symbol name to the error message.

Signed-off-by: Gaius Mulley 

Diff:
---
 gcc/m2/gm2-compiler/M2StateCheck.mod | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/m2/gm2-compiler/M2StateCheck.mod 
b/gcc/m2/gm2-compiler/M2StateCheck.mod
index e53cb174474c..940c433bcc14 100644
--- a/gcc/m2/gm2-compiler/M2StateCheck.mod
+++ b/gcc/m2/gm2-compiler/M2StateCheck.mod
@@ -306,7 +306,7 @@ PROCEDURE GenerateError (tok: CARDINAL; s: StateCheck; sym: 
CARDINAL) ;
 VAR
str: String ;
 BEGIN
-   str := InitString ('not expecting a {%1Ad} {%1a: }in a ') ;
+   str := InitString ('not expecting the {%1Ad} {%1a} in a ') ;
IF const IN s^.state
THEN
   str := ConCat (str, Mark (InitString ('{%kCONST} block')))


[gcc/devel/fortran_unsigned] modula2: Add GNU flex as a build and install prerequisite.

2024-07-28 Thread Thomas Kテカnig via Gcc-cvs
https://gcc.gnu.org/g:6c7ad84bc54e1a79ba19093f071acf78791ec5d5

commit 6c7ad84bc54e1a79ba19093f071acf78791ec5d5
Author: Gaius Mulley 
Date:   Wed Jul 24 14:25:45 2024 +0100

modula2: Add GNU flex as a build and install prerequisite.

gcc/ChangeLog:

* doc/install.texi (GM2-prerequisite): Add GNU flex.

Signed-off-by: Gaius Mulley 

Diff:
---
 gcc/doc/install.texi | 4 
 1 file changed, 4 insertions(+)

diff --git a/gcc/doc/install.texi b/gcc/doc/install.texi
index dda623f4410a..4973f195daf9 100644
--- a/gcc/doc/install.texi
+++ b/gcc/doc/install.texi
@@ -334,6 +334,10 @@ environment to your ``good'' shell prior to running
 @command{zsh} is not a fully compliant POSIX shell and will not
 work when configuring GCC@.
 
+@item GNU flex
+
+Necessary to build the lexical analysis module.
+
 @item A POSIX or SVR4 awk
 
 Necessary for creating some of the generated source files for GCC@.


[gcc/devel/fortran_unsigned] optabs/rs6000: Rename iorc and andc to iorn and andn

2024-07-28 Thread Thomas Kテカnig via Gcc-cvs
https://gcc.gnu.org/g:b34504a2594337d295875dc604c355aa851dd4aa

commit b34504a2594337d295875dc604c355aa851dd4aa
Author: Andrew Pinski 
Date:   Mon Jul 22 21:23:38 2024 -0700

optabs/rs6000: Rename iorc and andc to iorn and andn

When I was trying to add an scalar version of iorc and andc, the optab that
got matched was for and/ior with the mode of csi and cdi instead of iorc and
andc optabs for si and di modes. Since csi/cdi are the complex integer 
modes,
we need to rename the optabs to be without c there. This changes c to n 
which
is a neutral and known not to be first letter of a mode.

Bootstrapped and tested on x86_64 and powerpc64le.

gcc/ChangeLog:

* config/rs6000/rs6000-builtins.def: s/iorc/iorn/. s/andc/andn/
for the code.
* config/rs6000/rs6000-string.cc (expand_cmp_vec_sequence): Update
to iorn.
* config/rs6000/rs6000.md (andc3): Rename to ...
(andn3): This.
(iorc3): Rename to ...
(iorn3): This.
* doc/md.texi: Update documentation for the rename.
* internal-fn.def (BIT_ANDC): Rename to ...
(BIT_ANDN): This.
(BIT_IORC): Rename to ...
(BIT_IORN): This.
* optabs.def (andc_optab): Rename to ...
(andn_optab): This.
(iorc_optab): Rename to ...
(iorn_optab): This.
* gimple-isel.cc (gimple_expand_vec_cond_expr): Update for the
renamed internal functions, ANDC/IORC to ANDN/IORN.

Signed-off-by: Andrew Pinski 

Diff:
---
 gcc/config/rs6000/rs6000-builtins.def | 44 +--
 gcc/config/rs6000/rs6000-string.cc|  2 +-
 gcc/config/rs6000/rs6000.md   |  4 ++--
 gcc/doc/md.texi   |  8 +++
 gcc/gimple-isel.cc| 12 +-
 gcc/internal-fn.def   |  4 ++--
 gcc/optabs.def| 10 +---
 7 files changed, 44 insertions(+), 40 deletions(-)

diff --git a/gcc/config/rs6000/rs6000-builtins.def 
b/gcc/config/rs6000/rs6000-builtins.def
index 77eb0f7e4069..ffbeff64d6d6 100644
--- a/gcc/config/rs6000/rs6000-builtins.def
+++ b/gcc/config/rs6000/rs6000-builtins.def
@@ -518,25 +518,25 @@
 VAND_V8HI_UNS andv8hi3 {}
 
   const vsc __builtin_altivec_vandc_v16qi (vsc, vsc);
-VANDC_V16QI andcv16qi3 {}
+VANDC_V16QI andnv16qi3 {}
 
   const vuc __builtin_altivec_vandc_v16qi_uns (vuc, vuc);
-VANDC_V16QI_UNS andcv16qi3 {}
+VANDC_V16QI_UNS andnv16qi3 {}
 
   const vf __builtin_altivec_vandc_v4sf (vf, vf);
-VANDC_V4SF andcv4sf3 {}
+VANDC_V4SF andnv4sf3 {}
 
   const vsi __builtin_altivec_vandc_v4si (vsi, vsi);
-VANDC_V4SI andcv4si3 {}
+VANDC_V4SI andnv4si3 {}
 
   const vui __builtin_altivec_vandc_v4si_uns (vui, vui);
-VANDC_V4SI_UNS andcv4si3 {}
+VANDC_V4SI_UNS andnv4si3 {}
 
   const vss __builtin_altivec_vandc_v8hi (vss, vss);
-VANDC_V8HI andcv8hi3 {}
+VANDC_V8HI andnv8hi3 {}
 
   const vus __builtin_altivec_vandc_v8hi_uns (vus, vus);
-VANDC_V8HI_UNS andcv8hi3 {}
+VANDC_V8HI_UNS andnv8hi3 {}
 
   const vsc __builtin_altivec_vavgsb (vsc, vsc);
 VAVGSB avgv16qi3_ceil {}
@@ -1189,13 +1189,13 @@
 VAND_V2DI_UNS andv2di3 {}
 
   const vd __builtin_altivec_vandc_v2df (vd, vd);
-VANDC_V2DF andcv2df3 {}
+VANDC_V2DF andnv2df3 {}
 
   const vsll __builtin_altivec_vandc_v2di (vsll, vsll);
-VANDC_V2DI andcv2di3 {}
+VANDC_V2DI andnv2di3 {}
 
   const vull __builtin_altivec_vandc_v2di_uns (vull, vull);
-VANDC_V2DI_UNS andcv2di3 {}
+VANDC_V2DI_UNS andnv2di3 {}
 
   const vd __builtin_altivec_vnor_v2df (vd, vd);
 VNOR_V2DF norv2df3 {}
@@ -1975,40 +1975,40 @@
 NEG_V2DI negv2di2 {}
 
   const vsc __builtin_altivec_orc_v16qi (vsc, vsc);
-ORC_V16QI iorcv16qi3 {}
+ORC_V16QI iornv16qi3 {}
 
   const vuc __builtin_altivec_orc_v16qi_uns (vuc, vuc);
-ORC_V16QI_UNS iorcv16qi3 {}
+ORC_V16QI_UNS iornv16qi3 {}
 
   const vsq __builtin_altivec_orc_v1ti (vsq, vsq);
-ORC_V1TI iorcv1ti3 {}
+ORC_V1TI iornv1ti3 {}
 
   const vuq __builtin_altivec_orc_v1ti_uns (vuq, vuq);
-ORC_V1TI_UNS iorcv1ti3 {}
+ORC_V1TI_UNS iornv1ti3 {}
 
   const vd __builtin_altivec_orc_v2df (vd, vd);
-ORC_V2DF iorcv2df3 {}
+ORC_V2DF iornv2df3 {}
 
   const vsll __builtin_altivec_orc_v2di (vsll, vsll);
-ORC_V2DI iorcv2di3 {}
+ORC_V2DI iornv2di3 {}
 
   const vull __builtin_altivec_orc_v2di_uns (vull, vull);
-ORC_V2DI_UNS iorcv2di3 {}
+ORC_V2DI_UNS iornv2di3 {}
 
   const vf __builtin_altivec_orc_v4sf (vf, vf);
-ORC_V4SF iorcv4sf3 {}
+ORC_V4SF iornv4sf3 {}
 
   const vsi __builtin_altivec_orc_v4si (vsi, vsi);
-ORC_V4SI iorcv4si3 {}
+ORC_V4SI iornv4si3 {}
 
   const vui __builtin_altivec_orc_v4si_uns (vui, vui);
-ORC_V4SI_UNS iorcv4si3 {}
+ORC_V4SI_UNS iornv4si3 {}
 
   const vss __builtin_altivec_orc_v8hi (vss, vss);
- 

[gcc/devel/fortran_unsigned] c++: add fixed testcase [PR109997]

2024-07-28 Thread Thomas Kテカnig via Gcc-cvs
https://gcc.gnu.org/g:686a0e1af619f926842f11eef713825c8fe201f4

commit 686a0e1af619f926842f11eef713825c8fe201f4
Author: Jason Merrill 
Date:   Wed Jul 24 11:07:42 2024 -0400

c++: add fixed testcase [PR109997]

Fixed by r14-9713 for PR100667.

PR c++/109997

gcc/testsuite/ChangeLog:

* g++.dg/ext/is_assignable1.C: New test.

Diff:
---
 gcc/testsuite/g++.dg/ext/is_assignable1.C | 4 
 1 file changed, 4 insertions(+)

diff --git a/gcc/testsuite/g++.dg/ext/is_assignable1.C 
b/gcc/testsuite/g++.dg/ext/is_assignable1.C
new file mode 100644
index ..31e64509b452
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ext/is_assignable1.C
@@ -0,0 +1,4 @@
+// PR c++/109997
+
+struct S;
+bool b = __is_assignable(int, S); // { dg-error "incomplete" }


[gcc/devel/fortran_unsigned] aarch64: Remove unused global aarch64_tune_flags

2024-07-28 Thread Thomas Kテカnig via Gcc-cvs
https://gcc.gnu.org/g:fecc7eeb05d2ca9b57e49fa5da923a09286a6ae8

commit fecc7eeb05d2ca9b57e49fa5da923a09286a6ae8
Author: Andrew Carlotti 
Date:   Wed Apr 17 19:28:20 2024 +0100

aarch64: Remove unused global aarch64_tune_flags

gcc/ChangeLog:

* config/aarch64/aarch64.cc
(aarch64_tune_flags): Remove unused global variable.
(aarch64_override_options_internal): Remove dead assignment.

Diff:
---
 gcc/config/aarch64/aarch64.cc | 4 
 1 file changed, 4 deletions(-)

diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc
index 9e51236ce9fa..d8fbd7102e7b 100644
--- a/gcc/config/aarch64/aarch64.cc
+++ b/gcc/config/aarch64/aarch64.cc
@@ -349,9 +349,6 @@ static bool aarch64_print_address_internal (FILE*, 
machine_mode, rtx,
 /* The processor for which instructions should be scheduled.  */
 enum aarch64_processor aarch64_tune = cortexa53;
 
-/* Mask to specify which instruction scheduling options should be used.  */
-uint64_t aarch64_tune_flags = 0;
-
 /* Global flag for PC relative loads.  */
 bool aarch64_pcrelative_literal_loads;
 
@@ -18273,7 +18270,6 @@ void
 aarch64_override_options_internal (struct gcc_options *opts)
 {
   const struct processor *tune = aarch64_get_tune_cpu (opts->x_selected_tune);
-  aarch64_tune_flags = tune->flags;
   aarch64_tune = tune->sched_core;
   /* Make a copy of the tuning parameters attached to the core, which
  we may later overwrite.  */


[gcc/devel/fortran_unsigned] aarch64: Move AARCH64_NUM_ISA_MODES definition

2024-07-28 Thread Thomas Kテカnig via Gcc-cvs
https://gcc.gnu.org/g:f0140a67bf6e72f4b6159a6512110929ef2e60a8

commit f0140a67bf6e72f4b6159a6512110929ef2e60a8
Author: Andrew Carlotti 
Date:   Fri May 3 16:09:27 2024 +0100

aarch64: Move AARCH64_NUM_ISA_MODES definition

AARCH64_NUM_ISA_MODES will be used within aarch64-opts.h in a later
commit.

gcc/ChangeLog:

* config/aarch64/aarch64.h (DEF_AARCH64_ISA_MODE): Move to...
* config/aarch64/aarch64-opts.h (DEF_AARCH64_ISA_MODE): ...here.

Diff:
---
 gcc/config/aarch64/aarch64-opts.h | 5 +
 gcc/config/aarch64/aarch64.h  | 5 -
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/gcc/config/aarch64/aarch64-opts.h 
b/gcc/config/aarch64/aarch64-opts.h
index a05c0d3ded1c..06a4fed38334 100644
--- a/gcc/config/aarch64/aarch64-opts.h
+++ b/gcc/config/aarch64/aarch64-opts.h
@@ -24,6 +24,11 @@
 
 #ifndef USED_FOR_TARGET
 typedef uint64_t aarch64_feature_flags;
+
+constexpr unsigned int AARCH64_NUM_ISA_MODES = (0
+#define DEF_AARCH64_ISA_MODE(IDENT) + 1
+#include "aarch64-isa-modes.def"
+);
 #endif
 
 /* The various cores that implement AArch64.  */
diff --git a/gcc/config/aarch64/aarch64.h b/gcc/config/aarch64/aarch64.h
index fac1882bcb38..2be6dc4089b8 100644
--- a/gcc/config/aarch64/aarch64.h
+++ b/gcc/config/aarch64/aarch64.h
@@ -183,11 +183,6 @@ enum class aarch64_feature : unsigned char {
 
 constexpr auto AARCH64_FL_SM_STATE = AARCH64_FL_SM_ON | AARCH64_FL_SM_OFF;
 
-constexpr unsigned int AARCH64_NUM_ISA_MODES = (0
-#define DEF_AARCH64_ISA_MODE(IDENT) + 1
-#include "aarch64-isa-modes.def"
-);
-
 /* The mask of all ISA modes.  */
 constexpr auto AARCH64_FL_ISA_MODES
   = (aarch64_feature_flags (1) << AARCH64_NUM_ISA_MODES) - 1;


[gcc/devel/fortran_unsigned] aarch64: Eliminate a temporary variable.

2024-07-28 Thread Thomas Kテカnig via Gcc-cvs
https://gcc.gnu.org/g:3ff25c34c5a588cab7d31d4253367f65609ecb7a

commit 3ff25c34c5a588cab7d31d4253367f65609ecb7a
Author: Andrew Carlotti 
Date:   Fri May 10 12:56:44 2024 +0100

aarch64: Eliminate a temporary variable.

The name would become misleading in a later commit anyway, and I think
this is marginally more readable.

gcc/ChangeLog:

* config/aarch64/aarch64.cc
(aarch64_override_options): Remove temporary variable.

Diff:
---
 gcc/config/aarch64/aarch64.cc | 9 -
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc
index d8fbd7102e7b..4e3a4047ea80 100644
--- a/gcc/config/aarch64/aarch64.cc
+++ b/gcc/config/aarch64/aarch64.cc
@@ -18856,7 +18856,6 @@ aarch64_override_options (void)
   SUBTARGET_OVERRIDE_OPTIONS;
 #endif
 
-  auto isa_mode = AARCH64_FL_DEFAULT_ISA_MODE;
   if (cpu && arch)
 {
   /* If both -mcpu and -march are specified, warn if they are not
@@ -18879,25 +18878,25 @@ aarch64_override_options (void)
}
 
   selected_arch = arch->arch;
-  aarch64_set_asm_isa_flags (arch_isa | isa_mode);
+  aarch64_set_asm_isa_flags (arch_isa | AARCH64_FL_DEFAULT_ISA_MODE);
 }
   else if (cpu)
 {
   selected_arch = cpu->arch;
-  aarch64_set_asm_isa_flags (cpu_isa | isa_mode);
+  aarch64_set_asm_isa_flags (cpu_isa | AARCH64_FL_DEFAULT_ISA_MODE);
 }
   else if (arch)
 {
   cpu = &all_cores[arch->ident];
   selected_arch = arch->arch;
-  aarch64_set_asm_isa_flags (arch_isa | isa_mode);
+  aarch64_set_asm_isa_flags (arch_isa | AARCH64_FL_DEFAULT_ISA_MODE);
 }
   else
 {
   /* No -mcpu or -march specified, so use the default CPU.  */
   cpu = &all_cores[TARGET_CPU_DEFAULT];
   selected_arch = cpu->arch;
-  aarch64_set_asm_isa_flags (cpu->flags | isa_mode);
+  aarch64_set_asm_isa_flags (cpu->flags | AARCH64_FL_DEFAULT_ISA_MODE);
 }
 
   selected_tune = tune ? tune->ident : cpu->ident;


[gcc/devel/fortran_unsigned] aarch64: Introduce aarch64_isa_mode type

2024-07-28 Thread Thomas Kテカnig via Gcc-cvs
https://gcc.gnu.org/g:679ffdd4fcb4ebb051f07f62266481d7b7236805

commit 679ffdd4fcb4ebb051f07f62266481d7b7236805
Author: Andrew Carlotti 
Date:   Fri May 3 16:51:05 2024 +0100

aarch64: Introduce aarch64_isa_mode type

Currently there are many places where an aarch64_feature_flags variable
is used, but only the bottom three isa mode bits are set and read.
Using a separate data type for these value makes it more clear that
they're not expected or required to have any of their upper feature bits
set.  It will also make things simpler and more efficient when we extend
aarch64_feature_flags to 128 bits.

This patch uses explicit casts whenever converting from an
aarch64_feature_flags value to an aarch64_isa_mode value.  This isn't
strictly necessary, but serves to highlight the locations where an
explicit conversion will become necessary later.

gcc/ChangeLog:

* config/aarch64/aarch64-opts.h: Add aarch64_isa_mode typedef.
* config/aarch64/aarch64-protos.h
(aarch64_gen_callee_cookie): Use aarch64_isa_mode parameter.
(aarch64_sme_vq_immediate): Ditto.
* config/aarch64/aarch64.cc
(aarch64_fntype_pstate_sm): Use aarch64_isa_mode values.
(aarch64_fntype_pstate_za): Ditto.
(aarch64_fndecl_pstate_sm): Ditto.
(aarch64_fndecl_pstate_za): Ditto.
(aarch64_fndecl_isa_mode): Ditto.
(aarch64_cfun_incoming_pstate_sm): Ditto.
(aarch64_cfun_enables_pstate_sm): Ditto.
(aarch64_call_switches_pstate_sm): Ditto.
(aarch64_gen_callee_cookie): Ditto.
(aarch64_callee_isa_mode): Ditto.
(aarch64_insn_callee_abi): Ditto.
(aarch64_sme_vq_immediate): Ditto.
(aarch64_add_offset_temporaries): Ditto.
(aarch64_add_offset): Ditto.
(aarch64_add_sp): Ditto.
(aarch64_sub_sp): Ditto.
(aarch64_guard_switch_pstate_sm): Ditto.
(aarch64_switch_pstate_sm): Ditto.
(aarch64_init_cumulative_args): Ditto.
(aarch64_allocate_and_probe_stack_space): Ditto.
(aarch64_expand_prologue): Ditto.
(aarch64_expand_epilogue): Ditto.
(aarch64_start_call_args): Ditto.
(aarch64_expand_call): Ditto.
(aarch64_end_call_args): Ditto.
(aarch64_set_current_function): Ditto, with added conversions.
(aarch64_handle_attr_arch): Avoid macro with changed type.
(aarch64_handle_attr_cpu): Ditto.
(aarch64_handle_attr_isa_flags): Ditto.
(aarch64_switch_pstate_sm_for_landing_pad):
Use arch64_isa_mode values.
(aarch64_switch_pstate_sm_for_jump): Ditto.
(pass_switch_pstate_sm::gate): Ditto.
* config/aarch64/aarch64.h
(AARCH64_ISA_MODE_{SM_ON|SM_OFF|ZA_ON}): New macros.
(AARCH64_FL_SM_STATE): Mark as possibly unused.
(AARCH64_ISA_MODE_SM_STATE): New aarch64_isa_mode mask.
(AARCH64_DEFAULT_ISA_MODE): New aarch64_isa_mode value.
(AARCH64_FL_DEFAULT_ISA_MODE): Define using above value.
(AARCH64_ISA_MODE): Change type to aarch64_isa_mode.
(arm_pcs): Use aarch64_isa_mode value.

Diff:
---
 gcc/config/aarch64/aarch64-opts.h   |   2 +
 gcc/config/aarch64/aarch64-protos.h |   4 +-
 gcc/config/aarch64/aarch64.cc   | 144 ++--
 gcc/config/aarch64/aarch64.h|  21 +-
 4 files changed, 94 insertions(+), 77 deletions(-)

diff --git a/gcc/config/aarch64/aarch64-opts.h 
b/gcc/config/aarch64/aarch64-opts.h
index 06a4fed38334..2c36bfaad19b 100644
--- a/gcc/config/aarch64/aarch64-opts.h
+++ b/gcc/config/aarch64/aarch64-opts.h
@@ -23,6 +23,8 @@
 #define GCC_AARCH64_OPTS_H
 
 #ifndef USED_FOR_TARGET
+typedef uint64_t aarch64_isa_mode;
+
 typedef uint64_t aarch64_feature_flags;
 
 constexpr unsigned int AARCH64_NUM_ISA_MODES = (0
diff --git a/gcc/config/aarch64/aarch64-protos.h 
b/gcc/config/aarch64/aarch64-protos.h
index 42639e9efcf1..f64afe288901 100644
--- a/gcc/config/aarch64/aarch64-protos.h
+++ b/gcc/config/aarch64/aarch64-protos.h
@@ -767,7 +767,7 @@ bool aarch64_constant_address_p (rtx);
 bool aarch64_emit_approx_div (rtx, rtx, rtx);
 bool aarch64_emit_approx_sqrt (rtx, rtx, bool);
 tree aarch64_vector_load_decl (tree);
-rtx aarch64_gen_callee_cookie (aarch64_feature_flags, arm_pcs);
+rtx aarch64_gen_callee_cookie (aarch64_isa_mode, arm_pcs);
 void aarch64_expand_call (rtx, rtx, rtx, bool);
 bool aarch64_expand_cpymem_mops (rtx *, bool);
 bool aarch64_expand_cpymem (rtx *, bool);
@@ -808,7 +808,7 @@ int aarch64_add_offset_temporaries (rtx);
 void aarch64_split_add_offset (scalar_int_mode, rtx, rtx, rtx, rtx, rtx);
 bool aarch64_rdsvl_immediate_p (const_rtx);
 rtx aarch64_sme_vq_immediate (machine_mode mode, HOST_WIDE_INT,
- aarc

[gcc/devel/fortran_unsigned] aarch64: Define aarch64_get_{asm_|}isa_flags

2024-07-28 Thread Thomas Kテカnig via Gcc-cvs
https://gcc.gnu.org/g:7086cefb05fdaf3dc7fb12f009a18b5189c8cc17

commit 7086cefb05fdaf3dc7fb12f009a18b5189c8cc17
Author: Andrew Carlotti 
Date:   Fri May 10 11:46:17 2024 +0100

aarch64: Define aarch64_get_{asm_|}isa_flags

Building an aarch64_feature_flags value from data within a gcc_options
or cl_target_option struct will get more complicated in a later commit.
Use a macro to avoid doing this manually in more than one location.

gcc/ChangeLog:

* common/config/aarch64/aarch64-common.cc
(aarch64_handle_option): Use new macro.
* config/aarch64/aarch64.cc
(aarch64_override_options_internal): Ditto.
(aarch64_option_print): Ditto.
(aarch64_set_current_function): Ditto.
(aarch64_can_inline_p): Ditto.
(aarch64_declare_function_name): Ditto.
(aarch64_start_file): Ditto.
* config/aarch64/aarch64.h (aarch64_get_asm_isa_flags): New
(aarch64_get_isa_flags): New.
(aarch64_asm_isa_flags): Use new macro.
(aarch64_isa_flags): Ditto.

Diff:
---
 gcc/common/config/aarch64/aarch64-common.cc |  2 +-
 gcc/config/aarch64/aarch64.cc   | 36 ++---
 gcc/config/aarch64/aarch64.h| 11 +
 3 files changed, 26 insertions(+), 23 deletions(-)

diff --git a/gcc/common/config/aarch64/aarch64-common.cc 
b/gcc/common/config/aarch64/aarch64-common.cc
index 951d041d3109..63c50189a09d 100644
--- a/gcc/common/config/aarch64/aarch64-common.cc
+++ b/gcc/common/config/aarch64/aarch64-common.cc
@@ -111,7 +111,7 @@ aarch64_handle_option (struct gcc_options *opts,
 
 case OPT_mgeneral_regs_only:
   opts->x_target_flags |= MASK_GENERAL_REGS_ONLY;
-  aarch64_set_asm_isa_flags (opts, opts->x_aarch64_asm_isa_flags);
+  aarch64_set_asm_isa_flags (opts, aarch64_get_asm_isa_flags (opts));
   return true;
 
 case OPT_mfix_cortex_a53_835769:
diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc
index 1b343c9ae1c7..66ce04d77e17 100644
--- a/gcc/config/aarch64/aarch64.cc
+++ b/gcc/config/aarch64/aarch64.cc
@@ -18329,10 +18329,11 @@ aarch64_override_options_internal (struct gcc_options 
*opts)
   && !fixed_regs[R18_REGNUM])
 error ("%<-fsanitize=shadow-call-stack%> requires %<-ffixed-x18%>");
 
-  if ((opts->x_aarch64_isa_flags & (AARCH64_FL_SM_ON | AARCH64_FL_ZA_ON))
-  && !(opts->x_aarch64_isa_flags & AARCH64_FL_SME))
+  aarch64_feature_flags isa_flags = aarch64_get_isa_flags (opts);
+  if ((isa_flags & (AARCH64_FL_SM_ON | AARCH64_FL_ZA_ON))
+  && !(isa_flags & AARCH64_FL_SME))
 {
-  if (opts->x_aarch64_isa_flags & AARCH64_FL_SM_ON)
+  if (isa_flags & AARCH64_FL_SM_ON)
error ("streaming functions require the ISA extension %qs", "sme");
   else
error ("functions with SME state require the ISA extension %qs",
@@ -18341,8 +18342,7 @@ aarch64_override_options_internal (struct gcc_options 
*opts)
  " option %<-march%>, or by using the %"
  " attribute or pragma", "sme");
   opts->x_target_flags &= ~MASK_GENERAL_REGS_ONLY;
-  auto new_flags = (opts->x_aarch64_asm_isa_flags
-   | feature_deps::SME ().enable);
+  auto new_flags = isa_flags | feature_deps::SME ().enable;
   aarch64_set_asm_isa_flags (opts, new_flags);
 }
 
@@ -19036,9 +19036,9 @@ aarch64_option_print (FILE *file, int indent, struct 
cl_target_option *ptr)
   const struct processor *cpu
 = aarch64_get_tune_cpu (ptr->x_selected_tune);
   const struct processor *arch = aarch64_get_arch (ptr->x_selected_arch);
+  aarch64_feature_flags isa_flags = aarch64_get_asm_isa_flags(ptr);
   std::string extension
-= aarch64_get_extension_string_for_isa_flags (ptr->x_aarch64_asm_isa_flags,
- arch->flags);
+= aarch64_get_extension_string_for_isa_flags (isa_flags, arch->flags);
 
   fprintf (file, "%*sselected tune = %s\n", indent, "", cpu->name);
   fprintf (file, "%*sselected arch = %s%s\n", indent, "",
@@ -19098,7 +19098,7 @@ aarch64_set_current_function (tree fndecl)
   auto new_isa_mode = (fndecl
   ? aarch64_fndecl_isa_mode (fndecl)
   : AARCH64_DEFAULT_ISA_MODE);
-  auto isa_flags = TREE_TARGET_OPTION (new_tree)->x_aarch64_isa_flags;
+  auto isa_flags = aarch64_get_isa_flags (TREE_TARGET_OPTION (new_tree));
 
   static bool reported_zt0_p;
   if (!reported_zt0_p
@@ -20703,16 +20703,16 @@ aarch64_can_inline_p (tree caller, tree callee)
   : target_option_default_node);
 
   /* Callee's ISA flags should be a subset of the caller's.  */
-  auto caller_asm_isa = (caller_opts->x_aarch64_asm_isa_flags
+  auto caller_asm_isa = (aarch64_get_asm_isa_flags (caller_opts)
 & ~AARCH64_FL_ISA_MODES);
-  auto callee_asm_isa = (callee_opts->x_aarch64_asm_isa_flags
+  auto

[gcc/devel/fortran_unsigned] aarch64: Decouple feature flag option storage type

2024-07-28 Thread Thomas Kテカnig via Gcc-cvs
https://gcc.gnu.org/g:aa17619bfd61035c3cccb3ca40c72f2363a64600

commit aa17619bfd61035c3cccb3ca40c72f2363a64600
Author: Andrew Carlotti 
Date:   Fri May 10 11:56:57 2024 +0100

aarch64: Decouple feature flag option storage type

The awk scripts that process the .opt files are relatively fragile and
only handle a limited set of data types correctly.  The unrecognised
aarch64_feature_flags type is handled as a uint64_t, which happens to be
correct for now.  However, that assumption will change when we extend
the mask to 128 bits.

This patch changes the option members to use uint64_t types, and adds a
"_0" suffix to the names (both for future extensibility, and to allow
the original name to be used for the full aarch64_feature_flags mask
within generator files).

gcc/ChangeLog:

* common/config/aarch64/aarch64-common.cc
(aarch64_set_asm_isa_flags): Reorder, and add suffix to names.
* config/aarch64/aarch64.h
(aarch64_get_asm_isa_flags): Add "_0" suffix.
(aarch64_get_isa_flags): Ditto.
(aarch64_asm_isa_flags): Redefine using renamed uint64_t value.
(aarch64_isa_flags): Ditto.
* config/aarch64/aarch64.opt:
(aarch64_asm_isa_flags): Rename to...
(aarch64_asm_isa_flags_0): ...this, and change to uint64_t.
(aarch64_isa_flags): Rename to...
(aarch64_isa_flags_0): ...this, and change to uint64_t.

Diff:
---
 gcc/common/config/aarch64/aarch64-common.cc | 11 ++-
 gcc/config/aarch64/aarch64.h| 11 ---
 gcc/config/aarch64/aarch64.opt  |  4 ++--
 3 files changed, 16 insertions(+), 10 deletions(-)

diff --git a/gcc/common/config/aarch64/aarch64-common.cc 
b/gcc/common/config/aarch64/aarch64-common.cc
index 63c50189a09d..bd0770dd0d84 100644
--- a/gcc/common/config/aarch64/aarch64-common.cc
+++ b/gcc/common/config/aarch64/aarch64-common.cc
@@ -66,15 +66,16 @@ static const struct default_options 
aarch_option_optimization_table[] =
 { OPT_LEVELS_NONE, 0, NULL, 0 }
   };
 
-/* Set OPTS->x_aarch64_asm_isa_flags to FLAGS and update
-   OPTS->x_aarch64_isa_flags accordingly.  */
+
+/* Set OPTS->x_aarch64_asm_isa_flags_0 to FLAGS and update
+   OPTS->x_aarch64_isa_flags_0 accordingly.  */
 void
 aarch64_set_asm_isa_flags (gcc_options *opts, aarch64_feature_flags flags)
 {
-  opts->x_aarch64_asm_isa_flags = flags;
-  opts->x_aarch64_isa_flags = flags;
+  opts->x_aarch64_asm_isa_flags_0 = flags;
   if (opts->x_target_flags & MASK_GENERAL_REGS_ONLY)
-opts->x_aarch64_isa_flags &= ~feature_deps::get_flags_off (AARCH64_FL_FP);
+flags &= ~feature_deps::get_flags_off (AARCH64_FL_FP);
+  opts->x_aarch64_isa_flags_0 = flags;
 }
 
 /* Implement TARGET_HANDLE_OPTION.
diff --git a/gcc/config/aarch64/aarch64.h b/gcc/config/aarch64/aarch64.h
index 193f2486176b..903e708565dc 100644
--- a/gcc/config/aarch64/aarch64.h
+++ b/gcc/config/aarch64/aarch64.h
@@ -23,13 +23,18 @@
 #define GCC_AARCH64_H
 
 #define aarch64_get_asm_isa_flags(opts) \
-  (aarch64_feature_flags ((opts)->x_aarch64_asm_isa_flags))
+  (aarch64_feature_flags ((opts)->x_aarch64_asm_isa_flags_0))
 #define aarch64_get_isa_flags(opts) \
-  (aarch64_feature_flags ((opts)->x_aarch64_isa_flags))
+  (aarch64_feature_flags ((opts)->x_aarch64_isa_flags_0))
 
 /* Make these flags read-only so that all uses go via
aarch64_set_asm_isa_flags.  */
-#ifndef GENERATOR_FILE
+#ifdef GENERATOR_FILE
+#undef aarch64_asm_isa_flags
+#define aarch64_asm_isa_flags (aarch64_feature_flags (aarch64_asm_isa_flags_0))
+#undef aarch64_isa_flags
+#define aarch64_isa_flags (aarch64_feature_flags (aarch64_isa_flags_0))
+#else
 #undef aarch64_asm_isa_flags
 #define aarch64_asm_isa_flags (aarch64_get_asm_isa_flags (&global_options))
 #undef aarch64_isa_flags
diff --git a/gcc/config/aarch64/aarch64.opt b/gcc/config/aarch64/aarch64.opt
index 6356c419399b..45aab49de27b 100644
--- a/gcc/config/aarch64/aarch64.opt
+++ b/gcc/config/aarch64/aarch64.opt
@@ -31,10 +31,10 @@ TargetVariable
 enum aarch64_arch selected_arch = aarch64_no_arch
 
 TargetVariable
-aarch64_feature_flags aarch64_asm_isa_flags = 0
+uint64_t aarch64_asm_isa_flags_0 = 0
 
 TargetVariable
-aarch64_feature_flags aarch64_isa_flags = 0
+uint64_t aarch64_isa_flags_0 = 0
 
 TargetVariable
 unsigned aarch_enable_bti = 2


[gcc/devel/fortran_unsigned] aarch64: Add explicit bool cast to return value

2024-07-28 Thread Thomas Kテカnig via Gcc-cvs
https://gcc.gnu.org/g:7d55e6ca2bbe47a5b8892346b453580ff543b211

commit 7d55e6ca2bbe47a5b8892346b453580ff543b211
Author: Andrew Carlotti 
Date:   Wed Jul 10 15:00:16 2024 +0100

aarch64: Add explicit bool cast to return value

gcc/ChangeLog:

* config/aarch64/aarch64.cc
(aarch64_valid_sysreg_name_p): Add bool cast.

Diff:
---
 gcc/config/aarch64/aarch64.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc
index 66ce04d77e17..7c2af1316b67 100644
--- a/gcc/config/aarch64/aarch64.cc
+++ b/gcc/config/aarch64/aarch64.cc
@@ -30296,7 +30296,7 @@ aarch64_valid_sysreg_name_p (const char *regname)
   if (sysreg == NULL)
 return aarch64_is_implem_def_reg (regname);
   if (sysreg->arch_reqs)
-return (aarch64_isa_flags & sysreg->arch_reqs);
+return bool (aarch64_isa_flags & sysreg->arch_reqs);
   return true;
 }


[gcc/devel/fortran_unsigned] aarch64: Add bool conversion to TARGET_* macros

2024-07-28 Thread Thomas Kテカnig via Gcc-cvs
https://gcc.gnu.org/g:cc35f99789b7380558f97d835a0e67684f507721

commit cc35f99789b7380558f97d835a0e67684f507721
Author: Andrew Carlotti 
Date:   Wed Jul 10 14:42:37 2024 +0100

aarch64: Add bool conversion to TARGET_* macros

Use a new AARCH64_HAVE_ISA macro in TARGET_* definitions, and eliminate
all the AARCH64_ISA_* feature macros.

gcc/ChangeLog:

* config/aarch64/aarch64-c.cc
(aarch64_define_unconditional_macros): Use TARGET_V8R macro.
(aarch64_update_cpp_builtins): Use TARGET_* macros.
* config/aarch64/aarch64.h (AARCH64_HAVE_ISA): New macro.
(AARCH64_ISA_SM_OFF, AARCH64_ISA_SM_ON, AARCH64_ISA_ZA_ON)
(AARCH64_ISA_V8A, AARCH64_ISA_V8_1A, AARCH64_ISA_CRC)
(AARCH64_ISA_FP, AARCH64_ISA_SIMD, AARCH64_ISA_LSE)
(AARCH64_ISA_RDMA, AARCH64_ISA_V8_2A, AARCH64_ISA_F16)
(AARCH64_ISA_SVE, AARCH64_ISA_SVE2, AARCH64_ISA_SVE2_AES)
(AARCH64_ISA_SVE2_BITPERM, AARCH64_ISA_SVE2_SHA3)
(AARCH64_ISA_SVE2_SM4, AARCH64_ISA_SME, AARCH64_ISA_SME_I16I64)
(AARCH64_ISA_SME_F64F64, AARCH64_ISA_SME2, AARCH64_ISA_V8_3A)
(AARCH64_ISA_DOTPROD, AARCH64_ISA_AES, AARCH64_ISA_SHA2)
(AARCH64_ISA_V8_4A, AARCH64_ISA_SM4, AARCH64_ISA_SHA3)
(AARCH64_ISA_F16FML, AARCH64_ISA_RCPC, AARCH64_ISA_RCPC8_4)
(AARCH64_ISA_RNG, AARCH64_ISA_V8_5A, AARCH64_ISA_TME)
(AARCH64_ISA_MEMTAG, AARCH64_ISA_V8_6A, AARCH64_ISA_I8MM)
(AARCH64_ISA_F32MM, AARCH64_ISA_F64MM, AARCH64_ISA_BF16)
(AARCH64_ISA_SB, AARCH64_ISA_RCPC3, AARCH64_ISA_V8R)
(AARCH64_ISA_PAUTH, AARCH64_ISA_V8_7A, AARCH64_ISA_V8_8A)
(AARCH64_ISA_V8_9A, AARCH64_ISA_V9A, AARCH64_ISA_V9_1A)
(AARCH64_ISA_V9_2A, AARCH64_ISA_V9_3A, AARCH64_ISA_V9_4A)
(AARCH64_ISA_MOPS, AARCH64_ISA_LS64, AARCH64_ISA_CSSC)
(AARCH64_ISA_D128, AARCH64_ISA_THE, AARCH64_ISA_GCS): Remove.
(TARGET_BASE_SIMD, TARGET_SIMD, TARGET_FLOAT)
(TARGET_NON_STREAMING, TARGET_STREAMING, TARGET_ZA, TARGET_SHA2)
(TARGET_SHA3, TARGET_AES, TARGET_SM4, TARGET_F16FML)
(TARGET_CRC32, TARGET_LSE, TARGET_FP_F16INST)
(TARGET_SIMD_F16INST, TARGET_DOTPROD, TARGET_SVE, TARGET_SVE2)
(TARGET_SVE2_AES, TARGET_SVE2_BITPERM, TARGET_SVE2_SHA3)
(TARGET_SVE2_SM4, TARGET_SME, TARGET_SME_I16I64)
(TARGET_SME_F64F64, TARGET_SME2, TARGET_ARMV8_3, TARGET_JSCVT)
(TARGET_FRINT, TARGET_TME, TARGET_RNG, TARGET_MEMTAG)
(TARGET_I8MM, TARGET_SVE_I8MM, TARGET_SVE_F32MM)
(TARGET_SVE_F64MM, TARGET_BF16_FP, TARGET_BF16_SIMD)
(TARGET_SVE_BF16, TARGET_PAUTH, TARGET_BTI, TARGET_MOPS)
(TARGET_LS64, TARGET_CSSC, TARGET_SB, TARGET_RCPC, TARGET_RCPC2)
(TARGET_RCPC3, TARGET_SIMD_RDMA, TARGET_ARMV9_4, TARGET_D128)
(TARGET_THE, TARGET_GCS): Redefine using AARCH64_HAVE_ISA.
(TARGET_V8R, TARGET_V9A): New.
* config/aarch64/aarch64.md (arch_enabled): Use TARGET_RCPC2.
* config/aarch64/iterators.md (GPI_I16): Use TARGET_FP_F16INST.
(GPF_F16): Ditto.
* config/aarch64/predicates.md
(aarch64_rcpc_memory_operand): Use TARGET_RCPC2.

Diff:
---
 gcc/config/aarch64/aarch64-c.cc  |   6 +-
 gcc/config/aarch64/aarch64.h | 196 ++-
 gcc/config/aarch64/aarch64.md|   2 +-
 gcc/config/aarch64/iterators.md  |   4 +-
 gcc/config/aarch64/predicates.md |   2 +-
 5 files changed, 79 insertions(+), 131 deletions(-)

diff --git a/gcc/config/aarch64/aarch64-c.cc b/gcc/config/aarch64/aarch64-c.cc
index 2aff097dd33c..f9b9e3793755 100644
--- a/gcc/config/aarch64/aarch64-c.cc
+++ b/gcc/config/aarch64/aarch64-c.cc
@@ -64,7 +64,7 @@ aarch64_define_unconditional_macros (cpp_reader *pfile)
   builtin_define ("__ARM_ARCH_8A");
 
   builtin_define_with_int_value ("__ARM_ARCH_PROFILE",
-  AARCH64_ISA_V8R ? 'R' : 'A');
+  TARGET_V8R ? 'R' : 'A');
   builtin_define ("__ARM_FEATURE_CLZ");
   builtin_define ("__ARM_FEATURE_IDIV");
   builtin_define ("__ARM_FEATURE_UNALIGNED");
@@ -132,7 +132,7 @@ aarch64_update_cpp_builtins (cpp_reader *pfile)
   aarch64_def_or_undef (flag_unsafe_math_optimizations, "__ARM_FP_FAST", 
pfile);
 
   cpp_undef (pfile, "__ARM_ARCH");
-  builtin_define_with_int_value ("__ARM_ARCH", AARCH64_ISA_V9A ? 9 : 8);
+  builtin_define_with_int_value ("__ARM_ARCH", TARGET_V9A ? 9 : 8);
 
   builtin_define_with_int_value ("__ARM_SIZEOF_MINIMAL_ENUM",
 flag_short_enums ? 1 : 4);
@@ -259,7 +259,7 @@ aarch64_update_cpp_builtins (cpp_reader *pfile)
 
   aarch64_def_or_undef (TARGET_LS64,
"__ARM_FEATURE_LS64", pfile);
-  aarch64_def_or_undef (AARCH64_ISA_RCPC, "__ARM_FEATURE_RCPC", pfile);
+  aarch64_def_or_undef (TARGET_RCPC, "__ARM_FEATURE_RCPC", pfile);
   a

[gcc/devel/fortran_unsigned] aarch64: Use constructor explicitly in get_flags_off

2024-07-28 Thread Thomas Kテカnig via Gcc-cvs
https://gcc.gnu.org/g:8a2679f74fe0fe7717431e2b901f1aec6e607e72

commit 8a2679f74fe0fe7717431e2b901f1aec6e607e72
Author: Andrew Carlotti 
Date:   Thu Jul 11 01:25:05 2024 +0100

aarch64: Use constructor explicitly in get_flags_off

gcc/ChangeLog:

* config/aarch64/aarch64-feature-deps.h
(get_flags_off): Construct aarch64_feature_flags (0) explicitly.

Diff:
---
 gcc/config/aarch64/aarch64-feature-deps.h | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/gcc/config/aarch64/aarch64-feature-deps.h 
b/gcc/config/aarch64/aarch64-feature-deps.h
index 79126db88254..a14ae22b7298 100644
--- a/gcc/config/aarch64/aarch64-feature-deps.h
+++ b/gcc/config/aarch64/aarch64-feature-deps.h
@@ -97,9 +97,10 @@ template struct info;
 constexpr aarch64_feature_flags
 get_flags_off (aarch64_feature_flags mask)
 {
-  return (0
+  return (aarch64_feature_flags (0)
 #define AARCH64_OPT_EXTENSION(A, IDENT, C, D, E, F) \
- | (feature_deps::IDENT ().enable & mask ? AARCH64_FL_##IDENT : 0)
+ | (feature_deps::IDENT ().enable & mask ? AARCH64_FL_##IDENT \
+ : aarch64_feature_flags (0))
 #include "config/aarch64/aarch64-option-extensions.def"
  );
 }


[gcc/devel/fortran_unsigned] Add new bbitmap class

2024-07-28 Thread Thomas Kテカnig via Gcc-cvs
https://gcc.gnu.org/g:92b4552f64a1a065e6c20cdf55c8465faf3159cc

commit 92b4552f64a1a065e6c20cdf55c8465faf3159cc
Author: Andrew Carlotti 
Date:   Fri Jun 21 18:59:25 2024 +0100

Add new bbitmap class

This class provides a constant-size bitmap that can be used as almost a
drop-in replacement for bitmaps stored in integer types.  The
implementation is entirely within the header file and uses recursive
templated operations to support effective optimisation and usage in
constexpr expressions.

This initial implementation hardcodes the choice of uint64_t elements
for storage and initialisation, but this could instead be specified via
a second template parameter.

gcc/ChangeLog:

* bbitmap.h: New file.

Diff:
---
 gcc/bbitmap.h | 236 ++
 1 file changed, 236 insertions(+)

diff --git a/gcc/bbitmap.h b/gcc/bbitmap.h
new file mode 100644
index ..716c013b1035
--- /dev/null
+++ b/gcc/bbitmap.h
@@ -0,0 +1,236 @@
+/* Functions to support fixed-length bitmaps.
+   Copyright (C) 2024 Free Software Foundation, Inc.
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 3, or (at your option) any later
+version.
+
+GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING3.  If not see
+.  */
+
+#ifndef GCC_BBITMAP_H
+#define GCC_BBITMAP_H
+
+/* Implementation of bounded (fixed length) bitmaps.
+
+   This provides a drop-in replacement for bitmaps that have outgrown the
+   storage capacity of a single integer.
+
+   Sets are stored as a fixed length array of uint64_t elements.  The length of
+   this array is given as a template parameter.  */
+
+/* Use recusive templated functions to define constexpr operations.  */
+template
+struct bbitmap_operators
+{
+  /* Return a result that maps binary operator OP to elements [0, M) of
+ X and Y, and takes the remaining elements from REST.  */
+  template
+  static constexpr Result binary(Operator op, const Arg &x, const Arg &y,
+Rest ...rest)
+  {
+return bbitmap_operators::template binary
+  (op, x, y, op (x.val[M - 1], y.val[M - 1]), rest...);
+  }
+
+  /* Return a result that contains the bitwise inverse of elements [0, M) of X,
+ and takes the remaining elements from REST.  */
+  template
+  static constexpr Result bit_not(const Arg &x, Rest ...rest)
+  {
+return bbitmap_operators::template bit_not
+  (x, ~(x.val[M - 1]), rest...);
+  }
+
+  /* Return true if any element [0, M) of X is nonzero.  */
+  template
+  static constexpr bool non_zero(const Arg &x)
+  {
+return (bool) x.val[M - 1]
+  || bbitmap_operators::template non_zero (x);
+  }
+
+  /* Return true if elements [0, M) of X are all equal to the corresponding
+ elements of Y.  */
+  template
+  static constexpr bool equal(const Arg &x, const Arg &y)
+  {
+return x.val[M - 1] == y.val[M - 1]
+  && bbitmap_operators::template equal (x, y);
+  }
+
+  /* If bit index INDEX selects a bit in the first M elements, return a
+ Result with that bit set and the other bits of the leading M elements
+ clear.  Clear the leading M elements otherwise.  Take the remaining
+ elements of the Result from REST.  */
+  template
+  static constexpr Result from_index(int index, Rest ...rest)
+  {
+return bbitmap_operators::template from_index
+  (index,
+   uint64_t ((index - (M - 1) * 64) == (index & 63)) << (index & 63),
+   rest...);
+  }
+};
+
+/* These functions form the base for the recursive functions above.  They
+   return either bitmap containing the elements passed in REST, or a default
+   bool result.  */
+template<>
+struct bbitmap_operators<0>
+{
+  template
+  static constexpr Result binary(Operator, const Arg, const Arg,
+Rest ...rest)
+  {
+return Result { rest... };
+  }
+
+  template
+  static constexpr Result bit_not(const Arg, Rest ...rest)
+  {
+return Result { rest... };
+  }
+
+  template
+  static constexpr bool non_zero(const Arg)
+  {
+return false;
+  }
+
+  template
+  static constexpr bool equal(const Arg, const Arg)
+  {
+return true;
+  }
+
+  template
+  static constexpr Result from_index(int, Rest ...rest)
+  {
+return Result { rest... };
+  }
+};
+
+template
+constexpr T bbitmap_element_or(T x, T y) { return x | y;}
+
+template
+constexpr T bbitmap_element_and(T x, T y) { return x & y;}
+
+template
+constexpr T bbitmap_element_xor(T x, T y) { return x ^ y;}
+
+
+
+te

[gcc/devel/fortran_unsigned] aarch64: Extend aarch64_feature_flags to 128 bits

2024-07-28 Thread Thomas Kテカnig via Gcc-cvs
https://gcc.gnu.org/g:2afa4c45a392438dad05786a7c4dec9d8a3d097f

commit 2afa4c45a392438dad05786a7c4dec9d8a3d097f
Author: Andrew Carlotti 
Date:   Fri May 10 13:34:34 2024 +0100

aarch64: Extend aarch64_feature_flags to 128 bits

Replace the existing uint64_t typedef with a bbitmap<2> typedef.  Most
of the preparatory work was carried out in previous commits, so this
patch itself is fairly small.

gcc/ChangeLog:

* common/config/aarch64/aarch64-common.cc
(aarch64_set_asm_isa_flags): Store a second uint64_t value.
* config/aarch64/aarch64-opts.h
(aarch64_feature_flags): Switch typedef to bbitmap<2>.
* config/aarch64/aarch64.cc
(aarch64_set_current_function): Extract isa mode from val[0].
* config/aarch64/aarch64.h
(aarch64_get_asm_isa_flags): Load a second uint64_t value.
(aarch64_get_isa_flags): Ditto.
(aarch64_asm_isa_flags): Ditto.
(aarch64_isa_flags): Ditto.
(HANDLE): Use bbitmap<2>::from_index to initialise flags.
(AARCH64_FL_ISA_MODES): Do arithmetic on integer type.
(AARCH64_ISA_MODE): Extract value from bbitmap<2> array.
* config/aarch64/aarch64.opt
(aarch64_asm_isa_flags_1): New variable.
(aarch64_isa_flags_1): Ditto.

Diff:
---
 gcc/common/config/aarch64/aarch64-common.cc | 12 
 gcc/config/aarch64/aarch64-opts.h   |  6 --
 gcc/config/aarch64/aarch64.cc   |  6 +++---
 gcc/config/aarch64/aarch64.h| 20 
 gcc/config/aarch64/aarch64.opt  |  6 ++
 5 files changed, 33 insertions(+), 17 deletions(-)

diff --git a/gcc/common/config/aarch64/aarch64-common.cc 
b/gcc/common/config/aarch64/aarch64-common.cc
index bd0770dd0d84..64b65b7ff9e4 100644
--- a/gcc/common/config/aarch64/aarch64-common.cc
+++ b/gcc/common/config/aarch64/aarch64-common.cc
@@ -67,15 +67,19 @@ static const struct default_options 
aarch_option_optimization_table[] =
   };
 
 
-/* Set OPTS->x_aarch64_asm_isa_flags_0 to FLAGS and update
-   OPTS->x_aarch64_isa_flags_0 accordingly.  */
+/* Set OPTS->x_aarch64_asm_isa_flags_<0..n> to FLAGS and update
+   OPTS->x_aarch64_isa_flags_<0..n> accordingly.  */
 void
 aarch64_set_asm_isa_flags (gcc_options *opts, aarch64_feature_flags flags)
 {
-  opts->x_aarch64_asm_isa_flags_0 = flags;
+  opts->x_aarch64_asm_isa_flags_0 = flags.val[0];
+  opts->x_aarch64_asm_isa_flags_1 = flags.val[1];
+
   if (opts->x_target_flags & MASK_GENERAL_REGS_ONLY)
 flags &= ~feature_deps::get_flags_off (AARCH64_FL_FP);
-  opts->x_aarch64_isa_flags_0 = flags;
+
+  opts->x_aarch64_isa_flags_0 = flags.val[0];
+  opts->x_aarch64_isa_flags_1 = flags.val[1];
 }
 
 /* Implement TARGET_HANDLE_OPTION.
diff --git a/gcc/config/aarch64/aarch64-opts.h 
b/gcc/config/aarch64/aarch64-opts.h
index 2c36bfaad19b..80ec1a05253d 100644
--- a/gcc/config/aarch64/aarch64-opts.h
+++ b/gcc/config/aarch64/aarch64-opts.h
@@ -23,14 +23,16 @@
 #define GCC_AARCH64_OPTS_H
 
 #ifndef USED_FOR_TARGET
-typedef uint64_t aarch64_isa_mode;
+#include "bbitmap.h"
 
-typedef uint64_t aarch64_feature_flags;
+typedef uint64_t aarch64_isa_mode;
 
 constexpr unsigned int AARCH64_NUM_ISA_MODES = (0
 #define DEF_AARCH64_ISA_MODE(IDENT) + 1
 #include "aarch64-isa-modes.def"
 );
+
+typedef bbitmap<2> aarch64_feature_flags;
 #endif
 
 /* The various cores that implement AArch64.  */
diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc
index 7c2af1316b67..e0cf382998c7 100644
--- a/gcc/config/aarch64/aarch64.cc
+++ b/gcc/config/aarch64/aarch64.cc
@@ -19119,7 +19119,7 @@ aarch64_set_current_function (tree fndecl)
  aarch64_pragma_target_parse.  */
   if (old_tree == new_tree
   && (!fndecl || aarch64_previous_fndecl)
-  && (aarch64_isa_mode) (isa_flags & AARCH64_FL_ISA_MODES) == new_isa_mode)
+  && (isa_flags & AARCH64_FL_ISA_MODES).val[0] == new_isa_mode)
 {
   gcc_assert (AARCH64_ISA_MODE == new_isa_mode);
   return;
@@ -19134,11 +19134,11 @@ aarch64_set_current_function (tree fndecl)
   /* The ISA mode can vary based on function type attributes and
  function declaration attributes.  Make sure that the target
  options correctly reflect these attributes.  */
-  if ((aarch64_isa_mode) (isa_flags & AARCH64_FL_ISA_MODES) != new_isa_mode)
+  if ((isa_flags & AARCH64_FL_ISA_MODES).val[0] != new_isa_mode)
 {
   auto base_flags = (aarch64_asm_isa_flags & ~AARCH64_FL_ISA_MODES);
   aarch64_set_asm_isa_flags (base_flags
-| (aarch64_feature_flags) new_isa_mode);
+| aarch64_feature_flags (new_isa_mode));
 
   aarch64_override_options_internal (&global_options);
   new_tree = build_target_option_node (&global_options,
diff --git a/gcc/config/aarch64/aarch64.h b/gcc/config/aarch64/aarch64.h
index 6310ebd72ff2..b7e330438d9b 1006

[gcc/devel/fortran_unsigned] libstdc++: Remove duplicate include header from ranges_algobase.h

2024-07-28 Thread Thomas Kテカnig via Libstdc++-cvs
https://gcc.gnu.org/g:30c2dbf53800fffba148fadc3b8bac556efcc572

commit 30c2dbf53800fffba148fadc3b8bac556efcc572
Author: Michael Levine 
Date:   Tue Jul 23 12:50:31 2024 +0100

libstdc++: Remove duplicate include header from ranges_algobase.h

The bits/stl_algobase.h header was added to bits/ranges_algobase.h
separately through two related commits:
r15-1106-g674d213ab91871
r15-1117-g0bb1db32ccf54a

The comment for the first time it is included in the file is also
incorrect (my error from that 2nd one) since it is really being included
for __memcmp, not __memcpy

This patch removes the duplicate header include.

libstdc++-v3/ChangeLog:

* include/bits/ranges_algobase.h: Remove duplicate include of
.

Signed-off-by: Michael Levine 

Diff:
---
 libstdc++-v3/include/bits/ranges_algobase.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/libstdc++-v3/include/bits/ranges_algobase.h 
b/libstdc++-v3/include/bits/ranges_algobase.h
index 7ce5ac314f25..fd35b8ba14cb 100644
--- a/libstdc++-v3/include/bits/ranges_algobase.h
+++ b/libstdc++-v3/include/bits/ranges_algobase.h
@@ -35,7 +35,6 @@
 #include 
 #include 
 #include 
-#include  // __memcpy
 #include  // ranges::begin, ranges::range etc.
 #include   // __invoke
 #include  // __is_byte


[gcc/devel/fortran_unsigned] libstdc++: Fix std::vector for -std=gnu++14 -fconcepts [PR116070]

2024-07-28 Thread Thomas Kテカnig via Libstdc++-cvs
https://gcc.gnu.org/g:a45833868858e10293d68c72717ebec533e189a8

commit a45833868858e10293d68c72717ebec533e189a8
Author: Jonathan Wakely 
Date:   Wed Jul 24 11:32:22 2024 +0100

libstdc++: Fix std::vector for -std=gnu++14 -fconcepts [PR116070]

This questionable combination of flags causes a number of errors. This
one in std::vector needs to be fixed in the gcc-13 branch so I'm
committing it separately to simplify backporting.

libstdc++-v3/ChangeLog:

PR libstdc++/116070
* include/bits/stl_bvector.h: Check feature test macro before
using is_default_constructible_v.

Diff:
---
 libstdc++-v3/include/bits/stl_bvector.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libstdc++-v3/include/bits/stl_bvector.h 
b/libstdc++-v3/include/bits/stl_bvector.h
index 245e1c3b3a77..c45b7ff3320d 100644
--- a/libstdc++-v3/include/bits/stl_bvector.h
+++ b/libstdc++-v3/include/bits/stl_bvector.h
@@ -593,7 +593,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
_GLIBCXX20_CONSTEXPR
_Bvector_impl() _GLIBCXX_NOEXCEPT_IF(
  is_nothrow_default_constructible<_Bit_alloc_type>::value)
-#if __cpp_concepts
+#if __cpp_concepts && __glibcxx_type_trait_variable_templates
requires is_default_constructible_v<_Bit_alloc_type>
 #endif
: _Bit_alloc_type()


[gcc/devel/fortran_unsigned] libstdc++: Fix and for -std=gnu++14 -fconcepts [PR116070]

2024-07-28 Thread Thomas Kテカnig via Libstdc++-cvs
https://gcc.gnu.org/g:00fc1169f7cea8149c2a5442d07b64615cb8b336

commit 00fc1169f7cea8149c2a5442d07b64615cb8b336
Author: Jonathan Wakely 
Date:   Wed Jul 24 11:32:22 2024 +0100

libstdc++: Fix  and  for -std=gnu++14 -fconcepts 
[PR116070]

This questionable combination of flags causes a number of errors. The
ones in the rvalue stream overloads need to be fixed in the gcc-14
branch so I'm committing it separately to simplify backporting.

libstdc++-v3/ChangeLog:

PR libstdc++/116070
* include/std/istream: Check feature test macro before using
is_class_v and is_same_v.
* include/std/ostream: Likewise.

Diff:
---
 libstdc++-v3/include/std/istream | 2 +-
 libstdc++-v3/include/std/ostream | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/libstdc++-v3/include/std/istream b/libstdc++-v3/include/std/istream
index 11d51d3e666c..a2b207dae78c 100644
--- a/libstdc++-v3/include/std/istream
+++ b/libstdc++-v3/include/std/istream
@@ -1069,7 +1069,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   // 2328. Rvalue stream extraction should use perfect forwarding
   // 1203. More useful rvalue stream insertion
 
-#if __cpp_concepts >= 201907L
+#if __cpp_concepts >= 201907L && __glibcxx_type_trait_variable_templates
   template
 requires __derived_from_ios_base<_Is>
   && requires (_Is& __is, _Tp&& __t) { __is >> std::forward<_Tp>(__t); }
diff --git a/libstdc++-v3/include/std/ostream b/libstdc++-v3/include/std/ostream
index 8a21758d0a33..12be6c4fd178 100644
--- a/libstdc++-v3/include/std/ostream
+++ b/libstdc++-v3/include/std/ostream
@@ -768,7 +768,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   // _GLIBCXX_RESOLVE_LIB_DEFECTS
   // 1203. More useful rvalue stream insertion
 
-#if __cpp_concepts >= 201907L
+#if __cpp_concepts >= 201907L && __glibcxx_type_trait_variable_templates
   // Use concepts if possible because they're cheaper to evaluate.
   template
 concept __derived_from_ios_base = is_class_v<_Tp>


[gcc/devel/fortran_unsigned] testsuite: Fix up pr116034.c test for big/pdp endian [PR116061]

2024-07-28 Thread Thomas Kテカnig via Gcc-cvs
https://gcc.gnu.org/g:41886930c339c382cd4b5d9ea959590390bb0ac4

commit 41886930c339c382cd4b5d9ea959590390bb0ac4
Author: Jakub Jelinek 
Date:   Wed Jul 24 18:00:05 2024 +0200

testsuite: Fix up pr116034.c test for big/pdp endian [PR116061]

Didn't notice the memmove is into an int variable, so the test
was still failing on big endian.

2024-07-24  Jakub Jelinek  

PR tree-optimization/116034
PR testsuite/116061
* gcc.dg/pr116034.c (g): Change type from int to unsigned short.
(foo): Guard memmove call on __SIZEOF_SHORT__ == 2.

Diff:
---
 gcc/testsuite/gcc.dg/pr116034.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/gcc/testsuite/gcc.dg/pr116034.c b/gcc/testsuite/gcc.dg/pr116034.c
index 9a31de034246..955b4c9e86b8 100644
--- a/gcc/testsuite/gcc.dg/pr116034.c
+++ b/gcc/testsuite/gcc.dg/pr116034.c
@@ -2,12 +2,13 @@
 /* { dg-do run } */
 /* { dg-options "-O1 -fno-strict-aliasing" } */
 
-int g;
+unsigned short int g;
 
 static inline int
 foo (_Complex unsigned short c)
 {
-  __builtin_memmove (&g, 1 + (char *) &c, 2);
+  if (__SIZEOF_SHORT__ == 2)
+__builtin_memmove (&g, 1 + (char *) &c, 2);
   return g;
 }


[gcc/devel/fortran_unsigned] [rtl-optimization/116037] Explicitly track if a destination was skipped in ext-dce

2024-07-28 Thread Thomas Kテカnig via Gcc-cvs
https://gcc.gnu.org/g:e1577cad35935cfc687337c7cbd14ac105b6827d

commit e1577cad35935cfc687337c7cbd14ac105b6827d
Author: Jeff Law 
Date:   Wed Jul 24 11:16:26 2024 -0600

[rtl-optimization/116037] Explicitly track if a destination was skipped in 
ext-dce

So this has been in the hopper since the first bugs were reported against
ext-dce.  It'd been holding off committing as I was finding other issues in
terms of correctness of live computations.  There's still problems in that
space, but I think it's time to push this chunk forward.  I'm marking it as
116037, but it may impact other bugs.

This patch starts explicitly tracking if set processing skipped a 
destination,
which can happen for wide modes (TI+), vectors, certain subregs, etc.  This 
is
computed during ext_dce_set_processing.

During use processing we use that flag to determine reliably if we need to 
make
the inputs fully live and to avoid even trying to eliminate an extension if 
we
skipped output processing.

While testing this I found that a recent change to fix cases where we had 
two
subreg input operands mucked up the code to make things like a shift/rotate
count fully live.  So that goof has been fixed.

Bootstrapped and regression tested on x86.  Most, but not all, of these 
changes
have also been tested on the crosses.  Pushing to the trunk.

I'm not including it in this patch but I'm poking at converting this code to
use note_uses/note_stores to make it more maintainable.  The SUBREG and
STRICT_LOW_PART handling of note_stores is problematical, but I think it's
solvable.  I haven't tried a conversion to note_uses yet.

PR rtl-optimization/116037
gcc/
* ext-dce.cc (ext_dce_process_sets): Note if we ever skip a dest
and return that info explicitly.
(ext_dce_process_uses): If a set was skipped, then consider all bits
in every input as live.  Do not try to optimize away an extension if
we skipped processing a destination in the same insn.  Restore code
to make shift/rotate count fully live.
(ext_dce_process_bb): Handle API changes for ext_dce_process_sets.

gcc/testsuite/
* gcc.dg/torture/pr116037.c: New test

Diff:
---
 gcc/ext-dce.cc  | 42 ++---
 gcc/testsuite/gcc.dg/torture/pr116037.c | 36 
 2 files changed, 69 insertions(+), 9 deletions(-)

diff --git a/gcc/ext-dce.cc b/gcc/ext-dce.cc
index c56dfb505b88..c94d1fc34145 100644
--- a/gcc/ext-dce.cc
+++ b/gcc/ext-dce.cc
@@ -181,9 +181,11 @@ safe_for_live_propagation (rtx_code code)
within an object) are set by INSN, the more aggressive the
optimization phase during use handling will be.  */
 
-static void
+static bool
 ext_dce_process_sets (rtx_insn *insn, rtx obj, bitmap live_tmp)
 {
+  bool skipped_dest = false;
+
   subrtx_iterator::array_type array;
   FOR_EACH_SUBRTX (iter, array, obj, NONCONST)
 {
@@ -210,6 +212,7 @@ ext_dce_process_sets (rtx_insn *insn, rtx obj, bitmap 
live_tmp)
  /* Skip the subrtxs of this destination.  There is
 little value in iterating into the subobjects, so
 just skip them for a bit of efficiency.  */
+ skipped_dest = true;
  iter.skip_subrtxes ();
  continue;
}
@@ -241,6 +244,7 @@ ext_dce_process_sets (rtx_insn *insn, rtx obj, bitmap 
live_tmp)
  /* Skip the subrtxs of the STRICT_LOW_PART.  We can't
 process them because it'll set objects as no longer
 live when they are in fact still live.  */
+ skipped_dest = true;
  iter.skip_subrtxes ();
  continue;
}
@@ -291,6 +295,7 @@ ext_dce_process_sets (rtx_insn *insn, rtx obj, bitmap 
live_tmp)
  if (!is_a  (GET_MODE (SUBREG_REG (x)), 
&outer_mode)
  || GET_MODE_BITSIZE (outer_mode) > 64)
{
+ skipped_dest = true;
  iter.skip_subrtxes ();
  continue;
}
@@ -318,6 +323,7 @@ ext_dce_process_sets (rtx_insn *insn, rtx obj, bitmap 
live_tmp)
 remain the same.  Thus we can not continue here, we must
 either figure out what part of the destination is modified
 or skip the sub-rtxs.  */
+ skipped_dest = true;
  iter.skip_subrtxes ();
  continue;
}
@@ -370,9 +376,11 @@ ext_dce_process_sets (rtx_insn *insn, rtx obj, bitmap 
live_tmp)
   else if (GET_CODE (x) == COND_EXEC)
{
  /* This isn't ideal, but may not be so bad in practice.  */
+ skipped_dest = true;
  iter.skip_subrtxes ();
}
 }
+  return skipped_dest;
 }
 
 /* INSN has a sign/zero extended source

[gcc/devel/fortran_unsigned] c++: parse error with -std=c++14 -fconcepts [PR116071]

2024-07-28 Thread Thomas Kテカnig via Gcc-cvs
https://gcc.gnu.org/g:ea94dde1aa58bd337772f74787f821b34f866c4a

commit ea94dde1aa58bd337772f74787f821b34f866c4a
Author: Jason Merrill 
Date:   Wed Jul 24 16:20:33 2024 -0400

c++: parse error with -std=c++14 -fconcepts [PR116071]

cp_parser_simple_type_specifier tries a variety of different things that
might qualify as a user-defined type: an actual type-name, a constrained
auto, a CTAD placeholder.  In a context where a type-specifier is optional,
this is all tentative.  With -std=c++14 -fconcepts, we try type-name and
constrained auto in sub-tentative parses, and when we run out of things to
try we haven't found anything but also haven't failed the outer tentative
parse, so parse_definitely succeeds, discarding the nested-name-specifier.

Fixed by failing if we didn't find anything.

I said in r14-3203 that we should disable this combination of flags if
further problems arise, but this seems like a more general problem that only
happened to occur with just this combination of flags.  So it lives on.

PR c++/116071

gcc/cp/ChangeLog:

* parser.cc (cp_parser_simple_type_specifier): Call
cp_parser_simulate_error if nothing worked.

gcc/testsuite/ChangeLog:

* g++.dg/parse/pr116071.C: New test.

Diff:
---
 gcc/cp/parser.cc  | 10 +++---
 gcc/testsuite/g++.dg/parse/pr116071.C | 18 ++
 2 files changed, 25 insertions(+), 3 deletions(-)

diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc
index 1fa0780944b6..f79736c17ac6 100644
--- a/gcc/cp/parser.cc
+++ b/gcc/cp/parser.cc
@@ -20786,9 +20786,13 @@ cp_parser_simple_type_specifier (cp_parser* parser,
}
 
   /* If it didn't work out, we don't have a TYPE.  */
-  if ((flags & CP_PARSER_FLAGS_OPTIONAL)
- && !cp_parser_parse_definitely (parser))
-   type = NULL_TREE;
+  if (flags & CP_PARSER_FLAGS_OPTIONAL)
+   {
+ if (!type)
+   cp_parser_simulate_error (parser);
+ if (!cp_parser_parse_definitely (parser))
+   type = NULL_TREE;
+   }
 
   /* Keep track of all name-lookups performed in class scopes.  */
   if (type
diff --git a/gcc/testsuite/g++.dg/parse/pr116071.C 
b/gcc/testsuite/g++.dg/parse/pr116071.C
new file mode 100644
index ..7590782d5ee8
--- /dev/null
+++ b/gcc/testsuite/g++.dg/parse/pr116071.C
@@ -0,0 +1,18 @@
+// PR c++/116071
+// { dg-options "-std=c++14 -fconcepts" }
+
+template struct S { ~S(); };
+template S::~S() { }
+
+template
+struct result_of;
+
+template
+struct result_of
+{
+  using type = void;
+};
+
+struct thread {
+  void join() { };
+};


[gcc/devel/fortran_unsigned] c++: Mostly concepts related formatting fixes

2024-07-28 Thread Thomas Kテカnig via Gcc-cvs
https://gcc.gnu.org/g:2e6caf0f849f92332e95c468d6d989699301db77

commit 2e6caf0f849f92332e95c468d6d989699301db77
Author: Jakub Jelinek 
Date:   Wed Jul 24 19:46:58 2024 +0200

c++: Mostly concepts related formatting fixes

When playing with P2963R3, while reading and/or modifying code I've fixed
various comment or code formatting issues (and in 3 spots also comment
wording), but including that in the WIP P2963R3 patch made that patch
totally unreadable because these changes were 4 times the size of the
actual code changes.

So, here it is separated to a pure formatting + comment wording patch.

2024-07-24  Jakub Jelinek  

* constraint.cc (subst_info::quiet, subst_info::noisy): Formatting
fixes.
(known_non_bool_p): Comment formatting fixes.
(unpack_concept_check): Likewise.
(resolve_function_concept_overload): Likewise.
(resolve_function_concept_check): Likewise.
(resolve_concept_check): Likewise.
(deduce_constrained_parameter): Likewise.
(finish_type_constraints): Likewise.
(get_returned_expression): Likewise.
(get_variable_initializer): Likewise.
(norm_info::update_context, norm_info::ctx_params): Formatting
fixes.
(norm_info::context): Comment formatting fixes.
(normalize_logical_operation): Likewise.  Formatting fix.
(normalize_concept_check): Comment formatting fixes.
(normalize_atom): Likewise.
(normalize_expression): Likewise.
(get_normalized_constraints_from_info): Likewise.
(get_normalized_constraints_from_decl): Likewise.  Formatting
fixes.
(atomic_constraints_identical_p): Comment formatting fixes.
(constraints_equivalent_p): Formatting fixes.
(inchash::add_constraint): Likewise.
(associate_classtype_constraints): Comment formatting fixes.
(get_constraints): Likewise.
(set_constraints): Likewise.
(build_concept_check_arguments): Likewise.
(build_function_check): Likewise.
(build_concept_check): Likewise.
(finish_shorthand_constraint): Likewise.
(get_shorthand_constraints): Likewise.
(check_constraint_variables): Likewise.
(tsubst_constraint_variables): Likewise.
(tsubst_requires_expr): Likewise.
(get_mapped_args): Likewise.  Formatting fixes.
(satisfy_atom): Comment formatting fixes.
(satisfy_constraint_r): Comment wording and formatting fixes.
(satisfy_normalized_constraints): Comment formatting fixes.
(satisfy_declaration_constraints): Likewise.
(evaluate_concept_check): Likewise.
(finish_requires_expr): Likewise.
(finish_compound_requirement): Likewise.
(check_function_concept): Likewise.
(equivalently_constrained): Likewise.
(more_constrained): Likewise.
(diagnose_atomic_constraint): Likewise.
* cp-tree.h (TREE_LANG_FLAG_0): Fix a comment error,
FOLD_EXPR_MODIFY_P instead of FOLD_EXPR_MODOP_P.
(DECL_MAIN_FREESTANDING_P, DECL_MAIN_P): Comment formatting fixes.
(enum cpp0x_warn_str): Likewise.
(enum composite_pointer_operation): Likewise.
(enum expr_list_kind): Likewise.
(enum impl_conv_rhs): Likewise.
(enum impl_conv_void): Likewise.
(struct deferred_access_check): Likewise.
(ATOMIC_CONSTR_EXPR): Likewise.
(FUNCTION_REF_QUALIFIED): Likewise.
(DECL_DEPENDENT_P): Likewise.
(FOLD_EXPR_MODIFY_P): Likewise.
(FOLD_EXPR_OP_RAW): Likewise.
(FOLD_EXPR_PACK): Likewise.
(FOLD_EXPR_INIT): Likewise.
(TYPE_WAS_UNNAMED): Likewise.
(class cp_unevaluated): Likewise.
(struct ovl_op_info_t assertion): Likewise.
(cp_declarator::function::requires_clause): Likewise.
(variable_template_p): Likewise.
(concept_definition_p): Likewise.
* logic.cc (clause::clause): Likewise.
(clause::replace): Likewise.
(clause::insert): Likewise.  Formatting fixes.
(struct formula): Comment formatting fixes.
(formula::branch): Likewise.
(debug): Formatting fixes.
(dnf_size_r): Comment formatting fixes.
(cnf_size_r): Likewise.
(dnf_size): Likewise.
(cnf_size): Likewise.
(branch_clause): Likewise.
(decompose_term): Likewise.  Formatting fixes.
(struct subsumption_entry): Comment formatting fixes.
(subsumption_cache): Likewise.
(save_subsumption): Likewise.  Formatting fixes.
(subsumes_cons

[gcc/devel/fortran_unsigned] json: add dump overload for easier debugging

2024-07-28 Thread Thomas Kテカnig via Gcc-cvs
https://gcc.gnu.org/g:4dbb4af7aafdd67eb4d8247c83e92d2d1e9bbbd7

commit 4dbb4af7aafdd67eb4d8247c83e92d2d1e9bbbd7
Author: David Malcolm 
Date:   Wed Jul 24 18:07:51 2024 -0400

json: add dump overload for easier debugging

This has saved me a lot of typing in the debugger.

gcc/ChangeLog:
* json.cc (value::dump): New overload, taking no params.
* json.h (value::dump): New decl.

Signed-off-by: David Malcolm 

Diff:
---
 gcc/json.cc | 10 ++
 gcc/json.h  |  1 +
 2 files changed, 11 insertions(+)

diff --git a/gcc/json.cc b/gcc/json.cc
index b3106f39cedf..53edca520556 100644
--- a/gcc/json.cc
+++ b/gcc/json.cc
@@ -90,6 +90,16 @@ value::dump (FILE *outf, bool formatted) const
   pp_flush (&pp);
 }
 
+/* A convenience function for debugging.
+   Dump to stderr with formatting, and a trailing newline. */
+
+void
+value::dump () const
+{
+  dump (stderr, true);
+  fprintf (stderr, "\n");
+}
+
 /* class json::object, a subclass of json::value, representing
an ordered collection of key/value pairs.  */
 
diff --git a/gcc/json.h b/gcc/json.h
index 97c68116b329..ad4f8c448f8c 100644
--- a/gcc/json.h
+++ b/gcc/json.h
@@ -83,6 +83,7 @@ class value
   virtual void print (pretty_printer *pp, bool formatted) const = 0;
 
   void dump (FILE *, bool formatted) const;
+  void DEBUG_FUNCTION dump () const;
 };
 
 /* Subclass of value for objects: a collection of key/value pairs


[gcc/devel/fortran_unsigned] analyzer: reduce use of naked "new" for json dumps

2024-07-28 Thread Thomas Kテカnig via Gcc-cvs
https://gcc.gnu.org/g:8c6f0b6e2aa5a3b7207a2a8dd196f00b3bc1f56f

commit 8c6f0b6e2aa5a3b7207a2a8dd196f00b3bc1f56f
Author: David Malcolm 
Date:   Wed Jul 24 18:07:52 2024 -0400

analyzer: reduce use of naked "new" for json dumps

No functional change intended.

gcc/analyzer/ChangeLog:
* call-string.cc (call_string::to_json): Avoid naked "new".
* constraint-manager.cc (bounded_range::set_json_attr): Likewise.
(equiv_class::to_json): Likewise.
(constraint::to_json): Likewise.
(bounded_ranges_constraint::to_json): Likewise.
* diagnostic-manager.cc (saved_diagnostic::to_json): Likewise.
(saved_diagnostic::maybe_add_sarif_properties): Likewise.
* engine.cc (exploded_node::to_json): Likewise.
(exploded_edge::to_json): Likewise.
* program-point.cc (program_point::to_json): Likewise.
* program-state.cc (program_state::to_json): Likewise.
* sm.cc (state_machine::to_json): Likewise.
* store.cc (binding_cluster::to_json): Likewise.
(store::to_json): Likewise.
* supergraph.cc (supernode::to_json): Likewise.
(superedge::to_json): Likewise.

Signed-off-by: David Malcolm 

Diff:
---
 gcc/analyzer/call-string.cc|  9 +++--
 gcc/analyzer/constraint-manager.cc | 12 ++--
 gcc/analyzer/diagnostic-manager.cc | 14 +++---
 gcc/analyzer/engine.cc | 13 ++---
 gcc/analyzer/program-point.cc  | 11 ---
 gcc/analyzer/program-state.cc  |  2 +-
 gcc/analyzer/sm.cc |  2 +-
 gcc/analyzer/store.cc  |  6 +++---
 gcc/analyzer/supergraph.cc | 17 -
 9 files changed, 39 insertions(+), 47 deletions(-)

diff --git a/gcc/analyzer/call-string.cc b/gcc/analyzer/call-string.cc
index 23880e3f5419..c404c09ca0df 100644
--- a/gcc/analyzer/call-string.cc
+++ b/gcc/analyzer/call-string.cc
@@ -111,12 +111,9 @@ call_string::to_json () const
   for (const call_string::element_t &e : m_elements)
 {
   json::object *e_obj = new json::object ();
-  e_obj->set ("src_snode_idx",
- new json::integer_number (e.m_callee->m_index));
-  e_obj->set ("dst_snode_idx",
- new json::integer_number (e.m_caller->m_index));
-  e_obj->set ("funcname",
- new json::string (function_name (e.m_caller->m_fun)));
+  e_obj->set_integer ("src_snode_idx", e.m_callee->m_index);
+  e_obj->set_integer ("dst_snode_idx", e.m_caller->m_index);
+  e_obj->set_string ("funcname", function_name (e.m_caller->m_fun));
   arr->append (e_obj);
 }
 
diff --git a/gcc/analyzer/constraint-manager.cc 
b/gcc/analyzer/constraint-manager.cc
index 29539060ebdd..62d3b84bb745 100644
--- a/gcc/analyzer/constraint-manager.cc
+++ b/gcc/analyzer/constraint-manager.cc
@@ -479,7 +479,7 @@ bounded_range::set_json_attr (json::object *obj, const char 
*name, tree value)
   pretty_printer pp;
   pp_format_decoder (&pp) = default_tree_printer;
   pp_printf (&pp, "%E", value);
-  obj->set (name, new json::string (pp_formatted_text (&pp)));
+  obj->set_string (name, pp_formatted_text (&pp));
 }
 
 
@@ -1140,7 +1140,7 @@ equiv_class::to_json () const
   pretty_printer pp;
   pp_format_decoder (&pp) = default_tree_printer;
   pp_printf (&pp, "%qE", m_constant);
-  ec_obj->set ("constant", new json::string (pp_formatted_text (&pp)));
+  ec_obj->set_string ("constant", pp_formatted_text (&pp));
 }
 
   return ec_obj;
@@ -1397,9 +1397,9 @@ constraint::to_json () const
 {
   json::object *con_obj = new json::object ();
 
-  con_obj->set ("lhs", new json::integer_number (m_lhs.as_int ()));
-  con_obj->set ("op", new json::string (constraint_op_code (m_op)));
-  con_obj->set ("rhs", new json::integer_number (m_rhs.as_int ()));
+  con_obj->set_integer ("lhs", m_lhs.as_int ());
+  con_obj->set_string ("op", constraint_op_code (m_op));
+  con_obj->set_integer ("rhs", m_rhs.as_int ());
 
   return con_obj;
 }
@@ -1485,7 +1485,7 @@ bounded_ranges_constraint::to_json () const
 {
   json::object *con_obj = new json::object ();
 
-  con_obj->set ("ec", new json::integer_number (m_ec_id.as_int ()));
+  con_obj->set_integer ("ec", m_ec_id.as_int ());
   con_obj->set ("ranges", m_ranges->to_json ());
 
   return con_obj;
diff --git a/gcc/analyzer/diagnostic-manager.cc 
b/gcc/analyzer/diagnostic-manager.cc
index 51304b0795b6..92e30bd049bd 100644
--- a/gcc/analyzer/diagnostic-manager.cc
+++ b/gcc/analyzer/diagnostic-manager.cc
@@ -746,17 +746,17 @@ saved_diagnostic::to_json () const
   json::object *sd_obj = new json::object ();
 
   if (m_sm)
-sd_obj->set ("sm", new json::string (m_sm->get_name ()));
-  sd_obj->set ("enode", new json::integer_number (m_enode->m_index));
-  sd_obj->set ("snode", new json::integer_number (m_snode->m_index));
+sd_obj->set_string ("sm", m_sm->get_name ());
+  sd_obj->set_i

[gcc/devel/fortran_unsigned] json: add array::append_string

2024-07-28 Thread Thomas Kテカnig via Gcc-cvs
https://gcc.gnu.org/g:4a228dcfe5016401a02598910c7d0af7aa1f6b8d

commit 4a228dcfe5016401a02598910c7d0af7aa1f6b8d
Author: David Malcolm 
Date:   Wed Jul 24 18:07:51 2024 -0400

json: add array::append_string

No functional change intended.

gcc/analyzer/ChangeLog:
* supergraph.cc (supernode::to_json): Avoid naked "new" by using
json::array::append_string.
(supernode::to_json): Likewise.

gcc/ChangeLog:
* diagnostic-format-sarif.cc (sarif_artifact::populate_roles):
Avoid naked "new" by using json::array::append_string.
(sarif_builder::maybe_make_kinds_array): Likewise.
* json.cc (json::array::append_string): New.
(selftest::test_writing_arrays): Use it.
* json.h (json::array::append_string): New decl.
* optinfo-emit-json.cc (optrecord_json_writer::pass_to_json):
Avoid naked "new" by using json::array::append_string.
(optrecord_json_writer::optinfo_to_json): Likewise.

Signed-off-by: David Malcolm 

Diff:
---
 gcc/analyzer/supergraph.cc | 4 ++--
 gcc/diagnostic-format-sarif.cc | 8 
 gcc/json.cc| 9 -
 gcc/json.h | 1 +
 gcc/optinfo-emit-json.cc   | 4 ++--
 5 files changed, 17 insertions(+), 9 deletions(-)

diff --git a/gcc/analyzer/supergraph.cc b/gcc/analyzer/supergraph.cc
index 4dc7942b26aa..20c62856d4b6 100644
--- a/gcc/analyzer/supergraph.cc
+++ b/gcc/analyzer/supergraph.cc
@@ -747,7 +747,7 @@ supernode::to_json () const
pretty_printer pp;
pp_format_decoder (&pp) = default_tree_printer;
pp_gimple_stmt_1 (&pp, stmt, 0, (dump_flags_t)0);
-   phi_arr->append (new json::string (pp_formatted_text (&pp)));
+   phi_arr->append_string (pp_formatted_text (&pp));
   }
 snode_obj->set ("phis", phi_arr);
   }
@@ -762,7 +762,7 @@ supernode::to_json () const
pretty_printer pp;
pp_format_decoder (&pp) = default_tree_printer;
pp_gimple_stmt_1 (&pp, stmt, 0, (dump_flags_t)0);
-   stmt_arr->append (new json::string (pp_formatted_text (&pp)));
+   stmt_arr->append_string (pp_formatted_text (&pp));
   }
 snode_obj->set ("stmts", stmt_arr);
   }
diff --git a/gcc/diagnostic-format-sarif.cc b/gcc/diagnostic-format-sarif.cc
index 225476995d13..7105f7853318 100644
--- a/gcc/diagnostic-format-sarif.cc
+++ b/gcc/diagnostic-format-sarif.cc
@@ -435,7 +435,7 @@ sarif_artifact::populate_roles ()
 if (bitmap_bit_p (m_roles, i))
   {
enum diagnostic_artifact_role role = (enum diagnostic_artifact_role)i;
-   roles_arr->append (new json::string (get_artifact_role_string (role)));
+   roles_arr->append_string (get_artifact_role_string (role));
   }
   set ("roles", roles_arr);
 }
@@ -1394,13 +1394,13 @@ sarif_builder::maybe_make_kinds_array 
(diagnostic_event::meaning m) const
   json::array *kinds_arr = new json::array ();
   if (const char *verb_str
= diagnostic_event::meaning::maybe_get_verb_str (m.m_verb))
-kinds_arr->append (new json::string (verb_str));
+kinds_arr->append_string (verb_str);
   if (const char *noun_str
= diagnostic_event::meaning::maybe_get_noun_str (m.m_noun))
-kinds_arr->append (new json::string (noun_str));
+kinds_arr->append_string (noun_str);
   if (const char *property_str
= diagnostic_event::meaning::maybe_get_property_str (m.m_property))
-kinds_arr->append (new json::string (property_str));
+kinds_arr->append_string (property_str);
   return kinds_arr;
 }
 
diff --git a/gcc/json.cc b/gcc/json.cc
index 53edca520556..86490259dabf 100644
--- a/gcc/json.cc
+++ b/gcc/json.cc
@@ -286,6 +286,13 @@ array::append (value *v)
   m_elements.safe_push (v);
 }
 
+void
+array::append_string (const char *utf8_value)
+{
+  gcc_assert (utf8_value);
+  append (new json::string (utf8_value));
+}
+
 /* class json::float_number, a subclass of json::value, wrapping a double.  */
 
 /* Implementation of json::value::print for json::float_number.  */
@@ -432,7 +439,7 @@ test_writing_arrays ()
   arr.append (new json::string ("foo"));
   ASSERT_PRINT_EQ (arr, true, "[\"foo\"]");
 
-  arr.append (new json::string ("bar"));
+  arr.append_string ("bar");
   ASSERT_PRINT_EQ (arr, true,
   "[\"foo\",\n"
   " \"bar\"]");
diff --git a/gcc/json.h b/gcc/json.h
index ad4f8c448f8c..d3493a72d525 100644
--- a/gcc/json.h
+++ b/gcc/json.h
@@ -130,6 +130,7 @@ class array : public value
   void print (pretty_printer *pp, bool formatted) const final override;
 
   void append (value *v);
+  void append_string (const char *utf8_value);
 
  private:
   auto_vec m_elements;
diff --git a/gcc/optinfo-emit-json.cc b/gcc/optinfo-emit-json.cc
index 1fa82d438db9..faae95fc232a 100644
--- a/gcc/optinfo-emit-json.cc
+++ b/gcc/optinfo-emit-json.cc
@@ -259,7 +259,7 @@ optrecord_json_writer::pass_to_json (opt_pass *pass)
 optgroup->name != 

[gcc/devel/fortran_unsigned] gcov: reduce use of naked "new" for json output

2024-07-28 Thread Thomas Kテカnig via Gcc-cvs
https://gcc.gnu.org/g:d03459c5685287190ca623bdf355f3f80c3fd715

commit d03459c5685287190ca623bdf355f3f80c3fd715
Author: David Malcolm 
Date:   Wed Jul 24 18:07:52 2024 -0400

gcov: reduce use of naked "new" for json output

No functional change intended.

gcc/ChangeLog:
* gcov.cc (output_intermediate_json_line): Use
json::object::set_integer to avoid naked "new".

Signed-off-by: David Malcolm 

Diff:
---
 gcc/gcov.cc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gcc/gcov.cc b/gcc/gcov.cc
index e76a314041cd..85fdac4368e8 100644
--- a/gcc/gcov.cc
+++ b/gcc/gcov.cc
@@ -1285,8 +1285,8 @@ output_intermediate_json_line (json::array *object,
const int covered = info.popcount ();
 
json::object *cond = new json::object ();
-   cond->set ("count", new json::integer_number (count));
-   cond->set ("covered", new json::integer_number (covered));
+   cond->set_integer ("count", count);
+   cond->set_integer ("covered", covered);
 
json::array *mtrue = new json::array ();
json::array *mfalse = new json::array ();


[gcc/devel/fortran_unsigned] diagnostics: SARIF output: add sarif_object subclasses throughout

2024-07-28 Thread Thomas Kテカnig via Gcc-cvs
https://gcc.gnu.org/g:35bb4ff3442ce9116c5f933d431a05b2e8040f22

commit 35bb4ff3442ce9116c5f933d431a05b2e8040f22
Author: David Malcolm 
Date:   Wed Jul 24 18:07:52 2024 -0400

diagnostics: SARIF output: add sarif_object subclasses throughout

No functional change intended.

gcc/ChangeLog:
* diagnostic-format-sarif.cc: Introduce subclasses of sarif_object
for all aspects of the spec that we're using.  Replace almost all
usage of json::object with uses of these subclasses, the only
remaining use of json::object being for originalUriBaseIds, as per
SARIF 2.1.0 §3.14.14.  This stronger typing makes it considerably
easier to maintain validity against the schema.
* diagnostic-format-sarif.h (class sarif_logical_location): New.
(make_sarif_logical_location_object): Convert return type from
json::object * to sarif_logical_location *.

Signed-off-by: David Malcolm 

Diff:
---
 gcc/diagnostic-format-sarif.cc | 605 ++---
 gcc/diagnostic-format-sarif.h  |   9 +-
 2 files changed, 399 insertions(+), 215 deletions(-)

diff --git a/gcc/diagnostic-format-sarif.cc b/gcc/diagnostic-format-sarif.cc
index 7105f7853318..c35d8788d6de 100644
--- a/gcc/diagnostic-format-sarif.cc
+++ b/gcc/diagnostic-format-sarif.cc
@@ -36,18 +36,87 @@ along with GCC; see the file COPYING3.  If not see
 #include "ordered-hash-map.h"
 #include "sbitmap.h"
 
+/* Forward decls.  */
 class sarif_builder;
 
-/* Subclass of json::object for SARIF invocation objects
+/* Subclasses of sarif_object.
+   Keep these in order of their descriptions in the specification.  */
+class sarif_artifact_content; // 3.3
+class sarif_artifact_location; // 3.4
+class sarif_message; // 3.11
+class sarif_multiformat_message_string; // 3.12
+class sarif_log; // 3.13
+class sarif_run; // 3.14
+class sarif_tool; // 3.18
+class sarif_tool_component; // 3.19
+class sarif_invocation; // 3.20
+class sarif_artifact; // 3.24
+class sarif_result; // 3.27
+class sarif_location; // 3.28
+class sarif_physical_location; // 3.29
+class sarif_region; // 3.30
+class sarif_logical_location; // 3.33
+class sarif_code_flow; // 3.36
+class sarif_thread_flow; // 3.37
+class sarif_thread_flow_location; // 3.38
+class sarif_reporting_descriptor; // 3.49
+class sarif_reporting_descriptor_reference; // 3.53
+class sarif_tool_component_reference; // 3.54
+class sarif_fix; // 3.55
+class sarif_artifact_change; // 3.56
+class sarif_replacement; // 3.57
+class sarif_ice_notification; // 3.58
+
+/* Declarations of subclasses of sarif_object.
+   Keep these in order of their descriptions in the specification.  */
+
+/* Subclass of sarif_object for SARIF "artifactContent" objects
+   (SARIF v2.1.0 section 3.3).  */
+
+class sarif_artifact_content : public sarif_object {};
+
+/* Subclass of sarif_object for SARIF "artifactLocation" objects
+   (SARIF v2.1.0 section 3.4).  */
+
+class sarif_artifact_location : public sarif_object {};
+
+/* Subclass of sarif_object for SARIF "message" objects
+   (SARIF v2.1.0 section 3.11).  */
+
+class sarif_message : public sarif_object {};
+
+/* Subclass of sarif_object for SARIF "multiformatMessageString" objects
+   (SARIF v2.1.0 section 3.12).  */
+
+class sarif_multiformat_message_string : public sarif_object {};
+
+/* Subclass of sarif_object for SARIF "log" objects
+   (SARIF v2.1.0 section 3.13).  */
+
+class sarif_log : public sarif_object {};
+
+/* Subclass of sarif_object for SARIF "run" objects
+   (SARIF v2.1.0 section 3.14).  */
+
+class sarif_run : public sarif_object {};
+
+/* Subclass of sarif_object for SARIF "tool" objects
+   (SARIF v2.1.0 section 3.18).  */
+
+class sarif_tool : public sarif_object {};
+
+/* Subclass of sarif_object for SARIF "toolComponent" objects
+   (SARIF v2.1.0 section 3.19).  */
+
+class sarif_tool_component : public sarif_object {};
+
+/* Subclass of sarif_object for SARIF "invocation" objects
(SARIF v2.1.0 section 3.20).  */
 
 class sarif_invocation : public sarif_object
 {
 public:
-  sarif_invocation ()
-  : m_notifications_arr (new json::array ()),
-m_success (true)
-  {}
+  sarif_invocation ();
 
   void add_notification_for_ice (diagnostic_context *context,
 const diagnostic_info &diagnostic,
@@ -104,7 +173,7 @@ private:
   bool m_embed_contents;
 };
 
-/* Subclass of sarif_object for SARIF result objects
+/* Subclass of sarif_object for SARIF "result" objects
(SARIF v2.1.0 section 3.27).  */
 
 class sarif_result : public sarif_object
@@ -122,42 +191,95 @@ public:
   sarif_builder *builder);
 
 private:
-  void add_related_location (json::object *location_obj);
+  void
+  add_related_location (sarif_location *location_obj);
 
   json::array *m_related_locations_arr;
 };
 
-/* Subclass of sarif_object for SARIF notification objects
-   (SARIF v2.1.0 section 3.58).
+/* Subclass of sarif_object 

  1   2   >