[gcc] Created branch 'egallager/heads/ruff_fix' in namespace 'refs/users'

2024-08-28 Thread Eric Gallager via Gcc-cvs
The branch 'egallager/heads/ruff_fix' was created in namespace 'refs/users' 
pointing to:

 3cde331e9590... RISC-V: Add missing mode_idx for vrol and vror


[gcc(refs/users/egallager/heads/ruff_fix)] run `ruff check --fix`

2024-08-28 Thread Eric Gallager via Gcc-cvs
https://gcc.gnu.org/g:adaa6472e158d51fc30a74d799eb2a3e9576942c

commit adaa6472e158d51fc30a74d799eb2a3e9576942c
Author: Eric Gallager 
Date:   Wed Aug 28 03:28:10 2024 -0400

run `ruff check --fix`

Diff:
---
 contrib/analyze_brprob.py  |  4 +---
 contrib/check_GNU_style_lib.py |  1 -
 contrib/gcc-changelog/git_commit.py|  4 ++--
 contrib/header-tools/headerutils.py| 22 ++
 contrib/unicode/from_glibc/utf8_gen.py |  9 -
 contrib/unicode/gen-combining-chars.py |  2 +-
 contrib/unicode/gen-printable-chars.py |  2 +-
 contrib/unicode/gen_libstdcxx_unicode_data.py  |  9 -
 contrib/unused_functions.py|  5 +++--
 gcc/jit/docs/conf.py   |  2 +-
 gcc/m2/tools-src/boilerplate.py|  2 +-
 gcc/m2/tools-src/tidydates.py  |  2 +-
 gcc/regenerate-opt-urls.py |  2 --
 gcc/testsuite/g++.dg/modules/test-depfile.py   |  1 -
 maintainer-scripts/bugzilla-close-candidate.py |  3 +--
 15 files changed, 30 insertions(+), 40 deletions(-)

diff --git a/contrib/analyze_brprob.py b/contrib/analyze_brprob.py
index ca42fa6a6c26..17b8865ac6a7 100755
--- a/contrib/analyze_brprob.py
+++ b/contrib/analyze_brprob.py
@@ -64,8 +64,6 @@
 #  "opcode values nonequal (on trees)" heuristics has good hirate, but poor
 #  coverage.
 
-import sys
-import os
 import re
 import argparse
 
@@ -227,7 +225,7 @@ class Profile:
 self.niter_vector = []
 
 def add(self, name, prediction, count, hits):
-if not name in self.heuristics:
+if name not in self.heuristics:
 self.heuristics[name] = Summary(name)
 
 s = self.heuristics[name]
diff --git a/contrib/check_GNU_style_lib.py b/contrib/check_GNU_style_lib.py
index 6dbe4b53559c..07a33ce6fca4 100755
--- a/contrib/check_GNU_style_lib.py
+++ b/contrib/check_GNU_style_lib.py
@@ -26,7 +26,6 @@
 # like this:
 # $ pip3 install unidiff termcolor
 
-import sys
 import re
 import unittest
 
diff --git a/contrib/gcc-changelog/git_commit.py 
b/contrib/gcc-changelog/git_commit.py
index 87ecb9e1a17d..170bcad14348 100755
--- a/contrib/gcc-changelog/git_commit.py
+++ b/contrib/gcc-changelog/git_commit.py
@@ -348,7 +348,7 @@ class GitCommit:
 if self.info.lines and not self.revert_commit:
 self.subject_prs = {m.group('pr') for m in 
subject_pr2_regex.finditer(info.lines[0])}
 for m in subject_pr_regex.finditer(info.lines[0]):
-if not m.group('component') in bug_components:
+if m.group('component') not in bug_components:
 self.errors.append(Error('invalid PR component in 
subject', info.lines[0]))
 self.subject_prs.add(m.group('pr'))
 
@@ -506,7 +506,7 @@ class GitCommit:
 if not component:
 self.errors.append(Error('missing PR component', line))
 continue
-elif not component[:-1] in bug_components:
+elif component[:-1] not in bug_components:
 self.errors.append(Error('invalid PR component', line))
 continue
 else:
diff --git a/contrib/header-tools/headerutils.py 
b/contrib/header-tools/headerutils.py
index 1fb022144146..d62a79bd2733 100755
--- a/contrib/header-tools/headerutils.py
+++ b/contrib/header-tools/headerutils.py
@@ -1,10 +1,8 @@
 #! /usr/bin/python3
 import os.path
 import sys
-import shlex
 import re
 import subprocess
-import shutil
 import pickle
 
 import multiprocessing 
@@ -31,7 +29,7 @@ def find_pound_define (line):
   print ("What? more than 1 match in #define??")
   print (inc)
   sys.exit(5)
-return inc[0];
+return inc[0]
   return ""
 
 def is_pound_if (line):
@@ -95,7 +93,7 @@ def process_include_info (filen, do_macros, keep_src):
   if not os.path.exists (filen):
 return empty_iinfo
 
-  sfile = open (filen, "r");
+  sfile = open (filen, "r")
   data = sfile.readlines()
   sfile.close()
 
@@ -132,7 +130,7 @@ def process_include_info (filen, do_macros, keep_src):
   d = find_pound_define (line)
   if d:
 if d not in macout:
-  macout.append (d);
+  macout.append (d)
   continue
 
   d = find_pound_if (line)
@@ -146,7 +144,7 @@ def process_include_info (filen, do_macros, keep_src):
 else:
   for mac in d:
 if mac != "defined" and mac not in macin:
-  macin.append (mac);
+  macin.append (mac)
 
   if not keep_src:
 data = list()
@@ -299,7 +297,7 @@ def find_unique_include_list (filen):
 # (filen, macin, macout, incl)
 
 def create_macro_in_out (filen):
-  sfile = open (filen, "r");
+  sfile = open (filen, "r")
   data = sfile.readlines()
   sfile.close()
 
@@ -311,14 +309,14 @@ def create_macro_in_out (filen):
 d = find_pound_define (line)
 if d

[gcc] Created branch 'egallager/heads/ruff_fix_unsafe' in namespace 'refs/users'

2024-08-28 Thread Eric Gallager via Gcc-cvs
The branch 'egallager/heads/ruff_fix_unsafe' was created in namespace 
'refs/users' pointing to:

 adaa6472e158... run `ruff check --fix`


[gcc r15-3243] Vect: Reconcile the const_int operand type of unsigned .SAT_ADD

2024-08-28 Thread Pan Li via Gcc-cvs
https://gcc.gnu.org/g:6dccd5710380429c7addec9fe92a1a0bcb2f3367

commit r15-3243-g6dccd5710380429c7addec9fe92a1a0bcb2f3367
Author: Pan Li 
Date:   Tue Aug 27 15:01:02 2024 +0800

Vect: Reconcile the const_int operand type of unsigned .SAT_ADD

The .SAT_ADD has 2 operand, when one of the operand may be INTEGER_CST.
For example _1 = .SAT_ADD (_2, 9) comes from below sample code.

Form 3:
  #define DEF_VEC_SAT_U_ADD_IMM_FMT_3(T, IMM)  \
  T __attribute__((noinline))  \
  vec_sat_u_add_imm##IMM##_##T##_fmt_3 (T *out, T *in, unsigned limit) \
  {\
unsigned i;\
T ret; \
for (i = 0; i < limit; i++)\
  {\
out[i] = __builtin_add_overflow (in[i], IMM, &ret) ? -1 : ret; \
  }\
  }

DEF_VEC_SAT_U_ADD_IMM_FMT_3(uint64_t, 9)

It will fail to vectorize as the vectorizable_call will check the
operands is type_compatiable but the imm will be (const_int 9) with
the SImode, which is different from _2 (DImode).  Aka:

uint64_t _1;
uint64_t _2;
_1 = .SAT_ADD (_2, 9);

This patch would like to reconcile the imm operand to the operand type
mode of _2 by fold_convert to make the vectorizable_call happy.

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

gcc/ChangeLog:

* tree-vect-patterns.cc (vect_recog_sat_add_pattern): Add fold
convert for const_int to the type of operand 0.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/vec_sat_arith.h: Add test helper 
macros.
* 
gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add_imm_reconcile-1.c: New test.
* 
gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add_imm_reconcile-10.c: New test.
* 
gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add_imm_reconcile-11.c: New test.
* 
gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add_imm_reconcile-12.c: New test.
* 
gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add_imm_reconcile-13.c: New test.
* 
gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add_imm_reconcile-14.c: New test.
* 
gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add_imm_reconcile-15.c: New test.
* 
gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add_imm_reconcile-2.c: New test.
* 
gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add_imm_reconcile-3.c: New test.
* 
gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add_imm_reconcile-4.c: New test.
* 
gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add_imm_reconcile-5.c: New test.
* 
gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add_imm_reconcile-6.c: New test.
* 
gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add_imm_reconcile-7.c: New test.
* 
gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add_imm_reconcile-8.c: New test.
* 
gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add_imm_reconcile-9.c: New test.

Signed-off-by: Pan Li 

Diff:
---
 .../autovec/binop/vec_sat_u_add_imm_reconcile-1.c|  9 +
 .../autovec/binop/vec_sat_u_add_imm_reconcile-10.c   |  9 +
 .../autovec/binop/vec_sat_u_add_imm_reconcile-11.c   |  9 +
 .../autovec/binop/vec_sat_u_add_imm_reconcile-12.c   |  9 +
 .../autovec/binop/vec_sat_u_add_imm_reconcile-13.c   |  9 +
 .../autovec/binop/vec_sat_u_add_imm_reconcile-14.c   |  9 +
 .../autovec/binop/vec_sat_u_add_imm_reconcile-15.c   |  9 +
 .../autovec/binop/vec_sat_u_add_imm_reconcile-2.c|  9 +
 .../autovec/binop/vec_sat_u_add_imm_reconcile-3.c|  9 +
 .../autovec/binop/vec_sat_u_add_imm_reconcile-4.c|  9 +
 .../autovec/binop/vec_sat_u_add_imm_reconcile-5.c|  9 +
 .../autovec/binop/vec_sat_u_add_imm_reconcile-6.c|  9 +
 .../autovec/binop/vec_sat_u_add_imm_reconcile-7.c|  9 +
 .../autovec/binop/vec_sat_u_add_imm_reconcile-8.c|  9 +
 .../autovec/binop/vec_sat_u_add_imm_reconcile-9.c|  9 +
 .../gcc.target/riscv/rvv/autovec/vec_sat_arith.h | 20 
 gcc/tree-vect-patterns.cc|  3 +++
 17 files changed, 158 insertions(+)

diff --git 
a/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add_imm_reconcile-1.c
 
b/gcc/testsuite/gcc.target/riscv/rvv/autovec/binop/vec_sat_u_add_imm_reconcile-1.c
new file mode 100644
index 

[gcc(refs/users/egallager/heads/ruff_fix_unsafe)] run `ruff check --fix --unsafe-fixes`

2024-08-28 Thread Eric Gallager via Gcc-cvs
https://gcc.gnu.org/g:d7bb10b894601757925f95029904b73a2bfe9a46

commit d7bb10b894601757925f95029904b73a2bfe9a46
Author: Eric Gallager 
Date:   Wed Aug 28 03:30:01 2024 -0400

run `ruff check --fix --unsafe-fixes`

Diff:
---
 contrib/analyze_brprob.py  | 31 +-
 contrib/check_GNU_style_lib.py | 26 +-
 contrib/dg-extract-results.py  |  2 --
 contrib/header-tools/headerutils.py|  7 +++--
 contrib/testsuite-management/validate_failures.py  |  4 +--
 contrib/update-copyright.py|  1 -
 gcc/gdbhooks.py|  2 +-
 gcc/regenerate-opt-urls.py |  1 -
 .../diagnostic-test-paths-multithreaded-sarif.py   |  2 +-
 .../gcc.dg/sarif-output/test-include-chain-1.py|  2 +-
 .../gcc.dg/sarif-output/test-include-chain-2.py|  2 +-
 .../gcc.dg/sarif-output/test-missing-semicolon.py  |  2 +-
 .../gcc.dg/sarif-output/test-no-diagnostics.py |  2 +-
 gcc/testsuite/gcc.dg/sarif-output/test-werror.py   |  2 +-
 14 files changed, 43 insertions(+), 43 deletions(-)

diff --git a/contrib/analyze_brprob.py b/contrib/analyze_brprob.py
index 17b8865ac6a7..5073ab65b2ed 100755
--- a/contrib/analyze_brprob.py
+++ b/contrib/analyze_brprob.py
@@ -111,16 +111,16 @@ class PredictDefFile:
 elif l == '':
 p = None
 
-if p != None:
+if p is not None:
 heuristic = [x for x in heuristics if x.name == p]
 heuristic = heuristic[0] if len(heuristic) == 1 else None
 
 m = re.match('.*HITRATE \(([^)]*)\).*', l)
-if (m != None):
+if (m is not None):
 self.predictors[p] = int(m.group(1))
 
 # modify the line
-if heuristic != None:
+if heuristic is not None:
 new_line = (l[:m.start(1)]
 + str(round(heuristic.get_hitrate()))
 + l[m.end(1):])
@@ -181,14 +181,14 @@ class Summary:
 def print(self, branches_max, count_max, predict_def):
 # filter out most hot edges (if requested)
 self.edges = sorted(self.edges, reverse = True, key = lambda x: 
x.count)
-if args.coverage_threshold != None:
+if args.coverage_threshold is not None:
 threshold = args.coverage_threshold * self.count() / 100
 edges = [x for x in self.edges if x.count < threshold]
 if len(edges) != 0:
 self.edges = edges
 
 predicted_as = None
-if predict_def != None and self.name in predict_def.predictors:
+if predict_def is not None and self.name in predict_def.predictors:
 predicted_as = predict_def.predictors[self.name]
 
 print('%-40s %8i %5.1f%% %11.2f%% %7.2f%% / %6.2f%% %14i %8s %5.1f%%' %
@@ -200,14 +200,14 @@ class Summary:
 self.count(), self.count_formatted(),
 percentage(self.count(), count_max)), end = '')
 
-if predicted_as != None:
+if predicted_as is not None:
 print('%12i%% %5.1f%%' % (predicted_as,
 self.get_hitrate() - predicted_as), end = '')
 else:
 print(' ' * 20, end = '')
 
 # print details about the most important edges
-if args.coverage_threshold == None:
+if args.coverage_threshold is None:
 edges = [x for x in self.edges[:100] if x.count * hot_threshold > 
self.count()]
 if args.verbose:
 for c in edges:
@@ -251,15 +251,20 @@ class Profile:
 count_max = self.count_max()
 branches_max = self.branches_max()
 
-sorter = lambda x: x.branches()
+def sorter(x):
+return x.branches()
 if sorting == 'branch-hitrate':
-sorter = lambda x: x.get_branch_hitrate()
+def sorter(x):
+return x.get_branch_hitrate()
 elif sorting == 'hitrate':
-sorter = lambda x: x.get_hitrate()
+def sorter(x):
+return x.get_hitrate()
 elif sorting == 'coverage':
-sorter = lambda x: x.count
+def sorter(x):
+return x.count
 elif sorting == 'name':
-sorter = lambda x: x.name.lower()
+def sorter(x):
+return x.name.lower()
 
 print('%-40s %8s %6s %12s %18s %14s %8s %6s %12s %6s %s' %
 ('HEURISTICS', 'BRANCHES', '(REL)',
@@ -275,7 +280,7 @@ class Profile:
 return
 
 predict_def = None
-if args.def_file != None:
+if args.def_file is not None:
 predict_def = PredictDefFile(args.def_file)
 predict_def.parse_and_modify(heuristics, args.write_def_file)
 
diff --git a/contrib/check_GNU_style_lib.py b/contrib/check_GNU_style_lib.py
ind

[gcc r15-3244] Test: Move pr116278 run test to dg/torture [NFC]

2024-08-28 Thread Pan Li via Gcc-cvs
https://gcc.gnu.org/g:3178786c88761e47b3cbe700a97a0de2b6e133cb

commit r15-3244-g3178786c88761e47b3cbe700a97a0de2b6e133cb
Author: Pan Li 
Date:   Mon Aug 19 10:02:46 2024 +0800

Test: Move pr116278 run test to dg/torture [NFC]

Move the run test of pr116278 to dg/torture and leave the risc-v the
asm check under risc-v part.

PR target/116278

gcc/testsuite/ChangeLog:

* gcc.target/riscv/pr116278-run-1.c: Take compile instead of run.
* gcc.target/riscv/pr116278-run-2.c: Ditto.
* gcc.dg/torture/pr116278-run-1.c: New test.
* gcc.dg/torture/pr116278-run-2.c: New test.

Signed-off-by: Pan Li 

Diff:
---
 gcc/testsuite/gcc.dg/torture/pr116278-run-1.c   | 19 +++
 gcc/testsuite/gcc.dg/torture/pr116278-run-2.c   | 19 +++
 gcc/testsuite/gcc.target/riscv/pr116278-run-1.c |  4 ++--
 gcc/testsuite/gcc.target/riscv/pr116278-run-2.c |  4 ++--
 4 files changed, 42 insertions(+), 4 deletions(-)

diff --git a/gcc/testsuite/gcc.dg/torture/pr116278-run-1.c 
b/gcc/testsuite/gcc.dg/torture/pr116278-run-1.c
new file mode 100644
index ..ada3ac984451
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr116278-run-1.c
@@ -0,0 +1,19 @@
+/* { dg-do run } */
+/* { dg-require-effective-target int32 } */
+/* { dg-options "-O2" } */
+
+#include 
+
+int8_t b[1];
+int8_t *d = b;
+int32_t c;
+
+int main() {
+  b[0] = -40;
+  uint16_t t = (uint16_t)d[0];
+
+  c = (t < 0xFFF6 ? t : 0xFFF6) + 9;
+
+  if (c != 65505)
+__builtin_abort ();
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr116278-run-2.c 
b/gcc/testsuite/gcc.dg/torture/pr116278-run-2.c
new file mode 100644
index ..5e72d15957ea
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr116278-run-2.c
@@ -0,0 +1,19 @@
+/* { dg-do run } */
+/* { dg-require-effective-target int32 } */
+/* { dg-options "-O2" } */
+
+#include 
+
+int16_t b[1];
+int16_t *d = b;
+int64_t c;
+
+int main() {
+  b[0] = -40;
+  uint32_t t = (uint32_t)d[0];
+
+  c = (t < 0xFFF6u ? t : 0xFFF6u) + 9;
+
+  if (c != 4294967265)
+__builtin_abort ();
+}
diff --git a/gcc/testsuite/gcc.target/riscv/pr116278-run-1.c 
b/gcc/testsuite/gcc.target/riscv/pr116278-run-1.c
index d3812bdcdfb7..67cf17ebc33e 100644
--- a/gcc/testsuite/gcc.target/riscv/pr116278-run-1.c
+++ b/gcc/testsuite/gcc.target/riscv/pr116278-run-1.c
@@ -1,7 +1,7 @@
-/* { dg-do run { target { riscv_v } } } */
+/* { dg-do compile } */
 /* { dg-options "-O2 -fdump-rtl-expand-details" } */
 
-#include 
+#include 
 
 int8_t b[1];
 int8_t *d = b;
diff --git a/gcc/testsuite/gcc.target/riscv/pr116278-run-2.c 
b/gcc/testsuite/gcc.target/riscv/pr116278-run-2.c
index 669cd4f003f1..103602df2584 100644
--- a/gcc/testsuite/gcc.target/riscv/pr116278-run-2.c
+++ b/gcc/testsuite/gcc.target/riscv/pr116278-run-2.c
@@ -1,7 +1,7 @@
-/* { dg-do run { target { riscv_v } } } */
+/* { dg-do compile } */
 /* { dg-options "-O2 -fdump-rtl-expand-details" } */
 
-#include 
+#include 
 
 int16_t b[1];
 int16_t *d = b;


[gcc r14-10616] i386: testsuite: Add -no-pie for pr113689-1.c [PR70150]

2024-08-28 Thread Xi Ruoyao via Gcc-cvs
https://gcc.gnu.org/g:377c3e9a8b73b47a1211d43fee162179ee1f87e7

commit r14-10616-g377c3e9a8b73b47a1211d43fee162179ee1f87e7
Author: Xi Ruoyao 
Date:   Mon May 6 11:33:43 2024 +0800

i386: testsuite: Add -no-pie for pr113689-1.c [PR70150]

For a --enable-default-pie build, using -fno-pic (for compiler) but
not -no-pie (for linker) triggers some linker warnings counted as
excess errors:

/usr/bin/ld: /tmp/cc8MgxiR.o: warning: relocation in read-only
section `.text.startup'
/usr/bin/ld: warning: creating DT_TEXTREL in a PIE

gcc/testsuite/ChangeLog:

PR testsuite/70150
* gcc.target/i386/pr113689-1.c (dg-options): Add -no-pie.

(cherry picked from commit 331f7d8a393af99afccdb2729d4ab45797fd7a86)

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

diff --git a/gcc/testsuite/gcc.target/i386/pr113689-1.c 
b/gcc/testsuite/gcc.target/i386/pr113689-1.c
index 9b8474ed9330..0424db2dfdca 100644
--- a/gcc/testsuite/gcc.target/i386/pr113689-1.c
+++ b/gcc/testsuite/gcc.target/i386/pr113689-1.c
@@ -1,5 +1,5 @@
 /* { dg-do run { target { lp64 && fpic } } } */
-/* { dg-options "-O2 -fno-pic -fprofile -mcmodel=large" } */
+/* { dg-options "-O2 -fno-pic -no-pie -fprofile -mcmodel=large" } */
 /* { dg-skip-if "PR90698" { *-*-darwin* } } */
 /* { dg-skip-if "PR113909" { *-*-solaris2* } } */


[gcc r14-10617] i386: testsuite: Adapt fentryname3.c for r14-811 change [PR70150]

2024-08-28 Thread Xi Ruoyao via Gcc-cvs
https://gcc.gnu.org/g:f5b3dae221e6e41ebd806f504d83012173737dab

commit r14-10617-gf5b3dae221e6e41ebd806f504d83012173737dab
Author: Xi Ruoyao 
Date:   Mon May 6 11:39:14 2024 +0800

i386: testsuite: Adapt fentryname3.c for r14-811 change [PR70150]

After r14-811 "call *nop@GOTPCREL(%rip)" is only generated with
-mno-direct-extern-access even if --enable-default-pie.  So the r13-1614
change to this file is not valid anymore.

gcc/testsuite/ChangeLog:

PR testsuite/70150
* gcc.target/i386/fentryname3.c (dg-final): Revert r13-1614
change.

(cherry picked from commit 8035619b7313d9503852e1c7c8c06cfddca4d648)

Diff:
---
 gcc/testsuite/gcc.target/i386/fentryname3.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/gcc/testsuite/gcc.target/i386/fentryname3.c 
b/gcc/testsuite/gcc.target/i386/fentryname3.c
index c14a4ebb0cf5..bd7c997c178f 100644
--- a/gcc/testsuite/gcc.target/i386/fentryname3.c
+++ b/gcc/testsuite/gcc.target/i386/fentryname3.c
@@ -3,8 +3,7 @@
 /* { dg-require-profiling "-pg" } */
 /* { dg-options "-pg -mfentry"  } */
 /* { dg-final { scan-assembler "section.*__entry_loc" } } */
-/* { dg-final { scan-assembler "0x0f, 0x1f, 0x44, 0x00, 0x00" { target nonpic 
} } } */
-/* { dg-final { scan-assembler "call\t\\*nop@GOTPCREL" { target { ! nonpic } } 
} } */
+/* { dg-final { scan-assembler "0x0f, 0x1f, 0x44, 0x00, 0x00" } } */
 /* { dg-final { scan-assembler-not "__fentry__" } } */
 
 __attribute__((fentry_name("nop"), fentry_section("__entry_loc")))


[gcc r15-3245] libstdc++: remove extra semicolons

2024-08-28 Thread Jason Merrill via Libstdc++-cvs
https://gcc.gnu.org/g:7b500fa34ad88d5fdd4bf74eb2737b214749075b

commit r15-3245-g7b500fa34ad88d5fdd4bf74eb2737b214749075b
Author: Jason Merrill 
Date:   Tue Aug 27 13:13:40 2024 -0400

libstdc++: remove extra semicolons

The semicolons after each macro invocation here end up following the closing
brace of a function, leading to -Wextra-semi pedwarns.

libstdc++-v3/ChangeLog:

* include/decimal/decimal.h (_DEFINE_DECIMAL_BINARY_OP_WITH_INT):
Remove redundant semicolons.

Diff:
---
 libstdc++-v3/include/decimal/decimal.h | 24 
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/libstdc++-v3/include/decimal/decimal.h 
b/libstdc++-v3/include/decimal/decimal.h
index 6ecd16370835..99376a60cdf6 100644
--- a/libstdc++-v3/include/decimal/decimal.h
+++ b/libstdc++-v3/include/decimal/decimal.h
@@ -336,18 +336,18 @@ namespace decimal
   }
 
 #define _DEFINE_DECIMAL_BINARY_OP_WITH_INT(_Op, _T1)   \
-  _DEFINE_DECIMAL_BINARY_OP_LHS(_Op, _T1, int);\
-  _DEFINE_DECIMAL_BINARY_OP_LHS(_Op, _T1, unsigned int);   \
-  _DEFINE_DECIMAL_BINARY_OP_LHS(_Op, _T1, long);   \
-  _DEFINE_DECIMAL_BINARY_OP_LHS(_Op, _T1, unsigned long);  \
-  _DEFINE_DECIMAL_BINARY_OP_LHS(_Op, _T1, long long);  \
-  _DEFINE_DECIMAL_BINARY_OP_LHS(_Op, _T1, unsigned long long); \
-  _DEFINE_DECIMAL_BINARY_OP_RHS(_Op, _T1, int);\
-  _DEFINE_DECIMAL_BINARY_OP_RHS(_Op, _T1, unsigned int);   \
-  _DEFINE_DECIMAL_BINARY_OP_RHS(_Op, _T1, long);   \
-  _DEFINE_DECIMAL_BINARY_OP_RHS(_Op, _T1, unsigned long);  \
-  _DEFINE_DECIMAL_BINARY_OP_RHS(_Op, _T1, long long);  \
-  _DEFINE_DECIMAL_BINARY_OP_RHS(_Op, _T1, unsigned long long); \
+  _DEFINE_DECIMAL_BINARY_OP_LHS(_Op, _T1, int) \
+  _DEFINE_DECIMAL_BINARY_OP_LHS(_Op, _T1, unsigned int)\
+  _DEFINE_DECIMAL_BINARY_OP_LHS(_Op, _T1, long)\
+  _DEFINE_DECIMAL_BINARY_OP_LHS(_Op, _T1, unsigned long)   \
+  _DEFINE_DECIMAL_BINARY_OP_LHS(_Op, _T1, long long)   \
+  _DEFINE_DECIMAL_BINARY_OP_LHS(_Op, _T1, unsigned long long)  \
+  _DEFINE_DECIMAL_BINARY_OP_RHS(_Op, _T1, int) \
+  _DEFINE_DECIMAL_BINARY_OP_RHS(_Op, _T1, unsigned int)\
+  _DEFINE_DECIMAL_BINARY_OP_RHS(_Op, _T1, long)\
+  _DEFINE_DECIMAL_BINARY_OP_RHS(_Op, _T1, unsigned long)   \
+  _DEFINE_DECIMAL_BINARY_OP_RHS(_Op, _T1, long long)   \
+  _DEFINE_DECIMAL_BINARY_OP_RHS(_Op, _T1, unsigned long long)
 
   _DEFINE_DECIMAL_BINARY_OP_WITH_DEC(+, decimal32, decimal32, decimal32)
   _DEFINE_DECIMAL_BINARY_OP_WITH_INT(+, decimal32)


[gcc r15-3246] libstdc++: add missing return

2024-08-28 Thread Jason Merrill via Gcc-cvs
https://gcc.gnu.org/g:5974da3dfb6b4c205c14353f59b4369a3437e543

commit r15-3246-g5974da3dfb6b4c205c14353f59b4369a3437e543
Author: Jason Merrill 
Date:   Tue Aug 27 13:14:05 2024 -0400

libstdc++: add missing return

The return seems to have been lost in the r15-1858 RAII overhaul.

libstdc++-v3/ChangeLog:

* include/bits/stl_uninitialized.h (__uninitialized_move_copy): Add
missing return.

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

diff --git a/libstdc++-v3/include/bits/stl_uninitialized.h 
b/libstdc++-v3/include/bits/stl_uninitialized.h
index a9965f262696..f663057b1a1e 100644
--- a/libstdc++-v3/include/bits/stl_uninitialized.h
+++ b/libstdc++-v3/include/bits/stl_uninitialized.h
@@ -540,6 +540,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   __result = __mid; // Everything up to __mid is now guarded.
   __result = std::__uninitialized_copy_a(__first2, __last2, __mid, 
__alloc);
   __guard.release();
+  return __result;
 }
 
   // __uninitialized_fill_move


[gcc r15-3247] libstdc++: avoid -Wzero-as-null-pointer-constant

2024-08-28 Thread Jason Merrill via Gcc-cvs
https://gcc.gnu.org/g:28f94bf91a536395347a2da5558f0ddf014e814f

commit r15-3247-g28f94bf91a536395347a2da5558f0ddf014e814f
Author: Jason Merrill 
Date:   Tue Aug 27 13:15:52 2024 -0400

libstdc++: avoid -Wzero-as-null-pointer-constant

libstdc++-v3/ChangeLog:

* include/std/coroutine (coroutine_handle): Use nullptr instead of
0 as initializer for _M_fr_ptr.

Diff:
---
 libstdc++-v3/include/std/coroutine | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libstdc++-v3/include/std/coroutine 
b/libstdc++-v3/include/std/coroutine
index 908c1178a149..ccd016b255eb 100644
--- a/libstdc++-v3/include/std/coroutine
+++ b/libstdc++-v3/include/std/coroutine
@@ -99,7 +99,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 {
 public:
   // [coroutine.handle.con], construct/reset
-  constexpr coroutine_handle() noexcept : _M_fr_ptr(0) {}
+  constexpr coroutine_handle() noexcept : _M_fr_ptr(nullptr) {}
 
   constexpr coroutine_handle(std::nullptr_t __h) noexcept
: _M_fr_ptr(__h)


[gcc r15-3248] libstdc++: fix testcase regexp

2024-08-28 Thread Jason Merrill via Gcc-cvs
https://gcc.gnu.org/g:7bd2a2f9e3ef9f7de4c2f478241f7083cc54d7d3

commit r15-3248-g7bd2a2f9e3ef9f7de4c2f478241f7083cc54d7d3
Author: Jason Merrill 
Date:   Tue Aug 27 13:16:47 2024 -0400

libstdc++: fix testcase regexp

The unescaped * broke the match.

libstdc++-v3/ChangeLog:

* testsuite/20_util/default_delete/void_neg.cc: Fix regexp quoting.

Diff:
---
 libstdc++-v3/testsuite/20_util/default_delete/void_neg.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libstdc++-v3/testsuite/20_util/default_delete/void_neg.cc 
b/libstdc++-v3/testsuite/20_util/default_delete/void_neg.cc
index 709cc915fd59..ceb03a9e89e3 100644
--- a/libstdc++-v3/testsuite/20_util/default_delete/void_neg.cc
+++ b/libstdc++-v3/testsuite/20_util/default_delete/void_neg.cc
@@ -29,4 +29,4 @@ void test01()
 }
 
 // { dg-prune-output "invalid application of 'sizeof' to a void type" }
-// { dg-prune-output "deleting 'void*' is undefined" }
+// { dg-prune-output {deleting 'void\*' is undefined} }


[gcc r15-3249] libgomp: Add interop types and routines to OpenMP's headers and module

2024-08-28 Thread Tobias Burnus via Gcc-cvs
https://gcc.gnu.org/g:0beac1db38855eae0f71fa982ed05069d3873a9c

commit r15-3249-g0beac1db38855eae0f71fa982ed05069d3873a9c
Author: Tobias Burnus 
Date:   Wed Aug 28 11:50:43 2024 +0200

libgomp: Add interop types and routines to OpenMP's headers and module

This commit adds OpenMP 5.1+'s interop enumeration, type and routine
declarations to the C/C++ header file and, new in OpenMP TR13, also to
the Fortran module and omp_lib.h header file.

While a stub implementation is provided, only with foreign runtime
support by the libgomp GPU plugins and with the 'interop' directive,
this becomes really useful.

libgomp/ChangeLog:

* fortran.c (omp_get_interop_str_, omp_get_interop_name_,
omp_get_interop_type_desc_, omp_get_interop_rc_desc_): Add.
* libgomp.map (GOMP_5.1.3): New; add interop routines.
* omp.h.in: Add interop typedefs, enum and prototypes.
(__GOMP_DEFAULT_NULL): Define.
(omp_target_memcpy_async, omp_target_memcpy_rect_async):
Use it for the optional depend argument.
* omp_lib.f90.in: Add paramters and interfaces for interop.
* omp_lib.h.in: Likewise; move F90 '&' to column 81 for
-ffree-length-80.
* target.c (omp_get_num_interop_properties, omp_get_interop_int,
omp_get_interop_ptr, omp_get_interop_str, omp_get_interop_name,
omp_get_interop_type_desc, omp_get_interop_rc_desc): Add.
* config/gcn/target.c (omp_get_num_interop_properties,
omp_get_interop_int, omp_get_interop_ptr, omp_get_interop_str,
omp_get_interop_name, omp_get_interop_type_desc,
omp_get_interop_rc_desc): Add.
* config/nvptx/target.c (omp_get_num_interop_properties,
omp_get_interop_int, omp_get_interop_ptr, omp_get_interop_str,
omp_get_interop_name, omp_get_interop_type_desc,
omp_get_interop_rc_desc): Add.
* testsuite/libgomp.c-c++-common/interop-routines-1.c: New test.
* testsuite/libgomp.c-c++-common/interop-routines-2.c: New test.
* testsuite/libgomp.fortran/interop-routines-1.F90: New test.
* testsuite/libgomp.fortran/interop-routines-2.F90: New test.
* testsuite/libgomp.fortran/interop-routines-3.F: New test.
* testsuite/libgomp.fortran/interop-routines-4.F: New test.
* testsuite/libgomp.fortran/interop-routines-5.F: New test.
* testsuite/libgomp.fortran/interop-routines-6.F: New test.
* testsuite/libgomp.fortran/interop-routines-7.F90: New test.

Diff:
---
 libgomp/config/gcn/target.c| 105 ++
 libgomp/config/nvptx/target.c  | 105 ++
 libgomp/fortran.c  |  41 +++
 libgomp/libgomp.map|  15 +
 libgomp/omp.h.in   |  78 -
 libgomp/omp_lib.f90.in |  99 ++
 libgomp/omp_lib.h.in   | 170 --
 libgomp/target.c   | 110 +++
 .../libgomp.c-c++-common/interop-routines-1.c  | 287 +
 .../libgomp.c-c++-common/interop-routines-2.c  | 354 +
 .../libgomp.fortran/interop-routines-1.F90 | 236 ++
 .../libgomp.fortran/interop-routines-2.F90 |   3 +
 .../testsuite/libgomp.fortran/interop-routines-3.F |   2 +
 .../testsuite/libgomp.fortran/interop-routines-4.F |   4 +
 .../testsuite/libgomp.fortran/interop-routines-5.F |   4 +
 .../testsuite/libgomp.fortran/interop-routines-6.F |   4 +
 .../libgomp.fortran/interop-routines-7.F90 | 290 +
 17 files changed, 1883 insertions(+), 24 deletions(-)

diff --git a/libgomp/config/gcn/target.c b/libgomp/config/gcn/target.c
index 9cafea4e2cc7..f7fa6aa6396c 100644
--- a/libgomp/config/gcn/target.c
+++ b/libgomp/config/gcn/target.c
@@ -185,3 +185,108 @@ GOMP_target_enter_exit_data (int device, size_t mapnum, 
void **hostaddrs,
   (void) depend;
   __builtin_unreachable ();
 }
+
+int
+omp_get_num_interop_properties (const omp_interop_t interop
+   __attribute__ ((unused)))
+{
+  return 0;
+}
+
+omp_intptr_t
+omp_get_interop_int (const omp_interop_t interop,
+omp_interop_property_t property_id,
+omp_interop_rc_t *ret_code)
+{
+  if (ret_code == NULL)
+return 0;
+  if (property_id < omp_ipr_first || property_id >= 0)
+*ret_code = omp_irc_out_of_range;
+  else if (interop == omp_interop_none)
+*ret_code = omp_irc_empty;
+  else
+*ret_code = omp_irc_other;
+  return 0;
+}
+
+void *
+omp_get_interop_ptr (const omp_interop_t interop,
+omp_interop_property_t property_id,
+omp_interop_rc_t *ret_code)
+{
+  if (ret_code == NULL)
+return NULL;
+  if (property_id

[gcc r15-3250] c++: add missing -Wc++??-extensions checks

2024-08-28 Thread Jason Merrill via Gcc-cvs
https://gcc.gnu.org/g:7f4f1bb29a47fbe63a15dda8acfe247b2e934959

commit r15-3250-g7f4f1bb29a47fbe63a15dda8acfe247b2e934959
Author: Jason Merrill 
Date:   Tue Aug 27 13:14:45 2024 -0400

c++: add missing -Wc++??-extensions checks

The pedwarns for each of these features should be silenced by
the appropriate -Wno-c++??-extensions.

The handle_pragma_diagnostic_impl change is necessary so that we handle
-Wc++23-extensions early so it's available to interpret_float while lexing.

gcc/c-family/ChangeLog:

* c-pragma.cc (handle_pragma_diagnostic_impl): Also handle
-Wc++23-extensions early.
* c-lex.cc (interpret_float): Use -Wc++23-extensions for extended
floating point literal pedwarn.

gcc/cp/ChangeLog:

* parser.cc (cp_parser_simple_type_specifier): Use
-Wc++20-extensions for auto parameter pedwarn.
* pt.cc (do_decl_instantiation, do_type_instantiation): Use
-Wc++11-extensions for 'extern template'.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/extern_template-7.C: New test.
* g++.dg/cpp23/ext-floating19.C: New test.
* g++.dg/cpp2a/abbrev-fn1.C: New test.

Diff:
---
 gcc/c-family/c-lex.cc  |  8 
 gcc/c-family/c-pragma.cc   |  2 ++
 gcc/cp/parser.cc   |  2 +-
 gcc/cp/pt.cc   |  8 
 gcc/testsuite/g++.dg/cpp0x/extern_template-7.C | 10 ++
 gcc/testsuite/g++.dg/cpp23/ext-floating19.C| 20 
 gcc/testsuite/g++.dg/cpp2a/abbrev-fn1.C|  6 ++
 7 files changed, 47 insertions(+), 9 deletions(-)

diff --git a/gcc/c-family/c-lex.cc b/gcc/c-family/c-lex.cc
index ff5ce2bf729a..d99d8ea2c0c5 100644
--- a/gcc/c-family/c-lex.cc
+++ b/gcc/c-family/c-lex.cc
@@ -1254,8 +1254,8 @@ interpret_float (const cpp_token *token, unsigned int 
flags,
  }
else if (!extended)
  {
-   if (cxx_dialect < cxx23)
- pedwarn (input_location, OPT_Wpedantic,
+   if (cxx_dialect < cxx23 && pedantic)
+ pedwarn (input_location, OPT_Wc__23_extensions,
   "% or % suffix on floating constant only "
   "available with %<-std=c++2b%> or %<-std=gnu++2b%>",
   n, n);
@@ -1275,8 +1275,8 @@ interpret_float (const cpp_token *token, unsigned int 
flags,
if (!c_dialect_cxx ())
  pedwarn (input_location, OPT_Wpedantic,
   "non-standard suffix on floating constant");
-   else if (cxx_dialect < cxx23)
- pedwarn (input_location, OPT_Wpedantic,
+   else if (cxx_dialect < cxx23 && pedantic)
+ pedwarn (input_location, OPT_Wc__23_extensions,
   "% or % suffix on floating constant only "
   "available with %<-std=c++2b%> or %<-std=gnu++2b%>");
   }
diff --git a/gcc/c-family/c-pragma.cc b/gcc/c-family/c-pragma.cc
index ed2a7a00e9eb..bb867eb995aa 100644
--- a/gcc/c-family/c-pragma.cc
+++ b/gcc/c-family/c-pragma.cc
@@ -964,6 +964,8 @@ handle_pragma_diagnostic_impl ()
   unsigned int option_index = find_opt (data.option_str + 1, lang_mask);
 
   if (early && !(c_option_is_from_cpp_diagnostics (option_index)
+/* For interpret_float.  */
+|| option_index == OPT_Wc__23_extensions
 || option_index == OPT_Wunknown_pragmas))
 return;
 
diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc
index a722641be347..918072dbf637 100644
--- a/gcc/cp/parser.cc
+++ b/gcc/cp/parser.cc
@@ -20527,7 +20527,7 @@ cp_parser_simple_type_specifier (cp_parser* parser,
error_at (token->location,
 "use of % in template argument");
  else if (!flag_concepts)
-   pedwarn (token->location, 0,
+   pedwarn (token->location, OPT_Wc__20_extensions,
 "use of % in parameter declaration "
 "only available with %<-std=c++20%> or %<-fconcepts%>");
  else if (cxx_dialect < cxx14)
diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc
index 24a6241d3a51..9e0f0486ffbc 100644
--- a/gcc/cp/pt.cc
+++ b/gcc/cp/pt.cc
@@ -26531,8 +26531,8 @@ do_decl_instantiation (tree decl, tree storage)
 ;
   else if (storage == ridpointers[(int) RID_EXTERN])
 {
-  if (cxx_dialect == cxx98)
-   pedwarn (input_location, OPT_Wpedantic,
+  if (cxx_dialect == cxx98 && pedantic)
+   pedwarn (input_location, OPT_Wc__11_extensions,
 "ISO C++ 1998 forbids the use of % on explicit "
 "instantiations");
   extern_p = 1;
@@ -26598,8 +26598,8 @@ do_type_instantiation (tree t, tree storage, 
tsubst_flags_t complain)
 {
   if (storage == ridpointers[(int) RID_EXTERN])
{
- if (cxx_dialect == cxx98)
-   pedwarn (input_location, OPT_Wpedantic,
+ if (cxx_dialect == cxx98 

[gcc r15-3252] Fix leak of SLP nodes when building store interleaving

2024-08-28 Thread Richard Biener via Gcc-cvs
https://gcc.gnu.org/g:04065d8c3083f76f877dc62d56807a7d3638be69

commit r15-3252-g04065d8c3083f76f877dc62d56807a7d3638be69
Author: Richard Biener 
Date:   Wed Aug 28 11:04:07 2024 +0200

Fix leak of SLP nodes when building store interleaving

The following fixes a leak of the discovered single-lane store
SLP nodes from which we only use their children.  This uncovers
a latent reference counting issue in the interleaving build where
we fail to increment their reference count.

* tree-vect-slp.cc (vect_build_slp_store_interleaving):
Fix reference counting.
(vect_build_slp_instance): Release rhs_nodes.

Diff:
---
 gcc/tree-vect-slp.cc | 4 
 1 file changed, 4 insertions(+)

diff --git a/gcc/tree-vect-slp.cc b/gcc/tree-vect-slp.cc
index 79d83efb0159..d110c992b046 100644
--- a/gcc/tree-vect-slp.cc
+++ b/gcc/tree-vect-slp.cc
@@ -3486,6 +3486,7 @@ vect_build_slp_store_interleaving (vec 
&rhs_nodes,
{
  SLP_TREE_CHILDREN (perm)
.quick_push (SLP_TREE_CHILDREN (rhs_nodes[j])[l]);
+ SLP_TREE_CHILDREN (rhs_nodes[j])[l]->refcnt++;
  for (unsigned k = 0;
   k < SLP_TREE_SCALAR_STMTS (rhs_nodes[j]).length (); ++k)
{
@@ -3949,6 +3950,9 @@ vect_build_slp_instance (vec_info *vinfo,
  /* Now we assume we can build the root SLP node from all stores.  */
  node = vect_build_slp_store_interleaving (rhs_nodes, scalar_stmts);
 
+ while (!rhs_nodes.is_empty ())
+   vect_free_slp_tree (rhs_nodes.pop ());
+
  /* Create a new SLP instance.  */
  slp_instance new_instance = XNEW (class _slp_instance);
  SLP_INSTANCE_TREE (new_instance) = node;


[gcc r15-3253] Add debug overload for slp_instance

2024-08-28 Thread Richard Biener via Gcc-cvs
https://gcc.gnu.org/g:2c0b574ac6a2d01b099fcb60e46414e96b93f0a9

commit r15-3253-g2c0b574ac6a2d01b099fcb60e46414e96b93f0a9
Author: Richard Biener 
Date:   Wed Aug 28 11:06:00 2024 +0200

Add debug overload for slp_instance

I found it helpful to be able to print a whole SLP instance from gdb.

* tree-vect-slp.cc (debug): Add overload for slp_instance.

Diff:
---
 gcc/tree-vect-slp.cc | 9 +
 1 file changed, 9 insertions(+)

diff --git a/gcc/tree-vect-slp.cc b/gcc/tree-vect-slp.cc
index d110c992b046..fe4981177bf0 100644
--- a/gcc/tree-vect-slp.cc
+++ b/gcc/tree-vect-slp.cc
@@ -3038,6 +3038,15 @@ vect_print_slp_graph (dump_flags_t dump_kind, 
dump_location_t loc,
   vect_print_slp_graph (dump_kind, loc, entry, visited);
 }
 
+DEBUG_FUNCTION void
+debug (slp_instance instance)
+{
+  debug_dump_context ctx;
+  vect_print_slp_graph (MSG_NOTE,
+   dump_location_t::from_location_t (UNKNOWN_LOCATION),
+   SLP_INSTANCE_TREE (instance));
+}
+
 /* Mark the tree rooted at NODE with PURE_SLP.  */
 
 static void


[gcc r15-3251] Split out vect_build_slp_store_interleaving

2024-08-28 Thread Richard Biener via Gcc-cvs
https://gcc.gnu.org/g:ad895a28905c143ec731741cc93ebb340f59bfa8

commit r15-3251-gad895a28905c143ec731741cc93ebb340f59bfa8
Author: Richard Biener 
Date:   Tue Aug 27 14:19:38 2024 +0200

Split out vect_build_slp_store_interleaving

This splits out SLP store interleaving into a separate function.

* tree-vect-slp.cc (vect_build_slp_store_interleaving): Split
out from ...
(vect_build_slp_instance): Here.

Diff:
---
 gcc/tree-vect-slp.cc | 356 ++-
 1 file changed, 182 insertions(+), 174 deletions(-)

diff --git a/gcc/tree-vect-slp.cc b/gcc/tree-vect-slp.cc
index d6f34d0b73d0..79d83efb0159 100644
--- a/gcc/tree-vect-slp.cc
+++ b/gcc/tree-vect-slp.cc
@@ -3457,6 +3457,186 @@ vect_analyze_slp_instance (vec_info *vinfo,
   stmt_vec_info stmt_info, slp_instance_kind kind,
   unsigned max_tree_size, unsigned *limit);
 
+/* Build an interleaving scheme for the store sources RHS_NODES from
+   SCALAR_STMTS.  */
+
+static slp_tree
+vect_build_slp_store_interleaving (vec &rhs_nodes,
+  vec &scalar_stmts)
+{
+  unsigned int group_size = scalar_stmts.length ();
+  slp_tree node = vect_create_new_slp_node (scalar_stmts,
+   SLP_TREE_CHILDREN
+ (rhs_nodes[0]).length ());
+  SLP_TREE_VECTYPE (node) = SLP_TREE_VECTYPE (rhs_nodes[0]);
+  for (unsigned l = 0;
+   l < SLP_TREE_CHILDREN (rhs_nodes[0]).length (); ++l)
+{
+  /* And a permute merging all RHS SLP trees.  */
+  slp_tree perm = vect_create_new_slp_node (rhs_nodes.length (),
+   VEC_PERM_EXPR);
+  SLP_TREE_CHILDREN (node).quick_push (perm);
+  SLP_TREE_LANE_PERMUTATION (perm).create (group_size);
+  SLP_TREE_VECTYPE (perm) = SLP_TREE_VECTYPE (node);
+  SLP_TREE_LANES (perm) = group_size;
+  /* ???  We should set this NULL but that's not expected.  */
+  SLP_TREE_REPRESENTATIVE (perm)
+   = SLP_TREE_REPRESENTATIVE (SLP_TREE_CHILDREN (rhs_nodes[0])[l]);
+  for (unsigned j = 0; j < rhs_nodes.length (); ++j)
+   {
+ SLP_TREE_CHILDREN (perm)
+   .quick_push (SLP_TREE_CHILDREN (rhs_nodes[j])[l]);
+ for (unsigned k = 0;
+  k < SLP_TREE_SCALAR_STMTS (rhs_nodes[j]).length (); ++k)
+   {
+ /* ???  We should populate SLP_TREE_SCALAR_STMTS
+or SLP_TREE_SCALAR_OPS but then we might have
+a mix of both in our children.  */
+ SLP_TREE_LANE_PERMUTATION (perm)
+   .quick_push (std::make_pair (j, k));
+   }
+   }
+
+  /* Now we have a single permute node but we cannot code-generate
+the case with more than two inputs.
+Perform pairwise reduction, reducing the two inputs
+with the least number of lanes to one and then repeat until
+we end up with two inputs.  That scheme makes sure we end
+up with permutes satisfying the restriction of requiring at
+most two vector inputs to produce a single vector output
+when the number of lanes is even.  */
+  while (SLP_TREE_CHILDREN (perm).length () > 2)
+   {
+ /* When we have three equal sized groups left the pairwise
+reduction does not result in a scheme that avoids using
+three vectors.  Instead merge the first two groups
+to the final size with do-not-care elements (chosen
+from the first group) and then merge with the third.
+ { A0, B0,  x, A1, B1,  x, ... }
+  -> { A0, B0, C0, A1, B1, C1, ... }
+This handles group size of three (and at least
+power-of-two multiples of that).  */
+ if (SLP_TREE_CHILDREN (perm).length () == 3
+ && (SLP_TREE_LANES (SLP_TREE_CHILDREN (perm)[0])
+ == SLP_TREE_LANES (SLP_TREE_CHILDREN (perm)[1]))
+ && (SLP_TREE_LANES (SLP_TREE_CHILDREN (perm)[0])
+ == SLP_TREE_LANES (SLP_TREE_CHILDREN (perm)[2])))
+   {
+ int ai = 0;
+ int bi = 1;
+ slp_tree a = SLP_TREE_CHILDREN (perm)[ai];
+ slp_tree b = SLP_TREE_CHILDREN (perm)[bi];
+ unsigned n = SLP_TREE_LANES (perm);
+
+ slp_tree permab = vect_create_new_slp_node (2, VEC_PERM_EXPR);
+ SLP_TREE_LANES (permab) = n;
+ SLP_TREE_LANE_PERMUTATION (permab).create (n);
+ SLP_TREE_VECTYPE (permab) = SLP_TREE_VECTYPE (perm);
+ /* ???  Should be NULL but that's not expected.  */
+ SLP_TREE_REPRESENTATIVE (permab) = SLP_TREE_REPRESENTATIVE (perm);
+ SLP_TREE_CHILDREN (permab).quick_push (a);
+ for (unsigned k = 0; k < SLP_TREE_LANES (a); ++k)
+   SLP_TREE_LANE_PERMUTATION (permab)
+ .quick_

[gcc r15-3254] testsuite: Add scan-ltrans-rtl* for use in dg-final [PR116140]

2024-08-28 Thread Alex Coplan via Gcc-cvs
https://gcc.gnu.org/g:3f51f0dc88ec21c1ec79df694200f10ef85915f4

commit r15-3254-g3f51f0dc88ec21c1ec79df694200f10ef85915f4
Author: Alex Coplan 
Date:   Tue Aug 27 16:51:12 2024 +

testsuite: Add scan-ltrans-rtl* for use in dg-final [PR116140]

This extends the scan-ltrans-tree* helpers to create RTL variants.  This
is needed to check the behaviour of an RTL pass under LTO.

gcc/ChangeLog:

PR libstdc++/116140
* doc/sourcebuild.texi: Document ltrans-rtl value of kind for
scan--dump*.

gcc/testsuite/ChangeLog:

PR libstdc++/116140
* lib/scanltranstree.exp (scan-ltrans-rtl-dump): New.
(scan-ltrans-rtl-dump-not): New.
(scan-ltrans-rtl-dump-dem): New.
(scan-ltrans-rtl-dump-dem-not): New.
(scan-ltrans-rtl-dump-times): New.

Diff:
---
 gcc/doc/sourcebuild.texi |  4 +-
 gcc/testsuite/lib/scanltranstree.exp | 80 +---
 2 files changed, 39 insertions(+), 45 deletions(-)

diff --git a/gcc/doc/sourcebuild.texi b/gcc/doc/sourcebuild.texi
index 3c55f1037953..0636fc0567c5 100644
--- a/gcc/doc/sourcebuild.texi
+++ b/gcc/doc/sourcebuild.texi
@@ -3627,8 +3627,8 @@ stands for zero or more unmatched lines; the whitespace 
after
 @subsubsection Scan optimization dump files
 
 These commands are available for @var{kind} of @code{tree}, @code{ltrans-tree},
-@code{offload-tree}, @code{rtl}, @code{offload-rtl}, @code{ipa},
-@code{offload-ipa}, and @code{wpa-ipa}.
+@code{offload-tree}, @code{rtl}, @code{ltrans-rtl}, @code{offload-rtl},
+@code{ipa}, @code{offload-ipa}, and @code{wpa-ipa}.
 
 @table @code
 @item scan-@var{kind}-dump @var{regex} @var{suffix} [@{ target/xfail 
@var{selector} @}]
diff --git a/gcc/testsuite/lib/scanltranstree.exp 
b/gcc/testsuite/lib/scanltranstree.exp
index bc6e02dc3696..a7d4de3765fc 100644
--- a/gcc/testsuite/lib/scanltranstree.exp
+++ b/gcc/testsuite/lib/scanltranstree.exp
@@ -19,50 +19,44 @@
 
 load_lib scandump.exp
 
-# The first item in the list is an LTO equivalent of the second item
-# in the list; see the documentation of the second item for details.
-foreach { name scan type suffix } {
-scan-ltrans-tree-dump scan-dump ltrans-tree t
-scan-ltrans-tree-dump-not scan-dump-not ltrans-tree t
-scan-ltrans-tree-dump-dem scan-dump-dem ltrans-tree t
-scan-ltrans-tree-dump-dem-not scan-dump-dem-not ltrans-tree t
-} {
-eval [string map [list @NAME@ $name \
-  @SCAN@ $scan \
-  @TYPE@ $type \
-  @SUFFIX@ $suffix] {
-proc @NAME@ { args } {
-   if { [llength $args] < 2 } {
-   error "@NAME@: too few arguments"
-   return
-   }
-   if { [llength $args] > 3 } {
-   error "@NAME@: too many arguments"
-   return
+# Define scan-ltrans-{tree,rtl}-dump{,-not,-dem,-dem-not}.  These are LTO
+# variants of the corresponding functions without -ltrans in the name.
+foreach ir { tree rtl } {
+foreach modifier { {} -not -dem -dem-not } {
+   eval [string map [list @NAME@ scan-ltrans-$ir-dump$modifier \
+  @SCAN@ scan$modifier \
+  @TYPE@ ltrans-$ir \
+  @SUFFIX@ [string index $ir 0]] {
+   proc @NAME@ { args } {
+   if { [llength $args] < 2 } {
+   error "@NAME@: too few arguments"
+   return
+   }
+   if { [llength $args] > 3 } {
+   error "@NAME@: too many arguments"
+   return
+   }
+   if { [llength $args] >= 3 } {
+   @SCAN@ @TYPE@ [lindex $args 0] \
+   "\[0-9\]\[0-9\]\[0-9\]@SUFFIX@.[lindex $args 1]" \
+   ".ltrans0.ltrans" \
+   [lindex $args 2]
+   } else {
+   @SCAN@ @TYPE@ [lindex $args 0] \
+   "\[0-9\]\[0-9\]\[0-9\]@SUFFIX@.[lindex $args 1]" \
+   ".ltrans0.ltrans"
+   }
}
-   if { [llength $args] >= 3 } {
-   @SCAN@ @TYPE@ [lindex $args 0] \
-   "\[0-9\]\[0-9\]\[0-9\]@SUFFIX@.[lindex $args 1]" \
-   ".ltrans0.ltrans" \
-   [lindex $args 2]
-   } else {
-   @SCAN@ @TYPE@ [lindex $args 0] \
-   "\[0-9\]\[0-9\]\[0-9\]@SUFFIX@.[lindex $args 1]" \
-   ".ltrans0.ltrans"
-   }
-}
-}]
+   }]
+}
 }
 
-# The first item in the list is an LTO equivalent of the second item
-# in the list; see the documentation of the second item for details.
-foreach { name scan type suffix } {
-scan-ltrans-tree-dump-times scan-dump-times ltrans-tree t
-} {
-eval [string map [list @NAME@ $name \
-  @SCAN@ $scan \
-

[gcc r15-3255] libstdc++: avoid -Wsign-compare

2024-08-28 Thread Jason Merrill via Libstdc++-cvs
https://gcc.gnu.org/g:4246cf4f18053eeb47cb2a241fffa9a41573916e

commit r15-3255-g4246cf4f18053eeb47cb2a241fffa9a41573916e
Author: Jason Merrill 
Date:   Tue Aug 27 13:17:20 2024 -0400

libstdc++: avoid -Wsign-compare

-Wsign-compare complained about these comparisons between (unsigned) size_t
and (signed) streamsize, or between (unsigned) native_handle_type
and (signed) -1.  Fixed by adding casts to unify the types.

libstdc++-v3/ChangeLog:

* include/std/istream: Add cast to avoid -Wsign-compare.
* include/std/stacktrace: Likewise.

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

diff --git a/libstdc++-v3/include/std/istream b/libstdc++-v3/include/std/istream
index a2b207dae78c..730e413c290b 100644
--- a/libstdc++-v3/include/std/istream
+++ b/libstdc++-v3/include/std/istream
@@ -909,7 +909,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
  __n /= sizeof(_CharT);
  streamsize __w = __in.width();
  std::__istream_extract(__in, __s, __n);
- if (__in.good() && (__w <= 0 || __n < __w))
+ if (__in.good() && (__w <= 0 || __n < (size_t)__w))
{
  // Stopped extracting early to avoid overflowing the buffer,
  // but might have stopped anyway (and set eofbit) if at EOF.
diff --git a/libstdc++-v3/include/std/stacktrace 
b/libstdc++-v3/include/std/stacktrace
index e0a543920bc3..cd2606257fec 100644
--- a/libstdc++-v3/include/std/stacktrace
+++ b/libstdc++-v3/include/std/stacktrace
@@ -80,7 +80,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 constexpr native_handle_type
 native_handle() const noexcept { return _M_pc; }
 
-constexpr explicit operator bool() const noexcept { return _M_pc != -1; }
+constexpr explicit operator bool() const noexcept
+{ return _M_pc != (native_handle_type)-1; }
 
 // [stacktrace.entry.query], query
 [[nodiscard]]


[gcc r15-3256] gimple ssa: switchconv: Use __builtin_popcount and support more types in exp transform [PR116355]

2024-08-28 Thread Filip Kastl via Gcc-cvs
https://gcc.gnu.org/g:1c4b9826bd0d5ac471543c68f097d80b1969f599

commit r15-3256-g1c4b9826bd0d5ac471543c68f097d80b1969f599
Author: Filip Kastl 
Date:   Wed Aug 28 15:47:44 2024 +0200

gimple ssa: switchconv: Use __builtin_popcount and support more types in 
exp transform [PR116355]

The gen_pow2p function generates (a & -a) == a as a fallback for
POPCOUNT (a) == 1.  Not only is the bitmagic not equivalent to
POPCOUNT (a) == 1 but it also introduces UB (consider signed
a = INT_MIN).

This patch rewrites gen_pow2p to always use __builtin_popcount instead.
This means that what the end result GIMPLE code is gets decided by an
already existing machinery in a later pass.  That is a cleaner solution
I think.  This existing machinery also uses a ^ (a - 1) > a - 1 which is
the correct bitmagic.

While rewriting gen_pow2p I had to add logic for converting the
operand's type to a type that __builtin_popcount accepts.  I naturally
also added this logic to gen_log2.  Thanks to this, exponential index
transform gains the capability to handle all operand types with
precision at most that of long long int.

gcc/ChangeLog:

PR tree-optimization/116355
* tree-switch-conversion.cc (can_log2): Add capability to
suggest converting the operand to a different type.
(gen_log2): Add capability to generate a conversion in case the
operand is of a type incompatible with the logarithm operation.
(can_pow2p): New function.
(gen_pow2p): Rewrite to use __builtin_popcount instead of
manually inserting an internal fn call or bitmagic.  Also add
capability to generate a conversion.
(switch_conversion::is_exp_index_transform_viable): Call
can_pow2p.  Store types suggested by can_log2 and gen_log2.
(switch_conversion::exp_index_transform): Params of gen_pow2p
and gen_log2 changed so update their calls.
* tree-switch-conversion.h: Add m_exp_index_transform_log2_type
and m_exp_index_transform_pow2p_type to switch_conversion class
to track type conversions needed to generate the "is power of 2"
and logarithm operations.

gcc/testsuite/ChangeLog:

PR tree-optimization/116355
* gcc.target/i386/switch-exp-transform-1.c: Don't test for
presence of POPCOUNT internal fn after switch conversion.  Test
for it after __builtin_popcount has had a chance to get
expanded.
* gcc.target/i386/switch-exp-transform-3.c: Also test char and
short.

Signed-off-by: Filip Kastl 

Diff:
---
 .../gcc.target/i386/switch-exp-transform-1.c   |   7 +-
 .../gcc.target/i386/switch-exp-transform-3.c   |  98 -
 gcc/tree-switch-conversion.cc  | 152 -
 gcc/tree-switch-conversion.h   |   7 +
 4 files changed, 227 insertions(+), 37 deletions(-)

diff --git a/gcc/testsuite/gcc.target/i386/switch-exp-transform-1.c 
b/gcc/testsuite/gcc.target/i386/switch-exp-transform-1.c
index 53d31460ba37..a8c9e03e515f 100644
--- a/gcc/testsuite/gcc.target/i386/switch-exp-transform-1.c
+++ b/gcc/testsuite/gcc.target/i386/switch-exp-transform-1.c
@@ -1,9 +1,10 @@
 /* { dg-do compile } */
-/* { dg-options "-O2 -fdump-tree-switchconv -mpopcnt -mbmi" } */
+/* { dg-options "-O2 -fdump-tree-switchconv -fdump-tree-widening_mul -mpopcnt 
-mbmi" } */
 
 /* Checks that exponential index transform enables switch conversion to convert
this switch into an array lookup.  Also checks that the "index variable is a
-   power of two" check has been generated.  */
+   power of two" check has been generated and that it has been later expanded
+   into an internal function.  */
 
 int foo(unsigned bar)
 {
@@ -29,4 +30,4 @@ int foo(unsigned bar)
 }
 
 /* { dg-final { scan-tree-dump "CSWTCH" "switchconv" } } */
-/* { dg-final { scan-tree-dump "POPCOUNT" "switchconv" } } */
+/* { dg-final { scan-tree-dump "POPCOUNT" "widening_mul" } } */
diff --git a/gcc/testsuite/gcc.target/i386/switch-exp-transform-3.c 
b/gcc/testsuite/gcc.target/i386/switch-exp-transform-3.c
index 64a7b1461721..5011d1ebb0e8 100644
--- a/gcc/testsuite/gcc.target/i386/switch-exp-transform-3.c
+++ b/gcc/testsuite/gcc.target/i386/switch-exp-transform-3.c
@@ -3,10 +3,104 @@
 
 /* Checks that the exponential index transformation is done for all these types
of the index variable:
+   - (unsigned) char
+   - (unsigned) short
- (unsigned) int
- (unsigned) long
- (unsigned) long long  */
 
+int unopt_char(char bit_position)
+{
+switch (bit_position)
+{
+case (1 << 0):
+return 0;
+case (1 << 1):
+return 1;
+case (1 << 2):
+return 2;
+case (1 << 3):
+return 3;
+case (1 << 4):
+   

[gcc r15-3257] Libquadmath: update doc for some constants

2024-08-28 Thread François-Xavier Coudert via Gcc-cvs
https://gcc.gnu.org/g:bdcd30e4711943cae70a1b47f8a63e96a94c02a0

commit r15-3257-gbdcd30e4711943cae70a1b47f8a63e96a94c02a0
Author: Francois-Xavier Coudert 
Date:   Tue Aug 20 18:42:31 2024 +0200

Libquadmath: update doc for some constants

libquadmath/ChangeLog:

* libquadmath.texi (M_LOG2Eq, M_LOG10Eq, M_1_PIq,
M_2_PIq, M_2_SQRTPIq, M_SQRT1_2q): Adjust descriptioni
of these constants.

Diff:
---
 libquadmath/libquadmath.texi | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/libquadmath/libquadmath.texi b/libquadmath/libquadmath.texi
index dc2a9ff374bc..901ae5546edc 100644
--- a/libquadmath/libquadmath.texi
+++ b/libquadmath/libquadmath.texi
@@ -118,18 +118,18 @@ The following mathematical constants of type 
@code{__float128} are defined.
 
 @table @asis
 @item @code{M_Eq}: the constant e (Euler's number)
-@item @code{M_LOG2Eq}: binary logarithm of 2
-@item @code{M_LOG10Eq}: common, decimal logarithm of 2
+@item @code{M_LOG2Eq}: base 2 logarithm of e
+@item @code{M_LOG10Eq}: decimal (base 10) logarithm of e
 @item @code{M_LN2q}: natural logarithm of 2
 @item @code{M_LN10q}: natural logarithm of 10
 @item @code{M_PIq}: pi
 @item @code{M_PI_2q}: pi divided by two
 @item @code{M_PI_4q}: pi divided by four
-@item @code{M_1_PIq}: one over pi
-@item @code{M_2_PIq}: one over two pi
-@item @code{M_2_SQRTPIq}: two over square root of pi
+@item @code{M_1_PIq}: one divided by pi
+@item @code{M_2_PIq}: two divided by pi
+@item @code{M_2_SQRTPIq}: two divided by square root of pi
 @item @code{M_SQRT2q}: square root of 2
-@item @code{M_SQRT1_2q}: one over square root of 2
+@item @code{M_SQRT1_2q}: one divided by square root of 2
 @end table


[gcc r15-3258] Tweak documentation of ASM_INPUT_P

2024-08-28 Thread Richard Sandiford via Gcc-cvs
https://gcc.gnu.org/g:3c9338b532fd609f5cc1c50d6a4e77e0e1ab3bc5

commit r15-3258-g3c9338b532fd609f5cc1c50d6a4e77e0e1ab3bc5
Author: Richard Sandiford 
Date:   Wed Aug 28 16:37:53 2024 +0100

Tweak documentation of ASM_INPUT_P

The documentation of ASM_INPUT_P implied that the flag has no
effect on ASM_EXPRs that have operands (and which therefore must be
extended asms).  In fact we require ASM_INPUT_P to be false for all
extended asms.

gcc/
* tree.h (ASM_INPUT_P): Fix documentation.

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

diff --git a/gcc/tree.h b/gcc/tree.h
index 5dcbb2fb5dd6..c501019717f0 100644
--- a/gcc/tree.h
+++ b/gcc/tree.h
@@ -1428,8 +1428,9 @@ class auto_suppress_location_wrappers
 #define ASM_INPUTS(NODE)TREE_OPERAND (ASM_EXPR_CHECK (NODE), 2)
 #define ASM_CLOBBERS(NODE)  TREE_OPERAND (ASM_EXPR_CHECK (NODE), 3)
 #define ASM_LABELS(NODE)   TREE_OPERAND (ASM_EXPR_CHECK (NODE), 4)
-/* Nonzero if we want to create an ASM_INPUT instead of an
-   ASM_OPERAND with no operands.  */
+/* Nonzero if the asm is a basic asm, zero if it is an extended asm.
+   Basic asms use a plain ASM_INPUT insn pattern whereas extended asms
+   use an ASM_OPERANDS insn pattern.  */
 #define ASM_INPUT_P(NODE) (ASM_EXPR_CHECK (NODE)->base.static_flag)
 #define ASM_VOLATILE_P(NODE) (ASM_EXPR_CHECK (NODE)->base.public_flag)
 /* Nonzero if we want to consider this asm as minimum length and cost


[gcc r15-3259] aarch64: Add a test for zeroing <64bits>x2_t structures

2024-08-28 Thread Richard Sandiford via Gcc-cvs
https://gcc.gnu.org/g:035c196cb9be2f1aee142240d506dde474cbe64e

commit r15-3259-g035c196cb9be2f1aee142240d506dde474cbe64e
Author: Richard Sandiford 
Date:   Wed Aug 28 16:41:08 2024 +0100

aarch64: Add a test for zeroing <64bits>x2_t structures

g:8d6c6fbc5271dde433998c09407b30e2cf195420 improved the code
generated for functions like:

  void test_s8 (int8x8x2_t *ptr) { *ptr = (int8x8x2_t) {}; }

Previously we would load zero from the constant pool, whereas
now we just use "stp xzr, xzr".  This patch adds a test for
this improvement.

gcc/testsuite/
* gcc.target/aarch64/struct_zero.c: New test.

Diff:
---
 gcc/testsuite/gcc.target/aarch64/struct_zero.c | 21 +
 1 file changed, 21 insertions(+)

diff --git a/gcc/testsuite/gcc.target/aarch64/struct_zero.c 
b/gcc/testsuite/gcc.target/aarch64/struct_zero.c
new file mode 100644
index ..13f7236a4d27
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/struct_zero.c
@@ -0,0 +1,21 @@
+/* { dg-options "-O2" } */
+
+#include 
+
+void test_s8 (int8x8x2_t *ptr) { *ptr = (int8x8x2_t) {}; }
+void test_u8 (uint8x8x2_t *ptr) { *ptr = (uint8x8x2_t) {}; }
+void test_p8 (poly8x8x2_t *ptr) { *ptr = (poly8x8x2_t) {}; }
+void test_s16 (int16x4x2_t *ptr) { *ptr = (int16x4x2_t) {}; }
+void test_u16 (uint16x4x2_t *ptr) { *ptr = (uint16x4x2_t) {}; }
+void test_p16 (poly16x4x2_t *ptr) { *ptr = (poly16x4x2_t) {}; }
+void test_bf16 (bfloat16x4x2_t *ptr) { *ptr = (bfloat16x4x2_t) {}; }
+void test_f16 (float16x4x2_t *ptr) { *ptr = (float16x4x2_t) {}; }
+void test_s32 (int32x2x2_t *ptr) { *ptr = (int32x2x2_t) {}; }
+void test_u32 (uint32x2x2_t *ptr) { *ptr = (uint32x2x2_t) {}; }
+void test_f32 (float32x2x2_t *ptr) { *ptr = (float32x2x2_t) {}; }
+void test_s64 (int64x1x2_t *ptr) { *ptr = (int64x1x2_t) {}; }
+void test_u64 (uint64x1x2_t *ptr) { *ptr = (uint64x1x2_t) {}; }
+void test_p64 (poly64x1x2_t *ptr) { *ptr = (poly64x1x2_t) {}; }
+void test_f64 (float64x1x2_t *ptr) { *ptr = (float64x1x2_t) {}; }
+
+/* { dg-final { scan-assembler-times {\tstp\txzr, xzr, \[x0\]\n} 15 } } */


[gcc r15-3260] aarch64: Fix gather x32/x64 selection

2024-08-28 Thread Richard Sandiford via Gcc-cvs
https://gcc.gnu.org/g:3e27ea26fedf00c2662d8460cdf6aca05d0d64aa

commit r15-3260-g3e27ea26fedf00c2662d8460cdf6aca05d0d64aa
Author: Richard Sandiford 
Date:   Wed Aug 28 16:41:08 2024 +0100

aarch64: Fix gather x32/x64 selection

The SVE gather and scatter costs are classified based on whether
they do 4 loads per 128 bits (x32) or 2 loads per 128 bits (x64).
The number after the "x" refers to the number of bits in each
"container".

However, the test for which to use was based on the element size
rather than the container size.  This meant that we'd use the
overly conservative x32 costs for VNx2SI gathers.  VNx2SI gathers
are really .D gathers in which the upper half of each extension
result is ignored.

This patch is necessary to switch -mtune=generic over to the
"new" vector costs.

gcc/
* config/aarch64/aarch64.cc (aarch64_detect_vector_stmt_subtype)
(aarch64_vector_costs::add_stmt_cost): Use the x64 cost rather
than x32 cost for all VNx2 modes.

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

diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc
index 40dacfcf2e78..033ea61d3a8e 100644
--- a/gcc/config/aarch64/aarch64.cc
+++ b/gcc/config/aarch64/aarch64.cc
@@ -16819,7 +16819,8 @@ aarch64_detect_vector_stmt_subtype (vec_info *vinfo, 
vect_cost_for_stmt kind,
   && STMT_VINFO_MEMORY_ACCESS_TYPE (stmt_info) == VMAT_GATHER_SCATTER)
 {
   unsigned int nunits = vect_nunits_for_cost (vectype);
-  if (GET_MODE_UNIT_BITSIZE (TYPE_MODE (vectype)) == 64)
+  /* Test for VNx2 modes, which have 64-bit containers.  */
+  if (known_eq (GET_MODE_NUNITS (TYPE_MODE (vectype)), aarch64_sve_vg))
return { sve_costs->gather_load_x64_cost, nunits };
   return { sve_costs->gather_load_x32_cost, nunits };
 }
@@ -17309,7 +17310,9 @@ aarch64_vector_costs::add_stmt_cost (int count, 
vect_cost_for_stmt kind,
  const sve_vec_cost *sve_costs = aarch64_tune_params.vec_costs->sve;
  if (sve_costs)
{
- if (GET_MODE_UNIT_BITSIZE (TYPE_MODE (vectype)) == 64)
+ /* Test for VNx2 modes, which have 64-bit containers.  */
+ if (known_eq (GET_MODE_NUNITS (TYPE_MODE (vectype)),
+   aarch64_sve_vg))
m_sve_gather_scatter_init_cost
  += sve_costs->gather_load_x64_init_cost;
  else


[gcc r15-3261] aarch64: Assume zero gather/scatter set-up cost for -mtune=generic

2024-08-28 Thread Richard Sandiford via Gcc-cvs
https://gcc.gnu.org/g:abeeccef92892fe519cc417b30ae22ce9da2d5e6

commit r15-3261-gabeeccef92892fe519cc417b30ae22ce9da2d5e6
Author: Richard Sandiford 
Date:   Wed Aug 28 16:41:09 2024 +0100

aarch64: Assume zero gather/scatter set-up cost for -mtune=generic

generic_vector_cost is not currently used by any SVE target
by default; it has to be specifically selected by -mtune=generic.
Its SVE costing has historically been somewhat idealised, since
it predated any actual SVE cores.  This seems like a useful
tradition to continue, at least for testing purposes.

The ideal case is that gathers and scatters do not induce a specific
one-off overhead.  This patch therefore sets the gather/scatter init
costs to zero.

This patch is necessary to switch -mtune=generic over to the
"new" vector costs.

gcc/
* config/aarch64/tuning_models/generic.h (generic_sve_vector_cost):
Set gather_load_x32_init_cost and gather_load_x64_init_cost to 0.

Diff:
---
 gcc/config/aarch64/tuning_models/generic.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gcc/config/aarch64/tuning_models/generic.h 
b/gcc/config/aarch64/tuning_models/generic.h
index 101969bdbb9c..ee2f3ff42663 100644
--- a/gcc/config/aarch64/tuning_models/generic.h
+++ b/gcc/config/aarch64/tuning_models/generic.h
@@ -105,8 +105,8 @@ static const sve_vec_cost generic_sve_vector_cost =
   2, /* fadda_f64_cost  */
   4, /* gather_load_x32_cost  */
   2, /* gather_load_x64_cost  */
-  12, /* gather_load_x32_init_cost  */
-  4, /* gather_load_x64_init_cost  */
+  0, /* gather_load_x32_init_cost  */
+  0, /* gather_load_x64_init_cost  */
   1 /* scatter_store_elt_cost  */
 };


[gcc r15-3262] c++: ICE with ()-init and TARGET_EXPR eliding [PR116424]

2024-08-28 Thread Marek Polacek via Gcc-cvs
https://gcc.gnu.org/g:15f857af2943a4aa282d04ff71f860352ad3291b

commit r15-3262-g15f857af2943a4aa282d04ff71f860352ad3291b
Author: Marek Polacek 
Date:   Tue Aug 27 18:25:17 2024 -0400

c++: ICE with ()-init and TARGET_EXPR eliding [PR116424]

Here we crash on a cp_gimplify_expr/TARGET_EXPR assert:

  gcc_checking_assert (!TARGET_EXPR_ELIDING_P (*expr_p)
   || !TREE_ADDRESSABLE (TREE_TYPE (*expr_p)));

We cannot elide the TARGET_EXPR because we're taking its address.

It is set as eliding in massage_init_elt.  I've tried to not set
TARGET_EXPR_ELIDING_P when the context is not direct-initialization.
That didn't work: even when it's not direct-initialization now, it
can become one later, for instance, after split_nonconstant_init.
One problem is that replace_placeholders_for_class_temp_r will replace
placeholders in non-eliding TARGET_EXPRs with the slot, but if we then
elide the TARGET_EXPR, we end up with a "stray" VAR_DECL and crash.
(Only some TARGET_EXPRs are handled by replace_decl.)

I thought I'd have to go back to
 but
then I realized that this problem occurrs only with ()-init but not
{}-init.  With {}-init, there is no problem, because we are clearing
TARGET_EXPR_ELIDING_P in process_init_constructor_record:

   /* We can't actually elide the temporary when initializing a
  potentially-overlapping field from a function that returns by
  value.  */
   if (ce->index
   && TREE_CODE (next) == TARGET_EXPR
   && unsafe_copy_elision_p (ce->index, next))
 TARGET_EXPR_ELIDING_P (next) = false;

But that does not happen for ()-init because we have no ce->index.
()-init doesn't allow brace elision so we don't really reshape them.

But I can just move the clearing a few lines down and then it handles
both ()-init and {}-init.

PR c++/116424

gcc/cp/ChangeLog:

* typeck2.cc (process_init_constructor_record): Move the clearing of
TARGET_EXPR_ELIDING_P down.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/paren-init38.C: New test.

Diff:
---
 gcc/cp/typeck2.cc | 14 +++---
 gcc/testsuite/g++.dg/cpp2a/paren-init38.C | 20 
 2 files changed, 27 insertions(+), 7 deletions(-)

diff --git a/gcc/cp/typeck2.cc b/gcc/cp/typeck2.cc
index 30a6fbe95c99..a0c8f833ac1a 100644
--- a/gcc/cp/typeck2.cc
+++ b/gcc/cp/typeck2.cc
@@ -1774,13 +1774,6 @@ process_init_constructor_record (tree type, tree init, 
int nested, int flags,
{
  gcc_assert (ce->value);
  next = massage_init_elt (fldtype, next, nested, flags, complain);
- /* We can't actually elide the temporary when initializing a
-potentially-overlapping field from a function that returns by
-value.  */
- if (ce->index
- && TREE_CODE (next) == TARGET_EXPR
- && unsafe_copy_elision_p (ce->index, next))
-   TARGET_EXPR_ELIDING_P (next) = false;
  ++idx;
}
}
@@ -1873,6 +1866,13 @@ process_init_constructor_record (tree type, tree init, 
int nested, int flags,
}
}
 
+  /* We can't actually elide the temporary when initializing a
+potentially-overlapping field from a function that returns by
+value.  */
+  if (TREE_CODE (next) == TARGET_EXPR
+ && unsafe_copy_elision_p (field, next))
+   TARGET_EXPR_ELIDING_P (next) = false;
+
   if (is_empty_field (field)
  && !TREE_SIDE_EFFECTS (next))
/* Don't add trivial initialization of an empty base/field to the
diff --git a/gcc/testsuite/g++.dg/cpp2a/paren-init38.C 
b/gcc/testsuite/g++.dg/cpp2a/paren-init38.C
new file mode 100644
index ..58743e051da1
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp2a/paren-init38.C
@@ -0,0 +1,20 @@
+// PR c++/116424
+// { dg-do compile { target c++20 } }
+
+struct dd {
+  char *ptr;
+  dd();
+  dd(dd &&__str);
+};
+struct v {
+  dd n{};
+  int f = -1;
+  v operator|(const v &other) const;
+};
+struct cc : v {};
+static const cc a;
+static const cc b;
+static const cc c1(a | b);
+static const cc c2{a | b};
+static const cc c3 = cc(a | b);
+static const cc c4 = cc{a | b};


[gcc r15-3264] AVR: Overhaul the avr-ifelse RTL optimization pass.

2024-08-28 Thread Georg-Johann Lay via Gcc-cvs
https://gcc.gnu.org/g:898f013e195fa828bb30ae6ba4ad50abbd804fbd

commit r15-3264-g898f013e195fa828bb30ae6ba4ad50abbd804fbd
Author: Georg-Johann Lay 
Date:   Fri Aug 23 11:34:43 2024 +0200

AVR: Overhaul the avr-ifelse RTL optimization pass.

Mini-pass avr-ifelse realizes optimizations that replace two cbranch
insns with one comparison and two branches.  This patch adds the
following improvements:

- The right operand of the comparisons may also be REGs.
  Formerly only CONST_INT was handled.

- The RTX code of the first comparison in no more restricted
  to (effectively) EQ.

- When the second cbranch is located in the fallthrough path
  of the first cbranch, then difficult (expensive) comparisons
  can always be avoided.  This may require to swap the branch
  targets.  (When the second cbranch is located after the target
  label of the first one, then getting rid of difficult branches
  would require to reorder blocks.)

- The code has been cleaned up:  avr_rest_of_handle_ifelse() now
  just scans the insn stream for optimization candidates.  The code
  that actually performs the transformation has been outsourced to
  the new function avr_optimize_2ifelse().

- The code to find a better representation for reg-const_int comparisons
  has been split into two parts:  First try to find codes such that the
  right-hand sides of the comparisons are the same (avr_2comparisons_rhs).
  When this succeeds then one comparison can serve two branches, and
  that function tries to get rid of difficult branches.  This is always
  possible when the second cbranch is located in the fallthrough path
  of the first one.

Some final notes on why we don't use compare-elim:  1) The two cbranch
insns may come with different scratch operands depending on the chosen
constraint alternatives.  There are cases where the outgoing comparison
requires a scratch but only one incoming cbranch has one.  2) Avoiding
difficult branches can be achieved by rewiring basic blocks.
compare-elim doesn't do that; it doesn't even know the costs of the
branch codes.  3)  avr_2comparisons_rhs() may de-canonicalize a
comparison to achieve its goal.  compare-elim doesn't know how to do
that.  4) There are more reasons, see for example the commit message
and discussion for PR115830.

avr_2comparisons_rhs tries to decompose the interval as given by some
[u]intN_t into three intervals using the new Ranges struct that
implemens set operations on finite unions of intervals.
Sadly, value-range.h is not well suited for that, and writing a
wrapper around it that avoids all corner case ICEs would be more
laborious than struct Ranges.

gcc/
* config/avr/avr.cc (INCLUDE_VECTOR): Define it.
(cfganal.h): Include it.
(Ranges): New struct.
(avr_2comparisons_rhs, avr_redundant_compare_regs)
(avr_strict_signed_p, avr_strict_unsigned_p): New static functions.
(avr_redundant_compare): Overhaul: Allow more cases.
(avr_optimize_2ifelse): New static function, outsourced from...
(avr_rest_of_handle_ifelse): ...this method.
gcc/testsuite/
* gcc.target/avr/torture/ifelse-c.h: New file.
* gcc.target/avr/torture/ifelse-d.h: New file.
* gcc.target/avr/torture/ifelse-q.h: New file.
* gcc.target/avr/torture/ifelse-r.h: New file.
* gcc.target/avr/torture/ifelse-c-i8.c: New test.
* gcc.target/avr/torture/ifelse-d-i8.c: New test.
* gcc.target/avr/torture/ifelse-q-i8.c: New test.
* gcc.target/avr/torture/ifelse-r-i8.c: New test.
* gcc.target/avr/torture/ifelse-c-i16.c: New test.
* gcc.target/avr/torture/ifelse-d-i16.c: New test.
* gcc.target/avr/torture/ifelse-q-i16.c: New test.
* gcc.target/avr/torture/ifelse-r-i16.c: New test.
* gcc.target/avr/torture/ifelse-c-u16.c: New test.
* gcc.target/avr/torture/ifelse-d-u16.c: New test.
* gcc.target/avr/torture/ifelse-q-u16.c: New test.
* gcc.target/avr/torture/ifelse-r-u16.c: New test.

Diff:
---
 gcc/config/avr/avr.cc  | 987 -
 .../gcc.target/avr/torture/ifelse-c-i16.c  |  12 +
 gcc/testsuite/gcc.target/avr/torture/ifelse-c-i8.c |  12 +
 .../gcc.target/avr/torture/ifelse-c-u16.c  |  12 +
 gcc/testsuite/gcc.target/avr/torture/ifelse-c.h|  99 +++
 .../gcc.target/avr/torture/ifelse-d-i16.c  |  12 +
 gcc/testsuite/gcc.target/avr/torture/ifelse-d-i8.c |  12 +
 .../gcc.target/avr/torture/ifelse-d-u16.c  |  12 +
 gcc/testsuite/gcc.target/avr/torture/ifelse-d.h|  82 ++
 .../gcc.target/avr/torture/ifelse-q-i16.c  |  12 +
 gcc/testsuite/gcc.target/avr/torture/ifelse-q-i8

[gcc r15-3265] libstdc++: Fix @headername for bits/cpp_type_traits.h

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

commit r15-3265-gf6ed7a61a7c906f8fb7f8059132225c9bc41f3b2
Author: Kim Gräsman 
Date:   Tue Aug 27 17:08:47 2024 +0100

libstdc++: Fix @headername for bits/cpp_type_traits.h

There is no file ext/type_traits, point it to ext/type_traits.h instead.

libstdc++-v3/ChangeLog:

* include/bits/cpp_type_traits.h: Improve doxygen file docs.

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

diff --git a/libstdc++-v3/include/bits/cpp_type_traits.h 
b/libstdc++-v3/include/bits/cpp_type_traits.h
index 4bfb4521e064..ff74c5572458 100644
--- a/libstdc++-v3/include/bits/cpp_type_traits.h
+++ b/libstdc++-v3/include/bits/cpp_type_traits.h
@@ -24,7 +24,7 @@
 
 /** @file bits/cpp_type_traits.h
  *  This is an internal header file, included by other library headers.
- *  Do not attempt to use it directly. @headername{ext/type_traits}
+ *  Do not attempt to use it directly. @headername{ext/type_traits.h}
  */
 
 // Written by Gabriel Dos Reis 


[gcc r15-3266] libstdc++: Fix @file for target-specific opt_random.h

2024-08-28 Thread Jonathan Wakely via Libstdc++-cvs
https://gcc.gnu.org/g:c2ad7b2d5247cf2ddee98d7f46274775a3fa1268

commit r15-3266-gc2ad7b2d5247cf2ddee98d7f46274775a3fa1268
Author: Kim Gräsman 
Date:   Tue Aug 27 17:11:29 2024 +0100

libstdc++: Fix @file for target-specific opt_random.h

A few of these files self-identified as ext/random.tcc, update to use
the actual basename.

libstdc++-v3/ChangeLog:

* config/cpu/aarch64/opt/ext/opt_random.h: Improve doxygen file
docs.
* config/cpu/i486/opt/ext/opt_random.h: Likewise.

Diff:
---
 libstdc++-v3/config/cpu/aarch64/opt/ext/opt_random.h | 2 +-
 libstdc++-v3/config/cpu/i486/opt/ext/opt_random.h| 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/libstdc++-v3/config/cpu/aarch64/opt/ext/opt_random.h 
b/libstdc++-v3/config/cpu/aarch64/opt/ext/opt_random.h
index ae78aced27e9..7f756d1572f3 100644
--- a/libstdc++-v3/config/cpu/aarch64/opt/ext/opt_random.h
+++ b/libstdc++-v3/config/cpu/aarch64/opt/ext/opt_random.h
@@ -22,7 +22,7 @@
 // see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 // .
 
-/** @file ext/random.tcc
+/** @file ext/opt_random.h
  *  This is an internal header file, included by other library headers.
  *  Do not attempt to use it directly. @headername{ext/random}
  */
diff --git a/libstdc++-v3/config/cpu/i486/opt/ext/opt_random.h 
b/libstdc++-v3/config/cpu/i486/opt/ext/opt_random.h
index 0947197af7b5..3a3e892e7c3f 100644
--- a/libstdc++-v3/config/cpu/i486/opt/ext/opt_random.h
+++ b/libstdc++-v3/config/cpu/i486/opt/ext/opt_random.h
@@ -22,7 +22,7 @@
 // see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 // .
 
-/** @file ext/random.tcc
+/** @file ext/opt_random.h
  *  This is an internal header file, included by other library headers.
  *  Do not attempt to use it directly. @headername{ext/random}
  */


[gcc r15-3267] doc: Add Dhruv Matani to Contributors

2024-08-28 Thread Jonathan Wakely via Gcc-cvs
https://gcc.gnu.org/g:9740a1b0dc10c93f325fb17dacea7d123bc0cdd2

commit r15-3267-g9740a1b0dc10c93f325fb17dacea7d123bc0cdd2
Author: Jonathan Wakely 
Date:   Wed Aug 28 11:49:46 2024 +0100

doc: Add Dhruv Matani to Contributors

gcc/ChangeLog:

* doc/contrib.texi (Contributors): Add Dhruv Matani.

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

diff --git a/gcc/doc/contrib.texi b/gcc/doc/contrib.texi
index 32e89d6df25c..7714d52823b1 100644
--- a/gcc/doc/contrib.texi
+++ b/gcc/doc/contrib.texi
@@ -645,6 +645,9 @@ John Marino for contributing the DragonFly BSD port.
 Philip Martin for lots of libstdc++ string and vector iterator fixes and
 improvements, and string clean up and testsuites.
 
+@item
+Dhruv Matani for work on libstdc++ allocators.
+
 @item
 Michael Matz for his work on dominance tree discovery, the x86-64 port,
 link-time optimization framework and general optimization improvements.


[gcc r15-3268] libstdc++: Remove unused typedef in

2024-08-28 Thread Jonathan Wakely via Libstdc++-cvs
https://gcc.gnu.org/g:a59f1cc31cf6c7ed30a78cef134ea3ed5e139414

commit r15-3268-ga59f1cc31cf6c7ed30a78cef134ea3ed5e139414
Author: Jonathan Wakely 
Date:   Wed Aug 28 11:49:08 2024 +0100

libstdc++: Remove unused typedef in 

This local typedef should have been removed in r14-6199-g45630fbcf7875b.

libstdc++-v3/ChangeLog:

* include/std/ranges (to): Remove unused typedef.

Diff:
---
 libstdc++-v3/include/std/ranges | 1 -
 1 file changed, 1 deletion(-)

diff --git a/libstdc++-v3/include/std/ranges b/libstdc++-v3/include/std/ranges
index b7c7aa36ddc4..aa08a48440cf 100644
--- a/libstdc++-v3/include/std/ranges
+++ b/libstdc++-v3/include/std/ranges
@@ -9327,7 +9327,6 @@ namespace __detail
 std::forward<_Args>(__args)...);
  else
{
- using _RefT = range_reference_t<_Rg>;
  static_assert(constructible_from<_Cont, _Args...>);
  _Cont __c(std::forward<_Args>(__args)...);
  if constexpr (sized_range<_Rg>


[gcc r15-3269] libstdc++: Fix -Wunused-variable warning in

2024-08-28 Thread Jonathan Wakely via Libstdc++-cvs
https://gcc.gnu.org/g:0e2b3dba5179c9becbff0730febbdce3a088bae3

commit r15-3269-g0e2b3dba5179c9becbff0730febbdce3a088bae3
Author: Jonathan Wakely 
Date:   Wed Aug 28 12:09:58 2024 +0100

libstdc++: Fix -Wunused-variable warning in 

libstdc++-v3/ChangeLog:

* include/std/format (format_parse_context::check_dynamic_spec):
Add [[maybe_unused]] attribute and comment.

Diff:
---
 libstdc++-v3/include/std/format | 5 +
 1 file changed, 5 insertions(+)

diff --git a/libstdc++-v3/include/std/format b/libstdc++-v3/include/std/format
index 3280dadfb90e..52243eb54792 100644
--- a/libstdc++-v3/include/std/format
+++ b/libstdc++-v3/include/std/format
@@ -4323,6 +4323,11 @@ namespace __format
 constexpr void
 basic_format_parse_context<_CharT>::check_dynamic_spec(size_t __id) 
noexcept
 {
+  // This call enforces the Mandates: condition that _Ts contains valid
+  // types and each type appears at most once. It could be a static_assert
+  // but this way failures give better diagnostics, due to calling the
+  // non-constexpr __invalid_dynamic_spec function.
+  [[maybe_unused]]
   constexpr bool __ok = __check_dynamic_spec_types<_Ts...>();
 
   if consteval {


[gcc r15-3270] libstdc++: Fix -Wunused-parameter warnings in Networking TS headers

2024-08-28 Thread Jonathan Wakely via Libstdc++-cvs
https://gcc.gnu.org/g:51b0fef4e6ee01ed2509bd54a448d2564a89c518

commit r15-3270-g51b0fef4e6ee01ed2509bd54a448d2564a89c518
Author: Jonathan Wakely 
Date:   Wed Aug 28 12:21:56 2024 +0100

libstdc++: Fix -Wunused-parameter warnings in Networking TS headers

libstdc++-v3/ChangeLog:

* include/experimental/io_context: Remove name of unused
parameter.
* include/experimental/socket: Add [[maybe_unused]] attribute.

Diff:
---
 libstdc++-v3/include/experimental/io_context | 2 +-
 libstdc++-v3/include/experimental/socket | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/libstdc++-v3/include/experimental/io_context 
b/libstdc++-v3/include/experimental/io_context
index 4db3782e2bb6..8b0dba7d5fa6 100644
--- a/libstdc++-v3/include/experimental/io_context
+++ b/libstdc++-v3/include/experimental/io_context
@@ -148,7 +148,7 @@ inline namespace v1
 io_context() : _M_work_count(0) { }
 
 explicit
-io_context(int __concurrency_hint) : _M_work_count(0) { }
+io_context(int /* __concurrency_hint */) : _M_work_count(0) { }
 
 io_context(const io_context&) = delete;
 io_context& operator=(const io_context&) = delete;
diff --git a/libstdc++-v3/include/experimental/socket 
b/libstdc++-v3/include/experimental/socket
index 3fe83a001e61..62beb43d269c 100644
--- a/libstdc++-v3/include/experimental/socket
+++ b/libstdc++-v3/include/experimental/socket
@@ -493,7 +493,7 @@ inline namespace v1
 bool non_blocking() const { return _M_bits.non_blocking; }
 
 void
-native_non_blocking(bool __mode, error_code& __ec)
+native_non_blocking([[maybe_unused]] bool __mode, error_code& __ec)
 {
 #if defined _GLIBCXX_HAVE_FCNTL_H && defined _GLIBCXX_HAVE_DECL_O_NONBLOCK
   int __flags = ::fcntl(_M_sockfd, F_GETFL, 0);


[gcc r15-3271] libstdc++: Fix autoconf check for O_NONBLOCK in

2024-08-28 Thread Jonathan Wakely via Libstdc++-cvs
https://gcc.gnu.org/g:b68561dd7925dfee1836f75d3fa8d33fff5c2498

commit r15-3271-gb68561dd7925dfee1836f75d3fa8d33fff5c2498
Author: Jonathan Wakely 
Date:   Wed Aug 28 12:38:18 2024 +0100

libstdc++: Fix autoconf check for O_NONBLOCK in 

I misused the AC_CHECK_DECL macro, assuming that it behaved like
AC_CHECK_DECLS and always defined a HAVE_xxx macro if the decl was
found. Instead, the [action-if-found] shell commands are needed to
defined HAVE_O_NONBLOCK explicitly.

libstdc++-v3/ChangeLog:

* configure.ac: Fix check for O_NONBLOCK.
* config.h.in: Regenerate.
* configure: Regenerate.

Diff:
---
 libstdc++-v3/config.h.in  | 3 +++
 libstdc++-v3/configure| 2 ++
 libstdc++-v3/configure.ac | 5 -
 3 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/libstdc++-v3/config.h.in b/libstdc++-v3/config.h.in
index 486ba4507499..91e920044ee4 100644
--- a/libstdc++-v3/config.h.in
+++ b/libstdc++-v3/config.h.in
@@ -302,6 +302,9 @@
 /* Define if openat is available in . */
 #undef HAVE_OPENAT
 
+/* Define if O_NONBLOCK is defined in  */
+#undef HAVE_O_NONBLOCK
+
 /* Define if poll is available in . */
 #undef HAVE_POLL
 
diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure
index 305675eaa1e1..005c4a29fd09 100755
--- a/libstdc++-v3/configure
+++ b/libstdc++-v3/configure
@@ -54132,6 +54132,8 @@ if test 
"$ac_cv_have_decl_F_GETFL$ac_cv_have_decl_F_SETFL" = yesyes ; then
 "
 if test "x$ac_cv_have_decl_O_NONBLOCK" = xyes; then :
 
+$as_echo "#define HAVE_O_NONBLOCK 1" >>confdefs.h
+
 fi
 
 fi
diff --git a/libstdc++-v3/configure.ac b/libstdc++-v3/configure.ac
index 4049f54bd5a3..a3b257fe6528 100644
--- a/libstdc++-v3/configure.ac
+++ b/libstdc++-v3/configure.ac
@@ -554,7 +554,10 @@ AC_CHECK_HEADERS([fcntl.h sys/ioctl.h sys/socket.h 
sys/uio.h poll.h netdb.h arpa
 AC_CHECK_DECL(F_GETFL,,,[#include ])
 AC_CHECK_DECL(F_SETFL,,,[#include ])
 if test "$ac_cv_have_decl_F_GETFL$ac_cv_have_decl_F_SETFL" = yesyes ; then
-  AC_CHECK_DECL(O_NONBLOCK,,,[#include ])
+  AC_CHECK_DECL(O_NONBLOCK,
+AC_DEFINE(HAVE_O_NONBLOCK,1,[Define if O_NONBLOCK is defined in 
]),
+[],
+[#include ])
 fi
 
 # For Transactional Memory TS


[gcc r15-3272] expand: Add debug dump on the cost for `popcount==1` expand

2024-08-28 Thread Andrew Pinski via Gcc-cvs
https://gcc.gnu.org/g:3c89c41991d8e84d28d3aba22bb06b2712a29523

commit r15-3272-g3c89c41991d8e84d28d3aba22bb06b2712a29523
Author: Andrew Pinski 
Date:   Mon Aug 26 15:14:24 2024 -0700

expand: Add debug dump on the cost for `popcount==1` expand

While working on PR 114224, I found it would be useful to dump the
different costs of the expansion to make easier to understand why one
was chosen over the other.

Changes since v1:
* v2: make the dump a single line

Bootstrapped and tested on x86_64-linux-gnu.
Build and tested for aarch64-linux-gnu.

gcc/ChangeLog:

* internal-fn.cc (expand_POPCOUNT): Dump the costs for
the two choices.

Diff:
---
 gcc/internal-fn.cc | 5 +
 1 file changed, 5 insertions(+)

diff --git a/gcc/internal-fn.cc b/gcc/internal-fn.cc
index 89da13b38ce1..78997ef056ad 100644
--- a/gcc/internal-fn.cc
+++ b/gcc/internal-fn.cc
@@ -5351,6 +5351,11 @@ expand_POPCOUNT (internal_fn fn, gcall *stmt)
   unsigned popcount_cost = (seq_cost (popcount_insns, speed_p)
+ seq_cost (popcount_cmp_insns, speed_p));
   unsigned cmp_cost = seq_cost (cmp_insns, speed_p);
+
+  if (dump_file && (dump_flags & TDF_DETAILS))
+fprintf(dump_file, "popcount == 1: popcount cost: %u; cmp cost: %u\n",
+   popcount_cost, cmp_cost);
+
   if (popcount_cost <= cmp_cost)
 emit_insn (popcount_insns);
   else


[gcc r15-3274] c++: wrong error due to std::initializer_list opt [PR116476]

2024-08-28 Thread Marek Polacek via Gcc-cvs
https://gcc.gnu.org/g:9f79c7ddff5f1b004803931406ad17eaba095fff

commit r15-3274-g9f79c7ddff5f1b004803931406ad17eaba095fff
Author: Marek Polacek 
Date:   Wed Aug 28 15:45:49 2024 -0400

c++: wrong error due to std::initializer_list opt [PR116476]

Here maybe_init_list_as_array gets elttype=field, init={NON_LVALUE_EXPR <2>}
and it tries to convert the init's element type (int) to field
using implicit_conversion, which works, so overall maybe_init_list_as_array
is successful.

But it constifies init_elttype so we end up with "const int".  Later,
when we actually perform the conversion and invoke field::field(T&&),
we end up with this error:

  error: binding reference of type 'int&&' to 'const int' discards 
qualifiers

So I think maybe_init_list_as_array should try to perform the conversion,
like it does below with fc.

PR c++/116476

gcc/cp/ChangeLog:

* call.cc (maybe_init_list_as_array): Try convert_like and see if it
worked.

gcc/testsuite/ChangeLog:

* g++.dg/cpp0x/initlist-opt2.C: New test.

Reviewed-by: Jason Merrill 

Diff:
---
 gcc/cp/call.cc |  6 +-
 gcc/testsuite/g++.dg/cpp0x/initlist-opt2.C | 21 +
 2 files changed, 26 insertions(+), 1 deletion(-)

diff --git a/gcc/cp/call.cc b/gcc/cp/call.cc
index 623e4c66c117..fa7f05d76f68 100644
--- a/gcc/cp/call.cc
+++ b/gcc/cp/call.cc
@@ -4319,6 +4319,7 @@ maybe_init_list_as_array (tree elttype, tree init)
   /* Check with a stub expression to weed out special cases, and check whether
  we call the same function for direct-init as copy-list-init.  */
   conversion_obstack_sentinel cos;
+  init_elttype = cp_build_qualified_type (init_elttype, TYPE_QUAL_CONST);
   tree arg = build_stub_object (init_elttype);
   conversion *c = implicit_conversion (elttype, init_elttype, arg, false,
   LOOKUP_NORMAL, tf_none);
@@ -4326,6 +4327,10 @@ maybe_init_list_as_array (tree elttype, tree init)
 c = next_conversion (c);
   if (!c || c->kind != ck_user)
 return NULL_TREE;
+  /* Check that we actually can perform the conversion.  */
+  if (convert_like (c, arg, tf_none) == error_mark_node)
+/* Let the normal code give the error.  */
+return NULL_TREE;
 
   tree first = CONSTRUCTOR_ELT (init, 0)->value;
   conversion *fc = implicit_conversion (elttype, init_elttype, first, false,
@@ -4358,7 +4363,6 @@ maybe_init_list_as_array (tree elttype, tree init)
   if (!is_xible (INIT_EXPR, elttype, copy_argtypes))
 return NULL_TREE;
 
-  init_elttype = cp_build_qualified_type (init_elttype, TYPE_QUAL_CONST);
   tree arr = build_array_of_n_type (init_elttype, CONSTRUCTOR_NELTS (init));
   arr = finish_compound_literal (arr, init, tf_none);
   DECL_MERGEABLE (TARGET_EXPR_SLOT (arr)) = true;
diff --git a/gcc/testsuite/g++.dg/cpp0x/initlist-opt2.C 
b/gcc/testsuite/g++.dg/cpp0x/initlist-opt2.C
new file mode 100644
index ..6c71857daabc
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/initlist-opt2.C
@@ -0,0 +1,21 @@
+// PR c++/116476
+// { dg-do compile { target c++11 } }
+
+namespace std {
+template 
+class initializer_list {
+  T *_M_len;
+  __SIZE_TYPE__ size;
+};
+} // namespace std
+
+
+template 
+struct field {
+field(T &&) {}
+};
+struct vector {
+  vector(std::initializer_list>) { }
+};
+
+vector fields_normal{2};


[gcc r15-3276] Handle namespaced names for CodeView

2024-08-28 Thread Mark Harmstone via Gcc-cvs
https://gcc.gnu.org/g:350122685af24442501f19e2f03a0a2d8c651bc8

commit r15-3276-g350122685af24442501f19e2f03a0a2d8c651bc8
Author: Mark Harmstone 
Date:   Mon Aug 26 21:03:58 2024 +0100

Handle namespaced names for CodeView

Run all CodeView names through a new function get_name, which chains
together a DIE's DW_AT_name with that of its parent to create a
C++-style name.

gcc/
* dwarf2codeview.cc (get_name): New function.
(add_enum_forward_def): Call get_name.
(get_type_num_enumeration_type): Call get_name.
(add_struct_forward_def): Call get_name.
(get_type_num_struct): Call get_name.
(add_variable): Call get_name.
(add function): Call get_name.
* dwarf2out.cc (get_die_parent): Rename to dw_get_die_parent and 
make
non-static.
(generate_type_signature): Handle renamed get_die_parent.
* dwarf2out.h (dw_get_die_parent): Add declaration.

Diff:
---
 gcc/dwarf2codeview.cc | 92 +++
 gcc/dwarf2out.cc  |  6 ++--
 gcc/dwarf2out.h   |  1 +
 3 files changed, 83 insertions(+), 16 deletions(-)

diff --git a/gcc/dwarf2codeview.cc b/gcc/dwarf2codeview.cc
index e4c67f921cd0..b71c592b70c8 100644
--- a/gcc/dwarf2codeview.cc
+++ b/gcc/dwarf2codeview.cc
@@ -4511,6 +4511,79 @@ get_type_num_volatile_type (dw_die_ref type, bool 
in_struct)
   return ct->num;
 }
 
+/* Return the name of a DIE, traversing its parents in order to construct a
+   C++-style name if necessary.  */
+static char *
+get_name (dw_die_ref die)
+{
+  dw_die_ref decl = get_AT_ref (die, DW_AT_specification);
+  dw_die_ref parent;
+  const char *name;
+  char *str;
+  size_t len;
+
+  static const char anon[] = "";
+  static const char sep[] = "::";
+
+  if (decl)
+die = decl;
+
+  name = get_AT_string (die, DW_AT_name);
+
+  if (!name)
+return NULL;
+
+  parent = dw_get_die_parent (die);
+
+  if (!parent || dw_get_die_tag (parent) == DW_TAG_compile_unit)
+return xstrdup (name);
+
+  len = strlen (name);
+  while (parent && dw_get_die_tag (parent) != DW_TAG_compile_unit)
+{
+  const char *ns_name = get_AT_string (parent, DW_AT_name);
+
+  len += sizeof (sep) - 1;
+
+  if (ns_name)
+   len += strlen (ns_name);
+  else
+   len += sizeof (anon) - 1;
+
+  parent = dw_get_die_parent (parent);
+}
+
+  str = (char *) xmalloc (len + 1);
+  str[len] = 0;
+
+  len -= strlen (name);
+  memcpy (str + len, name, strlen (name));
+
+  parent = dw_get_die_parent (die);
+  while (parent && dw_get_die_tag (parent) != DW_TAG_compile_unit)
+{
+  const char *ns_name = get_AT_string (parent, DW_AT_name);
+
+  len -= sizeof (sep) - 1;
+  memcpy (str + len, sep, sizeof (sep) - 1);
+
+  if (ns_name)
+   {
+ len -= strlen (ns_name);
+ memcpy (str + len, ns_name, strlen (ns_name));
+   }
+  else
+   {
+ len -= sizeof (anon) - 1;
+ memcpy (str + len, anon, sizeof (anon) - 1);
+   }
+
+  parent = dw_get_die_parent (parent);
+}
+
+  return str;
+}
+
 /* Add a forward declaration for an enum.  This is legal from C++11 onwards.  
*/
 
 static uint32_t
@@ -4528,7 +4601,7 @@ add_enum_forward_def (dw_die_ref type)
   ct->lf_enum.underlying_type = get_type_num (get_AT_ref (type, DW_AT_type),
  false, false);
   ct->lf_enum.fieldlist = 0;
-  ct->lf_enum.name = xstrdup (get_AT_string (type, DW_AT_name));
+  ct->lf_enum.name = get_name (type);
 
   add_custom_type (ct);
 
@@ -4688,7 +4761,7 @@ get_type_num_enumeration_type (dw_die_ref type, bool 
in_struct)
   ct->lf_enum.underlying_type = get_type_num (get_AT_ref (type, DW_AT_type),
  in_struct, false);
   ct->lf_enum.fieldlist = last_type;
-  ct->lf_enum.name = xstrdup (get_AT_string (type, DW_AT_name));
+  ct->lf_enum.name = get_name (type);
 
   add_custom_type (ct);
 
@@ -4775,7 +4848,7 @@ add_struct_forward_def (dw_die_ref type)
   ct->lf_structure.vshape = 0;
   ct->lf_structure.length.neg = false;
   ct->lf_structure.length.num = 0;
-  ct->lf_structure.name = xstrdup (get_AT_string (type, DW_AT_name));
+  ct->lf_structure.name = get_name (type);
 
   add_custom_type (ct);
 
@@ -4823,7 +4896,6 @@ get_type_num_struct (dw_die_ref type, bool in_struct, 
bool *is_fwd_ref)
   codeview_custom_type *ct;
   uint16_t num_members = 0;
   uint32_t last_type = 0;
-  const char *name;
 
   if ((in_struct && get_AT_string (type, DW_AT_name))
   || get_AT_flag (type, DW_AT_declaration))
@@ -5010,13 +5082,7 @@ get_type_num_struct (dw_die_ref type, bool in_struct, 
bool *is_fwd_ref)
   ct->lf_structure.vshape = 0;
   ct->lf_structure.length.neg = false;
   ct->lf_structure.length.num = get_AT_unsigned (type, DW_AT_byte_size);
-
-  name = get_AT_string (type, DW_AT_name);
-
-  if (name)
-ct->lf_structure.name = xstrdup (name);

[gcc r15-3277] Handle scoping in CodeView LF_FUNC_ID types

2024-08-28 Thread Mark Harmstone via Gcc-cvs
https://gcc.gnu.org/g:310fd68c6cb62b69ddd98c61aab8cb9db242b6a4

commit r15-3277-g310fd68c6cb62b69ddd98c61aab8cb9db242b6a4
Author: Mark Harmstone 
Date:   Mon Aug 26 21:19:51 2024 +0100

Handle scoping in CodeView LF_FUNC_ID types

If a function is in a namespace, create an LF_STRING_ID type for the
name of its parent, and record this in the LF_FUNC_ID type we create
for the function.

gcc/
* dwarf2codeview.cc (enum cf_leaf_type): Add LF_STRING_ID.
(struct codeview_custom_type): Add lf_string_id to union.
(struct string_id_hasher): New type.
(string_id_htab): New global variable.
(write_lf_string_id): New function.
(write_custom_types): Call write_lf_string_id.
(codeview_debug_finish): Free string_id_htab.
(add_string_id): New function.
(get_scope_string_id): New function.
(add_function): Call get_scope_string_id and set scope.

Diff:
---
 gcc/dwarf2codeview.cc | 139 +-
 1 file changed, 137 insertions(+), 2 deletions(-)

diff --git a/gcc/dwarf2codeview.cc b/gcc/dwarf2codeview.cc
index b71c592b70c8..2535777d4cbd 100644
--- a/gcc/dwarf2codeview.cc
+++ b/gcc/dwarf2codeview.cc
@@ -107,6 +107,7 @@ enum cv_leaf_type {
   LF_ENUM = 0x1507,
   LF_MEMBER = 0x150d,
   LF_FUNC_ID = 0x1601,
+  LF_STRING_ID = 0x1605,
   LF_CHAR = 0x8000,
   LF_SHORT = 0x8001,
   LF_USHORT = 0x8002,
@@ -1293,6 +1294,11 @@ struct codeview_custom_type
   uint32_t function_type;
   char *name;
 } lf_func_id;
+struct
+{
+  uint32_t substring;
+  char *string;
+} lf_string_id;
   };
 };
 
@@ -1302,6 +1308,21 @@ struct codeview_deferred_type
   dw_die_ref type;
 };
 
+struct string_id_hasher : nofree_ptr_hash 
+{
+  typedef const char *compare_type;
+
+  static hashval_t hash (const codeview_custom_type *x)
+  {
+return htab_hash_string (x->lf_string_id.string);
+  }
+
+  static bool equal (const codeview_custom_type *x, const char *y)
+  {
+return !strcmp (x->lf_string_id.string, y);
+  }
+};
+
 static unsigned int line_label_num;
 static unsigned int func_label_num;
 static unsigned int sym_label_num;
@@ -1317,6 +1338,7 @@ static codeview_symbol *sym, *last_sym;
 static hash_table *types_htab;
 static codeview_custom_type *custom_types, *last_custom_type;
 static codeview_deferred_type *deferred_types, *last_deferred_type;
+static hash_table *string_id_htab;
 
 static uint32_t get_type_num (dw_die_ref type, bool in_struct, bool 
no_fwd_ref);
 
@@ -4089,6 +4111,50 @@ write_lf_func_id (codeview_custom_type *t)
   asm_fprintf (asm_out_file, "%LLcv_type%x_end:\n", t->num);
 }
 
+/* Write an LF_STRING_ID type, which provides a deduplicated string that other
+   types can reference.  */
+
+static void
+write_lf_string_id (codeview_custom_type *t)
+{
+  size_t string_len;
+
+  /* This is lf_string_id in binutils and lfStringId in Microsoft's cvinfo.h:
+
+struct lf_string_id
+{
+  uint16_t size;
+  uint16_t kind;
+  uint32_t substring;
+  char string[];
+} ATTRIBUTE_PACKED;
+  */
+
+  fputs (integer_asm_op (2, false), asm_out_file);
+  asm_fprintf (asm_out_file, "%LLcv_type%x_end - %LLcv_type%x_start\n",
+  t->num, t->num);
+
+  asm_fprintf (asm_out_file, "%LLcv_type%x_start:\n", t->num);
+
+  fputs (integer_asm_op (2, false), asm_out_file);
+  fprint_whex (asm_out_file, t->kind);
+  putc ('\n', asm_out_file);
+
+  fputs (integer_asm_op (4, false), asm_out_file);
+  fprint_whex (asm_out_file, t->lf_string_id.substring);
+  putc ('\n', asm_out_file);
+
+  string_len = strlen (t->lf_string_id.string) + 1;
+
+  ASM_OUTPUT_ASCII (asm_out_file, t->lf_string_id.string, string_len);
+
+  write_cv_padding (4 - (string_len % 4));
+
+  free (t->lf_string_id.string);
+
+  asm_fprintf (asm_out_file, "%LLcv_type%x_end:\n", t->num);
+}
+
 /* Write the .debug$T section, which contains all of our custom type
definitions.  */
 
@@ -4152,6 +4218,10 @@ write_custom_types (void)
  write_lf_func_id (custom_types);
  break;
 
+   case LF_STRING_ID:
+ write_lf_string_id (custom_types);
+ break;
+
default:
  break;
}
@@ -4182,6 +4252,9 @@ codeview_debug_finish (void)
 
   if (types_htab)
 delete types_htab;
+
+  if (string_id_htab)
+delete string_id_htab;
 }
 
 /* Translate a DWARF base type (DW_TAG_base_type) into its CodeView
@@ -5461,6 +5534,67 @@ add_variable (dw_die_ref die)
   last_sym = s;
 }
 
+/* Return the type number of the LF_STRING_ID entry corresponding to the given
+   string, creating a new one if necessary.  */
+
+static uint32_t
+add_string_id (const char *s)
+{
+  codeview_custom_type **slot;
+  codeview_custom_type *ct;
+
+  if (!string_id_htab)
+string_id_htab = new hash_table (10);
+
+  slot = string_id_htab->find_slot_with_hash (s, htab_hash_string (s),
+ INSERT

[gcc r15-3278] Record static data members in CodeView structs

2024-08-28 Thread Mark Harmstone via Gcc-cvs
https://gcc.gnu.org/g:6a9932ecdaac16c0fa21cc7c39589a3cd7cacf0f

commit r15-3278-g6a9932ecdaac16c0fa21cc7c39589a3cd7cacf0f
Author: Mark Harmstone 
Date:   Mon Aug 26 21:34:46 2024 +0100

Record static data members in CodeView structs

Record LF_STMEMBER field list subtypes to represent static data members
in structs.

gcc/
* dwarf2codeview.cc (enum cv_leaf_type): Add LF_STMEMBER.
(struct codeview_subtype): Add lf_static_member to union.
(write_lf_fieldlist): Handle LF_STMEMBER.
(add_struct_member): New function.
(add_struct_static_member): New function.
(get_accessibility): New function.
(get_type_num_struct): Split out into add_struct_member and
get_accessibility, and handle static members.

Diff:
---
 gcc/dwarf2codeview.cc | 183 +-
 1 file changed, 136 insertions(+), 47 deletions(-)

diff --git a/gcc/dwarf2codeview.cc b/gcc/dwarf2codeview.cc
index 2535777d4cbd..e243e0fba251 100644
--- a/gcc/dwarf2codeview.cc
+++ b/gcc/dwarf2codeview.cc
@@ -106,6 +106,7 @@ enum cv_leaf_type {
   LF_UNION = 0x1506,
   LF_ENUM = 0x1507,
   LF_MEMBER = 0x150d,
+  LF_STMEMBER = 0x150e,
   LF_FUNC_ID = 0x1601,
   LF_STRING_ID = 0x1605,
   LF_CHAR = 0x8000,
@@ -1218,6 +1219,12 @@ struct codeview_subtype
   codeview_integer offset;
   char *name;
 } lf_member;
+struct
+{
+  uint16_t attributes;
+  uint32_t type;
+  char *name;
+} lf_static_member;
   };
 };
 
@@ -3663,6 +3670,40 @@ write_lf_fieldlist (codeview_custom_type *t)
 
  break;
 
+   case LF_STMEMBER:
+ /* This is lf_static_member in binutils and lfSTMember in Microsoft's
+cvinfo.h:
+
+   struct lf_static_member
+   {
+ uint16_t kind;
+ uint16_t attributes;
+ uint32_t type;
+ char name[];
+   } ATTRIBUTE_PACKED;
+ */
+
+ fputs (integer_asm_op (2, false), asm_out_file);
+ fprint_whex (asm_out_file, LF_STMEMBER);
+ putc ('\n', asm_out_file);
+
+ fputs (integer_asm_op (2, false), asm_out_file);
+ fprint_whex (asm_out_file, v->lf_static_member.attributes);
+ putc ('\n', asm_out_file);
+
+ fputs (integer_asm_op (4, false), asm_out_file);
+ fprint_whex (asm_out_file, v->lf_static_member.type);
+ putc ('\n', asm_out_file);
+
+ name_len = strlen (v->lf_static_member.name) + 1;
+ ASM_OUTPUT_ASCII (asm_out_file, v->lf_static_member.name, name_len);
+
+ leaf_len = 8 + name_len;
+ write_cv_padding (4 - (leaf_len % 4));
+
+ free (v->lf_static_member.name);
+ break;
+
default:
  break;
}
@@ -4958,6 +4999,91 @@ create_bitfield (dw_die_ref c)
   return ct->num;
 }
 
+/* Create an LF_MEMBER field list subtype for a struct member, returning its
+   pointer in el and its size in el_len.  */
+
+static void
+add_struct_member (dw_die_ref c, uint16_t accessibility,
+  codeview_subtype **el, size_t *el_len)
+{
+  *el = (codeview_subtype *) xmalloc (sizeof (**el));
+  (*el)->next = NULL;
+  (*el)->kind = LF_MEMBER;
+  (*el)->lf_member.attributes = accessibility;
+
+  if (get_AT (c, DW_AT_data_bit_offset))
+(*el)->lf_member.type = create_bitfield (c);
+  else
+(*el)->lf_member.type = get_type_num (get_AT_ref (c, DW_AT_type),
+ true, false);
+
+  (*el)->lf_member.offset.neg = false;
+  (*el)->lf_member.offset.num = get_AT_unsigned (c, 
DW_AT_data_member_location);
+
+  *el_len = 11 + cv_integer_len (&(*el)->lf_member.offset);
+
+  if (get_AT_string (c, DW_AT_name))
+{
+  (*el)->lf_member.name = xstrdup (get_AT_string (c, DW_AT_name));
+  *el_len += strlen ((*el)->lf_member.name);
+}
+  else
+{
+  (*el)->lf_member.name = NULL;
+}
+
+  if (*el_len % 4)
+*el_len += 4 - (*el_len % 4);
+}
+
+/* Create an LF_STMEMBER field list subtype for a static struct member,
+   returning its pointer in el and its size in el_len.  */
+
+static void
+add_struct_static_member (dw_die_ref c, uint16_t accessibility,
+ codeview_subtype **el, size_t *el_len)
+{
+  *el = (codeview_subtype *) xmalloc (sizeof (**el));
+  (*el)->next = NULL;
+  (*el)->kind = LF_STMEMBER;
+  (*el)->lf_static_member.attributes = accessibility;
+  (*el)->lf_static_member.type = get_type_num (get_AT_ref (c, DW_AT_type),
+  true, false);
+  (*el)->lf_static_member.name = xstrdup (get_AT_string (c, DW_AT_name));
+
+  *el_len = 9 + strlen ((*el)->lf_static_member.name);
+
+  if (*el_len % 4)
+*el_len += 4 - (*el_len % 4);
+}
+
+/* Translate a DWARF DW_AT_accessibility constant into its CodeView
+   equivalent.  If implicit, follow the C++ rules.  */
+
+static uint16_t
+get_accessibility (dw_die_ref c)
+{
+  switch (get_AT_unsigned 

[gcc r15-3280] Write LF_MFUNC_ID types for CodeView struct member functions

2024-08-28 Thread Mark Harmstone via Gcc-cvs
https://gcc.gnu.org/g:155da081706e0e0527f01ad565b1cd6c217f5880

commit r15-3280-g155da081706e0e0527f01ad565b1cd6c217f5880
Author: Mark Harmstone 
Date:   Mon Aug 26 22:16:11 2024 +0100

Write LF_MFUNC_ID types for CodeView struct member functions

If recording the definition of a struct member function, write an
LF_MFUNC_ID type rather than an LF_FUNC_ID. This links directly to the
struct type, rather than to an LF_STRING_ID with its name.

gcc/
* dwarf2codeview.cc (enum cv_leaf_type): Add LF_MFUNC_ID.
(write_lf_mfunc_id): New function.
(add_lf_func_id): New function.
(add_lf_mfunc_id): New function.
(add_function): Call add_lf_func_id or add_lf_mfunc_id.

Diff:
---
 gcc/dwarf2codeview.cc | 150 +-
 1 file changed, 137 insertions(+), 13 deletions(-)

diff --git a/gcc/dwarf2codeview.cc b/gcc/dwarf2codeview.cc
index 00a1795575ab..d593795b5886 100644
--- a/gcc/dwarf2codeview.cc
+++ b/gcc/dwarf2codeview.cc
@@ -112,6 +112,7 @@ enum cv_leaf_type {
   LF_METHOD = 0x150f,
   LF_ONEMETHOD = 0x1511,
   LF_FUNC_ID = 0x1601,
+  LF_MFUNC_ID = 0x1602,
   LF_STRING_ID = 0x1605,
   LF_CHAR = 0x8000,
   LF_SHORT = 0x8001,
@@ -4293,6 +4294,56 @@ write_lf_func_id (codeview_custom_type *t)
   asm_fprintf (asm_out_file, "%LLcv_type%x_end:\n", t->num);
 }
 
+/* Write an LF_MFUNC_ID type, which is the version of LF_FUNC_ID for struct
+   functions.  Instead of an LF_STRING_ID for the parent scope, we write the
+   type number of the parent struct.  */
+
+static void
+write_lf_mfunc_id (codeview_custom_type *t)
+{
+  size_t name_len;
+
+  /* This is lf_mfunc_id in binutils and lfMFuncId in Microsoft's cvinfo.h:
+
+struct lf_mfunc_id
+{
+  uint16_t size;
+  uint16_t kind;
+  uint32_t parent_type;
+  uint32_t function_type;
+  char name[];
+} ATTRIBUTE_PACKED
+  */
+
+  fputs (integer_asm_op (2, false), asm_out_file);
+  asm_fprintf (asm_out_file, "%LLcv_type%x_end - %LLcv_type%x_start\n",
+  t->num, t->num);
+
+  asm_fprintf (asm_out_file, "%LLcv_type%x_start:\n", t->num);
+
+  fputs (integer_asm_op (2, false), asm_out_file);
+  fprint_whex (asm_out_file, t->kind);
+  putc ('\n', asm_out_file);
+
+  fputs (integer_asm_op (4, false), asm_out_file);
+  fprint_whex (asm_out_file, t->lf_mfunc_id.parent_type);
+  putc ('\n', asm_out_file);
+
+  fputs (integer_asm_op (4, false), asm_out_file);
+  fprint_whex (asm_out_file, t->lf_mfunc_id.function_type);
+  putc ('\n', asm_out_file);
+
+  name_len = strlen (t->lf_mfunc_id.name) + 1;
+
+  ASM_OUTPUT_ASCII (asm_out_file, t->lf_mfunc_id.name, name_len);
+
+  write_cv_padding (4 - (name_len % 4));
+
+  free (t->lf_mfunc_id.name);
+
+  asm_fprintf (asm_out_file, "%LLcv_type%x_end:\n", t->num);
+}
+
 /* Write an LF_STRING_ID type, which provides a deduplicated string that other
types can reference.  */
 
@@ -4523,6 +4574,10 @@ write_custom_types (void)
  write_lf_func_id (custom_types);
  break;
 
+   case LF_MFUNC_ID:
+ write_lf_mfunc_id (custom_types);
+ break;
+
case LF_STRING_ID:
  write_lf_string_id (custom_types);
  break;
@@ -6192,21 +6247,13 @@ get_scope_string_id (dw_die_ref die)
   return ret;
 }
 
-/* Process a DW_TAG_subprogram DIE, and add an S_GPROC32_ID or S_LPROC32_ID
-   symbol for this.  */
+/* Add an LF_FUNC_ID type and return its number (see write_lf_func_id).  */
 
-static void
-add_function (dw_die_ref die)
+static uint32_t
+add_lf_func_id (dw_die_ref die, const char *name)
 {
+  uint32_t function_type, scope_type;
   codeview_custom_type *ct;
-  const char *name = get_AT_string (die, DW_AT_name);
-  uint32_t function_type, func_id_type, scope_type;
-  codeview_symbol *s;
-
-  if (!name)
-return;
-
-  /* Add an LF_FUNC_ID type for this function.  */
 
   function_type = get_type_num_subroutine_type (die, false, 0, 0, 0);
   scope_type = get_scope_string_id (die);
@@ -6221,7 +6268,84 @@ add_function (dw_die_ref die)
 
   add_custom_type (ct);
 
-  func_id_type = ct->num;
+  return ct->num;
+}
+
+/* Add an LF_MFUNC_ID type and return its number (see write_lf_mfunc_id).  */
+
+static uint32_t
+add_lf_mfunc_id (dw_die_ref die, const char *name)
+{
+  uint32_t function_type = 0, parent_type;
+  codeview_custom_type *ct;
+  dw_die_ref spec = get_AT_ref (die, DW_AT_specification);
+
+  parent_type = get_type_num (dw_get_die_parent (spec), false, false);
+
+  if (types_htab)
+{
+  codeview_type **slot;
+
+  slot = types_htab->find_slot_with_hash (spec, htab_hash_pointer (spec),
+ NO_INSERT);
+
+  if (slot && *slot)
+   function_type = (*slot)->num;
+}
+
+  if (function_type == 0)
+{
+  function_type = get_type_num_subroutine_type (die, false, parent_type,
+   0, 0);
+}
+
+  ct = (codeview_custom_type *) xmalloc 

[gcc r15-3279] Record member functions in CodeView struct definitions

2024-08-28 Thread Mark Harmstone via Gcc-cvs
https://gcc.gnu.org/g:c5043d89449758ecf6a3f1475e027a73976f58c3

commit r15-3279-gc5043d89449758ecf6a3f1475e027a73976f58c3
Author: Mark Harmstone 
Date:   Mon Aug 26 22:40:56 2024 +0100

Record member functions in CodeView struct definitions

CodeView has two ways of recording struct member functions.
Non-overloaded functions have an LF_ONEMETHOD sub-type in the field
list, which records the name and the function type (LF_MFUNCTION).
Overloaded functions have an LF_METHOD instead, which points to an
LF_METHODLIST, which is an array of links to various LF_MFUNCTION types.

gcc/
* dwarf2codeview.cc (enum cv_leaf_type): Add LF_MFUNCTION,
LF_METHODLIST, LF_METHOD, and LF_ONEMETHOD.
(struct codeview_subtype): Add lf_onemethod and lf_method to union.
(struct lf_methodlist_entry): New type.
(struct codeview_custom_type): Add lf_mfunc_id, lf_mfunction, and
lf_methodlist to union.
(struct codeview_method): New type.
(struct method_hasher): New type.
(get_type_num_subroutine_type): Add forward declaration.
(write_lf_fieldlist): Handle LF_ONEMETHOD and LF_METHOD.
(write_lf_mfunction): New function.
(write_lf_methodlist): New function.
(write_custom_types): Handle LF_MFUNCTION and LF_METHODLIST.
(add_struct_function): New function.
(get_mfunction_type): New function.
(is_templated_func): New function.
(get_type_num_struct): Handle DW_TAG_subprogram child DIEs.
(get_type_num_subroutine_type): Add containing_class_type, 
this_type,
and this_adjustment params, and handle creating LF_MFUNCTION types 
as
well as LF_PROCEDURE.
(get_type_num): New params for get_type_num_subroutine_type.
(add_function): New params for get_type_num_subroutine_type.
* dwarf2codeview.h (CV_METHOD_VANILLA, CV_METHOD_VIRTUAL): Define.
(CV_METHOD_STATIC, CV_METHOD_FRIEND, CV_METHOD_INTRO): Likewise.
(CV_METHOD_PUREVIRT, CV_METHOD_PUREINTRO): Likewise.

Diff:
---
 gcc/dwarf2codeview.cc | 530 --
 gcc/dwarf2codeview.h  |   9 +
 2 files changed, 528 insertions(+), 11 deletions(-)

diff --git a/gcc/dwarf2codeview.cc b/gcc/dwarf2codeview.cc
index e243e0fba251..00a1795575ab 100644
--- a/gcc/dwarf2codeview.cc
+++ b/gcc/dwarf2codeview.cc
@@ -95,9 +95,11 @@ enum cv_leaf_type {
   LF_MODIFIER = 0x1001,
   LF_POINTER = 0x1002,
   LF_PROCEDURE = 0x1008,
+  LF_MFUNCTION = 0x1009,
   LF_ARGLIST = 0x1201,
   LF_FIELDLIST = 0x1203,
   LF_BITFIELD = 0x1205,
+  LF_METHODLIST = 0x1206,
   LF_INDEX = 0x1404,
   LF_ENUMERATE = 0x1502,
   LF_ARRAY = 0x1503,
@@ -107,6 +109,8 @@ enum cv_leaf_type {
   LF_ENUM = 0x1507,
   LF_MEMBER = 0x150d,
   LF_STMEMBER = 0x150e,
+  LF_METHOD = 0x150f,
+  LF_ONEMETHOD = 0x1511,
   LF_FUNC_ID = 0x1601,
   LF_STRING_ID = 0x1605,
   LF_CHAR = 0x8000,
@@ -1225,9 +1229,27 @@ struct codeview_subtype
   uint32_t type;
   char *name;
 } lf_static_member;
+struct
+{
+  uint16_t method_attribute;
+  uint32_t method_type;
+  char *name;
+} lf_onemethod;
+struct
+{
+  uint16_t count;
+  uint32_t method_list;
+  char *name;
+} lf_method;
   };
 };
 
+struct lf_methodlist_entry
+{
+  uint16_t method_attribute;
+  uint32_t method_type;
+};
+
 struct codeview_custom_type
 {
   struct codeview_custom_type *next;
@@ -1302,10 +1324,32 @@ struct codeview_custom_type
   char *name;
 } lf_func_id;
 struct
+{
+  uint32_t parent_type;
+  uint32_t function_type;
+  char *name;
+} lf_mfunc_id;
+struct
 {
   uint32_t substring;
   char *string;
 } lf_string_id;
+struct
+{
+  uint32_t return_type;
+  uint32_t containing_class_type;
+  uint32_t this_type;
+  uint8_t calling_convention;
+  uint8_t attributes;
+  uint16_t num_parameters;
+  uint32_t arglist;
+  int32_t this_adjustment;
+} lf_mfunction;
+struct
+{
+  unsigned int count;
+  lf_methodlist_entry *entries;
+} lf_methodlist;
   };
 };
 
@@ -1330,6 +1374,31 @@ struct string_id_hasher : nofree_ptr_hash 
   }
 };
 
+struct codeview_method
+{
+  uint16_t attribute;
+  uint32_t type;
+  char *name;
+  unsigned int count;
+  struct codeview_method *next;
+  struct codeview_method *last;
+};
+
+struct method_hasher : nofree_ptr_hash 
+{
+  typedef const char *compare_type;
+
+  static hashval_t hash (const codeview_method *x)
+  {
+return htab_hash_string (x->name);
+  }
+
+  static bool equal (const codeview_method *x, const char *y)
+  {
+return !strcmp (x->name, y);
+  }
+};
+
 static unsigned int line_label_num;
 static unsigned int func_label_num;
 static unsigned int sym_label_num;
@@ -1348,6 +1417,10 @@ static codeview_deferred_type *deferred_types,

[gcc r15-3281] i386: Support wide immediate constants in STV.

2024-08-28 Thread Roger Sayle via Gcc-cvs
https://gcc.gnu.org/g:3cb92be94e6581697369eeafdb67057c8cfba73f

commit r15-3281-g3cb92be94e6581697369eeafdb67057c8cfba73f
Author: Roger Sayle 
Date:   Wed Aug 28 21:19:28 2024 -0600

i386: Support wide immediate constants in STV.

This patch provides more accurate costs/gains for (wide) immediate
constants in STV, suitably adjusting the costs/gains when the highpart
and lowpart words are the same.

2024-08-28  Roger Sayle  

gcc/ChangeLog
* config/i386/i386-features.cc (timode_immed_const_gain): New
function to determine the gain/cost on a CONST_WIDE_INT.
(timode_scalar_chain::compute_convert_gain): Fix whitespace.
: Provide more accurate estimates using
timode_immed_const_gain.
: Handle CONSTANT_SCALAR_INT_P (src).

Diff:
---
 gcc/config/i386/i386-features.cc | 28 +++-
 1 file changed, 27 insertions(+), 1 deletion(-)

diff --git a/gcc/config/i386/i386-features.cc b/gcc/config/i386/i386-features.cc
index ca902ecf0de5..c09a5c73a8e3 100644
--- a/gcc/config/i386/i386-features.cc
+++ b/gcc/config/i386/i386-features.cc
@@ -1503,6 +1503,23 @@ general_scalar_chain::convert_insn (rtx_insn *insn)
   df_insn_rescan (insn);
 }
 
+/* Helper function to compute gain for loading an immediate constant.
+   Typically, two movabsq for TImode vs. vmovdqa for V1TImode, but
+   with numerous special cases.  */
+
+static int
+timode_immed_const_gain (rtx cst)
+{
+  /* movabsq vs. movabsq+vmovq+vunpacklqdq.  */
+  if (CONST_WIDE_INT_P (cst)
+  && CONST_WIDE_INT_NUNITS (cst) == 2
+  && CONST_WIDE_INT_ELT (cst, 0) == CONST_WIDE_INT_ELT (cst, 1))
+return optimize_insn_for_size_p () ? -COSTS_N_BYTES (9)
+  : -COSTS_N_INSNS (2);
+  /* 2x movabsq ~ vmovdqa.  */
+  return 0;
+}
+
 /* Compute a gain for chain conversion.  */
 
 int
@@ -1549,7 +1566,14 @@ timode_scalar_chain::compute_convert_gain ()
case CONST_INT:
  if (MEM_P (dst)
  && standard_sse_constant_p (src, V1TImode))
-   igain = optimize_insn_for_size_p() ? COSTS_N_BYTES (11) : 1;
+   igain = optimize_insn_for_size_p () ? COSTS_N_BYTES (11) : 1;
+ break;
+
+   case CONST_WIDE_INT:
+ /* 2 x mov vs. vmovdqa.  */
+ if (MEM_P (dst))
+   igain = optimize_insn_for_size_p () ? COSTS_N_BYTES (3)
+   : COSTS_N_INSNS (1);
  break;
 
case NOT:
@@ -1562,6 +1586,8 @@ timode_scalar_chain::compute_convert_gain ()
case IOR:
  if (!MEM_P (dst))
igain = COSTS_N_INSNS (1);
+ if (CONST_SCALAR_INT_P (XEXP (src, 1)))
+   igain += timode_immed_const_gain (XEXP (src, 1));
  break;
 
case ASHIFT: