[gcc r15-8025] match.pd: Fold ((X >> C1) & C2) * (1 << C1)

2025-03-13 Thread Richard Sandiford via Gcc-cvs
https://gcc.gnu.org/g:7dae3f64c069b942b9abd768fd94af4b2cd0b781

commit r15-8025-g7dae3f64c069b942b9abd768fd94af4b2cd0b781
Author: Richard Sandiford 
Date:   Thu Mar 13 12:03:04 2025 +

match.pd: Fold ((X >> C1) & C2) * (1 << C1)

Using a combination of rules, we were able to fold

  ((X >> C1) & C2) * (1 << C1)  -->  X & (C2 << C1)

if everything was done at the same precision, but we couldn't fold
it if the AND was done at a different precision.  The optimisation is
often (but not always) valid for that case too.

This patch adds a dedicated rule for the case where different precisions
are involved.

An alternative would be to extend the individual folds that together
handle the same-precision case so that those rules handle differing
precisions.  But the risk is that that could replace narrow operations
with wide operations, which would be especially harmful on targets
like avr.  It's also not obviously free of cycles.

I also wondered whether the converts should be non-optional.

gcc/
* match.pd: Fold ((X >> C1) & C2) * (1 << C1) to X & (C2 << C1).

gcc/testsuite/
* gcc.dg/fold-mul-and-lshift-1.c: New test.
* gcc.dg/fold-mul-and-lshift-2.c: Likewise.

Diff:
---
 gcc/match.pd | 28 +
 gcc/testsuite/gcc.dg/fold-mul-and-lshift-1.c | 59 
 gcc/testsuite/gcc.dg/fold-mul-and-lshift-2.c | 15 +++
 3 files changed, 102 insertions(+)

diff --git a/gcc/match.pd b/gcc/match.pd
index 5c679848bdf2..7017fd15277b 100644
--- a/gcc/match.pd
+++ b/gcc/match.pd
@@ -5231,6 +5231,34 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
  (if (mask)
   (bit_op (shift (convert @0) @1) { mask; })))
 
+/* Fold ((X >> C1) & C2) * (1 << C1) into X & (C2 << C1), including cases where
+   the & happens in a different type.  It is the conversion case that isn't
+   a composition of other folds.
+
+   Let the type of the * and >> be T1 and the type of the & be T2.
+   The fold is valid if the conversion to T2 preserves all information;
+   that is, if T2 is wider than T1 or drops no more than C1 bits from T1.
+   In that case, the & might operate on bits that are dropped by the
+   later conversion to T1 and the multiplication by (1 << C1), but those
+   bits are also dropped by ANDing with C2 << C1 (converted to T1).
+
+   If the conversion to T2 is not information-preserving, we have to be
+   careful about the later conversion to T1 acting as a sign extension.
+   We need either T2 to be unsigned or the top (sign) bit of C2 to be clear.
+   That is equivalent to testing whether C2 is nonnegative.  */
+(simplify
+ (mult (convert? (bit_and (convert? (rshift @0 INTEGER_CST@1)) INTEGER_CST@2))
+   INTEGER_CST@3)
+ (if (tree_nop_conversion_p (type, TREE_TYPE (@0))
+  && wi::ltu_p (wi::to_widest (@1), TYPE_PRECISION (type)))
+  (with { unsigned int shift = tree_to_uhwi (@1);
+ unsigned int prec = TYPE_PRECISION (type); }
+   (if ((prec <= TYPE_PRECISION (TREE_TYPE (@2)) + shift
+|| tree_int_cst_sgn (@2) >= 0)
+   && wi::to_wide (@3) == wi::set_bit_in_zero (shift, prec))
+(with { auto mask = wide_int::from (wi::to_wide (@2), prec, UNSIGNED); }
+ (bit_and @0 { wide_int_to_tree (type, mask << shift); }))
+
 /* ~(~X >> Y) -> X >> Y (for arithmetic shift).  */
 (simplify
  (bit_not (convert1?:s (rshift:s (convert2?@0 (bit_not @1)) @2)))
diff --git a/gcc/testsuite/gcc.dg/fold-mul-and-lshift-1.c 
b/gcc/testsuite/gcc.dg/fold-mul-and-lshift-1.c
new file mode 100644
index ..b1ce10495e30
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/fold-mul-and-lshift-1.c
@@ -0,0 +1,59 @@
+/* { dg-do compile { target lp64 } } */
+/* { dg-options "-O2 -fdump-tree-optimized" } */
+/* { dg-final { scan-tree-dump-not { >> } "optimized" } } */
+/* { dg-final { scan-tree-dump-not { \* } "optimized" } } */
+
+unsigned int
+f1 (unsigned int x)
+{
+x >>= 1;
+unsigned long y = x;
+y &= 255;
+x = y;
+x *= 2;
+return x;
+}
+
+unsigned int
+f2 (unsigned int x)
+{
+x >>= 1;
+unsigned long y = x;
+y &= -2UL;
+x = y;
+x *= 2;
+return x;
+}
+
+unsigned int
+f3 (unsigned int x)
+{
+x >>= 1;
+unsigned short y = x;
+y &= 255;
+x = y;
+x *= 2;
+return x;
+}
+
+unsigned int
+f4 (unsigned int x)
+{
+x >>= 1;
+short y = x;
+y &= (unsigned short) ~0U >> 1;
+x = y;
+x *= 2;
+return x;
+}
+
+unsigned int
+f5 (unsigned int x)
+{
+x >>= 16;
+short y = x;
+y &= -2;
+x = y;
+x *= 1 << 16;
+return x;
+}
diff --git a/gcc/testsuite/gcc.dg/fold-mul-and-lshift-2.c 
b/gcc/testsuite/gcc.dg/fold-mul-and-lshift-2.c
new file mode 100644
index ..86eabef0fef2
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/fold-mul-and-lshift-2.c
@@ -0,0 +1,15 @@
+/* { dg-do compile { target int32 } } */
+/* { dg-options "-O2 -fdump-tree-optimized" }

[gcc r15-8029] aarch64: xfail pr109072_1.c's s16x4_2 [PR117092]

2025-03-13 Thread Andrew Pinski via Gcc-cvs
https://gcc.gnu.org/g:e5d54c33a257b3f7137f8408592df009dffb5711

commit r15-8029-ge5d54c33a257b3f7137f8408592df009dffb5711
Author: Andrew Pinski 
Date:   Wed Mar 12 17:04:47 2025 -0700

aarch64: xfail pr109072_1.c's s16x4_2 [PR117092]

The fix for this depends on much more infrastructure which won't
be done for another few weeks. Pengxuan is working on the fix for GCC 16.
So let's xfail the testcase since it is a minor code quality regression.
we get:
```
moviv0.2s, 0
ins v0.h[0], w0
```
vs what we should get:
```
and x0, x0, 65535
fmovd0, x0
```
or
```
fmovh0, x0
```

Tested for aarch64-linux-gnu.

PR target/117092

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/pr109072_1.c: xfail s16x4_2.

Signed-off-by: Andrew Pinski 

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

diff --git a/gcc/testsuite/gcc.target/aarch64/pr109072_1.c 
b/gcc/testsuite/gcc.target/aarch64/pr109072_1.c
index 0fc195a598f3..39d802221424 100644
--- a/gcc/testsuite/gcc.target/aarch64/pr109072_1.c
+++ b/gcc/testsuite/gcc.target/aarch64/pr109072_1.c
@@ -77,7 +77,8 @@ s16x4_1 (int16_t x)
 }
 
 /*
-** s16x4_2:
+PR target/117092
+** s16x4_2: { xfail *-*-* }
 ** ...
 ** fmov[dsh]0, [wx][0-9]+
 ** ret
@@ -127,7 +128,7 @@ s64x2_1 (int64_t x)
 }
 
 /*
-** s64x2_2: { xfail *-*-* }
+** s64x2_2:
 ** fmovd0, x0
 ** ret
 */


[gcc r15-8020] cobol/119229 - fix external variable declaration

2025-03-13 Thread Richard Biener via Gcc-cvs
https://gcc.gnu.org/g:d109ad5e96ee9d31cbab0bba385fb490275a9937

commit r15-8020-gd109ad5e96ee9d31cbab0bba385fb490275a9937
Author: Richard Biener 
Date:   Wed Mar 12 13:46:14 2025 +0100

cobol/119229 - fix external variable declaration

The following makes vs_external_reference behave like documented,
declare a variable defined elsewhere which means not setting
TREE_STATIC but DECL_EXTERNAL.

Built on x86_64-unknown-linux-gnu, tested with the cobol.dg
testsuite (which doesn't mean much).  The removed comment mentions
'stderr', possibly the NIST testsuite has coverage.

OK for trunk?

Thanks,
Richard.

PR cobol/119229
* gengen.cc (gg_declare_variable): Use DECL_EXTERNAL and
drop TREE_STATIC for vs_external_reference.

* cobol.dg/pr119229.cob: New testcase.

Diff:
---
 gcc/cobol/gengen.cc |  6 +-
 gcc/testsuite/cobol.dg/pr119229.cob | 16 
 2 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/gcc/cobol/gengen.cc b/gcc/cobol/gengen.cc
index c39af0b45d83..4fc0a830c1ed 100644
--- a/gcc/cobol/gengen.cc
+++ b/gcc/cobol/gengen.cc
@@ -1012,13 +1012,9 @@ gg_declare_variable(tree type_decl,
   break;
 case vs_external_reference:
   // This is for referencing variables defined elsewhere
-  // TODO: Figure out why this is working.  For accessing "stderr", it
-  // doesn't matter if TREE_PUBLIC is on, but TREE_STATIC has to be on. 
This
-  // does *not* match what is seen when compiling a C program that accesses
-  // "stderr".
   DECL_CONTEXT (var_decl) = gg_trans_unit.trans_unit_decl;
   TREE_USED(var_decl)   = 1;
-  TREE_STATIC(var_decl) = 1;
+  DECL_EXTERNAL (var_decl) = 1;
   TREE_PUBLIC(var_decl) = 1;
   break;
 }
diff --git a/gcc/testsuite/cobol.dg/pr119229.cob 
b/gcc/testsuite/cobol.dg/pr119229.cob
new file mode 100644
index ..e7b500067eea
--- /dev/null
+++ b/gcc/testsuite/cobol.dg/pr119229.cob
@@ -0,0 +1,16 @@
+*> { dg-do compile }
+*> { dg-options "-flto" { target lto } }
+IDENTIFICATION DIVISION.
+PROGRAM-ID. CobolGreeting.
+*>Program to display COBOL greetings
+DATA DIVISION.
+WORKING-STORAGE SECTION.
+01  IterNum   PIC 9 VALUE 5.
+
+PROCEDURE DIVISION.
+BeginProgram.
+   PERFORM DisplayGreeting IterNum TIMES.
+   STOP RUN.
+
+DisplayGreeting.
+   DISPLAY "Greetings from COBOL".


[gcc r14-11405] c++: ICE with lambda in fold expression in requires [PR119134]

2025-03-13 Thread Marek Polacek via Gcc-cvs
https://gcc.gnu.org/g:e5ae0a014fbc792a69267af79cfbf580566b436a

commit r14-11405-ge5ae0a014fbc792a69267af79cfbf580566b436a
Author: Marek Polacek 
Date:   Fri Mar 7 11:26:46 2025 -0500

c++: ICE with lambda in fold expression in requires [PR119134]

The r12-8258 fix assumes that DECL_CONTEXT of 'pack' in
check_for_bare_parameter_packs is going to be an operator()
but as this test shows, it can be empty.

PR c++/119134

gcc/cp/ChangeLog:

* pt.cc (check_for_bare_parameter_packs): Check DECL_CONTEXT.

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/lambda-uneval24.C: New test.

Reviewed-by: Jason Merrill 
(cherry picked from commit 0e47062ce70d147091f1a97ec94bd6efad92bc5e)

Diff:
---
 gcc/cp/pt.cc | 1 +
 gcc/testsuite/g++.dg/cpp2a/lambda-uneval24.C | 4 
 2 files changed, 5 insertions(+)

diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc
index d5bf6af8467f..3369e6218aa5 100644
--- a/gcc/cp/pt.cc
+++ b/gcc/cp/pt.cc
@@ -4336,6 +4336,7 @@ check_for_bare_parameter_packs (tree t, location_t loc /* 
= UNKNOWN_LOCATION */)
tree pack = TREE_VALUE (parameter_packs);
if (is_capture_proxy (pack)
|| (TREE_CODE (pack) == PARM_DECL
+   && DECL_CONTEXT (pack)
&& DECL_CONTEXT (DECL_CONTEXT (pack)) == lam))
  break;
   }
diff --git a/gcc/testsuite/g++.dg/cpp2a/lambda-uneval24.C 
b/gcc/testsuite/g++.dg/cpp2a/lambda-uneval24.C
new file mode 100644
index ..a2b45595e479
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp2a/lambda-uneval24.C
@@ -0,0 +1,4 @@
+// PR c++/119134
+// { dg-do compile { target c++20 } }
+
+void f(auto... args) requires(([args] {}, ..., true)) {}


[gcc r15-8038] testsuite, gm2: Use -B option for libstdc++ where required.

2025-03-13 Thread Iain D Sandoe via Gcc-cvs
https://gcc.gnu.org/g:6b9ceac9e4e2be304c39e6bc8744edf21faac4fb

commit r15-8038-g6b9ceac9e4e2be304c39e6bc8744edf21faac4fb
Author: Iain Sandoe 
Date:   Mon Mar 10 08:44:41 2025 +

testsuite, gm2: Use -B option for libstdc++ where required.

We need to add testsuite  options to locate gm2 libs and libstdc++.

Usually '-L' options are added to point to the relevant directories for
the uninstalled libraries.

In cases where libraries are available as both shared and convenience some
additional checks are made.

For some targets -static- options are handled by specs substitution and
need a '-B' option rather than '-L'.  For Darwin, when embedded runpaths are
in use (the default for all versions after macOS 10.11), '-B' is also needed
to provide the runpath.

When '-B' is used, this results in a '-L' for each path that exists (so that
appending a '-L' as well is a needless duplicate).  There are also cases
where tools warn for duplicates, leading to spurious fails.

Therefore the objective of the code here is to add just one '-L' or '-B' for
each of the libraries.

Currently, we are forcing the full paths to each of the gm2 convenience libs
onto the link line and therefore the B/L logic is not needed there.  It 
would
need to be added if/when gm2 is tested with shared libraries

gcc/testsuite/ChangeLog:

* lib/gm2.exp: Arrange for a '-B' option to be added for the
libstdc++ paths on targets that need it.

Signed-off-by: Iain Sandoe 

Diff:
---
 gcc/testsuite/lib/gm2.exp | 46 --
 1 file changed, 36 insertions(+), 10 deletions(-)

diff --git a/gcc/testsuite/lib/gm2.exp b/gcc/testsuite/lib/gm2.exp
index f7d42a16e18e..5760bc02b1e5 100644
--- a/gcc/testsuite/lib/gm2.exp
+++ b/gcc/testsuite/lib/gm2.exp
@@ -254,12 +254,35 @@ proc gm2_link_flags { paths } {
 if [istarget "powerpc-*-*"] {
lappend flags "-mabi=ieeelongdouble"
 }
+
+# We need to add options to locate gm2 libs and libstdc++
+# Usually '-L' options are added to point to the relevant directories for
+# the uninstalled libraries.
+
+# In cases where libraries are available as both shared and convenience
+# some additional checks are made.
+
+# For some targets -static- options are handled by specs substitution
+# and need a '-B' option rather than '-L'.  For Darwin, when embedded
+# runpaths are in use (the default for all versions after macOS 10.11),
+# '-B' is also needed to provide the runpath.
+# When '-B' is used, this results in a '-L' for each path that exists (so
+# that appending a '-L' as well is a needless duplicate).  There are also
+# cases where tools warn for duplicates, leading to spurious fails.
+# Therefore the objective of the code below is to add just one '-L' or
+# '-B' for each of the libraries.
+
+set target_wants_B_option 0
+if { [istarget *-*-darwin9* ] || [istarget *-*-darwin\[12\]* ] } {
+  set target_wants_B_option 1
+}
+
 if { $gccpath == "" } {
   global tool_root_dir
 
   set libstdcpp [lookfor_file ${tool_root_dir} libstdc++]
   if { $libstdcpp != "" } {
-  append flags "-L${libstdcpp} "
+  append flags " -L${libstdcpp} "
   append ld_library_path ":${libstdcpp}"
   }
 } else {
@@ -267,19 +290,22 @@ proc gm2_link_flags { paths } {
append ld_library_path ":${gccpath}/lib"
}
if [file exists "${gccpath}/libstdc++/libstdc++.a"] {
-   append flags "-L${gccpath}/libstdc++ "
+   append flags " -L${gccpath}/libstdc++ "
append ld_library_path ":${gccpath}/libstdc++"
}
-   if [file exists "${gccpath}/libstdc++-v3/src/.libs/libstdc++.a"] {
-   append flags " -L${gccpath}/libstdc++-v3/src/.libs "
-   append ld_library_path ":${gccpath}/libstdc++-v3/src/.libs"
-   }
-   # Look for libstdc++.${shlib_ext}.
-   if [file exists 
"${gccpath}/libstdc++-v3/src/.libs/libstdc++.${shlib_ext}"] {
-   append flags " -L${gccpath}/libstdc++-v3/src/.libs "
+   # Look for libstdc++..
+if { [file exists "${gccpath}/libstdc++-v3/src/.libs/libstdc++.a"] \
+|| [file exists 
"${gccpath}/libstdc++-v3/src/.libs/libstdc++.${shlib_ext}"] } {
+if { $target_wants_B_option } {
+   append flags " -B${gccpath}/libstdc++-v3/src/.libs "
+} else {
+   append flags " -L${gccpath}/libstdc++-v3/src/.libs "
+}
append ld_library_path ":${gccpath}/libstdc++-v3/src/.libs"
}
 
+   # Here we are forcing the static libraries, with complete paths so 
+   # there's no -L/-B logic needed
# puts stderr "${gm2_link_libraries}  before foreach"
foreach d [list {*}${gm2_link_libraries}] {
# puts stderr "${d}  "
@@ -288

[gcc r15-8030] libstdc++: Fix ref_view branch of views::as_const [PR119135]

2025-03-13 Thread Patrick Palka via Gcc-cvs
https://gcc.gnu.org/g:50359c0a44381edb6dbd9359ef2ebdadbcc3ed42

commit r15-8030-g50359c0a44381edb6dbd9359ef2ebdadbcc3ed42
Author: Patrick Palka 
Date:   Thu Mar 13 09:15:21 2025 -0400

libstdc++: Fix ref_view branch of views::as_const [PR119135]

Unlike for span and empty_view, the range_reference_t of
ref_view doesn't correspond to X.  This patch fixes the ref_view
branch of views::as_const to correctly query its underlying range
type X.

PR libstdc++/119135

libstdc++-v3/ChangeLog:

* include/std/ranges: Include .
(views::__detail::__is_ref_view): Replace with ...
(views::__detail::__is_constable_ref_view): ... this.
(views::_AsConst::operator()): Replace bogus use of element_type
in the ref_view branch.
* testsuite/std/ranges/adaptors/as_const/1.cc (test03): Extend
test.

Reviewed-by: Tomasz Kamiński 
Reviewed-by: Jonathan Wakely 

Diff:
---
 libstdc++-v3/include/std/ranges  | 12 ++--
 libstdc++-v3/testsuite/std/ranges/adaptors/as_const/1.cc |  4 
 2 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/libstdc++-v3/include/std/ranges b/libstdc++-v3/include/std/ranges
index c2a2d6f4e05e..ef277b81bd3c 100644
--- a/libstdc++-v3/include/std/ranges
+++ b/libstdc++-v3/include/std/ranges
@@ -48,6 +48,7 @@
 #include 
 #include 
 #if __cplusplus > 202002L
+#include 
 #include 
 #endif
 #include 
@@ -9324,10 +9325,11 @@ namespace views::__adaptor
 namespace __detail
 {
   template
-   inline constexpr bool __is_ref_view = false;
+   inline constexpr bool __is_constable_ref_view = false;
 
   template
-   inline constexpr bool __is_ref_view> = true;
+   inline constexpr bool __is_constable_ref_view>
+ = constant_range;
 
   template
concept __can_as_const_view = requires { 
as_const_view(std::declval<_Range>()); };
@@ -9349,10 +9351,8 @@ namespace views::__adaptor
  return views::empty;
else if constexpr (std::__detail::__is_span<_Tp>)
  return span(std::forward<_Range>(__r));
-   else if constexpr (__detail::__is_ref_view<_Tp>
-  && constant_range)
- return ref_view(static_cast
- (std::forward<_Range>(__r).base()));
+   else if constexpr (__detail::__is_constable_ref_view<_Tp>)
+ return ref_view(std::as_const(std::forward<_Range>(__r).base()));
else if constexpr (is_lvalue_reference_v<_Range>
   && constant_range
   && !view<_Tp>)
diff --git a/libstdc++-v3/testsuite/std/ranges/adaptors/as_const/1.cc 
b/libstdc++-v3/testsuite/std/ranges/adaptors/as_const/1.cc
index c36786a8c5fa..3f1f8eb17726 100644
--- a/libstdc++-v3/testsuite/std/ranges/adaptors/as_const/1.cc
+++ b/libstdc++-v3/testsuite/std/ranges/adaptors/as_const/1.cc
@@ -63,6 +63,10 @@ test03()
   std::vector v;
   std::same_as>>
 auto r = views::as_const(v);
+
+  // PR libstdc++/119135
+  std::same_as>>
+auto r2 = views::as_const(views::all(v));
 }
 
 int


[gcc r15-8031] testsuite: Add -fno-tree-sink to sve/pr96357.c

2025-03-13 Thread Richard Sandiford via Gcc-cvs
https://gcc.gnu.org/g:11c6d8cc9e5924c3a70e9289d1be2c2885b1dc6d

commit r15-8031-g11c6d8cc9e5924c3a70e9289d1be2c2885b1dc6d
Author: Richard Sandiford 
Date:   Thu Mar 13 13:23:28 2025 +

testsuite: Add -fno-tree-sink to sve/pr96357.c

gcc.target/aarch64/sve/pr96357.c started failing after
r15-518-g99b1daae18c095d6, which tweaked the heuristics
about when to sink code.  The testcase has:

  double i = d, j = 1.0 - f, k = j ? d : j;
  if (k == 1.0)
i = 0.0;
  *l = *n = *g = *h = i * 0.5;

where k == 1.0 is false if j is zero (since k is then also 0).
So we end up with a diamond whose condition is j != 0 && d == 1.
The else branch of the diamond is the only one that uses the result
of i = d, so after the patch, we sink the conversion to there.
And that seems like a reasonable thing to do.

However, aarch64 doesn't yet allow int->double conversions to be
predicated, so ifcvt cannot handle the sunk form, meaning that we
can no longer vectorise.

The testcase is highly artificial and so shouldn't IMO be used
to tune the sinking heuristics.  Instead I think we should just
disable sinking for the test.  An alternative would be to add
-ffast-math, but I think that would interfere more with the
original intent.

gcc/testsuite/
* gcc.target/aarch64/sve/pr96357.c: Add -fno-tree-sink.

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

diff --git a/gcc/testsuite/gcc.target/aarch64/sve/pr96357.c 
b/gcc/testsuite/gcc.target/aarch64/sve/pr96357.c
index 5d8fd8b53c3d..9a7f912e529f 100644
--- a/gcc/testsuite/gcc.target/aarch64/sve/pr96357.c
+++ b/gcc/testsuite/gcc.target/aarch64/sve/pr96357.c
@@ -1,5 +1,5 @@
 /* { dg-do compile } */
-/* { dg-options "-fpermissive -O3 -march=armv8.2-a+sve" } */
+/* { dg-options "-fpermissive -O3 -march=armv8.2-a+sve -fno-tree-sink" } */
 
 int d;


[gcc/rdubner/heads/bobdev] (33 commits) aarch64: xfail pr109072_1.c's s16x4_2 [PR117092]

2025-03-13 Thread Robert Dubner via Gcc-cvs
The branch 'rdubner/heads/bobdev' was updated to point to:

 e5d54c33a257... aarch64: xfail pr109072_1.c's s16x4_2 [PR117092]

It previously pointed to:

 52e297a3aa91... MAINTAINERS: Remove extraneous "Robert Dubner" entries

Diff:

Summary of changes (added commits):
---

  e5d54c3... aarch64: xfail pr109072_1.c's s16x4_2 [PR117092] (*)
  6888a4b... Move 'find-dg-do-what' from 'gcc/testsuite/lib/gcc-dg.exp'  (*)
  5967fe0... libstdc++: Allow 'configure.host' to pre-set 'EXTRA_CFLAGS' (*)
  feb75e4... match.pd: Extend pointer alignment folds (*)
  7dae3f6... match.pd: Fold ((X >> C1) & C2) * (1 << C1) (*)
  a68e32b... testsuite: Remove sve/pre_cond_share_1.c [PR115248] (*)
  22847ef... libstdc++: Hide 128-bit int and float types behind handle f (*)
  77ef91d... RISC-V: Do not delete fused vsetvl if it has uses [PR119115 (*)
  f043ef2... RISC-V: Adjust LMUL when using maximum SEW [PR117955]. (*)
  d109ad5... cobol/119229 - fix external variable declaration (*)
  6fe63cc... Remove extra argument from subst macro (*)
  f1baee3... Allow to build libgccjit with a soname bound to the GCC maj (*)
  4e6967a... LoongArch: Don't use C++17 feature [PR119238] (*)
  8015a72... analyzer: support RAW_DATA_CST [PR117262] (*)
  0385556... Daily bump. (*)
  ebf6e62... c++: Evaluate immediate invocation call arguments with mce_ (*)
  2eb3d74... c++/modules: Better handle no-linkage decls in unnamed name (*)
  4cd99e4... c++/modules: Handle gnu_inline attribute, cleanup linkage d (*)
  3dd7b59... c++: ICE with aligned member and trivial assign op [PR11751 (*)
  cfb20f1... libstdc++: Implement P3137R3 views::to_input for C++26 (*)
  90e53ec... c++: Look through capture proxy from outer lambda instead o (*)
  9ee6c26... arm: testsuite: remove gcc.target/arm/lp1243022.c [PR117931 (*)
  d8a3944... libstdc++: Use new  header in  (*)
  fdcff3f... Remove bogus dg-error statements from binding_label_tests_2 (*)
  0e47062... c++: ICE with lambda in fold expression in requires [PR1191 (*)
  2560603... libstdc++: Optimize basic_format_parse_context::check_dynam (*)
  4d2683b... libstdc++: Add static_assert to std::packaged_task::package (*)
  0ce4c1c... libstdc++: Update tzdata to 2025a (*)
  90f5dab... contrib: relpath.sh /lib /include [PR119081] (*)
  758e617... df: Treat partial defs as uses in df_simulate_defs [PR11656 (*)
  d63b52e... libphobos: Merge upstream phobos 0faae92d6 (*)
  6e40455... arm: allow type-punning subregs in vpr_register_operand [PR (*)
  baa9b2b... Fortran: Add F2018 TEAM_NUMBER to coindexed expressions [PR (*)

(*) This commit already exists in another branch.
Because the reference `refs/users/rdubner/heads/bobdev' matches
your hooks.email-new-commits-only configuration,
no separate email is sent for this commit.


[gcc r15-8032] libgcc: Remove PREDRES and LS64 from AArch64 cpuinfo

2025-03-13 Thread Wilco Dijkstra via Gcc-cvs
https://gcc.gnu.org/g:6e47e6d48844ee578fd384aaa4b8cd62d73b49db

commit r15-8032-g6e47e6d48844ee578fd384aaa4b8cd62d73b49db
Author: Wilco Dijkstra 
Date:   Mon Feb 24 16:38:02 2025 +

libgcc: Remove PREDRES and LS64 from AArch64 cpuinfo

Change AArch64 cpuinfo to follow the latest updates to the FMV spec [1]:
Remove FEAT_PREDRES and FEAT_LS64*.  Preserve the ordering in enum 
CPUFeatures.

[1] https://github.com/ARM-software/acle/pull/382

gcc:
* common/config/aarch64/cpuinfo.h: Remove FEAT_PREDRES and 
FEAT_LS64*.
* config/aarch64/aarch64-option-extensions.def: Remove FMV support
for PREDRES.

libgcc:
* config/aarch64/cpuinfo.c (__init_cpu_features_constructor):
Remove FEAT_PREDRES and FEAT_LS64* support.

Diff:
---
 gcc/common/config/aarch64/cpuinfo.h  |  8 
 gcc/config/aarch64/aarch64-option-extensions.def |  2 +-
 libgcc/config/aarch64/cpuinfo.c  | 19 ---
 3 files changed, 5 insertions(+), 24 deletions(-)

diff --git a/gcc/common/config/aarch64/cpuinfo.h 
b/gcc/common/config/aarch64/cpuinfo.h
index aff43908e01a..cd3c2b20c531 100644
--- a/gcc/common/config/aarch64/cpuinfo.h
+++ b/gcc/common/config/aarch64/cpuinfo.h
@@ -75,13 +75,13 @@ enum CPUFeatures {
   FEAT_MEMTAG2,
   FEAT_MEMTAG3,
   FEAT_SB,
-  FEAT_PREDRES,
+  FEAT_unused1,
   FEAT_SSBS,
   FEAT_SSBS2,
   FEAT_BTI,
-  FEAT_LS64,
-  FEAT_LS64_V,
-  FEAT_LS64_ACCDATA,
+  FEAT_unused2,
+  FEAT_unused3,
+  FEAT_unused4,
   FEAT_WFXT,
   FEAT_SME_F64,
   FEAT_SME_I64,
diff --git a/gcc/config/aarch64/aarch64-option-extensions.def 
b/gcc/config/aarch64/aarch64-option-extensions.def
index aa8d315c240f..79b79358c5d4 100644
--- a/gcc/config/aarch64/aarch64-option-extensions.def
+++ b/gcc/config/aarch64/aarch64-option-extensions.def
@@ -213,7 +213,7 @@ AARCH64_OPT_EXTENSION("memtag", MEMTAG, (), (), (), "")
 
 AARCH64_OPT_FMV_EXTENSION("sb", SB, (), (), (), "sb")
 
-AARCH64_OPT_FMV_EXTENSION("predres", PREDRES, (), (), (), "")
+AARCH64_OPT_EXTENSION("predres", PREDRES, (), (), (), "")
 
 AARCH64_OPT_EXTENSION("ssbs", SSBS, (), (), (), "ssbs")
 
diff --git a/libgcc/config/aarch64/cpuinfo.c b/libgcc/config/aarch64/cpuinfo.c
index 6b4952ee542e..dda9dc696893 100644
--- a/libgcc/config/aarch64/cpuinfo.c
+++ b/libgcc/config/aarch64/cpuinfo.c
@@ -339,25 +339,6 @@ __init_cpu_features_constructor (unsigned long hwcap,
 setCPUFeature(FEAT_SME_I64);
   if (hwcap2 & HWCAP2_SME_F64F64)
 setCPUFeature(FEAT_SME_F64);
-  if (hwcap & HWCAP_CPUID)
-{
-  unsigned long ftr;
-
-  getCPUFeature(ID_AA64ISAR1_EL1, ftr);
-  /* ID_AA64ISAR1_EL1.SPECRES >= 0b0001  */
-  if (extractBits(ftr, 40, 4) >= 0x1)
-   setCPUFeature(FEAT_PREDRES);
-  /* ID_AA64ISAR1_EL1.LS64 >= 0b0001  */
-  if (extractBits(ftr, 60, 4) >= 0x1)
-   setCPUFeature(FEAT_LS64);
-  /* ID_AA64ISAR1_EL1.LS64 >= 0b0010  */
-  if (extractBits(ftr, 60, 4) >= 0x2)
-   setCPUFeature(FEAT_LS64_V);
-  /* ID_AA64ISAR1_EL1.LS64 >= 0b0011  */
-  if (extractBits(ftr, 60, 4) >= 0x3)
-   setCPUFeature(FEAT_LS64_ACCDATA);
-}
-
   if (hwcap & HWCAP_FP)
 {
   setCPUFeature(FEAT_FP);


[gcc r15-8039] libstdc++: Add P1206R7 from_range members to container adaptors [PR111055]

2025-03-13 Thread Tomasz Kaminski via Gcc-cvs
https://gcc.gnu.org/g:20828a812822f3009c3fe8a15d3db9160819b7de

commit r15-8039-g20828a812822f3009c3fe8a15d3db9160819b7de
Author: Jonathan Wakely 
Date:   Tue Oct 8 21:15:18 2024 +0100

libstdc++: Add P1206R7 from_range members to container adaptors [PR111055]

This is another piece of P1206R7, adding new members to std::stack,
std::queue, and std::priority_queue.

PR libstdc++/111055

libstdc++-v3/ChangeLog:

* include/bits/stl_queue.h (queue(from_range_t, _Rg&&))
(queue(from_range_t, _Rg&&, const _Alloc&), push_range):
Define.
(priority_queue(from_range_t, R&&, const Compare&))
(push_range): Define.
* include/bits/stl_stack.h (stack(from_range_t, R&&))
(stack(from_range_t, R&&, const Alloc&), push_range): Define.
* testsuite/util/testsuite_iterators.h (test_range_nocopy): Define.
* testsuite/23_containers/priority_queue/cons_from_range.cc: New 
test.
* testsuite/23_containers/priority_queue/members/push_range.cc: New 
test.
* testsuite/23_containers/queue/cons_from_range.cc: New test.
* testsuite/23_containers/queue/members/push_range.cc: New test.
* testsuite/23_containers/stack/cons_from_range.cc: New test.
* testsuite/23_containers/stack/members/push_range.cc: New test.

Co-authored-by: Tomasz Kamiński 
Signed-off-by: Tomasz Kamiński 

Diff:
---
 libstdc++-v3/include/bits/stl_queue.h  | 102 +++
 libstdc++-v3/include/bits/stl_stack.h  |  46 +
 .../priority_queue/cons_from_range.cc  | 111 +
 .../priority_queue/members/push_range.cc   |  86 
 .../23_containers/queue/cons_from_range.cc |  88 
 .../23_containers/queue/members/push_range.cc  |  73 ++
 .../23_containers/stack/cons_from_range.cc |  89 +
 .../23_containers/stack/members/push_range.cc  |  74 ++
 libstdc++-v3/testsuite/util/testsuite_iterators.h  |  11 ++
 9 files changed, 680 insertions(+)

diff --git a/libstdc++-v3/include/bits/stl_queue.h 
b/libstdc++-v3/include/bits/stl_queue.h
index 627d5e4e63ba..2a4b62918a0a 100644
--- a/libstdc++-v3/include/bits/stl_queue.h
+++ b/libstdc++-v3/include/bits/stl_queue.h
@@ -61,6 +61,10 @@
 #if __cplusplus >= 201103L
 # include 
 #endif
+#if __glibcxx_ranges_to_container // C++ >= 23
+# include  // ranges::to
+# include  // ranges::copy
+#endif
 
 namespace std _GLIBCXX_VISIBILITY(default)
 {
@@ -209,6 +213,27 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
: c(__first, __last, __a) { }
 #endif
 
+#if __glibcxx_ranges_to_container // C++ >= 23
+  /**
+   * @brief Construct a queue from a range.
+   * @since C++23
+   */
+  template<__detail::__container_compatible_range<_Tp> _Rg>
+   queue(from_range_t, _Rg&& __rg)
+   : c(ranges::to<_Sequence>(std::forward<_Rg>(__rg)))
+   { }
+
+  /**
+   * @brief Construct a queue from a range.
+   * @since C++23
+   */
+  template<__detail::__container_compatible_range<_Tp> _Rg,
+  typename _Alloc>
+   queue(from_range_t, _Rg&& __rg, const _Alloc& __a)
+   : c(ranges::to<_Sequence>(std::forward<_Rg>(__rg), __a))
+   { }
+#endif
+
   /**
*  Returns true if the %queue is empty.
*/
@@ -301,6 +326,18 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 #endif
 #endif
 
+#if __glibcxx_ranges_to_container // C++ >= 23
+  template<__detail::__container_compatible_range<_Tp> _Rg>
+   void
+   push_range(_Rg&& __rg)
+   {
+ if constexpr (requires { c.append_range(std::forward<_Rg>(__rg)); })
+   c.append_range(std::forward<_Rg>(__rg));
+ else
+   ranges::copy(__rg, std::back_inserter(c));
+   }
+#endif
+
   /**
*  @brief  Removes first element.
*
@@ -359,6 +396,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 queue(_InputIterator, _InputIterator, _Allocator)
 -> queue<_ValT, deque<_ValT, _Allocator>>;
 #endif
+
+#if __glibcxx_ranges_to_container // C++ >= 23
+  template
+queue(from_range_t, _Rg&&) -> queue>;
+
+  template
+queue(from_range_t, _Rg&&, _Alloc)
+-> queue,
+deque, _Alloc>>;
+#endif
 #endif
 
   /**
@@ -719,6 +766,32 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
}
 #endif
 
+#if __glibcxx_ranges_to_container // C++ >= 23
+  /**
+   * @brief Construct a priority_queue from a range.
+   * @since C++23
+   *
+   * @{
+   */
+  template<__detail::__container_compatible_range<_Tp> _Rg>
+   priority_queue(from_range_t, _Rg&& __rg,
+  const _Compare& __x = _Compare())
+   : c(ranges::to<_Sequence>(std::forward<_Rg>(__rg))), comp(__x)
+   { std::make_heap(c.begin(), c.end(), comp); }
+
+  template<__detail::__container_compatible_range<_Tp> _Rg, typ

[gcc r15-8033] Fixup DECL_NOT_GIMPLE_REG_P description

2025-03-13 Thread Richard Biener via Gcc-cvs
https://gcc.gnu.org/g:45ece0357d74cae47510af0f79070fe42a3fdd02

commit r15-8033-g45ece0357d74cae47510af0f79070fe42a3fdd02
Author: Richard Biener 
Date:   Thu Mar 13 15:11:08 2025 +0100

Fixup DECL_NOT_GIMPLE_REG_P description

When I changed DECL_GIMPLE_REG_P over to DECL_NOT_GIMPLE_REG_P I
failed to update its description.

* tree.h (DECL_NOT_GIMPLE_REG_P): Update description.

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

diff --git a/gcc/tree.h b/gcc/tree.h
index 21f3cd5525c2..6f45359f103d 100644
--- a/gcc/tree.h
+++ b/gcc/tree.h
@@ -2999,12 +2999,11 @@ extern tree vector_element_bits_tree (const_tree);
   (DECL_P (DECL)   \
&& (lookup_attribute ("persistent", DECL_ATTRIBUTES (DECL)) != NULL_TREE))
 
-/* For function local variables of COMPLEX and VECTOR types,
-   indicates that the variable is not aliased, and that all
-   modifications to the variable have been adjusted so that
-   they are killing assignments.  Thus the variable may now
-   be treated as a GIMPLE register, and use real instead of
-   virtual ops in SSA form.  */
+/* For function local variables indicates that the variable
+   should not be treated as a GIMPLE register.  In particular
+   this means that partial definitions can appear and the
+   variable cannot be written into SSA form and instead uses
+   virtual operands to represent the use-def dataflow.  */
 #define DECL_NOT_GIMPLE_REG_P(DECL) \
   DECL_COMMON_CHECK (DECL)->decl_common.not_gimple_reg_flag


[gcc r15-8034] Honor prefix and suffix when installing cobol binaries and man page.

2025-03-13 Thread Matthias Klose via Gcc-cvs
https://gcc.gnu.org/g:c5e7cfc1d3dcfdbf9df871e16e9a6a447a32f271

commit r15-8034-gc5e7cfc1d3dcfdbf9df871e16e9a6a447a32f271
Author: Matthias Klose 
Date:   Thu Mar 13 15:38:53 2025 +0100

Honor prefix and suffix when installing cobol binaries and man page.

2025-03-13  Matthias Klose  

gcc/cobol/
* Make-lang.in (cobol.install-common, cobol.install-man): Honor
GCOBOL_INSTALL_NAME.

Diff:
---
 gcc/cobol/Make-lang.in | 14 --
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/gcc/cobol/Make-lang.in b/gcc/cobol/Make-lang.in
index 9fa3b1cdfdb3..650b695e7ef5 100644
--- a/gcc/cobol/Make-lang.in
+++ b/gcc/cobol/Make-lang.in
@@ -34,8 +34,10 @@
 # - the compiler proper (eg: cc1plus)
 # - define the names for selecting the language in LANGUAGES.
 
-gcobol_INSTALL_NAME := $(shell echo gcobol|sed '$(program_transform_name)')
-gcobol_TARGET_INSTALL_NAME := $(target_noncanonical)-$(shell echo gcobol|sed 
'$(program_transform_name)')
+GCOBOL_INSTALL_NAME := $(shell echo gcobol|sed '$(program_transform_name)')
+GCOBOL_TARGET_INSTALL_NAME := $(target_noncanonical)-$(shell echo gcobol|sed 
'$(program_transform_name)')
+
+GCOBC_INSTALL_NAME := $(shell echo gcobc|sed '$(program_transform_name)')
 
 cobol: cobol1$(exeext)
 cobol.serial = cobol1$(exeext)
@@ -280,14 +282,14 @@ cobol.start.encap: gcobol$(exeext)
 cobol.rest.encap:
 
 cobol.install-common: installdirs
-   $(INSTALL_PROGRAM) gcobol$(exeext)  $(DESTDIR)$(bindir)/
+   $(INSTALL_PROGRAM) gcobol$(exeext)  
$(DESTDIR)$(bindir)/$(GCOBOL_INSTALL_NAME)$(exeext)
$(INSTALL_PROGRAM) cobol1$(exeext)  $(DESTDIR)$(libexecsubdir)/
-   $(INSTALL) -m 755 $(srcdir)/cobol/gcobc $(DESTDIR)$(bindir)/
+   $(INSTALL) -m 755 $(srcdir)/cobol/gcobc 
$(DESTDIR)$(bindir)/$(GCOBC_INSTALL_NAME)$(exeext)
mkdir -p $(DESTDIR)$(datadir)/gcobol/udf
$(INSTALL_DATA) $(srcdir)/cobol/udf/*   $(DESTDIR)$(datadir)/gcobol/udf/
 
 cobol.install-man: installdirs
-   $(INSTALL_DATA) $(srcdir)/cobol/gcobol.1 $(DESTDIR)$(man1dir)/
+   $(INSTALL_DATA) $(srcdir)/cobol/gcobol.1 
$(DESTDIR)$(man1dir)/$(GCOBOL_INSTALL_NAME)$(man1ext)
$(INSTALL_DATA) $(srcdir)/cobol/gcobol.3 $(DESTDIR)$(man3dir)/
 
 cobol.install-info:
@@ -332,7 +334,7 @@ gcobol-io.html: $(srcdir)/cobol/gcobol.3
 # "make uninstall" is not expected to work.  It's not clear how to name
 # the installed location of the cobol1 compiler.
 cobol.uninstall:
-   rm -rf  $(DESTDIR)$(bindir)/$(gcobol_INSTALL_NAME)$(exeext) \
+   rm -rf  $(DESTDIR)$(bindir)/$(GCOBOL_INSTALL_NAME)$(exeext) \
$(DESTDIR)$(bindir)/gcobc   \
$(DESTDIR)$(datadir)/gcobol/\
$(DESTDIR)$(man1dir)/gcobol.1   \


[gcc r15-8035] libstdc++: Implement for C++26 (P3370R1)

2025-03-13 Thread Jonathan Wakely via Gcc-cvs
https://gcc.gnu.org/g:7ee31bc92768152e4c900591a051ba48cdd847ae

commit r15-8035-g7ee31bc92768152e4c900591a051ba48cdd847ae
Author: Jonathan Wakely 
Date:   Thu Mar 13 13:34:55 2025 +

libstdc++: Implement  for C++26 (P3370R1)

This is the first part of the P3370R1 proposal just approved by the
committee in Wrocław. This adds C++ equivalents of the functions added
to C23 by WG14 N3022.

These functions are in the global namespace, but to avoid collisions
with the same functions defined by other standard library
implementations, this change defines them in namespace __gnu_cxx and
then adds them to the global namespace.

libstdc++-v3/ChangeLog:

* include/Makefile.am: Add stdbit.h.
* include/Makefile.in: Regenerate.
* src/c++23/std.compat.cc.in: Export  functions.
* include/c_compatibility/stdbit.h: New file.
* testsuite/20_util/stdbit/1.cc: New test.
* testsuite/20_util/stdbit/2_neg.cc: New test.

Reviewed-by: Patrick Palka 

Diff:
---
 libstdc++-v3/include/Makefile.am   |   1 +
 libstdc++-v3/include/Makefile.in   |   1 +
 libstdc++-v3/include/c_compatibility/stdbit.h  | 582 +
 libstdc++-v3/src/c++23/std.compat.cc.in|  29 ++
 libstdc++-v3/testsuite/20_util/stdbit/1.cc | 320 ++
 libstdc++-v3/testsuite/20_util/stdbit/2_neg.cc |  45 ++
 6 files changed, 978 insertions(+)

diff --git a/libstdc++-v3/include/Makefile.am b/libstdc++-v3/include/Makefile.am
index de25aadd219d..a8ff87fb600e 100644
--- a/libstdc++-v3/include/Makefile.am
+++ b/libstdc++-v3/include/Makefile.am
@@ -911,6 +911,7 @@ c_compatibility_headers = \
${c_compatibility_srcdir}/tgmath.h \
${c_compatibility_srcdir}/math.h \
${c_compatibility_srcdir}/stdatomic.h \
+   ${c_compatibility_srcdir}/stdbit.h \
${c_compatibility_srcdir}/stdlib.h
 endif
 
diff --git a/libstdc++-v3/include/Makefile.in b/libstdc++-v3/include/Makefile.in
index 5a20dfb69b0e..859cbee53d68 100644
--- a/libstdc++-v3/include/Makefile.in
+++ b/libstdc++-v3/include/Makefile.in
@@ -1248,6 +1248,7 @@ c_compatibility_builddir = .
 @GLIBCXX_C_HEADERS_C_GLOBAL_TRUE@  ${c_compatibility_srcdir}/tgmath.h \
 @GLIBCXX_C_HEADERS_C_GLOBAL_TRUE@  ${c_compatibility_srcdir}/math.h \
 @GLIBCXX_C_HEADERS_C_GLOBAL_TRUE@  ${c_compatibility_srcdir}/stdatomic.h \
+@GLIBCXX_C_HEADERS_C_GLOBAL_TRUE@  ${c_compatibility_srcdir}/stdbit.h \
 @GLIBCXX_C_HEADERS_C_GLOBAL_TRUE@  ${c_compatibility_srcdir}/stdlib.h
 
 @GLIBCXX_C_HEADERS_C_STD_TRUE@c_compatibility_headers = 
diff --git a/libstdc++-v3/include/c_compatibility/stdbit.h 
b/libstdc++-v3/include/c_compatibility/stdbit.h
new file mode 100644
index ..1fb691e36c18
--- /dev/null
+++ b/libstdc++-v3/include/c_compatibility/stdbit.h
@@ -0,0 +1,582 @@
+// C compatibility header  -*- C++ -*-
+
+// Copyright The GNU Toolchain Authors.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// Under Section 7 of GPL version 3, you are granted additional
+// permissions described in the GCC Runtime Library Exception, version
+// 3.1, as published by the Free Software Foundation.
+
+// You should have received a copy of the GNU General Public License and
+// a copy of the GCC Runtime Library Exception along with this program;
+// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+// .
+
+/** @file include/stdbit.h
+ *  This is a Standard C++ Library header.
+ */
+
+#ifndef _GLIBCXX_STDBIT_H
+#define _GLIBCXX_STDBIT_H
+
+#if __cplusplus > 202302L
+#include 
+
+#define __STDC_VERSION_STDBIT_H__ 202311L
+
+#define __STDC_ENDIAN_BIG__ __ORDER_BIG_ENDIAN__
+#define __STDC_ENDIAN_LITTLE__  __ORDER_LITTLE_ENDIAN__
+#define __STDC_ENDIAN_NATIVE__  __BYTE_ORDER__
+
+#ifndef _GLIBCXX_DOXYGEN
+// We define these in our own namespace, but let Doxygen think otherwise.
+namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
+{
+#endif
+
+/** Count the number of leading zero bits
+ *
+ * @param  __value An unsigned integer.
+ * @since C++26
+ * @{
+ */
+template
+inline unsigned int
+stdc_leading_zeros(_Tp __value)
+{
+  static_assert(std::__unsigned_integer<_Tp>);
+  return std::countl_zero(__value);
+}
+
+inline unsigned int
+stdc_leading_zeros_uc(unsigned char __value)
+{ return stdc_leading_zeros(__value); }
+
+inline unsigned int
+stdc_leading_zeros_us(unsigned short __value)
+

[gcc r15-8036] libstdc++: Implement for C++26 (P3370R1)

2025-03-13 Thread Jonathan Wakely via Gcc-cvs
https://gcc.gnu.org/g:d4c7de7dc925e79f7aec06848be9d05eb71bd6c8

commit r15-8036-gd4c7de7dc925e79f7aec06848be9d05eb71bd6c8
Author: Jonathan Wakely 
Date:   Thu Mar 13 14:10:00 2025 +

libstdc++: Implement  for C++26 (P3370R1)

This is the second part of the P3370R1 proposal just approved by the
committee in Wrocław. This adds C++ equivalents of the functions added
to C23 by WG14 N2683.

These functions are in the global namespace, but to avoid collisions
with the same functions defined by other standard library
implementations, this change defines them in namespace __gnu_cxx and
then adds them to the global namespace.

libstdc++-v3/ChangeLog:

* include/Makefile.am: Add stdckdint.h.
* include/Makefile.in: Regenerate.
* src/c++23/std.compat.cc.in: Export  functions.
* include/c_compatibility/stdckdint.h: New file.
* testsuite/26_numerics/stdckdint/1.cc: New test.
* testsuite/26_numerics/stdckdint/2_neg.cc: New test.

Reviewed-by: Patrick Palka 

Diff:
---
 libstdc++-v3/include/Makefile.am   |   1 +
 libstdc++-v3/include/Makefile.in   |   1 +
 libstdc++-v3/include/c_compatibility/stdckdint.h   | 113 +
 libstdc++-v3/src/c++23/std.compat.cc.in|   8 ++
 libstdc++-v3/testsuite/26_numerics/stdckdint/1.cc  |  63 
 .../testsuite/26_numerics/stdckdint/2_neg.cc   |  39 +++
 6 files changed, 225 insertions(+)

diff --git a/libstdc++-v3/include/Makefile.am b/libstdc++-v3/include/Makefile.am
index a8ff87fb600e..4dc771a540c4 100644
--- a/libstdc++-v3/include/Makefile.am
+++ b/libstdc++-v3/include/Makefile.am
@@ -912,6 +912,7 @@ c_compatibility_headers = \
${c_compatibility_srcdir}/math.h \
${c_compatibility_srcdir}/stdatomic.h \
${c_compatibility_srcdir}/stdbit.h \
+   ${c_compatibility_srcdir}/stdckdint.h \
${c_compatibility_srcdir}/stdlib.h
 endif
 
diff --git a/libstdc++-v3/include/Makefile.in b/libstdc++-v3/include/Makefile.in
index 859cbee53d68..0e3d09b3a750 100644
--- a/libstdc++-v3/include/Makefile.in
+++ b/libstdc++-v3/include/Makefile.in
@@ -1249,6 +1249,7 @@ c_compatibility_builddir = .
 @GLIBCXX_C_HEADERS_C_GLOBAL_TRUE@  ${c_compatibility_srcdir}/math.h \
 @GLIBCXX_C_HEADERS_C_GLOBAL_TRUE@  ${c_compatibility_srcdir}/stdatomic.h \
 @GLIBCXX_C_HEADERS_C_GLOBAL_TRUE@  ${c_compatibility_srcdir}/stdbit.h \
+@GLIBCXX_C_HEADERS_C_GLOBAL_TRUE@  ${c_compatibility_srcdir}/stdckdint.h \
 @GLIBCXX_C_HEADERS_C_GLOBAL_TRUE@  ${c_compatibility_srcdir}/stdlib.h
 
 @GLIBCXX_C_HEADERS_C_STD_TRUE@c_compatibility_headers = 
diff --git a/libstdc++-v3/include/c_compatibility/stdckdint.h 
b/libstdc++-v3/include/c_compatibility/stdckdint.h
new file mode 100644
index ..1de2d18dc1aa
--- /dev/null
+++ b/libstdc++-v3/include/c_compatibility/stdckdint.h
@@ -0,0 +1,113 @@
+// C compatibility header  -*- C++ -*-
+
+// Copyright The GNU Toolchain Authors.
+//
+// This file is part of the GNU ISO C++ Library.  This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 3, or (at your option)
+// any later version.
+
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+// GNU General Public License for more details.
+
+// Under Section 7 of GPL version 3, you are granted additional
+// permissions described in the GCC Runtime Library Exception, version
+// 3.1, as published by the Free Software Foundation.
+
+// You should have received a copy of the GNU General Public License and
+// a copy of the GCC Runtime Library Exception along with this program;
+// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+// .
+
+/** @file include/stdckdint.h
+ *  This is a Standard C++ Library header.
+ */
+
+#ifndef _GLIBCXX_STDCKDINT_H
+#define _GLIBCXX_STDCKDINT_H
+
+#if __cplusplus > 202302L
+#include 
+#include 
+
+#define __STDC_VERSION_STDCKDINT_H__ 202311L
+
+#ifndef _GLIBCXX_DOXYGEN
+// We define these in our own namespace, but let Doxygen think otherwise.
+namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)
+{
+#endif
+/// @cond undocumented
+namespace __detail
+{
+  template
+concept __cv_unqual_signed_or_unsigned_integer_type
+  = std::same_as<_Tp, std::remove_cv_t<_Tp>>
+ && std::__is_standard_integer<_Tp>::value;
+}
+/// @endcond
+
+/** Checked integer arithmetic
+ *
+ * Performs arithmetic on `__a` and `__b` and stores the result in `*__result`,
+ * with overflow detection.
+ * The arithmetic is performed in infinite signed precision, without overflow,
+ * then converted to the result type, `_Tp1`. If the converted result

[gcc r15-8027] libstdc++: Allow 'configure.host' to pre-set 'EXTRA_CFLAGS', 'EXTRA_CXX_FLAGS'

2025-03-13 Thread Thomas Schwinge via Libstdc++-cvs
https://gcc.gnu.org/g:5967fe0dd1f3a49176740553cd147e99d6950895

commit r15-8027-g5967fe0dd1f3a49176740553cd147e99d6950895
Author: Thomas Schwinge 
Date:   Wed Feb 26 10:13:51 2025 +0100

libstdc++: Allow 'configure.host' to pre-set 'EXTRA_CFLAGS', 
'EXTRA_CXX_FLAGS'

In particular, 'GLIBCXX_ENABLE_CXX_FLAGS' shouldn't overwrite 
'EXTRA_CXX_FLAGS'
(and instead append any additional '--enable-cxx-flags=[...]').

libstdc++-v3/
* acinclude.m4 (GLIBCXX_ENABLE_CXX_FLAGS): Append to
'EXTRA_CXX_FLAGS' any additional flags.
* configure: Regenerate.
* configure.host: Document 'EXTRA_CFLAGS', 'EXTRA_CXX_FLAGS'.

Diff:
---
 libstdc++-v3/acinclude.m4   | 4 +++-
 libstdc++-v3/configure  | 4 +++-
 libstdc++-v3/configure.host | 4 
 3 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4
index b3423d7957ac..e668d2dba274 100644
--- a/libstdc++-v3/acinclude.m4
+++ b/libstdc++-v3/acinclude.m4
@@ -3267,9 +3267,11 @@ AC_DEFUN([GLIBCXX_ENABLE_CXX_FLAGS], [dnl
 AC_MSG_ERROR([compiler flags start with a -]) ;;
   esac
 done
+
+# Append the additional flags to any that came from 'configure.host'.
+EXTRA_CXX_FLAGS="$EXTRA_CXX_FLAGS $enable_cxx_flags"
   fi
 
-  EXTRA_CXX_FLAGS="$enable_cxx_flags"
   AC_MSG_RESULT($EXTRA_CXX_FLAGS)
   AC_SUBST(EXTRA_CXX_FLAGS)
 ])
diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure
index e115ee55739f..78758285f211 100755
--- a/libstdc++-v3/configure
+++ b/libstdc++-v3/configure
@@ -19450,9 +19450,11 @@ fi
 as_fn_error $? "compiler flags start with a -" "$LINENO" 5 ;;
   esac
 done
+
+# Append the additional flags to any that came from 'configure.host'.
+EXTRA_CXX_FLAGS="$EXTRA_CXX_FLAGS $enable_cxx_flags"
   fi
 
-  EXTRA_CXX_FLAGS="$enable_cxx_flags"
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: $EXTRA_CXX_FLAGS" >&5
 $as_echo "$EXTRA_CXX_FLAGS" >&6; }
 
diff --git a/libstdc++-v3/configure.host b/libstdc++-v3/configure.host
index 7bc430716168..933a43f241c3 100644
--- a/libstdc++-v3/configure.host
+++ b/libstdc++-v3/configure.host
@@ -61,6 +61,10 @@
 #
 # It possibly modifies the following variables:
 #
+#   EXTRA_CFLAGS   extra flags to pass when compiling C code
+#
+#   EXTRA_CXX_FLAGSextra flags to pass when compiling C++ code
+#
 #   OPT_LDFLAGSextra flags to pass when linking the library, of
 #  the form '-Wl,blah'
 #  (defaults to empty in acinclude.m4)


[gcc r15-8024] testsuite: Remove sve/pre_cond_share_1.c [PR115248]

2025-03-13 Thread Richard Sandiford via Gcc-cvs
https://gcc.gnu.org/g:a68e32b8e4b4c03c81e3a4b7560d52fef2d16088

commit r15-8024-ga68e32b8e4b4c03c81e3a4b7560d52fef2d16088
Author: Richard Sandiford 
Date:   Thu Mar 13 12:03:04 2025 +

testsuite: Remove sve/pre_cond_share_1.c [PR115248]

gcc.target/aarch64/sve/pre_cond_share_1.c started failing after
r15-276-gbed6ec161be8c5ca.  However, that was incidental.
The test's inner loop is duplicated by -fswitch-loops and
that patch happened to change the copy of the loop that was
not the original focus of the test.

The test was added as part of r14-4713-g4b39aeef594f311e (patch A).
Before patch A we had:

  mask__109.48_201 = vect_distbb_170.43_191 < vect_cst__200;
  _263 = .COND_MUL (mask__109.48_201, vect_iftmp.45_195, vect_cst__198, { 
0.0, ... });
  vect_prephitmp_153.50_205 = .VCOND (vect_distbb_170.43_191, { 0.0, ... }, 
_263, vect_cst__198, 112);

which, expanding the .VCOND, is equivalent to:

  mask__102.46_197 = vect_distbb_170.43_191 >= { 0.0, ... };
  mask__109.48_201 = vect_distbb_170.43_191 < vect_cst__200;
  _263 = .COND_MUL (mask__109.48_201, vect_iftmp.45_195, vect_cst__198, { 
0.0, ... });
  vect_prephitmp_153.50_205 = mask__102.46_197 ? _263 : vect_cst__198

After patch A we had:

  mask__102.46_197 = vect_distbb_170.43_191 >= { 0.0, ... };
  mask__109.48_201 = vect_distbb_170.43_191 < vect_cst__200;
  _70 = mask__102.46_197 & mask__109.48_201;
  vect_prephitmp_153.50_205 = .COND_MUL (_70, vect_iftmp.45_195, 
vect_cst__198, { 0.0, ... });

But this changes the behaviour when vect_distbb_170.43_191 < { 0.0, ... }.
In that case, the original code would pick an else value of vect_cst__198,
whereas the new code would pick an else value of { 0.0, ... }.

That was fixed in r14-8668-g8123f3ca3fd89103 (PR113607, patch B),
but fixing the bug (rightly) reverted the code to the previous output.
Patch B therefore XFAILed the thing that patch A was originally testing.

Since the test was added for patch A and since patch A seems to generate
incorrect code for the test, I think we should just remove it.

gcc/testsuite/
PR testsuite/115248
* gcc.target/aarch64/sve/pre_cond_share_1.c: Delete

Diff:
---
 .../gcc.target/aarch64/sve/pre_cond_share_1.c  | 132 -
 1 file changed, 132 deletions(-)

diff --git a/gcc/testsuite/gcc.target/aarch64/sve/pre_cond_share_1.c 
b/gcc/testsuite/gcc.target/aarch64/sve/pre_cond_share_1.c
deleted file mode 100644
index e4f754d739c7..
--- a/gcc/testsuite/gcc.target/aarch64/sve/pre_cond_share_1.c
+++ /dev/null
@@ -1,132 +0,0 @@
-/* { dg-do compile } */
-/* { dg-options "-Ofast -fdump-tree-optimized" } */
-
-#include 
-#include 
-#include 
-#include 
-
-typedef struct __attribute__((__packed__)) _Atom {
-float x, y, z;
-int32_t type;
-} Atom;
-
-typedef struct __attribute__((__packed__)) _FFParams {
-int32_t hbtype;
-float radius;
-float hphb;
-float elsc;
-} FFParams;
-
-#ifndef PPWI
-#define PPWI (64)
-#endif
-
-#ifndef ITERS
-#define ITERS 8
-#endif
-
-#define DIFF_TOLERANCE_PCT 0.025f
-
-#define POSES_SIZE 393216
-#define PROTEIN_SIZE 938
-#define LIGAND_SIZE 26
-#define FORCEFIELD_SIZE 34
-
-#define ZERO 0.0f
-#define QUARTER 0.25f
-#define HALF 0.5f
-#define ONE 1.0f
-#define TWO 2.0f
-#define FOUR 4.0f
-#define CNSTNT 45.0f
-
-// Energy evaluation parameters
-#define HBTYPE_F 70
-#define HBTYPE_E 69
-#define HARDNESS 38.0f
-#define NPNPDIST 5.5f
-#define NPPDIST 1.0f
-
-void
-fasten_main(size_t group, size_t ntypes, size_t nposes, size_t natlig, size_t 
natpro,//
-const Atom *protein, const Atom *ligand,   
  //
-const float *transforms_0, const float *transforms_1, const float 
*transforms_2, //
-const float *transforms_3, const float *transforms_4, const float 
*transforms_5, //
-const FFParams *forcefield, float *energies
  //
-) {
-
-float etot[PPWI];
-float lpos_x[PPWI];
-
-for (int l = 0; l < PPWI; l++) {
-etot[l] = 0.f;
-lpos_x[l] = 0.f;
-}
-
-// Loop over ligand atoms
-for (int il = 0; il < natlig; il++) {
-// Load ligand atom data
-const Atom l_atom = ligand[il];
-const FFParams l_params = forcefield[l_atom.type];
-const int lhphb_ltz = l_params.hphb < 0.f;
-const int lhphb_gtz = l_params.hphb > 0.f;
-
-// Transform ligand atom
-
-// Loop over protein atoms
-for (int ip = 0; ip < natpro; ip++) {
-// Load protein atom data
-const Atom p_atom = protein[ip];
-const FFParams p_params = forcefield[p_atom.type];
-
-const float radij = p_params.radius + l_params.radius;
-const float r_radij = ONE / radij;
-
-const float elcdst = 

[gcc r15-8037] testsuite: Fix sve/mask_struct_load_3_run.c [PR113965]

2025-03-13 Thread Richard Sandiford via Gcc-cvs
https://gcc.gnu.org/g:df87b300bd13ed047b1159022c93445f130458e6

commit r15-8037-gdf87b300bd13ed047b1159022c93445f130458e6
Author: Richard Sandiford 
Date:   Thu Mar 13 15:13:00 2025 +

testsuite: Fix sve/mask_struct_load_3_run.c [PR113965]

Among other things, this testcase tests an addition of the four
values (n*4+[0:3])*9//2 for each n in [0:99].  The addition is
done in multiple integer and floating-point types and the test
is compiled with -ffast-math.

One of the floating-point types is _Float16, and as Andrew says
in the PR, _Float16's limited precision means that the order of the
additions begins to matter for higher n.  Specifically, some orders
begin to give different results from others at n=38, and at many
higher n as well.

This patch uses 5/3 rather than 9/2.  I tested locally that
all addition orders give the same result over the test range.

gcc/testsuite/
PR testsuite/113965
* gcc.target/aarch64/sve/mask_struct_load_3_run.c: Use an
input range that is suitable for _Float16.

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

diff --git a/gcc/testsuite/gcc.target/aarch64/sve/mask_struct_load_3_run.c 
b/gcc/testsuite/gcc.target/aarch64/sve/mask_struct_load_3_run.c
index 8bc3b08fcf4d..c0a7416cfafc 100644
--- a/gcc/testsuite/gcc.target/aarch64/sve/mask_struct_load_3_run.c
+++ b/gcc/testsuite/gcc.target/aarch64/sve/mask_struct_load_3_run.c
@@ -18,7 +18,7 @@
asm volatile ("" ::: "memory"); \
   }\
 for (int i = 0; i < N * 4; ++i)\
-  in[i] = i * 9 / 2;   \
+  in[i] = i * 5 / 3;   \
 NAME##_4 (out, in, mask, N);   \
 for (int i = 0; i < N; ++i)\
   {\


[gcc r15-7986] aarch64: Make latency account for synthetic VEC_PERM_EXPRs [PR116901]

2025-03-13 Thread Richard Sandiford via Gcc-cvs
https://gcc.gnu.org/g:e406994e31262b45d0daf0b9e9218fc49bd233e2

commit r15-7986-ge406994e31262b45d0daf0b9e9218fc49bd233e2
Author: Richard Sandiford 
Date:   Wed Mar 12 09:40:11 2025 +

aarch64: Make latency account for synthetic VEC_PERM_EXPRs [PR116901]

Another problem in pr110625_[24].c was that the latency calculations
were ignoring VEC_PERM_EXPRs that had no associated stmt_vec_info.
Such VEC_PERM_EXPRs are common and expected for SLP these days.

After this change, the number of general ops in the testcases seems
to be accurate apart from one remaining detail: we assume that the
extension in a permuted extending load is free, even though the
extension happens after the permutation.  Fixing that would require
more information from the vectoriser and so isn't GCC 15 material.
It also should cease to be a problem if we do end up moving the
permutation to its own node, rather than keeping it as part of
the load.

gcc/
PR target/116901
* config/aarch64/aarch64.cc (aarch64_vector_costs::count_ops): Allow
stmt_info to be null.
(aarch64_vector_costs::add_stmt_cost): Call count_ops even if
stmt_info is null.

Diff:
---
 gcc/config/aarch64/aarch64.cc | 47 ++-
 1 file changed, 28 insertions(+), 19 deletions(-)

diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc
index 41054b54b383..25963c9b300f 100644
--- a/gcc/config/aarch64/aarch64.cc
+++ b/gcc/config/aarch64/aarch64.cc
@@ -17498,7 +17498,8 @@ aarch64_vector_costs::count_ops (unsigned int count, 
vect_cost_for_stmt kind,
 
   /* Calculate the minimum cycles per iteration imposed by a reduction
  operation.  */
-  if ((kind == scalar_stmt || kind == vector_stmt || kind == vec_to_scalar)
+  if (stmt_info
+  && (kind == scalar_stmt || kind == vector_stmt || kind == vec_to_scalar)
   && vect_is_reduction (stmt_info))
 {
   unsigned int base
@@ -17534,7 +17535,8 @@ aarch64_vector_costs::count_ops (unsigned int count, 
vect_cost_for_stmt kind,
  costing when we see a vec_to_scalar on a stmt with VMAT_GATHER_SCATTER we
  are dealing with an emulated instruction and should adjust costing
  properly.  */
-  if (kind == vec_to_scalar
+  if (stmt_info
+  && kind == vec_to_scalar
   && (m_vec_flags & VEC_ADVSIMD)
   && vect_mem_access_type (stmt_info, node) == VMAT_GATHER_SCATTER)
 {
@@ -17590,7 +17592,8 @@ aarch64_vector_costs::count_ops (unsigned int count, 
vect_cost_for_stmt kind,
 case vector_load:
 case unaligned_load:
   ops->loads += count;
-  if (m_vec_flags || FLOAT_TYPE_P (aarch64_dr_type (stmt_info)))
+  if (m_vec_flags
+ || (stmt_info && FLOAT_TYPE_P (aarch64_dr_type (stmt_info
ops->general_ops += base_issue->fp_simd_load_general_ops * count;
   break;
 
@@ -17598,24 +17601,29 @@ aarch64_vector_costs::count_ops (unsigned int count, 
vect_cost_for_stmt kind,
 case unaligned_store:
 case scalar_store:
   ops->stores += count;
-  if (m_vec_flags || FLOAT_TYPE_P (aarch64_dr_type (stmt_info)))
+  if (m_vec_flags
+ || (stmt_info && FLOAT_TYPE_P (aarch64_dr_type (stmt_info
ops->general_ops += base_issue->fp_simd_store_general_ops * count;
   break;
 }
 
   /* Add any embedded comparison operations.  */
-  if ((kind == scalar_stmt || kind == vector_stmt || kind == vec_to_scalar)
+  if (stmt_info
+  && (kind == scalar_stmt || kind == vector_stmt || kind == vec_to_scalar)
   && vect_embedded_comparison_type (stmt_info))
 ops->general_ops += count;
 
   /* COND_REDUCTIONS need two sets of VEC_COND_EXPRs, whereas so far we
  have only accounted for one.  */
-  if ((kind == vector_stmt || kind == vec_to_scalar)
+  if (stmt_info
+  && (kind == vector_stmt || kind == vec_to_scalar)
   && vect_reduc_type (m_vinfo, stmt_info) == COND_REDUCTION)
 ops->general_ops += count;
 
   /* Count the predicate operations needed by an SVE comparison.  */
-  if (sve_issue && (kind == vector_stmt || kind == vec_to_scalar))
+  if (stmt_info
+  && sve_issue
+  && (kind == vector_stmt || kind == vec_to_scalar))
 if (tree type = vect_comparison_type (stmt_info))
   {
unsigned int base = (FLOAT_TYPE_P (type)
@@ -17625,7 +17633,7 @@ aarch64_vector_costs::count_ops (unsigned int count, 
vect_cost_for_stmt kind,
   }
 
   /* Add any extra overhead associated with LD[234] and ST[234] operations.  */
-  if (simd_issue)
+  if (stmt_info && simd_issue)
 switch (aarch64_ld234_st234_vectors (kind, stmt_info, node))
   {
   case 2:
@@ -17642,7 +17650,8 @@ aarch64_vector_costs::count_ops (unsigned int count, 
vect_cost_for_stmt kind,
   }
 
   /* Add any overhead associated with gather loads and scatter stores.  */
-  if (sve_issue
+  if (stmt_info
+  && sve_issue
   && (kind == scalar_load || kind ==

[gcc r15-8041] Fix speculation_useful_p

2025-03-13 Thread Jan Hubicka via Gcc-cvs
https://gcc.gnu.org/g:57dbbdd8e34b80926e06b352b6c442c555b303ed

commit r15-8041-g57dbbdd8e34b80926e06b352b6c442c555b303ed
Author: Jan Hubicka 
Date:   Thu Mar 13 20:11:02 2025 +0100

Fix speculation_useful_p

This patch fixes issue with speculation and x264.  With profile feedback
we first introduce speculative calls to mc_chroma which is called 
indirectly.
Then we propagate constants acorss these calls (which is useful transform) 
but
then speculation_useful_p decides that these speculations are not useful and
we end up calling unspecialized version.

This patch updates speculation_useful_p to consider edges redirected earlier
to clones as useful, since we can expect that ipa-cp knows what it is doing
(originally it only looked for inlined calls).  I also noticed that we want
to keep edges even if they are not hot.

Finally I noticed a typo in computing target in code which intends to keep
devirtualized calls to functions where we propagated pureness/constness. 
Newly
we also track ipa-modref summaries as they also may be useful.

gcc/ChangeLog:

PR ipa/119147
* ipa-inline.cc: Include ipa-modref-tree.h and
ipa-modref.h.
(speculation_useful_p): If target is a clone, speculation is usef;
fix mixup of caller and callee; speculate also calls not considered
hot; consider modref summary also possibly useful for optimization.
* ipa-profile.cc (ipa_profile): Keep non-hot speculations.

Diff:
---
 gcc/ipa-inline.cc  | 33 -
 gcc/ipa-profile.cc |  7 ---
 2 files changed, 24 insertions(+), 16 deletions(-)

diff --git a/gcc/ipa-inline.cc b/gcc/ipa-inline.cc
index 163129540ac5..9e6e85d714be 100644
--- a/gcc/ipa-inline.cc
+++ b/gcc/ipa-inline.cc
@@ -121,6 +121,8 @@ along with GCC; see the file COPYING3.  If not see
 #include "attribs.h"
 #include "asan.h"
 #include "ipa-strub.h"
+#include "ipa-modref-tree.h"
+#include "ipa-modref.h"
 
 /* Inliner uses greedy algorithm to inline calls in a priority order.
Badness is used as the key in a Fibonacci heap which roughly corresponds
@@ -1941,23 +1943,30 @@ heap_edge_removal_hook (struct cgraph_edge *e, void 
*data)
 bool
 speculation_useful_p (struct cgraph_edge *e, bool anticipate_inlining)
 {
-  /* If we have already decided to inline the edge, it seems useful.  */
-  if (!e->inline_failed)
+  /* If we have already decided to inline the edge, it seems useful.
+ Also if ipa-cp or other pass worked hard enough to produce a clone,
+ we already decided this is a good idea.  */
+  if (!e->inline_failed
+  || e->callee->clone_of)
 return true;
 
   enum availability avail;
   struct cgraph_node *target = e->callee->ultimate_alias_target (&avail,
-e->caller);
+e->callee);
 
   gcc_assert (e->speculative && !e->indirect_unknown_callee);
 
-  if (!e->maybe_hot_p ())
+  /* Even if calll statement is not hot, we can still have useful speculation
+ in cases where a lot of time is spent is callee.
+ Do not check maybe_hot_p.  */
+  if (!e->count.nonzero_p ())
 return false;
 
   /* See if IP optimizations found something potentially useful about the
- function.  For now we look only for CONST/PURE flags.  Almost everything
- else we propagate is useless.  */
-  if (avail >= AVAIL_AVAILABLE)
+ function.  Do this only if the call seems hot since this is about
+ optimizing the code surrounding call site rahter than improving
+ callee.  */
+  if (avail >= AVAIL_AVAILABLE && e->maybe_hot_p ())
 {
   int ecf_flags = flags_from_decl_or_type (target->decl);
   if (ecf_flags & ECF_CONST)
@@ -1972,12 +1981,18 @@ speculation_useful_p (struct cgraph_edge *e, bool 
anticipate_inlining)
->ecf_flags & ECF_PURE))
return true;
 }
+  else if (get_modref_function_summary (target))
+   return true;
 }
   /* If we did not managed to inline the function nor redirect
  to an ipa-cp clone (that are seen by having local flag set),
  it is probably pointless to inline it unless hardware is missing
- indirect call predictor.  */
-  if (!anticipate_inlining && !target->local)
+ indirect call predictor.
+
+ At this point we know we will not dispatch into faster version of
+ callee, so if call itself is not hot, we definitely can give up
+ speculating.  */
+  if (!anticipate_inlining && (!target->local || !e->maybe_hot_p ()))
 return false;
   /* For overwritable targets there is not much to do.  */
   if (!can_inline_edge_p (e, false)
diff --git a/gcc/ipa-profile.cc b/gcc/ipa-profile.cc
index 51616def254f..08638667f65c 100644
--- a/gcc/ipa-profile.cc
+++ b/gcc/ipa-profile.cc
@@ -882,13 +882,6 @@ ipa_profile (void)
 "Not 

[gcc(refs/users/mikael/heads/refactor_descriptor_v01)] Correction régression allocate_with_source_16.f90

2025-03-13 Thread Mikael Morin via Gcc-cvs
https://gcc.gnu.org/g:b33b93e06ab1f1f2f0da259b1e4383da7284fda4

commit b33b93e06ab1f1f2f0da259b1e4383da7284fda4
Author: Mikael Morin 
Date:   Thu Mar 13 21:46:02 2025 +0100

Correction régression allocate_with_source_16.f90

Diff:
---
 gcc/fortran/trans-types.cc | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/gcc/fortran/trans-types.cc b/gcc/fortran/trans-types.cc
index 7e4859bb434a..2ba3455ab6a0 100644
--- a/gcc/fortran/trans-types.cc
+++ b/gcc/fortran/trans-types.cc
@@ -2967,7 +2967,10 @@ gfc_get_derived_type (gfc_symbol * derived, int codimen)
   if (canonical_sym == derived)
self_is_canonical = true;
   else if (canonical_sym != nullptr)
-   class_canonical = gfc_get_derived_type (canonical_sym, codimen);
+   {
+ tree canonical_decl = gfc_get_derived_type (canonical_sym, codimen);
+ class_canonical = TYPE_CANONICAL (canonical_decl);
+   }
 }
 
   /* The derived types from an earlier namespace can be used as the


[gcc(refs/users/mikael/heads/refactor_descriptor_v01)] Correction régression class_optional_2.f90

2025-03-13 Thread Mikael Morin via Gcc-cvs
https://gcc.gnu.org/g:64df282fedfc7321bfa3ea2772604395fc828e73

commit 64df282fedfc7321bfa3ea2772604395fc828e73
Author: Mikael Morin 
Date:   Thu Mar 13 21:25:04 2025 +0100

Correction régression class_optional_2.f90

Diff:
---
 gcc/fortran/trans-types.cc | 63 +++---
 1 file changed, 32 insertions(+), 31 deletions(-)

diff --git a/gcc/fortran/trans-types.cc b/gcc/fortran/trans-types.cc
index ff43cb1522a0..7e4859bb434a 100644
--- a/gcc/fortran/trans-types.cc
+++ b/gcc/fortran/trans-types.cc
@@ -2825,8 +2825,11 @@ cobounds_match_decl (const gfc_symbol *derived)
 
 
 gfc_symbol *
-get_class_canonical_type (gfc_symbol *derived, int rank, int corank)
+get_class_canonical_type (gfc_symbol *derived, gfc_array_spec *as)
 {
+
+  int rank = as ? as->rank : 0;
+  int corank = as ? as->corank : 0;
   const char *class_name = gfc_class_name (derived, rank, corank, 0, 0);
 
   gfc_namespace *ns = gfc_class_namespace (derived);
@@ -2835,7 +2838,13 @@ get_class_canonical_type (gfc_symbol *derived, int rank, 
int corank)
   gfc_find_symbol (class_name, ns, 0, &canonical_class);
 
   if (canonical_class != nullptr)
-return canonical_class;
+{
+  gfc_array_spec *found_as = canonical_class->components->as;
+  if (gfc_compare_array_spec (as, found_as))
+   return canonical_class;
+  else
+   return nullptr;
+}
 
   gfc_typespec ts;
   memset (&ts, 0, sizeof (ts));
@@ -2848,21 +2857,9 @@ get_class_canonical_type (gfc_symbol *derived, int rank, 
int corank)
   attr.dimension = rank != 0;
   attr.codimension = corank != 0;
 
-  gfc_array_spec *as;
-  if (rank != 0 || corank != 0)
-{
-  as = gfc_get_array_spec ();
-  if (rank == -1)
-   as->type = AS_ASSUMED_RANK;
-  else
-   as->type = AS_DEFERRED;
-  as->rank = rank;
-  as->corank = corank;
-}
-  else
-as = nullptr;
+  gfc_array_spec *tmp_as = gfc_copy_array_spec (as);
 
-  gfc_build_class_symbol (&ts, &attr, &as);
+  gfc_build_class_symbol (&ts, &attr, &tmp_as);
 
   gfc_find_symbol (class_name, ns, 0, &canonical_class);
   if (canonical_class)
@@ -2884,10 +2881,8 @@ get_class_canonical_type (gfc_symbol *cls)
   gfc_component * data_comp = cls->components;
 
   gfc_symbol *derived = data_comp->ts.u.derived;
-  int rank = data_comp->as ? data_comp->as->rank : 0;
-  int corank = data_comp->as ? data_comp->as->corank : 0;
 
-  return get_class_canonical_type (derived, rank, corank);
+  return get_class_canonical_type (derived, data_comp->as);
 }
 
 
@@ -2900,9 +2895,10 @@ tree
 gfc_get_derived_type (gfc_symbol * derived, int codimen)
 {
   tree typenode = NULL, field = NULL, field_type = NULL;
-  tree canonical = NULL_TREE;
+  tree canonical = NULL_TREE, class_canonical = NULL_TREE;
   tree *chain = NULL;
   bool got_canonical = false;
+  bool self_is_canonical = false;
   bool unlimited_entity = false;
   gfc_component *c;
   gfc_namespace *ns;
@@ -2965,6 +2961,15 @@ gfc_get_derived_type (gfc_symbol * derived, int codimen)
   && gfc_get_module_backend_decl (derived))
 goto copy_derived_types;
 
+  if (derived->attr.is_class)
+{
+  gfc_symbol * canonical_sym = get_class_canonical_type (derived);
+  if (canonical_sym == derived)
+   self_is_canonical = true;
+  else if (canonical_sym != nullptr)
+   class_canonical = gfc_get_derived_type (canonical_sym, codimen);
+}
+
   /* The derived types from an earlier namespace can be used as the
  canonical type.  */
   if (derived->backend_decl == NULL
@@ -3001,6 +3006,8 @@ gfc_get_derived_type (gfc_symbol * derived, int codimen)
 
   derived->backend_decl = NULL_TREE;
 }
+  else if (class_canonical)
+canonical = class_canonical;
 
   /* derived->backend_decl != 0 means we saw it before, but its
  components' backend_decl may have not been built.  */
@@ -3228,24 +3235,18 @@ gfc_get_derived_type (gfc_symbol * derived, int codimen)
   /* Now lay out the derived type, including the fields.  */
   if (canonical)
 TYPE_CANONICAL (typenode) = canonical;
-  else if (derived->attr.is_class)
+  else if (self_is_canonical)
+TYPE_CANONICAL (typenode) = typenode;
+
+  if (derived->attr.is_class)
 {
-  gfc_symbol * canonical_sym = get_class_canonical_type (derived);
-  if (canonical_sym != nullptr)
-   {
- tree canonical_sym_decl = gfc_get_derived_type (canonical_sym, 
codimen);
- TYPE_CANONICAL (typenode) = TYPE_CANONICAL (canonical_sym_decl);
-   }
   gfc_component * data_comp = derived->components;
   gfc_symbol *orig_type = data_comp->ts.u.derived;
   if (orig_type->attr.extension)
{
- int rank = data_comp->as ? data_comp->as->rank : 0;
- int corank = data_comp->as ? data_comp->as->corank : 0;
-
  gfc_symbol * parent_type = orig_type->components->ts.u.derived;
  gfc_symbol * parent_wrapper = get_class_canonical_type (parent_type, 
-   

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

2025-03-13 Thread Jakub Jelinek via Libstdc++-cvs
https://gcc.gnu.org/g:4fe62f20633b8e1bf4d776d7f4644ce485efd0b2

commit 4fe62f20633b8e1bf4d776d7f4644ce485efd0b2
Merge: 504a13588c39 6888a4bb584a
Author: Jakub Jelinek 
Date:   Thu Mar 13 13:11:01 2025 +0100

Merge commit 'r15-8028-g6888a4bb584ad3977cb1e8cdefedea70b1f135ea' into 
redhat/gcc-15-branch

Diff:

 ChangeLog  |36 +
 MAINTAINERS| 2 +
 Makefile.def   | 5 +
 Makefile.in|   527 +-
 config-ml.in   | 3 +-
 configure  |56 +
 configure.ac   |53 +
 contrib/ChangeLog  |19 +
 contrib/gcc-changelog/git_commit.py| 3 +
 contrib/gcc-git-customization.sh   |46 -
 contrib/relpath.sh | 6 +-
 gcc/ChangeLog  |   893 +
 gcc/DATESTAMP  | 2 +-
 gcc/Makefile.in| 4 +
 gcc/analyzer/region-model-manager.cc   |53 +-
 gcc/analyzer/region-model-manager.h| 4 +
 gcc/analyzer/region-model.cc   | 1 +
 gcc/analyzer/store.cc  |35 +-
 gcc/builtins.cc|21 +-
 gcc/c-family/ChangeLog |26 +
 gcc/c-family/c-attribs.cc  | 5 +-
 gcc/c-family/c-common.cc   | 3 +
 gcc/c-family/c.opt | 2 +-
 gcc/c/ChangeLog|38 +
 gcc/c/c-parser.cc  |36 +-
 gcc/c/c-typeck.cc  |73 +-
 gcc/cobol/ChangeLog|94 +
 gcc/cobol/LICENSE  |29 +
 gcc/cobol/Make-lang.in |   370 +
 gcc/cobol/cbldiag.h|   111 +
 gcc/cobol/cdf-copy.cc  |   356 +
 gcc/cobol/cdf.y|   956 +
 gcc/cobol/cdfval.h |   113 +
 gcc/cobol/cobol-system.h   |64 +
 gcc/cobol/cobol1.cc|   692 +
 gcc/cobol/config-lang.in   |38 +
 gcc/cobol/convert.cc   |78 +
 gcc/cobol/copybook.h   |   205 +
 gcc/cobol/dts.h|   109 +
 gcc/cobol/except.cc|   370 +
 gcc/cobol/exceptg.h|61 +
 gcc/cobol/gcobc|   465 +
 gcc/cobol/gcobol.1 |  1628 +
 gcc/cobol/gcobol.3 |   328 +
 gcc/cobol/gcobolspec.cc|   706 +
 gcc/cobol/genapi.cc| 16926 
 gcc/cobol/genapi.h |   587 +
 gcc/cobol/gengen.cc|  3458 ++
 gcc/cobol/gengen.h |   544 +
 gcc/cobol/genmath.cc   |  1730 +
 gcc/cobol/genmath.h|36 +
 gcc/cobol/genutil.cc   |  2642 ++
 gcc/cobol/genutil.h|   168 +
 gcc/cobol/help.gen |15 +
 gcc/cobol/inspect.h|   237 +
 gcc/cobol/lang-specs.h |47 +
 gcc/cobol/lang.opt |   144 +
 gcc/cobol/lang.opt.urls|36 +
 gcc/cobol/lexio.cc |  1878 +
 gcc/cobol/lexio.h  |   294 +
 gcc/cobol/parse.y  | 13107 ++
 gcc/cobol/parse_ante.h |  3552 ++
 gcc/cobol/parse_util.h |   478 +
 gcc/cobol/scan.l   |  2487 ++
 gcc/cobol/scan_ante.h  |   745 +
 gcc/cobol/scan_post.h  |   401 +
 gcc/cobol/show_parse.h |   523 +
 gcc/cobol/structs.cc   |   333 +
 gcc/cobol/structs.h|62 +
 gcc/cobol/symbols.cc   |  4881 +++
 gcc/cobol/symbols.h|  2210 +
 gcc/cobol/symfind.cc   |   611 +
 gcc/cobol/token_names.h|  1373 +
 gcc/cobol/udf/stored-char-length.cbl   |15 +
 gcc/cobol/util.cc  |  2310 +
 gcc/co

[gcc r15-8026] match.pd: Extend pointer alignment folds

2025-03-13 Thread Richard Sandiford via Gcc-cvs
https://gcc.gnu.org/g:feb75e4643dca350b946b85ee25f4818ce6ce308

commit r15-8026-gfeb75e4643dca350b946b85ee25f4818ce6ce308
Author: Richard Sandiford 
Date:   Thu Mar 13 12:03:05 2025 +

match.pd: Extend pointer alignment folds

We have long had the fold:

/* Pattern match
 tem = (sizetype) ptr;
 tem = tem & algn;
 tem = -tem;
 ... = ptr p+ tem;
   and produce the simpler and easier to analyze with respect to alignment
 ... = ptr & ~algn;  */

But the gimple in gcc.target/aarch64/sve/pr98119.c has a variant in
which a constant is added before the conversion, giving:

 tem = (sizetype) (ptr p+ CST);
 tem = tem & algn;
 tem = -tem;
 ... = ptr p+ tem;

This case is also valid if algn fits within the trailing zero bits
of CST.  Adding CST then has no effect.

Similarly the testcase has:

 tem = (sizetype) (ptr p+ CST1);
 tem = tem & algn;
 tem = CST2 - tem;
 ... = ptr p+ tem;

This folds to:

 ... = (ptr & ~algn) p+ CST2;

if algn fits within the trailing zero bits of both CST1 and CST2.

An alternative would be:

 ... = (ptr p+ CST2) & ~algn;

but I would expect the alignment to be more easily shareable than
the CST2 addition, given that the CST2 addition wasn't being applied
by a POINTER_PLUS_EXPR.

gcc/
* match.pd: Extend pointer alignment folds so that they handle
the case where a constant is added before or after the alignment.

gcc/testsuite/
* gcc.dg/pointer-arith-11.c: New test.
* gcc.dg/pointer-arith-12.c: Likewise.

Diff:
---
 gcc/match.pd| 27 +++
 gcc/testsuite/gcc.dg/pointer-arith-11.c | 39 
 gcc/testsuite/gcc.dg/pointer-arith-12.c | 82 +
 3 files changed, 148 insertions(+)

diff --git a/gcc/match.pd b/gcc/match.pd
index 7017fd15277b..89612d1b15b6 100644
--- a/gcc/match.pd
+++ b/gcc/match.pd
@@ -3037,6 +3037,33 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
   (with { tree algn = wide_int_to_tree (TREE_TYPE (@0), ~wi::to_wide (@1)); }
(bit_and @0 { algn; })))
 
+/* Also match cases in which a constant is applied:
+
+   (1) tem = (sizetype) ptr;  ---> tem = (sizetype) (ptr + CST);
+   (2) tem = -tem ---> tem = CST - tem;
+
+   and where "& align" masks only trailing zeros of CST.  (1) then has no
+   effect, whereas (2) adds CST to the result.  */
+(simplify
+ (pointer_plus @0 (negate (bit_and (convert (pointer_plus @0 INTEGER_CST@1))
+  INTEGER_CST@2)))
+ (if (tree_int_cst_min_precision (@2, UNSIGNED) <= tree_ctz (@1))
+  (with { tree algn = wide_int_to_tree (TREE_TYPE (@0), ~wi::to_wide (@2)); }
+   (bit_and @0 { algn; }
+(simplify
+ (pointer_plus @0 (minus:s INTEGER_CST@1 (bit_and (convert @0) INTEGER_CST@2)))
+ (if (tree_int_cst_min_precision (@2, UNSIGNED) <= tree_ctz (@1))
+  (with { tree algn = wide_int_to_tree (TREE_TYPE (@0), ~wi::to_wide (@2)); }
+   (pointer_plus (bit_and @0 { algn; }) @1
+(simplify
+ (pointer_plus @0 (minus:s INTEGER_CST@1
+  (bit_and (convert (pointer_plus @0 INTEGER_CST@2))
+   INTEGER_CST@3)))
+ (with { auto mask_width = tree_int_cst_min_precision (@3, UNSIGNED); }
+  (if (mask_width <= tree_ctz (@1) && mask_width <= tree_ctz (@2))
+   (with { tree algn = wide_int_to_tree (TREE_TYPE (@0), ~wi::to_wide (@3)); }
+(pointer_plus (bit_and @0 { algn; }) @1)
+
 /* Try folding difference of addresses.  */
 (simplify
  (minus (convert ADDR_EXPR@0) (convert (pointer_plus @1 @2)))
diff --git a/gcc/testsuite/gcc.dg/pointer-arith-11.c 
b/gcc/testsuite/gcc.dg/pointer-arith-11.c
new file mode 100644
index ..e9390ef08380
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pointer-arith-11.c
@@ -0,0 +1,39 @@
+/* { dg-options "-O2 -fdump-tree-optimized" } */
+
+/* { dg-final { scan-tree-dump-times { & -16B?;} 4 "optimized" { target lp64 } 
} } */
+/* { dg-final { scan-tree-dump-times { \+ 16;} 3 "optimized" } } */
+/* { dg-final { scan-tree-dump-not { & 15;} "optimized" } } */
+/* { dg-final { scan-tree-dump-not { \+ 96;} "optimized" } } */
+
+typedef __UINTPTR_TYPE__ uintptr_t;
+
+char *
+f1 (char *x)
+{
+  char *y = x + 32;
+  x += -((uintptr_t) y & 15);
+  return x;
+}
+
+char *
+f2 (char *x)
+{
+  x += 16 - ((uintptr_t) x & 15);
+  return x;
+}
+
+char *
+f3 (char *x)
+{
+  char *y = x + 32;
+  x += 16 - ((uintptr_t) y & 15);
+  return x;
+}
+
+char *
+f4 (char *x)
+{
+  char *y = x + 16;
+  x += 16 - ((uintptr_t) y & 15);
+  return x;
+}
diff --git a/gcc/testsuite/gcc.dg/pointer-arith-12.c 
b/gcc/testsuite/gcc.dg/pointer-arith-12.c
new file mode 100644
index ..ebdcbd3c9679
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pointer-arith-12.c
@@ -0,0 +1,82 @@
+/* { dg-options "-O2 -fdump-tree-

[gcc r15-8028] Move 'find-dg-do-what' from 'gcc/testsuite/lib/gcc-dg.exp' into 'gcc/testsuite/lib/target-supports-d

2025-03-13 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:6888a4bb584ad3977cb1e8cdefedea70b1f135ea

commit r15-8028-g6888a4bb584ad3977cb1e8cdefedea70b1f135ea
Author: Thomas Schwinge 
Date:   Wed Mar 5 18:28:53 2025 +0100

Move 'find-dg-do-what' from 'gcc/testsuite/lib/gcc-dg.exp' into 
'gcc/testsuite/lib/target-supports-dg.exp'

This was added in commit f553b1aaa2b1b925c918e5dcf966290b045321c2
"Refactor duplicated code into 
'gcc/testsuite/lib/gcc-dg.exp:find-dg-do-what'",
for use by 'gcc/testsuite/lib/target-supports.exp'.  The latter is used by
several test suites, 'gcc/testsuite/lib/gcc-dg.exp' however doesn't get 
loaded
for 'make check-target-libstdc++-v3', for example, and testing ERRORs out:

ERROR: (DejaGnu) proc "find-dg-do-what" does not exist.
The error code is TCL LOOKUP COMMAND find-dg-do-what
The info on the error is:
invalid command name "find-dg-do-what"
while executing
"::tcl_unknown find-dg-do-what"
("uplevel" body line 1)
invoked from within
"uplevel 1 ::tcl_unknown $args"

Fix this by moving 'find-dg-do-what' into the DejaGnu interfacing file
corresponding to 'gcc/testsuite/lib/target-supports.exp':
'gcc/testsuite/lib/target-supports-dg.exp' (next to other related 
procedures).

gcc/testsuite/
* lib/gcc-dg.exp (find-dg-do-what): Move...
* lib/target-supports-dg.exp: ... here.

Diff:
---
 gcc/testsuite/lib/gcc-dg.exp | 20 
 gcc/testsuite/lib/target-supports-dg.exp | 21 +
 2 files changed, 21 insertions(+), 20 deletions(-)

diff --git a/gcc/testsuite/lib/gcc-dg.exp b/gcc/testsuite/lib/gcc-dg.exp
index 008b8538e46c..f5ad4247a619 100644
--- a/gcc/testsuite/lib/gcc-dg.exp
+++ b/gcc/testsuite/lib/gcc-dg.exp
@@ -1376,23 +1376,3 @@ proc gcc-transform-out-of-tree { args } {
 
 set additional_prunes ""
 set dg_runtest_extra_prunes ""
-
-# Find the 'dg-do-what' variable living inside DejaGnu's 'dg-test' procedure,
-# as a local variable.  We start looking at the second-outer frame: this way,
-# the caller of 'find-dg-do-what' may maintain a local 'dg-do-what' variable
-# without interfering with this search.
-proc find-dg-do-what { } {
-set level [info level]
-set lookup_level 2
-while { $lookup_level <= $level } {
-   upvar $lookup_level dg-do-what dg-do-what
-   if { [info exists dg-do-what] } {
-   verbose "find-dg-do-what: found 'dg-do-what' at level 
$lookup_level: ${dg-do-what}" 2
-   return ${dg-do-what}
-   }
-   incr lookup_level
-}
-# We've not be called (indirectly) from 'dg-test'.
-verbose "find-dg-do-what: have not found 'dg-do-what'" 2
-return [list]
-}
diff --git a/gcc/testsuite/lib/target-supports-dg.exp 
b/gcc/testsuite/lib/target-supports-dg.exp
index c307258db836..422ea8380845 100644
--- a/gcc/testsuite/lib/target-supports-dg.exp
+++ b/gcc/testsuite/lib/target-supports-dg.exp
@@ -58,6 +58,27 @@ proc testname-for-summary { } {
 return "$testname_with_flags"
 }
 
+# Find the 'dg-do-what' variable living inside DejaGnu's 'dg-test' procedure,
+# as a local variable.  We start looking at the second-outer frame: this way,
+# the caller of 'find-dg-do-what' may maintain a local 'dg-do-what' variable
+# without interfering with this search.
+
+proc find-dg-do-what { } {
+set level [info level]
+set lookup_level 2
+while { $lookup_level <= $level } {
+   upvar $lookup_level dg-do-what dg-do-what
+   if { [info exists dg-do-what] } {
+   verbose "find-dg-do-what: found 'dg-do-what' at level 
$lookup_level: ${dg-do-what}" 2
+   return ${dg-do-what}
+   }
+   incr lookup_level
+}
+# We've not be called (indirectly) from 'dg-test'.
+verbose "find-dg-do-what: have not found 'dg-do-what'" 2
+return [list]
+}
+
 # If this target does not support weak symbols, skip this test.
 
 proc dg-require-weak { args } {


[gcc/redhat/heads/gcc-15-branch] (259 commits) Merge commit 'r15-8028-g6888a4bb584ad3977cb1e8cdefedea70b1f

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

 4fe62f20633b... Merge commit 'r15-8028-g6888a4bb584ad3977cb1e8cdefedea70b1f

It previously pointed to:

 504a13588c39... Merge commit 'r15-7770-g8c15a6cefa0d1f8ec12701af1f528f473c3

Diff:

Summary of changes (added commits):
---

  4fe62f2... Merge commit 'r15-8028-g6888a4bb584ad3977cb1e8cdefedea70b1f
  6888a4b... Move 'find-dg-do-what' from 'gcc/testsuite/lib/gcc-dg.exp'  (*)
  5967fe0... libstdc++: Allow 'configure.host' to pre-set 'EXTRA_CFLAGS' (*)
  feb75e4... match.pd: Extend pointer alignment folds (*)
  7dae3f6... match.pd: Fold ((X >> C1) & C2) * (1 << C1) (*)
  a68e32b... testsuite: Remove sve/pre_cond_share_1.c [PR115248] (*)
  22847ef... libstdc++: Hide 128-bit int and float types behind handle f (*)
  77ef91d... RISC-V: Do not delete fused vsetvl if it has uses [PR119115 (*)
  f043ef2... RISC-V: Adjust LMUL when using maximum SEW [PR117955]. (*)
  d109ad5... cobol/119229 - fix external variable declaration (*)
  6fe63cc... Remove extra argument from subst macro (*)
  f1baee3... Allow to build libgccjit with a soname bound to the GCC maj (*)
  4e6967a... LoongArch: Don't use C++17 feature [PR119238] (*)
  8015a72... analyzer: support RAW_DATA_CST [PR117262] (*)
  0385556... Daily bump. (*)
  ebf6e62... c++: Evaluate immediate invocation call arguments with mce_ (*)
  2eb3d74... c++/modules: Better handle no-linkage decls in unnamed name (*)
  4cd99e4... c++/modules: Handle gnu_inline attribute, cleanup linkage d (*)
  3dd7b59... c++: ICE with aligned member and trivial assign op [PR11751 (*)
  cfb20f1... libstdc++: Implement P3137R3 views::to_input for C++26 (*)
  90e53ec... c++: Look through capture proxy from outer lambda instead o (*)
  9ee6c26... arm: testsuite: remove gcc.target/arm/lp1243022.c [PR117931 (*)
  d8a3944... libstdc++: Use new  header in  (*)
  fdcff3f... Remove bogus dg-error statements from binding_label_tests_2 (*)
  0e47062... c++: ICE with lambda in fold expression in requires [PR1191 (*)
  2560603... libstdc++: Optimize basic_format_parse_context::check_dynam (*)
  4d2683b... libstdc++: Add static_assert to std::packaged_task::package (*)
  0ce4c1c... libstdc++: Update tzdata to 2025a (*)
  90f5dab... contrib: relpath.sh /lib /include [PR119081] (*)
  758e617... df: Treat partial defs as uses in df_simulate_defs [PR11656 (*)
  d63b52e... libphobos: Merge upstream phobos 0faae92d6 (*)
  6e40455... arm: allow type-punning subregs in vpr_register_operand [PR (*)
  baa9b2b... Fortran: Add F2018 TEAM_NUMBER to coindexed expressions [PR (*)
  52e297a... MAINTAINERS: Remove extraneous "Robert Dubner" entries (*)
  445128c... libstdc++: Correct preprocessing checks for floatX_t and bf (*)
  2ac842a... libgcobol: Fix typo in comment (*)
  74be867... Regenerate cobol/lang.opt.urls (*)
  597ca24... libstdc++: Add lambda example to case transformation docs (*)
  503f10e... cobol: Remove unnecesssary CPPFLAGS update and restore MacO (*)
  8ff7ff1... libstdc++: Prevent dangling references in std::unique_ptr:: (*)
  04815ae... libstdc++: Make range adaptor __has_arrow helper use a cons (*)
  a21847a... libstdc++: Reject basic_format_parse_context::check_dynamic (*)
  bb83e83... testsuite: Add testcase for already fixed PR [PR119226] (*)
  e406994... aarch64: Make latency account for synthetic VEC_PERM_EXPRs  (*)
  855b61b... vect: Fix ncopies when costing SLP reductions [PR116901] (*)
  5cef719... aarch64: Tighten pr110625_1.c regexp (*)
  0787a65... tree.def: Improve RAW_DATA_CST documentation (*)
  5712e33... Simple cobol.dg testsuite (*)
  da967f0... builtins: Fix up strspn/strcspn folding [PR119219] (*)
  28b05e4... c++: Handle RAW_DATA_CST in modules.cc [PR119076] (*)
  2fa031a... preprocessor: Fix up diagnostic typo in convert_oct [PR1192 (*)
  7efe3aa... Daily bump. (*)
  9cebf12... Revert "[rtl-optimization/117467] Avoid unnecessarily marki (*)
  afb4654... c: Don't emit -Wunterminated-string-initialization warning  (*)
  799ed87... cobol: Regenerate libgcobol/config.h.h (*)
  0bbdffc... aarch64: Fix DFP constants [PR119131] (*)
  17ef5ca... c++: constexpr caching deleted pointer [PR119162] (*)
  bc6bbdb... MAINTAINERS: Add myself (*)
  f74ed83... OpenMP/C: Store location in cp_parser_omp_var_list for kind (*)
  f695d03... doc: Fix minor grammar nit in -ftrivial-auto-var-init docs (*)
  34bc311... contrib: Clean up outdated parts of gcc-git-customization.s (*)
  81582ca... d: Fix regression returning from function with invariants [ (*)
  b3becb1... testsuite: Improve builtin-bswap-5.c (*)
  5e9f712... Fortran: reject SAVE of a COMMON in a BLOCK construct [PR11 (*)
  0920568... aarch64: XFAIL pred-not-gen-[14].c [PR118956] (*)
  64a551f... Abstract interfaces and dummy arguments are not global. (*)
  456924e... aarch64: Generalise tbz_2.c (*)
  4001281... s390: fix delegitimization of addresses (*)
  dc47161... Fix a pasto in ao_compare::compare_ao_refs (*)
  09c2a0a... cobol: Fix 

[gcc/devel/omp/gcc-14] OpenMP: Integrate dynamic selectors with dispatch argument handling [PR118457]

2025-03-13 Thread Sandra Loosemore via Gcc-cvs
https://gcc.gnu.org/g:29a1c0c4bda74a786db857e409b2e960343211e7

commit 29a1c0c4bda74a786db857e409b2e960343211e7
Author: Sandra Loosemore 
Date:   Thu Mar 13 19:41:15 2025 +

OpenMP: Integrate dynamic selectors with dispatch argument handling 
[PR118457]

Support for dynamic selectors in "declare variant" was developed in
parallel with support for the adjust_args/append_args clauses and the
dispatch construct; they collided in a bad way.  This patch fixes the
"sorry" for calls that need both by removing the adjust_args/append_args
code from gimplify_call_expr and invoking it from the new variant
substitution code instead.

This is a backport of commit 44b1d52e2f4db57849ca54b63c52a687294b1793
from mainline, done by hand instead of cherry-picking because of
differences in the dynamic selector code between OG14 and mainline.

gcc/ChangeLog
PR middle-end/118457
* gimplify.cc (modify_call_for_omp_dispatch): New, containing
code split from gimplify_call_expr and modified to emit tree
instead of gimple.  Remove the error for falling through to a call
to the base function.
(gimplify_variant_call_expr):  Add omp_dispatch_p argument and
call modify_call_for_omp_dispatch if needed.
(gimplify_call_expr): Adjust call to gimplify_variant_call_expr.
Move adjust_args/append_args code to modify_call_for_omp_dispatch.

gcc/testsuite/ChangeLog
PR middle-end/118457
* c-c++-common/gomp/adjust-args-6.c: New.
* c-c++-common/gomp/append-args-5.c: Adjust expected output.
* c-c++-common/gomp/append-args-dynamic.c: New.
* c-c++-common/gomp/dispatch-11.c: Adjust expected output.
* gfortran.dg/gomp/dispatch-11.f90: Likewise.

Diff:
---
 gcc/gimplify.cc| 687 ++---
 gcc/testsuite/c-c++-common/gomp/adjust-args-6.c|  27 +
 gcc/testsuite/c-c++-common/gomp/append-args-5.c|  19 +-
 .../c-c++-common/gomp/append-args-dynamic.c|  94 +++
 gcc/testsuite/c-c++-common/gomp/dispatch-11.c  |  22 +-
 gcc/testsuite/gfortran.dg/gomp/dispatch-11.f90 |   5 -
 6 files changed, 447 insertions(+), 407 deletions(-)

diff --git a/gcc/gimplify.cc b/gcc/gimplify.cc
index 2bcadcf10383..ea46c81364b3 100644
--- a/gcc/gimplify.cc
+++ b/gcc/gimplify.cc
@@ -3892,6 +3892,303 @@ maybe_fold_stmt (gimple_stmt_iterator *gsi)
   return fold_stmt (gsi);
 }
 
+/* OpenMP: Handle the append_args and adjust_args clauses of
+   declare_variant for EXPR, which is a CALL_EXPR whose CALL_EXPR_FN
+   is the variant, within a dispatch construct with clauses DISPATCH_CLAUSES
+   and location DISPATCH_LOC.
+
+   'append_args' causes interop objects are added after the last regular
+   (nonhidden, nonvariadic) arguments of the variant function.
+   'adjust_args' with need_device_{addr,ptr} converts the pointer target of
+   a pointer from a host to a device address. This uses either the default
+   device or the passed device number, which then sets the default device
+   address.  */
+static tree
+modify_call_for_omp_dispatch (tree expr, tree dispatch_clauses,
+ location_t dispatch_loc)
+{
+  tree fndecl = get_callee_fndecl (expr);
+
+  /* Skip processing if we don't get the expected call form.  */
+  if (!fndecl)
+return expr;
+
+  int nargs = call_expr_nargs (expr);
+  tree dispatch_device_num = NULL_TREE;
+  tree dispatch_device_num_init = NULL_TREE;
+  tree dispatch_interop = NULL_TREE;
+  tree dispatch_append_args = NULL_TREE;
+  int nfirst_args = 0;
+  tree dispatch_adjust_args_list
+= lookup_attribute ("omp declare variant variant args",
+   DECL_ATTRIBUTES (fndecl));
+
+  if (dispatch_adjust_args_list)
+{
+  dispatch_adjust_args_list = TREE_VALUE (dispatch_adjust_args_list);
+  dispatch_append_args = TREE_CHAIN (dispatch_adjust_args_list);
+  if (TREE_PURPOSE (dispatch_adjust_args_list) == NULL_TREE
+ && TREE_VALUE (dispatch_adjust_args_list) == NULL_TREE)
+   dispatch_adjust_args_list = NULL_TREE;
+}
+  if (dispatch_append_args)
+{
+  nfirst_args = tree_to_shwi (TREE_PURPOSE (dispatch_append_args));
+  dispatch_append_args = TREE_VALUE (dispatch_append_args);
+}
+  dispatch_device_num = omp_find_clause (dispatch_clauses, OMP_CLAUSE_DEVICE);
+  if (dispatch_device_num)
+dispatch_device_num = OMP_CLAUSE_DEVICE_ID (dispatch_device_num);
+  dispatch_interop = omp_find_clause (dispatch_clauses, OMP_CLAUSE_INTEROP);
+  int nappend = 0, ninterop = 0;
+  for (tree t = dispatch_append_args; t; t = TREE_CHAIN (t))
+nappend++;
+
+  /* FIXME: error checking should be taken out of this function and
+ handled before any attempt at filtering or resolution happens.
+ Otherwise whether or not diagnostics appear is determined by
+ GCC internals, how good th

[gcc(refs/users/mikael/heads/refactor_descriptor_v01)] Correction régression submodule_6.f08

2025-03-13 Thread Mikael Morin via Gcc-cvs
https://gcc.gnu.org/g:84bf56c81627cf0dfe13a54764e71a68a0e6b4b2

commit 84bf56c81627cf0dfe13a54764e71a68a0e6b4b2
Author: Mikael Morin 
Date:   Thu Mar 13 22:06:57 2025 +0100

Correction régression submodule_6.f08

Diff:
---
 gcc/fortran/trans-decl.cc  | 5 -
 gcc/fortran/trans-types.cc | 2 +-
 gcc/fortran/trans.h| 2 +-
 3 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/gcc/fortran/trans-decl.cc b/gcc/fortran/trans-decl.cc
index 02a87339f953..44060f06bd0b 100644
--- a/gcc/fortran/trans-decl.cc
+++ b/gcc/fortran/trans-decl.cc
@@ -938,7 +938,7 @@ gfc_defer_symbol_init (gfc_symbol * sym)
an existing backend_decl is found.  */
 
 bool
-gfc_get_module_backend_decl (gfc_symbol *sym)
+gfc_get_module_backend_decl (gfc_symbol *sym, bool create_type_decl)
 {
   gfc_gsymbol *gsym;
   gfc_symbol *s;
@@ -994,6 +994,9 @@ gfc_get_module_backend_decl (gfc_symbol *sym)
 
  if (gfc_fl_struct (s->attr.flavor) && !s->backend_decl)
 {
+ if (!create_type_decl)
+   return false;
+
   if (s->attr.flavor == FL_UNION)
 s->backend_decl = gfc_get_union_type (s);
   else
diff --git a/gcc/fortran/trans-types.cc b/gcc/fortran/trans-types.cc
index 2ba3455ab6a0..09a17977f9f2 100644
--- a/gcc/fortran/trans-types.cc
+++ b/gcc/fortran/trans-types.cc
@@ -2958,7 +2958,7 @@ gfc_get_derived_type (gfc_symbol * derived, int codimen)
   if (derived->backend_decl == NULL
   && (derived->attr.use_assoc || derived->attr.used_in_submodule)
   && derived->module
-  && gfc_get_module_backend_decl (derived))
+  && gfc_get_module_backend_decl (derived, false))
 goto copy_derived_types;
 
   if (derived->attr.is_class)
diff --git a/gcc/fortran/trans.h b/gcc/fortran/trans.h
index 87e722daa92c..85c61959796b 100644
--- a/gcc/fortran/trans.h
+++ b/gcc/fortran/trans.h
@@ -661,7 +661,7 @@ void gfc_build_builtin_function_decls (void);
 void gfc_set_decl_location (tree, locus *);
 
 /* Get a module symbol backend_decl if possible.  */
-bool gfc_get_module_backend_decl (gfc_symbol *);
+bool gfc_get_module_backend_decl (gfc_symbol *, bool = true);
 
 /* Return the variable decl for a symbol.  */
 tree gfc_get_symbol_decl (gfc_symbol *);


[gcc r15-8040] Fortran: improve checking of substring bounds [PR119118]

2025-03-13 Thread Harald Anlauf via Gcc-cvs
https://gcc.gnu.org/g:a5d56278d145d439092adf6f65c865c85623f881

commit r15-8040-ga5d56278d145d439092adf6f65c865c85623f881
Author: Harald Anlauf 
Date:   Thu Mar 13 18:46:54 2025 +0100

Fortran: improve checking of substring bounds [PR119118]

Commit r15-7873 copy-pasted erroneous code containing a non-terminating
loop that did not progress its control variable, and a switch statement
with an unhandled case leading to a gcc_unreachable () with suitable input.

PR fortran/119118

gcc/fortran/ChangeLog:

* dependency.cc (contains_forall_index_p): Let loop over elements
of a constructor update its control variable.  Handle REF_INQUIRY
in switch statement.
(gfc_contains_implied_index_p): Likewise.

gcc/testsuite/ChangeLog:

* gfortran.dg/bounds_check_26.f90: Update test.

Diff:
---
 gcc/fortran/dependency.cc | 6 --
 gcc/testsuite/gfortran.dg/bounds_check_26.f90 | 4 +++-
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/gcc/fortran/dependency.cc b/gcc/fortran/dependency.cc
index 28b872f66382..57c0c49391bd 100644
--- a/gcc/fortran/dependency.cc
+++ b/gcc/fortran/dependency.cc
@@ -1853,7 +1853,7 @@ contains_forall_index_p (gfc_expr *expr)
 case EXPR_STRUCTURE:
 case EXPR_ARRAY:
   for (c = gfc_constructor_first (expr->value.constructor);
-  c; gfc_constructor_next (c))
+  c; c = gfc_constructor_next (c))
if (contains_forall_index_p (c->expr))
  return true;
   break;
@@ -1874,6 +1874,7 @@ contains_forall_index_p (gfc_expr *expr)
break;
 
   case REF_COMPONENT:
+  case REF_INQUIRY:
break;
 
   case REF_SUBSTRING:
@@ -1933,7 +1934,7 @@ gfc_contains_implied_index_p (gfc_expr *expr)
 case EXPR_STRUCTURE:
 case EXPR_ARRAY:
   for (c = gfc_constructor_first (expr->value.constructor);
-  c; gfc_constructor_next (c))
+  c; c = gfc_constructor_next (c))
if (gfc_contains_implied_index_p (c->expr))
  return true;
   break;
@@ -1954,6 +1955,7 @@ gfc_contains_implied_index_p (gfc_expr *expr)
break;
 
   case REF_COMPONENT:
+  case REF_INQUIRY:
break;
 
   case REF_SUBSTRING:
diff --git a/gcc/testsuite/gfortran.dg/bounds_check_26.f90 
b/gcc/testsuite/gfortran.dg/bounds_check_26.f90
index 69ac9fbe2f22..ddfcbd07f3c0 100644
--- a/gcc/testsuite/gfortran.dg/bounds_check_26.f90
+++ b/gcc/testsuite/gfortran.dg/bounds_check_26.f90
@@ -19,6 +19,8 @@ program main
   print *,  str(-n:11)  ! 2 checked bounds
   print *, len (str(-n:11)) ! 2 checked bounds
 
+  print *,  str(-n*n%kind:sum(n-[0,n%kind])) ! 2 checked bounds
+
 end program main
 
-! { dg-final { scan-tree-dump-times "Substring out of bounds:" 10 "original" } 
}
+! { dg-final { scan-tree-dump-times "Substring out of bounds:" 12 "original" } 
}


[gcc r15-8046] Doc: Remove redundant info from documentation of -ansi.

2025-03-13 Thread Sandra Loosemore via Gcc-cvs
https://gcc.gnu.org/g:81203220af87714fd0f3170a2043ab5d95353eef

commit r15-8046-g81203220af87714fd0f3170a2043ab5d95353eef
Author: Sandra Loosemore 
Date:   Wed Mar 12 23:36:17 2025 +

Doc: Remove redundant info from documentation of -ansi.

The -ansi option has essentially been superseded by the more general
-std= option, and all the additional information about its effects is
already covered elsewhere in the manual.  I also cleaned up some
confusing text about alternate keywords that I noticed while
confirming this.

gcc/ChangeLog
* doc/extend.texi (Alternate Keywords): Clean up text and remove
discussion of "restrict", which is not a GNU extension at all.
* doc/invoke.texi (C Dialect Options): Remove detailed discussion.

Diff:
---
 gcc/doc/extend.texi | 16 ++--
 gcc/doc/invoke.texi | 33 -
 2 files changed, 6 insertions(+), 43 deletions(-)

diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
index bae3fba6b2b6..79cc7dfcff9c 100644
--- a/gcc/doc/extend.texi
+++ b/gcc/doc/extend.texi
@@ -13049,17 +13049,13 @@ is taken as the minimum size, ignoring how many 
instructions GCC thinks it is.
 @cindex keywords, alternate
 
 @option{-ansi} and the various @option{-std} options disable certain
-keywords.  This causes trouble when you want to use GNU C extensions, or
-a general-purpose header file that should be usable by all programs,
-including ISO C programs.  The keywords @code{asm}, @code{typeof} and
+keywords that are GNU C extensions.
+Specifically, the keywords @code{asm}, @code{typeof} and
 @code{inline} are not available in programs compiled with
-@option{-ansi} or @option{-std} (although @code{inline} can be used in a
-program compiled with @option{-std=c99} or a later standard).  The
-ISO C99 keyword
-@code{restrict} is only available when @option{-std=gnu99} (which will
-eventually be the default) or @option{-std=c99} (or the equivalent
-@option{-std=iso9899:1999}), or an option for a later standard
-version, is used.
+@option{-ansi} or a @option{-std=} option specifying an ISO standard that
+doesn't define the keyword.  This causes trouble when you want to use
+these extensions in a header file that can be included in programs that may
+be compiled with with such options.
 
 The way to solve these problems is to put @samp{__} at the beginning and
 end of each problematical keyword.  For example, use @code{__asm__}
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 4fbb4cda101e..768b98dba74c 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -2386,39 +2386,6 @@ accepts:
 In C mode, this is equivalent to @option{-std=c90}. In C++ mode, it is
 equivalent to @option{-std=c++98}.
 
-This turns off certain features of GCC that are incompatible with ISO
-C90 (when compiling C code), or of standard C++ (when compiling C++ code),
-such as the @code{asm} and @code{typeof} keywords, and
-predefined macros such as @code{unix} and @code{vax} that identify the
-type of system you are using.  It also enables the undesirable and
-rarely used ISO trigraph feature.  For the C compiler,
-it disables recognition of C++ style @samp{//} comments as well as
-the @code{inline} keyword.
-
-The alternate keywords @code{__asm__}, @code{__extension__},
-@code{__inline__} and @code{__typeof__} continue to work despite
-@option{-ansi}.  You would not want to use them in an ISO C program, of
-course, but it is useful to put them in header files that might be included
-in compilations done with @option{-ansi}.  Alternate predefined macros
-such as @code{__unix__} and @code{__vax__} are also available, with or
-without @option{-ansi}.
-
-The @option{-ansi} option does not cause non-ISO programs to be
-rejected gratuitously.  For that, @option{-Wpedantic} is required in
-addition to @option{-ansi}.  @xref{Warning Options}.
-
-The macro @code{__STRICT_ANSI__} is predefined when the @option{-ansi}
-option is used.  Some header files may notice this macro and refrain
-from declaring certain functions or defining certain macros that the
-ISO standard doesn't call for; this is to avoid interfering with any
-programs that might use these names for other things.
-
-Functions that are normally built in but do not have semantics
-defined by ISO C (such as @code{alloca} and @code{ffs}) are not built-in
-functions when @option{-ansi} is used.  @xref{Other Builtins,,Other
-built-in functions provided by GCC}, for details of the functions
-affected.
-
 @opindex std
 @item -std=
 Determine the language standard. @xref{Standards,,Language Standards


[gcc r15-8044] libstdc++: Work around C++20 tuple> constraint recursion [PR116440]

2025-03-13 Thread Patrick Palka via Gcc-cvs
https://gcc.gnu.org/g:6570fa6f2612a4e4ddd2fcfc119369a1a48656e4

commit r15-8044-g6570fa6f2612a4e4ddd2fcfc119369a1a48656e4
Author: Patrick Palka 
Date:   Thu Mar 13 19:55:00 2025 -0400

libstdc++: Work around C++20 tuple> constraint recursion 
[PR116440]

The type tuple> is clearly copy/move constructible, but for
reasons that are not yet completely understood checking this triggers
constraint recursion with our C++20 tuple implementation (but not the
C++17 implementation).

It turns out this recursion stems from considering the non-template
tuple(const _Elements&) constructor during the copy/move constructibility
check.  Considering this constructor is ultimately redundant, since the
defaulted copy/move constructors are better matches.

GCC has a non-standard "perfect candidate" optimization[1] that causes
overload resolution to shortcut considering template candidates if we
find a (non-template) perfect candidate.  So to work around this issue
(and as a general compile-time optimization) this patch turns the
problematic constructor into a template so that GCC doesn't consider it
when checking for copy/move constructibility of this tuple type.

Changing the template-ness of a constructor can affect overload
resolution (since template-ness is a tiebreaker) so there's a risk this
change could e.g. introduce overload resolution ambiguities.  But the
original C++17 implementation has long defined this constructor as a
template (in order to constrain it etc), so doing the same thing in the
C++20 mode should naturally be quite safe.

The testcase still fails with Clang (in C++20 mode) since it doesn't
implement said optimization.

[1]: See r11-7287-g187d0d5871b1fa and
https://isocpp.org/files/papers/P3606R0.html

PR libstdc++/116440

libstdc++-v3/ChangeLog:

* include/std/tuple (tuple::tuple(const _Elements&...))
[C++20]: Turn into a template.
* testsuite/20_util/tuple/116440.C: New test.

Reviewed-by: Jonathan Wakely 

Diff:
---
 libstdc++-v3/include/std/tuple| 14 +++--
 libstdc++-v3/testsuite/20_util/tuple/116440.C | 29 +++
 2 files changed, 37 insertions(+), 6 deletions(-)

diff --git a/libstdc++-v3/include/std/tuple b/libstdc++-v3/include/std/tuple
index 34d790fd6f59..d3deb7bc1241 100644
--- a/libstdc++-v3/include/std/tuple
+++ b/libstdc++-v3/include/std/tuple
@@ -966,12 +966,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   : _Inherited()
   { }
 
-  constexpr explicit(!__convertible())
-  tuple(const _Elements&... __elements)
-  noexcept(__nothrow_constructible())
-  requires (__constructible())
-  : _Inherited(__elements...)
-  { }
+  // Defined as a template to work around PR libstdc++/116440.
+  template
+   constexpr explicit(!__convertible())
+   tuple(const _Elements&... __elements)
+   noexcept(__nothrow_constructible())
+   requires (__constructible())
+   : _Inherited(__elements...)
+   { }
 
   template
requires (__disambiguating_constraint<_UTypes...>())
diff --git a/libstdc++-v3/testsuite/20_util/tuple/116440.C 
b/libstdc++-v3/testsuite/20_util/tuple/116440.C
new file mode 100644
index ..12259134d251
--- /dev/null
+++ b/libstdc++-v3/testsuite/20_util/tuple/116440.C
@@ -0,0 +1,29 @@
+// PR libstdc++/116440 - std::tuple> does not compile
+// { dg-do compile { target c++17 } }
+
+#include 
+#include 
+#include 
+
+template 
+using TupleTuple = std::tuple>;
+
+struct EmbedAny {
+std::any content;
+};
+
+static_assert(std::is_copy_constructible>::value);
+static_assert(std::is_move_constructible>::value);
+
+static_assert(std::is_copy_constructible>::value);
+static_assert(std::is_move_constructible>::value);
+
+static_assert(std::is_constructible_v>);
+
+struct EmbedAnyWithZeroSizeArray {
+void* pad[0];
+std::any content;
+};
+
+static_assert(std::is_copy_constructible>::value);
+static_assert(std::is_move_constructible>::value);


[gcc r15-8043] Plug small loophole in the pattern matching done by -fdump-ada-spec

2025-03-13 Thread Eric Botcazou via Gcc-cvs
https://gcc.gnu.org/g:ab4e9fd943124f0630e560a56a5477d5d7ca2c1f

commit r15-8043-gab4e9fd943124f0630e560a56a5477d5d7ca2c1f
Author: Eric Botcazou 
Date:   Fri Mar 14 00:01:46 2025 +0100

Plug small loophole in the pattern matching done by -fdump-ada-spec

gcc/c-family/
PR ada/119265
* c-ada-spec.cc (dump_ada_node) : Deal with typedefs
of unsigned __int128.

Diff:
---
 gcc/c-family/c-ada-spec.cc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gcc/c-family/c-ada-spec.cc b/gcc/c-family/c-ada-spec.cc
index 152fb2093df1..c7ae032230a8 100644
--- a/gcc/c-family/c-ada-spec.cc
+++ b/gcc/c-family/c-ada-spec.cc
@@ -2255,8 +2255,8 @@ dump_ada_node (pretty_printer *pp, tree node, tree type, 
int spc,
 case BOOLEAN_TYPE:
   if (TYPE_NAME (node)
  && !(TREE_CODE (TYPE_NAME (node)) == TYPE_DECL
-  && !strcmp (IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (node))),
-  "__int128")))
+  && !strncmp (IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (node))),
+  "__int128", 8)))
{
  if (TREE_CODE (TYPE_NAME (node)) == IDENTIFIER_NODE)
pp_ada_tree_identifier (pp, TYPE_NAME (node), node,


[gcc r14-11408] Plug small loophole in the pattern matching done by -fdump-ada-spec

2025-03-13 Thread Eric Botcazou via Gcc-cvs
https://gcc.gnu.org/g:1016eea220ffb75a8b8c3031918e1834a8a544e8

commit r14-11408-g1016eea220ffb75a8b8c3031918e1834a8a544e8
Author: Eric Botcazou 
Date:   Fri Mar 14 00:01:46 2025 +0100

Plug small loophole in the pattern matching done by -fdump-ada-spec

gcc/c-family/
PR ada/119265
* c-ada-spec.cc (dump_ada_node) : Deal with typedefs
of unsigned __int128.

Diff:
---
 gcc/c-family/c-ada-spec.cc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gcc/c-family/c-ada-spec.cc b/gcc/c-family/c-ada-spec.cc
index e56ef10f443a..0f54f904b6a5 100644
--- a/gcc/c-family/c-ada-spec.cc
+++ b/gcc/c-family/c-ada-spec.cc
@@ -2193,8 +2193,8 @@ dump_ada_node (pretty_printer *buffer, tree node, tree 
type, int spc,
 case BOOLEAN_TYPE:
   if (TYPE_NAME (node)
  && !(TREE_CODE (TYPE_NAME (node)) == TYPE_DECL
-  && !strcmp (IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (node))),
-  "__int128")))
+  && !strncmp (IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (node))),
+  "__int128", 8)))
{
  if (TREE_CODE (TYPE_NAME (node)) == IDENTIFIER_NODE)
pp_ada_tree_identifier (buffer, TYPE_NAME (node), node,


[gcc r15-8021] RISC-V: Adjust LMUL when using maximum SEW [PR117955].

2025-03-13 Thread Robin Dapp via Gcc-cvs
https://gcc.gnu.org/g:f043ef2b6a59088b16a269b55f09023f76c92e32

commit r15-8021-gf043ef2b6a59088b16a269b55f09023f76c92e32
Author: Robin Dapp 
Date:   Tue Feb 25 12:55:08 2025 +0100

RISC-V: Adjust LMUL when using maximum SEW [PR117955].

When merging two vsetvls that both only demand "SEW >= ..." we
use their maximum SEW and keep the LMUL.  That may lead to invalid
vector configurations like
  e64, mf4.
As we make sure that the SEW requirements overlap we can use the SEW
and LMUL of the configuration with the larger SEW.

Ma Jin already touched this merge rule some weeks ago and fixed the
ratio calculation (r15-6873).  Calculating the ratio from an invalid
SEW/LMUL combination lead to an overflow in the ratio variable, though.
I'd argue the proper fix is to update SEW and LMUL, keeping the ratio
as before.  This "breaks" bug-10.c but its check only checked for a
workaround anyway so I turned it into a run test.

Ma Jin helped minify the PR's test and provided a larger test case for
bug-10.

PR target/117955

gcc/ChangeLog:

* config/riscv/riscv-vsetvl.cc: Use LMUL/ratio from vsetvl with
larger SEW.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/base/bug-10.c: Convert to run test.
* gcc.target/riscv/rvv/base/bug-10-2.c: New test.
* gcc.target/riscv/rvv/base/pr117955.c: New test.

Diff:
---
 gcc/config/riscv/riscv-vsetvl.cc   |  8 +-
 gcc/testsuite/gcc.target/riscv/rvv/base/bug-10-2.c | 93 ++
 gcc/testsuite/gcc.target/riscv/rvv/base/bug-10.c   | 33 +++-
 gcc/testsuite/gcc.target/riscv/rvv/base/pr117955.c | 26 ++
 4 files changed, 154 insertions(+), 6 deletions(-)

diff --git a/gcc/config/riscv/riscv-vsetvl.cc b/gcc/config/riscv/riscv-vsetvl.cc
index 82284624a242..f0165f7b8c8c 100644
--- a/gcc/config/riscv/riscv-vsetvl.cc
+++ b/gcc/config/riscv/riscv-vsetvl.cc
@@ -1729,9 +1729,11 @@ private:
   }
   inline void use_max_sew (vsetvl_info &prev, const vsetvl_info &next)
   {
-int max_sew = MAX (prev.get_sew (), next.get_sew ());
-prev.set_sew (max_sew);
-prev.set_ratio (calculate_ratio (prev.get_sew (), prev.get_vlmul ()));
+bool prev_sew_larger = prev.get_sew () >= next.get_sew ();
+const vsetvl_info from = prev_sew_larger ? prev : next;
+prev.set_sew (from.get_sew ());
+prev.set_vlmul (from.get_vlmul ());
+prev.set_ratio (from.get_ratio ());
 use_min_of_max_sew (prev, next);
   }
   inline void use_next_sew_lmul (vsetvl_info &prev, const vsetvl_info &next)
diff --git a/gcc/testsuite/gcc.target/riscv/rvv/base/bug-10-2.c 
b/gcc/testsuite/gcc.target/riscv/rvv/base/bug-10-2.c
new file mode 100644
index ..fe3a1efb8d86
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/rvv/base/bug-10-2.c
@@ -0,0 +1,93 @@
+/* { dg-do run { target { rv64 } } } */
+/* { dg-require-effective-target rv64 } */
+/* { dg-require-effective-target riscv_v_ok } */
+/* { dg-require-effective-target riscv_zvfh_ok } */
+/* { dg-options " -march=rv64gcv_zvfh -mabi=lp64d -O2" } */
+
+#include 
+
+int8_t a[1];
+uint16_t b[1];
+float c[1], n[1];
+uint16_t d[1];
+uint8_t e[1];
+uint16_t f[1];
+_Float16 g[1], k[1], m[1], p[1];
+uint16_t i[1];
+int8_t j[1];
+uint8_t o[1];
+uint32_t l[1];
+uint16_t q[1];
+uint32_t r[1];
+uint32_t s[1];
+int16_t t[1];
+int main()
+{
+  int u = 25;
+  int8_t *v = a;
+  uint32_t *w;
+  uint16_t *aa = b;
+  float *ab = c, *as = n;
+  uint32_t *ad;
+  uint16_t *ah = f;
+  _Float16 *ai = g, *aj = k, *an = m, *au = p;
+  int32_t *ak;
+  int16_t *al;
+  uint16_t *am = i;
+  int8_t *ao = j;
+  uint8_t *ap = o;
+  uint32_t *aq = l;
+  uint16_t *ar = q;
+  uint32_t *at = r;
+  uint32_t *av = s;
+  int32_t *ax;
+  int16_t *ay = t;
+  for (size_t az; u; u -= az)
+  {
+az = __riscv_vsetvl_e32m8(u);
+vint8m2_t ba = __riscv_vle8_v_i8m2(v, az);
+vbool4_t bb = __riscv_vmseq_vx_i8m2_b4(ba, 1, az);
+vuint16m4_t bc = __riscv_vsll_vx_u16m4(__riscv_vid_v_u16m4(az), 2, az);
+vuint32m8_t bd = __riscv_vsll_vx_u32m8(__riscv_vid_v_u32m8(az), 1, az);
+vuint32m8_t be = __riscv_vluxei16_v_u32m8_m(bb, w, bc, az);
+vuint16m4_t bf;
+__riscv_vsuxei16_v_u32m8_m(bb, aq, bf, be, az);
+vuint8m2_t bg = __riscv_vsll_vx_u8m2(__riscv_vid_v_u8m2(az), 1, az);
+vuint16m4_t bh = __riscv_vloxei8_v_u16m4(aa, bg, az);
+vfloat16m4_t bi;
+vuint16m4_t bj = __riscv_vsll_vx_u16m4(__riscv_vid_v_u16m4(az), 1, az);
+vint16m4_t bk = __riscv_vloxei32_v_i16m4_m(bb, al, bd, az);
+__riscv_vsse16_v_u16m4(ar, 2, bh, az);
+vuint16m4_t bl = __riscv_vloxei16_v_u16m4(d, bj, az);
+vfloat16m4_t bm = __riscv_vle16_v_f16m4(ai, az);
+vuint16m4_t bn = __riscv_vlse16_v_u16m4(ah, 2, az);
+vint32m8_t bo = __riscv_vle32_v_i32m8_m(bb, ak, az);
+vfloat16m1_t bp = __riscv_vle16_v_f16m1(aj, az);
+vuint16m4_t bq = __riscv_vrgatherei16_vv_u16m4(bl, bn, az);
+

[gcc(refs/users/mikael/heads/refactor_descriptor_v01)] gimple-exec: affichage valeur undef

2025-03-13 Thread Mikael Morin via Gcc-cvs
https://gcc.gnu.org/g:a39a9ecc71c8c253a844a767c984f74ed5ba41fa

commit a39a9ecc71c8c253a844a767c984f74ed5ba41fa
Author: Mikael Morin 
Date:   Thu Mar 13 09:46:18 2025 +0100

gimple-exec: affichage valeur undef

Diff:
---
 gcc/cgraphunit.cc | 174 +-
 1 file changed, 158 insertions(+), 16 deletions(-)

diff --git a/gcc/cgraphunit.cc b/gcc/cgraphunit.cc
index 9c5b7f5b882b..ec6ae33e0435 100644
--- a/gcc/cgraphunit.cc
+++ b/gcc/cgraphunit.cc
@@ -2442,6 +2442,7 @@ namespace selftest
   void exec_context_execute_assign_tests ();
   void exec_context_execute_call_tests ();
   void exec_context_allocate_tests ();
+  void exec_context_evaluate_condition_tests ();
 }
 
 
@@ -2663,6 +2664,7 @@ class exec_context
   data_value evaluate_constructor (tree cstr) const;
   data_value evaluate_unary (enum tree_code code, tree type, tree arg) const;
   data_value evaluate_binary (enum tree_code code, tree type, tree lhs, tree 
rhs) const;
+  bool evaluate_condition (gcond *cond) const;
   template 
   void add_variables (vec *variables, unsigned vars_count);
   template 
@@ -2689,6 +2691,7 @@ class exec_context
   friend void selftest::exec_context_execute_assign_tests ();
   friend void selftest::exec_context_execute_call_tests ();
   friend void selftest::exec_context_allocate_tests ();
+  friend void selftest::exec_context_evaluate_condition_tests ();
 
 public:
   exec_context (exec_context & caller, context_printer & printer,
@@ -3579,6 +3582,10 @@ context_printer::print_at (const data_value & value, 
tree type, unsigned offset,
  }
  break;
 
+   case VAL_UNDEFINED:
+ pp_string (&pp, "");
+ break;
+
default:
  gcc_unreachable ();
}
@@ -4348,6 +4355,59 @@ exec_context::execute (basic_block bb)
 }
 
 
+bool
+exec_context::evaluate_condition (gcond *cond) const
+{
+  enum tree_code code = gimple_cond_code (cond);
+  tree lhs = gimple_cond_lhs (cond);
+  tree rhs = gimple_cond_rhs (cond);
+
+  data_value val_lhs = evaluate (lhs);
+  data_value val_rhs = evaluate (rhs);
+
+  enum value_type lhs_type, rhs_type;
+  lhs_type = val_lhs.classify ();
+  rhs_type = val_rhs.classify ();
+  if (lhs_type == VAL_CONSTANT && rhs_type == VAL_CONSTANT)
+{
+  tree lval = val_lhs.to_tree (TREE_TYPE (lhs));
+  tree rval = val_rhs.to_tree (TREE_TYPE (rhs));
+
+  tree result = fold_binary (code, boolean_type_node, lval, rval);
+  gcc_assert (result != NULL_TREE);
+
+  if (integer_onep (result))
+   return true;
+  else if (integer_zerop (result))
+   return false;
+  else
+   gcc_unreachable ();
+}
+  else if ((lhs_type == VAL_CONSTANT && rhs_type == VAL_ADDRESS)
+  || (lhs_type == VAL_ADDRESS && rhs_type == VAL_CONSTANT))
+{
+  /* Comparison of an address against a null pointer.  */
+  data_value * null = nullptr;
+  if (lhs_type == VAL_CONSTANT)
+   null = &val_lhs;
+  else if (rhs_type == VAL_CONSTANT)
+   null = &val_rhs;
+  else
+   gcc_unreachable ();
+
+  gcc_assert (null->get_cst () == 0);
+  if (code == EQ_EXPR)
+   return false;
+  else if (code == NE_EXPR)
+   return true;
+  else
+   gcc_unreachable ();
+}
+  else
+gcc_unreachable ();
+}
+
+
 edge
 exec_context::select_leaving_edge (basic_block bb, gimple *last_stmt)
 {
@@ -4363,25 +4423,12 @@ exec_context::select_leaving_edge (basic_block bb, 
gimple *last_stmt)
 
   if (is_a  (last_stmt))
 {
-  gcond *cond = as_a  (last_stmt);
-
-  enum tree_code code = gimple_cond_code (cond);
-  tree lhs = gimple_cond_lhs (cond);
-  tree rhs = gimple_cond_rhs (cond);
-
-  tree lval = evaluate (lhs).to_tree (TREE_TYPE (lhs));
-  tree rval = evaluate (rhs).to_tree (TREE_TYPE (rhs));
-
-  tree result = fold_binary (code, boolean_type_node, lval, rval);
-  gcc_assert (result != NULL_TREE);
-
+  bool cond_result = evaluate_condition (as_a  (last_stmt));
   int flag;
-  if (integer_onep (result))
+  if (cond_result)
flag = EDGE_TRUE_VALUE;
-  else if (integer_zerop (result))
-   flag = EDGE_FALSE_VALUE;
   else
-   gcc_unreachable ();
+   flag = EDGE_FALSE_VALUE;
 
   edge e, selected = nullptr;
   edge_iterator ei;
@@ -5505,6 +5552,16 @@ data_value_print_tests ()
   printer9.print (v9, float_type_node);
 
   ASSERT_STREQ (pp_formatted_text (&pp9), "2.0e+0");
+
+
+  context_printer printer10;
+  pretty_printer & pp10 = printer10.pp;
+
+  data_value v10 (integer_type_node);
+
+  printer10.print (v10, integer_type_node);
+
+  ASSERT_STREQ (pp_formatted_text (&pp10), "");
 }
 
 
@@ -7067,6 +7124,90 @@ exec_context_evaluate_binary_tests ()
 }
 
 
+void
+exec_context_evaluate_condition_tests ()
+{
+  heap_memory mem1;
+  context_printer printer1;
+
+  tree a = create_var (integer_type_node, "a");
+  tree b = create_var (integer_type_node, "b");
+
+  vec decls1 {};
+  decls1.safe

[gcc r15-8023] libstdc++: Hide 128-bit int and float types behind handle for basic_format_arg visitation [PR108053]

2025-03-13 Thread Tomasz Kaminski via Gcc-cvs
https://gcc.gnu.org/g:22847ef193670e761ed205a4a6f0a694b939d4e4

commit r15-8023-g22847ef193670e761ed205a4a6f0a694b939d4e4
Author: Tomasz Kamiński 
Date:   Mon Mar 10 16:51:57 2025 +0100

libstdc++: Hide 128-bit int and float types behind handle for 
basic_format_arg visitation [PR108053]

Implement visit_format_arg and basic_format_arg::visit function,
in terms of  _M_visit_user member functions, that wraps any type
stored inside basic_format_arg, that is not specified in the standard,
into the handle. This affects __int128, unsigned __int128,
PowerPC specific __ieee128 and __ibm128, and _Float128 for architectures
where long double is not 128bits.

The bfloat16, _Float16, _Float32, _Float32, and _Float128 for
128bits long double are not are not addressed, as they
are transformed into a standard floating point types.

For internal purposes __format::__visit_format_arg function is
used, that provides an unmodified access to stored object.

PR libstdc++/108053

libstdc++-v3/ChangeLog:

* include/std/format (basic_format_arg::_M_visit_user):
Helper function for wrapping extension types into handle.
(visit_format_arg): Call `_M_visit_user` instead of `_M_visit`.
(basic_format_arg::visit): As above.
(__format::__visit_format_arg): Provides direct access to
values stored in basic_format_arg.
(__format::__int_from_arg): Use __format::__visit_format_arg
instead of std::visit_format_arg.
(_Formatting_scanner::_M_format_arg): As above.
(_Checking_scanner::__do_vformat_to): As above.
* testsuite/std/format/arguments/args.cc: New tests.
* testsuite/std/format/string.cc: Test for using __int128
as width/precision.

Reviewed-by: Jonathan Wakely 
Signed-off-by: Tomasz Kamiński 

Diff:
---
 libstdc++-v3/include/std/format| 49 ---
 .../testsuite/std/format/arguments/args.cc | 73 ++
 libstdc++-v3/testsuite/std/format/string.cc| 10 ++-
 3 files changed, 123 insertions(+), 9 deletions(-)

diff --git a/libstdc++-v3/include/std/format b/libstdc++-v3/include/std/format
index f52645a3ac75..1b38913359d1 100644
--- a/libstdc++-v3/include/std/format
+++ b/libstdc++-v3/include/std/format
@@ -3308,10 +3308,12 @@ namespace __format
   template
 class _Arg_store;
 
+  template
+decltype(auto) __visit_format_arg(_Visitor&&, basic_format_arg<_Ctx>);
+
   template
 consteval _Arg_t
 __to_arg_t_enum() noexcept;
-
 } // namespace __format
 /// @endcond
 
@@ -3383,12 +3385,12 @@ namespace __format
   template
decltype(auto)
visit(this basic_format_arg __arg, _Visitor&& __vis)
-   { return __arg._M_visit(std::forward<_Visitor>(__vis), __arg._M_type); }
+   { return __arg._M_visit_user(std::forward<_Visitor>(__vis), 
__arg._M_type); }
 
   template
_Res
visit(this basic_format_arg __arg, _Visitor&& __vis)
-   { return __arg._M_visit(std::forward<_Visitor>(__vis), __arg._M_type); }
+   { return __arg._M_visit_user(std::forward<_Visitor>(__vis), 
__arg._M_type); }
 #endif
 
 private:
@@ -3589,6 +3591,10 @@ namespace __format
friend decltype(auto)
visit_format_arg(_Visitor&& __vis, basic_format_arg<_Ctx>);
 
+  template
+   friend decltype(auto)
+   __format::__visit_format_arg(_Visitor&&, basic_format_arg<_Ctx>);
+
   template
friend consteval __format::_Arg_t
__format::__to_arg_t_enum() noexcept;
@@ -3657,6 +3663,28 @@ namespace __format
  __builtin_unreachable();
  }
}
+
+  template
+   decltype(auto)
+   _M_visit_user(_Visitor&& __vis, __format::_Arg_t __type)
+   {
+ return _M_visit([&__vis](_Tp& __val) -> decltype(auto)
+   {
+ constexpr bool __user_facing = __is_one_of<_Tp,
+   monostate, bool, _CharT,
+   int, unsigned int, long long int, unsigned long long int,
+   float, double, long double,
+   const _CharT*, basic_string_view<_CharT>,
+   const void*, handle>::value;
+if constexpr (__user_facing)
+  return std::forward<_Visitor>(__vis)(__val);
+else
+  {
+handle __h(__val);
+return std::forward<_Visitor>(__vis)(__h);
+  }
+  }, __type);
+   }
 };
 
   template
@@ -3664,12 +3692,19 @@ namespace __format
 inline decltype(auto)
 visit_format_arg(_Visitor&& __vis, basic_format_arg<_Context> __arg)
 {
-  return __arg._M_visit(std::forward<_Visitor>(__vis), __arg._M_type);
+  return __arg._M_visit_user(std::forward<_Visitor>(__vis), __arg._M_type);
 }
 
 /// @cond undocumented
 namespace __format
 {
+  template
+inline decltype(auto)
+

[gcc r15-8022] RISC-V: Do not delete fused vsetvl if it has uses [PR119115].

2025-03-13 Thread Robin Dapp via Gcc-cvs
https://gcc.gnu.org/g:77ef91d7159613c0cfc2920ddd5a32952c61ff5b

commit r15-8022-g77ef91d7159613c0cfc2920ddd5a32952c61ff5b
Author: Robin Dapp 
Date:   Wed Mar 5 18:16:57 2025 +0100

RISC-V: Do not delete fused vsetvl if it has uses [PR119115].

In PR119115 we end up with an orphaned
vsetvli zero,t1,e16,m1,ta,ma.
t1 originally came from another vsetvl that was fused from
vsetvli a4,a3,e8,mf2,ta,ma
vsetvli t1,a3,e8,mf2,ta,ma   (1)
to
vsetvli zero,a3,e16,m1,ta,ma.

This patch checks if t1, the VL operand of (1), has AVL uses and does
not delete the vsetvl if so.  While doing so, it also wraps the search
for VL uses into two new functions reg_used and reg_single_use_in_avl.

PR target/119115

gcc/ChangeLog:

* config/riscv/riscv-vsetvl.cc (reg_used): New function.
(reg_single_use_in_avl): Ditto.
(pre_vsetvl::fuse_local_vsetvl_info): Use reg_single_use_in_avl
when checking if vsetvl can be deleted.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/base/pr119115.c: New test.

Diff:
---
 gcc/config/riscv/riscv-vsetvl.cc   | 95 --
 gcc/testsuite/gcc.target/riscv/rvv/base/pr119115.c | 59 ++
 2 files changed, 131 insertions(+), 23 deletions(-)

diff --git a/gcc/config/riscv/riscv-vsetvl.cc b/gcc/config/riscv/riscv-vsetvl.cc
index f0165f7b8c8c..0ac2538f596f 100644
--- a/gcc/config/riscv/riscv-vsetvl.cc
+++ b/gcc/config/riscv/riscv-vsetvl.cc
@@ -780,6 +780,36 @@ enum class avl_demand_type : unsigned
   ignore_avl = demand_flags::DEMAND_EMPTY_P,
 };
 
+/* Go through all uses of INSN looking for a single use of register REG.
+   Return true if we find
+- Uses in a non-RVV insn
+- More than one use in an RVV insn
+- A single use in the VL operand of an RVV insn
+   and false otherwise.
+   A single use in the AVL operand does not count as use as we take care of
+   those separately in the pass.  */
+
+static bool
+reg_used (insn_info *insn, rtx reg)
+{
+  unsigned int regno = REGNO (reg);
+  const hash_set vl_uses = get_all_real_uses (insn, regno);
+  for (use_info *use : vl_uses)
+{
+  gcc_assert (use->insn ()->is_real ());
+  rtx_insn *rinsn = use->insn ()->rtl ();
+  if (!has_vl_op (rinsn)
+ || count_regno_occurrences (rinsn, regno) != 1)
+   return true;
+
+  rtx avl = ::get_avl (rinsn);
+  if (!avl || !REG_P (avl) || regno != REGNO (avl))
+   return true;
+}
+  return false;
+}
+
+
 class vsetvl_info
 {
 private:
@@ -1142,27 +1172,7 @@ public:
 
 /* Determine if dest operand(vl) has been used by non-RVV instructions.  */
 if (dest_vl)
-  {
-   const hash_set vl_uses
- = get_all_real_uses (get_insn (), REGNO (dest_vl));
-   for (use_info *use : vl_uses)
- {
-   gcc_assert (use->insn ()->is_real ());
-   rtx_insn *rinsn = use->insn ()->rtl ();
-   if (!has_vl_op (rinsn)
-   || count_regno_occurrences (rinsn, REGNO (dest_vl)) != 1)
- {
-   m_vl_used_by_non_rvv_insn = true;
-   break;
- }
-   rtx avl = ::get_avl (rinsn);
-   if (!avl || !REG_P (avl) || REGNO (dest_vl) != REGNO (avl))
- {
-   m_vl_used_by_non_rvv_insn = true;
-   break;
- }
- }
-  }
+  m_vl_used_by_non_rvv_insn = reg_used (get_insn (), dest_vl);
 
 /* Collect the read vl insn for the fault-only-first rvv loads.  */
 if (fault_first_load_p (insn->rtl ()))
@@ -1369,6 +1379,35 @@ public:
   void set_empty_info () { global_info.set_empty (); }
 };
 
+/* Same as REG_USED () but looks for a single use in an RVV insn's AVL
+   operand.  */
+static bool
+reg_single_use_in_avl (insn_info *insn, rtx reg)
+{
+  if (!reg)
+return false;
+  unsigned int regno = REGNO (reg);
+  const hash_set vl_uses = get_all_real_uses (insn, regno);
+  for (use_info *use : vl_uses)
+{
+  gcc_assert (use->insn ()->is_real ());
+  rtx_insn *rinsn = use->insn ()->rtl ();
+  if (!has_vl_op (rinsn)
+ || count_regno_occurrences (rinsn, regno) != 1)
+   return false;
+
+  vsetvl_info info = vsetvl_info (use->insn ());
+
+  if (!info.has_nonvlmax_reg_avl ())
+   return false;
+
+  rtx avl = info.get_avl ();
+  if (avl && REG_P (avl) && regno == REGNO (avl))
+   return true;
+}
+  return false;
+}
+
 /* Demand system is the RVV-based VSETVL info analysis tools wrapper.
It defines compatible rules for SEW/LMUL, POLICY and AVL.
Also, it provides 3 interfaces available_p, compatible_p and
@@ -2797,8 +2836,18 @@ pre_vsetvl::fuse_local_vsetvl_info ()
 64 into 32.  */
  prev_info.set_max_sew (
MIN (prev_info.get_max_sew (), curr_info.get_max_sew ()));
- if (!curr_info.vl_use

[gcc(refs/users/mikael/heads/refactor_descriptor_v01)] Correction régression select_type_26.f03

2025-03-13 Thread Mikael Morin via Gcc-cvs
https://gcc.gnu.org/g:0772b835b1f3c37c0ec5ea9e7554090bf164345c

commit 0772b835b1f3c37c0ec5ea9e7554090bf164345c
Author: Mikael Morin 
Date:   Thu Mar 13 11:08:37 2025 +0100

Correction régression select_type_26.f03

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

diff --git a/gcc/fortran/trans-types.cc b/gcc/fortran/trans-types.cc
index 7c481490eb1c..ff43cb1522a0 100644
--- a/gcc/fortran/trans-types.cc
+++ b/gcc/fortran/trans-types.cc
@@ -3222,6 +3222,9 @@ gfc_get_derived_type (gfc_symbol * derived, int codimen)
GFC_DECL_PTR_ARRAY_P (c->backend_decl) = 1;
 }
 
+  if (derived->attr.is_class)
+GFC_CLASS_TYPE_P (typenode) = 1;
+
   /* Now lay out the derived type, including the fields.  */
   if (canonical)
 TYPE_CANONICAL (typenode) = canonical;