[gcc(refs/users/aoliva/heads/testme)] Handle C++ exception hierarchies

2024-12-09 Thread Alexandre Oliva via Gcc-cvs
https://gcc.gnu.org/g:812f6c0f85d86bd2bfb898d75cff7a649134b8fe

commit 812f6c0f85d86bd2bfb898d75cff7a649134b8fe
Author: Alexandre Oliva 
Date:   Thu Dec 5 04:01:13 2024 -0300

Handle C++ exception hierarchies

This patch introduces support for defining exceptions in Ada with
C++'s notion of exception type compatibility, such as handling
occurrences of derived types, and obtaining class-wide access to the
thrown/raised objects.  As a bonus, it adds support for C++ dependent
(wrapped) exceptions, and introduces types and interfaces to match
C++'s std::type_info and std::exception.

for  gcc/ada/ChangeLog

* Makefile.rtl (GNATRTL_NONTASKING_OBJS): Add g-cpp, g-cppstd,
and g-cstyin.
* doc/gnat_rm/interfacing_to_other_languages.rst (Interfacing to 
C++):
Document class-wide matching and new interfaces.
* exp_prag.adb (Expand_Pragma_Import_Or_Interface): Add class-wide
exception matching support with 'B' as language identifier.
* libgnat/a-exexpr.adb (Setup_Current_Excep): Add Id formal.
(Set_Foreign_Occurrence): Likewise.
(Propagate_GCC_Exception): Adjust.
(Set_Exception_Parameter): Likewise.
(Unhandled_Except_Handler): Likewise.
* libgnat/g-cpp.ads: New.
* libgnat/g-cppexc.adb (Raise_Cpp_Exception): Match 'B' lang id.
(Get_Object_Address): New.
(Get_Object): Rewrite.
(Get_Access_To_Object): New.
(Get_Access_To_Tagged_Object): New.
(Get_Type_Info): New.
(Convert_Caught_Object): New.
* libgnat/g-cppexc.ads (Get_Object_Address): New.
(Get_Object): Note the Cpp Convention requirement.
(Get_Access_To_Object): New.
(Get_Access_To_Tagged_Object): New.
(Get_Type_Info): New.
* libgnat/g-cppstd.adb: New.
* libgnat/g-cppstd.ads: New.
* libgnat/g-csclex.ads: New, unused.
* libgnat/g-cstyin.adb: New.
* libgnat/g-cstyin.ads: New.
* libgnat/g-excact.adb (Exception_Language): New.
(Is_Foreign_Exception): Rewrite.
* libgnat/g-excact.ads (Exception_Languages): New.
(Exception_Language): New.
* libgnat/s-stalib.ads (Lang): Document 'B'.
* raise-gcc.c (__gnat_setup_current_excep): Add Exception_Id formal.
(CXX_DEPENDENT_EXCEPTION_CLASS): New.
(cxx_type_info): New.
(__cxa_exception): Rename exceptionType to encompass 
PrimaryException.
(_GNAT_Exception): Drop wrapper.
(EID_For): Adjust.
(exception_class_eq): Likewise.
(__gnat_exception_language_is_cplusplus): New.
(__gnat_exception_language_is_ada): New.
(__gnat_convert_caught_object): Declare.
(__gnat_get_cxx_dependent_exception): New.
(__gnat_maybe_get_cxx_dependent_exception): New.
(__gnat_get_cxx_exception_type_info): New.
(__gnat_obtain_caught_object): New.
(is_handled_by): Adjust.   [!CERT] Add eid formal, handle dependent
exceptions and base-type matches.
(get_action_description_for) [!CERT]: Add eid formal.  Adjust.
(personality_body): Adjust.

Diff:
---
 gcc/ada/Makefile.rtl   |   3 +
 .../doc/gnat_rm/interfacing_to_other_languages.rst | 163 +-
 gcc/ada/exp_prag.adb   |  57 -
 gcc/ada/libgnat/a-exexpr.adb   |  38 +++-
 gcc/ada/libgnat/g-cpp.ads  |  36 +++
 gcc/ada/libgnat/g-cppexc.adb   | 213 --
 gcc/ada/libgnat/g-cppexc.ads   |  48 +++-
 gcc/ada/libgnat/g-cppstd.adb   | 115 ++
 gcc/ada/libgnat/g-cppstd.ads   |  95 
 gcc/ada/libgnat/g-csclex.ads   |  98 
 gcc/ada/libgnat/g-cstyin.adb   | 122 ++
 gcc/ada/libgnat/g-cstyin.ads   | 141 
 gcc/ada/libgnat/g-excact.adb   |  72 +-
 gcc/ada/libgnat/g-excact.ads   |   7 +
 gcc/ada/libgnat/s-stalib.ads   |   3 +-
 gcc/ada/raise-gcc.c| 250 +
 16 files changed, 1376 insertions(+), 85 deletions(-)

diff --git a/gcc/ada/Makefile.rtl b/gcc/ada/Makefile.rtl
index e93a583058c9..a257083e54ed 100644
--- a/gcc/ada/Makefile.rtl
+++ b/gcc/ada/Makefile.rtl
@@ -419,6 +419,9 @@ GNATRTL_NONTASKING_OBJS= \
   g-comlin$(objext) \
   g-comver$(objext) \
   g-crc32$(objext) \
+  g-cpp$(objext) \
+  g-cppstd$(objext) \
+  g-cstyin$(objext) \
   g-ctrl_c$(objext) \
   g-curexc$(objext) \
   g-debpoo$(objext) \
diff --git a/gcc/ada/doc/gnat_rm/interfacing_to_other_languages.rs

[gcc(refs/users/aoliva/heads/testme)] Add units required for exception handling

2024-12-09 Thread Alexandre Oliva via Gcc-cvs
https://gcc.gnu.org/g:d376d811e91578a5b6461fb4521652d9028f94e9

commit d376d811e91578a5b6461fb4521652d9028f94e9
Author: Alexandre Oliva 
Date:   Thu Dec 5 03:25:19 2024 -0300

Add units required for exception handling

Support for C++ exceptions with base-type matching, added to raise-gcc
by calling subprograms in Ada units, requires these units and their
dependencies to be linked into programs that link with raise-gcc.

for  gcc/ada/gcc-interface

* gcc-interface/Make-lang.in (GNAT_ADA_OBJS, GNATBIND_OBJS)
[!STAGE1]: Add new g-cpp, g-cppstd, g-cstyin + preexisting
g-cppexc and i-cstrin.

Diff:
---
 gcc/ada/gcc-interface/Make-lang.in | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/gcc/ada/gcc-interface/Make-lang.in 
b/gcc/ada/gcc-interface/Make-lang.in
index f3009f1d612c..1d8f09709806 100644
--- a/gcc/ada/gcc-interface/Make-lang.in
+++ b/gcc/ada/gcc-interface/Make-lang.in
@@ -513,6 +513,10 @@ GNAT_ADA_OBJS+= \
  ada/libgnat/a-numeri.o\
  ada/libgnat/ada.o \
  ada/libgnat/g-byorma.o\
+ ada/libgnat/g-cpp.o   \
+ ada/libgnat/g-cppexc.o\
+ ada/libgnat/g-cppstd.o\
+ ada/libgnat/g-cstyin.o\
  ada/libgnat/g-heasor.o\
  ada/libgnat/g-htable.o\
  ada/libgnat/g-spchge.o\
@@ -520,6 +524,7 @@ GNAT_ADA_OBJS+= \
  ada/libgnat/g-table.o \
  ada/libgnat/g-u3spch.o\
  ada/libgnat/i-c.o \
+ ada/libgnat/i-cstrin.o\
  ada/libgnat/interfac.o\
  ada/libgnat/s-addope.o\
  ada/libgnat/s-addima.o \
@@ -692,9 +697,14 @@ GNATBIND_OBJS +=  \
  ada/libgnat/a-numeri.o   \
  ada/libgnat/ada.o\
  ada/libgnat/g-byorma.o   \
+ ada/libgnat/g-cpp.o  \
+ ada/libgnat/g-cppexc.o   \
+ ada/libgnat/g-cppstd.o   \
+ ada/libgnat/g-cstyin.o   \
  ada/libgnat/g-hesora.o   \
  ada/libgnat/g-htable.o   \
  ada/libgnat/i-c.o   \
+ ada/libgnat/i-cstrin.o   \
  ada/libgnat/interfac.o   \
  ada/libgnat/s-addope.o   \
  ada/libgnat/s-assert.o   \


[gcc/aoliva/heads/testme] (3 commits) fold fold_truth_andor field merging into ifcombine

2024-12-09 Thread Alexandre Oliva via Gcc-cvs
The branch 'aoliva/heads/testme' was updated to point to:

 c97a26955a04... fold fold_truth_andor field merging into ifcombine

It previously pointed to:

 a1d17cc43d77... ifcombine: simplify and check for build error

Diff:

!!! WARNING: THE FOLLOWING COMMITS ARE NO LONGER ACCESSIBLE (LOST):
---

  a1d17cc... ifcombine: simplify and check for build error
  155cb8f... ifcombine: don't try xor on right-hand op
  6cddc9a... fold fold_truth_andor field merging into ifcombine


Summary of changes (added commits):
---

  c97a269... fold fold_truth_andor field merging into ifcombine
  d376d81... Add units required for exception handling
  812f6c0... Handle C++ exception hierarchies


[gcc(refs/users/mikael/heads/refactor_descriptor_v01)] Correction variable inutilisée

2024-12-09 Thread Mikael Morin via Gcc-cvs
https://gcc.gnu.org/g:59e48f1e7019b4e3a54ac1ea8a21fabfd1e39f0c

commit 59e48f1e7019b4e3a54ac1ea8a21fabfd1e39f0c
Author: Mikael Morin 
Date:   Mon Dec 9 12:00:22 2024 +0100

Correction variable inutilisée

Diff:
---
 gcc/fortran/trans-array.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc
index 67da66268816..6dfccf1cc6ba 100644
--- a/gcc/fortran/trans-array.cc
+++ b/gcc/fortran/trans-array.cc
@@ -614,7 +614,7 @@ get_size_info (gfc_typespec &ts)
 
 
 static tree
-build_dtype (gfc_typespec &ts, int rank, const symbol_attribute &attr)
+build_dtype (gfc_typespec &ts, int rank, const symbol_attribute &)
 {
   vec *v = nullptr;


[gcc(refs/users/aoliva/heads/testme)] fold fold_truth_andor field merging into ifcombine

2024-12-09 Thread Alexandre Oliva via Gcc-cvs
https://gcc.gnu.org/g:c97a26955a043f27b8176c2e66bb0a983b414e90

commit c97a26955a043f27b8176c2e66bb0a983b414e90
Author: Alexandre Oliva 
Date:   Sun Dec 1 08:17:58 2024 -0300

fold fold_truth_andor field merging into ifcombine

This patch introduces various improvements to the logic that merges
field compares, while moving it into ifcombine.

Before the patch, we could merge:

  (a.x1 EQNE b.x1)  ANDOR  (a.y1 EQNE b.y1)

into something like:

  (((type *)&a)[Na] & MASK) EQNE (((type *)&b)[Nb] & MASK)

if both of A's fields live within the same alignment boundaries, and
so do B's, at the same relative positions.  Constants may be used
instead of the object B.

The initial goal of this patch was to enable such combinations when a
field crossed alignment boundaries, e.g. for packed types.  We can't
generally access such fields with a single memory access, so when we
come across such a compare, we will attempt to combine each access
separately.

Some merging opportunities were missed because of right-shifts,
compares expressed as e.g. ((a.x1 ^ b.x1) & MASK) EQNE 0, and
narrowing conversions, especially after earlier merges.  This patch
introduces handlers for several cases involving these.

The merging of multiple field accesses into wider bitfield-like
accesses is undesirable to do too early in compilation, so we move it
from folding to ifcombine, and guard its warnings with
-Wtautological-compare, turned into a common flag.

When the second of a noncontiguous pair of compares is the first that
accesses a word, we may merge the first compare with part of the
second compare that refers to the same word, keeping the compare of
the remaining bits at the spot where the second compare used to be.

Handling compares with non-constant fields was somewhat generalized
from what fold used to do, now handling non-adjacent fields, even if a
field of one object crosses an alignment boundary but the other
doesn't.


for  gcc/ChangeLog

* fold-const.cc (make_bit_field): Export.
(unextend, all_ones_mask_p): Drop.
(decode_field_reference, fold_truth_andor_1): Move
field compare merging logic...
* gimple-fold.cc: (fold_truth_andor_for_ifcombine) ... here,
with -Wtautological-compare warning guards, and...
(decode_field_reference): ... here.  Rework for gimple.
(gimple_convert_def_p, gimple_binop_def_p): New.
(compute_split_boundary_from_align): New.
(make_bit_field_load, build_split_load): New.
(reuse_split_load): New.
* fold-const.h: (make_bit_field_ref): Declare
(fold_truth_andor_for_ifcombine): Declare.
* tree-ssa-ifcombine.cc (ifcombine_ifandif): Try
fold_truth_andor_for_ifcombine.
* common.opt (Wtautological-compare): Move here.

for  gcc/c-family/ChangeLog

* c.opt (Wtautological-compare): Move to ../common.opt.

for  gcc/testsuite/ChangeLog

* gcc.dg/field-merge-1.c: New.
* gcc.dg/field-merge-2.c: New.
* gcc.dg/field-merge-3.c: New.
* gcc.dg/field-merge-4.c: New.
* gcc.dg/field-merge-5.c: New.
* gcc.dg/field-merge-6.c: New.
* gcc.dg/field-merge-7.c: New.
* gcc.dg/field-merge-8.c: New.
* gcc.dg/field-merge-9.c: New.
* gcc.dg/field-merge-10.c: New.
* gcc.dg/field-merge-11.c: New.
* gcc.dg/field-merge-12.c: New.
* gcc.target/aarch64/long_branch_1.c: Disable ifcombine.

Diff:
---
 gcc/c-family/c.opt   |4 -
 gcc/common.opt   |4 +
 gcc/fold-const.cc|  512 +-
 gcc/fold-const.h |   10 +
 gcc/gimple-fold.cc   | 1148 ++
 gcc/testsuite/gcc.dg/field-merge-1.c |   64 ++
 gcc/testsuite/gcc.dg/field-merge-10.c|   36 +
 gcc/testsuite/gcc.dg/field-merge-11.c|   32 +
 gcc/testsuite/gcc.dg/field-merge-12.c|   33 +
 gcc/testsuite/gcc.dg/field-merge-2.c |   31 +
 gcc/testsuite/gcc.dg/field-merge-3.c |   36 +
 gcc/testsuite/gcc.dg/field-merge-4.c |   40 +
 gcc/testsuite/gcc.dg/field-merge-5.c |   40 +
 gcc/testsuite/gcc.dg/field-merge-6.c |   26 +
 gcc/testsuite/gcc.dg/field-merge-7.c |   23 +
 gcc/testsuite/gcc.dg/field-merge-8.c |   25 +
 gcc/testsuite/gcc.dg/field-merge-9.c |   38 +
 gcc/testsuite/gcc.target/aarch64/long_branch_1.c |2 +-
 gcc/tree-ssa-ifcombine.cc|   14 +-
 19 files changed, 1604 insertions(+), 514 deletions(-)

[gcc(refs/users/aoliva/heads/testme)] fold fold_truth_andor field merging into ifcombine

2024-12-09 Thread Alexandre Oliva via Gcc-cvs
https://gcc.gnu.org/g:643e4363b9cabdbc827eec2a0cbf387eaa23a297

commit 643e4363b9cabdbc827eec2a0cbf387eaa23a297
Author: Alexandre Oliva 
Date:   Sun Dec 1 08:17:58 2024 -0300

fold fold_truth_andor field merging into ifcombine

This patch introduces various improvements to the logic that merges
field compares, while moving it into ifcombine.

Before the patch, we could merge:

  (a.x1 EQNE b.x1)  ANDOR  (a.y1 EQNE b.y1)

into something like:

  (((type *)&a)[Na] & MASK) EQNE (((type *)&b)[Nb] & MASK)

if both of A's fields live within the same alignment boundaries, and
so do B's, at the same relative positions.  Constants may be used
instead of the object B.

The initial goal of this patch was to enable such combinations when a
field crossed alignment boundaries, e.g. for packed types.  We can't
generally access such fields with a single memory access, so when we
come across such a compare, we will attempt to combine each access
separately.

Some merging opportunities were missed because of right-shifts,
compares expressed as e.g. ((a.x1 ^ b.x1) & MASK) EQNE 0, and
narrowing conversions, especially after earlier merges.  This patch
introduces handlers for several cases involving these.

The merging of multiple field accesses into wider bitfield-like
accesses is undesirable to do too early in compilation, so we move it
from folding to ifcombine, and guard its warnings with
-Wtautological-compare, turned into a common flag.

When the second of a noncontiguous pair of compares is the first that
accesses a word, we may merge the first compare with part of the
second compare that refers to the same word, keeping the compare of
the remaining bits at the spot where the second compare used to be.

Handling compares with non-constant fields was somewhat generalized
from what fold used to do, now handling non-adjacent fields, even if a
field of one object crosses an alignment boundary but the other
doesn't.


for  gcc/ChangeLog

* fold-const.cc (make_bit_field): Export.
(unextend, all_ones_mask_p): Drop.
(decode_field_reference, fold_truth_andor_1): Move
field compare merging logic...
* gimple-fold.cc: (fold_truth_andor_for_ifcombine) ... here,
with -Wtautological-compare warning guards, and...
(decode_field_reference): ... here.  Rework for gimple.
(gimple_convert_def_p, gimple_binop_def_p): New.
(compute_split_boundary_from_align): New.
(make_bit_field_load, build_split_load): New.
(reuse_split_load): New.
* fold-const.h: (make_bit_field_ref): Declare
(fold_truth_andor_for_ifcombine): Declare.
* tree-ssa-ifcombine.cc (ifcombine_ifandif): Try
fold_truth_andor_for_ifcombine.
* common.opt (Wtautological-compare): Move here.

for  gcc/c-family/ChangeLog

* c.opt (Wtautological-compare): Move to ../common.opt.

for  gcc/testsuite/ChangeLog

* gcc.dg/field-merge-1.c: New.
* gcc.dg/field-merge-2.c: New.
* gcc.dg/field-merge-3.c: New.
* gcc.dg/field-merge-4.c: New.
* gcc.dg/field-merge-5.c: New.
* gcc.dg/field-merge-6.c: New.
* gcc.dg/field-merge-7.c: New.
* gcc.dg/field-merge-8.c: New.
* gcc.dg/field-merge-9.c: New.
* gcc.dg/field-merge-10.c: New.
* gcc.dg/field-merge-11.c: New.
* gcc.dg/field-merge-12.c: New.
* gcc.target/aarch64/long_branch_1.c: Disable ifcombine.

Diff:
---
 gcc/c-family/c.opt   |4 -
 gcc/common.opt   |4 +
 gcc/fold-const.cc|  512 +-
 gcc/fold-const.h |   10 +
 gcc/gimple-fold.cc   | 1148 ++
 gcc/testsuite/gcc.dg/field-merge-1.c |   64 ++
 gcc/testsuite/gcc.dg/field-merge-10.c|   36 +
 gcc/testsuite/gcc.dg/field-merge-11.c|   32 +
 gcc/testsuite/gcc.dg/field-merge-12.c|   33 +
 gcc/testsuite/gcc.dg/field-merge-2.c |   31 +
 gcc/testsuite/gcc.dg/field-merge-3.c |   36 +
 gcc/testsuite/gcc.dg/field-merge-4.c |   40 +
 gcc/testsuite/gcc.dg/field-merge-5.c |   40 +
 gcc/testsuite/gcc.dg/field-merge-6.c |   26 +
 gcc/testsuite/gcc.dg/field-merge-7.c |   23 +
 gcc/testsuite/gcc.dg/field-merge-8.c |   25 +
 gcc/testsuite/gcc.dg/field-merge-9.c |   38 +
 gcc/testsuite/gcc.target/aarch64/long_branch_1.c |2 +-
 gcc/tree-ssa-ifcombine.cc|   14 +-
 19 files changed, 1604 insertions(+), 514 deletions(-)

[gcc/aoliva/heads/testme] fold fold_truth_andor field merging into ifcombine

2024-12-09 Thread Alexandre Oliva via Gcc-cvs
The branch 'aoliva/heads/testme' was updated to point to:

 643e4363b9ca... fold fold_truth_andor field merging into ifcombine

It previously pointed to:

 c97a26955a04... fold fold_truth_andor field merging into ifcombine

Diff:

!!! WARNING: THE FOLLOWING COMMITS ARE NO LONGER ACCESSIBLE (LOST):
---

  c97a269... fold fold_truth_andor field merging into ifcombine


Summary of changes (added commits):
---

  643e436... fold fold_truth_andor field merging into ifcombine


[gcc r15-6039] replace atoi with stroul in c_parser_gimple_parse_bb_spec [PR114541]

2024-12-09 Thread Richard Biener via Gcc-cvs
https://gcc.gnu.org/g:2b8ecbfe2ce6558637d42fdcb7efb3f878feb56b

commit r15-6039-g2b8ecbfe2ce6558637d42fdcb7efb3f878feb56b
Author: Heiko Eißfeldt 
Date:   Mon Dec 9 10:39:50 2024 +0100

replace atoi with stroul in c_parser_gimple_parse_bb_spec [PR114541]

The full treatment of these invalid values was considered out of
scope for this patch.

PR c/114541
* gimple-parser.cc (c_parser_gimple_parse_bb_spec):
Use strtoul with ERANGE check instead of atoi to avoid UB
and detect invalid __BB#.

Signed-off-by: Heiko Eißfeldt 

Diff:
---
 gcc/c/gimple-parser.cc | 20 +++-
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/gcc/c/gimple-parser.cc b/gcc/c/gimple-parser.cc
index 78e85d934879..1a677fc26c78 100644
--- a/gcc/c/gimple-parser.cc
+++ b/gcc/c/gimple-parser.cc
@@ -133,11 +133,21 @@ c_parser_gimple_parse_bb_spec (tree val, int *index)
 {
   if (!startswith (IDENTIFIER_POINTER (val), "__BB"))
 return false;
-  for (const char *p = IDENTIFIER_POINTER (val) + 4; *p; ++p)
-if (!ISDIGIT (*p))
-  return false;
-  *index = atoi (IDENTIFIER_POINTER (val) + 4);
-  return *index > 0;
+
+  const char *bb = IDENTIFIER_POINTER (val) + 4;
+  if (! ISDIGIT (*bb))
+return false;
+
+  char *pend;
+  errno = 0;
+  const unsigned long number = strtoul (bb, &pend, 10);
+  if (errno == ERANGE
+  || *pend != '\0'
+  || number > INT_MAX)
+return false;
+
+  *index = number;
+  return true;
 }
 
 /* See if VAL is an identifier matching __BB and return 


[gcc r15-6040] docs: Clarify -fsanitize=hwaddress target support [PR117960]

2024-12-09 Thread Jakub Jelinek via Gcc-cvs
https://gcc.gnu.org/g:2e958291ff68d9bff1092895a14b6763de56823b

commit r15-6040-g2e958291ff68d9bff1092895a14b6763de56823b
Author: Jakub Jelinek 
Date:   Mon Dec 9 14:17:39 2024 +0100

docs: Clarify -fsanitize=hwaddress target support [PR117960]

Since GCC 13 -fsanitize=hwaddress is not supported just on AArch64, but also
on x86_64 (but only with -mlam=u48 or -mlam=u57).

2024-12-09  Jakub Jelinek  

PR sanitizer/117960
* doc/invoke.texi (fsanitize=hwaddress): Clarify on which targets
it is supported.

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

diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index daab28908684..14afd1934bd2 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -17768,8 +17768,10 @@ the available options are shown at startup of the 
instrumented program.  See
 
@url{https://github.com/google/sanitizers/wiki/AddressSanitizerFlags#run-time-flags}
 for a list of supported options.
 The option cannot be combined with @option{-fsanitize=thread} or
-@option{-fsanitize=hwaddress}.  Note that the only target
-@option{-fsanitize=hwaddress} is currently supported on is AArch64.
+@option{-fsanitize=hwaddress}.  Note that the only targets
+@option{-fsanitize=hwaddress} is currently supported on are x86-64
+(only with @code{-mlam=u48} or @code{-mlam=u57} options) and AArch64,
+in both cases only in ABIs with 64-bit pointers.
 
 To get more accurate stack traces, it is possible to use options such as
 @option{-O0}, @option{-O1}, or @option{-Og} (which, for instance, prevent


[gcc r15-6023] aarch64: Update cpuinfo strings for some arch features

2024-12-09 Thread Kyrylo Tkachov via Gcc-cvs
https://gcc.gnu.org/g:0b79d8b98ec086fccd4714c1ff66ff4382780183

commit r15-6023-g0b79d8b98ec086fccd4714c1ff66ff4382780183
Author: Kyrylo Tkachov 
Date:   Tue Dec 3 04:12:09 2024 -0800

aarch64: Update cpuinfo strings for some arch features

The entries for some recently-added arch features were missing the cpuinfo
string used in -march=native detection.  Presumably the Linux kernel had not
specified such a string at the time the GCC support was added.
But I see that current versions of Linux do have strings for these features
in the arch/arm64/kernel/cpuinfo.c file in the kernel tree.

This patch adds them.  This fixes the strings for the f32mm and f64mm 
features
which I think were using the wrong string.  The kernel exposes them with an
"sve" prefix.

Bootstrapped and tested on aarch64-none-linux-gnu.

Signed-off-by: Kyrylo Tkachov 

gcc/

* config/aarch64/aarch64-option-extensions.def (sve-b16b16,
f32mm, f64mm, sve2p1, sme-f64f64, sme-i16i64, sme-b16b16,
sme-f16f16, mops): Update FEATURE_STRING field.

Diff:
---
 gcc/config/aarch64/aarch64-option-extensions.def | 18 +-
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/gcc/config/aarch64/aarch64-option-extensions.def 
b/gcc/config/aarch64/aarch64-option-extensions.def
index 52c3e7b57668..eb0459d2962d 100644
--- a/gcc/config/aarch64/aarch64-option-extensions.def
+++ b/gcc/config/aarch64/aarch64-option-extensions.def
@@ -166,13 +166,13 @@ AARCH64_FMV_FEATURE("rpres", RPRES, ())
 AARCH64_OPT_FMV_EXTENSION("sve", SVE, (SIMD, F16), (), (), "sve")
 
 /* This specifically does not imply +sve.  */
-AARCH64_OPT_EXTENSION("sve-b16b16", SVE_B16B16, (), (), (), "")
+AARCH64_OPT_EXTENSION("sve-b16b16", SVE_B16B16, (), (), (), "sveb16b16")
 
-AARCH64_OPT_EXTENSION("f32mm", F32MM, (SVE), (), (), "f32mm")
+AARCH64_OPT_EXTENSION("f32mm", F32MM, (SVE), (), (), "svef32mm")
 
 AARCH64_FMV_FEATURE("f32mm", SVE_F32MM, (F32MM))
 
-AARCH64_OPT_EXTENSION("f64mm", F64MM, (SVE), (), (), "f64mm")
+AARCH64_OPT_EXTENSION("f64mm", F64MM, (SVE), (), (), "svef64mm")
 
 AARCH64_FMV_FEATURE("f64mm", SVE_F64MM, (F64MM))
 
@@ -195,7 +195,7 @@ AARCH64_OPT_EXTENSION("sve2-sm4", SVE2_SM4, (SVE2, SM4), 
(), (), "svesm4")
 
 AARCH64_FMV_FEATURE("sve2-sm4", SVE_SM4, (SVE2_SM4))
 
-AARCH64_OPT_EXTENSION("sve2p1", SVE2p1, (SVE2), (), (), "")
+AARCH64_OPT_EXTENSION("sve2p1", SVE2p1, (SVE2), (), (), "sve2p1")
 
 AARCH64_OPT_FMV_EXTENSION("sme", SME, (BF16, SVE2), (), (), "sme")
 
@@ -215,11 +215,11 @@ AARCH64_OPT_EXTENSION("pauth", PAUTH, (), (), (), "paca 
pacg")
 
 AARCH64_OPT_EXTENSION("ls64", LS64, (), (), (), "")
 
-AARCH64_OPT_EXTENSION("sme-f64f64", SME_F64F64, (SME), (), (), "")
+AARCH64_OPT_EXTENSION("sme-f64f64", SME_F64F64, (SME), (), (), "smef64f64")
 
 AARCH64_FMV_FEATURE("sme-f64f64", SME_F64, (SME_F64F64))
 
-AARCH64_OPT_EXTENSION("sme-i16i64", SME_I16I64, (SME), (), (), "")
+AARCH64_OPT_EXTENSION("sme-i16i64", SME_I16I64, (SME), (), (), "smei16i64")
 
 AARCH64_FMV_FEATURE("sme-i16i64", SME_I64, (SME_I16I64))
 
@@ -227,11 +227,11 @@ AARCH64_OPT_FMV_EXTENSION("sme2", SME2, (SME), (), (), 
"sme2")
 
 AARCH64_OPT_EXTENSION("sme2p1", SME2p1, (SME2), (), (), "sme2p1")
 
-AARCH64_OPT_EXTENSION("sme-b16b16", SME_B16B16, (SME2, SVE_B16B16), (), (), "")
+AARCH64_OPT_EXTENSION("sme-b16b16", SME_B16B16, (SME2, SVE_B16B16), (), (), 
"smeb16b16")
 
-AARCH64_OPT_EXTENSION("sme-f16f16", SME_F16F16, (SME2), (), (), "")
+AARCH64_OPT_EXTENSION("sme-f16f16", SME_F16F16, (SME2), (), (), "smef16f16")
 
-AARCH64_OPT_EXTENSION("mops", MOPS, (), (), (), "")
+AARCH64_OPT_EXTENSION("mops", MOPS, (), (), (), "mops")
 
 AARCH64_OPT_EXTENSION("cssc", CSSC, (), (), (), "cssc")


[gcc r15-6024] libstdc++: Add missing equality comparison in new tests [PR117921]

2024-12-09 Thread Jonathan Wakely via Gcc-cvs
https://gcc.gnu.org/g:5cdd78b39725fb1d82cb6bd68e8f56bf4f5d51cd

commit r15-6024-g5cdd78b39725fb1d82cb6bd68e8f56bf4f5d51cd
Author: Jonathan Wakely 
Date:   Mon Dec 9 09:36:15 2024 +

libstdc++: Add missing equality comparison in new tests [PR117921]

These new tests fail in Debug Mode because the allocator types aren't
equality comparable.

libstdc++-v3/ChangeLog:

PR libstdc++/117921
* testsuite/23_containers/set/modifiers/swap/adl.cc: Add
equality comparison for Allocator.
* testsuite/23_containers/unordered_set/modifiers/swap-2.cc:
Likewise.

Diff:
---
 libstdc++-v3/testsuite/23_containers/set/modifiers/swap/adl.cc | 1 +
 libstdc++-v3/testsuite/23_containers/unordered_set/modifiers/swap-2.cc | 1 +
 2 files changed, 2 insertions(+)

diff --git a/libstdc++-v3/testsuite/23_containers/set/modifiers/swap/adl.cc 
b/libstdc++-v3/testsuite/23_containers/set/modifiers/swap/adl.cc
index 2b7975a366fc..e2a1742c953a 100644
--- a/libstdc++-v3/testsuite/23_containers/set/modifiers/swap/adl.cc
+++ b/libstdc++-v3/testsuite/23_containers/set/modifiers/swap/adl.cc
@@ -36,6 +36,7 @@ namespace adl
   using propagate_on_container_swap = std::true_type;
 
   friend void swap(Allocator&, Allocator&) { swapped = true; }
+  friend bool operator==(Allocator, Allocator) { return true; }
 };
 }
 
diff --git 
a/libstdc++-v3/testsuite/23_containers/unordered_set/modifiers/swap-2.cc 
b/libstdc++-v3/testsuite/23_containers/unordered_set/modifiers/swap-2.cc
index a0fb1a6f662f..9d8b2200e24c 100644
--- a/libstdc++-v3/testsuite/23_containers/unordered_set/modifiers/swap-2.cc
+++ b/libstdc++-v3/testsuite/23_containers/unordered_set/modifiers/swap-2.cc
@@ -43,6 +43,7 @@ namespace adl
   using propagate_on_container_swap = std::true_type;
 
   friend void swap(Allocator&, Allocator&) { swapped = true; }
+  friend bool operator==(Allocator, Allocator) { return true; }
 };
 }


[gcc r15-6031] middle-end/117932 - further speedup DF worklist solver

2024-12-09 Thread Richard Biener via Gcc-cvs
https://gcc.gnu.org/g:6b390f8253b7f6575f18e356610aeb5d83e1140f

commit r15-6031-g6b390f8253b7f6575f18e356610aeb5d83e1140f
Author: Richard Biener 
Date:   Sat Dec 7 14:43:00 2024 +0100

middle-end/117932 - further speedup DF worklist solver

The triple-indirect memory reference we perform for each incoming
edge age <= last_change_age[bbindex_to_postorder[e->src->index]]
is pretty bad and when there are a lot of small BBs like for the
PR26854 testcase this shows in the profile.  The following reduces
this by one level by making last_change_age indexed by BB index
rather than postorder number and realizing that for the first
iteration the age check is always true.  We pay for this by
allocating last_change_age for all BBs in the function but we
do it like for sparsesets and avoid initializing given we check
the considerd bitmap anyway.  We can also elide initializing
last_visit_age in an obvious way given we separated the initial
iteration in the previous change.

Together this improves compile-time in the PR117932 setting by
another 2%.

PR middle-end/117932
* df-core.cc (df_worklist_propagate_forward): Elide
age check for the first iteration, adjust for
last_change_age change.
(df_worklist_propagate_backward): Likewise.
(df_worklist_dataflow_doublequeue): Make last_change_age
indexed by BB index, avoid clearing both age arrays.

Diff:
---
 gcc/df-core.cc | 31 ---
 1 file changed, 16 insertions(+), 15 deletions(-)

diff --git a/gcc/df-core.cc b/gcc/df-core.cc
index 99fe466d053c..3b5076e2fa61 100644
--- a/gcc/df-core.cc
+++ b/gcc/df-core.cc
@@ -905,8 +905,7 @@ df_worklist_propagate_forward (struct dataflow *dataflow,
   if (EDGE_COUNT (bb->preds) > 0)
 FOR_EACH_EDGE (e, ei, bb->preds)
   {
-   if (bbindex_to_postorder[e->src->index] < last_change_age.length ()
-   && age <= last_change_age[bbindex_to_postorder[e->src->index]]
+   if ((!age || age <= last_change_age[e->src->index])
&& bitmap_bit_p (considered, e->src->index))
   changed |= dataflow->problem->con_fun_n (e);
   }
@@ -962,8 +961,7 @@ df_worklist_propagate_backward (struct dataflow *dataflow,
   if (EDGE_COUNT (bb->succs) > 0)
 FOR_EACH_EDGE (e, ei, bb->succs)
   {
-   if (bbindex_to_postorder[e->dest->index] < last_change_age.length ()
-   && age <= last_change_age[bbindex_to_postorder[e->dest->index]]
+   if ((!age || age <= last_change_age[e->dest->index])
&& bitmap_bit_p (considered, e->dest->index))
   changed |= dataflow->problem->con_fun_n (e);
   }
@@ -1028,13 +1026,17 @@ df_worklist_dataflow_doublequeue (struct dataflow 
*dataflow,
   bool changed;
   vec last_visit_age = vNULL;
   vec last_change_age = vNULL;
-  int prev_age;
 
   bitmap worklist = BITMAP_ALLOC (&df_bitmap_obstack);
   bitmap_tree_view (worklist);
 
-  last_visit_age.safe_grow_cleared (n_blocks, true);
-  last_change_age.safe_grow_cleared (n_blocks, true);
+  last_visit_age.safe_grow (n_blocks, true);
+  last_change_age.safe_grow (last_basic_block_for_fn (cfun) + 1, true);
+  /* Make last_change_age defined - we can access uninit values for not
+ considered blocks but will make sure they are considered as well.  */
+  VALGRIND_DISCARD (VALGRIND_MAKE_MEM_DEFINED
+ (last_change_age.address (),
+  sizeof (int) * last_basic_block_for_fn (cfun)));
 
   /* We start with processing all blocks, populating pending for the
  next iteration.  */
@@ -1044,24 +1046,23 @@ df_worklist_dataflow_doublequeue (struct dataflow 
*dataflow,
 {
   unsigned bb_index = blocks_in_postorder[index];
   dcount++;
-  prev_age = last_visit_age[index];
   if (dir == DF_FORWARD)
changed = df_worklist_propagate_forward (dataflow, bb_index,
 bbindex_to_postorder,
 NULL, pending,
 considered,
-last_change_age,
-prev_age);
+last_change_age, 0);
   else
changed = df_worklist_propagate_backward (dataflow, bb_index,
  bbindex_to_postorder,
  NULL, pending,
  considered,
- last_change_age,
- prev_age);
+ last_change_age, 0);
   last_visit_age[index] = ++age;
   if (changed)
-   last_change_age[index] = age;
+   last_change_age[bb_index] = age;
+  else
+   last_c

[gcc r15-6032] RISC-V: Refine unsigned SAT_ADD testcase dump check to tree optimized

2024-12-09 Thread Pan Li via Gcc-cvs
https://gcc.gnu.org/g:0404fd56aeae56ba9bbe50d3fe8e2911d4079f7b

commit r15-6032-g0404fd56aeae56ba9bbe50d3fe8e2911d4079f7b
Author: Pan Li 
Date:   Sun Dec 8 09:32:25 2024 +0800

RISC-V: Refine unsigned SAT_ADD testcase dump check to tree optimized

The sat alu related testcase check the rtl dump for the standard name
like .SAT_ADD exist or not.  But the rtl pass expand is somehow
impressionable by the middle-end change or debug information.  Like
below new appearance recently.

Replacing Expressions
_5 replace with --> _5 = .SAT_ADD (x_3(D), y_4(D)); [tail call]

After that we need to adjust the dump check time and again.  This
patch would like to switch to tree optimized pass for the standard
name check, which is more stable up to a point.

The below test suites are passed for this patch.
* The rv64gcv fully regression test.

It is test only patch and obvious up to a point, will commit it
directly if no comments in next 48H.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/sat/sat_u_add-1-u16.c: Take tree-optimized
pass for standard name check, and adjust the times.
* gcc.target/riscv/sat/sat_u_add-1-u32.c: Ditto.
* gcc.target/riscv/sat/sat_u_add-1-u64.c: Ditto.
* gcc.target/riscv/sat/sat_u_add-1-u8.c: Ditto.
* gcc.target/riscv/sat/sat_u_add-2-u16.c: Ditto.
* gcc.target/riscv/sat/sat_u_add-2-u32.c: Ditto.
* gcc.target/riscv/sat/sat_u_add-2-u64.c: Ditto.
* gcc.target/riscv/sat/sat_u_add-2-u8.c: Ditto.
* gcc.target/riscv/sat/sat_u_add-3-u16.c: Ditto.
* gcc.target/riscv/sat/sat_u_add-3-u32.c: Ditto.
* gcc.target/riscv/sat/sat_u_add-3-u64.c: Ditto.
* gcc.target/riscv/sat/sat_u_add-3-u8.c: Ditto.
* gcc.target/riscv/sat/sat_u_add-4-u16.c: Ditto.
* gcc.target/riscv/sat/sat_u_add-4-u32.c: Ditto.
* gcc.target/riscv/sat/sat_u_add-4-u64.c: Ditto.
* gcc.target/riscv/sat/sat_u_add-4-u8.c: Ditto.
* gcc.target/riscv/sat/sat_u_add-5-u16.c: Ditto.
* gcc.target/riscv/sat/sat_u_add-5-u32.c: Ditto.
* gcc.target/riscv/sat/sat_u_add-5-u64.c: Ditto.
* gcc.target/riscv/sat/sat_u_add-5-u8.c: Ditto.
* gcc.target/riscv/sat/sat_u_add-6-u16.c: Ditto.
* gcc.target/riscv/sat/sat_u_add-6-u32.c: Ditto.
* gcc.target/riscv/sat/sat_u_add-6-u64.c: Ditto.
* gcc.target/riscv/sat/sat_u_add-6-u8.c: Ditto.
* gcc.target/riscv/sat/sat_u_add_imm-1-u16.c: Ditto.
* gcc.target/riscv/sat/sat_u_add_imm-1-u32.c: Ditto.
* gcc.target/riscv/sat/sat_u_add_imm-1-u64.c: Ditto.
* gcc.target/riscv/sat/sat_u_add_imm-1-u8.c: Ditto.
* gcc.target/riscv/sat/sat_u_add_imm-2-u16.c: Ditto.
* gcc.target/riscv/sat/sat_u_add_imm-2-u32.c: Ditto.
* gcc.target/riscv/sat/sat_u_add_imm-2-u64.c: Ditto.
* gcc.target/riscv/sat/sat_u_add_imm-2-u8.c: Ditto.
* gcc.target/riscv/sat/sat_u_add_imm-3-u16.c: Ditto.
* gcc.target/riscv/sat/sat_u_add_imm-3-u32.c: Ditto.
* gcc.target/riscv/sat/sat_u_add_imm-3-u64.c: Ditto.
* gcc.target/riscv/sat/sat_u_add_imm-3-u8.c: Ditto.
* gcc.target/riscv/sat/sat_u_add_imm-4-u16.c: Ditto.
* gcc.target/riscv/sat/sat_u_add_imm-4-u32.c: Ditto.
* gcc.target/riscv/sat/sat_u_add_imm-4-u64.c: Ditto.
* gcc.target/riscv/sat/sat_u_add_imm-4-u8.c: Ditto.
* gcc.target/riscv/sat/sat_u_add_imm_type_check-1.c: Ditto.
* gcc.target/riscv/sat/sat_u_add_imm_type_check-10.c: Ditto.
* gcc.target/riscv/sat/sat_u_add_imm_type_check-11.c: Ditto.
* gcc.target/riscv/sat/sat_u_add_imm_type_check-12.c: Ditto.
* gcc.target/riscv/sat/sat_u_add_imm_type_check-13.c: Ditto.
* gcc.target/riscv/sat/sat_u_add_imm_type_check-14.c: Ditto.
* gcc.target/riscv/sat/sat_u_add_imm_type_check-15.c: Ditto.
* gcc.target/riscv/sat/sat_u_add_imm_type_check-16.c: Ditto.
* gcc.target/riscv/sat/sat_u_add_imm_type_check-17.c: Ditto.
* gcc.target/riscv/sat/sat_u_add_imm_type_check-18.c: Ditto.
* gcc.target/riscv/sat/sat_u_add_imm_type_check-19.c: Ditto.
* gcc.target/riscv/sat/sat_u_add_imm_type_check-2.c: Ditto.
* gcc.target/riscv/sat/sat_u_add_imm_type_check-20.c: Ditto.
* gcc.target/riscv/sat/sat_u_add_imm_type_check-21.c: Ditto.
* gcc.target/riscv/sat/sat_u_add_imm_type_check-22.c: Ditto.
* gcc.target/riscv/sat/sat_u_add_imm_type_check-23.c: Ditto.
* gcc.target/riscv/sat/sat_u_add_imm_type_check-24.c: Ditto.
* gcc.target/riscv/sat/sat_u_add_imm_type_check-25.c: Ditto.
* gcc.target/riscv/sat/sat_u_add_imm_type_check-26

[gcc r15-6035] RISC-V: Refine signed SAT_ADD testcase dump check to tree optimized

2024-12-09 Thread Pan Li via Gcc-cvs
https://gcc.gnu.org/g:e3c378aabb4120cd78f9a2b4cfddca2a1f71b7f5

commit r15-6035-ge3c378aabb4120cd78f9a2b4cfddca2a1f71b7f5
Author: Pan Li 
Date:   Sun Dec 8 09:32:28 2024 +0800

RISC-V: Refine signed SAT_ADD testcase dump check to tree optimized

The sat alu related testcase check the rtl dump for the standard name
like .SAT_ADD exist or not.  But the rtl pass expand is somehow
impressionable by the middle-end change or debug information.  Like
below new appearance recently.

Replacing Expressions
_5 replace with --> _5 = .SAT_ADD (x_3(D), y_4(D)); [tail call]

After that we need to adjust the dump check time and again.  This
patch would like to switch to tree optimized pass for the standard
name check, which is more stable up to a point.

The below test suites are passed for this patch.
* The rv64gcv fully regression test.

It is test only patch and obvious up to a point, will commit it
directly if no comments in next 48H.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/sat/sat_s_add-1-i16.c: Take tree-optimized
pass for standard name check, and adjust the times.
* gcc.target/riscv/sat/sat_s_add-1-i32.c: Ditto.
* gcc.target/riscv/sat/sat_s_add-1-i64.c: Ditto.
* gcc.target/riscv/sat/sat_s_add-1-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_add-2-i16.c: Ditto.
* gcc.target/riscv/sat/sat_s_add-2-i32.c: Ditto.
* gcc.target/riscv/sat/sat_s_add-2-i64.c: Ditto.
* gcc.target/riscv/sat/sat_s_add-2-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_add-3-i16.c: Ditto.
* gcc.target/riscv/sat/sat_s_add-3-i32.c: Ditto.
* gcc.target/riscv/sat/sat_s_add-3-i64.c: Ditto.
* gcc.target/riscv/sat/sat_s_add-3-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_add-4-i16.c: Ditto.
* gcc.target/riscv/sat/sat_s_add-4-i32.c: Ditto.
* gcc.target/riscv/sat/sat_s_add-4-i64.c: Ditto.
* gcc.target/riscv/sat/sat_s_add-4-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_add_imm-1-1.c: Ditto.
* gcc.target/riscv/sat/sat_s_add_imm-1.c: Ditto.
* gcc.target/riscv/sat/sat_s_add_imm-2-1.c: Ditto.
* gcc.target/riscv/sat/sat_s_add_imm-2.c: Ditto.
* gcc.target/riscv/sat/sat_s_add_imm-3-1.c: Ditto.
* gcc.target/riscv/sat/sat_s_add_imm-3.c: Ditto.
* gcc.target/riscv/sat/sat_s_add_imm-4.c: Ditto.

Signed-off-by: Pan Li 

Diff:
---
 gcc/testsuite/gcc.target/riscv/sat/sat_s_add-1-i16.c   | 4 ++--
 gcc/testsuite/gcc.target/riscv/sat/sat_s_add-1-i32.c   | 4 ++--
 gcc/testsuite/gcc.target/riscv/sat/sat_s_add-1-i64.c   | 4 ++--
 gcc/testsuite/gcc.target/riscv/sat/sat_s_add-1-i8.c| 4 ++--
 gcc/testsuite/gcc.target/riscv/sat/sat_s_add-2-i16.c   | 4 ++--
 gcc/testsuite/gcc.target/riscv/sat/sat_s_add-2-i32.c   | 4 ++--
 gcc/testsuite/gcc.target/riscv/sat/sat_s_add-2-i64.c   | 4 ++--
 gcc/testsuite/gcc.target/riscv/sat/sat_s_add-2-i8.c| 4 ++--
 gcc/testsuite/gcc.target/riscv/sat/sat_s_add-3-i16.c   | 4 ++--
 gcc/testsuite/gcc.target/riscv/sat/sat_s_add-3-i32.c   | 4 ++--
 gcc/testsuite/gcc.target/riscv/sat/sat_s_add-3-i64.c   | 4 ++--
 gcc/testsuite/gcc.target/riscv/sat/sat_s_add-3-i8.c| 4 ++--
 gcc/testsuite/gcc.target/riscv/sat/sat_s_add-4-i16.c   | 4 ++--
 gcc/testsuite/gcc.target/riscv/sat/sat_s_add-4-i32.c   | 4 ++--
 gcc/testsuite/gcc.target/riscv/sat/sat_s_add-4-i64.c   | 4 ++--
 gcc/testsuite/gcc.target/riscv/sat/sat_s_add-4-i8.c| 4 ++--
 gcc/testsuite/gcc.target/riscv/sat/sat_s_add_imm-1-1.c | 4 ++--
 gcc/testsuite/gcc.target/riscv/sat/sat_s_add_imm-1.c   | 4 ++--
 gcc/testsuite/gcc.target/riscv/sat/sat_s_add_imm-2-1.c | 4 ++--
 gcc/testsuite/gcc.target/riscv/sat/sat_s_add_imm-2.c   | 4 ++--
 gcc/testsuite/gcc.target/riscv/sat/sat_s_add_imm-3-1.c | 4 ++--
 gcc/testsuite/gcc.target/riscv/sat/sat_s_add_imm-3.c   | 4 ++--
 gcc/testsuite/gcc.target/riscv/sat/sat_s_add_imm-4.c   | 4 ++--
 23 files changed, 46 insertions(+), 46 deletions(-)

diff --git a/gcc/testsuite/gcc.target/riscv/sat/sat_s_add-1-i16.c 
b/gcc/testsuite/gcc.target/riscv/sat/sat_s_add-1-i16.c
index 24832c7435d9..55890d8487ce 100644
--- a/gcc/testsuite/gcc.target/riscv/sat/sat_s_add-1-i16.c
+++ b/gcc/testsuite/gcc.target/riscv/sat/sat_s_add-1-i16.c
@@ -1,5 +1,5 @@
 /* { dg-do compile } */
-/* { dg-options "-march=rv64gc -mabi=lp64d -fdump-rtl-expand-details 
-fno-schedule-insns -fno-schedule-insns2" } */
+/* { dg-options "-march=rv64gc -mabi=lp64d -fdump-tree-optimized 
-fno-schedule-insns -fno-schedule-insns2" } */
 /* { dg-final { check-function-bodies "**" "" } } */
 
 #include "sat_arith.h"
@@ -29,4 +29,4 @@
 */
 DEF_SAT_S_ADD_FMT_1(int16_t, uint16_t, INT16_MIN, INT16_MAX)
 
-/* { dg-final { scan-rtl-dump-times ".SAT_ADD " 2 "expand" } } */
+/* { dg-final { scan-tree-dump-times ".SAT_ADD " 1 "optimized" } } */
diff --git a/gcc

[gcc r15-6034] RISC-V: Refine unsigned SAT_TRUNC testcase dump check to tree optimized

2024-12-09 Thread Pan Li via Gcc-cvs
https://gcc.gnu.org/g:31778b48dd5fe6ae2bb089293a9a256918008d96

commit r15-6034-g31778b48dd5fe6ae2bb089293a9a256918008d96
Author: Pan Li 
Date:   Sun Dec 8 09:32:27 2024 +0800

RISC-V: Refine unsigned SAT_TRUNC testcase dump check to tree optimized

The sat alu related testcase check the rtl dump for the standard name
like .SAT_TRUNC exist or not.  But the rtl pass expand is somehow
impressionable by the middle-end change or debug information.  Like
below new appearance recently.

Replacing Expressions
_5 replace with --> _5 = .SAT_TRUNC (x_3(D), y_4(D)); [tail call]

After that we need to adjust the dump check time and again.  This
patch would like to switch to tree optimized pass for the standard
name check, which is more stable up to a point.

The below test suites are passed for this patch.
* The rv64gcv fully regression test.

It is test only patch and obvious up to a point, will commit it
directly if no comments in next 48H.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/sat/sat_u_trunc-1-u16.c: Take tree-optimized
pass for standard name check, and adjust the times.
* gcc.target/riscv/sat/sat_u_trunc-1-u32.c: Ditto.
* gcc.target/riscv/sat/sat_u_trunc-1-u64.c: Ditto.
* gcc.target/riscv/sat/sat_u_trunc-1-u8.c: Ditto.
* gcc.target/riscv/sat/sat_u_trunc-2-u16.c: Ditto.
* gcc.target/riscv/sat/sat_u_trunc-2-u32.c: Ditto.
* gcc.target/riscv/sat/sat_u_trunc-2-u64.c: Ditto.
* gcc.target/riscv/sat/sat_u_trunc-2-u8.c: Ditto.
* gcc.target/riscv/sat/sat_u_trunc-3-u16.c: Ditto.
* gcc.target/riscv/sat/sat_u_trunc-3-u32.c: Ditto.
* gcc.target/riscv/sat/sat_u_trunc-3-u64.c: Ditto.
* gcc.target/riscv/sat/sat_u_trunc-3-u8.c: Ditto.
* gcc.target/riscv/sat/sat_u_trunc-4-u16.c: Ditto.
* gcc.target/riscv/sat/sat_u_trunc-4-u32.c: Ditto.
* gcc.target/riscv/sat/sat_u_trunc-4-u64.c: Ditto.
* gcc.target/riscv/sat/sat_u_trunc-4-u8.c: Ditto.
* gcc.target/riscv/sat/sat_u_trunc-5-u16.c: Ditto.
* gcc.target/riscv/sat/sat_u_trunc-5-u32.c: Ditto.
* gcc.target/riscv/sat/sat_u_trunc-5-u64.c: Ditto.
* gcc.target/riscv/sat/sat_u_trunc-5-u8.c: Ditto.
* gcc.target/riscv/sat/sat_u_trunc-6-u16.c: Ditto.
* gcc.target/riscv/sat/sat_u_trunc-6-u32.c: Ditto.
* gcc.target/riscv/sat/sat_u_trunc-6-u64.c: Ditto.
* gcc.target/riscv/sat/sat_u_trunc-6-u8.c: Ditto.

Signed-off-by: Pan Li 

Diff:
---
 gcc/testsuite/gcc.target/riscv/sat/sat_u_trunc-1-u16.c | 4 ++--
 gcc/testsuite/gcc.target/riscv/sat/sat_u_trunc-1-u32.c | 4 ++--
 gcc/testsuite/gcc.target/riscv/sat/sat_u_trunc-1-u64.c | 4 ++--
 gcc/testsuite/gcc.target/riscv/sat/sat_u_trunc-1-u8.c  | 4 ++--
 gcc/testsuite/gcc.target/riscv/sat/sat_u_trunc-2-u16.c | 4 ++--
 gcc/testsuite/gcc.target/riscv/sat/sat_u_trunc-2-u32.c | 4 ++--
 gcc/testsuite/gcc.target/riscv/sat/sat_u_trunc-2-u64.c | 4 ++--
 gcc/testsuite/gcc.target/riscv/sat/sat_u_trunc-2-u8.c  | 4 ++--
 gcc/testsuite/gcc.target/riscv/sat/sat_u_trunc-3-u16.c | 4 ++--
 gcc/testsuite/gcc.target/riscv/sat/sat_u_trunc-3-u32.c | 4 ++--
 gcc/testsuite/gcc.target/riscv/sat/sat_u_trunc-3-u64.c | 4 ++--
 gcc/testsuite/gcc.target/riscv/sat/sat_u_trunc-3-u8.c  | 4 ++--
 gcc/testsuite/gcc.target/riscv/sat/sat_u_trunc-4-u16.c | 4 ++--
 gcc/testsuite/gcc.target/riscv/sat/sat_u_trunc-4-u32.c | 4 ++--
 gcc/testsuite/gcc.target/riscv/sat/sat_u_trunc-4-u64.c | 4 ++--
 gcc/testsuite/gcc.target/riscv/sat/sat_u_trunc-4-u8.c  | 4 ++--
 gcc/testsuite/gcc.target/riscv/sat/sat_u_trunc-5-u16.c | 4 ++--
 gcc/testsuite/gcc.target/riscv/sat/sat_u_trunc-5-u32.c | 4 ++--
 gcc/testsuite/gcc.target/riscv/sat/sat_u_trunc-5-u64.c | 4 ++--
 gcc/testsuite/gcc.target/riscv/sat/sat_u_trunc-5-u8.c  | 4 ++--
 gcc/testsuite/gcc.target/riscv/sat/sat_u_trunc-6-u16.c | 4 ++--
 gcc/testsuite/gcc.target/riscv/sat/sat_u_trunc-6-u32.c | 4 ++--
 gcc/testsuite/gcc.target/riscv/sat/sat_u_trunc-6-u64.c | 4 ++--
 gcc/testsuite/gcc.target/riscv/sat/sat_u_trunc-6-u8.c  | 4 ++--
 24 files changed, 48 insertions(+), 48 deletions(-)

diff --git a/gcc/testsuite/gcc.target/riscv/sat/sat_u_trunc-1-u16.c 
b/gcc/testsuite/gcc.target/riscv/sat/sat_u_trunc-1-u16.c
index 995abc9a18ec..b73290af8e3c 100644
--- a/gcc/testsuite/gcc.target/riscv/sat/sat_u_trunc-1-u16.c
+++ b/gcc/testsuite/gcc.target/riscv/sat/sat_u_trunc-1-u16.c
@@ -1,5 +1,5 @@
 /* { dg-do compile } */
-/* { dg-options "-march=rv64gc -mabi=lp64d -fdump-rtl-expand-details 
-fno-schedule-insns -fno-schedule-insns2" } */
+/* { dg-options "-march=rv64gc -mabi=lp64d -fdump-tree-optimized 
-fno-schedule-insns -fno-schedule-insns2" } */
 /* { dg-final { check-function-bodies "**" "" } } */
 
 #include "sat_arith.h"
@@ -17,4 +17,4 @@
 */
 DEF_SAT_U_TRUNC_FMT_1(uint16_t, uin

[gcc r15-6036] RISC-V: Refine signed SAT_SUB testcase dump check to tree optimized

2024-12-09 Thread Pan Li via Gcc-cvs
https://gcc.gnu.org/g:da448408682aeb0f02c39ce36b1312eee6a2ca5d

commit r15-6036-gda448408682aeb0f02c39ce36b1312eee6a2ca5d
Author: Pan Li 
Date:   Sun Dec 8 09:32:29 2024 +0800

RISC-V: Refine signed SAT_SUB testcase dump check to tree optimized

The sat alu related testcase check the rtl dump for the standard name
like .SAT_SUB exist or not.  But the rtl pass expand is somehow
impressionable by the middle-end change or debug information.  Like
below new appearance recently.

Replacing Expressions
_5 replace with --> _5 = .SAT_SUB (x_3(D), y_4(D)); [tail call]

After that we need to adjust the dump check time and again.  This
patch would like to switch to tree optimized pass for the standard
name check, which is more stable up to a point.

The below test suites are passed for this patch.
* The rv64gcv fully regression test.

It is test only patch and obvious up to a point, will commit it
directly if no comments in next 48H.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/sat/sat_s_sub-1-i16.c: Take tree-optimized
pass for standard name check, and adjust the times.
* gcc.target/riscv/sat/sat_s_sub-1-i32.c: Ditto.
* gcc.target/riscv/sat/sat_s_sub-1-i64.c: Ditto.
* gcc.target/riscv/sat/sat_s_sub-1-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_sub-2-i16.c: Ditto.
* gcc.target/riscv/sat/sat_s_sub-2-i32.c: Ditto.
* gcc.target/riscv/sat/sat_s_sub-2-i64.c: Ditto.
* gcc.target/riscv/sat/sat_s_sub-2-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_sub-3-i16.c: Ditto.
* gcc.target/riscv/sat/sat_s_sub-3-i32.c: Ditto.
* gcc.target/riscv/sat/sat_s_sub-3-i64.c: Ditto.
* gcc.target/riscv/sat/sat_s_sub-3-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_sub-4-i16.c: Ditto.
* gcc.target/riscv/sat/sat_s_sub-4-i32.c: Ditto.
* gcc.target/riscv/sat/sat_s_sub-4-i64.c: Ditto.
* gcc.target/riscv/sat/sat_s_sub-4-i8.c: Ditto.

Signed-off-by: Pan Li 

Diff:
---
 gcc/testsuite/gcc.target/riscv/sat/sat_s_sub-1-i16.c | 4 ++--
 gcc/testsuite/gcc.target/riscv/sat/sat_s_sub-1-i32.c | 4 ++--
 gcc/testsuite/gcc.target/riscv/sat/sat_s_sub-1-i64.c | 4 ++--
 gcc/testsuite/gcc.target/riscv/sat/sat_s_sub-1-i8.c  | 4 ++--
 gcc/testsuite/gcc.target/riscv/sat/sat_s_sub-2-i16.c | 4 ++--
 gcc/testsuite/gcc.target/riscv/sat/sat_s_sub-2-i32.c | 4 ++--
 gcc/testsuite/gcc.target/riscv/sat/sat_s_sub-2-i64.c | 4 ++--
 gcc/testsuite/gcc.target/riscv/sat/sat_s_sub-2-i8.c  | 4 ++--
 gcc/testsuite/gcc.target/riscv/sat/sat_s_sub-3-i16.c | 4 ++--
 gcc/testsuite/gcc.target/riscv/sat/sat_s_sub-3-i32.c | 4 ++--
 gcc/testsuite/gcc.target/riscv/sat/sat_s_sub-3-i64.c | 4 ++--
 gcc/testsuite/gcc.target/riscv/sat/sat_s_sub-3-i8.c  | 4 ++--
 gcc/testsuite/gcc.target/riscv/sat/sat_s_sub-4-i16.c | 4 ++--
 gcc/testsuite/gcc.target/riscv/sat/sat_s_sub-4-i32.c | 4 ++--
 gcc/testsuite/gcc.target/riscv/sat/sat_s_sub-4-i64.c | 4 ++--
 gcc/testsuite/gcc.target/riscv/sat/sat_s_sub-4-i8.c  | 4 ++--
 16 files changed, 32 insertions(+), 32 deletions(-)

diff --git a/gcc/testsuite/gcc.target/riscv/sat/sat_s_sub-1-i16.c 
b/gcc/testsuite/gcc.target/riscv/sat/sat_s_sub-1-i16.c
index 348a1525a88c..c244eb40947e 100644
--- a/gcc/testsuite/gcc.target/riscv/sat/sat_s_sub-1-i16.c
+++ b/gcc/testsuite/gcc.target/riscv/sat/sat_s_sub-1-i16.c
@@ -1,5 +1,5 @@
 /* { dg-do compile } */
-/* { dg-options "-march=rv64gc -mabi=lp64d -fdump-rtl-expand-details 
-fno-schedule-insns -fno-schedule-insns2" } */
+/* { dg-options "-march=rv64gc -mabi=lp64d -fdump-tree-optimized 
-fno-schedule-insns -fno-schedule-insns2" } */
 /* { dg-final { check-function-bodies "**" "" } } */
 
 #include "sat_arith.h"
@@ -27,4 +27,4 @@
 */
 DEF_SAT_S_SUB_FMT_1(int16_t, uint16_t, INT16_MIN, INT16_MAX)
 
-/* { dg-final { scan-rtl-dump-times ".SAT_SUB " 2 "expand" } } */
+/* { dg-final { scan-tree-dump-times ".SAT_SUB " 1 "optimized" } } */
diff --git a/gcc/testsuite/gcc.target/riscv/sat/sat_s_sub-1-i32.c 
b/gcc/testsuite/gcc.target/riscv/sat/sat_s_sub-1-i32.c
index 7af1e8c72d9d..9d8245d49979 100644
--- a/gcc/testsuite/gcc.target/riscv/sat/sat_s_sub-1-i32.c
+++ b/gcc/testsuite/gcc.target/riscv/sat/sat_s_sub-1-i32.c
@@ -1,5 +1,5 @@
 /* { dg-do compile } */
-/* { dg-options "-march=rv64gc -mabi=lp64d -fdump-rtl-expand-details 
-fno-schedule-insns -fno-schedule-insns2" } */
+/* { dg-options "-march=rv64gc -mabi=lp64d -fdump-tree-optimized 
-fno-schedule-insns -fno-schedule-insns2" } */
 /* { dg-final { check-function-bodies "**" "" } } */
 
 #include "sat_arith.h"
@@ -25,4 +25,4 @@
 */
 DEF_SAT_S_SUB_FMT_1(int32_t, uint32_t, INT32_MIN, INT32_MAX)
 
-/* { dg-final { scan-rtl-dump-times ".SAT_SUB " 2 "expand" } } */
+/* { dg-final { scan-tree-dump-times ".SAT_SUB " 1 "optimized" } } */
diff --git a/gcc/testsuite/gcc.target/riscv/sat/sat_s_sub-1-i64.c 
b/gcc/testsu

[gcc r15-6022] tree-eh: Don't crash on GIMPLE_TRY_FINALLY with empty cleanup sequence [PR117845]

2024-12-09 Thread Simon Martin via Gcc-cvs
https://gcc.gnu.org/g:3076539544d3e36684cc8eed3374aeff5b44c9b1

commit r15-6022-g3076539544d3e36684cc8eed3374aeff5b44c9b1
Author: Simon Martin 
Date:   Mon Dec 9 09:21:25 2024 +0100

tree-eh: Don't crash on GIMPLE_TRY_FINALLY with empty cleanup sequence 
[PR117845]

The following valid code triggers an ICE with -fsanitize=address

=== cut here ===
void l() {
auto const ints = {0,1,2,3,4,5};
for (auto i : { 3 } ) {
__builtin_printf("%d ", i);
}
}
=== cut here ===

The problem is that honor_protect_cleanup_actions does not expect the
cleanup sequence of a GIMPLE_TRY_FINALLY to be empty. It is however the
case here since r14-8681-gceb242f5302027, because lower_stmt removes the
only statement in the sequence: a ASAN_MARK statement for the array that
backs the initializer_list).

This patch simply checks that the finally block is not 0 before
accessing it in honor_protect_cleanup_actions.

PR c++/117845

gcc/ChangeLog:

* tree-eh.cc (honor_protect_cleanup_actions): Support empty
finally sequences.

gcc/testsuite/ChangeLog:

* g++.dg/asan/pr117845-2.C: New test.
* g++.dg/asan/pr117845.C: New test.

Diff:
---
 gcc/testsuite/g++.dg/asan/pr117845-2.C | 12 
 gcc/testsuite/g++.dg/asan/pr117845.C   | 12 
 gcc/tree-eh.cc |  5 +++--
 3 files changed, 27 insertions(+), 2 deletions(-)

diff --git a/gcc/testsuite/g++.dg/asan/pr117845-2.C 
b/gcc/testsuite/g++.dg/asan/pr117845-2.C
new file mode 100644
index ..c05563970091
--- /dev/null
+++ b/gcc/testsuite/g++.dg/asan/pr117845-2.C
@@ -0,0 +1,12 @@
+// PR c++/117845 - Actually valid variant
+// { dg-do "compile" }
+// { dg-options "-fsanitize=address" }
+
+#include 
+
+void l() {
+auto const ints = {0,1,2,3,4,5};
+for (auto i : { 3 } ) {
+__builtin_printf("%d ", i);
+}
+}
diff --git a/gcc/testsuite/g++.dg/asan/pr117845.C 
b/gcc/testsuite/g++.dg/asan/pr117845.C
new file mode 100644
index ..d90d351e2701
--- /dev/null
+++ b/gcc/testsuite/g++.dg/asan/pr117845.C
@@ -0,0 +1,12 @@
+// PR c++/117845 - Initially reported case.
+// { dg-do "compile" }
+// { dg-options "-fsanitize=address" }
+
+#include 
+
+void l() {
+auto const ints = {0,1,2,3,4,5};
+for (int i : ints | h) { // { dg-error "was not declared" }
+__builtin_printf("%d ", i);
+}
+}
diff --git a/gcc/tree-eh.cc b/gcc/tree-eh.cc
index 769785fad2b9..e8af5fb8989b 100644
--- a/gcc/tree-eh.cc
+++ b/gcc/tree-eh.cc
@@ -1025,8 +1025,9 @@ honor_protect_cleanup_actions (struct leh_state 
*outer_state,
 terminate before we get to it, so strip it away before adding the
 MUST_NOT_THROW filter.  */
   gimple_stmt_iterator gsi = gsi_start (finally);
-  gimple *x = gsi_stmt (gsi);
-  if (gimple_code (x) == GIMPLE_TRY
+  gimple *x = !gsi_end_p (gsi) ? gsi_stmt (gsi) : NULL;
+  if (x
+ && gimple_code (x) == GIMPLE_TRY
  && gimple_try_kind (x) == GIMPLE_TRY_CATCH
  && gimple_try_catch_is_cleanup (x))
{


[gcc r15-6030] middle-end/117932 - speed up DF solver

2024-12-09 Thread Richard Biener via Gcc-cvs
https://gcc.gnu.org/g:57dcb27e7a48151ad5f9a6122c6a40fac31843e9

commit r15-6030-g57dcb27e7a48151ad5f9a6122c6a40fac31843e9
Author: Richard Biener 
Date:   Fri Dec 6 16:36:39 2024 +0100

middle-end/117932 - speed up DF solver

The following addresses slow bitmap operations for maintaining the
iteration order of df_worklist_dataflow_doublequeue for large number
of basic-blocks.  The main complexity change is switching the
worklist and pending bitmaps to tree view, a secondary change is
avoiding the fully populated initial bitmap for the first iteration
and instead special-casing that plus avoiding all forward worklist
bitmap sets in that iteration.  Usually second or later iterations
are sparse, so optimizing the first iteration seems worthwhile.

For PR117932 when isolating from ext-dce and fold-mem-offset issues
this results in a 10% compile-time reduction.

PR middle-end/117932
* df-core.cc (df_worklist_propagate_forward): When WORKLIST
is NULL, do not set bits there.
(df_worklist_propagate_backward): Likewise.
(df_worklist_dataflow_doublequeue): Separate first pass
over all blocks with NULL worklist.
(df_worklist_dataflow): Do not initialize pending and adjust.

Diff:
---
 gcc/df-core.cc | 70 --
 1 file changed, 48 insertions(+), 22 deletions(-)

diff --git a/gcc/df-core.cc b/gcc/df-core.cc
index 0f27bd2524b3..99fe466d053c 100644
--- a/gcc/df-core.cc
+++ b/gcc/df-core.cc
@@ -872,7 +872,8 @@ make_pass_df_finish (gcc::context *ctxt)
Given a BB_INDEX, do the dataflow propagation
and set bits on for successors in PENDING for earlier
and WORKLIST for later in bbindex_to_postorder
-   if the out set of the dataflow has changed.
+   if the out set of the dataflow has changed.  When WORKLIST
+   is NULL we are processing all later blocks.
 
AGE specify time when BB was visited last time.
AGE of 0 means we are visiting for first time and need to
@@ -925,7 +926,10 @@ df_worklist_propagate_forward (struct dataflow *dataflow,
{
  if (bbindex_to_postorder[bb_index]
  < bbindex_to_postorder[ob_index])
-   bitmap_set_bit (worklist, bbindex_to_postorder[ob_index]);
+   {
+ if (worklist)
+   bitmap_set_bit (worklist, bbindex_to_postorder[ob_index]);
+   }
  else
bitmap_set_bit (pending, bbindex_to_postorder[ob_index]);
}
@@ -979,7 +983,10 @@ df_worklist_propagate_backward (struct dataflow *dataflow,
{
  if (bbindex_to_postorder[bb_index]
  < bbindex_to_postorder[ob_index])
-   bitmap_set_bit (worklist, bbindex_to_postorder[ob_index]);
+   {
+ if (worklist)
+   bitmap_set_bit (worklist, bbindex_to_postorder[ob_index]);
+   }
  else
bitmap_set_bit (pending, bbindex_to_postorder[ob_index]);
}
@@ -1010,26 +1017,55 @@ df_worklist_propagate_backward (struct dataflow 
*dataflow,
 
 static void
 df_worklist_dataflow_doublequeue (struct dataflow *dataflow,
- bitmap pending,
   sbitmap considered,
   int *blocks_in_postorder,
  unsigned *bbindex_to_postorder,
- int n_blocks)
+ unsigned n_blocks)
 {
   enum df_flow_dir dir = dataflow->problem->dir;
   int dcount = 0;
-  bitmap worklist = BITMAP_ALLOC (&df_bitmap_obstack);
   int age = 0;
   bool changed;
   vec last_visit_age = vNULL;
   vec last_change_age = vNULL;
   int prev_age;
 
+  bitmap worklist = BITMAP_ALLOC (&df_bitmap_obstack);
+  bitmap_tree_view (worklist);
+
   last_visit_age.safe_grow_cleared (n_blocks, true);
   last_change_age.safe_grow_cleared (n_blocks, true);
 
-  /* Double-queueing. Worklist is for the current iteration,
- and pending is for the next. */
+  /* We start with processing all blocks, populating pending for the
+ next iteration.  */
+  bitmap pending = BITMAP_ALLOC (&df_bitmap_obstack);
+  bitmap_tree_view (pending);
+  for (unsigned index = 0; index < n_blocks; ++index)
+{
+  unsigned bb_index = blocks_in_postorder[index];
+  dcount++;
+  prev_age = last_visit_age[index];
+  if (dir == DF_FORWARD)
+   changed = df_worklist_propagate_forward (dataflow, bb_index,
+bbindex_to_postorder,
+NULL, pending,
+considered,
+last_change_age,
+prev_age);
+  else
+   changed = df_worklist_propagat

[gcc r15-6028] GCN: Fix 'real_from_integer' usage

2024-12-09 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:91c503431f675bf3c94bd23c2b1deecdd2df52b8

commit r15-6028-g91c503431f675bf3c94bd23c2b1deecdd2df52b8
Author: Thomas Schwinge 
Date:   Thu Dec 5 14:28:26 2024 +0100

GCN: Fix 'real_from_integer' usage

The recent commit b3f1b9e2aa079f8ec73e3cb48143a16645c49566
"build: Remove INCLUDE_MEMORY [PR117737]" exposed an issue in code added in
2020 GCN back end commit 95607c12363712c39345e1d97f2c1aee8025e188
"Zero-initialise masked load destinations"; compilation now fails:

[...]
In file included from ../../source-gcc/gcc/coretypes.h:507:0,
 from ../../source-gcc/gcc/config/gcn/gcn.cc:24:
../../source-gcc/gcc/real.h: In instantiation of 
‘format_helper::format_helper(const T&) [with T = std::nullptr_t]’:
../../source-gcc/gcc/config/gcn/gcn.cc:1178:46:   required from here
../../source-gcc/gcc/real.h:233:17: error: no match for ‘operator==’ 
(operand types are ‘std::nullptr_t’ and ‘machine_mode’)
   : m_format (m == VOIDmode ? 0 : REAL_MODE_FORMAT (m))
 ^
[...]

That's with 'g++ (GCC) 5.5.0', and seen similarly with
'g++ (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0', for example.

gcc/
* config/gcn/gcn.cc (gcn_vec_constant): Fix 'real_from_integer'
usage.

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

diff --git a/gcc/config/gcn/gcn.cc b/gcc/config/gcn/gcn.cc
index 8fce1c9234ac..d017f22d1bc4 100644
--- a/gcc/config/gcn/gcn.cc
+++ b/gcc/config/gcn/gcn.cc
@@ -1175,7 +1175,7 @@ gcn_vec_constant (machine_mode mode, int a)
   if (FLOAT_MODE_P (innermode))
 {
   REAL_VALUE_TYPE rv;
-  real_from_integer (&rv, NULL, a, SIGNED);
+  real_from_integer (&rv, VOIDmode, a, SIGNED);
   tem = const_double_from_real_value (rv, innermode);
 }
   else


[gcc r15-6029] nvptx: Switch default from '-march=sm_30' to '-march=sm_52'

2024-12-09 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:d4e1f7cfdb8375c2a0076d4227a220b5e2682834

commit r15-6029-gd4e1f7cfdb8375c2a0076d4227a220b5e2682834
Author: Thomas Schwinge 
Date:   Mon Nov 11 13:20:46 2024 +0100

nvptx: Switch default from '-march=sm_30' to '-march=sm_52'

In preparation of GCC/nvptx code changes that require sm_52 features, this
commit raises nvptx code generation from sm_30 "Kepler" to sm_52 "Maxwell".
The latter has been supported as of CUDA 6.5 (2014-08), and is thus 
supported
by most Nvidia GPUs of the last decade, approximately.  (This commit doesn't
change the use of PTX ISA 6.0, which already requires CUDA 9.0 anyway.)

To continue building sm_30 multilib variants (for use via building/linking 
with
'-march=sm_30'), specify '--with-multilib-list=default,sm_30', for example. 
 Or,
to continue defaulting to sm_30 multilib variants, specify 
'--with-arch=sm_30'
(plus '--without-multilib-list', if applicable).  See the documentation,
.

(Note that after a long deprecation time, eventually the
sm_3x "Kepler architecture support is removed from CUDA 12.0", 2022-12.)

gcc/
* config.gcc [nvptx-*]: Switch default from '-march=sm_30' to
'-march=sm_52'.
* doc/install.texi (Nvidia PTX Options): Update.

Diff:
---
 gcc/config.gcc   | 4 ++--
 gcc/doc/install.texi | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/gcc/config.gcc b/gcc/config.gcc
index a2d21b5f3436..262b38cf0e36 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -4133,7 +4133,7 @@ if test x$with_arch = x ; then
   with_arch=mips2
   ;;
 nvptx-*)
-  with_arch=sm_30
+  with_arch=sm_52
   ;;
   esac
 
@@ -5596,7 +5596,7 @@ case "${target}" in
nvptx-*)
supported_defaults=arch
 
-   nvptx_multilibs_default=sm_30
+   nvptx_multilibs_default=sm_52
 
case "x${with_multilib_list}" in
x | xno)
diff --git a/gcc/doc/install.texi b/gcc/doc/install.texi
index f3a0700ced43..feabf4cbe20b 100644
--- a/gcc/doc/install.texi
+++ b/gcc/doc/install.texi
@@ -1422,7 +1422,7 @@ is specified, then no additional multilibs are built.
 Otherwise, @var{list} is a comma separated list specifying which
 multilibs to build.
 List items are either @samp{sm_SM}, or @samp{default}, which is a
-placeholder specifying a default set of multilibs: @samp{sm_30}.
+placeholder specifying a default set of multilibs: @samp{sm_52}.
 Any duplicates are filtered out.
 If @option{--with-multilib-list} is not specified, then
 @option{--with-multilib-list=default} is assumed.
@@ -4628,7 +4628,7 @@ Use the @option{--disable-sjlj-exceptions} and
 The @option{--with-arch} option may be specified to override the
 default value for the @option{-march} option, and to also build
 corresponding target libraries.
-The default is @option{--with-arch=sm_30}.
+The default is @option{--with-arch=sm_52}.
 
 For example, if @option{--with-arch=sm_70} is specified,
 code generation defaults to @option{-march=sm_70} and


[gcc r15-6026] Rust: Work around 'error[E0599]: no method named `leak` found for struct `std::string::String` in th

2024-12-09 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:9e4a87ceb31d5c25cb7163ed8016986f0adbc68f

commit r15-6026-g9e4a87ceb31d5c25cb7163ed8016986f0adbc68f
Author: Thomas Schwinge 
Date:   Sat Aug 3 16:39:17 2024 +0200

Rust: Work around 'error[E0599]: no method named `leak` found for struct 
`std::string::String` in the current scope'

Compiling with Debian GNU/Linux 12 (bookworm) packages:

$ apt-cache madison cargo rustc
 cargo | 0.66.0+ds1-1 | http://deb.debian.org/debian bookworm/main 
ppc64el Packages
 cargo | 0.66.0+ds1-1 | http://deb.debian.org/debian bookworm/main 
Sources
 rustc | 1.63.0+dfsg1-2 | http://deb.debian.org/debian 
bookworm/main ppc64el Packages
 rustc | 1.63.0+dfsg1-2 | http://deb.debian.org/debian 
bookworm/main Sources

..., we run into:

   Compiling libformat_parser v0.1.0 
([...]/source-gcc/libgrust/libformat_parser)
error[E0599]: no method named `leak` found for struct 
`std::string::String` in the current scope
   --> src/lib.rs:396:18
|
396 | ptr: str.leak().as_ptr(),
|   method not found in `std::string::String`

error[E0599]: no method named `leak` found for struct 
`std::string::String` in the current scope
   --> src/lib.rs:434:7
|
434 | s.leak();
|    method not found in `std::string::String`

error[E0599]: no method named `leak` found for struct 
`std::string::String` in the current scope
   --> src/lib.rs:439:23
|
439 | ptr: cloned_s.leak().as_ptr(),
|    method not found in 
`std::string::String`

Locally replace 1.72.0+ method 'leak' for struct 'std::string::String'.

libgrust/
* libformat_parser/src/lib.rs: Work around 'error[E0599]:
no method named `leak` found for struct `std::string::String` in 
the current scope'.

Diff:
---
 libgrust/libformat_parser/src/lib.rs | 13 ++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/libgrust/libformat_parser/src/lib.rs 
b/libgrust/libformat_parser/src/lib.rs
index 84fac38e224d..28f6a6a62b62 100644
--- a/libgrust/libformat_parser/src/lib.rs
+++ b/libgrust/libformat_parser/src/lib.rs
@@ -5,6 +5,13 @@
 
 use std::ffi::CStr;
 
+// Local replacement for 1.72.0+ method 'leak' for struct 
'std::string::String',
+// 
+fn leak_string<'a>(s: String) -> &'a mut str {
+let slice = s.into_bytes().leak();
+unsafe { std::str::from_utf8_unchecked_mut(slice) }
+}
+
 trait IntoFFI {
 fn into_ffi(self) -> T;
 }
@@ -393,7 +400,7 @@ pub extern "C" fn collect_pieces(
 let rust_string = RustString {
 len: str.len(),
 cap: str.capacity(),
-ptr: str.leak().as_ptr(),
+ptr: leak_string(str).as_ptr(),
 };
 
 FormatArgsHandle(piece_slice, rust_string)
@@ -431,12 +438,12 @@ pub extern "C" fn clone_pieces(
 let cloned_s = s.clone();
 
 // FIXME: Documentation
-s.leak();
+leak_string(s);
 
 let rust_string = RustString {
 len: cloned_s.len(),
 cap: cloned_s.capacity(),
-ptr: cloned_s.leak().as_ptr(),
+ptr: leak_string(cloned_s).as_ptr(),
 };
 
 FormatArgsHandle(piece_slice, rust_string)


[gcc r15-6027] Rust: libformat_parser: Lower minimum Rust version to 1.49

2024-12-09 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:be38c37fdc35e7f77dbab16736782cfe24769e77

commit r15-6027-gbe38c37fdc35e7f77dbab16736782cfe24769e77
Author: Arthur Cohen 
Date:   Tue Apr 23 14:13:21 2024 +0200

Rust: libformat_parser: Lower minimum Rust version to 1.49

libgrust/ChangeLog:

* libformat_parser/Cargo.toml: Change Rust edition from 2021 to 
2018.
* libformat_parser/generic_format_parser/Cargo.toml: Likewise.
* libformat_parser/generic_format_parser/src/lib.rs: Remove usage of
then-unstable std features and language constructs.
* libformat_parser/src/lib.rs: Likewise, plus provide extension 
trait
for String::leak.

Diff:
---
 libgrust/libformat_parser/Cargo.toml   |  2 +-
 .../generic_format_parser/Cargo.toml   |  2 +-
 .../generic_format_parser/src/lib.rs   | 42 +++---
 libgrust/libformat_parser/src/lib.rs   | 19 +-
 4 files changed, 42 insertions(+), 23 deletions(-)

diff --git a/libgrust/libformat_parser/Cargo.toml 
b/libgrust/libformat_parser/Cargo.toml
index 0fcfa3e89a4c..3c214915d31e 100644
--- a/libgrust/libformat_parser/Cargo.toml
+++ b/libgrust/libformat_parser/Cargo.toml
@@ -1,7 +1,7 @@
 [package]
 name = "libformat_parser"
 version = "0.1.0"
-edition = "2021"
+edition = "2018"
 
 [workspace]
 
diff --git a/libgrust/libformat_parser/generic_format_parser/Cargo.toml 
b/libgrust/libformat_parser/generic_format_parser/Cargo.toml
index 34577038cbed..224ad6826ec8 100644
--- a/libgrust/libformat_parser/generic_format_parser/Cargo.toml
+++ b/libgrust/libformat_parser/generic_format_parser/Cargo.toml
@@ -1,7 +1,7 @@
 [package]
 name = "generic_format_parser"
 version = "0.1.0"
-edition = "2021"
+edition = "2018"
 
 # See more keys and their definitions at 
https://doc.rust-lang.org/cargo/reference/manifest.html
 
diff --git a/libgrust/libformat_parser/generic_format_parser/src/lib.rs 
b/libgrust/libformat_parser/generic_format_parser/src/lib.rs
index ed3d8577befa..e255bf16908f 100644
--- a/libgrust/libformat_parser/generic_format_parser/src/lib.rs
+++ b/libgrust/libformat_parser/generic_format_parser/src/lib.rs
@@ -505,7 +505,7 @@ impl<'a> Parser<'a> {
 }
 
 pos = peek_pos;
-description = format!("expected `'}}'`, found `{maybe:?}`");
+description = format!("expected `'}}'`, found `{:?}`", maybe);
 } else {
 description = "expected `'}'` but string was 
terminated".to_owned();
 // point at closing `"`
@@ -690,12 +690,16 @@ impl<'a> Parser<'a> {
 
 // fill character
 if let Some(&(idx, c)) = self.cur.peek() {
-if let Some((_, '>' | '<' | '^')) = self.cur.clone().nth(1) {
-spec.fill = Some(c);
-spec.fill_span = Some(self.span(idx, idx + 1));
-self.cur.next();
+match self.cur.clone().nth(1) {
+Some((_, '>')) | Some((_, '<')) | Some((_, '^')) => {
+spec.fill = Some(c);
+spec.fill_span = Some(self.span(idx, idx + 1));
+self.cur.next();
+}
+_ => {}
 }
 }
+
 // Alignment
 if self.consume('<') {
 spec.align = AlignLeft;
@@ -908,7 +912,11 @@ impl<'a> Parser<'a> {
 );
 }
 
-found.then_some(cur)
+if found {
+Some(cur)
+} else {
+None
+}
 }
 
 fn suggest_format(&mut self) {
@@ -992,10 +1000,8 @@ fn find_width_map_from_snippet(
 // Alternatively, we could just count the trailing newlines and only trim 
one from the input if they don't match up.
 let input_no_nl = input.trim_end_matches('\n');
 let unescaped = match unescape_string(snippet) {
-Some(unescaped) => unescaped,
-_ => {
-return InputStringKind::NotALiteral;
-}
+Some(u) => u,
+None => return InputStringKind::NotALiteral,
 };
 
 let unescaped_no_nl = unescaped.trim_end_matches('\n');
@@ -1026,7 +1032,13 @@ fn find_width_map_from_snippet(
 
 width_mappings.push(InnerWidthMapping::new(pos, width, 0));
 }
-('\\', Some((_, 'n' | 't' | 'r' | '0' | '\\' | '\'' | '\"'))) => {
+('\\', Some((_, 'n')))
+| ('\\', Some((_, 't')))
+| ('\\', Some((_, 'r')))
+| ('\\', Some((_, '0')))
+| ('\\', Some((_, '\\')))
+| ('\\', Some((_, '\'')))
+| ('\\', Some((_, '\"'))) => {
 width_mappings.push(InnerWidthMapping::new(pos, 2, 1));
 let _ = s.next();
 }
@@ -1052,7 +1064,7 @@ fn find_width_map_from_snippet(
 .as_str()
 .get(..digits_len)
 .and_then(|digits| u32::from_str_radix(digits, 
16).ok())
-

[gcc r14-11075] tree-eh: Don't crash on GIMPLE_TRY_FINALLY with empty cleanup sequence [PR117845]

2024-12-09 Thread Simon Martin via Gcc-cvs
https://gcc.gnu.org/g:ac054467bf42365de85336775cba9b9f476e73ed

commit r14-11075-gac054467bf42365de85336775cba9b9f476e73ed
Author: Simon Martin 
Date:   Mon Dec 9 09:21:25 2024 +0100

tree-eh: Don't crash on GIMPLE_TRY_FINALLY with empty cleanup sequence 
[PR117845]

The following valid code triggers an ICE with -fsanitize=address

=== cut here ===
void l() {
auto const ints = {0,1,2,3,4,5};
for (auto i : { 3 } ) {
__builtin_printf("%d ", i);
}
}
=== cut here ===

The problem is that honor_protect_cleanup_actions does not expect the
cleanup sequence of a GIMPLE_TRY_FINALLY to be empty. It is however the
case here since r14-8681-gceb242f5302027, because lower_stmt removes the
only statement in the sequence: a ASAN_MARK statement for the array that
backs the initializer_list).

This patch simply checks that the finally block is not 0 before
accessing it in honor_protect_cleanup_actions.

PR c++/117845

gcc/ChangeLog:

* tree-eh.cc (honor_protect_cleanup_actions): Support empty
finally sequences.

gcc/testsuite/ChangeLog:

* g++.dg/asan/pr117845-2.C: New test.
* g++.dg/asan/pr117845.C: New test.

(cherry picked from commit 3076539544d3e36684cc8eed3374aeff5b44c9b1)

Diff:
---
 gcc/testsuite/g++.dg/asan/pr117845-2.C | 12 
 gcc/testsuite/g++.dg/asan/pr117845.C   | 12 
 gcc/tree-eh.cc |  5 +++--
 3 files changed, 27 insertions(+), 2 deletions(-)

diff --git a/gcc/testsuite/g++.dg/asan/pr117845-2.C 
b/gcc/testsuite/g++.dg/asan/pr117845-2.C
new file mode 100644
index ..c05563970091
--- /dev/null
+++ b/gcc/testsuite/g++.dg/asan/pr117845-2.C
@@ -0,0 +1,12 @@
+// PR c++/117845 - Actually valid variant
+// { dg-do "compile" }
+// { dg-options "-fsanitize=address" }
+
+#include 
+
+void l() {
+auto const ints = {0,1,2,3,4,5};
+for (auto i : { 3 } ) {
+__builtin_printf("%d ", i);
+}
+}
diff --git a/gcc/testsuite/g++.dg/asan/pr117845.C 
b/gcc/testsuite/g++.dg/asan/pr117845.C
new file mode 100644
index ..d90d351e2701
--- /dev/null
+++ b/gcc/testsuite/g++.dg/asan/pr117845.C
@@ -0,0 +1,12 @@
+// PR c++/117845 - Initially reported case.
+// { dg-do "compile" }
+// { dg-options "-fsanitize=address" }
+
+#include 
+
+void l() {
+auto const ints = {0,1,2,3,4,5};
+for (int i : ints | h) { // { dg-error "was not declared" }
+__builtin_printf("%d ", i);
+}
+}
diff --git a/gcc/tree-eh.cc b/gcc/tree-eh.cc
index 199b6d5d0051..a8de341e562a 100644
--- a/gcc/tree-eh.cc
+++ b/gcc/tree-eh.cc
@@ -1025,8 +1025,9 @@ honor_protect_cleanup_actions (struct leh_state 
*outer_state,
 terminate before we get to it, so strip it away before adding the
 MUST_NOT_THROW filter.  */
   gimple_stmt_iterator gsi = gsi_start (finally);
-  gimple *x = gsi_stmt (gsi);
-  if (gimple_code (x) == GIMPLE_TRY
+  gimple *x = !gsi_end_p (gsi) ? gsi_stmt (gsi) : NULL;
+  if (x
+ && gimple_code (x) == GIMPLE_TRY
  && gimple_try_kind (x) == GIMPLE_TRY_CATCH
  && gimple_try_catch_is_cleanup (x))
{


[gcc r15-6037] RISC-V: Refine signed SAT_TRUNC testcase dump check to tree optimized

2024-12-09 Thread Pan Li via Gcc-cvs
https://gcc.gnu.org/g:dbd6e147aaed246251351a4d48586fa965b6ee71

commit r15-6037-gdbd6e147aaed246251351a4d48586fa965b6ee71
Author: Pan Li 
Date:   Sun Dec 8 09:32:30 2024 +0800

RISC-V: Refine signed SAT_TRUNC testcase dump check to tree optimized

The sat alu related testcase check the rtl dump for the standard name
like .SAT_TRUNC exist or not.  But the rtl pass expand is somehow
impressionable by the middle-end change or debug information.  Like
below new appearance recently.

Replacing Expressions
_5 replace with --> _5 = .SAT_TRUNC (x_3(D), y_4(D)); [tail call]

After that we need to adjust the dump check time and again.  This
patch would like to switch to tree optimized pass for the standard
name check, which is more stable up to a point.

The below test suites are passed for this patch.
* The rv64gcv fully regression test.

It is test only patch and obvious up to a point, will commit it
directly if no comments in next 48H.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/sat/sat_s_trunc-1-i16-to-i8.c: Take 
tree-optimized
pass for standard name check, and adjust the times.
* gcc.target/riscv/sat/sat_s_trunc-1-i32-to-i16.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-1-i32-to-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-1-i64-to-i16.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-1-i64-to-i32.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-1-i64-to-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-2-i16-to-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-2-i32-to-i16.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-2-i32-to-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-2-i64-to-i16.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-2-i64-to-i32.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-2-i64-to-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-3-i16-to-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-3-i32-to-i16.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-3-i32-to-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-3-i64-to-i16.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-3-i64-to-i32.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-3-i64-to-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-4-i16-to-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-4-i32-to-i16.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-4-i32-to-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-4-i64-to-i16.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-4-i64-to-i32.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-4-i64-to-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-5-i16-to-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-5-i32-to-i16.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-5-i32-to-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-5-i64-to-i16.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-5-i64-to-i32.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-5-i64-to-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-6-i16-to-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-6-i32-to-i16.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-6-i32-to-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-6-i64-to-i16.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-6-i64-to-i32.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-6-i64-to-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-7-i16-to-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-7-i32-to-i16.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-7-i32-to-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-7-i64-to-i16.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-7-i64-to-i32.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-7-i64-to-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-8-i16-to-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-8-i32-to-i16.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-8-i32-to-i8.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-8-i64-to-i16.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-8-i64-to-i32.c: Ditto.
* gcc.target/riscv/sat/sat_s_trunc-8-i64-to-i8.c: Ditto.

Signed-off-by: Pan Li 

Diff:
---
 gcc/testsuite/gcc.target/riscv/sat/sat_s_trunc-1-i16-to-i8.c  | 4 ++--
 gcc/testsuite/gcc.target/riscv/sat/sat_s_trunc-1-i32-to-i16.c | 4 ++--
 gcc/testsuite/gcc.target/riscv/sat/sat_s_trunc-1-i32-to-i8.c  | 4 ++--
 gcc/testsuite/gcc.target/riscv/sat/sat_s_trunc-1-i64-to-i16.c | 4 ++--
 gcc/testsuite/gcc.target/riscv/sat/sat_s_trunc-1-i64-to-i32.c | 4 ++--
 gcc/testsuite/gcc.target/riscv/sat/sat_s_trunc-1-i64-to-i8.c  | 4 ++--
 gcc/testsuite/gcc.target/riscv/sat/sat_s_trunc-2-i1

[gcc r15-6033] RISC-V: Refine unsigned SAT_SUB testcase dump check to tree optimized

2024-12-09 Thread Pan Li via Gcc-cvs
https://gcc.gnu.org/g:4a783eb38a0f12b3d6f905e5085e51686f4f482b

commit r15-6033-g4a783eb38a0f12b3d6f905e5085e51686f4f482b
Author: Pan Li 
Date:   Sun Dec 8 09:32:26 2024 +0800

RISC-V: Refine unsigned SAT_SUB testcase dump check to tree optimized

The sat alu related testcase check the rtl dump for the standard name
like .SAT_SUB exist or not.  But the rtl pass expand is somehow
impressionable by the middle-end change or debug information.  Like
below new appearance recently.

Replacing Expressions
_5 replace with --> _5 = .SAT_SUB (x_3(D), y_4(D)); [tail call]

After that we need to adjust the dump check time and again.  This
patch would like to switch to tree optimized pass for the standard
name check, which is more stable up to a point.

The below test suites are passed for this patch.
* The rv64gcv fully regression test.

It is test only patch and obvious up to a point, will commit it
directly if no comments in next 48H.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/sat/sat_u_sub-1-u16.c: Take tree-optimized
pass for standard name check, and adjust the times.
* gcc.target/riscv/sat/sat_u_sub-1-u32.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-1-u64.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-1-u8.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-10-u16.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-10-u32.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-10-u64.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-10-u8.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-11-u16.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-11-u32.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-11-u64.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-11-u8.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-12-u16.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-12-u32.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-12-u64.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-12-u8.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-2-u16.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-2-u32.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-2-u64.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-2-u8.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-3-u16.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-3-u32.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-3-u64.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-3-u8.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-4-u16.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-4-u32.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-4-u64.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-4-u8.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-5-u16.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-5-u32.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-5-u64.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-5-u8.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-6-u16.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-6-u32.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-6-u64.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-6-u8.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-7-u16.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-7-u32.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-7-u64.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-7-u8.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-8-u16.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-8-u32.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-8-u64.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-8-u8.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-9-u16.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-9-u32.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-9-u64.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub-9-u8.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-1-u16-1.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-1-u16-2.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-1-u16-3.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-1-u16-4.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-1-u16.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-1-u32-1.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-1-u32-2.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-1-u32-3.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-1-u32-4.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-1-u32.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-1-u64-1.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-1-u64-2.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-1-u64.c: Ditto.
* gcc.target/riscv/sat/sat_u_sub_imm-1-u8-1.c: Ditto.
 

[gcc r15-6038] arm: remove obsolete vcond expanders

2024-12-09 Thread Richard Earnshaw via Gcc-cvs
https://gcc.gnu.org/g:2c9b69594665a87f74c6d5cb39fc6e075d75d771

commit r15-6038-g2c9b69594665a87f74c6d5cb39fc6e075d75d771
Author: Richard Earnshaw 
Date:   Fri Dec 6 12:57:52 2024 +

arm: remove obsolete vcond expanders

The vcond{,u} expander paterns have been declared as obsolete.  Remove
them from the Arm backend.

gcc/ChangeLog:

PR target/114189
* config/arm/arm-protos.h (arm_expand_vcond): Delete prototype.
* config/arm/arm.cc (arm_expand_vcond): Delete function.
* config/arm/vec-common.md (vcond): Delete pattern
(vcond): Likewise.
(vcond): Likewise.
(vcondu): Likewise.

Diff:
---
 gcc/config/arm/arm-protos.h  |  1 -
 gcc/config/arm/arm.cc| 44 ---
 gcc/config/arm/vec-common.md | 71 
 3 files changed, 116 deletions(-)

diff --git a/gcc/config/arm/arm-protos.h b/gcc/config/arm/arm-protos.h
index 7311ad4d8e4a..155507f4745d 100644
--- a/gcc/config/arm/arm-protos.h
+++ b/gcc/config/arm/arm-protos.h
@@ -406,7 +406,6 @@ extern bool arm_expand_vector_compare (rtx, rtx_code, rtx, 
rtx, bool);
 #endif /* RTX_CODE */
 
 extern bool arm_gen_setmem (rtx *);
-extern void arm_expand_vcond (rtx *, machine_mode);
 extern void arm_expand_vec_perm (rtx target, rtx op0, rtx op1, rtx sel);
 
 extern bool arm_autoinc_modes_ok_p (machine_mode, enum arm_auto_incmodes);
diff --git a/gcc/config/arm/arm.cc b/gcc/config/arm/arm.cc
index 1fbc4c22f223..bc6f9345d1e8 100644
--- a/gcc/config/arm/arm.cc
+++ b/gcc/config/arm/arm.cc
@@ -31803,50 +31803,6 @@ arm_expand_vector_compare (rtx target, rtx_code code, 
rtx op0, rtx op1,
 }
 }
 
-/* Expand a vcond or vcondu pattern with operands OPERANDS.
-   CMP_RESULT_MODE is the mode of the comparison result.  */
-
-void
-arm_expand_vcond (rtx *operands, machine_mode cmp_result_mode)
-{
-  /* When expanding for MVE, we do not want to emit a (useless) vpsel in
- arm_expand_vector_compare, and another one here.  */
-  rtx mask;
-
-  if (TARGET_HAVE_MVE)
-mask = gen_reg_rtx (arm_mode_to_pred_mode (cmp_result_mode).require ());
-  else
-mask = gen_reg_rtx (cmp_result_mode);
-
-  bool inverted = arm_expand_vector_compare (mask, GET_CODE (operands[3]),
-operands[4], operands[5], true);
-  if (inverted)
-std::swap (operands[1], operands[2]);
-  if (TARGET_NEON)
-  emit_insn (gen_neon_vbsl (GET_MODE (operands[0]), operands[0],
-   mask, operands[1], operands[2]));
-  else
-{
-  machine_mode cmp_mode = GET_MODE (operands[0]);
-
-  switch (GET_MODE_CLASS (cmp_mode))
-   {
-   case MODE_VECTOR_INT:
- emit_insn (gen_mve_q (VPSELQ_S, VPSELQ_S, cmp_mode, operands[0],
-   operands[1], operands[2], mask));
- break;
-   case MODE_VECTOR_FLOAT:
- if (TARGET_HAVE_MVE_FLOAT)
-   emit_insn (gen_mve_q_f (VPSELQ_F, cmp_mode, operands[0],
-   operands[1], operands[2], mask));
- else
-   gcc_unreachable ();
- break;
-   default:
- gcc_unreachable ();
-   }
-}
-}
 
 #define MAX_VECT_LEN 16
 
diff --git a/gcc/config/arm/vec-common.md b/gcc/config/arm/vec-common.md
index ff1c27a0d717..0b426cdaff7f 100644
--- a/gcc/config/arm/vec-common.md
+++ b/gcc/config/arm/vec-common.md
@@ -416,77 +416,6 @@
 }
 })
 
-;; Conditional instructions.  These are comparisons with conditional moves for
-;; vectors.  They perform the assignment:
-;;
-;; Vop0 = (Vop4  Vop5) ? Vop1 : Vop2;
-;;
-;; where op3 is <, <=, ==, !=, >= or >.  Operations are performed
-;; element-wise.
-
-(define_expand "vcond"
-  [(set (match_operand:VDQWH 0 "s_register_operand")
-   (if_then_else:VDQWH
- (match_operator 3 "comparison_operator"
-   [(match_operand:VDQWH 4 "s_register_operand")
-(match_operand:VDQWH 5 "reg_or_zero_operand")])
- (match_operand:VDQWH 1 "s_register_operand")
- (match_operand:VDQWH 2 "s_register_operand")))]
-  "ARM_HAVE__ARITH
-   && !TARGET_REALLY_IWMMXT
-   && (! || flag_unsafe_math_optimizations)"
-{
-  arm_expand_vcond (operands, mode);
-  DONE;
-})
-
-(define_expand "vcond"
-  [(set (match_operand: 0 "s_register_operand")
-   (if_then_else:
- (match_operator 3 "comparison_operator"
-   [(match_operand:V32 4 "s_register_operand")
-(match_operand:V32 5 "reg_or_zero_operand")])
- (match_operand: 1 "s_register_operand")
- (match_operand: 2 "s_register_operand")))]
-  "ARM_HAVE__ARITH
-   && !TARGET_REALLY_IWMMXT
-   && (! || flag_unsafe_math_optimizations)"
-{
-  arm_expand_vcond (operands, mode);
-  DONE;
-})
-
-(define_expand "vcond"
-  [(set (match_operand: 0 "s_register_operand")
-   (if_then_else:
- (match_operator 3 "comparison_operator"
-   [(match_operand:V16 4 "s_register_op

[gcc r15-6041] PR modula2/115328: use enable forward bool and set default true

2024-12-09 Thread Gaius Mulley via Gcc-cvs
https://gcc.gnu.org/g:548afd73cdbf310403a1e3f34226372c16c29706

commit r15-6041-g548afd73cdbf310403a1e3f34226372c16c29706
Author: Gaius Mulley 
Date:   Mon Dec 9 13:56:37 2024 +

PR modula2/115328: use enable forward bool and set default true

This patch introduces GetEnableForward and SetEnableForward
against which the forward procedure declaration feature is checked.
Currently this is set as default true.

gcc/m2/ChangeLog:

PR modula2/115328
* gm2-compiler/M2Options.def (GetEnableForward): New procedure
function.
(SetEnableForward): New procedure.
* gm2-compiler/M2Options.mod (GetEnableForward): New procedure
function.
(SetEnableForward): New procedure.
(EnableForward): New boolean.
* gm2-compiler/P1SymBuild.mod (EndBuildForward): Check
GetEnableForward and generate an error message if false.

gcc/testsuite/ChangeLog:

PR modula2/115328
* gm2/pim/fail/forward.mod: Move to...
* gm2/pim/pass/forward.mod: ...here.

Signed-off-by: Gaius Mulley 

Diff:
---
 gcc/m2/gm2-compiler/M2Options.def| 14 ++
 gcc/m2/gm2-compiler/M2Options.mod| 24 +++-
 gcc/m2/gm2-compiler/P1SymBuild.mod   |  6 +++---
 gcc/testsuite/gm2/pim/{fail => pass}/forward.mod |  0
 4 files changed, 40 insertions(+), 4 deletions(-)

diff --git a/gcc/m2/gm2-compiler/M2Options.def 
b/gcc/m2/gm2-compiler/M2Options.def
index baa5d7ec897f..1f483e6611ec 100644
--- a/gcc/m2/gm2-compiler/M2Options.def
+++ b/gcc/m2/gm2-compiler/M2Options.def
@@ -1121,6 +1121,20 @@ PROCEDURE GetDebugTraceLine () : BOOLEAN ;
 PROCEDURE GetDebugFunctionLineNumbers () : BOOLEAN ;
 
 
+(*
+   GetEnableForward - return EnableForward.
+*)
+
+PROCEDURE GetEnableForward () : BOOLEAN ;
+
+
+(*
+   SetEnableForward - set EnableForward to value.
+*)
+
+PROCEDURE SetEnableForward (value: BOOLEAN) ;
+
+
 (*
FinaliseOptions - once all options have been parsed we set any inferred
  values.
diff --git a/gcc/m2/gm2-compiler/M2Options.mod 
b/gcc/m2/gm2-compiler/M2Options.mod
index 4048144f48e5..8f4e326beb25 100644
--- a/gcc/m2/gm2-compiler/M2Options.mod
+++ b/gcc/m2/gm2-compiler/M2Options.mod
@@ -76,6 +76,7 @@ VAR
UselistFilename,
RuntimeModuleOverride,
CppArgs  : String ;
+   EnableForward,
DebugFunctionLineNumbers,
DebugTraceQuad,   (* -fm2-debug-trace=quad.  *)
DebugTraceLine,   (* -fm2-debug-trace=line.  *)
@@ -2008,6 +2009,26 @@ BEGIN
 END GetDumpDecl ;
 
 
+(*
+   GetEnableForward - return EnableForward.
+*)
+
+PROCEDURE GetEnableForward () : BOOLEAN ;
+BEGIN
+   RETURN EnableForward
+END GetEnableForward ;
+
+
+(*
+   SetEnableForward - set EnableForward to value.
+*)
+
+PROCEDURE SetEnableForward (value: BOOLEAN) ;
+BEGIN
+   EnableForward := value
+END SetEnableForward ;
+
+
 BEGIN
cflag := FALSE ;  (* -c.  *)
RuntimeModuleOverride := InitString 
(DefaultRuntimeModuleOverride) ;
@@ -2099,5 +2120,6 @@ BEGIN
DumpQuad  := FALSE ;
DumpGimple:= FALSE ;
M2Dump:= NIL ;
-   M2DumpFilter  := NIL
+   M2DumpFilter  := NIL ;
+   EnableForward := TRUE
 END M2Options.
diff --git a/gcc/m2/gm2-compiler/P1SymBuild.mod 
b/gcc/m2/gm2-compiler/P1SymBuild.mod
index cd42417a3948..e916fb6c66dc 100644
--- a/gcc/m2/gm2-compiler/P1SymBuild.mod
+++ b/gcc/m2/gm2-compiler/P1SymBuild.mod
@@ -32,7 +32,7 @@ FROM M2MetaError IMPORT MetaErrorString2, MetaError0, 
MetaError1,
 
 FROM DynamicStrings IMPORT String, Slice, InitString, KillString, 
EqualCharStar, RIndex, Mark, ConCat ;
 FROM M2Printf IMPORT printf0, printf1, printf2 ;
-FROM M2Options IMPORT Iso ;
+FROM M2Options IMPORT Iso, GetEnableForward ;
 
 FROM M2Reserved IMPORT ImportTok, ExportTok, QualifiedTok, UnQualifiedTok,
NulTok, VarTok, ArrayTok, BuiltinTok, InlineTok ;
@@ -1074,10 +1074,10 @@ VAR
 BEGIN
ProcSym := OperandT (1) ;
tok := OperandTok (1) ;
-   IF NOT Iso
+   IF NOT GetEnableForward ()
THEN
   MetaErrorT0 (forwardPos,
-   'forward declaration is only allowed in the ISO dialect of 
Modula-2')
+   'forward declaration has not been enabled, use -fiso or 
-fenable-forward to enable forward procedure declarations')
END ;
IF GetProcedureDefined (ProcSym, ForwardProcedure)
THEN
diff --git a/gcc/testsuite/gm2/pim/fail/forward.mod 
b/gcc/testsuite/gm2/pim/pass/forward.mod
similarity index 100%
rename from gcc/testsuite/gm2/pim/fail/forward.mod
rename to gcc/testsuite/gm2/pim/pass/forward.mod


[gcc r15-6042] c++: Allow overloaded builtins to be used in SFINAE context

2024-12-09 Thread Matthew Malcomson via Gcc-cvs
https://gcc.gnu.org/g:9ed094a817ecaf43c79505286759b88eb0555be2

commit r15-6042-g9ed094a817ecaf43c79505286759b88eb0555be2
Author: Matthew Malcomson 
Date:   Mon Oct 7 16:42:41 2024 +0100

c++: Allow overloaded builtins to be used in SFINAE context

This commit newly introduces the ability to use overloaded builtins in
C++ SFINAE context.

The goal behind this is in order to ensure there is a single mechanism
that libstdc++ can use to determine whether a given type can be used in
the atomic fetch_add (and similar) builtins.  I am working on another
patch that hopes to use this mechanism to identify whether fetch_add
(and similar) work on floating point types.

Current state of the world:

GCC currently exposes resolved versions of these builtins to the
user, so for GCC it's currently possible to use tests similar to the
below to check for atomic loads on a 2 byte sized object.
  #if __has_builtin(__atomic_load_2)
Clang does not expose resolved versions of the atomic builtins.

clang currently allows SFINAE on builtins, so that C++ code can
check whether a builtin is available on a given type.
GCC does not (and that is what this patch aims to change).

C libraries like libatomic can check whether a given atomic builtin
can work on a given type by using autoconf to check for a
miscompilation when attempting such a use.

My goal:
I would like to enable floating point fetch_add (and similar) in
GCC, in order to use those overloads in libstdc++ implementation of
atomic::fetch_add.
This should allow compilers targeting GPU's which have floating
point fetch_add instructions to emit optimal code.

In order to do that I need some consistent mechanism that libstdc++
can use to identify whether the fetch_add builtins have floating
point overloads (and for which types these exist).

I would hence like to enable SFINAE on builtins, so that libstdc++
can use that mechanism for the floating point fetch_add builtins.

Implementation follows the existing mechanism for handling SFINAE
contexts in c-common.cc.  A boolean is passed into the c-common.cc
function indicating whether these functions should emit errors or not.
This boolean comes from `complain & tf_error` in the C++ frontend.
(Similar to other functions like valid_array_size_p and
c_build_vec_perm_expr).

This is done both for resolve_overloaded_builtin and
check_builtin_function_arguments, both of which can be used in SFINAE
contexts.
I attempted to trigger something using the `reject_gcc_builtin`
function in an SFINAE context.  Given the context where this
function is called from the C++ frontend it looks like it may be
possible, but I did not manage to trigger this in template context
by attempting to do something similar to the testcases added around
those calls.
- I would appreciate any feedback on whether this is something that
  can happen in a template context, and if so some help writing a
  relevant testcase for it.

Both of these functions have target hooks for target specific builtins
that I have updated to take the extra boolean flag.  I have not adjusted
the functions implementing those target hooks (except to update the
declarations) so target specific builtins will still error in SFINAE
contexts.
- I could imagine not updating the target hook definition since nothing
  would use that change.  However I figure that allowing targets to
  decide this behaviour would be the right thing to do eventually, and
  since this is the target-independent part of the change to do that
  this patch should make that change.
  Could adjust if others disagree.

Other relevant points that I'd appreciate reviewers check:
- I did not pass this new flag through
  atomic_bitint_fetch_using_cas_loop since the _BitInt type is not
  available in the C++ frontend and I didn't want if conditions that can
  not be executed in the source.
- I only test non-compile-time-constant types with SVE types, since I do
  not know of a way to get a VLA into a SFINAE context.
- While writing tests I noticed a few differences with clang in this
  area.  I don't think they are problematic but am mentioning them for
  completeness and to allow others to judge if these are a problem).
  - atomic_fetch_add on a boolean is allowed by clang.
  - When __atomic_load is passed an invalid memory model (i.e. too
large), we give an SFINAE failure while clang does not.

Bootstrap and regression tested on AArch64 and x86_64.
Built first stage on targets whose target hook declaration needed
updated (though did not regtest etc).  T

[gcc r15-6043] s390: Fix UNSPEC_CC_TO_INT canonicalization

2024-12-09 Thread Juergen Christ via Gcc-cvs
https://gcc.gnu.org/g:bdc572f9a42b6a68dec1a5593d5311f45bd29cc9

commit r15-6043-gbdc572f9a42b6a68dec1a5593d5311f45bd29cc9
Author: Juergen Christ 
Date:   Fri Dec 6 18:52:36 2024 +0100

s390: Fix UNSPEC_CC_TO_INT canonicalization

Canonicalization of comparisons for UNSPEC_CC_TO_INT missed one case
causing unnecessarily complex code.  This especially seems to hit the
Linux kernel.

gcc/ChangeLog:

* config/s390/s390.cc (s390_canonicalize_comparison): Add
missing UNSPEC_CC_TO_INT case.

gcc/testsuite/ChangeLog:

* gcc.target/s390/ccusage.c: New test.

Signed-off-by: Juergen Christ 

Diff:
---
 gcc/config/s390/s390.cc |  2 +-
 gcc/testsuite/gcc.target/s390/ccusage.c | 37 +
 2 files changed, 38 insertions(+), 1 deletion(-)

diff --git a/gcc/config/s390/s390.cc b/gcc/config/s390/s390.cc
index cec054852c9b..573b22902469 100644
--- a/gcc/config/s390/s390.cc
+++ b/gcc/config/s390/s390.cc
@@ -1859,7 +1859,7 @@ s390_canonicalize_comparison (int *code, rtx *op0, rtx 
*op1,
   && CONST_INT_P (XEXP (*op0, 1))
   && CONST_INT_P (*op1)
   && INTVAL (XEXP (*op0, 1)) == -3
-  && *code == EQ)
+  && (*code == EQ || *code == NE))
 {
   if (INTVAL (*op1) == 0)
{
diff --git a/gcc/testsuite/gcc.target/s390/ccusage.c 
b/gcc/testsuite/gcc.target/s390/ccusage.c
new file mode 100644
index ..e25f712e25ca
--- /dev/null
+++ b/gcc/testsuite/gcc.target/s390/ccusage.c
@@ -0,0 +1,37 @@
+/* { dg-do compile } */
+/* { dg-options "-O3 -march=zEC12 -mzarch" } */
+
+static __attribute__((always_inline)) inline
+int __atomic_dec_and_test(int *ptr)
+{
+int cc;
+asm volatile(
+"   alsi%[ptr],-1\n"
+: "=@cc" (cc), [ptr] "+QS" (*ptr) : : "memory");
+return (cc == 0) || (cc == 2);
+}
+ 
+int a;
+void dummy(void);
+long fu(void)
+{
+if (__atomic_dec_and_test(&a))
+return 5;
+return 8;
+}
+ 
+void bar(void)
+{
+if (__atomic_dec_and_test(&a))
+dummy();
+}
+
+int foo(int x)
+{
+int cc;
+asm volatile ("ahi %[x],42\n"
+: [x] "+d" (x), "=@cc" (cc));
+return !(cc == 0 || cc == 2) ? 42 : 13;
+}
+
+/* { dg-final { scan-assembler-not {ipm} } } */


[gcc r15-6046] [committed] RISC-V testsuite changes to test clmul expansion of CRCs

2024-12-09 Thread Jeff Law via Gcc-cvs
https://gcc.gnu.org/g:3537aa694d7d817ac13c3c2908bda45adfb95511

commit r15-6046-g3537aa694d7d817ac13c3c2908bda45adfb95511
Author: Mariam Arutunian 
Date:   Mon Dec 9 07:29:36 2024 -0700

[committed] RISC-V testsuite changes to test clmul expansion of CRCs

This testsuite only patch allows us to test code generation for CRC 
functions
using clmul instructions.

Conceptually it's trivial.  We already have various execution tests in
gcc.dg/torture.  We just define a new set of dg directives and include the
testcase in gcc.dg/torture.

The only gotcha in here is the need to change target-supports.exp.  It was
passing the default set of arguments down to the check_runtime routine, so 
they
always failed to assemble the testcase and we never claimed the ability to
execute Zbc, Zbkb or Zbkc extension code.

Again, NFC, just testsuite bits.  Pushing to the trunk.

Only aarch64 and x86 bits left ;-)

gcc/testsuite
* gcc.target/riscv/crc-1-zbc.c: New test.
* gcc.target/riscv/crc-1-zbkc.c: Likewise.
* gcc.target/riscv/crc-10-zbc.c: Likewise.
* gcc.target/riscv/crc-10-zbkc.c: Likewise.
* gcc.target/riscv/crc-12-zbc.c: Likewise.
* gcc.target/riscv/crc-12-zbkc.c: Likewise.
* gcc.target/riscv/crc-13-zbc.c: Likewise.
* gcc.target/riscv/crc-13-zbkc.c: Likewise.
* gcc.target/riscv/crc-14-zbc.c: Likewise.
* gcc.target/riscv/crc-14-zbkc.c: Likewise.
* gcc.target/riscv/crc-17-zbc.c: Likewise.
* gcc.target/riscv/crc-17-zbkc.c: Likewise.
* gcc.target/riscv/crc-18-zbc.c: Likewise.
* gcc.target/riscv/crc-18-zbkc.c: Likewise.
* gcc.target/riscv/crc-21-rv64-zbc.c: Likewise.
* gcc.target/riscv/crc-21-rv64-zbkc.c: Likewise.
* gcc.target/riscv/crc-22-zbc.c: Likewise.
* gcc.target/riscv/crc-22-zbkc.c: Likewise.
* gcc.target/riscv/crc-23-zbc.c: Likewise.
* gcc.target/riscv/crc-23-zbkc.c: Likewise.
* gcc.target/riscv/crc-4-zbc.c: Likewise.
* gcc.target/riscv/crc-4-zbkb.c: Likewise.
* gcc.target/riscv/crc-4-zbkc.c: Likewise.
* gcc.target/riscv/crc-5-zbc.c: Likewise.
* gcc.target/riscv/crc-5-zbkb.c: Likewise.
* gcc.target/riscv/crc-5-zbkc.c: Likewise.
* gcc.target/riscv/crc-6-zbc.c: Likewise.
* gcc.target/riscv/crc-6-zbkc.c: Likewise.
* gcc.target/riscv/crc-7-zbc.c: Likewise.
* gcc.target/riscv/crc-7-zbkc.c: Likewise.
* gcc.target/riscv/crc-8-zbc.c: Likewise.
* gcc.target/riscv/crc-8-zbkc.c: Likewise.
* gcc.target/riscv/crc-9-zbc.c: Likewise.
* gcc.target/riscv/crc-9-zbkc.c: Likewise.
* gcc.target/riscv/crc-CCIT-data16-zbc.c: Likewise.
* gcc.target/riscv/crc-CCIT-data16-zbkc.c: Likewise.
* gcc.target/riscv/crc-CCIT-data8-zbc.c: Likewise.
* gcc.target/riscv/crc-CCIT-data8-zbkc.c: Likewise.
* gcc.target/riscv/crc-coremark-16bitdata-zbc.c: Likewise.
* gcc.target/riscv/crc-coremark-16bitdata-zbkc.c: Likewise.
* lib/target-supports.exp (check_effective_target_riscv_zbc_ok): Set
gcc_march before compiling test program.
(check_effective_target_riscv_zbkc_ok): Likewise.
(check_effective_target_riscv_zbkb_ok): Likewise.
Co-authored-by: Jeff Law 

Diff:
---
 gcc/testsuite/gcc.target/riscv/crc-1-zbc.c   | 10 ++
 gcc/testsuite/gcc.target/riscv/crc-1-zbkc.c  | 11 +++
 gcc/testsuite/gcc.target/riscv/crc-10-zbc.c  | 10 ++
 gcc/testsuite/gcc.target/riscv/crc-10-zbkc.c | 10 ++
 gcc/testsuite/gcc.target/riscv/crc-12-zbc.c  | 11 +++
 gcc/testsuite/gcc.target/riscv/crc-12-zbkc.c | 10 ++
 gcc/testsuite/gcc.target/riscv/crc-13-zbc.c  | 10 ++
 gcc/testsuite/gcc.target/riscv/crc-13-zbkc.c | 11 +++
 gcc/testsuite/gcc.target/riscv/crc-14-zbc.c  | 10 ++
 gcc/testsuite/gcc.target/riscv/crc-14-zbkc.c | 10 ++
 gcc/testsuite/gcc.target/riscv/crc-17-zbc.c  | 10 ++
 gcc/testsuite/gcc.target/riscv/crc-17-zbkc.c | 10 ++
 gcc/testsuite/gcc.target/riscv/crc-18-zbc.c  | 10 ++
 gcc/testsuite/gcc.target/riscv/crc-18-zbkc.c | 10 ++
 gcc/testsuite/gcc.target/riscv/crc-21-rv64-zbc.c | 10 ++
 gcc/testsuite/gcc.target/riscv/crc-21-rv64-zbkc.c| 10 ++
 gcc/testsuite/gcc.target/riscv/crc-22-zbc.c  | 10 ++
 gcc/testsuite/gcc.target/riscv/crc-22-zbkb.c |  9 +
 gcc/tests

[gcc(refs/users/mikael/heads/refactor_descriptor_v01)] Ajout conversion elem_len

2024-12-09 Thread Mikael Morin via Gcc-cvs
https://gcc.gnu.org/g:4ca9998c492206cdfb4d104056a70a7059688954

commit 4ca9998c492206cdfb4d104056a70a7059688954
Author: Mikael Morin 
Date:   Mon Dec 9 18:38:07 2024 +0100

Ajout conversion elem_len

Diff:
---
 gcc/fortran/trans-array.cc | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc
index b94d56110477..284c20eef8ed 100644
--- a/gcc/fortran/trans-array.cc
+++ b/gcc/fortran/trans-array.cc
@@ -625,7 +625,8 @@ build_dtype (gfc_typespec &ts, int rank, const 
symbol_attribute &)
   if (ts.type != BT_CLASS)
 {
   tree elem_len_field = gfc_advance_chain (fields, GFC_DTYPE_ELEM_LEN);
-  tree elem_len_val = get_size_info (ts);
+  tree elem_len_val = fold_convert (TREE_TYPE (elem_len_field),
+   get_size_info (ts));
   CONSTRUCTOR_APPEND_ELT (v, elem_len_field, elem_len_val);
 }


[gcc r15-6045] Free RTL SSA after late-combine

2024-12-09 Thread Richard Biener via Gcc-cvs
https://gcc.gnu.org/g:91bdaf659d23be61d1fa5c83ef02322bf0872c87

commit r15-6045-g91bdaf659d23be61d1fa5c83ef02322bf0872c87
Author: Richard Biener 
Date:   Mon Dec 9 14:10:34 2024 +0100

Free RTL SSA after late-combine

Late-combine fails to release RTL SSA info, leaking memory
(as -fmem-report shows).

* late-combine.cc (late_combine::execute): Delete RTL SSA.

Diff:
---
 gcc/late-combine.cc | 4 
 1 file changed, 4 insertions(+)

diff --git a/gcc/late-combine.cc b/gcc/late-combine.cc
index 1311f76f4431..d3587bc78da1 100644
--- a/gcc/late-combine.cc
+++ b/gcc/late-combine.cc
@@ -730,6 +730,10 @@ late_combine::execute (function *fn)
   // Finalization.
   if (crtl->ssa->perform_pending_updates ())
 cleanup_cfg (0);
+
+  delete crtl->ssa;
+  crtl->ssa = nullptr;
+
   // Make the recognizer allow volatile MEMs again.
   init_recog ();
   free_dominance_info (CDI_DOMINATORS);


[gcc r14-11076] s390: Fix UNSPEC_CC_TO_INT canonicalization

2024-12-09 Thread Juergen Christ via Gcc-cvs
https://gcc.gnu.org/g:7b58a7e27afac52ca630d5db523503b75c732305

commit r14-11076-g7b58a7e27afac52ca630d5db523503b75c732305
Author: Juergen Christ 
Date:   Mon Dec 9 15:26:54 2024 +0100

s390: Fix UNSPEC_CC_TO_INT canonicalization

Canonicalization of comparisons for UNSPEC_CC_TO_INT missed one case
causing unnecessarily complex code.  This especially seems to hit the
Linux kernel.

gcc/ChangeLog:

* config/s390/s390.cc (s390_canonicalize_comparison): Add
missing UNSPEC_CC_TO_INT case.

gcc/testsuite/ChangeLog:

* gcc.target/s390/ccusage.c: New test.

Signed-off-by: Juergen Christ 
(cherry picked from commit bdc572f9a42b6a68dec1a5593d5311f45bd29cc9)

Diff:
---
 gcc/config/s390/s390.cc |  2 +-
 gcc/testsuite/gcc.target/s390/ccusage.c | 37 +
 2 files changed, 38 insertions(+), 1 deletion(-)

diff --git a/gcc/config/s390/s390.cc b/gcc/config/s390/s390.cc
index a1c0a57a795f..f2e4f5e101cb 100644
--- a/gcc/config/s390/s390.cc
+++ b/gcc/config/s390/s390.cc
@@ -1859,7 +1859,7 @@ s390_canonicalize_comparison (int *code, rtx *op0, rtx 
*op1,
   && CONST_INT_P (XEXP (*op0, 1))
   && CONST_INT_P (*op1)
   && INTVAL (XEXP (*op0, 1)) == -3
-  && *code == EQ)
+  && (*code == EQ || *code == NE))
 {
   if (INTVAL (*op1) == 0)
{
diff --git a/gcc/testsuite/gcc.target/s390/ccusage.c 
b/gcc/testsuite/gcc.target/s390/ccusage.c
new file mode 100644
index ..e25f712e25ca
--- /dev/null
+++ b/gcc/testsuite/gcc.target/s390/ccusage.c
@@ -0,0 +1,37 @@
+/* { dg-do compile } */
+/* { dg-options "-O3 -march=zEC12 -mzarch" } */
+
+static __attribute__((always_inline)) inline
+int __atomic_dec_and_test(int *ptr)
+{
+int cc;
+asm volatile(
+"   alsi%[ptr],-1\n"
+: "=@cc" (cc), [ptr] "+QS" (*ptr) : : "memory");
+return (cc == 0) || (cc == 2);
+}
+ 
+int a;
+void dummy(void);
+long fu(void)
+{
+if (__atomic_dec_and_test(&a))
+return 5;
+return 8;
+}
+ 
+void bar(void)
+{
+if (__atomic_dec_and_test(&a))
+dummy();
+}
+
+int foo(int x)
+{
+int cc;
+asm volatile ("ahi %[x],42\n"
+: [x] "+d" (x), "=@cc" (cc));
+return !(cc == 0 || cc == 2) ? 42 : 13;
+}
+
+/* { dg-final { scan-assembler-not {ipm} } } */


[gcc(refs/users/mikael/heads/refactor_descriptor_v01)] Correction segmentation fault

2024-12-09 Thread Mikael Morin via Gcc-cvs
https://gcc.gnu.org/g:10b9b3ee1c1fbe8de7b654e9e2001e7a57fc21a7

commit 10b9b3ee1c1fbe8de7b654e9e2001e7a57fc21a7
Author: Mikael Morin 
Date:   Mon Dec 9 16:39:50 2024 +0100

Correction segmentation fault

Diff:
---
 gcc/fortran/trans-array.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc
index 6dfccf1cc6ba..b94d56110477 100644
--- a/gcc/fortran/trans-array.cc
+++ b/gcc/fortran/trans-array.cc
@@ -584,7 +584,7 @@ get_size_info (gfc_typespec &ts)
 case BT_COMPLEX:
 case BT_DERIVED:
 case BT_UNSIGNED:
-  return size_in_bytes (TREE_TYPE (gfc_typenode_for_spec (&ts)));
+  return size_in_bytes (gfc_typenode_for_spec (&ts));
 
 case BT_CHARACTER:
   {


[gcc/devel/rust/master] ci: Update expected warnings list for 32 bits build.

2024-12-09 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:b1273464c26b0f99f373889806b97786f54dc0bc

commit b1273464c26b0f99f373889806b97786f54dc0bc
Author: Arthur Cohen 
Date:   Mon Dec 9 13:35:49 2024 +0100

ci: Update expected warnings list for 32 bits build.

ChangeLog:

* .github/alpine_32bit_log_warnings: Update with new warnings.

Diff:
---
 .github/alpine_32bit_log_warnings | 26 +++---
 1 file changed, 3 insertions(+), 23 deletions(-)

diff --git a/.github/alpine_32bit_log_warnings 
b/.github/alpine_32bit_log_warnings
index 32a83ef1078c..9c99c7c14029 100644
--- a/.github/alpine_32bit_log_warnings
+++ b/.github/alpine_32bit_log_warnings
@@ -62,34 +62,14 @@
 ../../../libgcc/soft-fp/op-common.h:1563:25: warning: comparison of integer 
expressions of different signedness: ‘int’ and ‘USItype’ {aka ‘unsigned int’} 
[-Wsign-compare]
 ../../../libgcc/soft-fp/op-common.h:1563:25: warning: comparison of integer 
expressions of different signedness: ‘int’ and ‘USItype’ {aka ‘unsigned int’} 
[-Wsign-compare]
 ../../../libgcc/soft-fp/op-common.h:1563:25: warning: comparison of integer 
expressions of different signedness: ‘int’ and ‘USItype’ {aka ‘unsigned int’} 
[-Wsign-compare]
-../../gcc/analyzer/store.h:310:5: warning: 
'size_in_bytes.generic_wide_int 
>::.fixed_wide_int_storage<128>::val[1]' may be used uninitialized 
[-Wmaybe-uninitialized]
+../../gcc/../libgcc/libgcov-util.c:214:59: warning: 'void* calloc(size_t, 
size_t)' sizes specified with 'sizeof' in the earlier argument and not in the 
later argument [-Wcalloc-transposed-args]
+../../gcc/../libgcc/libgcov-util.c:529:43: warning: 'void* calloc(size_t, 
size_t)' sizes specified with 'sizeof' in the earlier argument and not in the 
later argument [-Wcalloc-transposed-args]
+../../gcc/analyzer/store.h:310:5: warning: 
'size_in_bytes.generic_wide_int 
>::fixed_wide_int_storage<128>.fixed_wide_int_storage<128>::val[1]' may be used 
uninitialized [-Wmaybe-uninitialized]
 ../../gcc/expmed.cc:1845:45: warning: '*(unsigned int*)((char*)&imode + 
offsetof(scalar_int_mode, scalar_int_mode::m_mode))' may be used uninitialized 
[-Wmaybe-uninitialized]
-../../gcc/gcc.cc:2412:30: warning: too many arguments for format 
[-Wformat-extra-args]
-../../gcc/gcc.cc:2413:32: warning: unknown conversion type character 't' in 
format [-Wformat=]
-../../gcc/gcc.cc:2432:30: warning: too many arguments for format 
[-Wformat-extra-args]
-../../gcc/gcc.cc:2433:32: warning: unknown conversion type character 't' in 
format [-Wformat=]
-../../gcc/gcc.cc:2458:30: warning: too many arguments for format 
[-Wformat-extra-args]
-../../gcc/gcc.cc:2459:32: warning: unknown conversion type character 't' in 
format [-Wformat=]
-../../gcc/gcc.cc:2467:30: warning: too many arguments for format 
[-Wformat-extra-args]
-../../gcc/gcc.cc:2468:32: warning: unknown conversion type character 't' in 
format [-Wformat=]
-../../gcc/gcc.cc:2477:30: warning: too many arguments for format 
[-Wformat-extra-args]
-../../gcc/gcc.cc:2478:32: warning: unknown conversion type character 't' in 
format [-Wformat=]
-../../gcc/gcc.cc:2487:30: warning: too many arguments for format 
[-Wformat-extra-args]
-../../gcc/gcc.cc:2488:32: warning: unknown conversion type character 't' in 
format [-Wformat=]
-../../gcc/gcc.cc:2527:26: warning: too many arguments for format 
[-Wformat-extra-args]
-../../gcc/gcc.cc:2527:59: warning: unknown conversion type character 't' in 
format [-Wformat=]
-../../gcc/gcc.cc:2539:22: warning: too many arguments for format 
[-Wformat-extra-args]
-../../gcc/gcc.cc:2539:51: warning: unknown conversion type character 't' in 
format [-Wformat=]
-../../gcc/gcc.cc:2553:22: warning: too many arguments for format 
[-Wformat-extra-args]
-../../gcc/gcc.cc:2553:51: warning: unknown conversion type character 't' in 
format [-Wformat=]
 ../../gcc/text-art/style.cc:150:25: warning: spurious leading punctuation 
sequence ';' in format [-Wformat-diag]
 ../../gcc/text-art/style.cc:160:25: warning: spurious leading punctuation 
sequence ';' in format [-Wformat-diag]
 ../../gcc/text-art/table.cc:981:62: warning: unquoted keyword 'char' in format 
[-Wformat-diag]
 ../../gcc/text-art/table.cc:981:69: warning: spurious trailing punctuation 
sequence '])' in format [-Wformat-diag]
-/usr/include/c++/13.2.1/bits/new_allocator.h:172:33: warning: 
'*(std::_Vector_base 
>*)((char*)&saved + offsetof(Rust::BIR::PatternBindingBuilder::SavedState, 
Rust::BIR::PatternBindingBuilder::SavedState::regions.tl::optional::.tl::detail::optional_move_assign_base::.tl::detail::optional_copy_assign_base::.tl::detail::optional_move_base::.tl::detail::optional_copy_base::.tl::detail::optional_operations_base::.tl::detail::optional_storage_base::)).std::_Vector_base >::_M_impl.std::_Vector_base 
>::_Vector_impl::.std::_Vector_base >::_Vector_impl_da
 ta::_M_start' may be used uninitialized [-Wmaybe-uninitialized]
-/usr/include/c++/13.2.1/bits/stl_vector.h:367:49: warning: 
'*(std::_Vector_base 
>*)((char*)&saved + offsetof(Rus

[gcc r15-6049] libstdc++: Add workaround for read(2) EINVAL on macOS and FreeBSD [PR102259]

2024-12-09 Thread Jonathan Wakely via Gcc-cvs
https://gcc.gnu.org/g:4065bf7c2c61dd6eb19fdccbcda99000d8e44b7a

commit r15-6049-g4065bf7c2c61dd6eb19fdccbcda99000d8e44b7a
Author: Jonathan Wakely 
Date:   Fri Dec 6 17:41:01 2024 +

libstdc++: Add workaround for read(2) EINVAL on macOS and FreeBSD [PR102259]

On macOS and FreeBSD the read(2) system call can return EINVAL for large
sizes, so limit the maximum that we try to read. The calling code in
basic_filebuf::xsgetn will loop until it gets the size it wants, so we don't
need to loop in basic_file::xsgetn, just limit the maximum size.

libstdc++-v3/ChangeLog:

PR libstdc++/102259
* config/io/basic_file_stdio.cc (basic_file::xsgetn): Limit n to
_GLIBCXX_MAX_READ_SIZE if that macro is defined.
* config/os/bsd/darwin/os_defines.h (_GLIBCXX_MAX_READ_SIZE):
Define to INT_MAX-1.
* config/os/bsd/freebsd/os_defines.h (_GLIBCXX_MAX_READ_SIZE):
Likewise.

Diff:
---
 libstdc++-v3/config/io/basic_file_stdio.cc  | 6 ++
 libstdc++-v3/config/os/bsd/darwin/os_defines.h  | 3 +++
 libstdc++-v3/config/os/bsd/freebsd/os_defines.h | 3 +++
 3 files changed, 12 insertions(+)

diff --git a/libstdc++-v3/config/io/basic_file_stdio.cc 
b/libstdc++-v3/config/io/basic_file_stdio.cc
index 9b529490f089..95e6905b3adf 100644
--- a/libstdc++-v3/config/io/basic_file_stdio.cc
+++ b/libstdc++-v3/config/io/basic_file_stdio.cc
@@ -338,6 +338,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 if (__ret == 0 && ferror(this->file()))
   __ret = -1;
 #else
+
+#ifdef _GLIBCXX_MAX_READ_SIZE
+if (__builtin_expect(__n > _GLIBCXX_MAX_READ_SIZE, 0))
+  __n = _GLIBCXX_MAX_READ_SIZE;
+#endif
+
 do
   __ret = read(this->fd(), __s, __n);
 while (__ret == -1L && errno == EINTR);
diff --git a/libstdc++-v3/config/os/bsd/darwin/os_defines.h 
b/libstdc++-v3/config/os/bsd/darwin/os_defines.h
index 6bc7930bdba0..a9cbdbb557bf 100644
--- a/libstdc++-v3/config/os/bsd/darwin/os_defines.h
+++ b/libstdc++-v3/config/os/bsd/darwin/os_defines.h
@@ -54,4 +54,7 @@
 // No support for referencing weak symbols without a definition.
 #define _GLIBCXX_USE_WEAK_REF 0
 
+// read(2) can return EINVAL for n >= INT_MAX.
+#define _GLIBCXX_MAX_READ_SIZE (__INT_MAX__ - 1)
+
 #endif
diff --git a/libstdc++-v3/config/os/bsd/freebsd/os_defines.h 
b/libstdc++-v3/config/os/bsd/freebsd/os_defines.h
index 125dfdc18885..bb4a8442dcce 100644
--- a/libstdc++-v3/config/os/bsd/freebsd/os_defines.h
+++ b/libstdc++-v3/config/os/bsd/freebsd/os_defines.h
@@ -50,4 +50,7 @@
 #define _GLIBCXX_USE_C99_FLOAT_TRANSCENDENTALS_DYNAMIC 0
 #endif
 
+// read(2) can return EINVAL for n >= INT_MAX.
+#define _GLIBCXX_MAX_READ_SIZE (__INT_MAX__ - 1)
+
 #endif


[gcc/devel/rust/master] lang-items: Store NodeId mappings for lang items

2024-12-09 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:6374da82b72ad38cb3eeb16c976e9b2d5103d76b

commit 6374da82b72ad38cb3eeb16c976e9b2d5103d76b
Author: Arthur Cohen 
Date:   Mon Nov 25 15:05:32 2024 +0100

lang-items: Store NodeId mappings for lang items

gcc/rust/ChangeLog:

* util/rust-hir-map.h: Keep a NodeId mappings for lang items.
* util/rust-hir-map.cc (Mappings::insert_lang_item_node): New 
function.
(Mappings::lookup_lang_item_node): Likewise.

Diff:
---
 gcc/rust/util/rust-hir-map.cc | 22 ++
 gcc/rust/util/rust-hir-map.h  |  8 
 2 files changed, 30 insertions(+)

diff --git a/gcc/rust/util/rust-hir-map.cc b/gcc/rust/util/rust-hir-map.cc
index 7315edb2fb8f..2edf0996276b 100644
--- a/gcc/rust/util/rust-hir-map.cc
+++ b/gcc/rust/util/rust-hir-map.cc
@@ -1241,6 +1241,9 @@ Mappings::lookup_builtin_marker ()
   return builtinMarker;
 }
 
+// FIXME: Before merging: Should we remove the `locus` parameter here? since
+// lang items are looked up mostly for code generation, it doesn't make sense 
to
+// error out on the locus of the node trying to access an inexistant lang item
 DefId
 Mappings::get_lang_item (LangItem::Kind item_type, location_t locus)
 {
@@ -1277,5 +1280,24 @@ Mappings::lookup_lang_item (LangItem::Kind item_type)
   return it->second;
 }
 
+void
+Mappings::insert_lang_item_node (LangItem::Kind item_type, NodeId node_id)
+{
+  auto it = lang_item_nodes.find (item_type);
+  rust_assert (it == lang_item_nodes.end ());
+
+  lang_item_nodes.insert ({item_type, node_id});
+}
+
+tl::optional
+Mappings::lookup_lang_item_node (LangItem::Kind item_type)
+{
+  auto it = lang_item_nodes.find (item_type);
+  if (it == lang_item_nodes.end ())
+return tl::nullopt;
+
+  return it->second;
+}
+
 } // namespace Analysis
 } // namespace Rust
diff --git a/gcc/rust/util/rust-hir-map.h b/gcc/rust/util/rust-hir-map.h
index 10ca71c57b69..6117b0ad8e00 100644
--- a/gcc/rust/util/rust-hir-map.h
+++ b/gcc/rust/util/rust-hir-map.h
@@ -259,6 +259,9 @@ public:
   void insert_lang_item (LangItem::Kind item_type, DefId id);
   tl::optional lookup_lang_item (LangItem::Kind item_type);
 
+  void insert_lang_item_node (LangItem::Kind item_type, NodeId node_id);
+  tl::optional lookup_lang_item_node (LangItem::Kind item_type);
+
   // This will fatal_error when this lang item does not exist
   DefId get_lang_item (LangItem::Kind item_type, location_t locus);
 
@@ -375,7 +378,12 @@ private:
   std::map hirGenericParamMappings;
   std::map hirTraitItemsToTraitMappings;
   std::map hirPatternMappings;
+
+  // We need to have two maps here, as lang-items need to be used for both AST
+  // passes and HIR passes. Thus those two maps are created at different times.
   std::map lang_item_mappings;
+  std::map lang_item_nodes;
+
   std::map paths;
   std::map locations;
   std::map nodeIdToHirMappings;


[gcc r15-6053] Fortran: fix two minor front-end GMP memleaks

2024-12-09 Thread Harald Anlauf via Gcc-cvs
https://gcc.gnu.org/g:d4525729b747827afa62320696709ca499904860

commit r15-6053-gd4525729b747827afa62320696709ca499904860
Author: Harald Anlauf 
Date:   Sun Dec 8 22:30:32 2024 +0100

Fortran: fix two minor front-end GMP memleaks

gcc/fortran/ChangeLog:

* expr.cc (find_array_section): Do not initialize GMP variables
twice.

Diff:
---
 gcc/fortran/expr.cc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gcc/fortran/expr.cc b/gcc/fortran/expr.cc
index a997bdae726a..a349d989d6c4 100644
--- a/gcc/fortran/expr.cc
+++ b/gcc/fortran/expr.cc
@@ -1613,7 +1613,7 @@ find_array_section (gfc_expr *expr, gfc_ref *ref)
  /* Zero-sized arrays have no shape and no elements, stop early.  */
  if (!begin->shape)
{
- mpz_init_set_ui (nelts, 0);
+ mpz_set_ui (nelts, 0);
  break;
}
 
@@ -1714,7 +1714,7 @@ find_array_section (gfc_expr *expr, gfc_ref *ref)
  constructor.  */
   for (idx = 0; idx < (int) mpz_get_si (nelts); idx++)
 {
-  mpz_init_set_ui (ptr, 0);
+  mpz_set_ui (ptr, 0);
 
   incr_ctr = true;
   for (d = 0; d < rank; d++)


[gcc r15-6052] c++: compile time evaluation of prvalues [PR116416]

2024-12-09 Thread Marek Polacek via Gcc-cvs
https://gcc.gnu.org/g:12de1942a0a673f9f2f1c2bfce4279a666061ffc

commit r15-6052-g12de1942a0a673f9f2f1c2bfce4279a666061ffc
Author: Marek Polacek 
Date:   Thu Aug 29 12:58:41 2024 -0400

c++: compile time evaluation of prvalues [PR116416]

This PR reports a missed optimization.  When we have:

  Str str{"Test"};
  callback(str);

as in the test, we're able to evaluate the Str::Str() call at compile
time.  But when we have:

  callback(Str{"Test"});

we are not.  With this patch (in fact, it's Patrick's patch with a little
tweak), we turn

  callback (TARGET_EXPR >>
(const char *) "Test" )

into

  callback (TARGET_EXPR )

I explored the idea of calling maybe_constant_value for the whole
TARGET_EXPR in cp_fold.  That has three problems:
- we can't always elide a TARGET_EXPR, so we'd have to make sure the
  result is also a TARGET_EXPR;
- the resulting TARGET_EXPR must have the same flags, otherwise Bad
  Things happen;
- getting a new slot is also problematic.  I've seen a test where we
  had "TARGET_EXPR, D.2680", and folding the whole TARGET_EXPR
  would get us "TARGET_EXPR", but since we don't see the outer
  D.2680, we can't replace it with D.2681, and things break.

With this patch, two tree-ssa tests regressed: pr78687.C and pr90883.C.

FAIL: g++.dg/tree-ssa/pr90883.C   scan-tree-dump dse1 "Deleted redundant 
store: .*.a = {}"
is easy.  Previously, we would call C::C, so .gimple has:

  D.2590 = {};
  C::C (&D.2590);
  D.2597 = D.2590;
  return D.2597;

Then .einline inlines the C::C call:

  D.2590 = {};
  D.2590.a = {}; // #1
  D.2590.b = 0;  // #2
  D.2597 = D.2590;
  D.2590 ={v} {CLOBBER(eos)};
  return D.2597;

then #2 is removed in .fre1, and #1 is removed in .dse1.  So the test
passes.  But with the patch, .gimple won't have that C::C call, so the
IL is of course going to look different.  The .optimized dump looks the
same though so there's no problem.

pr78687.C is XFAILed because the test passes with r15-5746 but not with
r15-5747 as well.  I opened .

PR c++/116416

gcc/cp/ChangeLog:

* cp-gimplify.cc (cp_fold_r) : Try to fold
TARGET_EXPR_INITIAL and replace it with the folded result if
it's TREE_CONSTANT.

gcc/testsuite/ChangeLog:

* g++.dg/analyzer/pr97116.C: Adjust dg-message.
* g++.dg/tree-ssa/pr78687.C: Add XFAIL.
* g++.dg/tree-ssa/pr90883.C: Adjust dg-final.
* g++.dg/cpp0x/constexpr-prvalue1.C: New test.
* g++.dg/cpp1y/constexpr-prvalue1.C: New test.

Co-authored-by: Patrick Palka 
Reviewed-by: Jason Merrill 

Diff:
---
 gcc/cp/cp-gimplify.cc   | 10 +++--
 gcc/testsuite/g++.dg/analyzer/pr97116.C |  2 +-
 gcc/testsuite/g++.dg/cpp0x/constexpr-prvalue1.C | 24 
 gcc/testsuite/g++.dg/cpp1y/constexpr-prvalue1.C | 30 +
 gcc/testsuite/g++.dg/tree-ssa/pr78687.C |  3 ++-
 gcc/testsuite/g++.dg/tree-ssa/pr90883.C |  4 ++--
 6 files changed, 67 insertions(+), 6 deletions(-)

diff --git a/gcc/cp/cp-gimplify.cc b/gcc/cp/cp-gimplify.cc
index b011badf00f4..623e2ee6e964 100644
--- a/gcc/cp/cp-gimplify.cc
+++ b/gcc/cp/cp-gimplify.cc
@@ -1470,13 +1470,19 @@ cp_fold_r (tree *stmt_p, int *walk_subtrees, void 
*data_)
   if (data->flags & ff_genericize)
cp_genericize_target_expr (stmt_p);
 
-  /* Folding might replace e.g. a COND_EXPR with a TARGET_EXPR; in
-that case, strip it in favor of this one.  */
   if (tree &init = TARGET_EXPR_INITIAL (stmt))
{
  cp_walk_tree (&init, cp_fold_r, data, NULL);
  cp_walk_tree (&TARGET_EXPR_CLEANUP (stmt), cp_fold_r, data, NULL);
  *walk_subtrees = 0;
+ if (!flag_no_inline)
+   {
+ tree folded = maybe_constant_init (init, TARGET_EXPR_SLOT (stmt));
+ if (folded != init && TREE_CONSTANT (folded))
+   init = folded;
+   }
+ /* Folding might replace e.g. a COND_EXPR with a TARGET_EXPR; in
+that case, strip it in favor of this one.  */
  if (TREE_CODE (init) == TARGET_EXPR)
{
  tree sub = TARGET_EXPR_INITIAL (init);
diff --git a/gcc/testsuite/g++.dg/analyzer/pr97116.C 
b/gcc/testsuite/g++.dg/analyzer/pr97116.C
index d8e08a73172d..1c404c2ceb23 100644
--- a/gcc/testsuite/g++.dg/analyzer/pr97116.C
+++ b/gcc/testsuite/g++.dg/analyzer/pr97116.C
@@ -16,7 +16,7 @@ struct foo
 void test_1 (void)
 {
   foo *p = new(NULL) foo (42); // { dg-warning "non-null expected" "warning" }
-  // { dg-message "argument 'this' \\(\[^\n\]*\\) NULL where non-null 
expected" "final event" { target *-*-* } .-1 }
+  // { dg-messa

[gcc r15-6044] Assign separate timevar to duplicate computed goto pass

2024-12-09 Thread Richard Biener via Gcc-cvs
https://gcc.gnu.org/g:75e481c711c0f6698ca063f5a009db71d45ddc0c

commit r15-6044-g75e481c711c0f6698ca063f5a009db71d45ddc0c
Author: Richard Biener 
Date:   Mon Dec 9 14:09:12 2024 +0100

Assign separate timevar to duplicate computed goto pass

It currently shares the timevar with bb-reorder but can use significant
memory and compile-time on its own.

* timevar.def (TV_DUP_COMPGOTO): Add.
* bb-reorder.cc (pass_data_duplicate_computed_gotos): Use
TV_DUP_COMPGOTO.

Diff:
---
 gcc/bb-reorder.cc | 2 +-
 gcc/timevar.def   | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/gcc/bb-reorder.cc b/gcc/bb-reorder.cc
index ee0aae105f31..d013e8386ab2 100644
--- a/gcc/bb-reorder.cc
+++ b/gcc/bb-reorder.cc
@@ -2799,7 +2799,7 @@ const pass_data pass_data_duplicate_computed_gotos =
   RTL_PASS, /* type */
   "compgotos", /* name */
   OPTGROUP_NONE, /* optinfo_flags */
-  TV_REORDER_BLOCKS, /* tv_id */
+  TV_DUP_COMPGOTO, /* tv_id */
   0, /* properties_required */
   0, /* properties_provided */
   0, /* properties_destroyed */
diff --git a/gcc/timevar.def b/gcc/timevar.def
index 4bd26e0b6b79..945b4977d5c3 100644
--- a/gcc/timevar.def
+++ b/gcc/timevar.def
@@ -294,6 +294,7 @@ DEFTIMEVAR (TV_SCHED2, "scheduling 2")
 DEFTIMEVAR (TV_MACH_DEP  , "machine dep reorg")
 DEFTIMEVAR (TV_DBR_SCHED , "delay branch sched")
 DEFTIMEVAR (TV_REORDER_BLOCKS, "reorder blocks")
+DEFTIMEVAR (TV_DUP_COMPGOTO  , "duplicate computed gotos")
 DEFTIMEVAR (TV_SHORTEN_BRANCH, "shorten branches")
 DEFTIMEVAR (TV_REG_STACK , "reg stack")
 DEFTIMEVAR (TV_FINAL , "final")


[gcc r15-6047] libstdc++: Fix debug containers for constant evaluation [PR117962]

2024-12-09 Thread Jonathan Wakely via Gcc-cvs
https://gcc.gnu.org/g:6fbe9e65645f54cc564a928bc0bc69c8b421cb98

commit r15-6047-g6fbe9e65645f54cc564a928bc0bc69c8b421cb98
Author: Jonathan Wakely 
Date:   Mon Dec 9 10:52:10 2024 +

libstdc++: Fix debug containers for constant evaluation [PR117962]

Using a stateful allocator with std::vector would fail in Debug Mode,
because the allocator-extended move constructor tries to swap all the
attached safe iterators, but that uses a non-inline function which isn't
constexpr. We don't actually need to swap any iterators in constant
expressions, because we never attach them to the container in the first
place.

This bug went unnoticed because the tests for constexpr std::vector were
using a stateful allocator with a std::allocator base class, but were
failing to override the inherited is_always_equal trait from
std::allocator. That meant that the allocators took the always-equal
code paths, and didn't try to use the buggy constructor. In C++26 the
std::allocator::is_always_equal trait goes away, and so the tests
changed behaviour, revealing the bug.

libstdc++-v3/ChangeLog:

PR libstdc++/117962
* include/debug/safe_container.h: Make allocator-extended move
constructor a no-op during constant evaluation.

Diff:
---
 libstdc++-v3/include/debug/safe_container.h | 11 +++
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/libstdc++-v3/include/debug/safe_container.h 
b/libstdc++-v3/include/debug/safe_container.h
index 9a6c4f7ba743..75c6834bfaec 100644
--- a/libstdc++-v3/include/debug/safe_container.h
+++ b/libstdc++-v3/include/debug/safe_container.h
@@ -64,10 +64,13 @@ namespace __gnu_debug
   _Safe_container(_Safe_container&& __x, const _Alloc& __a, 
std::false_type)
   : _Safe_container()
   {
-   if (__x._M_cont().get_allocator() == __a)
- _Base::_M_swap(__x);
-   else if (!std::__is_constant_evaluated())
- __x._M_invalidate_all();
+   if (!std::__is_constant_evaluated())
+ {
+   if (__x._M_cont().get_allocator() == __a)
+ _Base::_M_swap(__x);
+   else
+ __x._M_invalidate_all();
+ }
   }
 
 protected:


[gcc r15-6048] libstdc++: Remove std::allocator::is_always_equal typedef for C++26

2024-12-09 Thread Jonathan Wakely via Libstdc++-cvs
https://gcc.gnu.org/g:80bb28cb233e4679265c7847d57a15bf109a0f0e

commit r15-6048-g80bb28cb233e4679265c7847d57a15bf109a0f0e
Author: Jonathan Wakely 
Date:   Thu Nov 28 21:01:13 2024 +

libstdc++: Remove std::allocator::is_always_equal typedef for C++26

This was removed by P2868R3, voted into the C++26 draft at the November
2023 meeting in Kona. We've had a deprecated warning in place for three
years.

libstdc++-v3/ChangeLog:

* include/bits/allocator.h (allocator::is_always_equal): Do not
define for C++26.
(allocator::is_always_equal): Likewise.
* testsuite/20_util/allocator/requirements/typedefs.cc: Check
that is_always_equal is not present in C++26.
* testsuite/20_util/allocator/void.cc: Do not require
is_always_equal for C++26.
* testsuite/23_containers/vector/bool/cons/constexpr.cc: Add
missing override of base's is_always_equal.
* testsuite/23_containers/vector/cons/constexpr.cc: Likewise.

Diff:
---
 libstdc++-v3/include/bits/allocator.h  |  4 
 .../testsuite/20_util/allocator/requirements/typedefs.cc   | 14 +++---
 libstdc++-v3/testsuite/20_util/allocator/void.cc   |  4 +++-
 .../testsuite/23_containers/vector/bool/cons/constexpr.cc  |  4 
 .../testsuite/23_containers/vector/cons/constexpr.cc   |  4 
 5 files changed, 26 insertions(+), 4 deletions(-)

diff --git a/libstdc++-v3/include/bits/allocator.h 
b/libstdc++-v3/include/bits/allocator.h
index ebb487a3ffeb..ce678480571c 100644
--- a/libstdc++-v3/include/bits/allocator.h
+++ b/libstdc++-v3/include/bits/allocator.h
@@ -95,9 +95,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   // 2103. std::allocator propagate_on_container_move_assignment
   using propagate_on_container_move_assignment = true_type;
 
+#if __cplusplus <= 202302L
   using is_always_equal
_GLIBCXX20_DEPRECATED_SUGGEST("std::allocator_traits::is_always_equal")
= true_type;
+#endif
 
 #if __cplusplus >= 202002L
   // As noted above, these members are present for C++20 to provide the
@@ -152,9 +154,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   // 2103. std::allocator propagate_on_container_move_assignment
   using propagate_on_container_move_assignment = true_type;
 
+#if __cplusplus <= 202302L
   using is_always_equal
_GLIBCXX20_DEPRECATED_SUGGEST("std::allocator_traits::is_always_equal")
= true_type;
+#endif
 #endif
 
   // _GLIBCXX_RESOLVE_LIB_DEFECTS
diff --git a/libstdc++-v3/testsuite/20_util/allocator/requirements/typedefs.cc 
b/libstdc++-v3/testsuite/20_util/allocator/requirements/typedefs.cc
index 49d99e52415b..1572f8912467 100644
--- a/libstdc++-v3/testsuite/20_util/allocator/requirements/typedefs.cc
+++ b/libstdc++-v3/testsuite/20_util/allocator/requirements/typedefs.cc
@@ -54,9 +54,13 @@ static_assert( 
is_same::propagate_on_container_move_assignment,
std::true_type>::value,
"propagate_on_container_move_assignment" );
 
-using IAE = allocator::is_always_equal; // { dg-warning "deprecated" "" { 
target c++20 } }
+#if __cplusplus <= 202302L
+using IAE = allocator::is_always_equal; // { dg-warning "deprecated" "" { 
target { c++20_only || c++23_only } } }
 static_assert( is_same::value, "is_always_equal" );
-
+#else
+struct B { using is_always_equal = int; };
+struct tester : B, std::allocator { is_always_equal unambig; };
+#endif
 
 // Test required typedefs for allocator specialization.
 static_assert( is_same::value_type, void>::value,
@@ -75,6 +79,10 @@ static_assert( 
is_same::propagate_on_container_move_assignment,
std::true_type>::value,
"propagate_on_container_move_assignment" );
 
-using VIAE = allocator::is_always_equal; // { dg-warning "deprecated" "" 
{ target c++20 } }
+#if __cplusplus <= 202302L
+using VIAE = allocator::is_always_equal; // { dg-warning "deprecated" "" 
{ target { c++20_only || c++23_only } } }
 static_assert( is_same::value, "is_always_equal" );
+#else
+struct tester2 : B, std::allocator { is_always_equal unambig; };
+#endif
 #endif
diff --git a/libstdc++-v3/testsuite/20_util/allocator/void.cc 
b/libstdc++-v3/testsuite/20_util/allocator/void.cc
index 04cd2094776a..799774861f56 100644
--- a/libstdc++-v3/testsuite/20_util/allocator/void.cc
+++ b/libstdc++-v3/testsuite/20_util/allocator/void.cc
@@ -36,8 +36,10 @@ test01()
 
 static_assert( std::allocator::propagate_on_container_move_assignment(),
   "POCMA trait should always be present" );
+#if __cplusplus <= 202302L
 static_assert( std::allocator::is_always_equal(),
-  "is_always_equal trait should always be present" );
+  "is_always_equal trait should be present before C++26" );
+#endif
 
 static_assert(
 std::is_same::size_type, std::size_t>(),
diff --git a/libstdc++-v3/testsuite/23_containers/vector/bool/cons/constexpr.cc 
b

[gcc r15-6050] aarch64: Add @ to aarch64_get_lane

2024-12-09 Thread Richard Sandiford via Gcc-cvs
https://gcc.gnu.org/g:5a507b5108dc55ce7f01bd1bc31751e15a557da6

commit r15-6050-g5a507b5108dc55ce7f01bd1bc31751e15a557da6
Author: Richard Sandiford 
Date:   Mon Dec 9 16:52:42 2024 +

aarch64: Add @ to aarch64_get_lane

This is a prerequisite for Mariam's CRC support.

gcc/
* config/aarch64/aarch64-simd.md (aarch64_get_lane): Add
"@" to the name.

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

diff --git a/gcc/config/aarch64/aarch64-simd.md 
b/gcc/config/aarch64/aarch64-simd.md
index 05cbd38372d3..fd6965d9e86e 100644
--- a/gcc/config/aarch64/aarch64-simd.md
+++ b/gcc/config/aarch64/aarch64-simd.md
@@ -4357,7 +4357,7 @@
 ;; RTL uses GCC vector extension indices throughout so flip only for assembly.
 ;; Extracting lane zero is split into a simple move when it is between SIMD
 ;; registers or a store.
-(define_insn_and_split "aarch64_get_lane"
+(define_insn_and_split "@aarch64_get_lane"
   [(set (match_operand: 0 "aarch64_simd_nonimmediate_operand" "=?r, w, 
Utv")
(vec_select:
  (match_operand:VALL_F16 1 "register_operand" "w, w, w")


[gcc/devel/rust/master] lang-items: Add lang-items AST collector

2024-12-09 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:6b7e055ecc9a83295cb1f6cd7bb58f3270f2cd0c

commit 6b7e055ecc9a83295cb1f6cd7bb58f3270f2cd0c
Author: Arthur Cohen 
Date:   Mon Nov 25 14:30:39 2024 +0100

lang-items: Add lang-items AST collector

gcc/rust/ChangeLog:

* Make-lang.in: Add new object file.
* rust-session-manager.cc (Session::compile_crate): Call 
CollectLangItems.
* ast/rust-collect-lang-items.cc: New file.
* ast/rust-collect-lang-items.h: New file.

Diff:
---
 gcc/rust/Make-lang.in   |  3 +-
 gcc/rust/ast/rust-collect-lang-items.cc | 97 +
 gcc/rust/ast/rust-collect-lang-items.h  | 58 
 gcc/rust/rust-session-manager.cc|  3 +
 4 files changed, 160 insertions(+), 1 deletion(-)

diff --git a/gcc/rust/Make-lang.in b/gcc/rust/Make-lang.in
index 6de0a20b6a0a..fe82ab42ec87 100644
--- a/gcc/rust/Make-lang.in
+++ b/gcc/rust/Make-lang.in
@@ -227,8 +227,9 @@ GRS_OBJS = \
 rust/rust-dir-owner.o \
 rust/rust-unicode.o \
 rust/rust-punycode.o \
-   rust/rust-lang-item.o \
rust/rust-expand-format-args.o \
+   rust/rust-lang-item.o \
+   rust/rust-collect-lang-items.o \
 $(END)
 # removed object files from here
 
diff --git a/gcc/rust/ast/rust-collect-lang-items.cc 
b/gcc/rust/ast/rust-collect-lang-items.cc
new file mode 100644
index ..11a30aa37a74
--- /dev/null
+++ b/gcc/rust/ast/rust-collect-lang-items.cc
@@ -0,0 +1,97 @@
+// 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
+// .
+
+#include "rust-collect-lang-items.h"
+#include "optional.h"
+#include "rust-ast-collector.h"
+#include "rust-ast.h"
+#include "rust-attribute-values.h"
+#include "rust-attributes.h"
+#include "rust-hir-map.h"
+
+namespace Rust {
+namespace AST {
+
+// FIXME: Before merging: De-duplicate with function in rust-ast-lower-base.cc
+bool
+is_known_attribute (const std::string &attribute_path)
+{
+  const auto &lookup
+= Analysis::BuiltinAttributeMappings::get ()->lookup_builtin (
+  attribute_path);
+
+  return !lookup.is_error ();
+}
+
+template 
+tl::optional
+get_lang_item_attr (const T &maybe_lang_item)
+{
+  for (const auto &attr : maybe_lang_item.get_outer_attrs ())
+{
+  const auto &str_path = attr.get_path ().as_string ();
+  if (!is_known_attribute (str_path))
+   {
+ rust_error_at (attr.get_locus (), "unknown attribute");
+ continue;
+   }
+
+  bool is_lang_item = str_path == Values::Attributes::LANG
+ && attr.has_attr_input ()
+ && attr.get_attr_input ().get_attr_input_type ()
+  == AST::AttrInput::AttrInputType::LITERAL;
+
+  if (is_lang_item)
+   {
+ auto &literal
+   = static_cast (attr.get_attr_input ());
+ const auto &lang_item_type_str = literal.get_literal ().as_string ();
+
+ return LangItem::Parse (lang_item_type_str);
+   }
+}
+
+  return tl::nullopt;
+}
+
+template 
+void
+CollectLangItems::maybe_add_lang_item (const T &item)
+{
+  if (auto lang_item = get_lang_item_attr (item))
+mappings.insert_lang_item_node (lang_item.value (), item.get_node_id ());
+}
+
+void
+CollectLangItems::visit (AST::Trait &item)
+{
+  maybe_add_lang_item (item);
+
+  DefaultASTVisitor::visit (item);
+}
+
+void
+CollectLangItems::visit (AST::TraitItemType &item)
+{
+  maybe_add_lang_item (item);
+
+  DefaultASTVisitor::visit (item);
+}
+
+} // namespace AST
+} // namespace Rust
diff --git a/gcc/rust/ast/rust-collect-lang-items.h 
b/gcc/rust/ast/rust-collect-lang-items.h
new file mode 100644
index ..552648f04eda
--- /dev/null
+++ b/gcc/rust/ast/rust-collect-lang-items.h
@@ -0,0 +1,58 @@
+// 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.
+
+//

[gcc/devel/rust/master] attributes: Add class for sharing methods on attributes.

2024-12-09 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:72081086d6b8228f7db6526e39e41bea2eae244c

commit 72081086d6b8228f7db6526e39e41bea2eae244c
Author: Arthur Cohen 
Date:   Wed Dec 4 13:53:11 2024 +

attributes: Add class for sharing methods on attributes.

gcc/rust/ChangeLog:

* util/rust-attributes.h (class Attributes): New.
* util/rust-attributes.cc: Implement Attributes::is_known().
* ast/rust-collect-lang-items.cc (is_known_attribute): Remove.
(get_lang_item_attr): Call Attributes::is_known() instead.
* hir/rust-ast-lower-base.cc 
(ASTLoweringBase::handle_outer_attributes): Likewise.
(ASTLoweringBase::is_known_attribute): Remove.

Diff:
---
 gcc/rust/ast/rust-collect-lang-items.cc | 13 +
 gcc/rust/hir/rust-ast-lower-base.cc | 10 ++
 gcc/rust/util/rust-attributes.cc|  9 +
 gcc/rust/util/rust-attributes.h |  6 ++
 4 files changed, 18 insertions(+), 20 deletions(-)

diff --git a/gcc/rust/ast/rust-collect-lang-items.cc 
b/gcc/rust/ast/rust-collect-lang-items.cc
index 11a30aa37a74..308720ae69ab 100644
--- a/gcc/rust/ast/rust-collect-lang-items.cc
+++ b/gcc/rust/ast/rust-collect-lang-items.cc
@@ -27,17 +27,6 @@
 namespace Rust {
 namespace AST {
 
-// FIXME: Before merging: De-duplicate with function in rust-ast-lower-base.cc
-bool
-is_known_attribute (const std::string &attribute_path)
-{
-  const auto &lookup
-= Analysis::BuiltinAttributeMappings::get ()->lookup_builtin (
-  attribute_path);
-
-  return !lookup.is_error ();
-}
-
 template 
 tl::optional
 get_lang_item_attr (const T &maybe_lang_item)
@@ -45,7 +34,7 @@ get_lang_item_attr (const T &maybe_lang_item)
   for (const auto &attr : maybe_lang_item.get_outer_attrs ())
 {
   const auto &str_path = attr.get_path ().as_string ();
-  if (!is_known_attribute (str_path))
+  if (!Analysis::Attributes::is_known (str_path))
{
  rust_error_at (attr.get_locus (), "unknown attribute");
  continue;
diff --git a/gcc/rust/hir/rust-ast-lower-base.cc 
b/gcc/rust/hir/rust-ast-lower-base.cc
index 272de0f87172..eac2cba5c752 100644
--- a/gcc/rust/hir/rust-ast-lower-base.cc
+++ b/gcc/rust/hir/rust-ast-lower-base.cc
@@ -25,6 +25,7 @@
 #include "rust-diagnostics.h"
 #include "rust-item.h"
 #include "rust-system.h"
+#include "rust-attributes.h"
 
 namespace Rust {
 namespace HIR {
@@ -751,7 +752,7 @@ ASTLoweringBase::handle_outer_attributes (const ItemWrapper 
&item)
   for (const auto &attr : item.get_outer_attrs ())
 {
   const auto &str_path = attr.get_path ().as_string ();
-  if (!is_known_attribute (str_path))
+  if (!Analysis::Attributes::is_known (str_path))
{
  rust_error_at (attr.get_locus (), "unknown attribute");
  continue;
@@ -814,13 +815,6 @@ ASTLoweringBase::handle_lang_item_attribute (const 
ItemWrapper &item,
 rust_error_at (attr.get_locus (), "unknown lang item");
 }
 
-bool
-ASTLoweringBase::is_known_attribute (const std::string &attribute_path) const
-{
-  const auto &lookup = attr_mappings->lookup_builtin (attribute_path);
-  return !lookup.is_error ();
-}
-
 bool
 ASTLoweringBase::attribute_handled_in_another_pass (
   const std::string &attribute_path) const
diff --git a/gcc/rust/util/rust-attributes.cc b/gcc/rust/util/rust-attributes.cc
index 14f00bd3c526..45ebf8c65461 100644
--- a/gcc/rust/util/rust-attributes.cc
+++ b/gcc/rust/util/rust-attributes.cc
@@ -29,6 +29,15 @@
 namespace Rust {
 namespace Analysis {
 
+bool
+Attributes::is_known (const std::string &attribute_path)
+{
+  const auto &lookup
+= BuiltinAttributeMappings::get ()->lookup_builtin (attribute_path);
+
+  return !lookup.is_error ();
+}
+
 using Attrs = Values::Attributes;
 
 // 
https://doc.rust-lang.org/stable/nightly-rustc/src/rustc_feature/builtin_attrs.rs.html#248
diff --git a/gcc/rust/util/rust-attributes.h b/gcc/rust/util/rust-attributes.h
index f557b2d46b38..c341b3e0a5db 100644
--- a/gcc/rust/util/rust-attributes.h
+++ b/gcc/rust/util/rust-attributes.h
@@ -25,6 +25,12 @@
 namespace Rust {
 namespace Analysis {
 
+class Attributes
+{
+public:
+  static bool is_known (const std::string &attribute_path);
+};
+
 enum CompilerPass
 {
   UNKNOWN,


[gcc/devel/rust/master] hir: Lower lang-item paths

2024-12-09 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:625c811ed5093947ad32ab5fba2028229fd6604f

commit 625c811ed5093947ad32ab5fba2028229fd6604f
Author: Arthur Cohen 
Date:   Fri Nov 29 11:06:25 2024 +0100

hir: Lower lang-item paths

gcc/rust/ChangeLog:

* hir/rust-ast-lower-type.cc (ASTLowerTypePath::translate): Adapt to
handle lang item paths.
(ASTLowerTypePath::visit): Likewise.
(ASTLowerTypePath::translate_type_path): New.
(ASTLowerTypePath::translate_lang_item_type_path): New.
* hir/rust-ast-lower-type.h: Adapt to handle lang item paths.
* resolve/rust-ast-resolve-type.h: Likewise.

Diff:
---
 gcc/rust/hir/rust-ast-lower-type.cc  | 45 +---
 gcc/rust/hir/rust-ast-lower-type.h   |  6 -
 gcc/rust/resolve/rust-ast-resolve-type.h |  6 ++---
 3 files changed, 43 insertions(+), 14 deletions(-)

diff --git a/gcc/rust/hir/rust-ast-lower-type.cc 
b/gcc/rust/hir/rust-ast-lower-type.cc
index 50576532ec46..2c124d1a16ba 100644
--- a/gcc/rust/hir/rust-ast-lower-type.cc
+++ b/gcc/rust/hir/rust-ast-lower-type.cc
@@ -17,9 +17,10 @@
 // .
 
 #include "rust-ast-lower-type.h"
-#include "optional.h"
-#include "rust-attribute-values.h"
+#include "rust-hir-map.h"
+#include "rust-hir-path.h"
 #include "rust-path.h"
+#include "rust-pattern.h"
 
 namespace Rust {
 namespace HIR {
@@ -27,16 +28,20 @@ namespace HIR {
 HIR::TypePath *
 ASTLowerTypePath::translate (AST::Path &type)
 {
-  rust_assert (type.get_path_kind () == AST::Path::Kind::Type);
+  ASTLowerTypePath resolver;
 
-  return ASTLowerTypePath::translate (static_cast (type));
-}
+  switch (type.get_path_kind ())
+{
+case AST::Path::Kind::LangItem:
+  resolver.visit (static_cast (type));
+  break;
+case AST::Path::Kind::Type:
+  resolver.visit (static_cast (type));
+  break;
+default:
+  rust_unreachable ();
+}
 
-HIR::TypePath *
-ASTLowerTypePath::translate (AST::TypePath &type)
-{
-  ASTLowerTypePath resolver;
-  type.accept_vis (resolver);
   rust_assert (resolver.translated != nullptr);
   return resolver.translated;
 }
@@ -135,6 +140,26 @@ ASTLowerTypePath::visit (AST::TypePath &path)
 path.has_opening_scope_resolution_op ());
 }
 
+void
+ASTLowerTypePath::visit (AST::LangItemPath &path)
+{
+  auto crate_num = mappings.get_current_crate ();
+  auto hirid = mappings.get_next_hir_id (crate_num);
+
+  Analysis::NodeMapping mapping (crate_num, path.get_node_id (), hirid,
+mappings.get_next_localdef_id (crate_num));
+
+  std::vector> translated_segments;
+  translated_segments.emplace_back (std::unique_ptr (
+new HIR::TypePathSegment (mapping,
+ LangItem::ToString (path.get_lang_item_kind ()),
+ false, path.get_locus (;
+
+  translated
+= new HIR::TypePath (std::move (mapping), std::move (translated_segments),
+path.get_locus ());
+}
+
 HIR::QualifiedPathInType *
 ASTLowerQualifiedPathInType::translate (AST::QualifiedPathInType &type)
 {
diff --git a/gcc/rust/hir/rust-ast-lower-type.h 
b/gcc/rust/hir/rust-ast-lower-type.h
index ec73df27b8f3..2509276dec22 100644
--- a/gcc/rust/hir/rust-ast-lower-type.h
+++ b/gcc/rust/hir/rust-ast-lower-type.h
@@ -21,6 +21,7 @@
 
 #include "rust-ast-lower-base.h"
 #include "rust-ast-lower-expr.h"
+#include "rust-hir-path.h"
 
 namespace Rust {
 namespace HIR {
@@ -32,18 +33,21 @@ protected:
 
 public:
   static HIR::TypePath *translate (AST::Path &type);
-  static HIR::TypePath *translate (AST::TypePath &type);
 
   void visit (AST::TypePathSegmentFunction &segment) override;
   void visit (AST::TypePathSegment &segment) override;
   void visit (AST::TypePathSegmentGeneric &segment) override;
   void visit (AST::TypePath &path) override;
+  void visit (AST::LangItemPath &path) override;
 
 protected:
   HIR::TypePathSegment *translated_segment;
 
 private:
   HIR::TypePath *translated;
+
+  static HIR::TypePath *translate_type_path (AST::TypePath &type);
+  static HIR::TypePath *translate_lang_item_type_path (AST::LangItemPath 
&type);
 };
 
 class ASTLowerQualifiedPathInType : public ASTLowerTypePath
diff --git a/gcc/rust/resolve/rust-ast-resolve-type.h 
b/gcc/rust/resolve/rust-ast-resolve-type.h
index e9451d3a1028..763838ea488b 100644
--- a/gcc/rust/resolve/rust-ast-resolve-type.h
+++ b/gcc/rust/resolve/rust-ast-resolve-type.h
@@ -71,13 +71,13 @@ public:
   {
auto &type = static_cast (type_path);
 
-   rust_debug ("[ARTHUR]: lang item kind: %s",
-   LangItem::ToString (type.get_lang_item_kind ()).c_str ());
-
auto lang_item = Analysis::Mappings::get ()
   .lookup_lang_item_node (type.get_lang_item_kind ())
   .value ();
 
+   auto resolver = Resolver::get ();
+   resolver->insert_resolved_type (type.get_node_id (), lang_it

[gcc/devel/rust/master] hir: Start adapting visitors to accept multiple kinds of Paths

2024-12-09 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:3d2f58db04023adb74e5334cef31b67383def449

commit 3d2f58db04023adb74e5334cef31b67383def449
Author: Arthur Cohen 
Date:   Wed Nov 6 16:32:35 2024 +0100

hir: Start adapting visitors to accept multiple kinds of Paths

gcc/rust/ChangeLog:

* ast/rust-item.h: Add new method to specifically get a type-path.
* ast/rust-path.cc (LangItemPath::as_string): Implement properly.
* hir/rust-ast-lower-type.cc (ASTLowerTypePath::translate): Adapt
visitor to use the new LangItemPath.
* hir/rust-ast-lower-type.h: Likewise.
* resolve/rust-ast-resolve-item.cc (ResolveItem::visit): Likewise.
* resolve/rust-ast-resolve-type.h: Likewise.

Diff:
---
 gcc/rust/ast/rust-item.h  |  7 +++
 gcc/rust/ast/rust-path.cc |  3 +--
 gcc/rust/hir/rust-ast-lower-type.cc   |  9 +
 gcc/rust/hir/rust-ast-lower-type.h|  1 +
 gcc/rust/resolve/rust-ast-resolve-item.cc |  2 +-
 gcc/rust/resolve/rust-ast-resolve-type.h  | 28 
 6 files changed, 47 insertions(+), 3 deletions(-)

diff --git a/gcc/rust/ast/rust-item.h b/gcc/rust/ast/rust-item.h
index 0ee131390d14..02b305d816ee 100644
--- a/gcc/rust/ast/rust-item.h
+++ b/gcc/rust/ast/rust-item.h
@@ -3264,6 +3264,13 @@ public:
 return *trait_path;
   }
 
+  Type &get_trait_path_type ()
+  {
+rust_assert (trait_path->get_path_kind () == Path::Kind::Type);
+
+return (AST::Type &) static_cast (*trait_path);
+  }
+
 protected:
   /* Use covariance to implement clone function as returning this object
* rather than base */
diff --git a/gcc/rust/ast/rust-path.cc b/gcc/rust/ast/rust-path.cc
index 58bfbb47f7c9..3a7e6e34d867 100644
--- a/gcc/rust/ast/rust-path.cc
+++ b/gcc/rust/ast/rust-path.cc
@@ -152,8 +152,7 @@ RegularPath::as_string () const
 std::string
 LangItemPath::as_string () const
 {
-  // FIXME: Handle #[lang] paths
-  rust_unreachable ();
+  return "#[lang = \"" + LangItem::ToString (kind) + "\"]";
 }
 
 SimplePath
diff --git a/gcc/rust/hir/rust-ast-lower-type.cc 
b/gcc/rust/hir/rust-ast-lower-type.cc
index 553c9c9612da..50576532ec46 100644
--- a/gcc/rust/hir/rust-ast-lower-type.cc
+++ b/gcc/rust/hir/rust-ast-lower-type.cc
@@ -19,10 +19,19 @@
 #include "rust-ast-lower-type.h"
 #include "optional.h"
 #include "rust-attribute-values.h"
+#include "rust-path.h"
 
 namespace Rust {
 namespace HIR {
 
+HIR::TypePath *
+ASTLowerTypePath::translate (AST::Path &type)
+{
+  rust_assert (type.get_path_kind () == AST::Path::Kind::Type);
+
+  return ASTLowerTypePath::translate (static_cast (type));
+}
+
 HIR::TypePath *
 ASTLowerTypePath::translate (AST::TypePath &type)
 {
diff --git a/gcc/rust/hir/rust-ast-lower-type.h 
b/gcc/rust/hir/rust-ast-lower-type.h
index 5207ce27b55a..ec73df27b8f3 100644
--- a/gcc/rust/hir/rust-ast-lower-type.h
+++ b/gcc/rust/hir/rust-ast-lower-type.h
@@ -31,6 +31,7 @@ protected:
   using Rust::HIR::ASTLoweringBase::visit;
 
 public:
+  static HIR::TypePath *translate (AST::Path &type);
   static HIR::TypePath *translate (AST::TypePath &type);
 
   void visit (AST::TypePathSegmentFunction &segment) override;
diff --git a/gcc/rust/resolve/rust-ast-resolve-item.cc 
b/gcc/rust/resolve/rust-ast-resolve-item.cc
index 185b82aa7f73..49c0e6f4e49e 100644
--- a/gcc/rust/resolve/rust-ast-resolve-item.cc
+++ b/gcc/rust/resolve/rust-ast-resolve-item.cc
@@ -680,7 +680,7 @@ ResolveItem::visit (AST::TraitImpl &impl_block)
 
   // setup paths
   CanonicalPath canonical_trait_type = CanonicalPath::create_empty ();
-  bool ok = ResolveTypeToCanonicalPath::go (impl_block.get_trait_path (),
+  bool ok = ResolveTypeToCanonicalPath::go (impl_block.get_trait_path_type (),
canonical_trait_type);
   if (!ok)
 {
diff --git a/gcc/rust/resolve/rust-ast-resolve-type.h 
b/gcc/rust/resolve/rust-ast-resolve-type.h
index 50dd890c4e31..47c4e35a0a54 100644
--- a/gcc/rust/resolve/rust-ast-resolve-type.h
+++ b/gcc/rust/resolve/rust-ast-resolve-type.h
@@ -21,6 +21,8 @@
 
 #include "rust-ast-resolve-base.h"
 #include "rust-ast-resolve-expr.h"
+#include "rust-hir-map.h"
+#include "rust-path.h"
 
 namespace Rust {
 namespace Resolver {
@@ -56,6 +58,32 @@ class ResolveType : public ResolverBase
   using Rust::Resolver::ResolverBase::visit;
 
 public:
+  static NodeId go (AST::TypePath &type_path)
+  {
+return ResolveType::go ((AST::Type &) type_path);
+  }
+
+  static NodeId go (AST::Path &type_path)
+  {
+if (type_path.get_path_kind () == AST::Path::Kind::LangItem)
+  {
+   auto &type = static_cast (type_path);
+
+   Analysis::Mappings::get_lang_item (type);
+
+   type.get_node_id ();
+  }
+
+rust_assert (type_path.get_path_kind () == AST::Path::Kind::Type);
+
+// We have to do this dance to first downcast to a typepath, and then 
upcast
+// to a Type. The altnernative is to split `go` into `go` and `go_inner` or
+// somethi

[gcc/devel/rust/master] nr1.0: Resolve lang item paths properly.

2024-12-09 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:d812c793ef14bcfbb5ab7aa6e8c3837f8e817beb

commit d812c793ef14bcfbb5ab7aa6e8c3837f8e817beb
Author: Arthur Cohen 
Date:   Wed Dec 4 15:14:45 2024 +0100

nr1.0: Resolve lang item paths properly.

gcc/rust/ChangeLog:

* resolve/rust-ast-resolve-item.cc (ResolveItem::visit): Adapt 
resolver
to lang item paths.
* resolve/rust-ast-resolve-type.h: Likewise.

Diff:
---
 gcc/rust/resolve/rust-ast-resolve-item.cc | 30 +++---
 gcc/rust/resolve/rust-ast-resolve-type.h  | 11 +--
 2 files changed, 32 insertions(+), 9 deletions(-)

diff --git a/gcc/rust/resolve/rust-ast-resolve-item.cc 
b/gcc/rust/resolve/rust-ast-resolve-item.cc
index 49c0e6f4e49e..619efb00ac41 100644
--- a/gcc/rust/resolve/rust-ast-resolve-item.cc
+++ b/gcc/rust/resolve/rust-ast-resolve-item.cc
@@ -678,16 +678,32 @@ ResolveItem::visit (AST::TraitImpl &impl_block)
   return;
 }
 
+  bool ok = true;
+
   // setup paths
   CanonicalPath canonical_trait_type = CanonicalPath::create_empty ();
-  bool ok = ResolveTypeToCanonicalPath::go (impl_block.get_trait_path_type (),
-   canonical_trait_type);
-  if (!ok)
+  if (impl_block.get_trait_path ().get_path_kind ()
+  == AST::Path::Kind::LangItem)
 {
-  resolver->get_name_scope ().pop ();
-  resolver->get_type_scope ().pop ();
-  resolver->get_label_scope ().pop ();
-  return;
+  auto &lang_item
+   = static_cast (impl_block.get_trait_path ());
+
+  canonical_trait_type
+   = CanonicalPath::new_seg (lang_item.get_node_id (),
+ LangItem::ToString (
+   lang_item.get_lang_item_kind ()));
+}
+  else
+{
+  ok = ResolveTypeToCanonicalPath::go (impl_block.get_trait_path_type (),
+  canonical_trait_type);
+  if (!ok)
+   {
+ resolver->get_name_scope ().pop ();
+ resolver->get_type_scope ().pop ();
+ resolver->get_label_scope ().pop ();
+ return;
+   }
 }
 
   rust_debug ("AST::TraitImpl resolve trait type: {%s}",
diff --git a/gcc/rust/resolve/rust-ast-resolve-type.h 
b/gcc/rust/resolve/rust-ast-resolve-type.h
index 47c4e35a0a54..e9451d3a1028 100644
--- a/gcc/rust/resolve/rust-ast-resolve-type.h
+++ b/gcc/rust/resolve/rust-ast-resolve-type.h
@@ -21,8 +21,10 @@
 
 #include "rust-ast-resolve-base.h"
 #include "rust-ast-resolve-expr.h"
+#include "rust-diagnostics.h"
 #include "rust-hir-map.h"
 #include "rust-path.h"
+#include "util/rust-hir-map.h"
 
 namespace Rust {
 namespace Resolver {
@@ -69,9 +71,14 @@ public:
   {
auto &type = static_cast (type_path);
 
-   Analysis::Mappings::get_lang_item (type);
+   rust_debug ("[ARTHUR]: lang item kind: %s",
+   LangItem::ToString (type.get_lang_item_kind ()).c_str ());
 
-   type.get_node_id ();
+   auto lang_item = Analysis::Mappings::get ()
+  .lookup_lang_item_node (type.get_lang_item_kind ())
+  .value ();
+
+   return lang_item;
   }
 
 rust_assert (type_path.get_path_kind () == AST::Path::Kind::Type);


[gcc/devel/rust/master] type-check: Remove unused capture in nr2.0

2024-12-09 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:1995c8380836eac0edc02fbb9076fba721577ef2

commit 1995c8380836eac0edc02fbb9076fba721577ef2
Author: Arthur Cohen 
Date:   Fri Nov 29 12:03:59 2024 +0100

type-check: Remove unused capture in nr2.0

gcc/rust/ChangeLog:

* typecheck/rust-hir-type-check-type.cc 
(TypeCheckType::resolve_root_path):
Remove unused capture in lambda.

Diff:
---
 gcc/rust/typecheck/rust-hir-type-check-type.cc | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/gcc/rust/typecheck/rust-hir-type-check-type.cc 
b/gcc/rust/typecheck/rust-hir-type-check-type.cc
index aaff8db99bad..2962674da62f 100644
--- a/gcc/rust/typecheck/rust-hir-type-check-type.cc
+++ b/gcc/rust/typecheck/rust-hir-type-check-type.cc
@@ -19,6 +19,7 @@
 #include "rust-hir-type-check-type.h"
 #include "options.h"
 #include "optional.h"
+#include "rust-hir-map.h"
 #include "rust-hir-trait-resolve.h"
 #include "rust-hir-type-check-expr.h"
 #include "rust-hir-path-probe.h"
@@ -394,11 +395,10 @@ TypeCheckType::resolve_root_path (HIR::TypePath &path, 
size_t *offset,
{
  auto nr_ctx
= Resolver2_0::ImmutableNameResolutionContext::get ().resolver ();
+
  // assign the ref_node_id if we've found something
  nr_ctx.lookup (path.get_mappings ().get_nodeid ())
-   .map ([&ref_node_id, &path] (NodeId resolved) {
- ref_node_id = resolved;
-   });
+   .map ([&ref_node_id] (NodeId resolved) { ref_node_id = resolved; });
}
   else if (!resolver->lookup_resolved_name (ast_node_id, &ref_node_id))
resolver->lookup_resolved_type (ast_node_id, &ref_node_id);


[gcc/devel/rust/master] derive(Copy): Use new LangItemPath

2024-12-09 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:3630428e54586413957c5b8edb4ee136a830aac2

commit 3630428e54586413957c5b8edb4ee136a830aac2
Author: Arthur Cohen 
Date:   Wed Dec 4 15:10:10 2024 +0100

derive(Copy): Use new LangItemPath

gcc/rust/ChangeLog:

* expand/rust-derive-copy.cc: Use new LangItemPath for derive(Copy).

Diff:
---
 gcc/rust/expand/rust-derive-copy.cc | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/gcc/rust/expand/rust-derive-copy.cc 
b/gcc/rust/expand/rust-derive-copy.cc
index 070a7cd63bc5..b36011dab48a 100644
--- a/gcc/rust/expand/rust-derive-copy.cc
+++ b/gcc/rust/expand/rust-derive-copy.cc
@@ -18,6 +18,8 @@
 
 #include "rust-derive-copy.h"
 #include "rust-ast-full.h"
+#include "rust-mapping-common.h"
+#include "rust-path.h"
 
 namespace Rust {
 namespace AST {
@@ -44,7 +46,7 @@ DeriveCopy::copy_impl (
   // `$crate::core::marker::Copy` instead
   auto segments = std::vector> ();
   segments.emplace_back (builder.type_path_segment ("Copy"));
-  auto copy = TypePath (std::move (segments), loc);
+  auto copy = Rust::make_unique (LangItem::Kind::COPY, loc);
 
   // we need to build up the generics for this impl block which will be just a
   // clone of the types specified ones
@@ -116,7 +118,7 @@ DeriveCopy::copy_impl (
: builder.single_generic_type_path (name, generic_args_for_self);
 
   return std::unique_ptr (
-new TraitImpl (copy, /* unsafe */ false,
+new TraitImpl (std::move (copy), /* unsafe */ false,
   /* exclam */ false, /* trait items */ {},
   std::move (impl_generics), std::move (self_type_path),
   WhereClause::create_empty (), Visibility::create_private (),


[gcc/devel/rust/master] nr2.0: Resolve lang item paths properly.

2024-12-09 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:c0513af26dc7236e0f8fd31b8f4fd8b2e3b713b7

commit c0513af26dc7236e0f8fd31b8f4fd8b2e3b713b7
Author: Arthur Cohen 
Date:   Fri Nov 29 12:35:37 2024 +0100

nr2.0: Resolve lang item paths properly.

gcc/rust/ChangeLog:

* resolve/rust-late-name-resolver-2.0.cc (Late::visit): New.
* resolve/rust-late-name-resolver-2.0.h: New.

Diff:
---
 gcc/rust/resolve/rust-late-name-resolver-2.0.cc | 20 
 gcc/rust/resolve/rust-late-name-resolver-2.0.h  |  1 +
 2 files changed, 21 insertions(+)

diff --git a/gcc/rust/resolve/rust-late-name-resolver-2.0.cc 
b/gcc/rust/resolve/rust-late-name-resolver-2.0.cc
index a96dc1ccf346..f2245c987397 100644
--- a/gcc/rust/resolve/rust-late-name-resolver-2.0.cc
+++ b/gcc/rust/resolve/rust-late-name-resolver-2.0.cc
@@ -18,6 +18,7 @@
 
 #include "optional.h"
 #include "rust-ast-full.h"
+#include "rust-diagnostics.h"
 #include "rust-hir-map.h"
 #include "rust-late-name-resolver-2.0.h"
 #include "rust-default-resolver.h"
@@ -247,6 +248,25 @@ Late::visit (AST::PathInExpression &expr)
 Definition (resolved->get_node_id ()));
 }
 
+void
+Late::visit (AST::LangItemPath &type)
+{
+  auto &mappings = Rust::Analysis::Mappings::get ();
+  auto lang_item = mappings.lookup_lang_item_node (type.get_lang_item_kind ());
+
+  if (!lang_item)
+{
+  rust_fatal_error (
+   type.get_locus (), "use of undeclared lang item %qs",
+   LangItem::ToString (type.get_lang_item_kind ()).c_str ());
+  return;
+}
+
+  ctx.map_usage (Usage (type.get_node_id ()), Definition (lang_item.value ()));
+
+  DefaultResolver::visit (type);
+}
+
 void
 Late::visit (AST::TypePath &type)
 {
diff --git a/gcc/rust/resolve/rust-late-name-resolver-2.0.h 
b/gcc/rust/resolve/rust-late-name-resolver-2.0.h
index 59077035ce3c..98cf09205bf4 100644
--- a/gcc/rust/resolve/rust-late-name-resolver-2.0.h
+++ b/gcc/rust/resolve/rust-late-name-resolver-2.0.h
@@ -46,6 +46,7 @@ public:
   // resolutions
   void visit (AST::IdentifierExpr &) override;
   void visit (AST::PathInExpression &) override;
+  void visit (AST::LangItemPath &) override;
   void visit (AST::TypePath &) override;
   void visit (AST::StructExprStruct &) override;
   void visit (AST::StructExprStructBase &) override;


[gcc/devel/rust/master] Fix ForeverStack::find_starting_point output parameter

2024-12-09 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:e6e62d48237016f7a392a80054d84a37a6ff967a

commit e6e62d48237016f7a392a80054d84a37a6ff967a
Author: Owen Avery 
Date:   Mon Nov 11 16:04:58 2024 -0500

Fix ForeverStack::find_starting_point output parameter

gcc/rust/ChangeLog:

* resolve/rust-forever-stack.h
(ForeverStack::find_starting_point): Use type
'std::reference_wrapper &' instead of 'Node &' for
parameter starting_point.
* resolve/rust-forever-stack.hxx
(ForeverStack::find_starting_point): Likewise.
(ForeverStack::resolve_path): Handle change to
ForeverStack::find_starting_point.

Signed-off-by: Owen Avery 

Diff:
---
 gcc/rust/resolve/rust-forever-stack.h   |  3 ++-
 gcc/rust/resolve/rust-forever-stack.hxx | 13 +++--
 2 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/gcc/rust/resolve/rust-forever-stack.h 
b/gcc/rust/resolve/rust-forever-stack.h
index 623e256d32c5..a05088e56aca 100644
--- a/gcc/rust/resolve/rust-forever-stack.h
+++ b/gcc/rust/resolve/rust-forever-stack.h
@@ -614,7 +614,8 @@ private:
 
   template 
   tl::optional>
-  find_starting_point (const std::vector &segments, Node &starting_point);
+  find_starting_point (const std::vector &segments,
+  std::reference_wrapper &starting_point);
 
   template 
   tl::optional resolve_segments (Node &starting_point,
diff --git a/gcc/rust/resolve/rust-forever-stack.hxx 
b/gcc/rust/resolve/rust-forever-stack.hxx
index d49488e52c25..6181c05fc6c5 100644
--- a/gcc/rust/resolve/rust-forever-stack.hxx
+++ b/gcc/rust/resolve/rust-forever-stack.hxx
@@ -374,8 +374,8 @@ check_leading_kw_at_start (const S &segment, bool condition)
 template 
 template 
 tl::optional::const_iterator>
-ForeverStack::find_starting_point (const std::vector &segments,
- Node &starting_point)
+ForeverStack::find_starting_point (
+  const std::vector &segments, std::reference_wrapper &starting_point)
 {
   auto iterator = segments.begin ();
 
@@ -412,14 +412,15 @@ ForeverStack::find_starting_point (const 
std::vector &segments,
}
   if (seg.is_super_path_seg ())
{
- if (starting_point.is_root ())
+ if (starting_point.get ().is_root ())
{
  rust_error_at (seg.get_locus (), ErrorCode::E0433,
 "too many leading % keywords");
  return tl::nullopt;
}
 
- starting_point = find_closest_module (starting_point.parent.value ());
+ starting_point
+   = find_closest_module (starting_point.get ().parent.value ());
  continue;
}
 
@@ -494,12 +495,12 @@ ForeverStack::resolve_path (const std::vector 
&segments)
   if (segments.size () == 1)
 return get (segments.back ().as_string ());
 
-  auto starting_point = cursor ();
+  std::reference_wrapper starting_point = cursor ();
 
   return find_starting_point (segments, starting_point)
 .and_then ([this, &segments, &starting_point] (
 typename std::vector::const_iterator iterator) {
-  return resolve_segments (starting_point, segments, iterator);
+  return resolve_segments (starting_point.get (), segments, iterator);
 })
 .and_then ([&segments] (Node final_node) {
   return final_node.rib.get (segments.back ().as_string ());


[gcc/devel/rust/master] ast: Add LangItemPath class

2024-12-09 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:d2025fe536db08effbe6b82bca8eeec67a55f4a4

commit d2025fe536db08effbe6b82bca8eeec67a55f4a4
Author: Arthur Cohen 
Date:   Wed Dec 4 15:09:58 2024 +0100

ast: Add LangItemPath class

This commit adds a new kind of Path, changes the base Path class and turns 
TypePath
into a child of the base Path class.

gcc/rust/ChangeLog:

* ast/rust-path.h (class LangItemPath): New.
(class TypePath): Adapt to accomodate LangItemPath.
* ast/rust-ast.cc (TraitImpl::as_string): Use new checks for lang 
items.
(QualifiedPathType::as_string): Likewise.
(FormatArgs::set_outer_attrs): Likewise.
* ast/rust-item.h (class TraitImpl): Likewise.

Diff:
---
 gcc/rust/ast/rust-ast.cc |  4 +--
 gcc/rust/ast/rust-item.h | 28 +++
 gcc/rust/ast/rust-path.h | 73 +++-
 3 files changed, 71 insertions(+), 34 deletions(-)

diff --git a/gcc/rust/ast/rust-ast.cc b/gcc/rust/ast/rust-ast.cc
index 27e62a923a5c..09e71bce745d 100644
--- a/gcc/rust/ast/rust-ast.cc
+++ b/gcc/rust/ast/rust-ast.cc
@@ -1299,7 +1299,7 @@ TraitImpl::as_string () const
   else
 str += "false";
 
-  str += "\n TypePath (to trait): " + trait_path.as_string ();
+  str += "\n TypePath (to trait): " + trait_path->as_string ();
 
   str += "\n Type (struct to impl on): " + trait_type->as_string ();
 
@@ -1561,7 +1561,7 @@ QualifiedPathType::as_string () const
   str += type_to_invoke_on->as_string ();
 
   if (has_as_clause ())
-str += " as " + trait_path.as_string ();
+str += " as " + trait_path->as_string ();
 
   return str + ">";
 }
diff --git a/gcc/rust/ast/rust-item.h b/gcc/rust/ast/rust-item.h
index 3969398f27ef..0ee131390d14 100644
--- a/gcc/rust/ast/rust-item.h
+++ b/gcc/rust/ast/rust-item.h
@@ -3172,7 +3172,7 @@ class TraitImpl : public Impl
 {
   bool has_unsafe;
   bool has_exclam;
-  TypePath trait_path;
+  std::unique_ptr trait_path;
 
   // bool has_impl_items;
   std::vector> impl_items;
@@ -3184,7 +3184,7 @@ public:
   bool has_impl_items () const { return !impl_items.empty (); }
 
   // Mega-constructor
-  TraitImpl (TypePath trait_path, bool is_unsafe, bool has_exclam,
+  TraitImpl (std::unique_ptr trait_path, bool is_unsafe, bool has_exclam,
 std::vector> impl_items,
 std::vector> generic_params,
 std::unique_ptr trait_type, WhereClause where_clause,
@@ -3197,10 +3197,26 @@ public:
   trait_path (std::move (trait_path)), impl_items (std::move (impl_items))
   {}
 
+  // Helper constructor with a typepath
+  TraitImpl (TypePath trait_path, bool is_unsafe, bool has_exclam,
+std::vector> impl_items,
+std::vector> generic_params,
+std::unique_ptr trait_type, WhereClause where_clause,
+Visibility vis, std::vector inner_attrs,
+std::vector outer_attrs, location_t locus)
+: Impl (std::move (generic_params), std::move (trait_type),
+   std::move (where_clause), std::move (vis), std::move (inner_attrs),
+   std::move (outer_attrs), locus),
+  has_unsafe (is_unsafe), has_exclam (has_exclam),
+  trait_path (std::unique_ptr (new TypePath (trait_path))),
+  impl_items (std::move (impl_items))
+  {}
+
   // Copy constructor with vector clone
   TraitImpl (TraitImpl const &other)
 : Impl (other), has_unsafe (other.has_unsafe),
-  has_exclam (other.has_exclam), trait_path (other.trait_path)
+  has_exclam (other.has_exclam),
+  trait_path (other.trait_path->clone_path ())
   {
 impl_items.reserve (other.impl_items.size ());
 for (const auto &e : other.impl_items)
@@ -3211,7 +3227,7 @@ public:
   TraitImpl &operator= (TraitImpl const &other)
   {
 Impl::operator= (other);
-trait_path = other.trait_path;
+trait_path = other.trait_path->clone_path ();
 has_unsafe = other.has_unsafe;
 has_exclam = other.has_exclam;
 
@@ -3242,10 +3258,10 @@ public:
   }
 
   // TODO: is this better? Or is a "vis_block" better?
-  TypePath &get_trait_path ()
+  Path &get_trait_path ()
   {
 // TODO: assert that trait path is not empty?
-return trait_path;
+return *trait_path;
   }
 
 protected:
diff --git a/gcc/rust/ast/rust-path.h b/gcc/rust/ast/rust-path.h
index 2df1506923d7..25f160b73550 100644
--- a/gcc/rust/ast/rust-path.h
+++ b/gcc/rust/ast/rust-path.h
@@ -589,6 +589,7 @@ public:
   {
 LangItem,
 Regular,
+Type,
   };
 
   virtual Kind get_path_kind () const = 0;
@@ -598,8 +599,8 @@ public:
 return Pattern::Kind::Path;
   }
 
-  location_t get_locus () const override final { return locus; }
-  NodeId get_node_id () const override final { return node_id; }
+  location_t get_locus () const override { return locus; }
+  NodeId get_node_id () const override { return node_id; }
 
   std::unique_ptr clone_path ()
   {
@@ -661,11 +662,12 @@ public:
 class LangItemPath : public Path
 {
   NodeId lang_item;
-  // 

[gcc/devel/rust/master] lang-item: Remove unused NodeId from LangItemPath

2024-12-09 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:ed1b4d72d9b509c90cc35e9d082eac49352dd930

commit ed1b4d72d9b509c90cc35e9d082eac49352dd930
Author: Arthur Cohen 
Date:   Fri Nov 29 13:44:59 2024 +0100

lang-item: Remove unused NodeId from LangItemPath

gcc/rust/ChangeLog:

* ast/rust-path.h: Adapt children of Path to fix some NodeId issues.

Diff:
---
 gcc/rust/ast/rust-path.h | 76 +++-
 1 file changed, 37 insertions(+), 39 deletions(-)

diff --git a/gcc/rust/ast/rust-path.h b/gcc/rust/ast/rust-path.h
index 25f160b73550..93171321ea9c 100644
--- a/gcc/rust/ast/rust-path.h
+++ b/gcc/rust/ast/rust-path.h
@@ -599,9 +599,6 @@ public:
 return Pattern::Kind::Path;
   }
 
-  location_t get_locus () const override { return locus; }
-  NodeId get_node_id () const override { return node_id; }
-
   std::unique_ptr clone_path ()
   {
 return std::unique_ptr (clone_path_impl ());
@@ -613,22 +610,19 @@ public:
   }
 
 protected:
-  location_t locus;
-  NodeId node_id;
-
-  Path (location_t locus, NodeId node_id) : locus (locus), node_id (node_id) {}
-
   virtual Path *clone_path_impl () const = 0;
 };
 
 class RegularPath : public Path
 {
   std::vector segments;
+  NodeId node_id;
+  location_t locus;
 
 public:
   explicit RegularPath (std::vector &&segments,
location_t locus, NodeId node_id)
-: Path (locus, node_id), segments (std::move (segments))
+: segments (std::move (segments)), node_id (node_id), locus (locus)
   {}
 
   std::string as_string () const override;
@@ -657,17 +651,25 @@ public:
 return new RegularPath (std::vector (segments), locus,
node_id);
   }
+
+  NodeId get_node_id () const override { return node_id; }
+  location_t get_locus () const override { return locus; }
 };
 
 class LangItemPath : public Path
 {
-  NodeId lang_item;
-
   LangItem::Kind kind;
+  NodeId node_id;
+  location_t locus;
+
+  LangItemPath (LangItem::Kind kind, NodeId node_id, location_t locus)
+: kind (kind), node_id (node_id), locus (locus)
+  {}
 
 public:
   explicit LangItemPath (LangItem::Kind kind, location_t locus)
-: Path (locus, Analysis::Mappings::get ().get_next_node_id ()), kind (kind)
+: kind (kind), node_id (Analysis::Mappings::get ().get_next_node_id ()),
+  locus (locus)
   {}
 
   Path::Kind get_path_kind () const override { return Path::Kind::LangItem; }
@@ -676,12 +678,15 @@ public:
 
   Path *clone_path_impl () const override
   {
-return new LangItemPath (kind, locus);
+return new LangItemPath (kind, node_id, locus);
   }
 
   std::string as_string () const override;
 
   LangItem::Kind get_lang_item_kind () { return kind; }
+
+  NodeId get_node_id () const override { return node_id; }
+  location_t get_locus () const override { return locus; }
 };
 
 /* AST node representing a path-in-expression pattern (path that allows
@@ -739,11 +744,10 @@ public:
   // Returns whether path in expression is in an error state.
   bool is_error () const
   {
-// FIXME: Cleanup
 if (path->get_path_kind () == Path::Kind::Regular)
   return !static_cast (*path).has_segments ();
 
-return false;
+rust_unreachable ();
   }
 
   /* Converts PathInExpression to SimplePath if possible (i.e. no generic
@@ -822,7 +826,7 @@ public:
 if (path->get_path_kind () == Path::Kind::Regular)
   return static_cast (*path).get_segments ().size () == 1;
 
-return false;
+rust_unreachable ();
   }
 
   Pattern::Kind get_pattern_kind () override { return Pattern::Kind::Path; }
@@ -1201,17 +1205,13 @@ public:
   }
 };
 
-// Path used inside types
 class TypePath : public TypeNoBounds, public Path
 {
   bool has_opening_scope_resolution;
   std::vector > segments;
+  location_t locus;
 
 protected:
-  Kind get_path_kind () const override { return Kind::Type; }
-
-  Path *clone_path_impl () const override { return new TypePath (*this); }
-
   /* Use covariance to implement clone function as returning this object
* rather than base */
   TypePath *clone_type_no_bounds_impl () const override
@@ -1234,23 +1234,23 @@ public:
   static TypePath create_error ()
   {
 return TypePath (std::vector > (),
-UNKNOWN_LOCATION);
+UNDEF_LOCATION);
   }
 
   // Constructor
   TypePath (std::vector > segments,
location_t locus, bool has_opening_scope_resolution = false)
 : TypeNoBounds (),
-  Path (locus, Analysis::Mappings::get ().get_next_node_id ()),
   has_opening_scope_resolution (has_opening_scope_resolution),
-  segments (std::move (segments))
+  segments (std::move (segments)), locus (locus)
   {}
 
   // Copy constructor with vector clone
   TypePath (TypePath const &other)
-: Path (other.locus, other.Path::get_node_id ()),
-  has_opening_scope_resolution (other.has_opening_scope_resolution)
+: has_opening_scope_resolution (other.has_opening_scope_resolution),
+  locus (other.locus)
   {

[gcc(refs/users/mikael/heads/refactor_descriptor_v01)] Correction regression allocatable attribute

2024-12-09 Thread Mikael Morin via Gcc-cvs
https://gcc.gnu.org/g:9853930e77ff40078af79cdc349ed79d531749f4

commit 9853930e77ff40078af79cdc349ed79d531749f4
Author: Mikael Morin 
Date:   Mon Dec 9 17:53:58 2024 +0100

Correction regression allocatable attribute

Diff:
---
 gcc/fortran/primary.cc | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/gcc/fortran/primary.cc b/gcc/fortran/primary.cc
index cbc1eafdf768..a92d42e130ac 100644
--- a/gcc/fortran/primary.cc
+++ b/gcc/fortran/primary.cc
@@ -2914,7 +2914,6 @@ gfc_symbol_attr (gfc_symbol *sym)
   attr.pointer = pointer;
   attr.allocatable = allocatable;
   attr.target = target;
-  attr.save = sym->attr.save;
 
   return attr;
 }
@@ -2955,8 +2954,6 @@ gfc_variable_attr (gfc_expr *expr, gfc_typespec *ts)
   sym = expr->symtree->n.sym;
   attr = gfc_symbol_attr (sym);
 
-  attr = sym->attr;
-
   optional = attr.optional;
   dimension = attr.dimension;
   codimension = attr.codimension;


[gcc r15-6051] clang-format AlwaysBreakAfterReturnType to TopLevelDefinitions

2024-12-09 Thread Matthew Malcomson via Gcc-cvs
https://gcc.gnu.org/g:0c83096f19b075ac1b80113828188a0fd64400af

commit r15-6051-g0c83096f19b075ac1b80113828188a0fd64400af
Author: Matthew Malcomson 
Date:   Mon Dec 9 10:51:44 2024 +

clang-format AlwaysBreakAfterReturnType to TopLevelDefinitions

The previous value of TopLevel meant that the function name of
declarations would also be on a new line.  THis does not match the
current formatting of headers.

Manual testing done on c-common.h.

Also set BraceWrapping.BeforeWhile to true to match the formatting
specified for do/while loops in GNU coding standards.
https://www.gnu.org/prep/standards/standards.html#Formatting

Ok for trunk?

contrib/ChangeLog:

* clang-format: AlwaysBreakAfterReturnType set to
TopLevelDefinitions and BraceWrapping.BeforeWhile set to true.

Signed-off-by: Matthew Malcomson 

Diff:
---
 contrib/clang-format | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/contrib/clang-format b/contrib/clang-format
index 95f1455c14db..4ed50ab6b268 100644
--- a/contrib/clang-format
+++ b/contrib/clang-format
@@ -27,7 +27,7 @@
 ---
 Language: Cpp
 AccessModifierOffset: -2
-AlwaysBreakAfterReturnType: TopLevel
+AlwaysBreakAfterReturnType: TopLevelDefinitions
 BinPackArguments: true
 BinPackParameters: true
 BraceWrapping:
@@ -42,6 +42,7 @@ BraceWrapping:
   AfterUnion: true
   BeforeCatch: true
   BeforeElse: true
+  BeforeWhile: true
   IndentBraces: true
   SplitEmptyFunction: false
 BreakBeforeBinaryOperators: All


[gcc(refs/users/mikael/heads/refactor_descriptor_v01)] conversion type longueur chaine

2024-12-09 Thread Mikael Morin via Gcc-cvs
https://gcc.gnu.org/g:041909cf06af6008ce66111ffee57559ae546d94

commit 041909cf06af6008ce66111ffee57559ae546d94
Author: Mikael Morin 
Date:   Mon Dec 9 18:54:49 2024 +0100

conversion type longueur chaine

Diff:
---
 gcc/fortran/trans-array.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc
index 284c20eef8ed..38cea95840b6 100644
--- a/gcc/fortran/trans-array.cc
+++ b/gcc/fortran/trans-array.cc
@@ -596,7 +596,7 @@ get_size_info (gfc_typespec &ts)
tree len = ts.u.cl->backend_decl;
return fold_build2_loc (input_location, MULT_EXPR, size_type_node,
size_in_bytes (elt_type),
-   len);
+   fold_convert (size_type_node, len));
   }
 
 case BT_CLASS:


[gcc r15-6054] driver: fix crash with --diagnostics-plain-output [PR117942]

2024-12-09 Thread Marek Polacek via Gcc-cvs
https://gcc.gnu.org/g:be2062be9a629ae18a0c87c6b9cbe1885978417e

commit r15-6054-gbe2062be9a629ae18a0c87c6b9cbe1885978417e
Author: Marek Polacek 
Date:   Mon Dec 9 08:19:35 2024 -0500

driver: fix crash with --diagnostics-plain-output [PR117942]

We are crashing here because decode_cmdline_options_to_array has:

  if (!strcmp (opt, "-fdiagnostics-plain-output"))
...

but that doesn't handle the '--FLAG' variant.

PR driver/117942

gcc/ChangeLog:

* opts-common.cc (decode_cmdline_options_to_array): Also detect
--diagnostics-plain-output.

Reviewed-by: Joseph Myers 

Diff:
---
 gcc/opts-common.cc | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/gcc/opts-common.cc b/gcc/opts-common.cc
index 2594e5a56432..e85920bcb652 100644
--- a/gcc/opts-common.cc
+++ b/gcc/opts-common.cc
@@ -1077,7 +1077,9 @@ decode_cmdline_options_to_array (unsigned int argc, const 
char **argv,
   /* Expand -fdiagnostics-plain-output to its constituents.  This needs
 to happen here so that prune_options can handle -fdiagnostics-color
 specially.  */
-  if (!strcmp (opt, "-fdiagnostics-plain-output"))
+  if (opt[0] == '-'
+ && (opt[1] == '-' || opt[1] == 'f')
+ && !strcmp (opt + 2, "diagnostics-plain-output"))
{
  /* If you have changed the default diagnostics output, and this new
 output is not appropriately "plain" (e.g., the change needs to be


[gcc r15-6058] libstdc++: port away from is_trivial in string classes

2024-12-09 Thread Jonathan Wakely via Gcc-cvs
https://gcc.gnu.org/g:00ee881811f64f261465b39abd3c9c278be584b6

commit r15-6058-g00ee881811f64f261465b39abd3c9c278be584b6
Author: Giuseppe D'Angelo 
Date:   Mon Dec 9 01:43:27 2024 +0100

libstdc++: port away from is_trivial in string classes

In preparation for the deprecation of is_trivial (P3247R2), stop using
it from std::string_view. Also, add the same detection to std::string
(described in [strings.general]/2).

libstdc++-v3/ChangeLog:

* include/bits/basic_string.h: Add a static_assert on the
char-like type.
* include/std/string_view: Port away from is_trivial.

Signed-off-by: Giuseppe D'Angelo 

Diff:
---
 libstdc++-v3/include/bits/basic_string.h | 3 +++
 libstdc++-v3/include/std/string_view | 4 +++-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/libstdc++-v3/include/bits/basic_string.h 
b/libstdc++-v3/include/bits/basic_string.h
index 17b973c8b45c..8369c24d3ae3 100644
--- a/libstdc++-v3/include/bits/basic_string.h
+++ b/libstdc++-v3/include/bits/basic_string.h
@@ -88,6 +88,9 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
 class basic_string
 {
 #if __cplusplus >= 202002L
+  static_assert(is_trivially_copyable_v<_CharT>
+ && is_trivially_default_constructible_v<_CharT>
+ && is_standard_layout_v<_CharT>);
   static_assert(is_same_v<_CharT, typename _Traits::char_type>);
   static_assert(is_same_v<_CharT, typename _Alloc::value_type>);
   using _Char_alloc_type = _Alloc;
diff --git a/libstdc++-v3/include/std/string_view 
b/libstdc++-v3/include/std/string_view
index 96350f96b3c0..493edec26dc8 100644
--- a/libstdc++-v3/include/std/string_view
+++ b/libstdc++-v3/include/std/string_view
@@ -108,7 +108,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 class basic_string_view
 {
   static_assert(!is_array_v<_CharT>);
-  static_assert(is_trivial_v<_CharT> && is_standard_layout_v<_CharT>);
+  static_assert(is_trivially_copyable_v<_CharT>
+ && is_trivially_default_constructible_v<_CharT>
+ && is_standard_layout_v<_CharT>);
   static_assert(is_same_v<_CharT, typename _Traits::char_type>);
 
 public:


[gcc r15-6063] libstdc++: deprecate is_trivial for C++26 (P3247R2)

2024-12-09 Thread Jonathan Wakely via Libstdc++-cvs
https://gcc.gnu.org/g:6c41a912f5e654a1b6f7cf8d6b23f00d8612988c

commit r15-6063-g6c41a912f5e654a1b6f7cf8d6b23f00d8612988c
Author: Giuseppe D'Angelo 
Date:   Mon Dec 9 01:28:08 2024 +0100

libstdc++: deprecate is_trivial for C++26 (P3247R2)

This actually implements P3247R2 by deprecating the is_trivial type
trait.

libstdc++-v3/ChangeLog:

* include/std/type_traits: Deprecate is_trivial and
is_trivial_v.
* include/experimental/type_traits: Suppress the deprecation
warning.
* 
testsuite/20_util/is_trivial/requirements/explicit_instantiation.cc:
Amend the test to suppress the deprecation warning.
* testsuite/20_util/is_trivial/requirements/typedefs.cc:
Likewise.
* testsuite/20_util/is_trivial/value.cc: Likewise.
* testsuite/20_util/variable_templates_for_traits.cc: Likewise.
* testsuite/experimental/type_traits/value.cc: Likewise.
* testsuite/18_support/max_align_t/requirements/2.cc: Update the
test with P3247R2's new wording.

Signed-off-by: Giuseppe D'Angelo 

Diff:
---
 libstdc++-v3/include/experimental/type_traits   |  3 +++
 libstdc++-v3/include/std/type_traits| 13 +++--
 .../testsuite/18_support/max_align_t/requirements/2.cc  |  4 
 .../is_trivial/requirements/explicit_instantiation.cc   |  3 +++
 .../testsuite/20_util/is_trivial/requirements/typedefs.cc   |  3 +++
 libstdc++-v3/testsuite/20_util/is_trivial/value.cc  |  3 +++
 .../testsuite/20_util/variable_templates_for_traits.cc  |  4 
 libstdc++-v3/testsuite/experimental/type_traits/value.cc|  4 
 8 files changed, 35 insertions(+), 2 deletions(-)

diff --git a/libstdc++-v3/include/experimental/type_traits 
b/libstdc++-v3/include/experimental/type_traits
index 25bb21744207..917ac2d34053 100644
--- a/libstdc++-v3/include/experimental/type_traits
+++ b/libstdc++-v3/include/experimental/type_traits
@@ -121,8 +121,11 @@ template 
   constexpr bool is_const_v = is_const<_Tp>::value;
 template 
   constexpr bool is_volatile_v = is_volatile<_Tp>::value;
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
 template 
   constexpr bool is_trivial_v = is_trivial<_Tp>::value;
+#pragma GCC diagnostic pop
 template 
   constexpr bool is_trivially_copyable_v = is_trivially_copyable<_Tp>::value;
 template 
diff --git a/libstdc++-v3/include/std/type_traits 
b/libstdc++-v3/include/std/type_traits
index c650094f8c52..ae410f05a9cd 100644
--- a/libstdc++-v3/include/std/type_traits
+++ b/libstdc++-v3/include/std/type_traits
@@ -885,9 +885,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 : public true_type { };
 #endif
 
-  /// is_trivial
+  /** is_trivial
+   * @deprecated Deprecated in C++26.
+   * Use a combination of one or more more specialized type traits instead,
+   * such as `is_trivially_default_constructible`,
+   * `is_trivially_copy_constructible`, `is_trivially_copy_assignable`,
+   * etc., depending on the exact check(s) needed.
+   */
   template
-struct is_trivial
+struct
+_GLIBCXX26_DEPRECATED_SUGGEST("is_trivially_default_constructible && 
is_trivially_copyable")
+is_trivial
 : public __bool_constant<__is_trivial(_Tp)>
 {
   static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}),
@@ -3518,6 +3526,7 @@ template 
 #endif
 
 template 
+  _GLIBCXX26_DEPRECATED_SUGGEST("is_trivially_default_constructible_v && 
is_trivially_copyable_v")
   inline constexpr bool is_trivial_v = __is_trivial(_Tp);
 template 
   inline constexpr bool is_trivially_copyable_v = __is_trivially_copyable(_Tp);
diff --git a/libstdc++-v3/testsuite/18_support/max_align_t/requirements/2.cc 
b/libstdc++-v3/testsuite/18_support/max_align_t/requirements/2.cc
index b61a4b2b35d4..c496ad674254 100644
--- a/libstdc++-v3/testsuite/18_support/max_align_t/requirements/2.cc
+++ b/libstdc++-v3/testsuite/18_support/max_align_t/requirements/2.cc
@@ -24,4 +24,8 @@
 static_assert (std::is_pod::value, "");
 #endif
 static_assert (std::is_standard_layout::value, "");
+static_assert (std::is_trivially_copyable::value, "");
+static_assert 
(std::is_trivially_default_constructible::value, "");
+#if __cplusplus <= 202302L
 static_assert (std::is_trivial::value, "");
+#endif
diff --git 
a/libstdc++-v3/testsuite/20_util/is_trivial/requirements/explicit_instantiation.cc
 
b/libstdc++-v3/testsuite/20_util/is_trivial/requirements/explicit_instantiation.cc
index bace0ed00583..e66b7d4b27d9 100644
--- 
a/libstdc++-v3/testsuite/20_util/is_trivial/requirements/explicit_instantiation.cc
+++ 
b/libstdc++-v3/testsuite/20_util/is_trivial/requirements/explicit_instantiation.cc
@@ -25,5 +25,8 @@
 namespace std
 {
   typedef short test_type;
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
   template struct is_trivial;
+#pragma GCC diagnostic pop

[gcc r15-6060] libstdc++: port bitwise relocatable away from is_trivial

2024-12-09 Thread Jonathan Wakely via Gcc-cvs
https://gcc.gnu.org/g:e4a0157c2397c9b582cff71d114240a6b083a3dc

commit r15-6060-ge4a0157c2397c9b582cff71d114240a6b083a3dc
Author: Giuseppe D'Angelo 
Date:   Mon Dec 9 02:11:19 2024 +0100

libstdc++: port bitwise relocatable away from is_trivial

In preparation for the deprecation of is_trivial (P3247R2).
"bitwise relocation" (or "trivial relocation" à la P1144/P2786)
doesn't need the full-fledged notion of triviality, just checking for a
trivial move constructor and a trivial destructor is sufficient.

libstdc++-v3/ChangeLog:

* include/bits/stl_uninitialized.h: Amended the
__is_bitwise_relocatable type trait.

Signed-off-by: Giuseppe D'Angelo 

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

diff --git a/libstdc++-v3/include/bits/stl_uninitialized.h 
b/libstdc++-v3/include/bits/stl_uninitialized.h
index 2190261134e0..916288352d70 100644
--- a/libstdc++-v3/include/bits/stl_uninitialized.h
+++ b/libstdc++-v3/include/bits/stl_uninitialized.h
@@ -1248,7 +1248,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   // Also known as is_trivially_relocatable.
   template
 struct __is_bitwise_relocatable
-: is_trivial<_Tp> { };
+: __and_, 
is_trivially_destructible<_Tp>> { };
 
   template 


[gcc r15-6061] libstdc++: port the ranges::uninitialized_* algorithms away from is_trivial

2024-12-09 Thread Jonathan Wakely via Gcc-cvs
https://gcc.gnu.org/g:95c7a61a8b5003793d156c2833e350dd1e96712c

commit r15-6061-g95c7a61a8b5003793d156c2833e350dd1e96712c
Author: Giuseppe D'Angelo 
Date:   Mon Dec 9 02:22:23 2024 +0100

libstdc++: port the ranges::uninitialized_* algorithms away from is_trivial

In preparation for the deprecation of is_trivial (P3247R2).
The rangified uninitialized_* specialized memory algorithms have code
paths where they call the non-uninitialized versions, because the latter
are usually optimized. The detection in these code paths uses is_trivial;
port it away from it towards more specific checks.

The detection for the copy/move algorithms was suspicious: it checked
that the output type was trivial, and that assignment from the input
range reference type was nothrow. If so, the algorithm would copy/move
assign (by calling the ranges::copy/move algorithms) instead of
constructing elements. I think this is off because:

1) the constructor that would be called by the algorithm (which may be
   neither a copy or a move constructor) wasn't checked. If that
   constructor isn't trivial the caller might detect that we're not
   calling it, and that goes against the algorithms' specifications.
2) a nothrow assignment is necessary but not sufficient, as again we
   need to check for triviality, or the caller can detect we're calling
   an assignment operator we were never meant to be calling from these
   algorithms.

Therefore I've amended the respective detections.

libstdc++-v3/ChangeLog:

* include/bits/ranges_uninitialized.h: port some if
constexpr away from is_trivial, and towards more specific
detections instead.

Signed-off-by: Giuseppe D'Angelo 

Diff:
---
 libstdc++-v3/include/bits/ranges_uninitialized.h | 36 +---
 1 file changed, 20 insertions(+), 16 deletions(-)

diff --git a/libstdc++-v3/include/bits/ranges_uninitialized.h 
b/libstdc++-v3/include/bits/ranges_uninitialized.h
index f16f2ef39f59..ff673d58be75 100644
--- a/libstdc++-v3/include/bits/ranges_uninitialized.h
+++ b/libstdc++-v3/include/bits/ranges_uninitialized.h
@@ -202,8 +202,8 @@ namespace ranges
   operator()(_Iter __first, _Sent __last) const
   {
using _ValueType = remove_reference_t>;
-   if constexpr (is_trivial_v<_ValueType>
- && is_copy_assignable_v<_ValueType>)
+   if constexpr (is_trivially_default_constructible_v<_ValueType>
+ && is_trivially_copy_assignable_v<_ValueType>)
  return ranges::fill(__first, __last, _ValueType());
else
  {
@@ -235,8 +235,8 @@ namespace ranges
   operator()(_Iter __first, iter_difference_t<_Iter> __n) const
   {
using _ValueType = remove_reference_t>;
-   if constexpr (is_trivial_v<_ValueType>
- && is_copy_assignable_v<_ValueType>)
+   if constexpr (is_trivially_default_constructible_v<_ValueType>
+ && is_trivially_copy_assignable_v<_ValueType>)
  return ranges::fill_n(__first, __n, _ValueType());
else
  {
@@ -268,8 +268,9 @@ namespace ranges
using _OutType = remove_reference_t>;
if constexpr (sized_sentinel_for<_ISent, _Iter>
  && sized_sentinel_for<_OSent, _Out>
- && is_trivial_v<_OutType>
- && is_nothrow_assignable_v<_OutType&,
+ && is_trivially_constructible_v<_OutType, 
iter_reference_t<_Iter>>
+ && is_trivially_default_constructible_v<_OutType>
+ && is_trivially_assignable_v<_OutType&,
 iter_reference_t<_Iter>>)
  {
auto __d1 = __ilast - __ifirst;
@@ -316,8 +317,9 @@ namespace ranges
   {
using _OutType = remove_reference_t>;
if constexpr (sized_sentinel_for<_Sent, _Out>
- && is_trivial_v<_OutType>
- && is_nothrow_assignable_v<_OutType&,
+ && is_trivially_constructible_v<_OutType, 
iter_reference_t<_Iter>>
+ && is_trivially_default_constructible_v<_OutType>
+ && is_trivially_assignable_v<_OutType&,
 iter_reference_t<_Iter>>)
  {
auto __d = __olast - __ofirst;
@@ -355,8 +357,9 @@ namespace ranges
using _OutType = remove_reference_t>;
if constexpr (sized_sentinel_for<_ISent, _Iter>
  && sized_sentinel_for<_OSent, _Out>
- && is_trivial_v<_OutType>
- && is_nothrow_assignable_v<_OutType&,
+ && is_trivially_constructible_v<_OutType, 
iter_rvalue_reference_t<_Iter>>
+ && is_trivially_default_constructible_v<_OutType>
+ && is_trivially_assignable_v<_OutType&

[gcc r15-6059] libstdc++: pstl: port away from is_trivial

2024-12-09 Thread Jonathan Wakely via Libstdc++-cvs
https://gcc.gnu.org/g:65b5b828123abb925cca1cbb5bab31da31bfbbd7

commit r15-6059-g65b5b828123abb925cca1cbb5bab31da31bfbbd7
Author: Giuseppe D'Angelo 
Date:   Mon Dec 9 02:06:25 2024 +0100

libstdc++: pstl: port away from is_trivial

In preparation for the deprecation of is_trivial (P3247R2).
Unfortunately I am unable to fully understand what aspect of triviality
seems to matter for these algorithms, so I just ported is_trivial to its
direct equivalent (trivially copyable + trivially default
constructible.)

libstdc++-v3/ChangeLog:

* include/pstl/algorithm_impl.h (__remove_elements): Port away
from is_trivial.
(__pattern_inplace_merge): Likewise.
* include/pstl/glue_memory_impl.h (uninitialized_copy): Likewise.
(uninitialized_copy_n): Likewise.
(uninitialized_move): Likewise.
(uninitialized_move_n): Likewise.
(uninitialized_default_construct): Likewise.
(uninitialized_default_construct_n): Likewise.
(uninitialized_value_construct): Likewise.
(uninitialized_value_construct_n): Likewise.
* 
testsuite/20_util/specialized_algorithms/pstl/uninitialized_construct.cc:
Likewise.
* 
testsuite/20_util/specialized_algorithms/pstl/uninitialized_copy_move.cc:
Likewise.
* 
testsuite/20_util/specialized_algorithms/pstl/uninitialized_fill_destroy.cc:
Likewise.
* 
testsuite/25_algorithms/pstl/alg_modifying_operations/partition.cc:
Likewise.

Signed-off-by: Giuseppe D'Angelo 

Diff:
---
 libstdc++-v3/include/pstl/algorithm_impl.h  |  9 ++---
 libstdc++-v3/include/pstl/glue_memory_impl.h| 21 +
 .../pstl/uninitialized_construct.cc |  2 +-
 .../pstl/uninitialized_copy_move.cc |  2 +-
 .../pstl/uninitialized_fill_destroy.cc  |  2 +-
 .../pstl/alg_modifying_operations/partition.cc  | 13 +++--
 6 files changed, 33 insertions(+), 16 deletions(-)

diff --git a/libstdc++-v3/include/pstl/algorithm_impl.h 
b/libstdc++-v3/include/pstl/algorithm_impl.h
index 1403b02280f5..5b1cd2010944 100644
--- a/libstdc++-v3/include/pstl/algorithm_impl.h
+++ b/libstdc++-v3/include/pstl/algorithm_impl.h
@@ -1297,7 +1297,8 @@ __remove_elements(__parallel_tag<_IsVector> __tag, 
_ExecutionPolicy&& __exec, _F
 [](_ForwardIterator __x, _Tp* __z)
 {
 __internal::__invoke_if_else(
-std::is_trivial<_Tp>(), [&]() { *__z = 
std::move(*__x); },
+std::conjunction, 
std::is_trivially_default_constructible<_Tp>>(),
+[&]() { *__z = std::move(*__x); },
 [&]() { ::new (std::addressof(*__z)) 
_Tp(std::move(*__x)); });
 },
 _IsVector{});
@@ -1310,7 +1311,8 @@ __remove_elements(__parallel_tag<_IsVector> __tag, 
_ExecutionPolicy&& __exec, _F
 [__result, __first](_Tp* __i, _Tp* __j)
 {
 __invoke_if_else(
-std::is_trivial<_Tp>(), [&]() { __brick_move(__i, __j, 
__first + (__i - __result), _IsVector{}); },
+std::conjunction, 
std::is_trivially_default_constructible<_Tp>>(),
+[&]() { __brick_move(__i, __j, __first + (__i - __result), 
_IsVector{}); },
 [&]() { __brick_move_destroy()(__i, __j, __first + (__i - 
__result), _IsVector{}); });
 });
 return __first + __m;
@@ -2794,7 +2796,8 @@ __pattern_inplace_merge(__parallel_tag<_IsVector> __tag, 
_ExecutionPolicy&& __ex
 auto __move_values = [](_RandomAccessIterator __x, _Tp* __z)
 {
 __internal::__invoke_if_else(
-std::is_trivial<_Tp>(), [&]() { *__z = std::move(*__x); },
+std::conjunction, 
std::is_trivially_default_constructible<_Tp>>(),
+[&]() { *__z = std::move(*__x); },
 [&]() { ::new (std::addressof(*__z)) _Tp(std::move(*__x)); 
});
 };
 
diff --git a/libstdc++-v3/include/pstl/glue_memory_impl.h 
b/libstdc++-v3/include/pstl/glue_memory_impl.h
index 7850605f94a5..0f37fbbf2140 100644
--- a/libstdc++-v3/include/pstl/glue_memory_impl.h
+++ b/libstdc++-v3/include/pstl/glue_memory_impl.h
@@ -34,7 +34,8 @@ uninitialized_copy(_ExecutionPolicy&& __exec, _InputIterator 
__first, _InputIter
 using __is_vector = typename decltype(__dispatch_tag)::__is_vector;
 
 return __pstl::__internal::__invoke_if_else(
-std::integral_constant < bool, std::is_trivial<_ValueType1>::value&& 
std::is_trivial<_ValueType2>::value > (),
+std::conjunction, 
std::is_trivially_default_constructible<_ValueType1>,
+ std::is_trivially_copyable<_ValueType2>, 
std::is_tri

[gcc r15-6062] libstdc++: port tests away from is_trivial

2024-12-09 Thread Jonathan Wakely via Libstdc++-cvs
https://gcc.gnu.org/g:e663f8f39fa6d6bec57c902230d93e2693363bcf

commit r15-6062-ge663f8f39fa6d6bec57c902230d93e2693363bcf
Author: Giuseppe D'Angelo 
Date:   Mon Dec 9 02:44:30 2024 +0100

libstdc++: port tests away from is_trivial

In preparation for the deprecation of is_trivial (P3247R2).
Mostly a mechanical exercise, replacing is_trivial with
is_trivially_copyable and/or is_trivially_default_constructible
depending on the cases.

libstdc++-v3/ChangeLog:

* 
testsuite/20_util/specialized_algorithms/uninitialized_copy/102064.cc:
Port away from is_trivial.
* 
testsuite/20_util/specialized_algorithms/uninitialized_copy_n/102064.cc:
Likewise.
* 
testsuite/20_util/specialized_algorithms/uninitialized_default/94540.cc:
Likewise.
* 
testsuite/20_util/specialized_algorithms/uninitialized_default_n/94540.cc:
Likewise.
* 
testsuite/20_util/specialized_algorithms/uninitialized_fill/102064.cc:
Likewise.
* 
testsuite/20_util/specialized_algorithms/uninitialized_fill_n/102064.cc:
Likewise.
* 
testsuite/20_util/specialized_algorithms/uninitialized_value_construct/94540.cc:
Likewise.
* 
testsuite/20_util/specialized_algorithms/uninitialized_value_construct_n/94540.cc:
Likewise.
* testsuite/23_containers/vector/cons/94540.cc: Likewise.
* testsuite/25_algorithms/copy/move_iterators/69478.cc:
Likewise.
* testsuite/25_algorithms/copy_backward/move_iterators/69478.cc:
Likewise.
* testsuite/25_algorithms/move/69478.cc: Likewise.
* testsuite/25_algorithms/move_backward/69478.cc: Likewise.
* testsuite/25_algorithms/rotate/constrained.cc: Likewise.
* testsuite/25_algorithms/rotate_copy/constrained.cc: Likewise.

Signed-off-by: Giuseppe D'Angelo 

Diff:
---
 .../20_util/specialized_algorithms/uninitialized_copy/102064.cc | 6 --
 .../20_util/specialized_algorithms/uninitialized_copy_n/102064.cc   | 6 --
 .../20_util/specialized_algorithms/uninitialized_default/94540.cc   | 3 ++-
 .../20_util/specialized_algorithms/uninitialized_default_n/94540.cc | 3 ++-
 .../20_util/specialized_algorithms/uninitialized_fill/102064.cc | 6 --
 .../20_util/specialized_algorithms/uninitialized_fill_n/102064.cc   | 6 --
 .../specialized_algorithms/uninitialized_value_construct/94540.cc   | 3 ++-
 .../specialized_algorithms/uninitialized_value_construct_n/94540.cc | 3 ++-
 libstdc++-v3/testsuite/23_containers/vector/cons/94540.cc   | 3 ++-
 libstdc++-v3/testsuite/25_algorithms/copy/move_iterators/69478.cc   | 3 ++-
 .../testsuite/25_algorithms/copy_backward/move_iterators/69478.cc   | 3 ++-
 libstdc++-v3/testsuite/25_algorithms/move/69478.cc  | 3 ++-
 libstdc++-v3/testsuite/25_algorithms/move_backward/69478.cc | 3 ++-
 libstdc++-v3/testsuite/25_algorithms/rotate/constrained.cc  | 2 +-
 libstdc++-v3/testsuite/25_algorithms/rotate_copy/constrained.cc | 2 +-
 15 files changed, 36 insertions(+), 19 deletions(-)

diff --git 
a/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_copy/102064.cc
 
b/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_copy/102064.cc
index 27d37aab09f4..83caaaec1376 100644
--- 
a/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_copy/102064.cc
+++ 
b/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_copy/102064.cc
@@ -19,7 +19,8 @@ private:
 Y::operator X() const { return X(); }
 
 #if __cplusplus >= 201103L
-static_assert( std::is_trivial::value, "" );
+static_assert( std::is_trivially_default_constructible::value, "" );
+static_assert( std::is_trivially_copyable::value, "" );
 #endif
 
 void test01_pr102064()
@@ -40,7 +41,8 @@ struct Z
   Z& operator=(int) = delete;
 };
 
-static_assert( std::is_trivial::value, "" );
+static_assert( std::is_trivially_default_constructible::value, "" );
+static_assert( std::is_trivially_copyable::value, "" );
 
 void test02_pr102064()
 {
diff --git 
a/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_copy_n/102064.cc
 
b/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_copy_n/102064.cc
index 963e1531a71b..bb0850a34c1d 100644
--- 
a/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_copy_n/102064.cc
+++ 
b/libstdc++-v3/testsuite/20_util/specialized_algorithms/uninitialized_copy_n/102064.cc
@@ -18,7 +18,8 @@ private:
 
 Y::operator X() const { return X(); }
 
-static_assert( std::is_trivial::value, "" );
+static_assert( std::is_trivially_default_constructible::value, "" );
+static_assert( std::is_trivially_copyable::value, "" );
 
 void test01_pr102064()
 {
@@ -37,7 +38,8 @@ struct Z
   Z& operator=(int) = delete;
 };
 
-static_assert( std::is_trivial::value, "" );
+static

[gcc r15-6068] RISC-V: Refine signed vector SAT_TRUNC testcase dump check to tree optimized

2024-12-09 Thread Pan Li via Gcc-cvs
https://gcc.gnu.org/g:75d518100ed7554b0d4ae7df72e25110f3a4e180

commit r15-6068-g75d518100ed7554b0d4ae7df72e25110f3a4e180
Author: Pan Li 
Date:   Sun Dec 8 19:56:20 2024 +0800

RISC-V: Refine signed vector SAT_TRUNC testcase dump check to tree optimized

The sat alu related testcase check the rtl dump for the standard name
like .SAT_TRUNC exist or not.  But the rtl pass expand is somehow
impressionable by the middle-end change or debug information.  Like
below new appearance recently.

Replacing Expressions
_5 replace with --> _5 = .SAT_TRUNC (x_3(D), y_4(D)); [tail call]

After that we need to adjust the dump check time and again.  This
patch would like to switch to tree optimized pass for the standard
name check, which is more stable up to a point.

The below test suites are passed for this patch.
* The rv64gcv fully regression test.

It is test only patch and obvious up to a point, will commit it
directly if no comments in next 48H.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_trunc-1-i16-to-i8.c: 
Take
tree-optimized pass for standard name check, and adjust the times.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_trunc-1-i32-to-i16.c: 
Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_trunc-1-i32-to-i8.c: 
Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_trunc-1-i64-to-i16.c: 
Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_trunc-1-i64-to-i32.c: 
Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_trunc-1-i64-to-i8.c: 
Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_trunc-2-i16-to-i8.c: 
Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_trunc-2-i32-to-i16.c: 
Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_trunc-2-i32-to-i8.c: 
Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_trunc-2-i64-to-i16.c: 
Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_trunc-2-i64-to-i32.c: 
Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_trunc-2-i64-to-i8.c: 
Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_trunc-3-i16-to-i8.c: 
Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_trunc-3-i32-to-i16.c: 
Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_trunc-3-i32-to-i8.c: 
Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_trunc-3-i64-to-i16.c: 
Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_trunc-3-i64-to-i32.c: 
Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_trunc-3-i64-to-i8.c: 
Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_trunc-4-i16-to-i8.c: 
Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_trunc-4-i32-to-i16.c: 
Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_trunc-4-i32-to-i8.c: 
Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_trunc-4-i64-to-i16.c: 
Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_trunc-4-i64-to-i32.c: 
Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_trunc-4-i64-to-i8.c: 
Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_trunc-5-i16-to-i8.c: 
Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_trunc-5-i32-to-i16.c: 
Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_trunc-5-i32-to-i8.c: 
Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_trunc-5-i64-to-i16.c: 
Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_trunc-5-i64-to-i32.c: 
Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_trunc-5-i64-to-i8.c: 
Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_trunc-6-i16-to-i8.c: 
Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_trunc-6-i32-to-i16.c: 
Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_trunc-6-i32-to-i8.c: 
Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_trunc-6-i64-to-i16.c: 
Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_trunc-6-i64-to-i32.c: 
Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_trunc-6-i64-to-i8.c: 
Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_trunc-7-i16-to-i8.c: 
Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_trunc-7-i32-to-i16.c: 
Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_trunc-7-i32-to-i8.c: 
Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_trunc-7-i64-to-i16.c: 
Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_trunc-7-i64-to-i32.c: 
Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_trunc-7-i64-to-i8.c: 
Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_trunc-8-i16-to-i8.c: 
Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_trunc-8-i32-to-i16.c: 
Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_

[gcc r15-6069] RISC-V: Refine signed vector SAT_SUB testcase dump check to tree optimized

2024-12-09 Thread Pan Li via Gcc-cvs
https://gcc.gnu.org/g:6fbff06f9e39d75962b1cf5bfefb3d717ba4ace4

commit r15-6069-g6fbff06f9e39d75962b1cf5bfefb3d717ba4ace4
Author: Pan Li 
Date:   Sun Dec 8 19:56:19 2024 +0800

RISC-V: Refine signed vector SAT_SUB testcase dump check to tree optimized

The sat alu related testcase check the rtl dump for the standard name
like .SAT_SUB exist or not.  But the rtl pass expand is somehow
impressionable by the middle-end change or debug information.  Like
below new appearance recently.

Replacing Expressions
_5 replace with --> _5 = .SAT_SUB (x_3(D), y_4(D)); [tail call]

After that we need to adjust the dump check time and again.  This
patch would like to switch to tree optimized pass for the standard
name check, which is more stable up to a point.

The below test suites are passed for this patch.
* The rv64gcv fully regression test.

It is test only patch and obvious up to a point, will commit it
directly if no comments in next 48H.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_sub-1-i16.c: Take
tree-optimized pass for standard name check, and adjust the times.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_sub-1-i32.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_sub-1-i64.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_sub-1-i8.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_sub-2-i16.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_sub-2-i32.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_sub-2-i64.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_sub-2-i8.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_sub-3-i16.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_sub-3-i32.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_sub-3-i64.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_sub-3-i8.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_sub-4-i16.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_sub-4-i32.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_sub-4-i64.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_sub-4-i8.c: Ditto.

Signed-off-by: Pan Li 

Diff:
---
 .../gcc.target/riscv/rvv/autovec/sat/vec_sat_s_sub-1-i16.c  | 6 +++---
 .../gcc.target/riscv/rvv/autovec/sat/vec_sat_s_sub-1-i32.c  | 6 +++---
 .../gcc.target/riscv/rvv/autovec/sat/vec_sat_s_sub-1-i64.c  | 6 +++---
 gcc/testsuite/gcc.target/riscv/rvv/autovec/sat/vec_sat_s_sub-1-i8.c | 6 +++---
 .../gcc.target/riscv/rvv/autovec/sat/vec_sat_s_sub-2-i16.c  | 6 +++---
 .../gcc.target/riscv/rvv/autovec/sat/vec_sat_s_sub-2-i32.c  | 6 +++---
 .../gcc.target/riscv/rvv/autovec/sat/vec_sat_s_sub-2-i64.c  | 6 +++---
 gcc/testsuite/gcc.target/riscv/rvv/autovec/sat/vec_sat_s_sub-2-i8.c | 6 +++---
 .../gcc.target/riscv/rvv/autovec/sat/vec_sat_s_sub-3-i16.c  | 6 +++---
 .../gcc.target/riscv/rvv/autovec/sat/vec_sat_s_sub-3-i32.c  | 6 +++---
 .../gcc.target/riscv/rvv/autovec/sat/vec_sat_s_sub-3-i64.c  | 6 +++---
 gcc/testsuite/gcc.target/riscv/rvv/autovec/sat/vec_sat_s_sub-3-i8.c | 6 +++---
 .../gcc.target/riscv/rvv/autovec/sat/vec_sat_s_sub-4-i16.c  | 6 +++---
 .../gcc.target/riscv/rvv/autovec/sat/vec_sat_s_sub-4-i32.c  | 6 +++---
 .../gcc.target/riscv/rvv/autovec/sat/vec_sat_s_sub-4-i64.c  | 6 +++---
 gcc/testsuite/gcc.target/riscv/rvv/autovec/sat/vec_sat_s_sub-4-i8.c | 6 +++---
 16 files changed, 48 insertions(+), 48 deletions(-)

diff --git 
a/gcc/testsuite/gcc.target/riscv/rvv/autovec/sat/vec_sat_s_sub-1-i16.c 
b/gcc/testsuite/gcc.target/riscv/rvv/autovec/sat/vec_sat_s_sub-1-i16.c
index 38d105752377..5ae4515d2543 100644
--- a/gcc/testsuite/gcc.target/riscv/rvv/autovec/sat/vec_sat_s_sub-1-i16.c
+++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/sat/vec_sat_s_sub-1-i16.c
@@ -1,14 +1,14 @@
 /* { dg-do compile } */
-/* { dg-options "-march=rv64gcv -mabi=lp64d -ftree-vectorize 
-fdump-rtl-expand-details" } */
+/* { dg-options "-march=rv64gcv -mabi=lp64d -ftree-vectorize 
-fdump-tree-optimized" } */
 
 #include "vec_sat_arith.h"
 
 DEF_VEC_SAT_S_SUB_FMT_1(int16_t, uint16_t, INT16_MIN, INT16_MAX)
 
-/* { dg-final { scan-rtl-dump-times ".SAT_SUB " 2 "expand" { target { any-opts
+/* { dg-final { scan-tree-dump-times ".SAT_SUB " 1 "optimized" { target { 
any-opts
  "-O3"
} } } } */
-/* { dg-final { scan-rtl-dump-times ".SAT_SUB " 4 "expand" { target { any-opts
+/* { dg-final { scan-tree-dump-times ".SAT_SUB " 2 "optimized" { target { 
any-opts
  "-O2"
} } } } */
 /* { dg-final { scan-assembler-times {vssub\.vv} 1 } } */
diff --git 
a/gcc/testsuite/gcc.target/riscv/rvv/autovec/sat/vec_sat_s_sub-1-i32.c 
b/gcc/testsuite/gcc.target/riscv/rvv/autovec/sat/vec_sat_

[gcc r15-6065] RISC-V: Refine unsigned vector SAT_SUB testcase dump check to tree optimized

2024-12-09 Thread Pan Li via Gcc-cvs
https://gcc.gnu.org/g:aa8c20e32e54f2aa15bd138c0a22cfb3f1278852

commit r15-6065-gaa8c20e32e54f2aa15bd138c0a22cfb3f1278852
Author: Pan Li 
Date:   Sun Dec 8 19:56:16 2024 +0800

RISC-V: Refine unsigned vector SAT_SUB testcase dump check to tree optimized

The sat alu related testcase check the rtl dump for the standard name
like .SAT_SUB exist or not.  But the rtl pass expand is somehow
impressionable by the middle-end change or debug information.  Like
below new appearance recently.

Replacing Expressions
_5 replace with --> _5 = .SAT_SUB (x_3(D), y_4(D)); [tail call]

After that we need to adjust the dump check time and again.  This
patch would like to switch to tree optimized pass for the standard
name check, which is more stable up to a point.

The below test suites are passed for this patch.
* The rv64gcv fully regression test.

It is test only patch and obvious up to a point, will commit it
directly if no comments in next 48H.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub-1-u16.c: Take
tree-optimized pass for standard name check, and adjust the times.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub-1-u32.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub-1-u64.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub-1-u8.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub-10-u16.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub-10-u32.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub-10-u64.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub-10-u8.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub-2-u16.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub-2-u32.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub-2-u64.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub-2-u8.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub-3-u16.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub-3-u32.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub-3-u64.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub-3-u8.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub-4-u16.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub-4-u32.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub-4-u64.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub-4-u8.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub-5-u16.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub-5-u32.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub-5-u64.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub-5-u8.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub-6-u16.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub-6-u32.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub-6-u64.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub-6-u8.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub-7-u16.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub-7-u32.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub-7-u64.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub-7-u8.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub-8-u16.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub-8-u32.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub-8-u64.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub-8-u8.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub-9-u16.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub-9-u32.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub-9-u64.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub-9-u8.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub_imm-1-u16.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub_imm-1-u32.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub_imm-1-u64.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub_imm-1-u8.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub_trunc-1-u16.c: 
Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub_trunc-1-u32.c: 
Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub_trunc-1-u8.c: 
Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub_zip.c: Ditto.

Signed-off-by: Pan Li 

Diff:
---
 .../gcc.target/riscv/rvv/autovec/sat/vec_sat_u_sub-1-u16.c| 4 ++--
 .../gcc.target/ris

[gcc r15-6066] RISC-V: Refine unsigned vector SAT_TRUNC testcase dump check to tree optimized

2024-12-09 Thread Pan Li via Gcc-cvs
https://gcc.gnu.org/g:b5c99314b80ba132ffd70541fde6bc5c215f324c

commit r15-6066-gb5c99314b80ba132ffd70541fde6bc5c215f324c
Author: Pan Li 
Date:   Sun Dec 8 19:56:17 2024 +0800

RISC-V: Refine unsigned vector SAT_TRUNC testcase dump check to tree 
optimized

The sat alu related testcase check the rtl dump for the standard name
like .SAT_TRUNC exist or not.  But the rtl pass expand is somehow
impressionable by the middle-end change or debug information.  Like
below new appearance recently.

Replacing Expressions
_5 replace with --> _5 = .SAT_TRUNC (x_3(D), y_4(D)); [tail call]

After that we need to adjust the dump check time and again.  This
patch would like to switch to tree optimized pass for the standard
name check, which is more stable up to a point.

The below test suites are passed for this patch.
* The rv64gcv fully regression test.

It is test only patch and obvious up to a point, will commit it
directly if no comments in next 48H.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_trunc-1-u16.c: Take
tree-optimized pass for standard name check, and adjust the times.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_trunc-1-u32.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_trunc-1-u64.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_trunc-1-u8.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_trunc-2-u16.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_trunc-2-u32.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_trunc-2-u64.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_trunc-2-u8.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_trunc-3-u16.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_trunc-3-u32.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_trunc-3-u64.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_trunc-3-u8.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_trunc-4-u16.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_trunc-4-u32.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_trunc-4-u64.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_trunc-4-u8.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_trunc-5-u16.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_trunc-5-u32.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_trunc-5-u64.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_trunc-5-u8.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_trunc-6-u16.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_trunc-6-u32.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_trunc-6-u64.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_trunc-6-u8.c: Ditto.

Signed-off-by: Pan Li 

Diff:
---
 .../gcc.target/riscv/rvv/autovec/sat/vec_sat_u_trunc-1-u16.c  | 4 ++--
 .../gcc.target/riscv/rvv/autovec/sat/vec_sat_u_trunc-1-u32.c  | 4 ++--
 .../gcc.target/riscv/rvv/autovec/sat/vec_sat_u_trunc-1-u64.c  | 4 ++--
 gcc/testsuite/gcc.target/riscv/rvv/autovec/sat/vec_sat_u_trunc-1-u8.c | 4 ++--
 .../gcc.target/riscv/rvv/autovec/sat/vec_sat_u_trunc-2-u16.c  | 4 ++--
 .../gcc.target/riscv/rvv/autovec/sat/vec_sat_u_trunc-2-u32.c  | 4 ++--
 .../gcc.target/riscv/rvv/autovec/sat/vec_sat_u_trunc-2-u64.c  | 4 ++--
 gcc/testsuite/gcc.target/riscv/rvv/autovec/sat/vec_sat_u_trunc-2-u8.c | 4 ++--
 .../gcc.target/riscv/rvv/autovec/sat/vec_sat_u_trunc-3-u16.c  | 4 ++--
 .../gcc.target/riscv/rvv/autovec/sat/vec_sat_u_trunc-3-u32.c  | 4 ++--
 .../gcc.target/riscv/rvv/autovec/sat/vec_sat_u_trunc-3-u64.c  | 4 ++--
 gcc/testsuite/gcc.target/riscv/rvv/autovec/sat/vec_sat_u_trunc-3-u8.c | 4 ++--
 .../gcc.target/riscv/rvv/autovec/sat/vec_sat_u_trunc-4-u16.c  | 4 ++--
 .../gcc.target/riscv/rvv/autovec/sat/vec_sat_u_trunc-4-u32.c  | 4 ++--
 .../gcc.target/riscv/rvv/autovec/sat/vec_sat_u_trunc-4-u64.c  | 4 ++--
 gcc/testsuite/gcc.target/riscv/rvv/autovec/sat/vec_sat_u_trunc-4-u8.c | 4 ++--
 .../gcc.target/riscv/rvv/autovec/sat/vec_sat_u_trunc-5-u16.c  | 4 ++--
 .../gcc.target/riscv/rvv/autovec/sat/vec_sat_u_trunc-5-u32.c  | 4 ++--
 .../gcc.target/riscv/rvv/autovec/sat/vec_sat_u_trunc-5-u64.c  | 4 ++--
 gcc/testsuite/gcc.target/riscv/rvv/autovec/sat/vec_sat_u_trunc-5-u8.c | 4 ++--
 .../gcc.target/riscv/rvv/autovec/sat/vec_sat_u_trunc-6-u16.c  | 4 ++--
 .../gcc.target/riscv/rvv/autovec/sat/vec_sat_u_trunc-6-u32.c  | 4 ++--
 .../gcc.target/riscv/rvv/autovec/sat/vec_sat_u_trunc-6-u64.c  | 4 ++--
 gcc/testsuite/gcc.target/riscv/rvv/autovec/sat/vec_sat_u_trunc-6-u8.c | 4 ++--
 

[gcc r15-6064] RISC-V: Refine unsigned vector SAT_ADD testcase dump check to tree optimized

2024-12-09 Thread Pan Li via Gcc-cvs
https://gcc.gnu.org/g:a6aa0719aaadf0014910852a049634357e1779ff

commit r15-6064-ga6aa0719aaadf0014910852a049634357e1779ff
Author: Pan Li 
Date:   Sun Dec 8 19:56:15 2024 +0800

RISC-V: Refine unsigned vector SAT_ADD testcase dump check to tree optimized

The sat alu related testcase check the rtl dump for the standard name
like .SAT_ADD exist or not.  But the rtl pass expand is somehow
impressionable by the middle-end change or debug information.  Like
below new appearance recently.

Replacing Expressions
_5 replace with --> _5 = .SAT_ADD (x_3(D), y_4(D)); [tail call]

After that we need to adjust the dump check time and again.  This
patch would like to switch to tree optimized pass for the standard
name check, which is more stable up to a point.

The below test suites are passed for this patch.
* The rv64gcv fully regression test.

It is test only patch and obvious up to a point, will commit it
directly if no comments in next 48H.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-1-u16.c: Take
tree-optimized pass for standard name check, and adjust the times.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-1-u32.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-1-u64.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-1-u8.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-2-u16.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-2-u32.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-2-u64.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-2-u8.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-3-u16.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-3-u32.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-3-u64.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-3-u8.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-4-u16.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-4-u32.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-4-u64.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-4-u8.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-5-u16.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-5-u32.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-5-u64.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-5-u8.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-6-u16.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-6-u32.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-6-u64.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-6-u8.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-7-u16.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-7-u32.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-7-u64.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-7-u8.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-8-u16.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-8-u32.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-8-u64.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add-8-u8.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add_imm-1-u16.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add_imm-1-u32.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add_imm-1-u64.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add_imm-1-u8.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add_imm-2-u16.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add_imm-2-u32.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add_imm-2-u64.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add_imm-2-u8.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add_imm-3-u16.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add_imm-3-u32.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add_imm-3-u64.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add_imm-3-u8.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add_imm-4-u16.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add_imm-4-u32.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add_imm-4-u64.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add_imm-4-u8.c: Ditto.
* 
gcc.target/riscv/rvv/autovec/sat/vec_sat_u_add_imm_reconcile-1-u16.c: Ditto.
* 
gcc.ta

[gcc r15-6067] RISC-V: Refine signed vector SAT_ADD testcase dump check to tree optimized

2024-12-09 Thread Pan Li via Gcc-cvs
https://gcc.gnu.org/g:1850da91610aa6df1f69f816aff6fecbb43e1fdd

commit r15-6067-g1850da91610aa6df1f69f816aff6fecbb43e1fdd
Author: Pan Li 
Date:   Sun Dec 8 19:56:18 2024 +0800

RISC-V: Refine signed vector SAT_ADD testcase dump check to tree optimized

The sat alu related testcase check the rtl dump for the standard name
like .SAT_ADD exist or not.  But the rtl pass expand is somehow
impressionable by the middle-end change or debug information.  Like
below new appearance recently.

Replacing Expressions
_5 replace with --> _5 = .SAT_ADD (x_3(D), y_4(D)); [tail call]

After that we need to adjust the dump check time and again.  This
patch would like to switch to tree optimized pass for the standard
name check, which is more stable up to a point.

The below test suites are passed for this patch.
* The rv64gcv fully regression test.

It is test only patch and obvious up to a point, will commit it
directly if no comments in next 48H.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_add-1-s16.c: Take
tree-optimized pass for standard name check, and adjust the times.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_add-1-s32.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_add-1-s64.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_add-1-s8.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_add-2-s16.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_add-2-s32.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_add-2-s64.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_add-2-s8.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_add-3-s16.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_add-3-s32.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_add-3-s64.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_add-3-s8.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_add-4-s16.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_add-4-s32.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_add-4-s64.c: Ditto.
* gcc.target/riscv/rvv/autovec/sat/vec_sat_s_add-4-s8.c: Ditto.

Signed-off-by: Pan Li 

Diff:
---
 .../gcc.target/riscv/rvv/autovec/sat/vec_sat_s_add-1-s16.c  | 6 +++---
 .../gcc.target/riscv/rvv/autovec/sat/vec_sat_s_add-1-s32.c  | 6 +++---
 .../gcc.target/riscv/rvv/autovec/sat/vec_sat_s_add-1-s64.c  | 6 +++---
 gcc/testsuite/gcc.target/riscv/rvv/autovec/sat/vec_sat_s_add-1-s8.c | 6 +++---
 .../gcc.target/riscv/rvv/autovec/sat/vec_sat_s_add-2-s16.c  | 6 +++---
 .../gcc.target/riscv/rvv/autovec/sat/vec_sat_s_add-2-s32.c  | 6 +++---
 .../gcc.target/riscv/rvv/autovec/sat/vec_sat_s_add-2-s64.c  | 6 +++---
 gcc/testsuite/gcc.target/riscv/rvv/autovec/sat/vec_sat_s_add-2-s8.c | 6 +++---
 .../gcc.target/riscv/rvv/autovec/sat/vec_sat_s_add-3-s16.c  | 6 +++---
 .../gcc.target/riscv/rvv/autovec/sat/vec_sat_s_add-3-s32.c  | 6 +++---
 .../gcc.target/riscv/rvv/autovec/sat/vec_sat_s_add-3-s64.c  | 6 +++---
 gcc/testsuite/gcc.target/riscv/rvv/autovec/sat/vec_sat_s_add-3-s8.c | 6 +++---
 .../gcc.target/riscv/rvv/autovec/sat/vec_sat_s_add-4-s16.c  | 6 +++---
 .../gcc.target/riscv/rvv/autovec/sat/vec_sat_s_add-4-s32.c  | 6 +++---
 .../gcc.target/riscv/rvv/autovec/sat/vec_sat_s_add-4-s64.c  | 6 +++---
 gcc/testsuite/gcc.target/riscv/rvv/autovec/sat/vec_sat_s_add-4-s8.c | 6 +++---
 16 files changed, 48 insertions(+), 48 deletions(-)

diff --git 
a/gcc/testsuite/gcc.target/riscv/rvv/autovec/sat/vec_sat_s_add-1-s16.c 
b/gcc/testsuite/gcc.target/riscv/rvv/autovec/sat/vec_sat_s_add-1-s16.c
index 6ef8ecbc1701..6147e7ab56ee 100644
--- a/gcc/testsuite/gcc.target/riscv/rvv/autovec/sat/vec_sat_s_add-1-s16.c
+++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/sat/vec_sat_s_add-1-s16.c
@@ -1,10 +1,10 @@
 /* { dg-do compile } */
-/* { dg-options "-march=rv64gcv -mabi=lp64d -ftree-vectorize 
-fdump-rtl-expand-details" } */
+/* { dg-options "-march=rv64gcv -mabi=lp64d -ftree-vectorize 
-fdump-tree-optimized" } */
 
 #include "vec_sat_arith.h"
 
 DEF_VEC_SAT_S_ADD_FMT_1(int16_t, uint16_t, INT16_MIN, INT16_MAX)
 
-/* { dg-final { scan-rtl-dump-times ".SAT_ADD " 2 "expand" { target { no-opts 
"-O2" } } } } */
-/* { dg-final { scan-rtl-dump-times ".SAT_ADD " 4 "expand" { target { no-opts 
"-O3" } } } } */
+/* { dg-final { scan-tree-dump-times ".SAT_ADD " 1 "optimized" { target { 
no-opts "-O2" } } } } */
+/* { dg-final { scan-tree-dump-times ".SAT_ADD " 2 "optimized" { target { 
no-opts "-O3" } } } } */
 /* { dg-final { scan-assembler-times {vsadd\.vv} 1 } } */
diff --git 
a/gcc/testsuite/gcc.target/riscv/rvv/autovec/sat/vec_sat_s_add-1-s32.c 
b/gcc/testsuite/gcc.target/riscv/rvv/autovec/

[gcc r15-6070] aarch64: Fix ICE happening in SET_TYPE_VECTOR_SUBPARTS with libgccjit

2024-12-09 Thread Antoni Boucher via Gcc-cvs
https://gcc.gnu.org/g:62fa2e434b60558a7c3b4c578fda744bde96

commit r15-6070-g62fa2e434b60558a7c3b4c578fda744bde96
Author: Antoni Boucher 
Date:   Wed Dec 4 20:59:53 2024 -0500

aarch64: Fix ICE happening in SET_TYPE_VECTOR_SUBPARTS with libgccjit

The structure aarch64_simd_type_info was split in 2 because we do not
want to reset the static members of aarch64_simd_type_info to their
default value. We only want the tree types to be GC-ed. This is
necessary for libgccjit which can run multiple times in the same
process. If the static values were GC-ed, the second run would
ICE/segfault because of their invalid value.

The following test suites passed for this patch:

 * The aarch64 tests.
 * The aarch64 regression tests.

The number of failures of the jit tests on aarch64 lowered from +100 to
~7.

gcc/ChangeLog:
PR target/117923
* config/aarch64/aarch64-builtins.cc: Remove GTY marker on 
aarch64_simd_types,
aarch64_simd_types_trees (new variable), rename aarch64_simd_types 
to
aarch64_simd_types_trees.
* config/aarch64/aarch64-builtins.h: Remove GTY marker on 
aarch64_simd_types,
aarch64_simd_types_trees (new variable).
* config/aarch64/aarch64-sve-builtins-shapes.cc: Rename 
aarch64_simd_types to
aarch64_simd_types_trees.
* config/aarch64/aarch64-sve-builtins.cc: Rename aarch64_simd_types 
to
aarch64_simd_types_trees.

Diff:
---
 gcc/config/aarch64/aarch64-builtins.cc| 129 --
 gcc/config/aarch64/aarch64-builtins.h |  29 +++--
 gcc/config/aarch64/aarch64-sve-builtins-shapes.cc |   4 +-
 gcc/config/aarch64/aarch64-sve-builtins.cc|   2 +-
 4 files changed, 95 insertions(+), 69 deletions(-)

diff --git a/gcc/config/aarch64/aarch64-builtins.cc 
b/gcc/config/aarch64/aarch64-builtins.cc
index f528592a17d8..02c73f11223c 100644
--- a/gcc/config/aarch64/aarch64-builtins.cc
+++ b/gcc/config/aarch64/aarch64-builtins.cc
@@ -983,16 +983,20 @@ const char *aarch64_scalar_builtin_types[] = {
   NULL
 };
 
-extern GTY(()) aarch64_simd_type_info aarch64_simd_types[];
+extern const aarch64_simd_type_info aarch64_simd_types[];
+extern GTY(()) aarch64_simd_type_info_trees aarch64_simd_types_trees[];
 
 #undef ENTRY
 #define ENTRY(E, M, Q, G)  \
-  {E, "__" #E, #G "__" #E, NULL_TREE, NULL_TREE, E_##M##mode, qualifier_##Q},
-struct aarch64_simd_type_info aarch64_simd_types [] = {
+  {E, "__" #E, #G "__" #E, E_##M##mode, qualifier_##Q},
+const struct aarch64_simd_type_info aarch64_simd_types[] = {
 #include "aarch64-simd-builtin-types.def"
 };
 #undef ENTRY
 
+struct aarch64_simd_type_info_trees
+aarch64_simd_types_trees[ARRAY_SIZE (aarch64_simd_types)];
+
 static machine_mode aarch64_simd_tuple_modes[ARM_NEON_H_TYPES_LAST][3];
 static GTY(()) tree aarch64_simd_tuple_types[ARM_NEON_H_TYPES_LAST][3];
 
@@ -1133,7 +1137,7 @@ aarch64_lookup_simd_type_in_table (machine_mode mode,
 {
   if (aarch64_simd_types[i].mode == mode
  && aarch64_simd_types[i].q == q)
-   return aarch64_simd_types[i].itype;
+   return aarch64_simd_types_trees[i].itype;
   if (aarch64_simd_tuple_types[i][0] != NULL_TREE)
for (int j = 0; j < 3; j++)
  if (aarch64_simd_tuple_modes[i][j] == mode
@@ -1180,66 +1184,76 @@ aarch64_init_simd_builtin_types (void)
   tree tdecl;
 
   /* Init all the element types built by the front-end.  */
-  aarch64_simd_types[Int8x8_t].eltype = intQI_type_node;
-  aarch64_simd_types[Int8x16_t].eltype = intQI_type_node;
-  aarch64_simd_types[Int16x4_t].eltype = intHI_type_node;
-  aarch64_simd_types[Int16x8_t].eltype = intHI_type_node;
-  aarch64_simd_types[Int32x2_t].eltype = intSI_type_node;
-  aarch64_simd_types[Int32x4_t].eltype = intSI_type_node;
-  aarch64_simd_types[Int64x1_t].eltype = intDI_type_node;
-  aarch64_simd_types[Int64x2_t].eltype = intDI_type_node;
-  aarch64_simd_types[Uint8x8_t].eltype = unsigned_intQI_type_node;
-  aarch64_simd_types[Uint8x16_t].eltype = unsigned_intQI_type_node;
-  aarch64_simd_types[Uint16x4_t].eltype = unsigned_intHI_type_node;
-  aarch64_simd_types[Uint16x8_t].eltype = unsigned_intHI_type_node;
-  aarch64_simd_types[Uint32x2_t].eltype = unsigned_intSI_type_node;
-  aarch64_simd_types[Uint32x4_t].eltype = unsigned_intSI_type_node;
-  aarch64_simd_types[Uint64x1_t].eltype = unsigned_intDI_type_node;
-  aarch64_simd_types[Uint64x2_t].eltype = unsigned_intDI_type_node;
+  aarch64_simd_types_trees[Int8x8_t].eltype = intQI_type_node;
+  aarch64_simd_types_trees[Int8x16_t].eltype = intQI_type_node;
+  aarch64_simd_types_trees[Int16x4_t].eltype = intHI_type_node;
+  aarch64_simd_types_trees[Int16x8_t].eltype = intHI_type_node;
+  aarch64_simd_types_trees[Int32x2_t].eltype = intSI_type_node;
+  aarch64_simd_types_trees[Int32x4_t].eltype = intSI_type_node;
+  aarch64_simd_types_trees[Int64x1_t].eltype = intDI_type_

[gcc r15-6071] testsuite/gcc.dg/tree-ssa/pr111456-1.c: Handle fallout

2024-12-09 Thread Hans-Peter Nilsson via Gcc-cvs
https://gcc.gnu.org/g:0374e6771477553b3cc0c13f000f9e79aabd5020

commit r15-6071-g0374e6771477553b3cc0c13f000f9e79aabd5020
Author: Hans-Peter Nilsson 
Date:   Sun Dec 8 19:40:55 2024 +0100

testsuite/gcc.dg/tree-ssa/pr111456-1.c: Handle fallout

This is expected fallout from r15-5646-gd1cf0d7a0f27fd as
described by that commit.  The =0 case is covered by
PR117973.

PR tree-optimization/117954
* gcc.dg/tree-ssa/pr111456-1.c: Pass
--param=logical-op-non-short-circuit=1.

Diff:
---
 gcc/testsuite/gcc.dg/tree-ssa/pr111456-1.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr111456-1.c 
b/gcc/testsuite/gcc.dg/tree-ssa/pr111456-1.c
index 664a1afa..2e89228761c7 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/pr111456-1.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr111456-1.c
@@ -1,5 +1,5 @@
 /* { dg-do compile } */
-/* { dg-options "-O2 -fdump-tree-optimized" } */
+/* { dg-options "-O2 -fdump-tree-optimized --param 
logical-op-non-short-circuit=1" } */
 /* PR tree-optimization/111456 */
 
 void foo(void);


[gcc r15-6055] aarch64: Implement new expander for efficient CRC computation.

2024-12-09 Thread Richard Sandiford via Gcc-cvs
https://gcc.gnu.org/g:a193f5333295a96021f98b3dfde2941d69f06d8b

commit r15-6055-ga193f5333295a96021f98b3dfde2941d69f06d8b
Author: Mariam Arutunian 
Date:   Mon Dec 9 22:41:41 2024 +

aarch64: Implement new expander for efficient CRC computation.

This patch introduces two new expanders for the aarch64 backend,
dedicated to generate optimized code for CRC computations.
The new expanders are designed to leverage specific hardware capabilities
to achieve faster CRC calculations,
particularly using the crc32, crc32c and pmull instructions when supported
by the target architecture.

Expander 1: Bit-Forward CRC (crc4)
For targets that support pmul instruction (TARGET_AES),
the expander will generate code that uses the pmull (crypto_pmulldi)
instruction for CRC computation.

Expander 2: Bit-Reversed CRC (crc_rev4)
The expander first checks if the target supports the CRC32* instruction set
(TARGET_CRC32)
and the polynomial in use is 0x1EDC6F41 (iSCSI) or 0x04C11DB7 (HDLC). If
the conditions are met,
it emits calls to the corresponding crc32* instruction (depending on the
data size and the polynomial).
If the target does not support crc32* but supports pmull, it then uses the
pmull (crypto_pmulldi) instruction for bit-reversed CRC computation.
Otherwise table-based CRC is generated.

gcc/

* config/aarch64/aarch64-protos.h (aarch64_expand_crc_using_pmull): 
New
extern function declaration.
(aarch64_expand_reversed_crc_using_pmull):  Likewise.
* config/aarch64/aarch64.cc (aarch64_expand_crc_using_pmull): New
function.
(aarch64_expand_reversed_crc_using_pmull):  Likewise.
* config/aarch64/aarch64.md (crc_rev4): New
expander for reversed CRC.
(crc4): New expander for bit-forward CRC.
* config/aarch64/iterators.md (crc_data_type): New mode attribute.

gcc/testsuite/

* gcc.target/aarch64/crc-1-pmul.c: New test.
* gcc.target/aarch64/crc-10-pmul.c: Likewise.
* gcc.target/aarch64/crc-12-pmul.c: Likewise.
* gcc.target/aarch64/crc-13-pmul.c: Likewise.
* gcc.target/aarch64/crc-14-pmul.c: Likewise.
* gcc.target/aarch64/crc-17-pmul.c: Likewise.
* gcc.target/aarch64/crc-18-pmul.c: Likewise.
* gcc.target/aarch64/crc-21-pmul.c: Likewise.
* gcc.target/aarch64/crc-22-pmul.c: Likewise.
* gcc.target/aarch64/crc-23-pmul.c: Likewise.
* gcc.target/aarch64/crc-4-pmul.c: Likewise.
* gcc.target/aarch64/crc-5-pmul.c: Likewise.
* gcc.target/aarch64/crc-6-pmul.c: Likewise.
* gcc.target/aarch64/crc-7-pmul.c: Likewise.
* gcc.target/aarch64/crc-8-pmul.c: Likewise.
* gcc.target/aarch64/crc-9-pmul.c: Likewise.
* gcc.target/aarch64/crc-CCIT-data16-pmul.c: Likewise.
* gcc.target/aarch64/crc-CCIT-data8-pmul.c: Likewise.
* gcc.target/aarch64/crc-coremark-16bitdata-pmul.c: Likewise.
* gcc.target/aarch64/crc-crc32-data16.c: Likewise.
* gcc.target/aarch64/crc-crc32-data32.c: Likewise.
* gcc.target/aarch64/crc-crc32-data8.c: Likewise.
* gcc.target/aarch64/crc-crc32c-data16.c: Likewise.
* gcc.target/aarch64/crc-crc32c-data32.c: Likewise.
* gcc.target/aarch64/crc-crc32c-data8.c: Likewise.

Signed-off-by: Mariam Arutunian 
Co-authored-by: Richard Sandiford 

Diff:
---
 gcc/config/aarch64/aarch64-protos.h|   3 +
 gcc/config/aarch64/aarch64.cc  | 131 +
 gcc/config/aarch64/aarch64.md  |  57 +
 gcc/config/aarch64/iterators.md|   4 +
 gcc/testsuite/gcc.target/aarch64/crc-1-pmul.c  |   8 ++
 gcc/testsuite/gcc.target/aarch64/crc-10-pmul.c |   8 ++
 gcc/testsuite/gcc.target/aarch64/crc-12-pmul.c |   9 ++
 gcc/testsuite/gcc.target/aarch64/crc-13-pmul.c |   8 ++
 gcc/testsuite/gcc.target/aarch64/crc-14-pmul.c |   8 ++
 gcc/testsuite/gcc.target/aarch64/crc-17-pmul.c |   8 ++
 gcc/testsuite/gcc.target/aarch64/crc-18-pmul.c |   8 ++
 gcc/testsuite/gcc.target/aarch64/crc-21-pmul.c |   8 ++
 gcc/testsuite/gcc.target/aarch64/crc-22-pmul.c |   8 ++
 gcc/testsuite/gcc.target/aarch64/crc-23-pmul.c |   8 ++
 gcc/testsuite/gcc.target/aarch64/crc-4-pmul.c  |   8 ++
 gcc/testsuite/gcc.target/aarch64/crc-5-pmul.c  |   8 ++
 gcc/testsuite/gcc.target/aarch64/crc-6-pmul.c  |   8 ++
 gcc/testsuite/gcc.target/aarch64/crc-7-pmul.c  |   8 ++
 gcc/testsuite/gcc.target/aarch64/crc-8-pmul.c  |   8 ++
 gcc/testsuite/gcc.target/aarch64/crc-9-pmul.c  |   8 ++
 .../gcc.target/aarch64/crc-CCIT-data16-pmul.c  |   9 ++
 .../gcc.target/aarch64/crc-CCIT-data8-pmul.c   |   9 ++
 .../

[gcc r15-6056] aarch64: Add CRC built-ins test for the target AES.

2024-12-09 Thread Richard Sandiford via Gcc-cvs
https://gcc.gnu.org/g:5b63ae06a7800527314032f005b2908a283c7e07

commit r15-6056-g5b63ae06a7800527314032f005b2908a283c7e07
Author: Mariam Arutunian 
Date:   Mon Dec 9 22:41:42 2024 +

aarch64: Add CRC built-ins test for the target AES.

gcc/testsuite/

* gcc.target/aarch64/crc-builtin-pmul64.c: New test.

Signed-off-by: Mariam Arutunian 

Diff:
---
 .../gcc.target/aarch64/crc-builtin-pmul64.c| 61 ++
 1 file changed, 61 insertions(+)

diff --git a/gcc/testsuite/gcc.target/aarch64/crc-builtin-pmul64.c 
b/gcc/testsuite/gcc.target/aarch64/crc-builtin-pmul64.c
new file mode 100644
index ..d8bb1724a65c
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/crc-builtin-pmul64.c
@@ -0,0 +1,61 @@
+/* { dg-options "-march=armv8-a+crypto" } */
+
+#include 
+int8_t crc8_data8 ()
+{
+  return __builtin_crc8_data8 ('a', 0xff, 0x12);
+}
+int16_t crc16_data8 ()
+{
+  return __builtin_crc16_data8 (0x1234, 'a', 0x1021);
+}
+
+int16_t crc16_data16 ()
+{
+  return __builtin_crc16_data16 (0x1234, 0x3214, 0x1021);
+}
+
+int32_t crc32_data8 ()
+{
+  return __builtin_crc32_data8 (0x, 0x32, 0x4002123);
+}
+int32_t crc32_data16 ()
+{
+  return __builtin_crc32_data16 (0x, 0x3232, 0x4002123);
+}
+
+int32_t crc32_data32 ()
+{
+  return __builtin_crc32_data32 (0x, 0x123546ff, 0x4002123);
+}
+
+int8_t rev_crc8_data8 ()
+{
+  return __builtin_rev_crc8_data8 (0x34, 'a', 0x12);
+}
+
+int16_t rev_crc16_data8 ()
+{
+  return __builtin_rev_crc16_data8 (0x1234, 'a', 0x1021);
+}
+
+int16_t rev_crc16_data16 ()
+{
+  return __builtin_rev_crc16_data16 (0x1234, 0x3214, 0x1021);
+}
+
+int32_t rev_crc32_data8 ()
+{
+  return __builtin_rev_crc32_data8 (0x, 0x32, 0x4002123);
+}
+
+int32_t rev_crc32_data16 ()
+{
+  return __builtin_rev_crc32_data16 (0x, 0x3232, 0x4002123);
+}
+
+int32_t rev_crc32_data32 ()
+{
+  return __builtin_rev_crc32_data32 (0x, 0x123546ff, 0x4002123);
+} 
+/* { dg-final { scan-assembler-times "pmull" 24 } } */
\ No newline at end of file