[gcc r14-11050] [PATCH] PR modula2/115328 The FORWARD keyword is not implemented

2024-12-03 Thread Gaius Mulley via Gcc-cvs
https://gcc.gnu.org/g:e8acf6816cf360d5db0ebfaf995415961f455274

commit r14-11050-ge8acf6816cf360d5db0ebfaf995415961f455274
Author: Gaius Mulley 
Date:   Tue Dec 3 13:37:01 2024 +

[PATCH] PR modula2/115328 The FORWARD keyword is not implemented

This patch implements the FORWARD keyword found in the ISO standard.
The patch checks incoming parameters against the prior declaration
found in definition/forward sections and will issue an error based
on virtual tokens highlighing the full parameter declaration.

gcc/m2/ChangeLog:

PR modula2/115328
* gm2-compiler/M2MetaError.def: Extend comment documentating
new format specifiers.
* gm2-compiler/M2MetaError.mod (GetTokProcedure): New declaration.
(doErrorScopeModule): New procedure.
(doErrorScopeForward): Ditto.
(doErrorScopeMod): Reimplement.
(doErrorScopeFor): New procedure.
(declarationMod): Ditto.
(doErrorScopeDefinition): Ditto.
(doErrorScopeDef): Reimplement.
(declaredDef): New procedure.
(declaredFor): Ditto.
(doErrorScopeProc): Ditto.
(declaredVar): Ditto.
(declaredType): Ditto.
(declaredFull): Ditto.
* gm2-compiler/M2Options.mod (SetAutoInit): Add missing
return type.
(GetDumpGimple): Remove duplicate implementation.
* gm2-compiler/M2Quads.def (DupFrame): New procedure.
* gm2-compiler/M2Quads.mod (DupFrame): New procedure.
* gm2-compiler/M2Reserved.def (ForwardTok): New variable.
* gm2-compiler/M2Reserved.mod (ForwardTok): Initialize variable.
* gm2-compiler/M2Scaffold.mod (DeclareArgEnvParams): Add
tokno parameter for call to PutParam.
* gm2-compiler/P0SymBuild.def (EndForward): New procedure.
* gm2-compiler/P0SymBuild.mod (EndForward): New procedure.
* gm2-compiler/P0SyntaxCheck.bnf (BlockAssert): New procedure.
(ProcedureDeclaration): Reimplement rule.
(PostProcedureHeading): New rule.
(ForwardDeclaration): Ditto.
(ProperProcedure): Ditto.
* gm2-compiler/P1Build.bnf (ProcedureDeclaration): Reimplement rule.
(PostProcedureHeading): New rule.
(ForwardDeclaration): Ditto.
(ProperProcedure): Ditto.
* gm2-compiler/P1SymBuild.def (Export): Removed unnecessary
export.
(EndBuildForward): New procedure.
* gm2-compiler/P1SymBuild.mod (StartBuildProcedure): Reimplement.
(EndBuildProcedure): Ditto.
(EndBuildForward): Ditto.
* gm2-compiler/P2Build.bnf (ProcedureDeclaration): Reimplement rule.
(PostProcedureHeading): New rule.
(ForwardDeclaration): Ditto.
(ProperProcedure): Ditto.
* gm2-compiler/P2SymBuild.def (BuildProcedureDefinedByForward):
New procedure.
(BuildProcedureDefinedByProper): Ditto.
(CheckProcedure): Ditto.
(EndBuildForward): Ditto.
* gm2-compiler/P2SymBuild.mod (EndBuildProcedure): Reimplement.
(EndBuildForward): New procedure.
(BuildFPSection): Reimplement to allow forward declaration or
checking of parameters.
(BuildProcedureDefinedByProper): New procedure.
(BuildProcedureDefinedByForward): Ditto
(FailParameter): Remove.
(ParameterError): New procedure.
(ParameterMismatch): Ditto.
(EndBuildFormalParameters): Add parameter number check.
(GetComparison): New procedure function.
(GetSourceDesc): Ditto.
(GetCurSrcDesc): Ditto.
(GetDeclared): New procedure.
(ReturnTypeMismatch): Ditto.
(BuildFunction): Reimplement.
(CheckProcedure): New procedure.
(CheckFormalParameterSection): Reimplement using ParameterError.
* gm2-compiler/P3Build.bnf (ProcedureDeclaration): Reimplement rule.
(PostProcedureHeading): New rule.
(ForwardDeclaration): Ditto.
(ProperProcedure): Ditto.
* gm2-compiler/P3SymBuild.def (Export): Remove unnecessary export.
(EndBuildForward): New procedure.
* gm2-compiler/P3SymBuild.mod (EndBuildForward): New procedure.
* gm2-compiler/PCBuild.bnf (ProcedureDeclaration): Reimplement rule.
(PostProcedureHeading): New rule.
(ForwardDeclaration): Ditto.
(ProperProcedure): Ditto.
* gm2-compiler/PCSymBuild.def (EndBuildForward): New procedure.
* gm2-compiler/PCSymBuild.mod (EndBuildForward): Ditto.
* gm2-compiler/PHBuild.bnf (ProcedureDeclaration): Reimplement rule.
(PostProcedureHeading): New rule.
  

[gcc r15-5896] AVR: ad target/117726 - Also split logic shifts of bitsize - 1.

2024-12-03 Thread Georg-Johann Lay via Gcc-cvs
https://gcc.gnu.org/g:4114b7fb1cb4cb90b9fafc22213d7d9579bc19e0

commit r15-5896-g4114b7fb1cb4cb90b9fafc22213d7d9579bc19e0
Author: Georg-Johann Lay 
Date:   Tue Dec 3 15:49:18 2024 +0100

AVR: ad target/117726 - Also split logic shifts of bitsize - 1.

When -msplit-bit-shift is on, also split logic shifts of bitsize(mode) - 1.

gcc/
PR target/117726
* config/avr/avr-passes.cc (avr_split_shift_p)
[ASHIFT, LSHIFTRT]: Allow offsets of bitsize - 1.
(avr_split_shift4) [ASHIFT, LSHIFTRT]: Also split offset 31.
(avr_split_shift3) [ASHIFT, LSHIFTRT]: Also split offset 23.
(avr_split_shift2) [ASHIFT, LSHIFTRT]: Also split offset 15.

Diff:
---
 gcc/config/avr/avr-passes.cc | 24 
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/gcc/config/avr/avr-passes.cc b/gcc/config/avr/avr-passes.cc
index dc98780ef277..076d8cbe365e 100644
--- a/gcc/config/avr/avr-passes.cc
+++ b/gcc/config/avr/avr-passes.cc
@@ -4860,23 +4860,23 @@ avr_split_shift_p (int n_bytes, int offset, rtx_code 
code)
 
   if (n_bytes == 4)
 return select()
-  : code == ASHIFT ? IN_RANGE (offset, 9, 30) && offset != 15
+  : code == ASHIFT ? IN_RANGE (offset, 9, 31) && offset != 15
   : code == ASHIFTRT ? IN_RANGE (offset, 9, 29) && offset != 15
-  : code == LSHIFTRT ? IN_RANGE (offset, 9, 30) && offset != 15
+  : code == LSHIFTRT ? IN_RANGE (offset, 9, 31) && offset != 15
   : bad_case ();
 
   if (n_bytes == 3)
 return select()
-  : code == ASHIFT ? IN_RANGE (offset, 9, 22) && offset != 15
+  : code == ASHIFT ? IN_RANGE (offset, 9, 23) && offset != 15
   : code == ASHIFTRT ? IN_RANGE (offset, 9, 21) && offset != 15
-  : code == LSHIFTRT ? IN_RANGE (offset, 9, 22) && offset != 15
+  : code == LSHIFTRT ? IN_RANGE (offset, 9, 23) && offset != 15
   : bad_case ();
 
   if (n_bytes == 2)
 return select()
-  : code == ASHIFT ? IN_RANGE (offset, 9, 14)
+  : code == ASHIFT ? IN_RANGE (offset, 9, 15)
   : code == ASHIFTRT ? IN_RANGE (offset, 9, 13)
-  : code == LSHIFTRT ? IN_RANGE (offset, 9, 14)
+  : code == LSHIFTRT ? IN_RANGE (offset, 9, 15)
   : bad_case ();
 
   return false;
@@ -4955,7 +4955,7 @@ avr_split_shift4 (rtx dest, rtx src, int ioff, rtx 
scratch, rtx_code code)
 
   if (code == ASHIFT)
 {
-  if (IN_RANGE (ioff, 25, 30))
+  if (IN_RANGE (ioff, 25, 31))
{
  rtx dst8 = avr_byte (dest, 3);
  rtx src8 = avr_byte (src, 0);
@@ -4978,7 +4978,7 @@ avr_split_shift4 (rtx dest, rtx src, int ioff, rtx 
scratch, rtx_code code)
   else if (code == ASHIFTRT
   || code == LSHIFTRT)
 {
-  if (IN_RANGE (ioff, 25, 30))
+  if (IN_RANGE (ioff, 25, 30 + (code == LSHIFTRT)))
{
  rtx dst8 = avr_byte (dest, 0);
  rtx src8 = avr_byte (src, 3);
@@ -5042,7 +5042,7 @@ avr_split_shift3 (rtx dest, rtx src, int ioff, rtx 
scratch, rtx_code code)
 
   if (code == ASHIFT)
 {
-  if (IN_RANGE (ioff, 17, 22))
+  if (IN_RANGE (ioff, 17, 23))
{
  rtx dst8 = avr_byte (dest, 2);
  rtx src8 = avr_byte (src, 0);
@@ -5056,7 +5056,7 @@ avr_split_shift3 (rtx dest, rtx src, int ioff, rtx 
scratch, rtx_code code)
   else if (code == ASHIFTRT
   || code == LSHIFTRT)
 {
-  if (IN_RANGE (ioff, 17, 22))
+  if (IN_RANGE (ioff, 17, 22 + (code == LSHIFTRT)))
{
  rtx dst8 = avr_byte (dest, 0);
  rtx src8 = avr_byte (src, 2);
@@ -5102,7 +5102,7 @@ avr_split_shift2 (rtx dest, rtx src, int ioff, rtx 
/*scratch*/, rtx_code code)
 
   if (code == ASHIFT)
 {
-  if (IN_RANGE (ioff, 9, 14))
+  if (IN_RANGE (ioff, 9, 15))
{
  rtx dst8 = avr_byte (dest, 1);
  rtx src8 = avr_byte (src, 0);
@@ -5114,7 +5114,7 @@ avr_split_shift2 (rtx dest, rtx src, int ioff, rtx 
/*scratch*/, rtx_code code)
   else if (code == ASHIFTRT
   || code == LSHIFTRT)
 {
-  if (IN_RANGE (ioff, 9, 14))
+  if (IN_RANGE (ioff, 9, 14 + (code == LSHIFTRT)))
{
  rtx dst8 = avr_byte (dest, 0);
  rtx src8 = avr_byte (src, 1);


[gcc(refs/vendors/redhat/heads/gcc-15-branch)] Merge commit 'r15-5896-g4114b7fb1cb4cb90b9fafc22213d7d9579bc19e0' into redhat/gcc-15-branch

2024-12-03 Thread Jakub Jelinek via Libstdc++-cvs
https://gcc.gnu.org/g:d2b3fd44a4b20c573bb9c8ef5b17bdca70ea748b

commit d2b3fd44a4b20c573bb9c8ef5b17bdca70ea748b
Merge: ec0e37c5cf7e 4114b7fb1cb4
Author: Jakub Jelinek 
Date:   Tue Dec 3 16:31:16 2024 +0100

Merge commit 'r15-5896-g4114b7fb1cb4cb90b9fafc22213d7d9579bc19e0' into 
redhat/gcc-15-branch

Diff:

 ChangeLog  |4 +
 MAINTAINERS|1 +
 contrib/ChangeLog  |5 +
 contrib/testsuite-management/validate_failures.py  |8 +-
 gcc/ChangeLog  |  336 +++
 gcc/DATESTAMP  |2 +-
 gcc/Makefile.in|5 +
 gcc/c-family/ChangeLog |7 +
 gcc/c/ChangeLog|   11 +
 gcc/c/c-parser.cc  |5 +-
 gcc/cgraphunit.cc  |   12 +
 gcc/common.opt |   10 +
 gcc/common.opt.urls|3 +
 gcc/config.in  |6 +
 gcc/config/aarch64/aarch64-builtins.cc |  244 +-
 gcc/config/aarch64/aarch64-c.cc|3 +-
 gcc/config/aarch64/aarch64-option-extensions.def   |   16 +-
 gcc/config/aarch64/aarch64-protos.h|   15 +-
 .../aarch64/aarch64-simd-pragma-builtins.def   |   69 +-
 gcc/config/aarch64/aarch64-simd.md |   25 +
 gcc/config/aarch64/aarch64-sve-builtins-base.cc|8 +-
 gcc/config/aarch64/aarch64-sve-builtins.cc |   65 +-
 gcc/config/aarch64/aarch64.cc  |  116 +-
 gcc/config/aarch64/aarch64.h   |3 +
 gcc/config/aarch64/iterators.md|  117 +-
 gcc/config/arm/arm_mve.h   |4 +
 gcc/config/arm/arm_mve_types.h |4 +
 gcc/config/avr/avr-c.cc|3 +-
 gcc/config/avr/avr-passes.cc   |   35 +-
 gcc/config/avr/avr.cc  |   70 +-
 gcc/config/avr/avr.md  |   26 +-
 gcc/config/i386/i386-features.cc   |2 +-
 gcc/config/m68k/m68k.md|   12 +-
 gcc/config/mingw/mingw-stdint.h|2 +-
 gcc/config/mingw/winnt-dll.cc  |2 +-
 gcc/config/riscv/generic-vector-ooo.md |2 +-
 gcc/config/riscv/genrvv-type-indexer.cc|   10 +
 gcc/config/riscv/riscv-c.cc|3 +-
 gcc/config/riscv/riscv-vector-builtins-bases.cc|6 -
 gcc/config/riscv/riscv-vector-builtins-bases.h |6 +
 gcc/config/riscv/riscv-vector-builtins-shapes.cc   |   28 +
 gcc/config/riscv/riscv-vector-builtins-shapes.h|1 +
 gcc/config/riscv/riscv-vector-builtins.cc  |   51 +-
 gcc/config/riscv/riscv-vector-builtins.def |   31 +-
 gcc/config/riscv/riscv-vector-builtins.h   |7 +
 gcc/config/riscv/riscv.cc  |   64 +-
 gcc/config/riscv/riscv.md  |3 +-
 gcc/config/riscv/sifive-vector-builtins-bases.cc   |   52 +
 gcc/config/riscv/sifive-vector-builtins-bases.h|2 +
 .../riscv/sifive-vector-builtins-functions.def |4 +
 gcc/config/riscv/sifive-vector.md  |   20 +
 gcc/config/riscv/vector-iterators.md   |   30 +-
 gcc/configure  |   38 +-
 gcc/configure.ac   |9 +-
 gcc/cp/ChangeLog   |   70 +
 gcc/cp/constraint.cc   |  185 +-
 gcc/cp/cp-objcp-common.cc  |1 -
 gcc/cp/cp-tree.def |6 -
 gcc/cp/cp-tree.h   |   36 +-
 gcc/cp/cxx-pretty-print.cc |4 +-
 gcc/cp/error.cc|5 -
 gcc/cp/parser.cc   |  114 +-
 gcc/cp/pt.cc   |   42 +-
 gcc/crc-verification.cc| 1299 +++
 gcc/crc-verification.h |  162 ++
 gcc/debug.cc   |9 +-
 gcc/debug.h|3 +-
 gcc/diagnostic-show-locus.cc   |  128 +-
 gcc/doc/invoke.texi|   18 +-
 .../libgdiagnostics/tutorial/01-hello-world.rst|2 +-
 gcc/doc/tm.texi|2 +-
 gcc/dwarf2codeview.cc  |  769 ++-
 gcc/dwarf2codeview.h   |3 +
 gcc/dwarf2out.cc   |   22 +-
 gcc/final.cc   |2 +-
 gcc/fortran/trans-decl.cc 

[gcc/redhat/heads/gcc-15-branch] (76 commits) Merge commit 'r15-5896-g4114b7fb1cb4cb90b9fafc22213d7d9579b

2024-12-03 Thread Jakub Jelinek via Gcc-cvs
The branch 'redhat/heads/gcc-15-branch' was updated to point to:

 d2b3fd44a4b2... Merge commit 'r15-5896-g4114b7fb1cb4cb90b9fafc22213d7d9579b

It previously pointed to:

 ec0e37c5cf7e... Red Hat customizations.

Diff:

Summary of changes (added commits):
---

  d2b3fd4... Merge commit 'r15-5896-g4114b7fb1cb4cb90b9fafc22213d7d9579b
  4114b7f... AVR: ad target/117726 - Also split logic shifts of bitsize  (*)
  f3b5de9... preprocessor: Adjust C rules on UCNs for C23 [PR117162] (*)
  af9a3fe... tree-optimization/117874 - optimize SLP discovery budget us (*)
  d4f3c3e... Use the number of relevant stmts to limit SLP build (*)
  d203f4c... AVR: Tweak uin8_t << 6 and uint8_t >> 6 shifts. (*)
  d777d66... aarch64: Fix fp8 cpuinfo feature names (*)
  d1318eb... libstdc++: Make std::vector constructor noexcept (LWG (*)
  29bea69... libstdc++: Fix constraints on std::optional converting cons (*)
  17c9c7c... tree-ssanames, match.pd: get_nonzero_bits/with_*_nonzero_bi (*)
  0b89341... bitintlower: Fix up ?ROTATE_EXPR lowering [PR117847] (*)
  3d72e50... OpenMP: 'allocate' directive - fixes for 'alignof' and [[om (*)
  83f22c1... aarch64: Add flags field to aarch64-simd-pragma-builtins.de (*)
  a07a2b8... aarch64: Add support for AdvSIMD lut (*)
  f855bc3... aarch64: Refactor AdvSIMD intrinsics (*)
  c063f83... aarch64: Put iterators into the right section (*)
  5f3282f... aarch64: Split out aarch64_v64_mode (*)
  e8fc954... aarch64: Move some diagnostic functions to aarch64.cc (*)
  f2d9116... Match: Refactor the unsigned SAT_SUB match patterns [NFC] (*)
  5cbeecf... RISC-V: Fix incorrect optimization options passing to reduc (*)
  4acab37... replace atoi with strtoul in varasm.cc (decode_reg_name_and (*)
  be8d1a3... tree-optimization/117874 - missed vectorization that's form (*)
  dfb9f6e... RISC-V: Fix incorrect optimization options passing to cond  (*)
  6f72fd5... Daily bump. (*)
  e11c795... libgdiagnostics: fix a missing rename in the docs (*)
  8173d0a... gccrs: Remove unused files 'gcc/rust/typecheck/rust-hir-typ (*)
  1467409... libstdc++: Simplify std::_Destroy using 'if constexpr' (*)
  4df8e6f... [committed] Add sym-exec subdirectory to configure.in rathe (*)
  4c857e9... MAINTAINERS: add myself to write after approval (*)
  27e5d86... libstdc++: Disable deprecated warnings for std::rel_ops in  (*)
  73e7f63... c++: some further concepts cleanups (*)
  cec9754... m68k: don't allow o/o in movdi, movdf, movxf (*)
  a3e5fbc... Add trailing newlines where needed (*)
  cde7ce0... arm, mve: Adding missing Runtime Library Exception to heade (*)
  5ab3f09... tree-optimization/116352 - SLP scheduling and stmt order (*)
  e36eae1... testsuite: Adjust rs6000-ldouble-2.c for switch to -std=gnu (*)
  2751970... RISC-V: Add intrinsics testcases for SiFive Xsfvfnrclipxfqf (*)
  1352d4d... RISC-V: Add intrinsics support for SiFive Xsfvfnrclipxfqf e (*)
  712cb29... riscv: Avoid narrowing warning (*)
  e4dd007... x86: Correct comments for pass_apx_nf_convert (*)
  12e30d8... RISC-V: Fix incorrect optimization options passing to widde (*)
  aedb306... RISC-V: Fix RVV strided load/store testcases failure (*)
  326d474... Daily bump. (*)
  90becd9... [contrib] validate_failures.py: fix python 3.12 escape sequ (*)
  721a38a... [PATCH] gcc: configure: Fix the optimization flags cleanup (*)
  999aad4... Thanks for the feedback on the first version of the patch.  (*)
  113e902... [PATCH v7 12/12] Add tests for CRC detection and generation (*)
  4d2b920... [PATCH v7 11/12] Replace the original CRC loops with a fast (*)
  dcc6101... [PATCH v7 10/12] Verify detected CRC loop with symbolic exe (*)
  148e204... [PATCH v6 09/12] Add symbolic execution support. (*)
  062ad20... [PATCH v7 08/12] Add a new pass for naive CRC loops detecti (*)
  75fe4e2... Write binary annotations for CodeView S_INLINESITE symbols (*)
  7151aa1... testsuite: Silence gcc.dg/pr117806.c for default_packed (*)
  e1009b3... VN: Don't recurse on for the same value of `a != 0` [PR1178 (*)
  24949e6... gimple-lim: Reuse boolean var when moving PHI (*)
  e0ffe66... testsuite: Fix aarch64/sve/acle/general-c/gnu_vectors_[12]. (*)
  8491723... testsuite: Fix aarch64/sve/acle/general-c++/gnu_vectors_[12 (*)
  b996304... testsuite: Fix sve-sizeless-[12].C for C++98 (*)
  86b0750... testsuite: Fix sve-sizeless-[12].C for aggregate change (*)
  99d1fcf... testsuite: Fix another issue with sve-sizeless-[12].C (*)
  cdcc938... testsuite: Fix part of sve-sizeless-2.c (*)
  e4c1b3d... [PATCH v3] zero_extend(not) -> xor optimization [PR112398] (*)
  ff5e235... Daily bump. (*)
  abed480... libstdc++: Improve new testcase for std::optional assignmen (*)
  c2c7d71... libstdc++: Fix constraints on std::optional converting assi (*)
  91f4550... libstdc++: Move std::monostate to  for C++26 (P047 (*)
  0598e2f... libstdc++: Improve test for  synopsis (*)
  2ae0566... Support for 64-bit location_t: Internal parts (*)
  8cc9d27... Support for 64-bit lo

[gcc r14-11052] [PATCH] modula2: M2MetaError.{def, mod} and P2SymBuild.mod further cleanup

2024-12-03 Thread Gaius Mulley via Gcc-cvs
https://gcc.gnu.org/g:d35eeeca7b27bb153d61e5668d52efff6432cf66

commit r14-11052-gd35eeeca7b27bb153d61e5668d52efff6432cf66
Author: Gaius Mulley 
Date:   Tue Dec 3 15:58:27 2024 +

[PATCH] modula2: M2MetaError.{def,mod} and P2SymBuild.mod further cleanup

Further cleanups and improve the wording of an error message.

gcc/m2/ChangeLog:

* gm2-compiler/M2MetaError.mod (op): Corrected ordering.
* gm2-compiler/P2SymBuild.def: Remove comment.
* gm2-compiler/P2SymBuild.mod (GetComparison): Replace
the word less with fewer.

(cherry picked from commit 961c02313f7e7a918e06851964ba54ea2e342cfa)

Signed-off-by: Gaius Mulley 

Diff:
---
 gcc/m2/gm2-compiler/M2MetaError.mod | 8 
 gcc/m2/gm2-compiler/P2SymBuild.def  | 9 -
 gcc/m2/gm2-compiler/P2SymBuild.mod  | 2 +-
 3 files changed, 5 insertions(+), 14 deletions(-)

diff --git a/gcc/m2/gm2-compiler/M2MetaError.mod 
b/gcc/m2/gm2-compiler/M2MetaError.mod
index e9f3127925c4..14df6457d64c 100644
--- a/gcc/m2/gm2-compiler/M2MetaError.mod
+++ b/gcc/m2/gm2-compiler/M2MetaError.mod
@@ -1684,7 +1684,7 @@ END copySym ;
 
 
 (*
-   op := {'!'|'a'|'c'|'d'|'k'|'q'|'t'|'p'|'n'|'s'|'u'|
+   op := {'!'|'a'|'c'|'d'|'k'|'n'|'p'|'q'|'s'|'t'|'u'|
   'A'|'B'|'C'|'D'|'E'|'F'|'G'|'H'|'K'|'M'|'N'|
   'O'|'P'|'Q'|'R'|'S'|'T'|'U'|'V'|'W'|'X'|'Y'|'Z'} then =:
 *)
@@ -1707,11 +1707,11 @@ BEGIN
   'd':  doDesc (eb, sym, bol) |
   'k':  unquotedKeyword (eb) ;
 DEC (eb.ini) |
-  'q':  doQualified (eb, sym, bol) |
-  't':  doType (eb, sym, bol) |
-  'p':  popColor (eb) |
   'n':  doNumber (eb, sym, bol) |
+  'p':  popColor (eb) |
+  'q':  doQualified (eb, sym, bol) |
   's':  doSkipType (eb, sym, bol) |
+  't':  doType (eb, sym, bol) |
   'u':  eb.quotes := FALSE |
   'A':  eb.type := aborta ;
 seenAbort := TRUE |
diff --git a/gcc/m2/gm2-compiler/P2SymBuild.def 
b/gcc/m2/gm2-compiler/P2SymBuild.def
index 45b52f7f02d7..ae736886e8a0 100644
--- a/gcc/m2/gm2-compiler/P2SymBuild.def
+++ b/gcc/m2/gm2-compiler/P2SymBuild.def
@@ -21,15 +21,6 @@ along with GNU Modula-2; see the file COPYING3.  If not see
 
 DEFINITION MODULE P2SymBuild ;
 
-(*
-   Title  : P2SymBuild
-   Author : Gaius Mulley
-   Date   : 24/6/87
-   LastEdit   : Sat Dec  9 11:10:57 EST 1989
-   System : UNIX (GNU Modula-2)
-   Description: pass 2 symbol creation.
-*)
-
 
 (*
BlockStart - tokno is the module/procedure/implementation/definition token
diff --git a/gcc/m2/gm2-compiler/P2SymBuild.mod 
b/gcc/m2/gm2-compiler/P2SymBuild.mod
index 9edb911949ea..2196b584eb55 100644
--- a/gcc/m2/gm2-compiler/P2SymBuild.mod
+++ b/gcc/m2/gm2-compiler/P2SymBuild.mod
@@ -2055,7 +2055,7 @@ PROCEDURE GetComparison (left, right: CARDINAL) : String ;
 BEGIN
IF left < right
THEN
-  RETURN InitString ('less')
+  RETURN InitString ('fewer')
ELSIF left > right
THEN
   RETURN InitString ('more')


[gcc r15-5890] libstdc++: Make std::vector constructor noexcept (LWG 3778)

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

commit r15-5890-gd1318ebb7d1fb474a3b096406bda759187c56610
Author: Jonathan Wakely 
Date:   Mon Dec 2 15:13:52 2024 +

libstdc++: Make std::vector constructor noexcept (LWG 3778)

LWG 3778 was approved in November 2022. We already implement all the
changes except for one, which this commit does.

The new test verifies all the changes from LWG 3778, not just the one
implemented here.

libstdc++-v3/ChangeLog:

* include/bits/stl_bvector.h (vector(const allocator_type&)):
Add noexcept, as per LWG 3778.
* testsuite/23_containers/vector/bool/cons/lwg3778.cc: New test.

Diff:
---
 libstdc++-v3/include/bits/stl_bvector.h|  2 +-
 .../23_containers/vector/bool/cons/lwg3778.cc  | 87 ++
 2 files changed, 88 insertions(+), 1 deletion(-)

diff --git a/libstdc++-v3/include/bits/stl_bvector.h 
b/libstdc++-v3/include/bits/stl_bvector.h
index 39d19e7954d6..341eee33b21c 100644
--- a/libstdc++-v3/include/bits/stl_bvector.h
+++ b/libstdc++-v3/include/bits/stl_bvector.h
@@ -787,7 +787,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
 
   _GLIBCXX20_CONSTEXPR
   explicit
-  vector(const allocator_type& __a)
+  vector(const allocator_type& __a) _GLIBCXX_NOEXCEPT
   : _Base(__a) { }
 
 #if __cplusplus >= 201103L
diff --git a/libstdc++-v3/testsuite/23_containers/vector/bool/cons/lwg3778.cc 
b/libstdc++-v3/testsuite/23_containers/vector/bool/cons/lwg3778.cc
new file mode 100644
index ..49c510dd626b
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/vector/bool/cons/lwg3778.cc
@@ -0,0 +1,87 @@
+// { dg-do compile { target c++11 } }
+
+// LWG 3778. vector missing exception specifications
+
+#include 
+#include 
+
+using V = std::vector;
+
+static_assert(std::is_nothrow_default_constructible::value,
+ "nothrow default constructible with std::allocator");
+static_assert(std::is_nothrow_constructible::value,
+ "nothrow constructible with allocator argument");
+static_assert(std::is_nothrow_move_constructible::value,
+ "unconditionally nothrow move constructible");
+static_assert(std::is_nothrow_move_assignable::value,
+ "nothrow move assignment with std::allocator");
+static_assert(std::__is_nothrow_swappable::value,
+ "nothrow swap with std::allocator");
+
+template
+struct Allocator : __gnu_test::SimpleAllocator
+{
+  Allocator() noexcept(false) { }
+
+  template
+Allocator(const Allocator&) { }
+};
+
+using V2 = std::vector>;
+static_assert(std::is_default_constructible::value,
+ "default constructible with Allocator");
+static_assert(std::is_nothrow_constructible::value,
+ "nothrow constructible with allocator argument");
+static_assert(! std::is_nothrow_default_constructible::value,
+ "but not nothrow default constructible with Allocator");
+static_assert(std::is_nothrow_move_constructible::value,
+ "also checked by ./noexcept_move_construct.cc");
+static_assert(std::__is_nothrow_swappable::value,
+ "nothrow swap with std::allocator");
+
+template
+struct PropAllocator : __gnu_test::SimpleAllocator
+{
+  PropAllocator() noexcept { }
+
+  template
+PropAllocator(const PropAllocator&) { }
+
+  using is_always_equal = POCMA;
+  using propagate_on_container_move_assignment = IAE;
+};
+
+using V3 = std::vector>;
+static_assert(std::is_nothrow_move_constructible::value,
+ "unconditionally nothrow move constructible");
+static_assert(std::is_nothrow_constructible::value,
+ "nothrow constructible with allocator argument");
+static_assert(! std::is_nothrow_move_assignable::value,
+ "throwing move assignment with !(propagating || equal) alloc");
+#ifdef _GLIBCXX_RELEASE
+// We strengthen std::vector::swap to be always noexcept.
+static_assert(std::__is_nothrow_swappable::value,
+ "nothrow swap even with !(propagating || equal) alloc");
+#endif
+
+using V4
+  = std::vector>;
+static_assert(std::is_nothrow_constructible::value,
+ "nothrow constructible with allocator argument");
+static_assert(std::is_nothrow_move_constructible::value,
+ "unconditionally nothrow move constructible");
+static_assert(std::is_nothrow_move_assignable::value,
+ "nothrow move assignment with propagating alloc");
+static_assert(std::__is_nothrow_swappable::value,
+ "nothrow swap with always-equal alloc");
+
+using V5
+  = std::vector>;
+static_assert(std::is_nothrow_constructible::value,
+ "nothrow constructible with allocator argument");
+static_assert(std::is_nothrow_move_constructible::value,
+ "unconditionally nothrow move constructible");
+static_assert(std::is_nothrow_move_assignable::value,
+ "nothrow move assignment with always-equal alloc");
+static_assert(std::__is_nothrow_swappable::value,
+  

[gcc r15-5884] aarch64: Add support for AdvSIMD lut

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

commit r15-5884-ga07a2b8c9e7c2d123f0178875c9110eaf9770b7a
Author: Saurabh Jha 
Date:   Tue Dec 3 09:54:01 2024 +

aarch64: Add support for AdvSIMD lut

The AArch64 FEAT_LUT extension is optional from Armv9.2-A and mandatory
from Armv9.5-A. It introduces instructions for lookup table reads with
bit indices.

This patch adds support for AdvSIMD lut intrinsics. The intrinsics for
this extension are implemented as the following builtin functions:
* vluti2{q}_lane{q}_{u8|s8|p8}
* vluti2{q}_lane{q}_{u16|s16|p16|f16|bf16}
* vluti4q_lane{q}_{u8|s8|p8}
* vluti4q_lane{q}_{u16|s16|p16|f16|bf16}_x2

We also introduced a new approach to do lane checks for AdvSIMD.

gcc/ChangeLog:

* config/aarch64/aarch64-builtins.cc
(aarch64_builtin_signatures): Add binary_lane.
(aarch64_fntype): Handle it.
(simd_types): Add 16-bit x2 types.
(aarch64_pragma_builtins_checker): New class.
(aarch64_general_check_builtin_call): Use it.
(aarch64_expand_pragma_builtin): Add support for lut unspecs.
* config/aarch64/aarch64-option-extensions.def
(AARCH64_OPT_EXTENSION): Add lut option.
* config/aarch64/aarch64-simd-pragma-builtins.def
(ENTRY_BINARY_LANE): Modify to use new ENTRY macro.
(ENTRY_TERNARY_VLUT8): Macro to declare lut intrinsics.
(ENTRY_TERNARY_VLUT16): Macro to declare lut intrinsics.
(REQUIRED_EXTENSIONS): Declare lut intrinsics.
* config/aarch64/aarch64-simd.md
(@aarch64_): Instruction
pattern for luti2 and luti4 intrinsics.
(@aarch64_lutx2): Instruction pattern for
luti4x2 intrinsics.
* config/aarch64/aarch64.h
(TARGET_LUT): lut flag.
* config/aarch64/iterators.md: Iterators and attributes for lut.
* doc/invoke.texi: Document extension in AArch64 Options.

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/simd/lut-incorrect-range.c: New test.
* gcc.target/aarch64/simd/lut-no-flag.c: New test.
* gcc.target/aarch64/simd/lut.c: New test.

Co-authored-by: Vladimir Miloserdov 
Co-authored-by: Richard Sandiford 

Diff:
---
 gcc/config/aarch64/aarch64-builtins.cc | 132 +++-
 gcc/config/aarch64/aarch64-option-extensions.def   |   2 +
 .../aarch64/aarch64-simd-pragma-builtins.def   |  38 +
 gcc/config/aarch64/aarch64-simd.md |  25 +
 gcc/config/aarch64/aarch64.h   |   3 +
 gcc/config/aarch64/iterators.md|  14 +
 gcc/doc/invoke.texi|   2 +
 .../gcc.target/aarch64/simd/lut-incorrect-range.c  | 221 ++
 .../gcc.target/aarch64/simd/lut-no-flag.c  |  10 +
 gcc/testsuite/gcc.target/aarch64/simd/lut.c| 849 +
 10 files changed, 1294 insertions(+), 2 deletions(-)

diff --git a/gcc/config/aarch64/aarch64-builtins.cc 
b/gcc/config/aarch64/aarch64-builtins.cc
index 8984f0c59b97..f8c8a2721388 100644
--- a/gcc/config/aarch64/aarch64-builtins.cc
+++ b/gcc/config/aarch64/aarch64-builtins.cc
@@ -50,6 +50,8 @@
 #include "builtins.h"
 #include "aarch64-builtins.h"
 
+using namespace aarch64;
+
 #define v8qi_UP  E_V8QImode
 #define v8di_UP  E_V8DImode
 #define v4hi_UP  E_V4HImode
@@ -1600,6 +1602,7 @@ aarch64_init_simd_builtin_functions (bool 
called_from_pragma)
 enum class aarch64_builtin_signatures
 {
   binary,
+  binary_lane,
 };
 
 namespace {
@@ -1623,15 +1626,20 @@ namespace simd_types {
 
   constexpr simd_type f16 { V4HFmode, qualifier_none };
   constexpr simd_type f16q { V8HFmode, qualifier_none };
+  constexpr simd_type f16qx2 { V2x8HFmode, qualifier_none };
   constexpr simd_type p16 { V4HImode, qualifier_poly };
   constexpr simd_type p16q { V8HImode, qualifier_poly };
+  constexpr simd_type p16qx2 { V2x8HImode, qualifier_poly };
   constexpr simd_type s16 { V4HImode, qualifier_none };
   constexpr simd_type s16q { V8HImode, qualifier_none };
+  constexpr simd_type s16qx2 { V2x8HImode, qualifier_none };
   constexpr simd_type u16 { V4HImode, qualifier_unsigned };
   constexpr simd_type u16q { V8HImode, qualifier_unsigned };
+  constexpr simd_type u16qx2 { V2x8HImode, qualifier_unsigned };
 
   constexpr simd_type bf16 { V4BFmode, qualifier_none };
   constexpr simd_type bf16q { V8BFmode, qualifier_none };
+  constexpr simd_type bf16qx2 { V2x8BFmode, qualifier_none };
 
   constexpr simd_type f32 { V2SFmode, qualifier_none };
   constexpr simd_type f32q { V4SFmode, qualifier_none };
@@ -1671,11 +1679,21 @@ aarch64_fntype (const aarch64_pragma_builtins_data 
&builtin_data)
   switch (builtin_data.signature)
 {
 case aarch64_builtin_signatures::binary:
+case aarch64_builtin_signatures::binary_lane:
   return_type = builtin_data

[gcc r15-5885] aarch64: Add flags field to aarch64-simd-pragma-builtins.def

2024-12-03 Thread Richard Sandiford via Gcc-cvs
https://gcc.gnu.org/g:83f22c1c526368cafc3d32f03462ecd7847f054f

commit r15-5885-g83f22c1c526368cafc3d32f03462ecd7847f054f
Author: Richard Sandiford 
Date:   Tue Dec 3 09:54:01 2024 +

aarch64: Add flags field to aarch64-simd-pragma-builtins.def

This patch adds a flags field to aarch64-simd-pragma-builtins.def
and uses it to add attributes to the function declaration.

gcc/
* config/aarch64/aarch64-simd-pragma-builtins.def: Add a flags
field to each entry.
* config/aarch64/aarch64-builtins.cc: Update includes accordingly.
(aarch64_pragma_builtins_data): Add a flags field.
(aarch64_init_pragma_builtins): Use the flags field to add 
attributes
to the function declaration.

Diff:
---
 gcc/config/aarch64/aarch64-builtins.cc | 12 +++--
 .../aarch64/aarch64-simd-pragma-builtins.def   | 59 +-
 2 files changed, 42 insertions(+), 29 deletions(-)

diff --git a/gcc/config/aarch64/aarch64-builtins.cc 
b/gcc/config/aarch64/aarch64-builtins.cc
index f8c8a2721388..22f8216a45b3 100644
--- a/gcc/config/aarch64/aarch64-builtins.cc
+++ b/gcc/config/aarch64/aarch64-builtins.cc
@@ -782,7 +782,7 @@ typedef struct
   AARCH64_SIMD_BUILTIN_##T##_##N##A,
 
 #undef ENTRY
-#define ENTRY(N, S, T0, T1, T2, U) \
+#define ENTRY(N, S, T0, T1, T2, U, F)  \
   AARCH64_##N,
 
 enum aarch64_builtins
@@ -1651,9 +1651,10 @@ namespace simd_types {
 }
 
 #undef ENTRY
-#define ENTRY(N, S, T0, T1, T2, U) \
+#define ENTRY(N, S, T0, T1, T2, U, F) \
   {#N, aarch64_builtin_signatures::S, simd_types::T0, simd_types::T1, \
-   simd_types::T2, U, aarch64_required_extensions::REQUIRED_EXTENSIONS},
+   simd_types::T2, U, aarch64_required_extensions::REQUIRED_EXTENSIONS, \
+   FLAG_##F},
 
 /* Initialize pragma builtins.  */
 
@@ -1664,6 +1665,7 @@ struct aarch64_pragma_builtins_data
   simd_type types[3];
   int unspec;
   aarch64_required_extensions required_extensions;
+  unsigned int flags;
 };
 
 static aarch64_pragma_builtins_data aarch64_pragma_builtins[] = {
@@ -1708,8 +1710,10 @@ aarch64_init_pragma_builtins ()
   auto data = aarch64_pragma_builtins[i];
   auto fntype = aarch64_fntype (data);
   auto code = AARCH64_PRAGMA_BUILTIN_START + i + 1;
+  auto flag_mode = data.types[0].mode;
+  auto attrs = aarch64_get_attributes (data.flags, flag_mode);
   aarch64_builtin_decls[code]
-   = aarch64_general_simulate_builtin (data.name, fntype, code);
+   = aarch64_general_simulate_builtin (data.name, fntype, code, attrs);
 }
 }
 
diff --git a/gcc/config/aarch64/aarch64-simd-pragma-builtins.def 
b/gcc/config/aarch64/aarch64-simd-pragma-builtins.def
index db40745e9e34..ae8732bdb318 100644
--- a/gcc/config/aarch64/aarch64-simd-pragma-builtins.def
+++ b/gcc/config/aarch64/aarch64-simd-pragma-builtins.def
@@ -19,46 +19,55 @@
.  */
 
 #undef ENTRY_BINARY
-#define ENTRY_BINARY(N, T0, T1, T2, U) \
-  ENTRY (N, binary, T0, T1, T2, U)
+#define ENTRY_BINARY(N, T0, T1, T2, U, F)  \
+  ENTRY (N, binary, T0, T1, T2, U, F)
 
 #undef ENTRY_BINARY_LANE
-#define ENTRY_BINARY_LANE(N, T0, T1, T2, U)\
-  ENTRY (N, binary_lane, T0, T1, T2, U)
+#define ENTRY_BINARY_LANE(N, T0, T1, T2, U, F) \
+  ENTRY (N, binary_lane, T0, T1, T2, U, F)
 
 #undef ENTRY_BINARY_VHSDF
-#define ENTRY_BINARY_VHSDF(NAME, UNSPEC)  \
-  ENTRY_BINARY (NAME##_f16, f16, f16, f16, UNSPEC) \
-  ENTRY_BINARY (NAME##q_f16, f16q, f16q, f16q, UNSPEC) \
-  ENTRY_BINARY (NAME##_f32, f32, f32, f32, UNSPEC) \
-  ENTRY_BINARY (NAME##q_f32, f32q, f32q, f32q, UNSPEC) \
-  ENTRY_BINARY (NAME##q_f64, f64q, f64q, f64q, UNSPEC)
+#define ENTRY_BINARY_VHSDF(NAME, UNSPEC, FLAGS)\
+  ENTRY_BINARY (NAME##_f16, f16, f16, f16, UNSPEC, FLAGS)  \
+  ENTRY_BINARY (NAME##q_f16, f16q, f16q, f16q, UNSPEC, FLAGS)  \
+  ENTRY_BINARY (NAME##_f32, f32, f32, f32, UNSPEC, FLAGS)  \
+  ENTRY_BINARY (NAME##q_f32, f32q, f32q, f32q, UNSPEC, FLAGS)  \
+  ENTRY_BINARY (NAME##q_f64, f64q, f64q, f64q, UNSPEC, FLAGS)
 
 #undef ENTRY_TERNARY_VLUT8
-#define ENTRY_TERNARY_VLUT8(T) \
-  ENTRY_BINARY_LANE (vluti2_lane_##T##8, T##8q, T##8, u8, UNSPEC_LUTI2)
\
-  ENTRY_BINARY_LANE (vluti2_laneq_##T##8, T##8q, T##8, u8q, UNSPEC_LUTI2) \
-  ENTRY_BINARY_LANE (vluti2q_lane_##T##8, T##8q, T##8q, u8, UNSPEC_LUTI2) \
-  ENTRY_BINARY_LANE (vluti2q_laneq_##T##8, T##8q, T##8q, u8q, UNSPEC_LUTI2) \
-  ENTRY_BINARY_LANE (vluti4q_lane_##T##8, T##8q, T##8q, u8, UNSPEC_LUTI4) \
-  ENTRY_BINARY_LANE (vluti4q_laneq_##T##8, T##8q, T##8q, u8q, UNSPEC_LUTI4)
+#define ENTRY_TERNARY_VLUT8(T) \
+  ENTRY_BINARY_LANE (vluti2_lane_##T##8, T##8q, T##8, u8,  \
+UNSPEC_LUTI2, NONE)\
+  ENTRY_BINARY_LANE (vluti2_laneq_##T##8, T##8q, T##8, u8q,\
+UNSP

[gcc r15-5882] aarch64: Put iterators into the right section

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

commit r15-5882-gc063f833c668b6571ca23207e85237ff3da100a3
Author: Saurabh Jha 
Date:   Tue Dec 3 09:54:00 2024 +

aarch64: Put iterators into the right section

iterators.md is grouped by iterator type and by attribute type.
This patch just moves some stuff that was in the "wrong" section.

gcc/
* config/aarch64/iterators.md: Reorder some declarations,
putting them under the associated heading comment.

Co-authored-by: Vladimir Miloserdov 
Co-authored-by: Richard Sandiford 

Diff:
---
 gcc/config/aarch64/iterators.md | 103 +++-
 1 file changed, 50 insertions(+), 53 deletions(-)

diff --git a/gcc/config/aarch64/iterators.md b/gcc/config/aarch64/iterators.md
index 4786b0210e7e..720d79db8e43 100644
--- a/gcc/config/aarch64/iterators.md
+++ b/gcc/config/aarch64/iterators.md
@@ -3165,6 +3165,10 @@
 
 (define_int_iterator LAST [UNSPEC_LASTA UNSPEC_LASTB])
 
+;; Iterators for fp8 operations
+
+(define_int_iterator FAMINMAX_UNS [UNSPEC_FAMAX UNSPEC_FAMIN])
+
 (define_int_iterator SVE_INT_UNARY [UNSPEC_REVB
UNSPEC_REVH UNSPEC_REVW])
 
@@ -3738,20 +3742,44 @@
  [UNSPECV_ATOMIC_LDOP_OR UNSPECV_ATOMIC_LDOP_BIC
   UNSPECV_ATOMIC_LDOP_XOR UNSPECV_ATOMIC_LDOP_PLUS])
 
-(define_int_attr atomic_ldop
- [(UNSPECV_ATOMIC_LDOP_OR "set") (UNSPECV_ATOMIC_LDOP_BIC "clr")
-  (UNSPECV_ATOMIC_LDOP_XOR "eor") (UNSPECV_ATOMIC_LDOP_PLUS "add")])
-
-(define_int_attr atomic_ldoptab
- [(UNSPECV_ATOMIC_LDOP_OR "ior") (UNSPECV_ATOMIC_LDOP_BIC "bic")
-  (UNSPECV_ATOMIC_LDOP_XOR "xor") (UNSPECV_ATOMIC_LDOP_PLUS "add")])
-
 (define_int_iterator SUBDI_BITS [8 16 32])
 
 (define_int_iterator BHSD_BITS [8 16 32 64])
 
 (define_int_iterator LUTI_BITS [2 4])
 
+(define_int_iterator GET_FPSCR
+  [UNSPECV_GET_FPSR UNSPECV_GET_FPCR])
+
+(define_int_iterator SET_FPSCR
+  [UNSPECV_SET_FPSR UNSPECV_SET_FPCR])
+
+(define_int_iterator FP8CVT_UNS
+  [UNSPEC_F1CVT
+   UNSPEC_F2CVT
+   UNSPEC_F1CVTLT
+   UNSPEC_F2CVTLT])
+
+(define_int_iterator SVE2_FP8_TERNARY_VNX8HF
+  [UNSPEC_FMLALB_FP8
+   UNSPEC_FMLALT_FP8])
+
+(define_int_iterator SVE2_FP8_TERNARY_VNX4SF
+  [UNSPEC_FMLALLBB_FP8
+   UNSPEC_FMLALLBT_FP8
+   UNSPEC_FMLALLTB_FP8
+   UNSPEC_FMLALLTT_FP8])
+
+(define_int_iterator SVE2_FP8_TERNARY_LANE_VNX8HF
+  [UNSPEC_FMLALB_FP8
+   UNSPEC_FMLALT_FP8])
+
+(define_int_iterator SVE2_FP8_TERNARY_LANE_VNX4SF
+  [UNSPEC_FMLALLBB_FP8
+   UNSPEC_FMLALLBT_FP8
+   UNSPEC_FMLALLTB_FP8
+   UNSPEC_FMLALLTT_FP8])
+
 ;; ---
 ;; Int Iterators Attributes.
 ;; ---
@@ -3968,6 +3996,8 @@
 (define_code_attr binqops_op_rev [(ss_plus "sqsub")
  (ss_minus "sqadd")])
 
+(define_code_attr faminmax_op [(smax "famax") (smin "famin")])
+
 ;; The SVE logical instruction that implements an unspec.
 (define_int_attr logicalf_op [(UNSPEC_ANDF "and")
  (UNSPEC_IORF "orr")
@@ -4180,6 +4210,12 @@
 (define_int_attr frintnzs_op [(UNSPEC_FRINT32Z "frint32z") (UNSPEC_FRINT32X 
"frint32x")
  (UNSPEC_FRINT64Z "frint64z") (UNSPEC_FRINT64X 
"frint64x")])
 
+(define_int_attr faminmax_cond_uns_op
+  [(UNSPEC_COND_SMAX "famax") (UNSPEC_COND_SMIN "famin")])
+
+(define_int_attr faminmax_uns_op
+  [(UNSPEC_FAMAX "famax") (UNSPEC_FAMIN "famin")])
+
 ;; The condition associated with an UNSPEC_COND_.
 (define_int_attr cmp_op [(UNSPEC_COND_CMPEQ_WIDE "eq")
 (UNSPEC_COND_CMPGE_WIDE "ge")
@@ -4724,12 +4760,6 @@
 
 ;; Iterators and attributes for fpcr fpsr getter setters
 
-(define_int_iterator GET_FPSCR
-  [UNSPECV_GET_FPSR UNSPECV_GET_FPCR])
-
-(define_int_iterator SET_FPSCR
-  [UNSPECV_SET_FPSR UNSPECV_SET_FPCR])
-
 (define_int_attr fpscr_name
   [(UNSPECV_GET_FPSR "fpsr")
(UNSPECV_SET_FPSR "fpsr")
@@ -4738,26 +4768,13 @@
 
 (define_int_attr bits_etype [(8 "b") (16 "h") (32 "s") (64 "d")])
 
-;; Iterators and attributes for faminmax
-
-(define_int_iterator FAMINMAX_UNS [UNSPEC_FAMAX UNSPEC_FAMIN])
-
-(define_int_attr faminmax_cond_uns_op
-  [(UNSPEC_COND_SMAX "famax") (UNSPEC_COND_SMIN "famin")])
-
-(define_int_attr faminmax_uns_op
-  [(UNSPEC_FAMAX "famax") (UNSPEC_FAMIN "famin")])
-
-(define_code_attr faminmax_op
-  [(smax "famax") (smin "famin")])
-
-;; Iterators and attributes for fp8 sve/sme conversions
+(define_int_attr atomic_ldop
+ [(UNSPECV_ATOMIC_LDOP_OR "set") (UNSPECV_ATOMIC_LDOP_BIC "clr")
+  (UNSPECV_ATOMIC_LDOP_XOR "eor") (UNSPECV_ATOMIC_LDOP_PLUS "add")])
 
-(define_int_iterator FP8CVT_UNS
-  [UNSPEC_F1CVT
-   UNSPEC_F2CVT
-   UNSPEC_F1CVTLT
-   UNSPEC_F2CVTLT])
+(define_int_attr atomic_ldoptab
+ [(UNSPECV_ATOMIC_LDOP_OR "ior") (UNSPECV_ATOMIC_LDOP_BIC "bic")
+  (UNSPECV_ATOMIC_LDOP_XOR "xor") (UNSPECV_ATOMIC_LDOP_PLUS "add")])
 
 (define_int_attr fp8_cvt_uns

[gcc r15-5883] aarch64: Refactor AdvSIMD intrinsics

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

commit r15-5883-gf855bc3006f43a623bd6197a795f238e70a3f007
Author: Saurabh Jha 
Date:   Tue Dec 3 09:54:00 2024 +

aarch64: Refactor AdvSIMD intrinsics

Refactor AdvSIMD intrinsics defined using the new pragma-based approach
so that it is more extensible.

Introduce a new struct, simd_type, which defines types using a mode and
qualifiers, and use objects of this struct in the declaration of intrinsics
in the aarch64-simd-pragma-builtins.def file.

Change aarch64_pragma_builtins_data struct to support return type and
argument types.

Refactor aarch64_fntype and aarch64_expand_pragma_builtin so that it
initialises corresponding vectors in a loop. As we add intrinsics with
more arguments, these functions won't need to change to support those.

gcc/ChangeLog:

* config/aarch64/aarch64-builtins.cc
(ENTRY): Modify to add support of return and argument types.
(struct simd_type): New struct to declare types using mode and
qualifiers.
(struct aarch64_pragma_builtins_data): Replace mode with
the array of types to support return and argument types.
(aarch64_fntype): Modify to handle different signatures.
(aarch64_expand_pragma_builtin): Modify to handle different
signatures.
* config/aarch64/aarch64-simd-pragma-builtins.def
(ENTRY_VHSDF): Rename to ENTRY_BINARY_VHSDF.
(ENTRY_BINARY): New macro to declare binary intrinsics.
(ENTRY_BINARY_VHSDF): Remove signature argument and use
ENTRY_BINARY.

Co-authored-by: Vladimir Miloserdov 
Co-authored-by: Richard Sandiford 

Diff:
---
 gcc/config/aarch64/aarch64-builtins.cc | 108 -
 .../aarch64/aarch64-simd-pragma-builtins.def   |  22 +++--
 2 files changed, 98 insertions(+), 32 deletions(-)

diff --git a/gcc/config/aarch64/aarch64-builtins.cc 
b/gcc/config/aarch64/aarch64-builtins.cc
index bc1719adbaa4..8984f0c59b97 100644
--- a/gcc/config/aarch64/aarch64-builtins.cc
+++ b/gcc/config/aarch64/aarch64-builtins.cc
@@ -780,7 +780,7 @@ typedef struct
   AARCH64_SIMD_BUILTIN_##T##_##N##A,
 
 #undef ENTRY
-#define ENTRY(N, S, M, U) \
+#define ENTRY(N, S, T0, T1, T2, U) \
   AARCH64_##N,
 
 enum aarch64_builtins
@@ -1602,10 +1602,50 @@ enum class aarch64_builtin_signatures
   binary,
 };
 
+namespace {
+
+/* Pairs a machine mode with the information needed to turn it into a
+   function argument type or return type.  */
+struct simd_type {
+  tree type () const { return aarch64_simd_builtin_type (mode, qualifiers); }
+
+  machine_mode mode;
+  aarch64_type_qualifiers qualifiers;
+};
+
+namespace simd_types {
+  constexpr simd_type p8 { V8QImode, qualifier_poly };
+  constexpr simd_type p8q { V16QImode, qualifier_poly };
+  constexpr simd_type s8 { V8QImode, qualifier_none };
+  constexpr simd_type s8q { V16QImode, qualifier_none };
+  constexpr simd_type u8 { V8QImode, qualifier_unsigned };
+  constexpr simd_type u8q { V16QImode, qualifier_unsigned };
+
+  constexpr simd_type f16 { V4HFmode, qualifier_none };
+  constexpr simd_type f16q { V8HFmode, qualifier_none };
+  constexpr simd_type p16 { V4HImode, qualifier_poly };
+  constexpr simd_type p16q { V8HImode, qualifier_poly };
+  constexpr simd_type s16 { V4HImode, qualifier_none };
+  constexpr simd_type s16q { V8HImode, qualifier_none };
+  constexpr simd_type u16 { V4HImode, qualifier_unsigned };
+  constexpr simd_type u16q { V8HImode, qualifier_unsigned };
+
+  constexpr simd_type bf16 { V4BFmode, qualifier_none };
+  constexpr simd_type bf16q { V8BFmode, qualifier_none };
+
+  constexpr simd_type f32 { V2SFmode, qualifier_none };
+  constexpr simd_type f32q { V4SFmode, qualifier_none };
+  constexpr simd_type f64q { V2DFmode, qualifier_none };
+
+  constexpr simd_type none { VOIDmode, qualifier_none };
+}
+
+}
+
 #undef ENTRY
-#define ENTRY(N, S, M, U) \
-  {#N, aarch64_builtin_signatures::S, E_##M##mode, U, \
-   aarch64_required_extensions::REQUIRED_EXTENSIONS},
+#define ENTRY(N, S, T0, T1, T2, U) \
+  {#N, aarch64_builtin_signatures::S, simd_types::T0, simd_types::T1, \
+   simd_types::T2, U, aarch64_required_extensions::REQUIRED_EXTENSIONS},
 
 /* Initialize pragma builtins.  */
 
@@ -1613,7 +1653,7 @@ struct aarch64_pragma_builtins_data
 {
   const char *name;
   aarch64_builtin_signatures signature;
-  machine_mode mode;
+  simd_type types[3];
   int unspec;
   aarch64_required_extensions required_extensions;
 };
@@ -1622,19 +1662,26 @@ static aarch64_pragma_builtins_data 
aarch64_pragma_builtins[] = {
 #include "aarch64-simd-pragma-builtins.def"
 };
 
+/* Return the function type for BUILTIN_DATA.  */
 static tree
 aarch64_fntype (const aarch64_pragma_builtins_data &builtin_data)
 {
-  auto type = aarch64_simd_builtin_type (builtin_data.mode, qualifier_none);
+

[gcc r15-5881] aarch64: Split out aarch64_v64_mode

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

commit r15-5881-g5f3282f726bd4b0868ae3a5e3109081288ef7e4b
Author: Richard Sandiford 
Date:   Tue Dec 3 09:53:59 2024 +

aarch64: Split out aarch64_v64_mode

We had a function called aarch64_vq_mode, where "vq" stood for "vector
quadword".  It was used by aarch64_simd_container_mode (from which it
originated) and in preparation for various SVE ...Q instructions.

It's useful for follow-on patches if we also split out the handling
of 64-bit modes from aarch64_simd_container_mode.  Keeping to the
same naming scheme would replace "q" with "d", but that has
unfortunate connotations, and doesn't AFAIK correspond to any
actual SVE mnemonics.

This patch therefore splits the handling out into a function called
aarch64_v64_mode and renames aarch64_vq_mode to aarch64_v128_mode for
consistency.  I didn't rename the "vq" local variables, since I think
those names make sense in context.

gcc/
* config/aarch64/aarch64-protos.h (aarch64_v64_mode): Declare.
(aarch64_vq_mode): Rename to...
(aarch64_v128_mode): ...this.
* config/aarch64/aarch64.cc (aarch64_v64_mode): New function,
split out from...
(aarch64_simd_container_mode): ...here.
(aarch64_vq_mode): Rename to...
(aarch64_v128_mode): ...this and update callers.
* config/aarch64/aarch64-sve-builtins-base.cc: Likewise update 
calls.

Diff:
---
 gcc/config/aarch64/aarch64-protos.h |  3 +-
 gcc/config/aarch64/aarch64-sve-builtins-base.cc |  8 ++--
 gcc/config/aarch64/aarch64.cc   | 52 ++---
 3 files changed, 36 insertions(+), 27 deletions(-)

diff --git a/gcc/config/aarch64/aarch64-protos.h 
b/gcc/config/aarch64/aarch64-protos.h
index cad6e0b0a6f0..8644d29a0a6c 100644
--- a/gcc/config/aarch64/aarch64-protos.h
+++ b/gcc/config/aarch64/aarch64-protos.h
@@ -853,7 +853,8 @@ bool aarch64_and_bitmask_imm (unsigned HOST_WIDE_INT 
val_in, machine_mode mode);
 int aarch64_branch_cost (bool, bool);
 enum aarch64_symbol_type aarch64_classify_symbolic_expression (rtx);
 bool aarch64_advsimd_struct_mode_p (machine_mode mode);
-opt_machine_mode aarch64_vq_mode (scalar_mode);
+opt_machine_mode aarch64_v64_mode (scalar_mode);
+opt_machine_mode aarch64_v128_mode (scalar_mode);
 opt_machine_mode aarch64_full_sve_mode (scalar_mode);
 bool aarch64_can_const_movi_rtx_p (rtx x, machine_mode mode);
 bool aarch64_const_vec_all_same_int_p (rtx, HOST_WIDE_INT);
diff --git a/gcc/config/aarch64/aarch64-sve-builtins-base.cc 
b/gcc/config/aarch64/aarch64-sve-builtins-base.cc
index b97941932ab5..13e020b53455 100644
--- a/gcc/config/aarch64/aarch64-sve-builtins-base.cc
+++ b/gcc/config/aarch64/aarch64-sve-builtins-base.cc
@@ -996,7 +996,7 @@ private:
 tree lhs_type = TREE_TYPE (lhs);
 tree elt_type = TREE_TYPE (lhs_type);
 scalar_mode elt_mode = SCALAR_TYPE_MODE (elt_type);
-machine_mode vq_mode = aarch64_vq_mode (elt_mode).require ();
+machine_mode vq_mode = aarch64_v128_mode (elt_mode).require ();
 tree vq_type = build_vector_type_for_mode (elt_type, vq_mode);
 
 unsigned nargs = gimple_call_num_args (f.call);
@@ -1067,7 +1067,7 @@ public:
 
 /* Get the 128-bit Advanced SIMD vector for this data size.  */
 scalar_mode element_mode = GET_MODE_INNER (mode);
-machine_mode vq_mode = aarch64_vq_mode (element_mode).require ();
+machine_mode vq_mode = aarch64_v128_mode (element_mode).require ();
 gcc_assert (known_eq (elements_per_vq, GET_MODE_NUNITS (vq_mode)));
 
 /* Put the arguments into a 128-bit Advanced SIMD vector.  We want
@@ -1651,7 +1651,7 @@ public:
   machine_mode
   memory_vector_mode (const function_instance &fi) const override
   {
-return aarch64_vq_mode (GET_MODE_INNER (fi.vector_mode (0))).require ();
+return aarch64_v128_mode (GET_MODE_INNER (fi.vector_mode (0))).require ();
   }
 
   rtx
@@ -1685,7 +1685,7 @@ public:
tree eltype = TREE_TYPE (lhs_type);
 
scalar_mode elmode = GET_MODE_INNER (TYPE_MODE (lhs_type));
-   machine_mode vq_mode = aarch64_vq_mode (elmode).require ();
+   machine_mode vq_mode = aarch64_v128_mode (elmode).require ();
tree vectype = build_vector_type_for_mode (eltype, vq_mode);
 
tree elt_ptr_type
diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc
index cc401befde4f..43238aefef2f 100644
--- a/gcc/config/aarch64/aarch64.cc
+++ b/gcc/config/aarch64/aarch64.cc
@@ -5737,7 +5737,7 @@ aarch64_expand_sve_const_vector (rtx target, rtx src)
 targets, the layout of the 128-bit vector in an Advanced SIMD
 register would be different from its layout in an SVE register,
 but this 128-bit vector is a memory value only.  */
-  machine_mode vq_mode = aarch64_vq_mode (elt_mode).require ();
+  machine_mode vq_mode = aarch64_v128_mode (elt_

[gcc r15-5880] aarch64: Move some diagnostic functions to aarch64.cc

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

commit r15-5880-ge8fc954631a85dcb9b1de4d936a5110d72a4986b
Author: Richard Sandiford 
Date:   Tue Dec 3 09:53:59 2024 +

aarch64: Move some diagnostic functions to aarch64.cc

Some of the diagnostics reported for SVE builtins would also be
useful for Advanced SIMD builtins, so this patch moves them from
aarch64-sve-builtins.cc to aarch64.cc.  I put them in a new aarch64
namespace for now -- perhaps in future they should be generic.

gcc/
* config/aarch64/aarch64-sve-builtins.cc (report_non_ice)
(report_out_of_range, report_neither_nor, report_not_one_of)
(report_not_enum): Move to...
* config/aarch64/aarch64.cc: ...here, putting them in the aarch64
namespace, and...
* config/aarch64/aarch64-protos.h: ...declare them here.

Diff:
---
 gcc/config/aarch64/aarch64-protos.h| 12 ++
 gcc/config/aarch64/aarch64-sve-builtins.cc | 65 +-
 gcc/config/aarch64/aarch64.cc  | 64 +
 3 files changed, 78 insertions(+), 63 deletions(-)

diff --git a/gcc/config/aarch64/aarch64-protos.h 
b/gcc/config/aarch64/aarch64-protos.h
index c6ce62190bce..cad6e0b0a6f0 100644
--- a/gcc/config/aarch64/aarch64-protos.h
+++ b/gcc/config/aarch64/aarch64-protos.h
@@ -1119,6 +1119,18 @@ bool aarch64_general_check_builtin_call (location_t, 
vec,
 unsigned int, tree, unsigned int,
 tree *);
 
+namespace aarch64 {
+  void report_non_ice (location_t, tree, unsigned int);
+  void report_out_of_range (location_t, tree, unsigned int, HOST_WIDE_INT,
+   HOST_WIDE_INT, HOST_WIDE_INT);
+  void report_neither_nor (location_t, tree, unsigned int, HOST_WIDE_INT,
+  HOST_WIDE_INT, HOST_WIDE_INT);
+  void report_not_one_of (location_t, tree, unsigned int, HOST_WIDE_INT,
+ HOST_WIDE_INT, HOST_WIDE_INT, HOST_WIDE_INT,
+ HOST_WIDE_INT);
+  void report_not_enum (location_t, tree, unsigned int, HOST_WIDE_INT, tree);
+}
+
 namespace aarch64_sve {
   void init_builtins ();
   void handle_arm_sve_h (bool);
diff --git a/gcc/config/aarch64/aarch64-sve-builtins.cc 
b/gcc/config/aarch64/aarch64-sve-builtins.cc
index 79dc81fcbb73..8e94a2d2cfe4 100644
--- a/gcc/config/aarch64/aarch64-sve-builtins.cc
+++ b/gcc/config/aarch64/aarch64-sve-builtins.cc
@@ -55,6 +55,8 @@
 #include "aarch64-sve-builtins-shapes.h"
 #include "aarch64-builtins.h"
 
+using namespace aarch64;
+
 namespace aarch64_sve {
 
 /* Static information about each single-predicate or single-vector
@@ -1150,69 +1152,6 @@ lookup_fndecl (tree fndecl)
 }
 
 
-/* Report that LOCATION has a call to FNDECL in which argument ARGNO
-   was not an integer constant expression.  ARGNO counts from zero.  */
-static void
-report_non_ice (location_t location, tree fndecl, unsigned int argno)
-{
-  error_at (location, "argument %d of %qE must be an integer constant"
-   " expression", argno + 1, fndecl);
-}
-
-/* Report that LOCATION has a call to FNDECL in which argument ARGNO has
-   the value ACTUAL, whereas the function requires a value in the range
-   [MIN, MAX].  ARGNO counts from zero.  */
-static void
-report_out_of_range (location_t location, tree fndecl, unsigned int argno,
-HOST_WIDE_INT actual, HOST_WIDE_INT min,
-HOST_WIDE_INT max)
-{
-  if (min == max)
-error_at (location, "passing %wd to argument %d of %qE, which expects"
- " the value %wd", actual, argno + 1, fndecl, min);
-  else
-error_at (location, "passing %wd to argument %d of %qE, which expects"
- " a value in the range [%wd, %wd]", actual, argno + 1, fndecl,
- min, max);
-}
-
-/* Report that LOCATION has a call to FNDECL in which argument ARGNO has
-   the value ACTUAL, whereas the function requires either VALUE0 or
-   VALUE1.  ARGNO counts from zero.  */
-static void
-report_neither_nor (location_t location, tree fndecl, unsigned int argno,
-   HOST_WIDE_INT actual, HOST_WIDE_INT value0,
-   HOST_WIDE_INT value1)
-{
-  error_at (location, "passing %wd to argument %d of %qE, which expects"
-   " either %wd or %wd", actual, argno + 1, fndecl, value0, value1);
-}
-
-/* Report that LOCATION has a call to FNDECL in which argument ARGNO has
-   the value ACTUAL, whereas the function requires one of VALUE0..3.
-   ARGNO counts from zero.  */
-static void
-report_not_one_of (location_t location, tree fndecl, unsigned int argno,
-  HOST_WIDE_INT actual, HOST_WIDE_INT value0,
-  HOST_WIDE_INT value1, HOST_WIDE_INT value2,
-  HOST_WIDE_INT value3)
-{
-  error_at (location, "passing %wd to argument %d of %qE, which expects"
-   " %wd, %wd, %wd or %wd", actual, 

[gcc r15-5886] OpenMP: 'allocate' directive - fixes for 'alignof' and [[omp::decl]]

2024-12-03 Thread Tobias Burnus via Gcc-cvs
https://gcc.gnu.org/g:3d72e50caebf232fdd7f70613616ca4fd4fb472b

commit r15-5886-g3d72e50caebf232fdd7f70613616ca4fd4fb472b
Author: Tobias Burnus 
Date:   Tue Dec 3 11:02:03 2024 +0100

OpenMP: 'allocate' directive - fixes for 'alignof' and [[omp::decl]]

Fixed a check to permit [[omp::decl(allocate,...)]] parsing in C.

Additionaly, we discussed that 'allocate align' should not affect
'alignof' to avoid issues like with:

  int a;
  _Alignas(_Alignof(a)) int b;
  #pragma omp allocate(a) align(128)
  _Alignas(_Alignof(a)) int c;

Thus, the alignment is no longer set in the C and Fortran front ends,
but for static variables now in varpool_node::finalize_decl.
(For stack variables, the alignment is handled in gimplify_bind_expr.)

NOTE: 'omp allocate' is not yet supported in C++.

gcc/c/ChangeLog:

* c-parser.cc (c_parser_omp_allocate): Only check scope if
not in_omp_decl_attribute. Remove setting the alignment.

gcc/ChangeLog:

* cgraphunit.cc (varpool_node::finalize_decl): Set alignment
based on OpenMP's 'omp allocate' attribute/directive.

gcc/fortran/ChangeLog:

* trans-decl.cc (gfc_finish_var_decl): Remove setting the alignment.

libgomp/ChangeLog:

* libgomp.texi (Memory allocation): Mention (non-)effect of 'align'
on _Alignof.
* testsuite/libgomp.c/allocate-7.c: New test.

gcc/testsuite/ChangeLog:

* c-c++-common/gomp/allocate-18.c: Check that alignof is unaffected
by 'omp allocate'.
* c-c++-common/gomp/allocate-19.c: Likewise.

Diff:
---
 gcc/c/c-parser.cc |  5 +--
 gcc/cgraphunit.cc | 12 ++
 gcc/fortran/trans-decl.cc |  3 --
 gcc/testsuite/c-c++-common/gomp/allocate-18.c |  6 +--
 gcc/testsuite/c-c++-common/gomp/allocate-19.c | 10 ++---
 libgomp/libgomp.texi  |  6 +++
 libgomp/testsuite/libgomp.c/allocate-7.c  | 54 +++
 7 files changed, 81 insertions(+), 15 deletions(-)

diff --git a/gcc/c/c-parser.cc b/gcc/c/c-parser.cc
index 0acba0542df6..a7719acf0bf2 100644
--- a/gcc/c/c-parser.cc
+++ b/gcc/c/c-parser.cc
@@ -22158,7 +22158,7 @@ c_parser_omp_allocate (c_parser *parser)
"% directive", var);
  continue;
}
-  if (!c_check_in_current_scope (var))
+  if (!parser->in_omp_decl_attribute && !c_check_in_current_scope (var))
{
  error_at (OMP_CLAUSE_LOCATION (nl),
"% directive must be in the same scope as %qD",
@@ -22199,9 +22199,6 @@ c_parser_omp_allocate (c_parser *parser)
= {EXPR_LOC_OR_LOC (allocator, OMP_CLAUSE_LOCATION (nl)), var};
  walk_tree (&allocator, c_check_omp_allocate_allocator_r, &data, NULL);
}
-  if (alignment)
-   SET_DECL_ALIGN (var, BITS_PER_UNIT * MAX (tree_to_uhwi (alignment),
- DECL_ALIGN_UNIT (var)));
   DECL_ATTRIBUTES (var) = tree_cons (get_identifier ("omp allocate"),
 build_tree_list (allocator, alignment),
 DECL_ATTRIBUTES (var));
diff --git a/gcc/cgraphunit.cc b/gcc/cgraphunit.cc
index d60ebc1c9884..e954e889960b 100644
--- a/gcc/cgraphunit.cc
+++ b/gcc/cgraphunit.cc
@@ -983,6 +983,18 @@ varpool_node::finalize_decl (tree decl)
  && !DECL_ARTIFICIAL (node->decl)))
 node->force_output = true;
 
+  if (flag_openmp)
+{
+  tree attr = lookup_attribute ("omp allocate", DECL_ATTRIBUTES (decl));
+  if (attr)
+   {
+ tree align = TREE_VALUE (TREE_VALUE (attr));
+ if (align)
+   SET_DECL_ALIGN (decl, MAX (tree_to_uhwi (align) * BITS_PER_UNIT,
+  DECL_ALIGN (decl)));
+   }
+}
+
   if (symtab->state == CONSTRUCTION
   && (node->needed_p () || node->referred_to_p ()))
 enqueue_node (node);
diff --git a/gcc/fortran/trans-decl.cc b/gcc/fortran/trans-decl.cc
index a62fe3f0441c..d69c8430484a 100644
--- a/gcc/fortran/trans-decl.cc
+++ b/gcc/fortran/trans-decl.cc
@@ -830,9 +830,6 @@ gfc_finish_var_decl (tree decl, gfc_symbol * sym)
   tree alloc = gfc_conv_constant_to_tree (n->u2.allocator);
   tree align = (n->u.align ? gfc_conv_constant_to_tree (n->u.align)
   : NULL_TREE);
-  if (align != NULL_TREE)
-   SET_DECL_ALIGN (decl, MAX (tree_to_uhwi (align),
-   DECL_ALIGN_UNIT (decl)) * BITS_PER_UNIT);
   DECL_ATTRIBUTES (decl)
= tree_cons (get_identifier ("omp allocate"),
 build_tree_list (alloc, align), DECL_ATTRIBUTES (decl));
diff --git a/gcc/testsuite/c-c++-common/gomp/allocate-18.c 
b/gcc/testsuite/c-c++-common/gomp/allocate-18.c
index 4182f7ee37ec..93c5aca29a7c 100644
--

[gcc r15-5878] RISC-V: Fix incorrect optimization options passing to reduc and ternop

2024-12-03 Thread Pan Li via Gcc-cvs
https://gcc.gnu.org/g:5cbeecf07df4f50ee02345419bafffc5f0e3d604

commit r15-5878-g5cbeecf07df4f50ee02345419bafffc5f0e3d604
Author: Pan Li 
Date:   Tue Dec 3 14:08:07 2024 +0800

RISC-V: Fix incorrect optimization options passing to reduc and ternop

Like the strided load/store, the testcases of vector reduce and ternop
are designed to pick up different sorts of optimization options but
actually these option are ignored according to the Execution log of
the gcc.log.

This patch would like to make it correct almost the same as what we
fixed for strided load/store.

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/rvv.exp: Fix the incorrect optimization
options passing to testcases.

Signed-off-by: Pan Li 

Diff:
---
 gcc/testsuite/gcc.target/riscv/rvv/rvv.exp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gcc/testsuite/gcc.target/riscv/rvv/rvv.exp 
b/gcc/testsuite/gcc.target/riscv/rvv/rvv.exp
index 87dea4576081..65a57aa79138 100644
--- a/gcc/testsuite/gcc.target/riscv/rvv/rvv.exp
+++ b/gcc/testsuite/gcc.target/riscv/rvv/rvv.exp
@@ -71,9 +71,9 @@ foreach op $AUTOVEC_TEST_OPTS {
   dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/autovec/unop/*.\[cS\]]] \
 "" "$op"
   dg-runtest [lsort [glob -nocomplain 
$srcdir/$subdir/autovec/ternop/*.\[cS\]]] \
-"" "$op"
+"$op" ""
   dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/autovec/reduc/*.\[cS\]]] 
\
-"" "$op"
+"$op" ""
   dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/autovec/cond/*.\[cS\]]] \
 "$op" ""
   dg-runtest [lsort [glob -nocomplain 
$srcdir/$subdir/autovec/builtin/*.\[cS\]]] \


[gcc r15-5887] bitintlower: Fix up ?ROTATE_EXPR lowering [PR117847]

2024-12-03 Thread Jakub Jelinek via Gcc-cvs
https://gcc.gnu.org/g:0b89341f124eadc689682d01193309225adfec23

commit r15-5887-g0b89341f124eadc689682d01193309225adfec23
Author: Jakub Jelinek 
Date:   Tue Dec 3 11:16:37 2024 +0100

bitintlower: Fix up ?ROTATE_EXPR lowering [PR117847]

In the ?ROTATE_EXPR lowering I forgot to handle rotation by 0 correctly.
INTEGER_CST 0 is very unlikely, it would be probably folded away, but
a non-constant count can't use just p - n because then the shift count
is out of bounds for zero.

In the FE I use n == 0 ? x : (x << n) | (x >> (p - n)) but bitintlower
here isn't prepared at this point to have bb split and am not sure if
using COND_EXPR is a good idea either, so the patch uses (p - n) % p.
Perhaps I should just disable lowering the rotate in the FE for the
non-mode precision BITINT_TYPEs too.

2024-12-03  Jakub Jelinek  

PR middle-end/117847
* gimple-lower-bitint.cc (gimple_lower_bitint) :
Use m = (p - n) % p instead of m = p - n for the other shift count.

* gcc.dg/torture/bitint-75.c: New test.

Diff:
---
 gcc/gimple-lower-bitint.cc   | 13 +++--
 gcc/testsuite/gcc.dg/torture/bitint-75.c | 27 +++
 2 files changed, 38 insertions(+), 2 deletions(-)

diff --git a/gcc/gimple-lower-bitint.cc b/gcc/gimple-lower-bitint.cc
index 1b7c2f46230c..7fa679b731ba 100644
--- a/gcc/gimple-lower-bitint.cc
+++ b/gcc/gimple-lower-bitint.cc
@@ -6233,11 +6233,20 @@ gimple_lower_bitint (void)
  tree p = build_int_cst (TREE_TYPE (n),
  TYPE_PRECISION (type));
  if (TREE_CODE (n) == INTEGER_CST)
-   m = fold_build2 (MINUS_EXPR, TREE_TYPE (n), p, n);
+   {
+ if (integer_zerop (n))
+   m = n;
+ else
+   m = fold_build2 (MINUS_EXPR, TREE_TYPE (n), p, n);
+   }
  else
{
+ tree tem = make_ssa_name (TREE_TYPE (n));
+ g = gimple_build_assign (tem, MINUS_EXPR, p, n);
+ gsi_insert_before (&gsi, g, GSI_SAME_STMT);
+ gimple_set_location (g, loc);
  m = make_ssa_name (TREE_TYPE (n));
- g = gimple_build_assign (m, MINUS_EXPR, p, n);
+ g = gimple_build_assign (m, TRUNC_MOD_EXPR, tem, p);
  gsi_insert_before (&gsi, g, GSI_SAME_STMT);
  gimple_set_location (g, loc);
}
diff --git a/gcc/testsuite/gcc.dg/torture/bitint-75.c 
b/gcc/testsuite/gcc.dg/torture/bitint-75.c
new file mode 100644
index ..365e6d623c15
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/bitint-75.c
@@ -0,0 +1,27 @@
+/* PR middle-end/117847 */
+/* { dg-do run { target bitint } } */
+/* { dg-options "-std=c23" } */
+/* { dg-skip-if "" { ! run_expensive_tests }  { "*" } { "-O0" "-O2" } } */
+/* { dg-skip-if "" { ! run_expensive_tests } { "-flto" } { "" } } */
+
+#if __BITINT_MAXWIDTH__ >= 512
+typedef unsigned _BitInt(512) B;
+
+__attribute__((noipa)) B
+foo (B a, int r)
+{
+  B b = __builtin_stdc_rotate_left (a, r);
+  return b;
+}
+#endif
+
+int
+main ()
+{
+#if __BITINT_MAXWIDTH__ >= 512
+  B a = 
0x4ad4fdecc8717d7c6f8b1afb82fdb742477ef2ab34057d1dcc79ba30c38a352dea3253c8c25126d98da02213ad54b90d2998f947941ea4b45e71c61dc1fe3192uwb;
+  B x = foo (a, 0);
+  if (x != a)
+__builtin_abort ();
+#endif
+}


[gcc r15-5888] tree-ssanames, match.pd: get_nonzero_bits/with_*_nonzero_bits* cleanups and improvements [PR117420]

2024-12-03 Thread Jakub Jelinek via Gcc-cvs
https://gcc.gnu.org/g:17c9c7c10a70d18dea5849d11a4fa382d3817fa1

commit r15-5888-g17c9c7c10a70d18dea5849d11a4fa382d3817fa1
Author: Jakub Jelinek 
Date:   Tue Dec 3 11:17:49 2024 +0100

tree-ssanames, match.pd: get_nonzero_bits/with_*_nonzero_bits* cleanups and 
improvements [PR117420]

The following patch implements the with_*_nonzero_bits* cleanups and
improvements I was talking about.

get_nonzero_bits is extended to also handle BIT_AND_EXPR (as a tree or
as SSA_NAME with BIT_AND_EXPR def_stmt), new function is added for the
bits known to be set (get_known_nonzero_bits) and the match.pd predicates
are renamed and adjusted, so that there is no confusion on which one to
use (one is named and documented to be internal), changed so that it can be
used only as a simple predicate, not match some operands, and that it 
doesn't
try to match twice for the GIMPLE case (where SSA_NAME with integral or 
pointer
type matches, but SSA_NAME with BIT_AND_EXPR def_stmt matched differently).
Furthermore, get_nonzero_bits just returns the all bits set (or
get_known_nonzero_bits no bits set) fallback if the argument isn't a
SSA_NAME (nor INTEGER_CST or whatever the functions handle explicitly).

2024-12-03  Jakub Jelinek  

PR tree-optimization/117420
* tree-ssanames.h (get_known_nonzero_bits): Declare.
* tree-ssanames.cc (get_nonzero_bits): New wrapper function.  Move 
old
definition to ...
(get_nonzero_bits_1): ... here, add static.  Change widest_int in
function comment to wide_int.
(get_known_nonzero_bits_1, get_known_nonzero_bits): New functions.
* match.pd (with_possible_nonzero_bits2): Rename to ...
(with_possible_nonzero_bits): ... this.  Guard the bit_and case with
#if GENERIC.  Change to a normal match predicate without parameters.
Rename the old with_possible_nonzero_bits match to ...
(with_possible_nonzero_bits_1): ... this.
(with_certain_nonzero_bits2): Remove.
(with_known_nonzero_bits_1, with_known_nonzero_bits): New match
predicates.
(X == C (or X & Z == Y | C) is impossible if ~nonzero(X) & C != 0):
Use with_known_nonzero_bits@0 instead of
(with_certain_nonzero_bits2 @1), use with_possible_nonzero_bits@0
instead of (with_possible_nonzero_bits2 @0) and
get_known_nonzero_bits (@1) instead of wi::to_wide (@1).

* gcc.dg/tree-ssa/pr117420.c: New test.

Diff:
---
 gcc/match.pd | 45 +++--
 gcc/testsuite/gcc.dg/tree-ssa/pr117420.c | 16 ++
 gcc/tree-ssanames.cc | 84 ++--
 gcc/tree-ssanames.h  |  1 +
 4 files changed, 127 insertions(+), 19 deletions(-)

diff --git a/gcc/match.pd b/gcc/match.pd
index 94202322602c..fd1d8bcc7763 100644
--- a/gcc/match.pd
+++ b/gcc/match.pd
@@ -2869,32 +2869,45 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
  { constant_boolean_node (cmp == LT_EXPR, type); })
 
 /* Arguments on which one can call get_nonzero_bits to get the bits
-   possibly set.  */
-(match with_possible_nonzero_bits
+   possibly set.  with_possible_nonzero_bits_1 is an internal version,
+   use with_possible_nonzero_bits.  */
+(match with_possible_nonzero_bits_1
  INTEGER_CST@0)
-(match with_possible_nonzero_bits
+(match with_possible_nonzero_bits_1
  POLY_INT_CST@0)
-(match with_possible_nonzero_bits
+(match with_possible_nonzero_bits_1
  SSA_NAME@0
  (if (INTEGRAL_TYPE_P (TREE_TYPE (@0)) || POINTER_TYPE_P (TREE_TYPE (@0)
 /* Slightly extended version, do not make it recursive to keep it cheap.  */
-(match (with_possible_nonzero_bits2 @0)
- with_possible_nonzero_bits@0)
-(match (with_possible_nonzero_bits2 @0)
- (bit_and:c with_possible_nonzero_bits@0 @2))
-
-/* Same for bits that are known to be set, but we do not have
-   an equivalent to get_nonzero_bits yet.  */
-(match (with_certain_nonzero_bits2 @0)
+(match with_possible_nonzero_bits
+ with_possible_nonzero_bits_1@0)
+#if GENERIC
+(match with_possible_nonzero_bits
+ (bit_and:c with_possible_nonzero_bits_1@0 @1))
+#endif
+
+/* Arguments on which one can call get_known_nonzero_bits to get the
+   bits known to be set.  with_known_nonzero_bits_1 is an internal version,
+   use with_known_nonzero_bits.  */
+(match with_known_nonzero_bits_1
  INTEGER_CST@0)
-(match (with_certain_nonzero_bits2 @0)
- (bit_ior @1 INTEGER_CST@0))
+(match with_known_nonzero_bits_1
+ SSA_NAME@0
+ (if (INTEGRAL_TYPE_P (TREE_TYPE (@0)
+/* Slightly extended version, do not make it recursive to keep it cheap.  */
+(match with_known_nonzero_bits
+ with_known_nonzero_bits_1@0)
+#if GENERIC
+(match with_known_nonzero_bits
+ (bit_ior:c with_known_nonzero_bits_1@0 @1))
+#endif
 
 /* X == C (or X & Z == Y | C) is impossible if ~nonzero(X) & C != 0.  */
 (f

[gcc r15-5889] libstdc++: Fix constraints on std::optional converting constructors [PR117889]

2024-12-03 Thread Jonathan Wakely via Gcc-cvs
https://gcc.gnu.org/g:29bea6921d0e2e3dd20bc78926ef0e98b1b1e4ad

commit r15-5889-g29bea6921d0e2e3dd20bc78926ef0e98b1b1e4ad
Author: Jonathan Wakely 
Date:   Sat Nov 30 21:37:02 2024 +

libstdc++: Fix constraints on std::optional converting constructors 
[PR117889]

The converting constructors had the same bug as the converting
assignments, so need the same fix as r15-5833-gc2c7d71eeeab7c.

libstdc++-v3/ChangeLog:

PR libstdc++/117889
PR libstdc++/117858
* include/std/optional (optional(const optional&)): Fix copy
and paste error in constraints.
(optional(optional&&)): Likewise.
* testsuite/20_util/optional/assignment/117858.cc: Move to ...
* testsuite/20_util/optional/cons/117858.cc: New test.

Diff:
---
 libstdc++-v3/include/std/optional  |  4 ++--
 .../20_util/optional/assignment/117858.cc  | 17 
 .../testsuite/20_util/optional/cons/117858.cc  | 23 ++
 3 files changed, 25 insertions(+), 19 deletions(-)

diff --git a/libstdc++-v3/include/std/optional 
b/libstdc++-v3/include/std/optional
index 55e56cfb9ed1..617e4418ad7e 100644
--- a/libstdc++-v3/include/std/optional
+++ b/libstdc++-v3/include/std/optional
@@ -876,7 +876,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
: _Base(std::in_place, std::forward<_Up>(__t)) { }
 
   template
-   requires (!is_same_v>)
+   requires (!is_same_v<_Tp, _Up>)
  && is_constructible_v<_Tp, const _Up&>
  && __construct_from_contained_value<_Up>
constexpr explicit(!is_convertible_v)
@@ -888,7 +888,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
}
 
   template
-   requires (!is_same_v>)
+   requires (!is_same_v<_Tp, _Up>)
  && is_constructible_v<_Tp, _Up>
  && __construct_from_contained_value<_Up>
constexpr explicit(!is_convertible_v<_Up, _Tp>)
diff --git a/libstdc++-v3/testsuite/20_util/optional/assignment/117858.cc 
b/libstdc++-v3/testsuite/20_util/optional/assignment/117858.cc
deleted file mode 100644
index e7045b37dd9c..
--- a/libstdc++-v3/testsuite/20_util/optional/assignment/117858.cc
+++ /dev/null
@@ -1,17 +0,0 @@
-// { dg-do compile { target c++17 } }
-
-// PR 117858 std::optional with a constructor template ctor(T)
-
-#include 
-
-struct Focus
-{
-  template
-  Focus(T newValue)  { }
-};
-
-void g(std::optional f)
-{
-  f = f;
-  f = std::move(f);
-}
diff --git a/libstdc++-v3/testsuite/20_util/optional/cons/117858.cc 
b/libstdc++-v3/testsuite/20_util/optional/cons/117858.cc
new file mode 100644
index ..adb1bc7791cd
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/optional/cons/117858.cc
@@ -0,0 +1,23 @@
+// { dg-do compile { target c++17 } }
+
+// PR 117858 std::optional with a constructor template ctor(T)
+// PR 117889 Failure to build qtwebengine-6.8.1
+
+#include 
+
+struct Focus
+{
+  template Focus(T) { }
+};
+
+void test_pr117858(std::optional& f)
+{
+  f = f;
+  f = std::move(f);
+}
+
+void test_pr117889(std::optional& f)
+{
+  std::optional f2 = f;
+  std::optional f3 = std::move(f);
+}


[gcc r15-5892] AVR: Tweak uin8_t << 6 and uint8_t >> 6 shifts.

2024-12-03 Thread Georg-Johann Lay via Gcc-cvs
https://gcc.gnu.org/g:d203f4cb968a1dc45c7fcd1bf5d7cd485ca6f510

commit r15-5892-gd203f4cb968a1dc45c7fcd1bf5d7cd485ca6f510
Author: Georg-Johann Lay 
Date:   Mon Dec 2 12:31:18 2024 +0100

AVR: Tweak uin8_t << 6 and uint8_t >> 6 shifts.

Logic 8-bit shifts with an offset of 6 can be improved by
supporting them as 3-operand operations.

PR target/117726
gcc/
* config/avr/avr-passes.cc (avr_emit_shift): All 8-bit shifts with
an offset of 6 have 3-operand alternatives.
* config/avr/avr.cc (ashlqi3_out, lshrqi3_out) [case 6]:
Implement as 3-operand insn.
(avr_rtx_costs_1) [QImode, ASHIFT + LSHIFTRT]: Adjust
costs for offset of 6.
* config/avr/avr.md (*ashlqi3_split, *ashlqi3)
(*lshrqi3_split, *lshrqi3): Add "r,r,C06" alternative.

Diff:
---
 gcc/config/avr/avr-passes.cc |  3 ++
 gcc/config/avr/avr.cc| 70 
 gcc/config/avr/avr.md| 26 
 3 files changed, 73 insertions(+), 26 deletions(-)

diff --git a/gcc/config/avr/avr-passes.cc b/gcc/config/avr/avr-passes.cc
index 7be5ec25fbce..dc98780ef277 100644
--- a/gcc/config/avr/avr-passes.cc
+++ b/gcc/config/avr/avr-passes.cc
@@ -4899,6 +4899,8 @@ avr_emit_shift (rtx_code code, rtx dest, rtx src, int 
off, rtx scratch)
   // Work out which alternatives can handle 3 operands independent
   // of options.
 
+  const bool b8_is_3op = off == 6;
+
   const bool b16_is_3op = select()
 : code == ASHIFT ? satisfies_constraint_C7c (xoff) // 7...12
 : code == LSHIFTRT ? satisfies_constraint_C7c (xoff)
@@ -4914,6 +4916,7 @@ avr_emit_shift (rtx_code code, rtx dest, rtx src, int 
off, rtx scratch)
   const bool is_3op = (off % 8 == 0
   || off == n_bits - 1
   || (code == ASHIFTRT && off == n_bits - 2)
+  || (n_bits == 8 && b8_is_3op)
   || (n_bits == 16 && b16_is_3op)
   || (n_bits == 24 && b24_is_3op));
   rtx shift;
diff --git a/gcc/config/avr/avr.cc b/gcc/config/avr/avr.cc
index 32028df30a53..ccf9b05bb3e5 100644
--- a/gcc/config/avr/avr.cc
+++ b/gcc/config/avr/avr.cc
@@ -6780,6 +6780,8 @@ ashlqi3_out (rtx_insn *insn, rtx operands[], int *plen)
 {
   if (CONST_INT_P (operands[2]))
 {
+  int reg0 = REGNO (operands[0]);
+  int reg1 = REGNO (operands[1]);
   bool ldreg_p = test_hard_reg_class (LD_REGS, operands[0]);
   int offs = INTVAL (operands[2]);
 
@@ -6787,7 +6789,7 @@ ashlqi3_out (rtx_insn *insn, rtx operands[], int *plen)
*plen = 0;
 
   if (offs <= 3
- || (offs <= 6 && ! ldreg_p))
+ || (offs <= 5 && ! ldreg_p))
{
  for (int i = 0; i < offs; ++i)
avr_asm_len ("lsl %0", operands, plen, 1);
@@ -6814,10 +6816,28 @@ ashlqi3_out (rtx_insn *insn, rtx operands[], int *plen)
  "lsl %0"  CR_TAB
  "andi %0,0xe0", operands, plen, 3);
case 6:
- return avr_asm_len ("swap %0" CR_TAB
- "lsl %0"  CR_TAB
- "lsl %0"  CR_TAB
- "andi %0,0xc0", operands, plen, 4);
+ if (ldreg_p && reg0 == reg1)
+   return avr_asm_len ("swap %0" CR_TAB
+   "lsl %0"  CR_TAB
+   "lsl %0"  CR_TAB
+   "andi %0,0xc0", operands, plen, 4);
+ if (ldreg_p && reg0 != reg1 && AVR_HAVE_MUL)
+   return avr_asm_len ("ldi %0,1<<6" CR_TAB
+   "mul %0,%1"   CR_TAB
+   "mov %0,r0"   CR_TAB
+   "clr __zero_reg__", operands, plen, 4);
+ return reg0 != reg1
+   ? avr_asm_len ("clr %0"CR_TAB
+  "bst %1,0"  CR_TAB
+  "bld %0,6"  CR_TAB
+  "bst %1,1"  CR_TAB
+  "bld %0,7", operands, plen, 5)
+   : avr_asm_len ("lsl %0"  CR_TAB
+  "lsl %0"  CR_TAB
+  "lsl %0"  CR_TAB
+  "lsl %0"  CR_TAB
+  "lsl %0"  CR_TAB
+  "lsl %0", operands, plen, 6);
case 7:
  return avr_asm_len ("bst %1,0" CR_TAB
  "clr %0"   CR_TAB
@@ -7663,6 +7683,8 @@ lshrqi3_out (rtx_insn *insn, rtx operands[], int *plen)
 {
   if (CONST_INT_P (operands[2]))
 {
+  int reg0 = REGNO (operands[0]);
+  int reg1 = REGNO (operands[1]);
   bool ldreg_p = test_hard_reg_class (LD_REGS, operands[0]);
   int offs = INTVAL (operands[2]);
 
@@ -7670,7 +7692,7 @@ lshrqi3_out (rtx_insn *insn, rtx operands[], int *plen)
*plen = 0;
 
   if (offs <= 3
- || (offs <= 6 && ! ldreg_p))
+ || (offs <= 5 && ! ldreg_p))
{
  for 

[gcc r15-5894] tree-optimization/117874 - optimize SLP discovery budget use

2024-12-03 Thread Richard Biener via Gcc-cvs
https://gcc.gnu.org/g:af9a3fe6a52974252516b3eea4c5ab5caae47b4b

commit r15-5894-gaf9a3fe6a52974252516b3eea4c5ab5caae47b4b
Author: Richard Biener 
Date:   Tue Dec 3 08:56:35 2024 +0100

tree-optimization/117874 - optimize SLP discovery budget use

The following tries to avoid eating into the SLP discovery limit
when we can do cheaper checks first.  Together with the previous
patch this allows to use two-lane SLP discovery for mult_su3_an
in 433.milc.

PR tree-optimization/117874
* tree-vect-slp.cc (vect_build_slp_tree_2): Perform early
reassoc checks before eating into discovery limit.

Diff:
---
 gcc/tree-vect-slp.cc | 39 +--
 1 file changed, 29 insertions(+), 10 deletions(-)

diff --git a/gcc/tree-vect-slp.cc b/gcc/tree-vect-slp.cc
index 1799d5a619b1..425135a9ee0a 100644
--- a/gcc/tree-vect-slp.cc
+++ b/gcc/tree-vect-slp.cc
@@ -2292,6 +2292,9 @@ vect_build_slp_tree_2 (vec_info *vinfo, slp_tree node,
}
}
  /* 2. try to build children nodes, associating as necessary.  */
+ /* 2a. prepare and perform early checks to avoid eating into
+discovery limit unnecessarily.  */
+ vect_def_type *dts = XALLOCAVEC (vect_def_type, chain_len);
  for (unsigned n = 0; n < chain_len; ++n)
{
  vect_def_type dt = chains[0][n].dt;
@@ -2319,6 +2322,7 @@ vect_build_slp_tree_2 (vec_info *vinfo, slp_tree node,
matches[0] = false;
  goto out;
}
+ dts[n] = dt;
  if (dt == vect_constant_def
  || dt == vect_external_def)
{
@@ -2333,16 +2337,6 @@ vect_build_slp_tree_2 (vec_info *vinfo, slp_tree node,
  matches[0] = false;
  goto out;
}
- vec ops;
- ops.create (group_size);
- for (lane = 0; lane < group_size; ++lane)
-   if (stmts[lane])
- ops.quick_push (chains[lane][n].op);
-   else
- ops.quick_push (NULL_TREE);
- slp_tree child = vect_create_new_slp_node (ops);
- SLP_TREE_DEF_TYPE (child) = dt;
- children.safe_push (child);
}
  else if (dt != vect_internal_def)
{
@@ -2354,6 +2348,26 @@ vect_build_slp_tree_2 (vec_info *vinfo, slp_tree node,
  hard_fail = false;
  goto out;
}
+   }
+ /* 2b. do the actual build.  */
+ for (unsigned n = 0; n < chain_len; ++n)
+   {
+ vect_def_type dt = dts[n];
+ unsigned lane;
+ if (dt == vect_constant_def
+ || dt == vect_external_def)
+   {
+ vec ops;
+ ops.create (group_size);
+ for (lane = 0; lane < group_size; ++lane)
+   if (stmts[lane])
+ ops.quick_push (chains[lane][n].op);
+   else
+ ops.quick_push (NULL_TREE);
+ slp_tree child = vect_create_new_slp_node (ops);
+ SLP_TREE_DEF_TYPE (child) = dt;
+ children.safe_push (child);
+   }
  else
{
  vec op_stmts;
@@ -2396,6 +2410,11 @@ vect_build_slp_tree_2 (vec_info *vinfo, slp_tree node,
term = true;
break;
  }
+   if (dump_enabled_p ())
+ dump_printf_loc (MSG_NOTE, vect_location,
+  "swapping operand %d and %d "
+  "of lane %d\n",
+  n, n + perms[lane] + 1, lane);
std::swap (chains[lane][n],
   chains[lane][n + perms[lane] + 1]);
perms[lane]++;


[gcc r15-5893] Use the number of relevant stmts to limit SLP build

2024-12-03 Thread Richard Biener via Gcc-cvs
https://gcc.gnu.org/g:d4f3c3efc669afe6e270344ff73c7471fea67ce7

commit r15-5893-gd4f3c3efc669afe6e270344ff73c7471fea67ce7
Author: Richard Biener 
Date:   Tue Dec 3 08:52:48 2024 +0100

Use the number of relevant stmts to limit SLP build

The following removes scalar stmt counting from loop vectorization
and using that as base to limit both the SLP tree final size and
discovery.  Instead use the number of relevant stmts for that
which is conveniently the number of stmt_vec_infos we create which
in turn includes things like pattern stmts.

PR tree-optimization/117874
* tree-vectorizer.h (vec_info_shared::n_stmts): Remove.
(LOOP_VINFO_N_STMTS): Likewise.
* tree-vectorizer.cc (vec_info_shared::vec_info_shared): Adjust.
* tree-vect-loop.cc (vect_get_datarefs_in_loop): Do not
count stmts.
(vect_analyze_loop_2): Adjust.  Pass stmt_vec_info.length ()
to vect_analyze_slp as SLP tree size limit.

Diff:
---
 gcc/tree-vect-loop.cc  | 10 +++---
 gcc/tree-vectorizer.cc |  3 +--
 gcc/tree-vectorizer.h  |  4 
 3 files changed, 4 insertions(+), 13 deletions(-)

diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc
index 85209604486a..4f401cd2d0c4 100644
--- a/gcc/tree-vect-loop.cc
+++ b/gcc/tree-vect-loop.cc
@@ -2499,10 +2499,8 @@ vect_analyze_loop_costing (loop_vec_info loop_vinfo,
 
 static opt_result
 vect_get_datarefs_in_loop (loop_p loop, basic_block *bbs,
-  vec *datarefs,
-  unsigned int *n_stmts)
+  vec *datarefs)
 {
-  *n_stmts = 0;
   for (unsigned i = 0; i < loop->num_nodes; i++)
 for (gimple_stmt_iterator gsi = gsi_start_bb (bbs[i]);
 !gsi_end_p (gsi); gsi_next (&gsi))
@@ -2510,7 +2508,6 @@ vect_get_datarefs_in_loop (loop_p loop, basic_block *bbs,
gimple *stmt = gsi_stmt (gsi);
if (is_gimple_debug (stmt))
  continue;
-   ++(*n_stmts);
opt_result res = vect_find_stmt_data_reference (loop, stmt, datarefs,
NULL, 0);
if (!res)
@@ -2786,8 +2783,7 @@ vect_analyze_loop_2 (loop_vec_info loop_vinfo, bool 
&fatal,
 {
   opt_result res
= vect_get_datarefs_in_loop (loop, LOOP_VINFO_BBS (loop_vinfo),
-&LOOP_VINFO_DATAREFS (loop_vinfo),
-&LOOP_VINFO_N_STMTS (loop_vinfo));
+&LOOP_VINFO_DATAREFS (loop_vinfo));
   if (!res)
{
  if (dump_enabled_p ())
@@ -2898,7 +2894,7 @@ start_over:
 {
   /* Check the SLP opportunities in the loop, analyze and build
 SLP trees.  */
-  ok = vect_analyze_slp (loop_vinfo, LOOP_VINFO_N_STMTS (loop_vinfo),
+  ok = vect_analyze_slp (loop_vinfo, loop_vinfo->stmt_vec_infos.length (),
 slp == 1);
   if (!ok)
return ok;
diff --git a/gcc/tree-vectorizer.cc b/gcc/tree-vectorizer.cc
index 9a068a408647..0bec28048f4d 100644
--- a/gcc/tree-vectorizer.cc
+++ b/gcc/tree-vectorizer.cc
@@ -480,8 +480,7 @@ vec_info::~vec_info ()
 }
 
 vec_info_shared::vec_info_shared ()
-  : n_stmts (0),
-datarefs (vNULL),
+  : datarefs (vNULL),
 datarefs_copy (vNULL),
 ddrs (vNULL)
 {
diff --git a/gcc/tree-vectorizer.h b/gcc/tree-vectorizer.h
index 7f69a3f57b49..1059fc5c18f5 100644
--- a/gcc/tree-vectorizer.h
+++ b/gcc/tree-vectorizer.h
@@ -474,9 +474,6 @@ public:
   void save_datarefs();
   void check_datarefs();
 
-  /* The number of scalar stmts.  */
-  unsigned n_stmts;
-
   /* All data references.  Freed by free_data_refs, so not an auto_vec.  */
   vec datarefs;
   vec datarefs_copy;
@@ -1070,7 +1067,6 @@ public:
 #define LOOP_VINFO_RGROUP_IV_TYPE(L)   (L)->rgroup_iv_type
 #define LOOP_VINFO_PARTIAL_VECTORS_STYLE(L) (L)->partial_vector_style
 #define LOOP_VINFO_PTR_MASK(L) (L)->ptr_mask
-#define LOOP_VINFO_N_STMTS(L) (L)->shared->n_stmts
 #define LOOP_VINFO_LOOP_NEST(L)(L)->shared->loop_nest
 #define LOOP_VINFO_DATAREFS(L) (L)->shared->datarefs
 #define LOOP_VINFO_DDRS(L) (L)->shared->ddrs


[gcc r14-11051] [PATCH] modula2: Tidyup gm2-compiler/M2MetaError.mod

2024-12-03 Thread Gaius Mulley via Gcc-cvs
https://gcc.gnu.org/g:b16824e10d9ae6c7740fc01424e192ae3448fc9a

commit r14-11051-gb16824e10d9ae6c7740fc01424e192ae3448fc9a
Author: Gaius Mulley 
Date:   Tue Dec 3 14:39:03 2024 +

[PATCH] modula2: Tidyup gm2-compiler/M2MetaError.mod

This patch is a tidyup for gm2-compiler/M2MetaError.mod.

gcc/m2/ChangeLog:

* gm2-compiler/M2MetaError.mod (op): Alphabetically order
each case label and comment.

(cherry picked from commit 7fa9fd47f161d6b8177439ae2b46a2048a5eaa24)

Signed-off-by: Gaius Mulley 

Diff:
---
 gcc/m2/gm2-compiler/M2MetaError.mod | 51 +++--
 1 file changed, 26 insertions(+), 25 deletions(-)

diff --git a/gcc/m2/gm2-compiler/M2MetaError.mod 
b/gcc/m2/gm2-compiler/M2MetaError.mod
index 007c10b28bdf..e9f3127925c4 100644
--- a/gcc/m2/gm2-compiler/M2MetaError.mod
+++ b/gcc/m2/gm2-compiler/M2MetaError.mod
@@ -1684,8 +1684,9 @@ END copySym ;
 
 
 (*
-   op := {'a'|'q'|'t'|'d'|'n'|'s'|'B'|'D'|'F'|'G'|'H'|'M'|'U'|'E'|'V'|'W'|'A'} 
then =:
-   op := {'a'|'q'|'t'|'d'|'n'|'s'| 'u' |'D'|'F'|'G'|'M'|'U'|'E'|'W'} then =:
+   op := {'!'|'a'|'c'|'d'|'k'|'q'|'t'|'p'|'n'|'s'|'u'|
+  'A'|'B'|'C'|'D'|'E'|'F'|'G'|'H'|'K'|'M'|'N'|
+  'O'|'P'|'Q'|'R'|'S'|'T'|'U'|'V'|'W'|'X'|'Y'|'Z'} then =:
 *)
 
 PROCEDURE op (VAR eb: errorBlock;
@@ -1701,43 +1702,43 @@ BEGIN
 
   '!':  eb.positive := NOT eb.positive |
   'a':  doName (eb, sym, bol) |
+  'c':  eb.currentCol := readColor (eb) ;
+DEC (eb.ini) |
+  'd':  doDesc (eb, sym, bol) |
+  'k':  unquotedKeyword (eb) ;
+DEC (eb.ini) |
   'q':  doQualified (eb, sym, bol) |
   't':  doType (eb, sym, bol) |
-  'd':  doDesc (eb, sym, bol) |
+  'p':  popColor (eb) |
   'n':  doNumber (eb, sym, bol) |
-  'N':  doCount (eb, sym, bol) |
   's':  doSkipType (eb, sym, bol) |
-  'B':  declaredType (eb, sym, bol) |
-  'H':  declaredFull (eb, sym, bol) |
-  'V':  declaredVar (eb, sym, bol) |
-  'G':  declaredFor (eb, sym, bol) |
-  'M':  declaredMod (eb, sym, bol) |
-  'D':  declaredDef (eb, sym, bol) |
-  'U':  used (eb, sym, bol) |
-  'E':  eb.type := error |
+  'u':  eb.quotes := FALSE |
   'A':  eb.type := aborta ;
 seenAbort := TRUE |
-  'W':  eb.type := warning |
-  'O':  eb.type := note |
+  'B':  declaredType (eb, sym, bol) |
   'C':  eb.chain := TRUE |
-  'R':  eb.root := TRUE |
-  'S':  doGetSkipType (eb, sym, bol) |
-  'T':  doGetType (eb, sym, bol) |
-  'P':  pushColor (eb) |
-  'p':  popColor (eb) |
-  'c':  eb.currentCol := readColor (eb) ;
+  'D':  declaredDef (eb, sym, bol) |
+  'E':  eb.type := error |
+  'F':  filename (eb) ;
 DEC (eb.ini) |
+  'G':  declaredFor (eb, sym, bol) |
+  'H':  declaredFull (eb, sym, bol) |
   'K':  keyword (eb) ;
 DEC (eb.ini) |
-  'k':  unquotedKeyword (eb) ;
-DEC (eb.ini) |
+  'M':  declaredMod (eb, sym, bol) |
+  'N':  doCount (eb, sym, bol) |
+  'O':  eb.type := note |
+  'P':  pushColor (eb) |
   'Q':  resetDictionary |
+  'R':  eb.root := TRUE |
+  'S':  doGetSkipType (eb, sym, bol) |
+  'T':  doGetType (eb, sym, bol) |
+  'U':  used (eb, sym, bol) |
+  'V':  declaredVar (eb, sym, bol) |
+  'W':  eb.type := warning |
   'X':  pushOutput (eb) |
   'Y':  processDefine (eb) |
   'Z':  popOutput (eb) |
-  'F':  filename (eb) ;
-DEC (eb.ini) |
-  'u':  eb.quotes := FALSE |
   ':':  ifNonNulThen (eb, sym) ;
 DEC (eb.ini) |
   '1':  InternalError ('incorrect format spec, expecting %1 rather than % 
spec 1') |


[gcc r15-5877] replace atoi with strtoul in varasm.cc (decode_reg_name_and_count) [PR114540]

2024-12-03 Thread Jakub Jelinek via Gcc-cvs
https://gcc.gnu.org/g:4acab372d31a9fe9184ccc247780940821cda367

commit r15-5877-g4acab372d31a9fe9184ccc247780940821cda367
Author: Heiko Eißfeldt 
Date:   Tue Dec 3 09:47:59 2024 +0100

replace atoi with strtoul in varasm.cc (decode_reg_name_and_count) 
[PR114540]

The function uses atoi, which can silently return valid numbers even for
some too large numbers in the string.

Furthermore, the verification that all the characters in asmspec are
decimal digits can be simplified when using strotoul, we can check just
the first digit and whether the end pointer points to '\0'.

2024-12-03  Heiko Eißfeldt  

PR middle-end/114540
* varasm.cc (decode_reg_name_and_count): Use strtoul instead of atoi
and simplify verification that the whole asmspec contains just 
decimal
digits.

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

Signed-off-by: Heiko Eißfeldt 
Co-authored-by: Jakub Jelinek 

Diff:
---
 gcc/testsuite/gcc.dg/pr114540.c | 31 +++
 gcc/varasm.cc   | 23 ++-
 2 files changed, 45 insertions(+), 9 deletions(-)

diff --git a/gcc/testsuite/gcc.dg/pr114540.c b/gcc/testsuite/gcc.dg/pr114540.c
new file mode 100644
index ..e59dffa1e90c
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr114540.c
@@ -0,0 +1,31 @@
+/* PR middle-end/114540 */
+/* { dg-do compile } */
+/* { dg-options "" } */
+
+void
+foo ()
+{
+  asm ("" : : : "2147483648"); /* { dg-error "unknown register 
name" } */
+  asm ("" : : : "4294967296"); /* { dg-error "unknown register 
name" } */
+  asm ("" : : : "18446744073709551616");   /* { dg-error "unknown register 
name" } */
+  asm ("" : : : "9223372036854775808");/* { dg-error "unknown 
register name" } */
+  asm ("" : : : "9223372036854775807");/* { dg-error "unknown 
register name" } */
+  asm ("" : : : "2147483647"); /* { dg-error "unknown register 
name" } */
+  asm ("" : : : "4&"); /* { dg-error "unknown register 
name" } */
+  asm ("" : : : "1'0");/* { dg-error "unknown 
register name" } */
+#if defined(__i386__) || defined(__x86_64__) || defined(__powerpc__) || 
defined(__s390__) || defined(__aarch64__) || defined(__arm__)
+  asm ("" : : : "0");
+#endif
+
+  register int a asm("2147483648");/* { dg-error "invalid register 
name for" } */
+  register int b asm("4294967296");/* { dg-error "invalid register 
name for" } */
+  register int c asm("18446744073709551616");  /* { dg-error "invalid register 
name for" } */
+  register int d asm("9223372036854775808");   /* { dg-error "invalid register 
name for" } */
+  register int e asm("9223372036854775807");   /* { dg-error "invalid register 
name for" } */
+  register int f asm("2147483647");/* { dg-error "invalid register 
name for" } */
+  register int g asm("4&");/* { dg-error "invalid register 
name for" } */
+  register int h asm("1'0");   /* { dg-error "invalid register 
name for" } */
+#if defined(__i386__) || defined(__x86_64__) || defined(__powerpc__) || 
defined(__s390__) || defined(__aarch64__) || defined(__arm__)
+  register int i asm("0");
+#endif
+}
diff --git a/gcc/varasm.cc b/gcc/varasm.cc
index be11123180cd..261621a18c73 100644
--- a/gcc/varasm.cc
+++ b/gcc/varasm.cc
@@ -990,16 +990,21 @@ decode_reg_name_and_count (const char *asmspec, int 
*pnregs)
   asmspec = strip_reg_name (asmspec);
 
   /* Allow a decimal number as a "register name".  */
-  for (i = strlen (asmspec) - 1; i >= 0; i--)
-   if (! ISDIGIT (asmspec[i]))
- break;
-  if (asmspec[0] != 0 && i < 0)
+  if (ISDIGIT (asmspec[0]))
{
- i = atoi (asmspec);
- if (i < FIRST_PSEUDO_REGISTER && i >= 0 && reg_names[i][0])
-   return i;
- else
-   return -2;
+ char *pend;
+ errno = 0;
+ unsigned long j = strtoul (asmspec, &pend, 10);
+ if (*pend == '\0')
+   {
+ static_assert (FIRST_PSEUDO_REGISTER <= INT_MAX, "");
+ if (errno != ERANGE
+ && j < FIRST_PSEUDO_REGISTER
+ && reg_names[j][0])
+   return j;
+ else
+   return -2;
+   }
}
 
   for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)


[gcc r15-5879] Match: Refactor the unsigned SAT_SUB match patterns [NFC]

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

commit r15-5879-gf2d91164a5c54f4c246a7cc73f23aa79bc5e
Author: Pan Li 
Date:   Fri Nov 29 20:33:19 2024 +0800

Match: Refactor the unsigned SAT_SUB match patterns [NFC]

This patch would like to refactor the all unsigned SAT_SUB patterns, aka:
* Extract type check outside.
* Re-arrange the related match pattern forms together.

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

gcc/ChangeLog:

* match.pd: Refactor sorts of unsigned SAT_SUB match patterns.

Signed-off-by: Pan Li 

Diff:
---
 gcc/match.pd | 203 ++-
 1 file changed, 89 insertions(+), 114 deletions(-)

diff --git a/gcc/match.pd b/gcc/match.pd
index 2dd67b69cf1f..94202322602c 100644
--- a/gcc/match.pd
+++ b/gcc/match.pd
@@ -3160,6 +3160,95 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
 integer_minus_onep (realpart @2))
   (if (types_match (type, @0) && int_fits_type_p (@1, type)
 
+(if (INTEGRAL_TYPE_P (type) && TYPE_UNSIGNED (type))
+ (match (unsigned_integer_sat_sub @0 @1)
+  /* SAT_U_SUB = X > Y ? X - Y : 0  */
+  (cond^ (gt @0 @1) (minus @0 @1) integer_zerop)
+  (if (types_match (type, @0, @1
+ (match (unsigned_integer_sat_sub @0 @1)
+  /* SAT_U_SUB = X >= Y ? X - Y : 0  */
+  (cond^ (ge @0 @1) (convert? (minus (convert1? @0) (convert1? @1)))
+   integer_zerop)
+  (if (TYPE_UNSIGNED (TREE_TYPE (@0)) && types_match (@0, @1
+ (match (unsigned_integer_sat_sub @0 @1)
+  /* SAT_U_SUB = (X - Y) * (X > Y)  */
+  (mult:c (minus @0 @1) (convert (gt @0 @1)))
+  (if (types_match (type, @0, @1
+ (match (unsigned_integer_sat_sub @0 @1)
+  /* SAT_U_SUB = (X - Y) * (X >= Y)  */
+  (mult:c (minus @0 @1) (convert (ge @0 @1)))
+  (if (types_match (type, @0, @1
+ (match (unsigned_integer_sat_sub @0 @1)
+  /* DIFF = SUB_OVERFLOW (X, Y)
+ SAT_U_SUB = REALPART (DIFF) | (IMAGPART (DIFF) + (-1))  */
+  (bit_and:c (realpart (IFN_SUB_OVERFLOW@2 @0 @1))
+   (plus (imagpart @2) integer_minus_onep))
+  (if (types_match (type, @0, @1
+ (match (unsigned_integer_sat_sub @0 @1)
+  /* DIFF = SUB_OVERFLOW (X, Y)
+ SAT_U_SUB = REALPART (DIFF) * (IMAGPART (DIFF) ^ (1))  */
+  (mult:c (realpart (IFN_SUB_OVERFLOW@2 @0 @1))
+   (bit_xor (imagpart @2) integer_onep))
+  (if (types_match (type, @0, @1
+ (match (unsigned_integer_sat_sub @0 @1)
+  /* DIFF = SUB_OVERFLOW (X, Y)
+ SAT_U_SUB = IMAGPART (DIFF) == 0 ? REALPART (DIFF) : 0  */
+  (cond^ (eq (imagpart (IFN_SUB_OVERFLOW@2 @0 @1)) integer_zerop)
+(realpart @2) integer_zerop)
+  (if (types_match (type, @0, @1
+ (match (unsigned_integer_sat_sub @0 @1)
+  /* DIFF = SUB_OVERFLOW (X, Y)
+ SAT_U_SUB = IMAGPART (DIFF) != 0 ? 0 : REALPART (DIFF)  */
+  (cond^ (ne (imagpart (IFN_SUB_OVERFLOW@2 @0 @1)) integer_zerop)
+integer_zerop (realpart @2))
+  (if (types_match (type, @0, @1
+ (match (unsigned_integer_sat_sub @0 @1)
+  /* SAT_U_SUB = IMM > Y ? (IMM - Y) : 0
+ SAT_U_SUB = IMM >= Y ? (IMM - Y) : 0  */
+  (cond^ (le @1 INTEGER_CST@2) (minus INTEGER_CST@0 @1) integer_zerop)
+  (if (types_match (type, @1) && int_fits_type_p (@0, type))
+   (with
+{
+ unsigned precision = TYPE_PRECISION (type);
+ wide_int max = wi::mask (precision, false, precision);
+ wide_int c0 = wi::to_wide (@0);
+ wide_int c2 = wi::to_wide (@2);
+ wide_int c2_add_1 = wi::add (c2, wi::uhwi (1, precision));
+ bool equal_p = wi::eq_p (c0, c2);
+ bool less_than_1_p = !wi::eq_p (c2, max) && wi::eq_p (c2_add_1, c0);
+}
+(if (equal_p || less_than_1_p)
+ (match (unsigned_integer_sat_sub @0 @1)
+  /* SAT_U_SUB = (MAX - 1) >= Y ? ((MAX - 1) - Y) : 0  */
+  (cond^ (ne @1 INTEGER_CST@2) (minus INTEGER_CST@0 @1) integer_zerop)
+  (if (types_match (type, @1))
+   (with
+{
+ unsigned precision = TYPE_PRECISION (type);
+ wide_int max = wi::mask (precision, false, precision);
+ wide_int c0 = wi::to_wide (@0);
+ wide_int c2 = wi::to_wide (@2);
+ wide_int c0_add_1 = wi::add (c0, wi::uhwi (1, precision));
+}
+(if (wi::eq_p (c2, max) && wi::eq_p (c0_add_1, max))
+ (match (unsigned_integer_sat_sub @0 @1)
+  /* SAT_U_SUB = 1 >= Y ? (1 - Y) : 0  */
+  (cond^ (le @1 integer_onep@0) (bit_xor @1 integer_onep@0) integer_zerop)
+  (if (types_match (type, @1
+ (match (unsigned_integer_sat_sub @0 @1)
+  /* SAT_U_SUB = X > IMM  ? (X - IMM) : 0.
+ SAT_U_SUB = X >= IMM ? (X - IMM) : 0.  */
+  (plus (max @0 INTEGER_CST@1) INTEGER_CST@2)
+  (if (types_match (type, @1) && int_fits_type_p (@1, type))
+   (with
+{
+ unsigned precision = TYPE_PRECISION (type);
+ wide_int c1 = wi::to_wide (@1);
+ wide_int c2 = wi::to_wide (@2);
+ wide_int sum = wi::add (c1, c2);
+}
+(if (wi::eq_p (sum, wi::uhwi (0, precision
+
 /

[gcc r15-5891] aarch64: Fix fp8 cpuinfo feature names

2024-12-03 Thread Claudio Bantaloukas via Gcc-cvs
https://gcc.gnu.org/g:d777d66cc168a5019dad8e60b075c82b6207f199

commit r15-5891-gd777d66cc168a5019dad8e60b075c82b6207f199
Author: Claudio Bantaloukas 
Date:   Tue Dec 3 10:53:53 2024 +

aarch64: Fix fp8 cpuinfo feature names

The previous version of the patch was based on the mistaken assumption that
features in /proc/cpuinfo had matching names to the feature names that gcc 
and
gas accept.
This patch enables the fp8 feature when the f8cvt feature is enabled, under 
the
assumption that fpmr is always enabled when f8cvt is.

Changelog:

gcc/
* config/aarch64/aarch64-option-extensions.def: (fp8): fix 
FEATURE_STRING.
(fp8fma, ssve-fp8fma): Likewise.
(fp8dot4, ssve-fp8dot4, fp8dot2, ssve-fp8dot2): Likewise.

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

diff --git a/gcc/config/aarch64/aarch64-option-extensions.def 
b/gcc/config/aarch64/aarch64-option-extensions.def
index 0a61b4858b17..52c3e7b57668 100644
--- a/gcc/config/aarch64/aarch64-option-extensions.def
+++ b/gcc/config/aarch64/aarch64-option-extensions.def
@@ -243,21 +243,21 @@ AARCH64_OPT_EXTENSION("the", THE, (), (), (), "the")
 
 AARCH64_OPT_EXTENSION("gcs", GCS, (), (), (), "gcs")
 
-AARCH64_OPT_EXTENSION("fp8", FP8, (SIMD), (), (), "fp8")
+AARCH64_OPT_EXTENSION("fp8", FP8, (SIMD), (), (), "f8cvt")
 
-AARCH64_OPT_EXTENSION("fp8fma", FP8FMA, (FP8), (), (), "fp8fma")
+AARCH64_OPT_EXTENSION("fp8fma", FP8FMA, (FP8), (), (), "f8fma")
 
-AARCH64_OPT_EXTENSION("ssve-fp8fma", SSVE_FP8FMA, (SME2,FP8), (), (), 
"ssve-fp8fma")
+AARCH64_OPT_EXTENSION("ssve-fp8fma", SSVE_FP8FMA, (SME2,FP8), (), (), 
"smesf8fma")
 
 AARCH64_OPT_EXTENSION("faminmax", FAMINMAX, (SIMD), (), (), "faminmax")
 
-AARCH64_OPT_EXTENSION("fp8dot4", FP8DOT4, (FP8FMA), (), (), "fp8dot4")
+AARCH64_OPT_EXTENSION("fp8dot4", FP8DOT4, (FP8FMA), (), (), "f8dp4")
 
-AARCH64_OPT_EXTENSION("ssve-fp8dot4", SSVE_FP8DOT4, (SSVE_FP8FMA), (), (), 
"ssve-fp8dot4")
+AARCH64_OPT_EXTENSION("ssve-fp8dot4", SSVE_FP8DOT4, (SSVE_FP8FMA), (), (), 
"smesf8dp4")
 
-AARCH64_OPT_EXTENSION("fp8dot2", FP8DOT2, (FP8DOT4), (), (), "fp8dot2")
+AARCH64_OPT_EXTENSION("fp8dot2", FP8DOT2, (FP8DOT4), (), (), "f8dp2")
 
-AARCH64_OPT_EXTENSION("ssve-fp8dot2", SSVE_FP8DOT2, (SSVE_FP8DOT4), (), (), 
"ssve-fp8dot2")
+AARCH64_OPT_EXTENSION("ssve-fp8dot2", SSVE_FP8DOT2, (SSVE_FP8DOT4), (), (), 
"smesf8dp2")
 
 AARCH64_OPT_EXTENSION("lut", LUT, (SIMD), (), (), "lut")


[gcc r14-11053] middle-end:For multiplication try swapping operands when matching complex multiply [PR116463]

2024-12-03 Thread Tamar Christina via Gcc-cvs
https://gcc.gnu.org/g:f01f01f0ebf8f5207096cb9650354210d890fe0d

commit r14-11053-gf01f01f0ebf8f5207096cb9650354210d890fe0d
Author: Tamar Christina 
Date:   Thu Nov 21 15:10:24 2024 +

middle-end:For multiplication try swapping operands when matching complex 
multiply [PR116463]

This commit fixes the failures of complex.exp=fast-math-complex-mls-*.c on 
the
GCC 14 branch and some of the ones on the master.

The current matching just looks for one order for multiplication and was 
relying
on canonicalization to always give the right order because of the 
TWO_OPERANDS.

However when it comes to the multiplication trying only one order is a bit
fragile as they can be flipped.

The failing tests on the branch are:

void fms180snd(_Complex TYPE a[restrict N], _Complex TYPE b[restrict N],
   _Complex TYPE c[restrict N]) {
  for (int i = 0; i < N; i++)
c[i] -= a[i] * (b[i] * I * I);
}

void fms180fst(_Complex TYPE a[restrict N], _Complex TYPE b[restrict N],
   _Complex TYPE c[restrict N]) {
  for (int i = 0; i < N; i++)
c[i] -= (a[i] * I * I) * b[i];
}

The issue is just a small difference in commutative operations.
we look for {R,R} * {R,I} but found {R,I} * {R,R}.

Since the DF analysis is cached, we should be able to swap operands and 
retry
for multiply cheaply.

There is a constraint being checked by vect_validate_multiplication for the 
data
flow of the operands feeding the multiplications.  So e.g.

between the nodes:

note:   node 0x4d1d210 (max_nunits=2, refcnt=3) vector(2) double
note:   op template: _27 = _10 * _25;
note:  stmt 0 _27 = _10 * _25;
note:  stmt 1 _29 = _11 * _25;
note:   node 0x4d1d060 (max_nunits=2, refcnt=2) vector(2) double
note:   op template: _26 = _11 * _24;
note:  stmt 0 _26 = _11 * _24;
note:  stmt 1 _28 = _10 * _24;

we require the lanes to come from the same source which
vect_validate_multiplication checks.  As such it doesn't make sense to flip 
them
individually because that would invalidate the earlier linear_loads_p checks
which have validated that the arguments all come from the same datarefs.

This patch thus flips the operands in unison to still maintain this 
invariant,
but also honor the commutative nature of multiplication.

gcc/ChangeLog:

PR tree-optimization/116463
* tree-vect-slp-patterns.cc (complex_mul_pattern::matches,
complex_fms_pattern::matches): Try swapping operands on multiply.

(cherry picked from commit a9473f9c6f2d755d2eb79dbd30877e64b4bc6fc8)

Diff:
---
 gcc/tree-vect-slp-patterns.cc | 20 ++--
 1 file changed, 18 insertions(+), 2 deletions(-)

diff --git a/gcc/tree-vect-slp-patterns.cc b/gcc/tree-vect-slp-patterns.cc
index 4a582ec9512e..3bb283a3b5b4 100644
--- a/gcc/tree-vect-slp-patterns.cc
+++ b/gcc/tree-vect-slp-patterns.cc
@@ -1069,7 +1069,15 @@ complex_mul_pattern::matches (complex_operation_t op,
   enum _conj_status status;
   if (!vect_validate_multiplication (perm_cache, compat_cache, left_op,
 right_op, false, &status))
-return IFN_LAST;
+{
+  /* Try swapping the order and re-trying since multiplication is
+commutative.  */
+  std::swap (left_op[0], left_op[1]);
+  std::swap (right_op[0], right_op[1]);
+  if (!vect_validate_multiplication (perm_cache, compat_cache, left_op,
+right_op, false, &status))
+   return IFN_LAST;
+}
 
   if (status == CONJ_NONE)
 {
@@ -1286,7 +1294,15 @@ complex_fms_pattern::matches (complex_operation_t op,
   enum _conj_status status;
   if (!vect_validate_multiplication (perm_cache, compat_cache, right_op,
 left_op, true, &status))
-return IFN_LAST;
+{
+  /* Try swapping the order and re-trying since multiplication is
+commutative.  */
+  std::swap (left_op[0], left_op[1]);
+  std::swap (right_op[0], right_op[1]);
+  if (!vect_validate_multiplication (perm_cache, compat_cache, right_op,
+left_op, true, &status))
+   return IFN_LAST;
+}
 
   if (status == CONJ_NONE)
 ifn = IFN_COMPLEX_FMS;


[gcc r15-5897] Fortran: Fix class transformational intrinsic calls [PR102689]

2024-12-03 Thread Paul Thomas via Gcc-cvs
https://gcc.gnu.org/g:31250baf81446aa4fc1b729e2fc5165a36005ebc

commit r15-5897-g31250baf81446aa4fc1b729e2fc5165a36005ebc
Author: Paul Thomas 
Date:   Tue Dec 3 15:56:53 2024 +

Fortran: Fix class transformational intrinsic calls [PR102689]

2024-12-03  Paul Thomas  

gcc/fortran
PR fortran/102689
* trans-array.cc (get_array_ref_dim_for_loop_dim): Use the arg1
class container carried in ss->info as the seed for a lhs in
class valued transformational intrinsic calls that are not the
rhs of an assignment. Otherwise, the lhs variable expression is
taken from the loop chain. For this latter case, the _vptr and
_len fields are set.
(gfc_trans_create_temp_array): Use either the lhs expression
seeds to build a class variable that will take the returned
descriptor as its _data field. In the case that the arg1 expr.
is used, 'atmp' must be marked as unused, a typespec built with
the correct rank and the _vptr and _len fields set. The element
size is provided for the temporary allocation and to set the
descriptor span.
(gfc_array_init_size): When an intrinsic type scalar expr3 is
used in allocation of a class array, use its element size in
the descriptor dtype.
* trans-expr.cc (gfc_conv_class_to_class): Class valued
transformational intrinsics return the pointer to the array
descriptor as the _data field of a class temporary. Extract
directly and return the address of the class temporary.
(gfc_conv_procedure_call): store the expression for the first
argument of a class valued transformational intrinsic function
in the ss info class_container field. Later, use its type  as
the element type in the call to gfc_trans_create_temp_array.
(fcncall_realloc_result): Add a dtype argument and use it in
the descriptor, when available.
(gfc_trans_arrayfunc_assign): For class lhs, build a dtype with
the lhs rank and the rhs element size and use it in the call to
fcncall_realloc_result.

gcc/testsuite/
PR fortran/102689
* gfortran.dg/class_transformational_1.f90: New test for class-
valued reshape.
* gfortran.dg/class_transformational_2.f90: New test for other
class_valued transformational intrinsics.

Diff:
---
 gcc/fortran/trans-array.cc | 157 +---
 gcc/fortran/trans-expr.cc  |  57 +-
 .../gfortran.dg/class_transformational_1.f90   | 204 +
 .../gfortran.dg/class_transformational_2.f90   | 107 +++
 4 files changed, 490 insertions(+), 35 deletions(-)

diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc
index a458af322ce8..6ff2c238038d 100644
--- a/gcc/fortran/trans-array.cc
+++ b/gcc/fortran/trans-array.cc
@@ -1325,23 +1325,28 @@ get_array_ref_dim_for_loop_dim (gfc_ss *ss, int 
loop_dim)
is a class expression.  */
 
 static tree
-get_class_info_from_ss (stmtblock_t * pre, gfc_ss *ss, tree *eltype)
+get_class_info_from_ss (stmtblock_t * pre, gfc_ss *ss, tree *eltype,
+   gfc_ss **fcnss)
 {
+  gfc_ss *loop_ss = ss->loop->ss;
   gfc_ss *lhs_ss;
   gfc_ss *rhs_ss;
+  gfc_ss *fcn_ss = NULL;
   tree tmp;
   tree tmp2;
   tree vptr;
-  tree rhs_class_expr = NULL_TREE;
+  tree class_expr = NULL_TREE;
   tree lhs_class_expr = NULL_TREE;
   bool unlimited_rhs = false;
   bool unlimited_lhs = false;
   bool rhs_function = false;
+  bool unlimited_arg1 = false;
   gfc_symbol *vtab;
+  tree cntnr = NULL_TREE;
 
   /* The second element in the loop chain contains the source for the
- temporary; ie. the rhs of the assignment.  */
-  rhs_ss = ss->loop->ss->loop_chain;
+ class temporary created in gfc_trans_create_temp_array.  */
+  rhs_ss = loop_ss->loop_chain;
 
   if (rhs_ss != gfc_ss_terminator
   && rhs_ss->info
@@ -1350,28 +1355,58 @@ get_class_info_from_ss (stmtblock_t * pre, gfc_ss *ss, 
tree *eltype)
   && rhs_ss->info->data.array.descriptor)
 {
   if (rhs_ss->info->expr->expr_type != EXPR_VARIABLE)
-   rhs_class_expr
+   class_expr
  = gfc_get_class_from_expr (rhs_ss->info->data.array.descriptor);
   else
-   rhs_class_expr = gfc_get_class_from_gfc_expr (rhs_ss->info->expr);
+   class_expr = gfc_get_class_from_gfc_expr (rhs_ss->info->expr);
   unlimited_rhs = UNLIMITED_POLY (rhs_ss->info->expr);
   if (rhs_ss->info->expr->expr_type == EXPR_FUNCTION)
rhs_function = true;
 }
 
+  /* Usually, ss points to the function. When the function call is an actual
+ argument, it is instead rhs_ss because the ss chain is shifted by one.  */
+  *fcnss = fcn_ss = rhs_function ? rhs_ss : ss;
+
+  /

[gcc r15-5898] libgdiagnostics: fix docs metadata

2024-12-03 Thread David Malcolm via Gcc-cvs
https://gcc.gnu.org/g:2b93d71b068b2f5be134350697fb075d72d01163

commit r15-5898-g2b93d71b068b2f5be134350697fb075d72d01163
Author: David Malcolm 
Date:   Tue Dec 3 12:17:01 2024 -0500

libgdiagnostics: fix docs metadata

gcc/ChangeLog:
* doc/libgdiagnostics/conf.py: Remove "author".  Change
"copyright" field to the FSF.

Signed-off-by: David Malcolm 

Diff:
---
 gcc/doc/libgdiagnostics/conf.py | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/gcc/doc/libgdiagnostics/conf.py b/gcc/doc/libgdiagnostics/conf.py
index 8e92e12e91ea..b83f41c38810 100644
--- a/gcc/doc/libgdiagnostics/conf.py
+++ b/gcc/doc/libgdiagnostics/conf.py
@@ -7,8 +7,7 @@
 # 
https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
 
 project = 'libgdiagnostics'
-copyright = '2024, David Malcolm'
-author = 'David Malcolm'
+copyright = '2024 Free Software Foundation, Inc.'
 
 # -- General configuration ---
 # 
https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration


[gcc r15-5909] libstdc++: Add fancy pointer support to std::list [PR57272]

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

commit r15-5909-gf29d1b5836790ec795cb51bcfe25f7270b3e9f30
Author: Jonathan Wakely 
Date:   Fri Nov 15 19:06:47 2024 +

libstdc++: Add fancy pointer support to std::list [PR57272]

Currently std::list uses raw pointers to connect its nodes, which is
non-conforming. We should use the allocator's pointer type everywhere
that a "pointer" is needed.

Because the existing types like _List_node are part of the ABI now,
we can't change them. To support nodes that are connected by fancy
pointers we need a parallel hierarchy of node types. This change
introduces new class templates parameterized on the allocator's
void_pointer type, __list::_Node_base and __list::_Node_header, and new
class templates parameterized on the allocator's pointer type,
__list::Node, __list::_Iterator. The iterator class template is used for
both iterator and const_iterator. Whether std::list should use the
old _List_node or new _list::_Node type family internally
is controlled by a new __list::_Node_traits traits template.

Because std::pointer_traits and std::__to_address are not defined for
C++98, there is no way to support fancy pointers in C++98. For C++98 the
_Node_traits traits always choose the old _List_node family.

In case anybody is currently using std::list with an allocator that has
a fancy pointer, this change would be an ABI break, because their
std::list instantiations would start to (correctly) use the fancy
pointer type. If the fancy pointer just contains a single pointer and so
has the same size, layout, and object represenation as a raw pointer,
the code might still work (despite being an ODR violation). But if their
fancy pointer has a different representation, they would need to
recompile all their code using that allocator with std::list. Because
std::list will never use fancy pointers in C++98 mode, recompiling
everything to use fancy pointers isn't even possible if mixing C++98 and
C++11 code that uses std::list. To alleviate this problem, compiling
with -D_GLIBCXX_USE_ALLOC_PTR_FOR_LIST=0 will force std::list to have
the old, non-conforming behaviour and use raw pointers internally. For
testing purposes, compiling with -D_GLIBCXX_USE_ALLOC_PTR_FOR_LIST=9001
will force std::list to always use the new node types.  This macro is
currently undocumented, which needs to be fixed.

The original _List_node type is trivially constructible and trivially
destructible, but the new __list::_Node type might not be,
depending on the fancy pointer data members in _Node_base. This means
that std::list needs to explicitly construct and destroy the node
object, not just the value that it contains. This commit adds a new
__allocated_obj helper which wraps an __allocated_ptr and additionally
constructs and destroys an object in the allocated storage.

Pretty printers for std::list need to be updated to handle the new node
types. Potentially we just can't pretty print them, because we don't
know how to follow the fancy pointers to traverse the list.

libstdc++-v3/ChangeLog:

PR libstdc++/57272
PR libstdc++/110952
* include/bits/allocated_ptr.h (__allocated_ptr::get): Add
const.
(__allocated_ptr::operator bool, __allocated_ptr::release): New
member functions.
(__allocate_guarded): Add inline.
(__allocated_obj): New class template.
(__allocate_guarded_obj): New function template.
* include/bits/list.tcc (_List_base::_M_clear()): Replace uses
of raw pointers. Use _M_destroy_node.
(list::emplace, list::insert): Likewise.
(list::sort): Adjust check for 0 or 1 wsize. Use template
argument list for _Scratch_list.
* include/bits/stl_list.h (_GLIBCXX_USE_ALLOC_PTR_FOR_LIST):
Define.
(_List_node_base::_Base_ptr): New typedef.
(_List_node_base::_M_base): New member functions.
(_List_node_header::_M_base): Make public and add
using-declaration for base class overload.
(__list::_Node_traits, __list::_Node_base)
(__list::_Node_header, __list::_Node, __list::_Iterator): New
class templates.
(_Scratch_list): Turn class into class template. Use _Base_ptr
typedef instead of _List_node_base*.
(_List_node::_Node_ptr): New typedef.
(_List_node::_M_node_ptr): New member function.
(_List_base, _List_impl): Use _Node_traits to get node types.
(_List_base::_M_put_node): Convert to fancy pointer if needed.
(_List_base::_M_destroy_node): New member function.
(_List_base(_List_base&&, _Node_alloc_type&&)): Use if constexpr
   

[gcc r15-5907] libstdc++: Refactor std::list::size() for cxx11 ABI

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

commit r15-5907-gca24f585fc3b7bf5e145cf3ee3f6f83ad8a4f2dd
Author: Jonathan Wakely 
Date:   Tue Nov 12 15:36:17 2024 +

libstdc++: Refactor std::list::size() for cxx11 ABI

Remove some preprocessor conditionals by moving the _M_size member for
the cxx11 ABI into a new base class, which is empty for the gcc4-compat
ABI.

Move some unused members that are only retained for ABI compatibility to
the end of _List_base and add an explanatory comment. Stop using
list::_M_node_count and list::_D_distance and then move them to the end
of std::list with a comment too.

libstdc++-v3/ChangeLog:

* include/bits/stl_list.h (_List_size): New struct.
(_List_node_header): Replace _M_size member with _List_size base
class.
(_List_node_header(_List_node_header&&)): Replace explicit uses
of _M_size with initializing the base.
(_List_node_header::_M_init): Likewise.
(_List_base::_S_distance, _List_base::_M_distance)
(_List_base::_M_node_count): Move to end of class body and add
comment.
(list::_S_distance, list::_M_node_count): Likewise.
(list::size): Inline _M_node_count effects to here.
(list::splice(iterator, list&, iterator, iterator)): Use #if and
call std::distance instead of _S_distance.

Diff:
---
 libstdc++-v3/include/bits/stl_list.h | 179 +++
 1 file changed, 97 insertions(+), 82 deletions(-)

diff --git a/libstdc++-v3/include/bits/stl_list.h 
b/libstdc++-v3/include/bits/stl_list.h
index cf3d05fcae95..dfdab6e511a9 100644
--- a/libstdc++-v3/include/bits/stl_list.h
+++ b/libstdc++-v3/include/bits/stl_list.h
@@ -105,22 +105,24 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   _M_unhook() _GLIBCXX_USE_NOEXCEPT;
 };
 
-/// The %list node header.
-struct _List_node_header : public _List_node_base
+struct _List_size
 {
 #if _GLIBCXX_USE_CXX11_ABI
-  std::size_t _M_size;
+  // Store the size here so that std::list::size() is fast.
+  size_t _M_size;
 #endif
+};
+
 
+/// The %list node header.
+struct _List_node_header : public _List_node_base, _List_size
+{
   _List_node_header() _GLIBCXX_NOEXCEPT
   { _M_init(); }
 
 #if __cplusplus >= 201103L
   _List_node_header(_List_node_header&& __x) noexcept
-  : _List_node_base{ __x._M_next, __x._M_prev }
-# if _GLIBCXX_USE_CXX11_ABI
-  , _M_size(__x._M_size)
-# endif
+  : _List_node_base(__x), _List_size(__x)
   {
if (__x._M_base()->_M_next == __x._M_base())
  this->_M_next = this->_M_prev = this;
@@ -143,9 +145,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
__node->_M_next = __xnode->_M_next;
__node->_M_prev = __xnode->_M_prev;
__node->_M_next->_M_prev = __node->_M_prev->_M_next = __node;
-# if _GLIBCXX_USE_CXX11_ABI
-   _M_size = __x._M_size;
-# endif
+   _List_size::operator=(__x);
__x._M_init();
  }
   }
@@ -155,9 +155,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   _M_init() _GLIBCXX_NOEXCEPT
   {
this->_M_next = this->_M_prev = this;
-#if _GLIBCXX_USE_CXX11_ABI
-   this->_M_size = 0;
-#endif
+   _List_size::operator=(_List_size());
   }
 
 private:
@@ -437,21 +435,6 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
rebind<_List_node<_Tp> >::other _Node_alloc_type;
   typedef __gnu_cxx::__alloc_traits<_Node_alloc_type> _Node_alloc_traits;
 
-#if !_GLIBCXX_INLINE_VERSION
-  static size_t
-  _S_distance(const __detail::_List_node_base* __first,
- const __detail::_List_node_base* __last)
-  {
-   size_t __n = 0;
-   while (__first != __last)
- {
-   __first = __first->_M_next;
-   ++__n;
- }
-   return __n;
-  }
-#endif
-
   struct _List_impl
   : public _Node_alloc_type
   {
@@ -489,33 +472,12 @@ _GLIBCXX_BEGIN_NAMESPACE_CXX11
   void _M_inc_size(size_t __n) { _M_impl._M_node._M_size += __n; }
 
   void _M_dec_size(size_t __n) { _M_impl._M_node._M_size -= __n; }
-
-# if !_GLIBCXX_INLINE_VERSION
-  size_t
-  _M_distance(const __detail::_List_node_base* __first,
- const __detail::_List_node_base* __last) const
-  { return _S_distance(__first, __last); }
-
-  // return the stored size
-  size_t _M_node_count() const { return _M_get_size(); }
-# endif
 #else
   // dummy implementations used when the size is not stored
   size_t _M_get_size() const { return 0; }
   void _M_set_size(size_t) { }
   void _M_inc_size(size_t) { }
   void _M_dec_size(size_t) { }
-
-# if !_GLIBCXX_INLINE_VERSION
-  size_t _M_distance(const void*, const void*) const { return 0; }
-
-  // count the number of nodes
-  size_t _M_node_count() const
-  {
-   return _S_distan

[gcc r15-5910] libstdc++: Add fancy pointer support to std::forward_list [PR57272]

2024-12-03 Thread Jonathan Wakely via Libstdc++-cvs
https://gcc.gnu.org/g:84b40a1c1b2c9e3feb546838fa988d653eed0755

commit r15-5910-g84b40a1c1b2c9e3feb546838fa988d653eed0755
Author: Jonathan Wakely 
Date:   Fri Nov 15 21:45:16 2024 +

libstdc++: Add fancy pointer support to std::forward_list [PR57272]

This takes a very similar approach to the changes for std::list.

libstdc++-v3/ChangeLog:

PR libstdc++/57272
* include/bits/forward_list.h (_GLIBCXX_USE_ALLOC_PTR_FOR_LIST):
Define.
(_Fwd_list_node_base::_M_base_ptr): New member functions.
(_Fwd_list_node::_M_node_ptr): New member function.
(_Fwd_list_iterator, _Fwd_list_const_iterator): Make internal
member functions and data member private. Declare forward_list
and _Fwd_list_base as friends.
(__fwdlist::_Node_base, __fwdlist::_Node, __fwdlist::_Iterator):
New class templates.
(__fwdlist::_Node_traits): New class template.
(_Fwd_list_base): Use _Node_traits to get types. Use _Base_ptr
instad of _Fwd_list_node_base*. Use _M_base_ptr() instead of
taking address of head node.
(forward_list): Likewise.
(_Fwd_list_base::_M_get_node): Do not define for versioned
namespace.
(_Fwd_list_base::_M_put_node): Only convert pointer if needed.
(_Fwd_list_base::_M_create_node): Use __allocate_guarded_obj.
(_Fwd_list_base::_M_destroy_node): New member function.
* include/bits/forward_list.tcc (_Fwd_list_base::_M_insert_after)
(forward_list::_M_splice_after, forward_list::insert_after): Use
const_iterator::_M_const_cast() instead of casting pointers.
(_Fwd_list_base::_M_erase_after): Use _M_destroy_node.
(forward_list::remove, forward_list::remove_if): Only do
downcasts when accessing the value.
(forward_list::sort): Likewise.
* testsuite/23_containers/forward_list/capacity/1.cc: Check
max_size for new node type.
* testsuite/23_containers/forward_list/capacity/node_sizes.cc:
New test.
* 
testsuite/23_containers/forward_list/requirements/explicit_instantiation/alloc_ptr.cc:
New test.
* 
testsuite/23_containers/forward_list/requirements/explicit_instantiation/alloc_ptr_ignored.cc:
New test.

Diff:
---
 libstdc++-v3/include/bits/forward_list.h   | 508 +
 libstdc++-v3/include/bits/forward_list.tcc | 124 ++---
 .../23_containers/forward_list/capacity/1.cc   |  11 +-
 .../forward_list/capacity/node_sizes.cc|  24 +
 .../forward_list/requirements/completeness.cc  |  19 +
 .../explicit_instantiation/alloc_ptr.cc|  88 
 .../explicit_instantiation/alloc_ptr_ignored.cc|   4 +
 7 files changed, 635 insertions(+), 143 deletions(-)

diff --git a/libstdc++-v3/include/bits/forward_list.h 
b/libstdc++-v3/include/bits/forward_list.h
index f6d4e6bd3d26..f4a53bb4d7ef 100644
--- a/libstdc++-v3/include/bits/forward_list.h
+++ b/libstdc++-v3/include/bits/forward_list.h
@@ -40,6 +40,9 @@
 #include 
 #include 
 #include 
+#include 
+#include 
+#include 
 #include 
 #include 
 #include 
@@ -48,6 +51,10 @@
 # include  // ranges::subrange
 #endif
 
+#if ! defined _GLIBCXX_USE_ALLOC_PTR_FOR_FWD_LIST
+# define _GLIBCXX_USE_ALLOC_PTR_FOR_FWD_LIST 1
+#endif
+
 namespace std _GLIBCXX_VISIBILITY(default)
 {
 _GLIBCXX_BEGIN_NAMESPACE_VERSION
@@ -55,11 +62,14 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
 
   /**
*  @brief  A helper basic node class for %forward_list.
+   *
*  This is just a linked list with nothing inside it.
*  There are purely list shuffling utility methods here.
*/
   struct _Fwd_list_node_base
   {
+using _Base_ptr = _Fwd_list_node_base*;
+
 _Fwd_list_node_base() = default;
 _Fwd_list_node_base(_Fwd_list_node_base&& __x) noexcept
   : _M_next(__x._M_next)
@@ -108,6 +118,9 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
  _M_next->_M_next = __keep;
}
 }
+
+_Fwd_list_node_base* _M_base_ptr() { return this; }
+const _Fwd_list_node_base* _M_base_ptr() const { return this; }
   };
 
   /**
@@ -120,6 +133,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
 struct _Fwd_list_node
 : public _Fwd_list_node_base
 {
+  using _Node_ptr = _Fwd_list_node*;
+
   _Fwd_list_node() = default;
 
   __gnu_cxx::__aligned_buffer<_Tp> _M_storage;
@@ -131,8 +146,14 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
   const _Tp*
   _M_valptr() const noexcept
   { return _M_storage._M_ptr(); }
+
+  _Node_ptr
+  _M_node_ptr()
+  { return this; }
 };
 
+  template struct _Fwd_list_const_iterator;
+
   /**
*   @brief A forward_list::iterator.
*
@@ -200,6 +221,13 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
   { return __x._M_node != __y._M_node; }
 #endif
 
+pr

[gcc r15-5908] libstdc++: Stop using _Self typedefs in std::list iterators

2024-12-03 Thread Jonathan Wakely via Libstdc++-cvs
https://gcc.gnu.org/g:5f02a4f5c66df222ca8db12cde510c387a962c2d

commit r15-5908-g5f02a4f5c66df222ca8db12cde510c387a962c2d
Author: Jonathan Wakely 
Date:   Tue Nov 12 17:01:59 2024 +

libstdc++: Stop using _Self typedefs in std::list iterators

We can just use the injected-class-name instead of defining a new name.
That seems simpler.

libstdc++-v3/ChangeLog:

* include/bits/stl_list.h (_List_iterator): Remove _Self typedef
and just use injected-class-name instead.
(_List_const_iterator): Likewise.

Diff:
---
 libstdc++-v3/include/bits/stl_list.h | 40 +++-
 1 file changed, 21 insertions(+), 19 deletions(-)

diff --git a/libstdc++-v3/include/bits/stl_list.h 
b/libstdc++-v3/include/bits/stl_list.h
index dfdab6e511a9..db6b31fdc166 100644
--- a/libstdc++-v3/include/bits/stl_list.h
+++ b/libstdc++-v3/include/bits/stl_list.h
@@ -255,7 +255,6 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
   template
 struct _List_iterator
 {
-  typedef _List_iterator<_Tp>  _Self;
   typedef _List_node<_Tp>  _Node;
 
   typedef ptrdiff_tdifference_type;
@@ -271,7 +270,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
   _List_iterator(__detail::_List_node_base* __x) _GLIBCXX_NOEXCEPT
   : _M_node(__x) { }
 
-  _Self
+  _List_iterator
   _M_const_cast() const _GLIBCXX_NOEXCEPT
   { return *this; }
 
@@ -286,45 +285,47 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
   operator->() const _GLIBCXX_NOEXCEPT
   { return static_cast<_Node*>(_M_node)->_M_valptr(); }
 
-  _Self&
+  _List_iterator&
   operator++() _GLIBCXX_NOEXCEPT
   {
_M_node = _M_node->_M_next;
return *this;
   }
 
-  _Self
+  _List_iterator
   operator++(int) _GLIBCXX_NOEXCEPT
   {
-   _Self __tmp = *this;
+   _List_iterator __tmp = *this;
_M_node = _M_node->_M_next;
return __tmp;
   }
 
-  _Self&
+  _List_iterator&
   operator--() _GLIBCXX_NOEXCEPT
   {
_M_node = _M_node->_M_prev;
return *this;
   }
 
-  _Self
+  _List_iterator
   operator--(int) _GLIBCXX_NOEXCEPT
   {
-   _Self __tmp = *this;
+   _List_iterator __tmp = *this;
_M_node = _M_node->_M_prev;
return __tmp;
   }
 
   _GLIBCXX_NODISCARD
   friend bool
-  operator==(const _Self& __x, const _Self& __y) _GLIBCXX_NOEXCEPT
+  operator==(const _List_iterator& __x,
+const _List_iterator& __y) _GLIBCXX_NOEXCEPT
   { return __x._M_node == __y._M_node; }
 
 #if __cpp_impl_three_way_comparison < 201907L
   _GLIBCXX_NODISCARD
   friend bool
-  operator!=(const _Self& __x, const _Self& __y) _GLIBCXX_NOEXCEPT
+  operator!=(const _List_iterator& __x,
+const _List_iterator& __y) _GLIBCXX_NOEXCEPT
   { return __x._M_node != __y._M_node; }
 #endif
 
@@ -340,7 +341,6 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
   template
 struct _List_const_iterator
 {
-  typedef _List_const_iterator<_Tp>_Self;
   typedef const _List_node<_Tp>_Node;
   typedef _List_iterator<_Tp>  iterator;
 
@@ -376,45 +376,47 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
   operator->() const _GLIBCXX_NOEXCEPT
   { return static_cast<_Node*>(_M_node)->_M_valptr(); }
 
-  _Self&
+  _List_const_iterator&
   operator++() _GLIBCXX_NOEXCEPT
   {
_M_node = _M_node->_M_next;
return *this;
   }
 
-  _Self
+  _List_const_iterator
   operator++(int) _GLIBCXX_NOEXCEPT
   {
-   _Self __tmp = *this;
+   _List_const_iterator __tmp = *this;
_M_node = _M_node->_M_next;
return __tmp;
   }
 
-  _Self&
+  _List_const_iterator&
   operator--() _GLIBCXX_NOEXCEPT
   {
_M_node = _M_node->_M_prev;
return *this;
   }
 
-  _Self
+  _List_const_iterator
   operator--(int) _GLIBCXX_NOEXCEPT
   {
-   _Self __tmp = *this;
+   _List_const_iterator __tmp = *this;
_M_node = _M_node->_M_prev;
return __tmp;
   }
 
   _GLIBCXX_NODISCARD
   friend bool
-  operator==(const _Self& __x, const _Self& __y) _GLIBCXX_NOEXCEPT
+  operator==(const _List_const_iterator& __x,
+const _List_const_iterator& __y) _GLIBCXX_NOEXCEPT
   { return __x._M_node == __y._M_node; }
 
 #if __cpp_impl_three_way_comparison < 201907L
   _GLIBCXX_NODISCARD
   friend bool
-  operator!=(const _Self& __x, const _Self& __y) _GLIBCXX_NOEXCEPT
+  operator!=(const _List_const_iterator& __x,
+const _List_const_iterator& __y) _GLIBCXX_NOEXCEPT
   { return __x._M_node != __y._M_node; }
 #endif


[gcc r15-5911] libstdc++: Simplify allocator propagation helpers using 'if constexpr'

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

commit r15-5911-gaa7acf6fc9251cc9bdb9a406dc58439eb54e1217
Author: Jonathan Wakely 
Date:   Mon Nov 25 21:55:09 2024 +

libstdc++: Simplify allocator propagation helpers using 'if constexpr'

Use diagnostic pragmas to allow using `if constexpr` in C++11 mode, so
that we don't need to use tag dispatching.

These helpers could be removed entirely by just using `if constexpr`
directly in the container member functions, but that's a slightly larger
change that can happen later.

It also looks like we could remove the __alloc_on_copy(const Alloc&)
overload, which is unused.

libstdc++-v3/ChangeLog:

* include/bits/alloc_traits.h (__do_alloc_on_copy): Remove.
(__do_alloc_on_move __do_alloc_on_swap): Remove.
(__alloc_on_copy, __alloc_on_move, __alloc_on_swap): Use if
constexpr.

Diff:
---
 libstdc++-v3/include/bits/alloc_traits.h | 56 ++--
 1 file changed, 3 insertions(+), 53 deletions(-)

diff --git a/libstdc++-v3/include/bits/alloc_traits.h 
b/libstdc++-v3/include/bits/alloc_traits.h
index c64f4757d5da..76d5646afe57 100644
--- a/libstdc++-v3/include/bits/alloc_traits.h
+++ b/libstdc++-v3/include/bits/alloc_traits.h
@@ -835,20 +835,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 #endif
 
   /// @cond undocumented
-#if __cplusplus < 201703L
-  template
-[[__gnu__::__always_inline__]]
-inline void
-__do_alloc_on_copy(_Alloc& __one, const _Alloc& __two, true_type)
-{ __one = __two; }
-
-  template
-[[__gnu__::__always_inline__]]
-inline void
-__do_alloc_on_copy(_Alloc&, const _Alloc&, false_type)
-{ }
-#endif
-
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wc++17-extensions" // if constexpr
   template
 [[__gnu__::__always_inline__]]
 _GLIBCXX14_CONSTEXPR inline void
@@ -857,12 +845,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   using __traits = allocator_traits<_Alloc>;
   using __pocca =
typename __traits::propagate_on_container_copy_assignment::type;
-#if __cplusplus >= 201703L
   if constexpr (__pocca::value)
__one = __two;
-#else
-  __do_alloc_on_copy(__one, __two, __pocca());
-#endif
 }
 
   template
@@ -874,18 +858,6 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   return __traits::select_on_container_copy_construction(__a);
 }
 
-#if __cplusplus < 201703L
-  template
-[[__gnu__::__always_inline__]]
-inline void __do_alloc_on_move(_Alloc& __one, _Alloc& __two, true_type)
-{ __one = std::move(__two); }
-
-  template
-[[__gnu__::__always_inline__]]
-inline void __do_alloc_on_move(_Alloc&, _Alloc&, false_type)
-{ }
-#endif
-
   template
 [[__gnu__::__always_inline__]]
 _GLIBCXX14_CONSTEXPR inline void
@@ -894,29 +866,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   using __traits = allocator_traits<_Alloc>;
   using __pocma
= typename __traits::propagate_on_container_move_assignment::type;
-#if __cplusplus >= 201703L
   if constexpr (__pocma::value)
__one = std::move(__two);
-#else
-  __do_alloc_on_move(__one, __two, __pocma());
-#endif
-}
-
-#if __cplusplus < 201703L
-  template
-[[__gnu__::__always_inline__]]
-inline void __do_alloc_on_swap(_Alloc& __one, _Alloc& __two, true_type)
-{
-  using std::swap;
-  swap(__one, __two);
 }
 
-  template
-[[__gnu__::__always_inline__]]
-inline void __do_alloc_on_swap(_Alloc&, _Alloc&, false_type)
-{ }
-#endif
-
   template
 [[__gnu__::__always_inline__]]
 _GLIBCXX14_CONSTEXPR inline void
@@ -924,16 +877,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 {
   using __traits = allocator_traits<_Alloc>;
   using __pocs = typename __traits::propagate_on_container_swap::type;
-#if __cplusplus >= 201703L
   if constexpr (__pocs::value)
{
  using std::swap;
  swap(__one, __two);
}
-#else
-  __do_alloc_on_swap(__one, __two, __pocs());
-#endif
 }
+#pragma GCC diagnostic pop
 
   template,


[gcc r15-5912] libstdc++: Fix parallel std::exclusive_scan [PR108236]

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

commit r15-5912-gcd107a6343c96c4ef26096e250d43a4a4211eced
Author: Jonathan Wakely 
Date:   Tue Dec 3 16:36:05 2024 +

libstdc++: Fix parallel std::exclusive_scan [PR108236]

The standard says that std::exclusive_scan can be used to work in
place, i.e. where the output range is the same as the input range. This
means that the first sum cannot be written to the output until after
reading the first input value, otherwise we'll already have overwritten
the first input value.

While writing a new testcase I also realised that the serial version of
std::exclusive_scan uses copy construction for the accumulator variable,
but the standard only requires Cpp17MoveConstructible. We also require
move assignable, which is missing from the standard's requirements, but
we should at least use move construction not copy construction.

A similar problem exists for some other new C++17 numeric algos, but
I'll fix the others in a subsequent commit.

libstdc++-v3/ChangeLog:

PR libstdc++/108236
* include/pstl/glue_numeric_impl.h (exclusive_scan): Pass __init
as rvalue.
* include/pstl/numeric_impl.h (__brick_transform_scan): Do not
write through __result until after reading through __first. Move
__init into return value.
(__pattern_transform_scan): Pass __init as rvalue.
* include/std/numeric (exclusive_scan): Move construct instead
of copy constructing.
* testsuite/26_numerics/exclusive_scan/2.cc: New test.
* testsuite/26_numerics/pstl/numeric_ops/108236.cc: New test.

Diff:
---
 libstdc++-v3/include/pstl/glue_numeric_impl.h  |  2 +-
 libstdc++-v3/include/pstl/numeric_impl.h   |  9 ++--
 libstdc++-v3/include/std/numeric   |  4 +-
 .../testsuite/26_numerics/exclusive_scan/2.cc  | 46 
 .../26_numerics/pstl/numeric_ops/108236.cc | 50 ++
 5 files changed, 104 insertions(+), 7 deletions(-)

diff --git a/libstdc++-v3/include/pstl/glue_numeric_impl.h 
b/libstdc++-v3/include/pstl/glue_numeric_impl.h
index 490175c8b835..10d4912deede 100644
--- a/libstdc++-v3/include/pstl/glue_numeric_impl.h
+++ b/libstdc++-v3/include/pstl/glue_numeric_impl.h
@@ -108,7 +108,7 @@ exclusive_scan(_ExecutionPolicy&& __exec, _ForwardIterator1 
__first, _ForwardIte
 
 using namespace __pstl;
 return __internal::__pattern_transform_scan(__dispatch_tag, 
std::forward<_ExecutionPolicy>(__exec), __first, __last,
-__result, 
__pstl::__internal::__no_op(), __init, __binary_op,
+__result, 
__pstl::__internal::__no_op(), std::move(__init), __binary_op,
 
/*inclusive=*/std::false_type());
 }
 
diff --git a/libstdc++-v3/include/pstl/numeric_impl.h 
b/libstdc++-v3/include/pstl/numeric_impl.h
index 7ba83eeb7149..e1ebec160398 100644
--- a/libstdc++-v3/include/pstl/numeric_impl.h
+++ b/libstdc++-v3/include/pstl/numeric_impl.h
@@ -160,11 +160,12 @@ __brick_transform_scan(_ForwardIterator __first, 
_ForwardIterator __last, _Outpu
 {
 for (; __first != __last; ++__first, ++__result)
 {
-*__result = __init;
+   _Tp __v = std::move(__init);
 _PSTL_PRAGMA_FORCEINLINE
-__init = __binary_op(__init, __unary_op(*__first));
+__init = __binary_op(__v, __unary_op(*__first));
+*__result = std::move(__v);
 }
-return std::make_pair(__result, __init);
+return std::make_pair(__result, std::move(__init));
 }
 
 // Inclusive form
@@ -225,7 +226,7 @@ __pattern_transform_scan(_Tag, _ExecutionPolicy&&, 
_ForwardIterator __first, _Fo
  _OutputIterator __result, _UnaryOperation __unary_op, 
_Tp __init, _BinaryOperation __binary_op,
  _Inclusive) noexcept
 {
-return __internal::__brick_transform_scan(__first, __last, __result, 
__unary_op, __init, __binary_op, _Inclusive(),
+return __internal::__brick_transform_scan(__first, __last, __result, 
__unary_op, std::move(__init), __binary_op, _Inclusive(),
   typename _Tag::__is_vector{})
 .first;
 }
diff --git a/libstdc++-v3/include/std/numeric b/libstdc++-v3/include/std/numeric
index dd98f40c7a83..37579c589e18 100644
--- a/libstdc++-v3/include/std/numeric
+++ b/libstdc++-v3/include/std/numeric
@@ -491,8 +491,8 @@ namespace __detail
 {
   while (__first != __last)
{
- auto __v = __init;
- __init = __binary_op(__init, *__first);
+ _Tp __v = std::move(__init);
+ __init = __binary_op(__v, *__first);
  ++__first;
  *__result++ = std::move(__v);
}
diff --git a/libstdc++-v3/testsuite/26_numerics/exclusive_scan/2.cc 
b/lib

[gcc r15-5913] Rectify some test cases.

2024-12-03 Thread Georg-Johann Lay via Gcc-cvs
https://gcc.gnu.org/g:846c0b397b5c1b4ff6c68d83af99aff2aa80a162

commit r15-5913-g846c0b397b5c1b4ff6c68d83af99aff2aa80a162
Author: Georg-Johann Lay 
Date:   Tue Dec 3 11:32:30 2024 +0100

Rectify some test cases.

PR testsuite/52641
PR testsuite/109123
PR testsuite/114661
PR testsuite/117828
PR testsuite/116481
PR testsuite/91069
gcc/testsuite/
* gcc.dg/Wuse-after-free-pr109123.c: Use size_t
instead of long unsigned int.
* gcc.dg/c23-tag-bitfields-1.c: Requires int32plus.
* gcc.dg/pr114661.c: Same.
* gcc.dg/pr117828.c: Same.
* gcc.dg/flex-array-counted-by-2.c: Use uintptr_t
instead of unsigned long.
* gcc.dg/pr116481.c: Same.
* gcc.dg/lto/tag-1_0.c: Use int32_t instead of int.
* gcc.dg/lto/tag-1_1.c: Use int16_t instead of short.
* gcc.dg/pr91069.c: Require double64.
* gcc.dg/type-convert-var.c: Require double64plus.

Diff:
---
 gcc/testsuite/gcc.dg/Wuse-after-free-pr109123.c | 2 +-
 gcc/testsuite/gcc.dg/c23-tag-bitfields-1.c  | 1 +
 gcc/testsuite/gcc.dg/flex-array-counted-by-2.c  | 8 +---
 gcc/testsuite/gcc.dg/lto/tag-1_0.c  | 2 +-
 gcc/testsuite/gcc.dg/lto/tag-1_1.c  | 2 +-
 gcc/testsuite/gcc.dg/pr114661.c | 1 +
 gcc/testsuite/gcc.dg/pr116481.c | 3 ++-
 gcc/testsuite/gcc.dg/pr117828.c | 1 +
 gcc/testsuite/gcc.dg/pr91069.c  | 3 ++-
 gcc/testsuite/gcc.dg/type-convert-var.c | 2 ++
 10 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/gcc/testsuite/gcc.dg/Wuse-after-free-pr109123.c 
b/gcc/testsuite/gcc.dg/Wuse-after-free-pr109123.c
index ece066dd28be..8e6fc3aa014e 100644
--- a/gcc/testsuite/gcc.dg/Wuse-after-free-pr109123.c
+++ b/gcc/testsuite/gcc.dg/Wuse-after-free-pr109123.c
@@ -1,7 +1,7 @@
 /* { dg-do compile } */
 /* { dg-options "-O2 -Wall" } */
 
-typedef long unsigned int size_t;
+typedef __SIZE_TYPE__ size_t;
 extern void *realloc (void *__ptr, size_t __size)
  __attribute__ ((__nothrow__ , __leaf__)) __attribute__ 
((__warn_unused_result__)) __attribute__ ((__alloc_size__ (2)));
 struct vector_objective; 
diff --git a/gcc/testsuite/gcc.dg/c23-tag-bitfields-1.c 
b/gcc/testsuite/gcc.dg/c23-tag-bitfields-1.c
index d775d9f67a13..8ee8d47586c2 100644
--- a/gcc/testsuite/gcc.dg/c23-tag-bitfields-1.c
+++ b/gcc/testsuite/gcc.dg/c23-tag-bitfields-1.c
@@ -1,5 +1,6 @@
 /* { dg-do compile } */
 /* { dg-options "-std=c23" } */
+/* { dg-require-effective-target int32plus } */
 
 struct bar0 { int r : 16; };
 struct bar0 { int r : 16; };
diff --git a/gcc/testsuite/gcc.dg/flex-array-counted-by-2.c 
b/gcc/testsuite/gcc.dg/flex-array-counted-by-2.c
index d4899a63af3c..42d6436cec2c 100644
--- a/gcc/testsuite/gcc.dg/flex-array-counted-by-2.c
+++ b/gcc/testsuite/gcc.dg/flex-array-counted-by-2.c
@@ -5,6 +5,8 @@
 
 #include 
 
+typedef __UINTPTR_TYPE__ uintptr_t;
+
 struct annotated {
   int b;
   char c[] __attribute__ ((counted_by (b)));
@@ -86,10 +88,10 @@ void __attribute__((__noinline__)) test (char a, char b)
   if (__alignof (array_nested_annotated->c) != __alignof (char))
 abort ();
 
-  if ((unsigned long) array_annotated->c != (unsigned long) 
&array_annotated->c)
+  if ((uintptr_t) array_annotated->c != (uintptr_t) &array_annotated->c)
 abort ();
-  if ((unsigned long) array_nested_annotated->c
-   != (unsigned long) &array_nested_annotated->c)
+  if ((uintptr_t) array_nested_annotated->c
+   != (uintptr_t) &array_nested_annotated->c)
 abort ();
 
   array_annotated->c[2] = a;
diff --git a/gcc/testsuite/gcc.dg/lto/tag-1_0.c 
b/gcc/testsuite/gcc.dg/lto/tag-1_0.c
index c9b0c719f4e4..87ca7fa5d08e 100644
--- a/gcc/testsuite/gcc.dg/lto/tag-1_0.c
+++ b/gcc/testsuite/gcc.dg/lto/tag-1_0.c
@@ -1,5 +1,5 @@
 /* { dg-lto-do link } */
 /* { dg-lto-options { { -Wodr -flto } } }  */
 
-struct foo { int x; };
+struct foo { __INT32_TYPE__ x; };
 struct foo a = {};
diff --git a/gcc/testsuite/gcc.dg/lto/tag-1_1.c 
b/gcc/testsuite/gcc.dg/lto/tag-1_1.c
index 443f91098110..3c6db5a37ecf 100644
--- a/gcc/testsuite/gcc.dg/lto/tag-1_1.c
+++ b/gcc/testsuite/gcc.dg/lto/tag-1_1.c
@@ -1,4 +1,4 @@
-struct foo { short x; };
+struct foo { __INT16_TYPE__ x; };
 
 extern struct foo a; /* { dg-lto-warning {type of 'a' does not match original 
declaration} } */
 struct foo *ptr = &a;
diff --git a/gcc/testsuite/gcc.dg/pr114661.c b/gcc/testsuite/gcc.dg/pr114661.c
index e6b5c69dba86..8ea3f8d7d47b 100644
--- a/gcc/testsuite/gcc.dg/pr114661.c
+++ b/gcc/testsuite/gcc.dg/pr114661.c
@@ -1,5 +1,6 @@
 /* { dg-do compile } */
 /* { dg-options "-O2 -fdump-tree-evrp" } */
+/* { dg-require-effective-target int32plus } */
 
 unsigned mul(unsigned char c) {
 if (c > 3) __builtin_unreachable();
diff --git a/gcc/testsuite/gcc.dg/pr116481.c b/gcc/testsuite/gcc.dg/pr116481.c
index 3ee6d7470876..29896ba0d

[gcc r15-5916] phiopt: Reset the number of iterations information of a loop when changing an exit from the loop [PR

2024-12-03 Thread Andrew Pinski via Gcc-cvs
https://gcc.gnu.org/g:b7c69cc072ef0da36439ebc55c513b48e68391b7

commit r15-5916-gb7c69cc072ef0da36439ebc55c513b48e68391b7
Author: Andrew Pinski 
Date:   Mon Dec 2 08:35:23 2024 -0800

phiopt: Reset the number of iterations information of a loop when changing 
an exit from the loop [PR117243]

After r12-5300-gf98f373dd822b3, phiopt could get the following bb structure:
  |
middle-bb -|
  ||
  |   ||   |
phi<1, 2>  |   |
cond   |   |
  ||   |
  |+---|

Which was considered 2 loops. The inner loop had esimtate of upper_bound to 
be 8,
due to the original `for (b = 0; b <= 7; b++)`. The outer loop was already 
an
infinite one.
So phiopt would come along and change the condition to be unconditionally 
true,
we change the inner loop to being an infinite one but don't reset the 
estimate
on the loop and cleanup cfg comes along and changes it into one loop but 
also
does not reset the estimate of the loop. Then the loop unrolling uses the 
old estimate
and decides to add an unreachable there.o
So the fix is when phiopt changes an exit to a loop, reset the estimates, 
similar to
how cleanupcfg does it when merging some basic blocks.

Bootstrapped and tested on x86_64-linux-gnu.

PR tree-optimization/117243
PR tree-optimization/116749

gcc/ChangeLog:

* tree-ssa-phiopt.cc (replace_phi_edge_with_variable): Reset loop
estimates if the cond_block was an exit to a loop.

gcc/testsuite/ChangeLog:

* gcc.dg/torture/pr117243-1.c: New test.
* gcc.dg/torture/pr117243-2.c: New test.

Signed-off-by: Andrew Pinski 

Diff:
---
 gcc/testsuite/gcc.dg/torture/pr117243-1.c | 30 +++
 gcc/testsuite/gcc.dg/torture/pr117243-2.c | 34 +++
 gcc/tree-ssa-phiopt.cc| 11 ++
 3 files changed, 75 insertions(+)

diff --git a/gcc/testsuite/gcc.dg/torture/pr117243-1.c 
b/gcc/testsuite/gcc.dg/torture/pr117243-1.c
new file mode 100644
index ..c4bbc31467c5
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr117243-1.c
@@ -0,0 +1,30 @@
+/* { dg-do compile } */
+/* { dg-options "-fdump-tree-optimized" } */
+/* { dg-skip-if "" { *-*-* } { "-fno-fat-lto-objects" } { "" } } */
+
+/* PR tree-optimization/117243 */
+/* foo should be an infinite but sometimes it gets optimized incorrectly into
+   an __builtin_unreachable(); which is not valid.  */
+void
+foo (unsigned int a, unsigned char b)
+{
+  lbl:
+  for (b = 0; b <= 7; b++)
+{
+  unsigned char c[1][1];
+  int i, j;
+  for (i = 0; i < 1; i++)
+for (j = 0; j < 1; j++)
+  c[i][j] = 1;
+  if (b)
+   goto lbl;
+}
+}
+
+int
+main ()
+{
+  foo (1, 2);
+}
+
+/* { dg-final { scan-tree-dump-not "__builtin_unreachable " "optimized"} } */
diff --git a/gcc/testsuite/gcc.dg/torture/pr117243-2.c 
b/gcc/testsuite/gcc.dg/torture/pr117243-2.c
new file mode 100644
index ..d9b0d3eeb982
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr117243-2.c
@@ -0,0 +1,34 @@
+/* { dg-do compile } */
+/* { dg-options "-fno-tree-ch -fdump-tree-optimized" } */
+/* { dg-skip-if "" { *-*-* } { "-fno-fat-lto-objects" } { "" } } */
+
+/* PR tree-optimization/117243 */
+/* PR tree-optimization/116749 */
+
+/* main1 should be an infinite but sometimes it gets optimized incorrectly into
+   an __builtin_unreachable(); which is not valid.  */
+int main1 (void)
+{
+int g=0;
+int l1[1];
+int *l2 = &g;
+int i;
+for (i=0; i<1; i++)
+l1[i] = (1);
+for (g=0; g; ++g)
+{
+int *l3[1] = {&l1[0]};
+}
+*l2 = *l1;
+b:
+for (i=0; i<2; ++i)
+{ 
+if (i)
+goto b;
+if (g)
+continue;
+}
+return 0;
+}
+
+/* { dg-final { scan-tree-dump-not "__builtin_unreachable " "optimized"} } */
diff --git a/gcc/tree-ssa-phiopt.cc b/gcc/tree-ssa-phiopt.cc
index 15651809d71b..d7b7c7467c19 100644
--- a/gcc/tree-ssa-phiopt.cc
+++ b/gcc/tree-ssa-phiopt.cc
@@ -55,6 +55,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "tree-ssa-propagate.h"
 #include "tree-ssa-dce.h"
 #include "calls.h"
+#include "tree-ssa-loop-niter.h"
 
 /* Return the singleton PHI in the SEQ of PHIs for edges E0 and E1. */
 
@@ -152,6 +153,16 @@ replace_phi_edge_with_variable (basic_block cond_block,
   else
 gcc_unreachable ();
 
+  /* If we are removing the cond on a loop exit,
+ reset number of iteration information of the loop. */
+  if (loop_exits_from_bb_p (cond_block->loop_father, cond_block))
+{
+  auto loop = cond_block->loop_father;
+  free_numbers_of_iterations_estimates (loop);
+  loop->any_upper_bound = false;
+  loop->any_likely_upper_bound = false;
+}
+
   if (edge_to_remove && EDGE_COUNT (edge_to_remove->dest->preds) == 1)
 {

[gcc r15-5900] Update gcc zh_CN.po

2024-12-03 Thread Joseph Myers via Gcc-cvs
https://gcc.gnu.org/g:0b01549916d7526d27d652cbea1f448399fcee33

commit r15-5900-g0b01549916d7526d27d652cbea1f448399fcee33
Author: Joseph Myers 
Date:   Tue Dec 3 18:27:03 2024 +

Update gcc zh_CN.po

* zh_CN.po: Update.

Diff:
---
 gcc/po/zh_CN.po | 501 
 1 file changed, 212 insertions(+), 289 deletions(-)

diff --git a/gcc/po/zh_CN.po b/gcc/po/zh_CN.po
index c03d3f290a9b..5cead23a97ce 100644
--- a/gcc/po/zh_CN.po
+++ b/gcc/po/zh_CN.po
@@ -36,7 +36,7 @@ msgstr ""
 "Project-Id-Version: gcc 14.2.0\n"
 "Report-Msgid-Bugs-To: https://gcc.gnu.org/bugs/\n";
 "POT-Creation-Date: 2024-07-25 16:23+\n"
-"PO-Revision-Date: 2024-09-15 10:21+0800\n"
+"PO-Revision-Date: 2024-12-03 09:31+0800\n"
 "Last-Translator: Zhanhaoxiang Zhang \n"
 "Language-Team: Chinese (simplified) \n"
 "Language: zh_CN\n"
@@ -19268,11 +19268,11 @@ msgstr "编译中断。\n"
 
 #: diagnostic.cc:881
 msgid " from"
-msgstr "  从"
+msgstr "于"
 
 #: diagnostic.cc:882
 msgid "In file included from"
-msgstr ""
+msgstr "包含于文件"
 
 #. 2
 #: diagnostic.cc:883
@@ -19281,7 +19281,7 @@ msgstr "包含自"
 
 #: diagnostic.cc:884
 msgid "In module"
-msgstr ""
+msgstr "在模块中"
 
 #. 4
 #: diagnostic.cc:885
@@ -19290,12 +19290,12 @@ msgstr ""
 
 #: diagnostic.cc:886
 msgid "In module imported at"
-msgstr ""
+msgstr "在此处导入的模块中"
 
 #. 6
 #: diagnostic.cc:887
 msgid "imported at"
-msgstr ""
+msgstr "在此导入"
 
 #: diagnostic.cc:1592
 #, c-format
@@ -22946,22 +22946,16 @@ msgid "In static member function %qD"
 msgstr "在静态成员函数%qs中"
 
 #: cp/error.cc:3705
-#, fuzzy
-#| msgid "In copy constructor %qs"
 msgid "In copy constructor %qD"
-msgstr "在复制构造函数%qs"
+msgstr "在复制构造函数%qD"
 
 #: cp/error.cc:3707
-#, fuzzy
-#| msgid "In constructor %qs"
 msgid "In constructor %qD"
-msgstr "在构造函数%qs中"
+msgstr "在构造函数%qD中"
 
 #: cp/error.cc:3709
-#, fuzzy
-#| msgid "In destructor %qs"
 msgid "In destructor %qD"
-msgstr "在析构函数%qs中"
+msgstr "在析构函数%qD中"
 
 #: cp/error.cc:3711
 msgid "In lambda function"
@@ -22980,10 +22974,8 @@ msgid "In member function %qD"
 msgstr "在成员函数%qs中"
 
 #: cp/error.cc:3718
-#, fuzzy
-#| msgid "In function %qs"
 msgid "In function %qD"
-msgstr "在函数%qs中"
+msgstr "在函数%qD中"
 
 #: cp/error.cc:3741
 #, fuzzy, c-format
@@ -22991,9 +22983,8 @@ msgid "%s: In substitution of %qS:\n"
 msgstr "空动态字符串替换"
 
 #: cp/error.cc:3742
-#, fuzzy
 msgid "%s: In instantiation of %q#D:\n"
-msgstr "对%q#D的显式实例化"
+msgstr "%s: 在%q#D的实例化中: \n"
 
 #: cp/error.cc:3767 cp/error.cc:3925
 msgid "%r%s:%d:%d:%R   "
@@ -23019,9 +23010,8 @@ msgid "recursively required from %q#D\n"
 msgstr "与先前的声明%q+D不同"
 
 #: cp/error.cc:3785
-#, fuzzy
 msgid "required from %q#D\n"
-msgstr "与先前的声明%q+D不同"
+msgstr "在 %q#D 中的要求\n"
 
 #: cp/error.cc:3792
 #, fuzzy
@@ -23029,9 +23019,8 @@ msgid "recursively required from here\n"
 msgstr "从此处调用"
 
 #: cp/error.cc:3793
-#, fuzzy
 msgid "required from here\n"
-msgstr "从此处调用"
+msgstr "在此处的要求\n"
 
 #: cp/error.cc:3849
 #, fuzzy
@@ -26600,10 +26589,9 @@ msgid "%q+F declared % but never defined"
 msgstr "%q+F声明为%却从未定义过"
 
 #: cgraphunit.cc:1144
-#, fuzzy, gcc-internal-format
-#| msgid "%q+D defined but not used"
+#, gcc-internal-format
 msgid "%qD defined but not used"
-msgstr "%q+D定义后未使用"
+msgstr "%qD 在此处定义"
 
 #: cgraphunit.cc:1479
 #, fuzzy, gcc-internal-format
@@ -29586,7 +29574,7 @@ msgstr ""
 #: gimplify.cc:2764
 #, gcc-internal-format
 msgid "here"
-msgstr ""
+msgstr "此处"
 
 #. We've found [[fallthrough]]; at the end of a switch, which the C++
 #. standard says is ill-formed; see [dcl.attr.fallthrough].
@@ -34011,9 +33999,9 @@ msgid "in definition of macro %qs"
 msgstr "%qs后缺少宏名"
 
 #: tree-diagnostic.cc:224
-#, fuzzy, gcc-internal-format
+#, gcc-internal-format
 msgid "in expansion of macro %qs"
-msgstr "印出 EXPR 的宏展开"
+msgstr "在宏 %qs 展开时"
 
 #: tree-eh.cc:4946
 #, gcc-internal-format, gfc-internal-format
@@ -34735,14 +34723,14 @@ msgid "tree check: accessed operand %d of 
% with %d operands in
 msgstr "树检查:在 %4$s 中访问有 %3$d 个操作数的 omp_clause %2$s 的第 %1$d 个操作数,于 %5$s:%6$d"
 
 #: tree.cc:12476
-#, fuzzy, gcc-internal-format
+#, gcc-internal-format
 msgid "%qD is deprecated: %s"
-msgstr "已弃用%qE:%s"
+msgstr "%qD 已被弃用: %s"
 
 #: tree.cc:12479
-#, fuzzy, gcc-internal-format
+#, gcc-internal-format
 msgid "%qD is deprecated"
-msgstr "已弃用%qE"
+msgstr "%qD 已被弃用"
 
 #: tree.cc:12502
 #, gcc-internal-format
@@ -35246,9 +35234,9 @@ msgid "invalid initial value for member %qE"
 msgstr "成员%qE的初始值无效"
 
 #: varasm.cc:5981
-#, fuzzy, gcc-internal-format
+#, gcc-internal-format
 msgid "%qD declared weak after being used"
-msgstr "%q+D声明为友元"
+msgstr "%qD 在使用后被声明为弱符号"
 
 #: varasm.cc:6033
 #, fuzzy, gcc-internal-format
@@ -36060,9 +36048,9 @@ msgid "%qE argument not an identifier"
 msgstr "cleanup 实参不是一个标识符"
 
 #: c-family/c-attribs.cc:4396
-#, fuzzy, gcc-internal-format
+#, gcc-internal-format
 msgid "%qD is not compatible with %qD"
-msgstr "选择%qD而不是%qD"
+msgstr "%qD 与 %qD 不兼容"
 
 #: c-family

[gcc r15-5903] c++/contracts: ICE with contract assert on non-empty statement [PR 117579]

2024-12-03 Thread Jason Merrill via Gcc-cvs
https://gcc.gnu.org/g:3b0fca5835b92ca7b139ef9f06d16b65510568ef

commit r15-5903-g3b0fca5835b92ca7b139ef9f06d16b65510568ef
Author: Nina Ranns 
Date:   Tue Dec 3 14:58:21 2024 +

c++/contracts: ICE with contract assert on non-empty statement [PR 117579]

Contract assert is an attribute on an empty statement. Currently we assert
that the statement is empty before emitting the assertion. This has been
changed to a conditional check that the statement is empty before the
assertion is emitted.

PR c++/117579

gcc/cp/ChangeLog:

* parser.cc (cp_parser_statement): Replace assertion with a
conditional check that the statement containing a contract assert
is empty.

gcc/testsuite/ChangeLog:

* g++.dg/contracts/pr117579.C: New test.

Signed-off-by: Nina Ranns 
Reviewed-by: Jason Merrill 

Diff:
---
 gcc/cp/parser.cc  | 6 --
 gcc/testsuite/g++.dg/contracts/pr117579.C | 9 +
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc
index e583649bc937..2995a11c60fe 100644
--- a/gcc/cp/parser.cc
+++ b/gcc/cp/parser.cc
@@ -13164,8 +13164,10 @@ cp_parser_statement (cp_parser* parser, tree 
in_statement_expr,
   if (cp_contract_assertion_p (std_attrs))
{
  /* Add the assertion as a statement in the current block.  */
- gcc_assert (!statement || statement == error_mark_node);
- emit_assertion (std_attrs);
+ if (!statement)
+   emit_assertion (std_attrs);
+ /* We already checked that the contract assertion is followed by
+  a semicolon.  */
  std_attrs = NULL_TREE;
}
 }
diff --git a/gcc/testsuite/g++.dg/contracts/pr117579.C 
b/gcc/testsuite/g++.dg/contracts/pr117579.C
new file mode 100644
index ..8878de8f23d4
--- /dev/null
+++ b/gcc/testsuite/g++.dg/contracts/pr117579.C
@@ -0,0 +1,9 @@
+// Check that contract assertion on a non-empty statement doesn't cause an
+// ICE.
+// { dg-options "-std=c++2a -fcontracts " }
+
+void f();
+int main ()
+{
+  [[assert: true]] f(); // { dg-error "assertions must be followed by" }
+}


[gcc r15-5902] maintainer-scripts: build the libgdiagnostics docs for the website [PR117883]

2024-12-03 Thread David Malcolm via Gcc-cvs
https://gcc.gnu.org/g:e6e4cb34e30f25adfb57e998663a8a1796b8573c

commit r15-5902-ge6e4cb34e30f25adfb57e998663a8a1796b8573c
Author: David Malcolm 
Date:   Tue Dec 3 13:53:46 2024 -0500

maintainer-scripts: build the libgdiagnostics docs for the website 
[PR117883]

maintainer-scripts/ChangeLog:
PR web/117883
* update_web_docs_git: Introduce SPHINX_VENV to make
it easier to test the script.  Add the libgdiagnostics docs
and testsuite to the files to be preserved.  Use sphinx to build
the libgdiagnostics docs as HTML.  Copy them into $DOCSDIR.

Signed-off-by: David Malcolm 

Diff:
---
 maintainer-scripts/update_web_docs_git | 26 +++---
 1 file changed, 19 insertions(+), 7 deletions(-)

diff --git a/maintainer-scripts/update_web_docs_git 
b/maintainer-scripts/update_web_docs_git
index 77210f961cf4..8ff34f86f65d 100755
--- a/maintainer-scripts/update_web_docs_git
+++ b/maintainer-scripts/update_web_docs_git
@@ -14,6 +14,10 @@ export GITROOT
 
 PATH=/usr/local/bin:$PATH
 
+# We use a copy of Sphinx installed in a virtual environment so that
+# we don't depend on a system package.
+SPHINX_VENV=${SPHINX_VENV:-"/home/gccadmin/venv"}
+
 makeinfo_git=/home/gccadmin/texinfo/install-git/bin/
 if [ -x "${makeinfo_git}"/makeinfo ]; then
 : "${MAKEINFO:=${makeinfo_git}/makeinfo}"
@@ -138,7 +142,7 @@ rm -rf gcc/.git
 # Note that we have to preserve gcc/jit/docs since the jit docs are
 # not .texi files (Makefile, .rst and .png), and the jit docs use
 # include directives to pull in content from jit/jit-common.h and
-# jit/notes.txt, and from the testsuite, so we have to preserve those also.
+# Similar considerations apply for libgdiagnostics.
 find gcc -type f \( -name '*.texi' \
   -o -path gcc/gcc/doc/install.texi2html \
   -o -path gcc/gcc/doc/include/texinfo.tex \
@@ -149,6 +153,8 @@ find gcc -type f \( -name '*.texi' \
   -o -path "gcc/gcc/jit/jit-common.h" \
   -o -path "gcc/gcc/jit/notes.txt" \
   -o -path "gcc/gcc/testsuite/jit.dg/*" \
+  -o -path "gcc/gcc/doc/libgdiagnostics/*" \
+  -o -path "gcc/gcc/testsuite/libgdiagnostics.dg/*" \
   -o -print0 \) | xargs -0 rm -f
 
 # Build a tarball of the sources.
@@ -194,18 +200,24 @@ for file in $MANUALS; do
   fi
 done
 
-# The jit is a special-case, using Sphinx rather than texinfo.
-# Specifically, the jit docs need Sphinx 3.0 or later.
+# jit and libgdiagnostics are a special-case, using Sphinx rather than texinfo.
+# Specifically, they need Sphinx 3.0 or later.
 #
 # Use the Sphinx installed in a virtual environment so that
 # we don't depend on a system package.
 
 pushd gcc/gcc/jit/docs
-make html SPHINXBUILD=/home/gccadmin/venv/bin/sphinx-build || true
+make html SPHINXBUILD=$SPHINX_VENV/bin/sphinx-build || true
 popd
 cp -a gcc/gcc/jit/docs/_build/html jit
 mkdir -p $DOCSDIR/jit
 
+pushd gcc/gcc/doc/libgdiagnostics
+make html SPHINXBUILD=$SPHINX_VENV/bin/sphinx-build || true
+popd
+cp -a gcc/gcc/doc/libgdiagnostics/_build/html libgdiagnostics
+mkdir -p $DOCSDIR/libgdiagnostics
+
 # Work around makeinfo generated file names and references with
 # "_002d" instead of "-".
 find . -name '*.html' | while read f; do
@@ -252,11 +264,11 @@ for file in */*.html *.ps *.pdf *.tar; do
   fi
 done
 
-# Again, the jit is a special case, with nested subdirectories
-# below "jit", and with some non-HTML files (.png images from us,
+# Again, jit and libgdignostics are special cases, with nested subdirectories
+# below them, and with some non-HTML files (.png images from us,
 # plus .css and .js supplied by sphinx, and source files, renamed
 # from .rst to .txt).
-find jit \
+find jit libgdiagnostics \
 -name "*.html" -o -name "*.png" \
 -o -name "*.css" -o -name "*.js" \
 -o -name "*.txt" |


[gcc r15-5901] maintainer-scripts: fix jit docs on website

2024-12-03 Thread David Malcolm via Gcc-cvs
https://gcc.gnu.org/g:168f938b8f2aab5c0443b02404d004ed4298651f

commit r15-5901-g168f938b8f2aab5c0443b02404d004ed4298651f
Author: David Malcolm 
Date:   Tue Dec 3 13:53:42 2024 -0500

maintainer-scripts: fix jit docs on website

I noticed whilst working on the libgdiagnostics docs
that some errors like this were occurring in the jit docs:

/tmp/gcc-doc-update.3782849/gcc/gcc/jit/docs/cp/topics/asm.rst:63: WARNING: 
Include file '/tmp/gcc-doc-update.3782849/gcc/gcc/testsuite/jit.dg/test-asm.cc' 
not found or reading it failed

which was occurring for:
* test-asm.c and .cc
* test-switch.c
* test-accessing-union.c

and indeed https://gcc.gnu.org/onlinedocs/jit/topics/asm.html is
currently missing various code examples.

Fixed thusly; tested locally.

maintainer-scripts/ChangeLog:
* update_web_docs_git: Add the jit testsuite to the files to
be preserved, since this is used by the jit docs.

Signed-off-by: David Malcolm 

Diff:
---
 maintainer-scripts/update_web_docs_git | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/maintainer-scripts/update_web_docs_git 
b/maintainer-scripts/update_web_docs_git
index 0d7b6c90fe9c..77210f961cf4 100755
--- a/maintainer-scripts/update_web_docs_git
+++ b/maintainer-scripts/update_web_docs_git
@@ -138,7 +138,7 @@ rm -rf gcc/.git
 # Note that we have to preserve gcc/jit/docs since the jit docs are
 # not .texi files (Makefile, .rst and .png), and the jit docs use
 # include directives to pull in content from jit/jit-common.h and
-# jit/notes.txt, so we have to preserve those also.
+# jit/notes.txt, and from the testsuite, so we have to preserve those also.
 find gcc -type f \( -name '*.texi' \
   -o -path gcc/gcc/doc/install.texi2html \
   -o -path gcc/gcc/doc/include/texinfo.tex \
@@ -148,6 +148,7 @@ find gcc -type f \( -name '*.texi' \
   -o -path "gcc/gcc/jit/docs/*" \
   -o -path "gcc/gcc/jit/jit-common.h" \
   -o -path "gcc/gcc/jit/notes.txt" \
+  -o -path "gcc/gcc/testsuite/jit.dg/*" \
   -o -print0 \) | xargs -0 rm -f
 
 # Build a tarball of the sources.


[gcc r15-5915] Fortran: Fix B64.0 formatted write output.

2024-12-03 Thread Jerry DeLisle via Gcc-cvs
https://gcc.gnu.org/g:7a92ba766815c9a6b73593967a26fdfbebfc7e69

commit r15-5915-g7a92ba766815c9a6b73593967a26fdfbebfc7e69
Author: Jerry DeLisle 
Date:   Tue Dec 3 20:55:41 2024 -0800

Fortran: Fix B64.0 formatted write output.

PR fortran/117820

libgfortran/ChangeLog:

* io/write.c (write_b): Add test for zero needed by write_boz.

gcc/testsuite/ChangeLog:

* gfortran.dg/pr117820.f90: New test.

Diff:
---
 gcc/testsuite/gfortran.dg/pr117820.f90 | 10 ++
 libgfortran/io/write.c |  4 
 2 files changed, 14 insertions(+)

diff --git a/gcc/testsuite/gfortran.dg/pr117820.f90 
b/gcc/testsuite/gfortran.dg/pr117820.f90
new file mode 100644
index ..59a4b363e056
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr117820.f90
@@ -0,0 +1,10 @@
+! { dg-do run }
+! See pr117820, original testcase provided by Malcolm Cohen.
+program test
+  integer(8) :: x
+  character(80) :: output
+  output = "garbage"
+  x = ibset (0_8, 63)
+  write(output, '("<",B64.0,">")') x
+  if (output .ne. 
"<1000>") stop 1
+end program
diff --git a/libgfortran/io/write.c b/libgfortran/io/write.c
index 2f414c6b57d2..ccb2b5cb810a 100644
--- a/libgfortran/io/write.c
+++ b/libgfortran/io/write.c
@@ -1392,6 +1392,10 @@ write_b (st_parameter_dt *dtp, const fnode *f, const 
char *source, int len)
 {
   n = extract_uint (source, len);
   p = btoa (n, itoa_buf, sizeof (itoa_buf));
+
+  /* Test for zero. Needed by write_boz.  */
+  if (n != 0)
+   n = 1;
   write_boz (dtp, f, p, n, len);
 }
 }


[gcc r15-5899] RISC-V: Fix test target selector

2024-12-03 Thread Edwin Lu via Gcc-cvs
https://gcc.gnu.org/g:eee3182e1af633f99e5264854cb6b5c00ce7a5dd

commit r15-5899-geee3182e1af633f99e5264854cb6b5c00ce7a5dd
Author: Edwin Lu 
Date:   Mon Dec 2 17:29:55 2024 -0800

RISC-V: Fix test target selector

The previous target selector was not properly gating the tests to rv32
and rv64 targets. This was triggering an excess failure on rv32 targets
where it would try to run the zbc64 tests. Fix selector

gcc/testsuite/ChangeLog:

* gcc.target/riscv/crc-builtin-zbc32.c: Fix selector.
* gcc.target/riscv/crc-builtin-zbc64.c: Ditto.

Signed-off-by: Edwin Lu 

Diff:
---
 gcc/testsuite/gcc.target/riscv/crc-builtin-zbc32.c | 2 +-
 gcc/testsuite/gcc.target/riscv/crc-builtin-zbc64.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/gcc/testsuite/gcc.target/riscv/crc-builtin-zbc32.c 
b/gcc/testsuite/gcc.target/riscv/crc-builtin-zbc32.c
index 3eb4be78dcb5..ca90feaef26b 100644
--- a/gcc/testsuite/gcc.target/riscv/crc-builtin-zbc32.c
+++ b/gcc/testsuite/gcc.target/riscv/crc-builtin-zbc32.c
@@ -1,4 +1,4 @@
-/* { dg-do compile { target { riscv32*-*-* } } } */
+/* { dg-do compile { target { rv32 } } } */
 /* { dg-options "-march=rv32gc_zbc" } */
 
 #include 
diff --git a/gcc/testsuite/gcc.target/riscv/crc-builtin-zbc64.c 
b/gcc/testsuite/gcc.target/riscv/crc-builtin-zbc64.c
index d99a78daaa93..f31a8bd949f5 100644
--- a/gcc/testsuite/gcc.target/riscv/crc-builtin-zbc64.c
+++ b/gcc/testsuite/gcc.target/riscv/crc-builtin-zbc64.c
@@ -1,4 +1,4 @@
-/* { dg-do compile { target { riscv64*-*-* } } } */
+/* { dg-do compile { target { rv64 } } } */
 /* { dg-options "-march=rv64gc_zbc" } */
 
 #include 


[gcc r14-11054] Update gcc zh_CN.po

2024-12-03 Thread Joseph Myers via Gcc-cvs
https://gcc.gnu.org/g:92014ea7ca9d10d1b07eeb03b4f701bc249de311

commit r14-11054-g92014ea7ca9d10d1b07eeb03b4f701bc249de311
Author: Joseph Myers 
Date:   Tue Dec 3 18:28:09 2024 +

Update gcc zh_CN.po

* zh_CN.po: Update.

Diff:
---
 gcc/po/zh_CN.po | 501 
 1 file changed, 212 insertions(+), 289 deletions(-)

diff --git a/gcc/po/zh_CN.po b/gcc/po/zh_CN.po
index c03d3f290a9b..5cead23a97ce 100644
--- a/gcc/po/zh_CN.po
+++ b/gcc/po/zh_CN.po
@@ -36,7 +36,7 @@ msgstr ""
 "Project-Id-Version: gcc 14.2.0\n"
 "Report-Msgid-Bugs-To: https://gcc.gnu.org/bugs/\n";
 "POT-Creation-Date: 2024-07-25 16:23+\n"
-"PO-Revision-Date: 2024-09-15 10:21+0800\n"
+"PO-Revision-Date: 2024-12-03 09:31+0800\n"
 "Last-Translator: Zhanhaoxiang Zhang \n"
 "Language-Team: Chinese (simplified) \n"
 "Language: zh_CN\n"
@@ -19268,11 +19268,11 @@ msgstr "编译中断。\n"
 
 #: diagnostic.cc:881
 msgid " from"
-msgstr "  从"
+msgstr "于"
 
 #: diagnostic.cc:882
 msgid "In file included from"
-msgstr ""
+msgstr "包含于文件"
 
 #. 2
 #: diagnostic.cc:883
@@ -19281,7 +19281,7 @@ msgstr "包含自"
 
 #: diagnostic.cc:884
 msgid "In module"
-msgstr ""
+msgstr "在模块中"
 
 #. 4
 #: diagnostic.cc:885
@@ -19290,12 +19290,12 @@ msgstr ""
 
 #: diagnostic.cc:886
 msgid "In module imported at"
-msgstr ""
+msgstr "在此处导入的模块中"
 
 #. 6
 #: diagnostic.cc:887
 msgid "imported at"
-msgstr ""
+msgstr "在此导入"
 
 #: diagnostic.cc:1592
 #, c-format
@@ -22946,22 +22946,16 @@ msgid "In static member function %qD"
 msgstr "在静态成员函数%qs中"
 
 #: cp/error.cc:3705
-#, fuzzy
-#| msgid "In copy constructor %qs"
 msgid "In copy constructor %qD"
-msgstr "在复制构造函数%qs"
+msgstr "在复制构造函数%qD"
 
 #: cp/error.cc:3707
-#, fuzzy
-#| msgid "In constructor %qs"
 msgid "In constructor %qD"
-msgstr "在构造函数%qs中"
+msgstr "在构造函数%qD中"
 
 #: cp/error.cc:3709
-#, fuzzy
-#| msgid "In destructor %qs"
 msgid "In destructor %qD"
-msgstr "在析构函数%qs中"
+msgstr "在析构函数%qD中"
 
 #: cp/error.cc:3711
 msgid "In lambda function"
@@ -22980,10 +22974,8 @@ msgid "In member function %qD"
 msgstr "在成员函数%qs中"
 
 #: cp/error.cc:3718
-#, fuzzy
-#| msgid "In function %qs"
 msgid "In function %qD"
-msgstr "在函数%qs中"
+msgstr "在函数%qD中"
 
 #: cp/error.cc:3741
 #, fuzzy, c-format
@@ -22991,9 +22983,8 @@ msgid "%s: In substitution of %qS:\n"
 msgstr "空动态字符串替换"
 
 #: cp/error.cc:3742
-#, fuzzy
 msgid "%s: In instantiation of %q#D:\n"
-msgstr "对%q#D的显式实例化"
+msgstr "%s: 在%q#D的实例化中: \n"
 
 #: cp/error.cc:3767 cp/error.cc:3925
 msgid "%r%s:%d:%d:%R   "
@@ -23019,9 +23010,8 @@ msgid "recursively required from %q#D\n"
 msgstr "与先前的声明%q+D不同"
 
 #: cp/error.cc:3785
-#, fuzzy
 msgid "required from %q#D\n"
-msgstr "与先前的声明%q+D不同"
+msgstr "在 %q#D 中的要求\n"
 
 #: cp/error.cc:3792
 #, fuzzy
@@ -23029,9 +23019,8 @@ msgid "recursively required from here\n"
 msgstr "从此处调用"
 
 #: cp/error.cc:3793
-#, fuzzy
 msgid "required from here\n"
-msgstr "从此处调用"
+msgstr "在此处的要求\n"
 
 #: cp/error.cc:3849
 #, fuzzy
@@ -26600,10 +26589,9 @@ msgid "%q+F declared % but never defined"
 msgstr "%q+F声明为%却从未定义过"
 
 #: cgraphunit.cc:1144
-#, fuzzy, gcc-internal-format
-#| msgid "%q+D defined but not used"
+#, gcc-internal-format
 msgid "%qD defined but not used"
-msgstr "%q+D定义后未使用"
+msgstr "%qD 在此处定义"
 
 #: cgraphunit.cc:1479
 #, fuzzy, gcc-internal-format
@@ -29586,7 +29574,7 @@ msgstr ""
 #: gimplify.cc:2764
 #, gcc-internal-format
 msgid "here"
-msgstr ""
+msgstr "此处"
 
 #. We've found [[fallthrough]]; at the end of a switch, which the C++
 #. standard says is ill-formed; see [dcl.attr.fallthrough].
@@ -34011,9 +33999,9 @@ msgid "in definition of macro %qs"
 msgstr "%qs后缺少宏名"
 
 #: tree-diagnostic.cc:224
-#, fuzzy, gcc-internal-format
+#, gcc-internal-format
 msgid "in expansion of macro %qs"
-msgstr "印出 EXPR 的宏展开"
+msgstr "在宏 %qs 展开时"
 
 #: tree-eh.cc:4946
 #, gcc-internal-format, gfc-internal-format
@@ -34735,14 +34723,14 @@ msgid "tree check: accessed operand %d of 
% with %d operands in
 msgstr "树检查:在 %4$s 中访问有 %3$d 个操作数的 omp_clause %2$s 的第 %1$d 个操作数,于 %5$s:%6$d"
 
 #: tree.cc:12476
-#, fuzzy, gcc-internal-format
+#, gcc-internal-format
 msgid "%qD is deprecated: %s"
-msgstr "已弃用%qE:%s"
+msgstr "%qD 已被弃用: %s"
 
 #: tree.cc:12479
-#, fuzzy, gcc-internal-format
+#, gcc-internal-format
 msgid "%qD is deprecated"
-msgstr "已弃用%qE"
+msgstr "%qD 已被弃用"
 
 #: tree.cc:12502
 #, gcc-internal-format
@@ -35246,9 +35234,9 @@ msgid "invalid initial value for member %qE"
 msgstr "成员%qE的初始值无效"
 
 #: varasm.cc:5981
-#, fuzzy, gcc-internal-format
+#, gcc-internal-format
 msgid "%qD declared weak after being used"
-msgstr "%q+D声明为友元"
+msgstr "%qD 在使用后被声明为弱符号"
 
 #: varasm.cc:6033
 #, fuzzy, gcc-internal-format
@@ -36060,9 +36048,9 @@ msgid "%qE argument not an identifier"
 msgstr "cleanup 实参不是一个标识符"
 
 #: c-family/c-attribs.cc:4396
-#, fuzzy, gcc-internal-format
+#, gcc-internal-format
 msgid "%qD is not compatible with %qD"
-msgstr "选择%qD而不是%qD"
+msgstr "%qD 与 %qD 不兼容"
 
 #: c-famil

[gcc r14-11057] [PATCH] PR modula2/117371: type incompatibility between INTEGER and CARDINAL

2024-12-03 Thread Gaius Mulley via Gcc-cvs
https://gcc.gnu.org/g:c1409e1955110fcf3641cec6e8381fbf03f0a510

commit r14-11057-gc1409e1955110fcf3641cec6e8381fbf03f0a510
Author: Gaius Mulley 
Date:   Wed Dec 4 00:11:22 2024 +

[PATCH] PR modula2/117371: type incompatibility between INTEGER and CARDINAL

This patch enforces a const expression increment in a FOR loop.
It also fixes missing error locations.  The FOR loop last iterator
value is now calculated during M2GenGCC after all types and constants have
been resolved.  This results in fewer quadruples (as there is no need to
build two paths for step > 0 and step < 0).

gcc/m2/ChangeLog:

PR modula2/117371
* gm2-compiler/M2Base.mod (MixMetaTypes): Add parameter TRUE to
MetaErrorDecl.
(IsUserType): Test against ZType.
(MixTypesDecl): Test for ZType.
* gm2-compiler/M2GenGCC.mod (ErrorMessageDecl): Add parameter TRUE 
to
MetaErrorDecl.
(CodeLastForIterator): New procedure.
(FoldLastForIterator): Ditto.
(PerformLastForIterator): Ditto.
(CodeStatement): Add case clause for LastForIteratorOp.
(ErrorMessageDecl): Add iserror parameter.
Call MetaErrorDecl with iserror parameter.
(checkIncorrectMeta): Call MetaErrorDecl with TRUE parameter.
(CheckBinaryExpressionTypes): Ditto.
(CheckElementSetTypes): Ditto.
* gm2-compiler/M2LexBuf.def (MakeVirtualTok): Update comment
detailing the fall back when UnknownTokenNo is encountered.
(MakeVirtual2Tok): Ditto.
* gm2-compiler/M2LexBuf.mod (MakeVirtualTok): Check against
UnknownTokenNo.
(MakeVirtual2Tok): Ditto.
* gm2-compiler/M2MetaError.def (MetaErrorDecl): Add error parameter.
* gm2-compiler/M2MetaError.mod (MetaErrorDecl): Add error
parameter.
Issue warning if error is FALSE.
* gm2-compiler/M2Quads.def (QuadOperator): Add LastForIteratorOp.
* gm2-compiler/M2Quads.mod (AddQuadInformation): New case clause
LastForIteratorOp.
(CheckAddTuple2Read): New procedure.
(BuildForLoopToRangeCheck): Remove.
(ForLoopLastIteratorVariable): Ditto.
(ForLoopLastIteratorConstant): Ditto.
(ForLoopLastIterator): Reimplement.
(BuildForToByDo): Remove ByType from call to ForLoopLastIterator.
(WriteQuad): New case clause LastForIteratorOp.
(WriteOperator): Ditto.
* gm2-compiler/M2Students.def
(CheckForVariableThatLooksLikeKeyword): Replace with ...
(CheckVariableAgainstKeyword): ... this.
* gm2-compiler/M2Students.mod
(CheckForVariableThatLooksLikeKeyword): Replace with ...
(CheckVariableAgainstKeyword): ... this.
* gm2-compiler/M2SymInit.mod (CheckLastForIterator): New
procedure.
(CheckReadBeforeInitQuad): New case clause to call
CheckLastForIterator.
* gm2-compiler/P2SymBuild.mod: Replace
CheckForVariableThatLooksLikeKeyword with 
CheckVariableAgainstKeyword.

gcc/testsuite/ChangeLog:

PR modula2/117371
* gm2/iso/fail/forloopbyvar.mod: New test.
* gm2/iso/fail/forloopbyvar4.mod: New test.
* gm2/iso/fail/forloopbyvar5.mod: New test.
* gm2/iso/pass/forloopbyvar3.mod: New test.

(cherry picked from commit f242f79b8afeec58477e99c44530bd503878c6d5)

Signed-off-by: Gaius Mulley 

Diff:
---
 gcc/m2/gm2-compiler/M2Base.mod   |  15 ++-
 gcc/m2/gm2-compiler/M2GenGCC.mod | 144 +++--
 gcc/m2/gm2-compiler/M2LexBuf.def |  11 +-
 gcc/m2/gm2-compiler/M2LexBuf.mod |  20 ++-
 gcc/m2/gm2-compiler/M2MetaError.def  |   5 +-
 gcc/m2/gm2-compiler/M2MetaError.mod  |  21 ++-
 gcc/m2/gm2-compiler/M2Quads.def  |   1 +
 gcc/m2/gm2-compiler/M2Quads.mod  | 186 ++-
 gcc/m2/gm2-compiler/M2Students.def   |   8 +-
 gcc/m2/gm2-compiler/M2Students.mod   |   8 +-
 gcc/m2/gm2-compiler/M2SymInit.mod|  20 ++-
 gcc/m2/gm2-compiler/P2SymBuild.mod   |   4 +-
 gcc/testsuite/gm2/iso/fail/forloopbyvar.mod  |  16 +++
 gcc/testsuite/gm2/iso/fail/forloopbyvar4.mod |  17 +++
 gcc/testsuite/gm2/iso/fail/forloopbyvar5.mod |  17 +++
 gcc/testsuite/gm2/iso/pass/forloopbyvar3.mod |  16 +++
 16 files changed, 330 insertions(+), 179 deletions(-)

diff --git a/gcc/m2/gm2-compiler/M2Base.mod b/gcc/m2/gm2-compiler/M2Base.mod
index 986e208e0c37..7064c60b1fbe 100644
--- a/gcc/m2/gm2-compiler/M2Base.mod
+++ b/gcc/m2/gm2-compiler/M2Base.mod
@@ -1997,8 +1997,8 @@ BEGIN
 
no:  MetaErrorT2 (NearTok, 'type incompatibility between {%1asd} 
and {%2asd}',

[gcc r15-5906] AVR: Skip some test cases that don't work for it.

2024-12-03 Thread Georg-Johann Lay via Gcc-cvs
https://gcc.gnu.org/g:5aa4ab4d62f4b6c6e1b0ceb746582bdac3bb14a9

commit r15-5906-g5aa4ab4d62f4b6c6e1b0ceb746582bdac3bb14a9
Author: Georg-Johann Lay 
Date:   Tue Dec 3 11:50:54 2024 +0100

AVR: Skip some test cases that don't work for it.

gcc/testsuite/
* gcc.c-torture/execute/ieee/cdivchkd.x: New file.
* gcc.c-torture/execute/ieee/cdivchkf.x: New file.
* gcc.dg/flex-array-counted-by.c: Require wchar.
* gcc.dg/fold-copysign-1.c [avr]: Add -mdouble=64.

Diff:
---
 gcc/testsuite/gcc.c-torture/execute/ieee/cdivchkd.x | 5 +
 gcc/testsuite/gcc.c-torture/execute/ieee/cdivchkf.x | 5 +
 gcc/testsuite/gcc.dg/flex-array-counted-by.c| 1 +
 gcc/testsuite/gcc.dg/fold-copysign-1.c  | 1 +
 4 files changed, 12 insertions(+)

diff --git a/gcc/testsuite/gcc.c-torture/execute/ieee/cdivchkd.x 
b/gcc/testsuite/gcc.c-torture/execute/ieee/cdivchkd.x
new file mode 100644
index ..7c575fceae87
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/execute/ieee/cdivchkd.x
@@ -0,0 +1,5 @@
+if [istarget "avr-*-*"] {
+# Floating-point support is incomplete.
+return 1
+}
+return 0
diff --git a/gcc/testsuite/gcc.c-torture/execute/ieee/cdivchkf.x 
b/gcc/testsuite/gcc.c-torture/execute/ieee/cdivchkf.x
new file mode 100644
index ..7c575fceae87
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/execute/ieee/cdivchkf.x
@@ -0,0 +1,5 @@
+if [istarget "avr-*-*"] {
+# Floating-point support is incomplete.
+return 1
+}
+return 0
diff --git a/gcc/testsuite/gcc.dg/flex-array-counted-by.c 
b/gcc/testsuite/gcc.dg/flex-array-counted-by.c
index e8b54c2de1c0..16eb2c630101 100644
--- a/gcc/testsuite/gcc.dg/flex-array-counted-by.c
+++ b/gcc/testsuite/gcc.dg/flex-array-counted-by.c
@@ -1,6 +1,7 @@
 /* Testing the correct usage of attribute counted_by.  */   
 /* { dg-do compile } */
 /* { dg-options "-O2" } */
+/* { dg-require-effective-target wchar } */
 
 #include 
 
diff --git a/gcc/testsuite/gcc.dg/fold-copysign-1.c 
b/gcc/testsuite/gcc.dg/fold-copysign-1.c
index 96b80c733794..1f5141b1c5d6 100644
--- a/gcc/testsuite/gcc.dg/fold-copysign-1.c
+++ b/gcc/testsuite/gcc.dg/fold-copysign-1.c
@@ -1,6 +1,7 @@
 /* { dg-do compile } */
 /* { dg-options "-O -fdump-tree-cddce1" } */
 /* { dg-additional-options "-msse -mfpmath=sse" { target { { i?86-*-* 
x86_64-*-* } && ilp32 } } } */
+/* { dg-additional-options "-mdouble=64" { target { avr-*-* } } } */
 
 double foo (double x)
 {


[gcc r15-5905] AVR: Improve location of late diagnostics.

2024-12-03 Thread Georg-Johann Lay via Gcc-cvs
https://gcc.gnu.org/g:b6a43fe2c5498f823b5df735a4702f35a812e5bd

commit r15-5905-gb6a43fe2c5498f823b5df735a4702f35a812e5bd
Author: Georg-Johann Lay 
Date:   Tue Dec 3 14:19:40 2024 +0100

AVR: Improve location of late diagnostics.

Some diagnostics are issues late, e.g. in avr_print_operand().
This patch uses the insn's location as a proxy for the operand
location.  Without the patch, the location is usually input_location,
which points to the closing } of the function body.

gcc/
* config/avr/avr.cc (avr_insn_location): New variable.
(avr_final_prescan_insn): Set avr_insn_location.
(avr_asm_final_postscan_insn): Unset avr_insn_location after last 
insn.
(avr_print_operand): Pass avr_insn_location to warning_at.

gcc/testsuite/
* gcc.dg/Warray-bounds-33.c: Adjust for avr diagnostics.
* gcc.dg/pr56228.c: Same.
* gcc.dg/pr86124.c: Same.
* gcc.dg/pr94291.c: Same.
* gcc.dg/tree-ssa/pr82059.c: Same.

Diff:
---
 gcc/config/avr/avr.cc   | 40 +++--
 gcc/testsuite/gcc.dg/Warray-bounds-33.c |  3 +--
 gcc/testsuite/gcc.dg/pr56228.c  |  3 +--
 gcc/testsuite/gcc.dg/pr86124.c  |  3 +--
 gcc/testsuite/gcc.dg/pr94291.c  |  4 ++--
 gcc/testsuite/gcc.dg/tree-ssa/pr82059.c |  3 +--
 6 files changed, 34 insertions(+), 22 deletions(-)

diff --git a/gcc/config/avr/avr.cc b/gcc/config/avr/avr.cc
index ccf9b05bb3e5..9bebd67cd9c4 100644
--- a/gcc/config/avr/avr.cc
+++ b/gcc/config/avr/avr.cc
@@ -234,6 +234,7 @@ bool avr_has_rodata_p = false;
insn condition for shift insn splitters.  */
 int n_avr_fuse_add_executed = 0;
 
+static location_t avr_insn_location = UNKNOWN_LOCATION;
 
 
 /* Transform UP into lowercase and write the result to LO.
@@ -2712,12 +2713,17 @@ avr_print_operand (FILE *file, rtx x, int code)
fatal_insn ("bad address, not a constant:", addr);
  /* Assembler template with m-code is data - not progmem section */
  if (text_segment_operand (addr, VOIDmode))
-   if (warning (0, "accessing data memory with"
-" program memory address"))
- {
-   output_addr_const (stderr, addr);
-   fprintf(stderr,"\n");
- }
+   {
+ location_t loc = avr_insn_location != UNKNOWN_LOCATION
+   ? avr_insn_location
+   : input_location;
+ if (warning_at (loc, 0, "accessing data memory with"
+ " program memory address"))
+   {
+ output_addr_const (stderr, addr);
+ fprintf (stderr,"\n");
+   }
+   }
  output_addr_const (file, addr);
}
   else if (code == 'o')
@@ -2760,12 +2766,17 @@ avr_print_operand (FILE *file, rtx x, int code)
 {
   /* Constant progmem address - like used in jmp or call */
   if (text_segment_operand (x, VOIDmode) == 0)
-   if (warning (0, "accessing program memory"
-" with data memory address"))
- {
-   output_addr_const (stderr, x);
-   fprintf (stderr, "\n");
- }
+   {
+ location_t loc = avr_insn_location != UNKNOWN_LOCATION
+   ? avr_insn_location
+   : input_location;
+ if (warning_at (loc, 0, "accessing program memory"
+ " with data memory address"))
+   {
+ output_addr_const (stderr, x);
+ fprintf (stderr, "\n");
+   }
+   }
   /* Use normal symbol for direct address no linker trampoline needed */
   output_addr_const (file, x);
 }
@@ -2954,6 +2965,8 @@ void
 avr_final_prescan_insn (rtx_insn *insn, rtx * /*operands*/,
int /*num_operands*/)
 {
+  avr_insn_location = LOCATION_LOCUS (INSN_LOCATION (insn));
+
   if (avr_log.rtx_costs)
 {
   rtx set = single_set (insn);
@@ -2982,6 +2995,9 @@ avr_final_prescan_insn (rtx_insn *insn, rtx * 
/*operands*/,
 static void
 avr_asm_final_postscan_insn (FILE *stream, rtx_insn *insn, rtx *, int)
 {
+  if (!next_real_insn (insn))
+avr_insn_location = UNKNOWN_LOCATION;
+
   if (cfun->machine->gasisr.yes
   && !next_real_insn (insn))
 {
diff --git a/gcc/testsuite/gcc.dg/Warray-bounds-33.c 
b/gcc/testsuite/gcc.dg/Warray-bounds-33.c
index 13efabe33b6e..5f06471f8207 100644
--- a/gcc/testsuite/gcc.dg/Warray-bounds-33.c
+++ b/gcc/testsuite/gcc.dg/Warray-bounds-33.c
@@ -2,7 +2,6 @@
an object of incomplete type
{ dg-do compile }
{ dg-options "-O2 -Wall" }  */
-/* { dg-skip-if "acessing data memory with program memory address" { "avr-*-*" 
} } */
 
 struct S
 {
@@ -30,7 +29,7 @@ void test_incomplete_enum (void)
 void test_func (void)
 {
   struct S *b = (struct S*)&f;
-  if (b->s)
+  if (b->s) /* { dg-warning "accessing data memory with program memory 
address.*" "" { tar

[gcc r14-11056] [PATCH] modula2: Add dependencies for generated sources

2024-12-03 Thread Gaius Mulley via Gcc-cvs
https://gcc.gnu.org/g:de4f10f07c05cd638070ce4d3091ab28cc3cfa03

commit r14-11056-gde4f10f07c05cd638070ce4d3091ab28cc3cfa03
Author: Gaius Mulley 
Date:   Tue Dec 3 21:17:20 2024 +

[PATCH] modula2: Add dependencies for generated sources

This patch adds rules and dependencies for the automatically
generated grammar sources.  Bootstrapped using make -j 160.

gcc/m2/ChangeLog:

* Make-lang.in (m2/gm2-compiler-boot/P0SyntaxCheck.c):
New rule.
(m2/gm2-compiler-boot/P0SyntaxCheck.o): Ditto.
(m2/gm2-compiler-boot/P1Build.c): Ditto.
(m2/gm2-compiler-boot/P1Build.o): Ditto.
(m2/gm2-compiler-boot/P2Build.c): Ditto.
(m2/gm2-compiler-boot/P2Build.o): Ditto.
(m2/gm2-compiler-boot/P3Build.c): Ditto.
(m2/gm2-compiler-boot/P3Build.o): Ditto.
(m2/gm2-compiler-boot/PCBuild.c): Ditto.
(m2/gm2-compiler-boot/PCBuild.o): Ditto.
(m2/gm2-compiler-boot/PHBuild.c): Ditto.
(m2/gm2-compiler-boot/PHBuild.o): Ditto.

(cherry picked from commit 3e6a7824033ffb88b8f99ad93b389f7d0eef22a4)

Signed-off-by: Gaius Mulley 

Diff:
---
 gcc/m2/Make-lang.in | 60 +
 1 file changed, 60 insertions(+)

diff --git a/gcc/m2/Make-lang.in b/gcc/m2/Make-lang.in
index 480c4fb28a7e..154270214389 100644
--- a/gcc/m2/Make-lang.in
+++ b/gcc/m2/Make-lang.in
@@ -1590,6 +1590,66 @@ m2/gm2-compiler-boot/$(SRC_PREFIX)%.h: 
$(srcdir)/m2/gm2-compiler/%.def $(MCDEPS)
-test -d $(@D) || $(mkinstalldirs) $(@D)
$(MC) -o=$@ $(srcdir)/m2/gm2-compiler/$*.def
 
+m2/gm2-compiler-boot/P0SyntaxCheck.c: m2/gm2-compiler-boot/P0SyntaxCheck.mod 
$(MCDEPS)
+   -test -d $(@D)/$(DEPDIR) || $(mkinstalldirs) $(@D)/$(DEPDIR)
+   $(MC) -o=m2/gm2-compiler-boot/P0SyntaxCheck.c 
m2/gm2-compiler-boot/P0SyntaxCheck.mod
+
+m2/gm2-compiler-boot/P0SyntaxCheck.o: m2/gm2-compiler-boot/P0SyntaxCheck.c 
$(MCDEPS) $(BUILD-BOOT-H)
+   -test -d $(@D)/$(DEPDIR) || $(mkinstalldirs) $(@D)/$(DEPDIR)
+   $(COMPILER) $(CM2DEP) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(GM2GCC) 
\
+$(GM2_BOOT_INCLUDES) $(MCINCLUDES) $(INCLUDES) 
m2/gm2-compiler-boot/P0SyntaxCheck.c -o $@
+   $(POSTCOMPILE)
+
+m2/gm2-compiler-boot/P1Build.c: m2/gm2-compiler-boot/P1Build.mod $(MCDEPS)
+   -test -d $(@D)/$(DEPDIR) || $(mkinstalldirs) $(@D)/$(DEPDIR)
+   $(MC) -o=m2/gm2-compiler-boot/P1Build.c m2/gm2-compiler-boot/P1Build.mod
+
+m2/gm2-compiler-boot/P1Build.o: m2/gm2-compiler-boot/P1Build.c $(MCDEPS) 
$(BUILD-BOOT-H)
+   -test -d $(@D)/$(DEPDIR) || $(mkinstalldirs) $(@D)/$(DEPDIR)
+   $(COMPILER) $(CM2DEP) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(GM2GCC) 
\
+$(GM2_BOOT_INCLUDES) $(MCINCLUDES) $(INCLUDES) 
m2/gm2-compiler-boot/P1Build.c -o $@
+   $(POSTCOMPILE)
+
+m2/gm2-compiler-boot/P2Build.c: m2/gm2-compiler-boot/P2Build.mod $(MCDEPS)
+   -test -d $(@D)/$(DEPDIR) || $(mkinstalldirs) $(@D)/$(DEPDIR)
+   $(MC) -o=m2/gm2-compiler-boot/P2Build.c m2/gm2-compiler-boot/P2Build.mod
+
+m2/gm2-compiler-boot/P2Build.o: m2/gm2-compiler-boot/P2Build.c $(MCDEPS) 
$(BUILD-BOOT-H)
+   -test -d $(@D)/$(DEPDIR) || $(mkinstalldirs) $(@D)/$(DEPDIR)
+   $(COMPILER) $(CM2DEP) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(GM2GCC) 
\
+$(GM2_BOOT_INCLUDES) $(MCINCLUDES) $(INCLUDES) 
m2/gm2-compiler-boot/P2Build.c -o $@
+   $(POSTCOMPILE)
+
+m2/gm2-compiler-boot/P3Build.c: m2/gm2-compiler-boot/P3Build.mod $(MCDEPS)
+   -test -d $(@D)/$(DEPDIR) || $(mkinstalldirs) $(@D)/$(DEPDIR)
+   $(MC) -o=m2/gm2-compiler-boot/P3Build.c m2/gm2-compiler-boot/P3Build.mod
+
+m2/gm2-compiler-boot/P3Build.o: m2/gm2-compiler-boot/P3Build.c $(MCDEPS) 
$(BUILD-BOOT-H)
+   -test -d $(@D)/$(DEPDIR) || $(mkinstalldirs) $(@D)/$(DEPDIR)
+   $(COMPILER) $(CM2DEP) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(GM2GCC) 
\
+$(GM2_BOOT_INCLUDES) $(MCINCLUDES) $(INCLUDES) 
m2/gm2-compiler-boot/P3Build.c -o $@
+   $(POSTCOMPILE)
+
+m2/gm2-compiler-boot/PCBuild.c: m2/gm2-compiler-boot/PCBuild.mod $(MCDEPS)
+   -test -d $(@D)/$(DEPDIR) || $(mkinstalldirs) $(@D)/$(DEPDIR)
+   $(MC) -o=m2/gm2-compiler-boot/PCBuild.c m2/gm2-compiler-boot/PCBuild.mod
+
+m2/gm2-compiler-boot/PCBuild.o: m2/gm2-compiler-boot/PCBuild.c $(MCDEPS) 
$(BUILD-BOOT-H)
+   -test -d $(@D)/$(DEPDIR) || $(mkinstalldirs) $(@D)/$(DEPDIR)
+   $(COMPILER) $(CM2DEP) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(GM2GCC) 
\
+$(GM2_BOOT_INCLUDES) $(MCINCLUDES) $(INCLUDES) 
m2/gm2-compiler-boot/PCBuild.c -o $@
+   $(POSTCOMPILE)
+
+m2/gm2-compiler-boot/PHBuild.c: m2/gm2-compiler-boot/PHBuild.mod $(MCDEPS)
+   -test -d $(@D)/$(DEPDIR) || $(mkinstalldirs) $(@D)/$(DEPDIR)
+   $(MC) -o=m2/gm2-compiler-boot/PHBuild.c m2/gm2-compiler-boot/PHBuild.mod
+
+m2/gm2-compiler-boot/PHBuild.o: m2/gm2-compiler-boot/PHBuild.c $(MCDEP

[gcc r15-5904] Move some CRC tests into the gcc.dg/torture directory

2024-12-03 Thread Jeff Law via Gcc-cvs
https://gcc.gnu.org/g:96f5fd3089075b56ea9ea85060213cc4edd7251a

commit r15-5904-g96f5fd3089075b56ea9ea85060213cc4edd7251a
Author: Jeff Law 
Date:   Tue Dec 3 12:26:01 2024 -0700

Move some CRC tests into the gcc.dg/torture directory

Jakub noted that these tests were using dg-skip-if directives that implied 
the
tests were expected to run under multiple optimization options, which means
they probably should be in gcc.dg/torture rather than in the gcc.dg 
directory.

This moves the relevant tests from gcc.dg to gcc.dg/torture.

gcc/testsuite
* gcc.dg/crc-linux-1.c: Moved to from gcc.dg/torture.
* gcc.dg/crc-linux-2.c: Likewise.
* gcc.dg/crc-linux-4.c: Likewise.
* gcc.dg/crc-linux-5.c: Likewise.
* gcc.dg/crc-not-crc-15.c: Likewise.
* gcc.dg/crc-side-instr-1.c: Likewise.
* gcc.dg/crc-side-instr-2.c: Likewise.
* gcc.dg/crc-side-instr-3.c: Likewise.
* gcc.dg/crc-side-instr-4.c: Likewise.
* gcc.dg/crc-side-instr-5.c: Likewise.
* gcc.dg/crc-side-instr-6.c: Likewise.
* gcc.dg/crc-side-instr-7.c: Likewise.
* gcc.dg/crc-side-instr-8.c: Likewise.
* gcc.dg/crc-side-instr-9.c: Likewise.
* gcc.dg/crc-side-instr-10.c: Likewise.
* gcc.dg/crc-side-instr-11.c: Likewise.
* gcc.dg/crc-side-instr-12.c: Likewise.
* gcc.dg/crc-side-instr-13.c: Likewise.
* gcc.dg/crc-side-instr-14.c: Likewise.
* gcc.dg/crc-side-instr-15.c: Likewise.
* gcc.dg/crc-side-instr-16.c: Likewise.
* gcc.dg/crc-side-instr-17.c: Likewise.

Diff:
---
 gcc/testsuite/gcc.dg/{ => torture}/crc-linux-1.c   | 0
 gcc/testsuite/gcc.dg/{ => torture}/crc-linux-2.c   | 0
 gcc/testsuite/gcc.dg/{ => torture}/crc-linux-4.c   | 0
 gcc/testsuite/gcc.dg/{ => torture}/crc-linux-5.c   | 0
 gcc/testsuite/gcc.dg/{ => torture}/crc-not-crc-15.c| 0
 gcc/testsuite/gcc.dg/{ => torture}/crc-side-instr-1.c  | 0
 gcc/testsuite/gcc.dg/{ => torture}/crc-side-instr-10.c | 0
 gcc/testsuite/gcc.dg/{ => torture}/crc-side-instr-11.c | 0
 gcc/testsuite/gcc.dg/{ => torture}/crc-side-instr-12.c | 0
 gcc/testsuite/gcc.dg/{ => torture}/crc-side-instr-13.c | 0
 gcc/testsuite/gcc.dg/{ => torture}/crc-side-instr-14.c | 0
 gcc/testsuite/gcc.dg/{ => torture}/crc-side-instr-15.c | 0
 gcc/testsuite/gcc.dg/{ => torture}/crc-side-instr-16.c | 0
 gcc/testsuite/gcc.dg/{ => torture}/crc-side-instr-17.c | 0
 gcc/testsuite/gcc.dg/{ => torture}/crc-side-instr-2.c  | 0
 gcc/testsuite/gcc.dg/{ => torture}/crc-side-instr-3.c  | 0
 gcc/testsuite/gcc.dg/{ => torture}/crc-side-instr-4.c  | 0
 gcc/testsuite/gcc.dg/{ => torture}/crc-side-instr-5.c  | 0
 gcc/testsuite/gcc.dg/{ => torture}/crc-side-instr-6.c  | 0
 gcc/testsuite/gcc.dg/{ => torture}/crc-side-instr-7.c  | 0
 gcc/testsuite/gcc.dg/{ => torture}/crc-side-instr-8.c  | 0
 gcc/testsuite/gcc.dg/{ => torture}/crc-side-instr-9.c  | 0
 22 files changed, 0 insertions(+), 0 deletions(-)

diff --git a/gcc/testsuite/gcc.dg/crc-linux-1.c 
b/gcc/testsuite/gcc.dg/torture/crc-linux-1.c
similarity index 100%
rename from gcc/testsuite/gcc.dg/crc-linux-1.c
rename to gcc/testsuite/gcc.dg/torture/crc-linux-1.c
diff --git a/gcc/testsuite/gcc.dg/crc-linux-2.c 
b/gcc/testsuite/gcc.dg/torture/crc-linux-2.c
similarity index 100%
rename from gcc/testsuite/gcc.dg/crc-linux-2.c
rename to gcc/testsuite/gcc.dg/torture/crc-linux-2.c
diff --git a/gcc/testsuite/gcc.dg/crc-linux-4.c 
b/gcc/testsuite/gcc.dg/torture/crc-linux-4.c
similarity index 100%
rename from gcc/testsuite/gcc.dg/crc-linux-4.c
rename to gcc/testsuite/gcc.dg/torture/crc-linux-4.c
diff --git a/gcc/testsuite/gcc.dg/crc-linux-5.c 
b/gcc/testsuite/gcc.dg/torture/crc-linux-5.c
similarity index 100%
rename from gcc/testsuite/gcc.dg/crc-linux-5.c
rename to gcc/testsuite/gcc.dg/torture/crc-linux-5.c
diff --git a/gcc/testsuite/gcc.dg/crc-not-crc-15.c 
b/gcc/testsuite/gcc.dg/torture/crc-not-crc-15.c
similarity index 100%
rename from gcc/testsuite/gcc.dg/crc-not-crc-15.c
rename to gcc/testsuite/gcc.dg/torture/crc-not-crc-15.c
diff --git a/gcc/testsuite/gcc.dg/crc-side-instr-1.c 
b/gcc/testsuite/gcc.dg/torture/crc-side-instr-1.c
similarity index 100%
rename from gcc/testsuite/gcc.dg/crc-side-instr-1.c
rename to gcc/testsuite/gcc.dg/torture/crc-side-instr-1.c
diff --git a/gcc/testsuite/gcc.dg/crc-side-instr-10.c 
b/gcc/testsuite/gcc.dg/torture/crc-side-instr-10.c
similarity index 100%
rename from gcc/testsuite/gcc.dg/crc-side-instr-10.c
rename to gcc/testsuite/gcc.dg/torture/crc-side-instr-10.c
diff --git a/gcc/testsuite/gcc.dg/crc-side-instr-11.c 
b/gcc/testsuite/gcc.dg/torture/crc-side-instr-11.c
similarity index 100%
rename from gcc/testsuite/gcc.dg/crc-side-instr-11.c
rename to gcc/testsuite/gcc.dg/torture/crc-side-instr-11.c
diff --git a/gcc/testsuite/gcc.dg/crc-side-instr-12.c 
b/gcc/testsuite/gcc.dg/torture/crc-side-in