[gcc r16-821] libstdc++: Define _Scoped_allocation RAII helper

2025-05-22 Thread Tomasz Kaminski via Libstdc++-cvs
https://gcc.gnu.org/g:0faa31da113768a626daa294e840ff1b17499ebf

commit r16-821-g0faa31da113768a626daa294e840ff1b17499ebf
Author: Jonathan Wakely 
Date:   Thu May 22 10:58:31 2025 +0200

libstdc++: Define _Scoped_allocation RAII helper

libstdc++-v3/ChangeLog:

* include/bits/allocated_ptr.h (_Scoped_allocation): New class
template.

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

Diff:
---
 libstdc++-v3/include/bits/allocated_ptr.h | 96 +++
 1 file changed, 96 insertions(+)

diff --git a/libstdc++-v3/include/bits/allocated_ptr.h 
b/libstdc++-v3/include/bits/allocated_ptr.h
index 0b2b6fe5820e..aa5355f0e2fc 100644
--- a/libstdc++-v3/include/bits/allocated_ptr.h
+++ b/libstdc++-v3/include/bits/allocated_ptr.h
@@ -36,6 +36,7 @@
 # include 
 # include 
 # include 
+# include 
 
 namespace std _GLIBCXX_VISIBILITY(default)
 {
@@ -136,6 +137,101 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   return { std::__allocate_guarded(__a) };
 }
 
+  // An RAII type that acquires memory from an allocator.
+  // N.B.  'scoped' here in in the RAII sense, not the scoped allocator model,
+  // so this has nothing to do with `std::scoped_allocator_adaptor`.
+  // This class can be used to simplify the common pattern:
+  //
+  // auto ptr = alloc.allocate(1);
+  // try {
+  //   std::construct_at(std::to_address(ptr), args);
+  //   m_ptr = ptr;
+  // } catch (...) {
+  //   alloc.deallocate(ptr, 1);
+  //   throw;
+  // }
+  //
+  // Instead you can do:
+  //
+  // _Scoped_allocation sa(alloc);
+  // m_ptr = std::construct_at(sa.get(), args);
+  // (void) sa.release();
+  //
+  // Or even simpler:
+  //
+  // _Scoped_allocation sa(alloc, std::in_place, args);
+  // m_ptr = sa.release();
+  //
+  template
+struct _Scoped_allocation
+{
+  using value_type = typename allocator_traits<_Alloc>::value_type;
+  using pointer = typename allocator_traits<_Alloc>::pointer;
+
+  // Use `a` to allocate memory for `n` objects.
+  constexpr explicit
+  _Scoped_allocation(const _Alloc& __a, size_t __n = 1)
+  : _M_a(__a), _M_n(__n), _M_p(_M_a.allocate(__n))
+  { }
+
+#if __glibcxx_optional >= 201606L
+  // Allocate memory for a single object and if that succeeds,
+  // construct an object using args.
+  //
+  // Does not do uses-allocator construction; don't use if you need that.
+  //
+  // CAUTION: the destructor will *not* destroy this object, it will only
+  // free the memory. That means the following pattern is unsafe:
+  //
+  // _Scoped_allocation  sa(alloc, in_place, args);
+  // potentially_throwing_operations();
+  // return sa.release();
+  //
+  // If the middle operation throws, the object will not be destroyed.
+  template
+   constexpr explicit
+   _Scoped_allocation(const _Alloc& __a, in_place_t, _Args&&... __args)
+   : _Scoped_allocation(__a, 1)
+   {
+ // The target constructor has completed, so if the next line throws,
+ // the destructor will deallocate the memory.
+ allocator_traits<_Alloc>::construct(_M_a, get(),
+ std::forward<_Args>(__args)...);
+   }
+#endif
+
+  _GLIBCXX20_CONSTEXPR
+  ~_Scoped_allocation()
+  {
+   if (_M_p) [[__unlikely__]]
+ _M_a.deallocate(_M_p, _M_n);
+  }
+
+  _Scoped_allocation(_Scoped_allocation&&) = delete;
+
+  constexpr _Alloc
+  get_allocator() const noexcept { return _M_a; }
+
+  constexpr value_type*
+  get() const noexcept
+  { return std::__to_address(_M_p); }
+
+  [[__nodiscard__]]
+  constexpr pointer
+  release() noexcept { return std::__exchange(_M_p, nullptr); }
+
+private:
+  [[__no_unique_address__]] _Alloc _M_a;
+  size_t _M_n;
+  pointer _M_p;
+};
+
+#if __glibcxx_optional >= 201606L && __cpp_deduction_guides >= 201606L
+  template
+_Scoped_allocation(_Alloc, in_place_t, _Args...)
+  -> _Scoped_allocation<_Alloc>;
+#endif
+
 /// @endcond
 _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace std


[gcc r16-822] expand: Use rtx_cost directly instead of gen_move_insn for canonicalize_comparison.

2025-05-22 Thread Andrew Pinski via Gcc-cvs
https://gcc.gnu.org/g:21a487046f4acda0d7d3aaed08a99501bd0430d3

commit r16-822-g21a487046f4acda0d7d3aaed08a99501bd0430d3
Author: Andrew Pinski 
Date:   Tue May 20 14:48:58 2025 -0700

expand: Use rtx_cost directly instead of gen_move_insn for 
canonicalize_comparison.

This is the first part in fixing PR target/120372.
The current code for canonicalize_comparison, uses gen_move_insn and 
rtx_cost to find
out the cost of generating a constant. This is ok in most cases except 
sometimes
the comparison instruction can handle different constants than a simple set
intruction can do. This changes to use rtx_cost directly with the outer 
being COMPARE
just like how prepare_cmp_insn handles that.

Note this is also a small speedup and small memory improvement because we 
are not creating
a move for the constant any more. Since we are not creating a 
psedu-register any more, this
also removes the check on that.

Also adds a dump so we can see why one choice was chosen over the other.

Build and tested for aarch64-linux-gnu.

gcc/ChangeLog:

* expmed.cc (canonicalize_comparison): Use rtx_cost directly
instead of gen_move_insn. Print out the choice if dump is enabled.

Signed-off-by: Andrew Pinski 

Diff:
---
 gcc/expmed.cc | 23 +++
 1 file changed, 15 insertions(+), 8 deletions(-)

diff --git a/gcc/expmed.cc b/gcc/expmed.cc
index 72dbafe5d9f8..d5da199d033d 100644
--- a/gcc/expmed.cc
+++ b/gcc/expmed.cc
@@ -6408,18 +6408,25 @@ canonicalize_comparison (machine_mode mode, enum 
rtx_code *code, rtx *imm)
   if (overflow)
 return;
 
-  /* The following creates a pseudo; if we cannot do that, bail out.  */
-  if (!can_create_pseudo_p ())
-return;
-
-  rtx reg = gen_rtx_REG (mode, LAST_VIRTUAL_REGISTER + 1);
   rtx new_imm = immed_wide_int_const (imm_modif, mode);
 
-  rtx_insn *old_rtx = gen_move_insn (reg, *imm);
-  rtx_insn *new_rtx = gen_move_insn (reg, new_imm);
+  int old_cost = rtx_cost (*imm, mode, COMPARE, 0, true);
+  int new_cost = rtx_cost (new_imm, mode, COMPARE, 0, true);
+
+  if (dump_file && (dump_flags & TDF_DETAILS))
+{
+  fprintf (dump_file, ";; cmp: %s, old cst: ",
+  GET_RTX_NAME (*code));
+  print_rtl (dump_file, *imm);
+  fprintf (dump_file, " new cst: ");
+  print_rtl (dump_file, new_imm);
+  fprintf (dump_file, "\n");
+  fprintf (dump_file, ";; old cst cost: %d, new cst cost: %d\n",
+  old_cost, new_cost);
+}
 
   /* Update the immediate and the code.  */
-  if (insn_cost (old_rtx, true) > insn_cost (new_rtx, true))
+  if (old_cost > new_cost)
 {
   *code = equivalent_cmp_code (*code);
   *imm = new_imm;


[gcc r16-824] [PATCH][RISC-V][PR target/70557] Improve storing 0 to memory on rv32

2025-05-22 Thread Jeff Law via Gcc-cvs
https://gcc.gnu.org/g:c77085970ec98916e12e079a5a9d9530b86aae71

commit r16-824-gc77085970ec98916e12e079a5a9d9530b86aae71
Author: Siarhei Volkau 
Date:   Thu May 22 08:52:17 2025 -0600

[PATCH][RISC-V][PR target/70557] Improve storing 0 to memory on rv32

Patch is originally from Siarhei Volkau .

RISC-V has a zero register (x0) which we can use to store zero into memory
without loading the constant into a distinct register. Adjust the 
constraints
of the 32-bit movdi_32bit pattern to recognize that we can store 0.0 into
memory using x0 as the source register.

This patch only affects RISC-V. It has been regression tested on 
riscv64-elf.
Jeff has also tested this in his tester (riscv64-elf and riscv32-elf) with 
no
regressions.

PR target/70557
gcc/
* config/riscv/riscv.md (movdi_32bit): Add "J" constraint to allow 
storing 0
directly to memory.

Diff:
---
 gcc/config/riscv/riscv.md | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gcc/config/riscv/riscv.md b/gcc/config/riscv/riscv.md
index a5b3abbe5d45..92fe7c7741a2 100644
--- a/gcc/config/riscv/riscv.md
+++ b/gcc/config/riscv/riscv.md
@@ -2501,8 +2501,8 @@
 })
 
 (define_insn "*movdi_32bit"
-  [(set (match_operand:DI 0 "nonimmediate_operand" "=r,r,r,m,  
*f,*f,*r,*f,*m,r")
-   (match_operand:DI 1 "move_operand" " 
r,i,m,r,*J*r,*m,*f,*f,*f,vp"))]
+  [(set (match_operand:DI 0 "nonimmediate_operand" "=r,r,r, m,  
*f,*f,*r,*f,*m,r")
+   (match_operand:DI 1 "move_operand" " 
r,i,m,rJ,*J*r,*m,*f,*f,*f,vp"))]
   "!TARGET_64BIT
&& (register_operand (operands[0], DImode)
|| reg_or_0_operand (operands[1], DImode))"


[gcc/devel/omp/gcc-15] GCN, nvptx offloading: Restrain 'WARNING: program timed out.' while in 'dynamic_cast'" [PR119692]

2025-05-22 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:3a3b24aec2a849efff37433e28617ec6fd18ad2e

commit 3a3b24aec2a849efff37433e28617ec6fd18ad2e
Author: Thomas Schwinge 
Date:   Fri May 9 14:49:03 2025 +0200

GCN, nvptx offloading: Restrain 'WARNING: program timed out.' while in 
'dynamic_cast'" [PR119692]

PR target/119692
libgomp/
* testsuite/libgomp.c++/pr119692-1-4.C: '{ dg-timeout 10 }'.
* testsuite/libgomp.c++/pr119692-1-5.C: Likewise.
* testsuite/libgomp.c++/target-exceptions-bad_cast-1.C: Likewise.
* testsuite/libgomp.c++/target-exceptions-bad_cast-2.C: Likewise.
* testsuite/libgomp.oacc-c++/exceptions-bad_cast-1.C: Likewise.
* testsuite/libgomp.oacc-c++/exceptions-bad_cast-2.C: Likewise.

(cherry picked from commit b5f48e7872db30b8f174cb2c497868a358bf75d6)

Diff:
---
 libgomp/testsuite/libgomp.c++/pr119692-1-4.C | 3 +++
 libgomp/testsuite/libgomp.c++/pr119692-1-5.C | 3 +++
 libgomp/testsuite/libgomp.c++/target-exceptions-bad_cast-1.C | 3 +++
 libgomp/testsuite/libgomp.c++/target-exceptions-bad_cast-2.C | 3 +++
 libgomp/testsuite/libgomp.oacc-c++/exceptions-bad_cast-1.C   | 3 +++
 libgomp/testsuite/libgomp.oacc-c++/exceptions-bad_cast-2.C   | 3 +++
 6 files changed, 18 insertions(+)

diff --git a/libgomp/testsuite/libgomp.c++/pr119692-1-4.C 
b/libgomp/testsuite/libgomp.c++/pr119692-1-4.C
index 6995f2633328..af9fe1c8c183 100644
--- a/libgomp/testsuite/libgomp.c++/pr119692-1-4.C
+++ b/libgomp/testsuite/libgomp.c++/pr119692-1-4.C
@@ -3,6 +3,9 @@
 /* { dg-additional-options -DDEFAULT=defaultmap(firstprivate) }
Wrong code for offloading execution.
{ dg-xfail-run-if PR119692 { offload_device } } */
+/* There are configurations where we 'WARNING: program timed out.' while in
+   'dynamic_cast', see 
.
+   { dg-timeout 10 } ... to make sure that happens quickly.  */
 /* { dg-additional-options -fdump-tree-gimple } */
 
 #include "pr119692-1-1.C"
diff --git a/libgomp/testsuite/libgomp.c++/pr119692-1-5.C 
b/libgomp/testsuite/libgomp.c++/pr119692-1-5.C
index 02121b6e9c51..e5c6e077fc8d 100644
--- a/libgomp/testsuite/libgomp.c++/pr119692-1-5.C
+++ b/libgomp/testsuite/libgomp.c++/pr119692-1-5.C
@@ -3,6 +3,9 @@
 /* { dg-additional-options -DDEFAULT=defaultmap(to) }
Wrong code for offloading execution.
{ dg-xfail-run-if PR119692 { offload_device } } */
+/* There are configurations where we 'WARNING: program timed out.' while in
+   'dynamic_cast', see 
.
+   { dg-timeout 10 } ... to make sure that happens quickly.  */
 /* { dg-additional-options -fdump-tree-gimple } */
 
 #include "pr119692-1-1.C"
diff --git a/libgomp/testsuite/libgomp.c++/target-exceptions-bad_cast-1.C 
b/libgomp/testsuite/libgomp.c++/target-exceptions-bad_cast-1.C
index 3848295fbabc..a862652f4a8e 100644
--- a/libgomp/testsuite/libgomp.c++/target-exceptions-bad_cast-1.C
+++ b/libgomp/testsuite/libgomp.c++/target-exceptions-bad_cast-1.C
@@ -23,3 +23,6 @@
PR119692.
 
{ dg-shouldfail {'std::bad_cast' exception} } */
+/* There are configurations where we 'WARNING: program timed out.' while in
+   'dynamic_cast', see 
.
+   { dg-timeout 10 } ... to make sure that happens quickly.  */
diff --git a/libgomp/testsuite/libgomp.c++/target-exceptions-bad_cast-2.C 
b/libgomp/testsuite/libgomp.c++/target-exceptions-bad_cast-2.C
index 88617400a723..ff15c9fa61f6 100644
--- a/libgomp/testsuite/libgomp.c++/target-exceptions-bad_cast-2.C
+++ b/libgomp/testsuite/libgomp.c++/target-exceptions-bad_cast-2.C
@@ -22,3 +22,6 @@
 
For GCN, nvptx offload execution, there is no 'catch'ing; any exception is 
fatal.
{ dg-shouldfail {'MyException' exception} { offload_device } } */
+/* There are configurations where we 'WARNING: program timed out.' while in
+   'dynamic_cast', see 
.
+   { dg-timeout 10 } ... to make sure that happens quickly.  */
diff --git a/libgomp/testsuite/libgomp.oacc-c++/exceptions-bad_cast-1.C 
b/libgomp/testsuite/libgomp.oacc-c++/exceptions-bad_cast-1.C
index 05456011ca1d..6957a6caec70 100644
--- a/libgomp/testsuite/libgomp.oacc-c++/exceptions-bad_cast-1.C
+++ b/libgomp/testsuite/libgomp.oacc-c++/exceptions-bad_cast-1.C
@@ -52,3 +52,6 @@ int main()
PR119692.
 
{ dg-shouldfail {'std::bad_cast' exception} } */
+/* There are configurations where we 'WARNING: program timed out.' while in
+   'dynamic_cast', see 
.
+   { dg-timeout 10 } ... to make sure that happens quickly.  */
diff --git a/libgomp/testsuite/libgomp.oacc-c++/exceptions-bad_cast-2.C 
b/libgomp/testsuite/libgomp.oacc-c++/exceptions-bad_cast-2.C
index 24399eff978b..0f84cf212c25 100644
--- a/libgomp/testsuite/libgomp.oacc-c++/exceptions-bad_cast-2.C
+++ b/libgomp/testsui

[gcc/devel/omp/gcc-15] 'TYPE_EMPTY_P' vs. code offloading [PR120308]

2025-05-22 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:0ae12e55c09c46bd477e377e3dfc567478a607c0

commit 0ae12e55c09c46bd477e377e3dfc567478a607c0
Author: Thomas Schwinge 
Date:   Thu May 15 18:11:16 2025 +0200

'TYPE_EMPTY_P' vs. code offloading [PR120308]

We've got 'gcc/stor-layout.cc:finalize_type_size':

/* Handle empty records as per the x86-64 psABI.  */
TYPE_EMPTY_P (type) = targetm.calls.empty_record_p (type);

(Indeed x86_64 is still the only target to define 'TARGET_EMPTY_RECORD_P',
calling 'gcc/tree.cc-default_is_empty_record'.)

And so it happens that for an empty struct used in code offloaded from 
x86_64
host (but not powerpc64le host, for example), we get to see 'TYPE_EMPTY_P' 
in
offloading compilation (where the offload targets (currently?) don't use it
themselves, and therefore aren't prepared to handle it).

For nvptx offloading compilation, this causes wrong code generation:
'ptxas [...] error : Call has wrong number of parameters', as nvptx code
generation for function definition doesn't pay attention to this flag (say, 
in
'gcc/config/nvptx/nvptx.cc:pass_in_memory', or whereever else would be
appropriate to handle that), but the generic code 'gcc/calls.cc:expand_call'
via 'gcc/function.cc:aggregate_value_p' does pay attention to it, and we 
thus
get mismatching function definition vs. function call.

This issue apparently isn't a problem for GCN offloading, but I don't know 
if
that's by design or by accident.

Richard Biener:
> It looks like TYPE_EMPTY_P is only used during RTL expansion for ABI
> purposes, so computing it during layout_type is premature as shown here.
>
> I would suggest to simply re-compute it at offload stream-in time.

(For avoidance of doubt, the additions to 
'gcc.target/nvptx/abi-struct-arg.c',
'gcc.target/nvptx/abi-struct-ret.c' are not dependent on the offload 
streaming
code changes, but are just to mirror the changes to
'libgomp.oacc-c-c++-common/abi-struct-1.c'.)

PR lto/120308
gcc/
* lto-streamer-out.cc (hash_tree): Don't handle 'TYPE_EMPTY_P' for
'lto_stream_offload_p'.
* tree-streamer-in.cc (unpack_ts_type_common_value_fields):
Likewise.
* tree-streamer-out.cc (pack_ts_type_common_value_fields):
Likewise.
libgomp/
* testsuite/libgomp.oacc-c-c++-common/abi-struct-1.c: Add empty
structure testing.
gcc/testsuite/
* gcc.target/nvptx/abi-struct-arg.c: Add empty structure testing.
* gcc.target/nvptx/abi-struct-ret.c: Likewise.

(cherry picked from commit 9063810c86beee6274d745b91d8fb43a81c9683e)

Diff:
---
 gcc/lto-streamer-out.cc|  3 ++-
 gcc/testsuite/gcc.target/nvptx/abi-struct-arg.c| 10 +
 gcc/testsuite/gcc.target/nvptx/abi-struct-ret.c| 11 ++
 gcc/tree-streamer-in.cc| 12 ++-
 gcc/tree-streamer-out.cc   |  3 ++-
 .../libgomp.oacc-c-c++-common/abi-struct-1.c   | 25 ++
 6 files changed, 61 insertions(+), 3 deletions(-)

diff --git a/gcc/lto-streamer-out.cc b/gcc/lto-streamer-out.cc
index a055d12d6bed..8efda29f7676 100644
--- a/gcc/lto-streamer-out.cc
+++ b/gcc/lto-streamer-out.cc
@@ -1376,7 +1376,8 @@ hash_tree (struct streamer_tree_cache_d *cache, 
hash_map *map,
   hstate.commit_flag ();
   hstate.add_int (TYPE_PRECISION_RAW (t));
   hstate.add_int (TYPE_ALIGN (t));
-  hstate.add_int (TYPE_EMPTY_P (t));
+  if (!lto_stream_offload_p)
+   hstate.add_int (TYPE_EMPTY_P (t));
 }
 
   if (CODE_CONTAINS_STRUCT (code, TS_TRANSLATION_UNIT_DECL))
diff --git a/gcc/testsuite/gcc.target/nvptx/abi-struct-arg.c 
b/gcc/testsuite/gcc.target/nvptx/abi-struct-arg.c
index 54ae651dccaa..c2cc4de115e4 100644
--- a/gcc/testsuite/gcc.target/nvptx/abi-struct-arg.c
+++ b/gcc/testsuite/gcc.target/nvptx/abi-struct-arg.c
@@ -3,12 +3,16 @@
 
 /* Struct arg.  Passed via pointer.  */
 
+typedef struct {} empty;  /* See 'gcc/doc/extend.texi', "Empty Structures".  */
 typedef struct {char a;} one;
 typedef struct {short a;} two;
 typedef struct {int a;} four;
 typedef struct {long long a;} eight;
 typedef struct {int a, b[12];} big;
 
+/* { dg-final { scan-assembler-times ".extern .func dcl_aempty \\(.param.u64 
%\[_a-z0-9\]*\\);" 1 } } */
+void dcl_aempty (empty);
+
 /* { dg-final { scan-assembler-times ".extern .func dcl_aone \\(.param.u64 
%\[_a-z0-9\]*\\);" 1 } } */
 void dcl_aone (one);
 
@@ -28,6 +32,7 @@ void dcl_abig (big);
 
 void test_1 (void)
 {
+  dcl_aempty (({empty t; t;}));
   dcl_aone (M (one, 1));
   dcl_atwo (M (two, 2));
   dcl_afour (M (four, 3));
@@ -35,6 +40,11 @@ void test_1 (void)
   dcl_abig (M (big, 5));
 }
 
+/* { dg-final { scan-assembler-times ".visible .func dfn_aempty \\(.param.u64 
%\[_a-z0-9\]*\\)(?:;|\

[gcc/devel/omp/gcc-15] ChangeLog.omp bump

2025-05-22 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:e841798c07dc20df9fca82c7093d42576342632e

commit e841798c07dc20df9fca82c7093d42576342632e
Author: Thomas Schwinge 
Date:   Thu May 22 18:15:14 2025 +0200

ChangeLog.omp bump

Diff:
---
 gcc/ChangeLog.omp   | 13 +
 gcc/testsuite/ChangeLog.omp |  9 +
 libgomp/ChangeLog.omp   | 30 ++
 3 files changed, 52 insertions(+)

diff --git a/gcc/ChangeLog.omp b/gcc/ChangeLog.omp
index d522b49914cf..eaeb97f7f2ee 100644
--- a/gcc/ChangeLog.omp
+++ b/gcc/ChangeLog.omp
@@ -1,3 +1,16 @@
+2025-05-22  Thomas Schwinge  
+
+   Backported from master:
+   2025-05-19  Thomas Schwinge  
+
+   PR lto/120308
+   * lto-streamer-out.cc (hash_tree): Don't handle 'TYPE_EMPTY_P' for
+   'lto_stream_offload_p'.
+   * tree-streamer-in.cc (unpack_ts_type_common_value_fields):
+   Likewise.
+   * tree-streamer-out.cc (pack_ts_type_common_value_fields):
+   Likewise.
+
 2025-05-15  Sandra Loosemore  
Tobias Burnus  
 
diff --git a/gcc/testsuite/ChangeLog.omp b/gcc/testsuite/ChangeLog.omp
index a2bb7f052bf1..621a45de7643 100644
--- a/gcc/testsuite/ChangeLog.omp
+++ b/gcc/testsuite/ChangeLog.omp
@@ -1,3 +1,12 @@
+2025-05-22  Thomas Schwinge  
+
+   Backported from master:
+   2025-05-19  Thomas Schwinge  
+
+   PR lto/120308
+   * gcc.target/nvptx/abi-struct-arg.c: Add empty structure testing.
+   * gcc.target/nvptx/abi-struct-ret.c: Likewise.
+
 2025-05-15  Sandra Loosemore  
Tobias Burnus  
 
diff --git a/libgomp/ChangeLog.omp b/libgomp/ChangeLog.omp
index 9823e5833a1f..8ee1287d2be6 100644
--- a/libgomp/ChangeLog.omp
+++ b/libgomp/ChangeLog.omp
@@ -1,3 +1,33 @@
+2025-05-22  Thomas Schwinge  
+
+   Backported from master:
+   2025-05-19  Thomas Schwinge  
+
+   PR lto/120308
+   * testsuite/libgomp.oacc-c-c++-common/abi-struct-1.c: Add empty
+   structure testing.
+
+2025-05-22  Thomas Schwinge  
+
+   Backported from master:
+   2025-05-19  Thomas Schwinge  
+
+   * testsuite/libgomp.c-c++-common/target-abi-struct-1-O0.c: New.
+   * testsuite/libgomp.oacc-c-c++-common/abi-struct-1.c: Likewise.
+
+2025-05-22  Thomas Schwinge  
+
+   Backported from master:
+   2025-05-12  Thomas Schwinge  
+
+   PR target/119692
+   * testsuite/libgomp.c++/pr119692-1-4.C: '{ dg-timeout 10 }'.
+   * testsuite/libgomp.c++/pr119692-1-5.C: Likewise.
+   * testsuite/libgomp.c++/target-exceptions-bad_cast-1.C: Likewise.
+   * testsuite/libgomp.c++/target-exceptions-bad_cast-2.C: Likewise.
+   * testsuite/libgomp.oacc-c++/exceptions-bad_cast-1.C: Likewise.
+   * testsuite/libgomp.oacc-c++/exceptions-bad_cast-2.C: Likewise.
+
 2025-05-16  Tobias Burnus  
 
Backported from master:


[gcc/devel/omp/gcc-15] Add 'libgomp.c-c++-common/target-abi-struct-1-O0.c', 'libgomp.oacc-c-c++-common/abi-struct-1.c'

2025-05-22 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:d83af9fe9929772362a78d76084fcf485fa04dca

commit d83af9fe9929772362a78d76084fcf485fa04dca
Author: Thomas Schwinge 
Date:   Thu May 15 18:10:05 2025 +0200

Add 'libgomp.c-c++-common/target-abi-struct-1-O0.c', 
'libgomp.oacc-c-c++-common/abi-struct-1.c'

libgomp/
* testsuite/libgomp.c-c++-common/target-abi-struct-1-O0.c: New.
* testsuite/libgomp.oacc-c-c++-common/abi-struct-1.c: Likewise.

(cherry picked from commit 45efda05c47f770a617b44cf85713a696bcf0384)

Diff:
---
 .../libgomp.c-c++-common/target-abi-struct-1-O0.c  |  3 +
 .../libgomp.oacc-c-c++-common/abi-struct-1.c   | 96 ++
 2 files changed, 99 insertions(+)

diff --git a/libgomp/testsuite/libgomp.c-c++-common/target-abi-struct-1-O0.c 
b/libgomp/testsuite/libgomp.c-c++-common/target-abi-struct-1-O0.c
new file mode 100644
index ..35ec75d648d3
--- /dev/null
+++ b/libgomp/testsuite/libgomp.c-c++-common/target-abi-struct-1-O0.c
@@ -0,0 +1,3 @@
+/* { dg-additional-options -O0 } */
+
+#include "../libgomp.oacc-c-c++-common/abi-struct-1.c"
diff --git a/libgomp/testsuite/libgomp.oacc-c-c++-common/abi-struct-1.c 
b/libgomp/testsuite/libgomp.oacc-c-c++-common/abi-struct-1.c
new file mode 100644
index ..379e9fd3a977
--- /dev/null
+++ b/libgomp/testsuite/libgomp.oacc-c-c++-common/abi-struct-1.c
@@ -0,0 +1,96 @@
+/* Inspired by 'gcc.target/nvptx/abi-struct-arg.c', 
'gcc.target/nvptx/abi-struct-ret.c'.  */
+
+/* See also '../libgomp.c-c++-common/target-abi-struct-1-O0.c'.  */
+
+typedef struct {char a;} schar;
+typedef struct {short a;} sshort;
+typedef struct {int a;} sint;
+typedef struct {long long a;} slonglong;
+typedef struct {int a, b[12];} sint_13;
+
+#pragma omp declare target
+
+#define M(T) ({T t; t.a = sizeof t; t;})
+
+#pragma acc routine
+static schar rschar(void)
+{
+  return M(schar);
+}
+
+#pragma acc routine
+static sshort rsshort(void)
+{
+  return M(sshort);
+}
+
+#pragma acc routine
+static sint rsint(void)
+{
+  return M(sint);
+}
+
+#pragma acc routine
+static slonglong rslonglong(void)
+{
+  return M(slonglong);
+}
+
+#pragma acc routine
+static sint_13 rsint_13(void)
+{
+  return M(sint_13);
+}
+
+#pragma acc routine
+static void aschar(schar schar)
+{
+  if (schar.a != sizeof (char))
+__builtin_abort();
+}
+
+#pragma acc routine
+static void asshort(sshort sshort)
+{
+  if (sshort.a != sizeof (short))
+__builtin_abort();
+}
+
+#pragma acc routine
+static void asint(sint sint)
+{
+  if (sint.a != sizeof (int))
+__builtin_abort();
+}
+
+#pragma acc routine
+static void aslonglong(slonglong slonglong)
+{
+  if (slonglong.a != sizeof (long long))
+__builtin_abort();
+}
+
+#pragma acc routine
+static void asint_13(sint_13 sint_13)
+{
+  if (sint_13.a != (sizeof (int) * 13))
+__builtin_abort();
+}
+
+#pragma omp end declare target
+
+int main()
+{
+#pragma omp target
+#pragma acc serial
+  /* { dg-bogus {using 'vector_length \(32\)', ignoring 1} {} { target 
openacc_nvidia_accel_selected xfail *-*-* } .-1 } */
+  {
+aschar(rschar());
+asshort(rsshort());
+asint(rsint());
+aslonglong(rslonglong());
+asint_13(rsint_13());
+  }
+
+  return 0;
+}


[gcc(refs/users/meissner/heads/work206-bugs)] Revert changes

2025-05-22 Thread Michael Meissner via Gcc-cvs
https://gcc.gnu.org/g:9e4e7275743b9a7588712923cef5872f109f30f7

commit 9e4e7275743b9a7588712923cef5872f109f30f7
Author: Michael Meissner 
Date:   Thu May 22 15:08:12 2025 -0400

Revert changes

Diff:
---
 gcc/config/rs6000/predicates.md |   6 +-
 gcc/config/rs6000/rs6000-protos.h   |   1 -
 gcc/config/rs6000/rs6000.cc |  24 -
 gcc/config/rs6000/rs6000.h  |  15 +--
 gcc/config/rs6000/rs6000.md |  12 +--
 gcc/testsuite/gcc.target/powerpc/pr118541.c | 147 
 6 files changed, 13 insertions(+), 192 deletions(-)

diff --git a/gcc/config/rs6000/predicates.md b/gcc/config/rs6000/predicates.md
index 3a82113833c3..647e89afb6a7 100644
--- a/gcc/config/rs6000/predicates.md
+++ b/gcc/config/rs6000/predicates.md
@@ -1465,9 +1465,9 @@
 
 ;; Return 1 if OP is a comparison operator suitable for vector/scalar
 ;; comparisons that generate a 0/-1 mask (i.e. the inverse of
-;; fpmask_comparison_operator when the arguments are swapped).
-(define_predicate "fpmask_reverse_args_comparison_operator"
-  (match_code "ne,lt,le"))
+;; fpmask_comparison_operator).
+(define_predicate "invert_fpmask_comparison_operator"
+  (match_code "ne,unlt,unle"))
 
 ;; Return 1 if OP is a comparison operation suitable for integer vector/scalar
 ;; comparisons that generate a -1/0 mask.
diff --git a/gcc/config/rs6000/rs6000-protos.h 
b/gcc/config/rs6000/rs6000-protos.h
index f3cbfbfe5a13..4619142d197b 100644
--- a/gcc/config/rs6000/rs6000-protos.h
+++ b/gcc/config/rs6000/rs6000-protos.h
@@ -116,7 +116,6 @@ extern const char *rs6000_indirect_sibcall_template (rtx *, 
unsigned int);
 extern const char *rs6000_pltseq_template (rtx *, int);
 extern enum rtx_code rs6000_reverse_condition (machine_mode,
   enum rtx_code);
-extern enum rtx_code rs6000_fpmask_reverse_args (enum rtx_code);
 extern rtx rs6000_emit_eqne (machine_mode, rtx, rtx, rtx);
 extern rtx rs6000_emit_fp_cror (rtx_code, machine_mode, rtx);
 extern void rs6000_emit_sCOND (machine_mode, rtx[]);
diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc
index 8eaca7988d80..11dfde7f288b 100644
--- a/gcc/config/rs6000/rs6000.cc
+++ b/gcc/config/rs6000/rs6000.cc
@@ -15379,30 +15379,6 @@ rs6000_reverse_condition (machine_mode mode, enum 
rtx_code code)
 return reverse_condition (code);
 }
 
-/* Like reverse_condition, but return the condition code where the arguments
-   are reversed.  I.e. do not convert an unordered compare into an ordered
-   compare.  This is used for the fpmask operations in power9 to implement
-   floating point conditional moves.  */
-
-enum rtx_code
-rs6000_fpmask_reverse_args (enum rtx_code code)
-{
-  switch (code)
-{
-case NE:
-  return EQ;
-
-case LE:
-  return GT;
-
-case LT:
-  return GE;
-
-default:
-  gcc_unreachable ();
-}
-}
-
 /* Check if C (as 64bit integer) can be rotated to a constant which constains
nonzero bits at the LOWBITS low bits only.
 
diff --git a/gcc/config/rs6000/rs6000.h b/gcc/config/rs6000/rs6000.h
index c8d9456e0912..9267612fbc9c 100644
--- a/gcc/config/rs6000/rs6000.h
+++ b/gcc/config/rs6000/rs6000.h
@@ -1810,17 +1810,10 @@ extern scalar_int_mode rs6000_pmode;
: (((OP) == EQ || (OP) == NE) && COMPARISON_P (X) \
   ? CCEQmode : CCmode))
 
-/* Can the condition code MODE be safely reversed?  Don't allow floating point
-   comparisons to be reversed unless NaNs are not allowed.
-
-   In the past, we used to allow reversing FP operations because we only
-   generated FCMPU comparisons and not FCMPO.  However, starting with power9,
-   the XSCMPEQDP, XSCMPGTDP, and XSCMPGEDP instructions will trap if a
-   signalling NaN is used.  If we allow reversing FP operations, we could wind
-   up converting a LT operation into UNGE and the instruction will trap.  The
-   machine independent parts of the compiler will handle reversing the
-   arguments if the FP comparison cannot be reversed.  */
-#define REVERSIBLE_CC_MODE(MODE) ((MODE) != CCFPmode || flag_finite_math_only)
+/* Can the condition code MODE be safely reversed?  This is safe in
+   all cases on this port, because at present it doesn't use the
+   trapping FP comparisons (fcmpo).  */
+#define REVERSIBLE_CC_MODE(MODE) 1
 
 /* Given a condition code and a mode, return the inverse condition.  */
 #define REVERSE_CONDITION(CODE, MODE) rs6000_reverse_condition (MODE, CODE)
diff --git a/gcc/config/rs6000/rs6000.md b/gcc/config/rs6000/rs6000.md
index b5cc98bcb0eb..65da0c653304 100644
--- a/gcc/config/rs6000/rs6000.md
+++ b/gcc/config/rs6000/rs6000.md
@@ -5734,7 +5734,7 @@
 (define_insn_and_split "*movcc_invert_p9"
   [(set (match_operand:SFDF 0 "vsx_register_operand" "=&wa,wa")
(if_then_else:SFDF
-(match_operator:CCFP 1 "fpmask_reverse_args_comparison_operator"
+(match_operator:CCFP 1 "invert_fpmask_comparison_operator"
[(match_

[gcc r15-9721] Fortran: default-initialization and functions returning derived type [PR85750]

2025-05-22 Thread Harald Anlauf via Gcc-cvs
https://gcc.gnu.org/g:6fb3dd1de63e48a0cc465973f9de24f680c3fde5

commit r15-9721-g6fb3dd1de63e48a0cc465973f9de24f680c3fde5
Author: Harald Anlauf 
Date:   Thu May 15 21:07:07 2025 +0200

Fortran: default-initialization and functions returning derived type 
[PR85750]

Functions with non-pointer, non-allocatable result and of derived type did
not always get initialized although the type had default-initialization,
and a derived type component had the allocatable or pointer attribute.
Rearrange the logic when to apply default-initialization.

PR fortran/85750

gcc/fortran/ChangeLog:

* resolve.cc (resolve_symbol): Reorder conditions when to apply
default-initializers.

gcc/testsuite/ChangeLog:

* gfortran.dg/alloc_comp_auto_array_3.f90: Adjust scan counts.
* gfortran.dg/alloc_comp_class_3.f03: Remove bogus warnings.
* gfortran.dg/alloc_comp_class_4.f03: Likewise.
* gfortran.dg/allocate_with_source_14.f03: Adjust scan count.
* gfortran.dg/derived_constructor_comps_6.f90: Likewise.
* gfortran.dg/derived_result_5.f90: New test.

(cherry picked from commit d31ab498b12ebbe4f50acb2aa240ff92c73f310c)

Diff:
---
 gcc/fortran/resolve.cc |   8 +-
 .../gfortran.dg/alloc_comp_auto_array_3.f90|   4 +-
 gcc/testsuite/gfortran.dg/alloc_comp_class_3.f03   |   3 +-
 gcc/testsuite/gfortran.dg/alloc_comp_class_4.f03   |   5 +-
 .../gfortran.dg/allocate_with_source_14.f03|   2 +-
 .../gfortran.dg/derived_constructor_comps_6.f90|   2 +-
 gcc/testsuite/gfortran.dg/derived_result_5.f90 | 123 +
 7 files changed, 134 insertions(+), 13 deletions(-)

diff --git a/gcc/fortran/resolve.cc b/gcc/fortran/resolve.cc
index 1db886ee476c..1fb16cabb78c 100644
--- a/gcc/fortran/resolve.cc
+++ b/gcc/fortran/resolve.cc
@@ -17970,16 +17970,16 @@ skip_interfaces:
  || (a->dummy && !a->pointer && a->intent == INTENT_OUT
  && sym->ns->proc_name->attr.if_source != IFSRC_IFBODY))
apply_default_init (sym);
+  else if (a->function && !a->pointer && !a->allocatable && !a->use_assoc
+  && sym->result)
+   /* Default initialization for function results.  */
+   apply_default_init (sym->result);
   else if (a->function && sym->result && a->access != ACCESS_PRIVATE
   && (sym->ts.u.derived->attr.alloc_comp
   || sym->ts.u.derived->attr.pointer_comp))
/* Mark the result symbol to be referenced, when it has allocatable
   components.  */
sym->result->attr.referenced = 1;
-  else if (a->function && !a->pointer && !a->allocatable && !a->use_assoc
-  && sym->result)
-   /* Default initialization for function results.  */
-   apply_default_init (sym->result);
 }
 
   if (sym->ts.type == BT_CLASS && sym->ns == gfc_current_ns
diff --git a/gcc/testsuite/gfortran.dg/alloc_comp_auto_array_3.f90 
b/gcc/testsuite/gfortran.dg/alloc_comp_auto_array_3.f90
index 2af089e84e8d..d0751f3d3eba 100644
--- a/gcc/testsuite/gfortran.dg/alloc_comp_auto_array_3.f90
+++ b/gcc/testsuite/gfortran.dg/alloc_comp_auto_array_3.f90
@@ -25,6 +25,6 @@ contains
 allocate (array(1)%bigarr)
   end function
 end
-! { dg-final { scan-tree-dump-times "builtin_malloc" 3 "original" } }
+! { dg-final { scan-tree-dump-times "builtin_malloc" 4 "original" } }
 ! { dg-final { scan-tree-dump-times "builtin_free" 3 "original" } }
-! { dg-final { scan-tree-dump-times "while \\(1\\)" 4 "original" } }
+! { dg-final { scan-tree-dump-times "while \\(1\\)" 5 "original" } }
diff --git a/gcc/testsuite/gfortran.dg/alloc_comp_class_3.f03 
b/gcc/testsuite/gfortran.dg/alloc_comp_class_3.f03
index 0753e33d535d..8202d783621c 100644
--- a/gcc/testsuite/gfortran.dg/alloc_comp_class_3.f03
+++ b/gcc/testsuite/gfortran.dg/alloc_comp_class_3.f03
@@ -45,11 +45,10 @@ contains
 type(c), value :: d
   end subroutine
 
-  type(c) function c_init()  ! { dg-warning "not set" }
+  type(c) function c_init()
   end function
 
   subroutine sub(d)
 type(u), value :: d
   end subroutine
 end program test_pr58586
-
diff --git a/gcc/testsuite/gfortran.dg/alloc_comp_class_4.f03 
b/gcc/testsuite/gfortran.dg/alloc_comp_class_4.f03
index 4a55d73b245e..9ff38e3fb7c5 100644
--- a/gcc/testsuite/gfortran.dg/alloc_comp_class_4.f03
+++ b/gcc/testsuite/gfortran.dg/alloc_comp_class_4.f03
@@ -51,14 +51,14 @@ contains
 type(t), value :: d
   end subroutine
 
-  type(c) function c_init() ! { dg-warning "not set" }
+  type(c) function c_init()
   end function
 
   class(c) function c_init2() ! { dg-warning "not set" }
 allocatable :: c_init2
   end function
 
-  type(c) function d_init(this) ! { dg-warning "not set" }
+  type(c) function d_init(this)
 class(d) :: this
   end function
 
@@ -102,4 +102,3 @@ program test_pr58586
   call add_c(oe%init())
   deallocate(oe)
 end

[gcc(refs/users/meissner/heads/work206-bugs)] Fix PR 118541, do not generate unordered fp cmoves for IEEE compares.

2025-05-22 Thread Michael Meissner via Gcc-cvs
https://gcc.gnu.org/g:7fdca3d4dcc96e50e8369634edb89bb95c99a3ea

commit 7fdca3d4dcc96e50e8369634edb89bb95c99a3ea
Author: Michael Meissner 
Date:   Thu May 22 15:48:09 2025 -0400

Fix PR 118541, do not generate unordered fp cmoves for IEEE compares.

In bug PR target/118541 on power9, power10, and power11 systems, for the
function:

extern double __ieee754_acos (double);

double
__acospi (double x)
{
  double ret = __ieee754_acos (x) / 3.14;
  return __builtin_isgreater (ret, 1.0) ? 1.0 : ret;
}

GCC currently generates the following code:

Power9  Power10 and Power11
==  ===
bl __ieee754_acos   bl __ieee754_acos@notoc
nop plfd 0,.LC0@pcrel
addis 9,2,.LC2@toc@ha   xxspltidp 12,1065353216
addi 1,1,32 addi 1,1,32
lfd 0,.LC2@toc@l(9) ld 0,16(1)
addis 9,2,.LC0@toc@ha   fdiv 0,1,0
ld 0,16(1)  mtlr 0
lfd 12,.LC0@toc@l(9)xscmpgtdp 1,0,12
fdiv 0,1,0  xxsel 1,0,12,1
mtlr 0  blr
xscmpgtdp 1,0,12
xxsel 1,0,12,1
blr

This is because ifcvt.c optimizes the conditional floating point move to 
use the
XSCMPGTDP instruction.

However, the XSCMPGTDP instruction traps if one of the arguments is a 
signaling
NaN.  This patch disables generating XSCMP{EQ,GT,GE}{DP,QP} instructions 
unless
-ffinite-math-only is in effect so that we do not get a trap.

2025-05-22  Michael Meissner  

gcc/

PR target/118541
* config/rs6000/rs6000.md (movcc_p9): Disable
generating XSCMP{EQ,GT,GE}{DP,QP} unless -ffinite-math-only is in
effect.
(movcc_invert_p9): Likewise.
(fpmask, SFDF iterator): Likewise.
(xxsel, SFDF iterator): Likewise.
(movcc, IEEE128 iterator): Likewise.
(movcc_p10): Likewise.
(movcc_invert_p10): Likewise.
(fpmask, IEEE128 iterator): Likewise.
(xxsel, IEEE128 iterator): Likewise.

gcc/testsuite/

PR target/118541
* gcc.target/powerpc/float128-cmove.c: Change optimization flag to
-Ofast instead of -O2.

Diff:
---
 gcc/config/rs6000/rs6000.md   | 27 +++
 gcc/testsuite/gcc.target/powerpc/float128-cmove.c |  6 -
 2 files changed, 23 insertions(+), 10 deletions(-)

diff --git a/gcc/config/rs6000/rs6000.md b/gcc/config/rs6000/rs6000.md
index 65da0c653304..1f8cfcf0d255 100644
--- a/gcc/config/rs6000/rs6000.md
+++ b/gcc/config/rs6000/rs6000.md
@@ -5699,6 +5699,10 @@
   "fsel %0,%1,%2,%3"
   [(set_attr "type" "fp")])
 
+;; On power9, we can generate XSCMP{EQ,GT,GE}DP and XXSEL to do a floating
+;; point conditional move.  However, these instructions trap if one of the
+;; arguments is a signalling NaN.  Therefore we can only do this optimize if
+;; NaNs are not expected in the code.
 (define_insn_and_split "*movcc_p9"
   [(set (match_operand:SFDF 0 "vsx_register_operand" "=&wa,wa")
(if_then_else:SFDF
@@ -5708,7 +5712,7 @@
 (match_operand:SFDF 4 "vsx_register_operand" "wa,wa")
 (match_operand:SFDF 5 "vsx_register_operand" "wa,wa")))
(clobber (match_scratch:V2DI 6 "=0,&wa"))]
-  "TARGET_P9_MINMAX"
+  "TARGET_P9_MINMAX && flag_finite_math_only"
   "#"
   "&& 1"
   [(set (match_dup 6)
@@ -5740,7 +5744,7 @@
 (match_operand:SFDF 4 "vsx_register_operand" "wa,wa")
 (match_operand:SFDF 5 "vsx_register_operand" "wa,wa")))
(clobber (match_scratch:V2DI 6 "=0,&wa"))]
-  "TARGET_P9_MINMAX"
+  "TARGET_P9_MINMAX && flag_finite_math_only"
   "#"
   "&& 1"
   [(set (match_dup 6)
@@ -5775,7 +5779,7 @@
 (match_operand:SFDF 3 "vsx_register_operand" "wa")])
 (match_operand:V2DI 4 "all_ones_constant" "")
 (match_operand:V2DI 5 "zero_constant" "")))]
-  "TARGET_P9_MINMAX"
+  "TARGET_P9_MINMAX && flag_finite_math_only"
   "xscmp%V1dp %x0,%x2,%x3"
   [(set_attr "type" "fpcompare")])
 
@@ -5785,18 +5789,23 @@
   (match_operand:V2DI 2 "zero_constant" ""))
   (match_operand:SFDF 3 "vsx_register_operand" "wa")
   (match_operand:SFDF 4 "vsx_register_operand" "wa")))]
-  "TARGET_P9_MINMAX"
+  "TARGET_P9_MINMAX && flag_finite_math_only"
   "xxsel %x0,%x4,%x3,%x1"
   [(set_attr "type" "vecmove")])
 
 ;; Support for ISA 3.1 IEEE 128-bit conditional move.  The mode used in the
 ;; comparison must be the same as used in the move.
+;;
+;; On power10, we can generate XSCMP{EQ,GT,GE}QP and XXSEL to do a floating
+;; point c

[gcc(refs/users/meissner/heads/work206-bugs)] Update ChangeLog.*

2025-05-22 Thread Michael Meissner via Gcc-cvs
https://gcc.gnu.org/g:61bb3adee51d749d131af5582c79d1c5a432eec9

commit 61bb3adee51d749d131af5582c79d1c5a432eec9
Author: Michael Meissner 
Date:   Thu May 22 15:49:49 2025 -0400

Update ChangeLog.*

Diff:
---
 gcc/ChangeLog.bugs | 89 +++---
 1 file changed, 18 insertions(+), 71 deletions(-)

diff --git a/gcc/ChangeLog.bugs b/gcc/ChangeLog.bugs
index 0134634d76f9..f9eeb7439c96 100644
--- a/gcc/ChangeLog.bugs
+++ b/gcc/ChangeLog.bugs
@@ -1,4 +1,4 @@
- Branch work206-bugs, patch #112 
+ Branch work206-bugs, patch #113 
 
 Fix PR 118541, do not generate unordered fp cmoves for IEEE compares.
 
@@ -35,87 +35,34 @@ GCC currently generates the following code:
 This is because ifcvt.c optimizes the conditional floating point move to use 
the
 XSCMPGTDP instruction.
 
-However, the XSCMPGTDP instruction will generate an interrupt if one of the
-arguments is a signalling NaN and signalling NaNs can generate an interrupt.
-The IEEE comparison functions (isgreater, etc.) require that the comparison not
-raise an interrupt.
+However, the XSCMPGTDP instruction traps if one of the arguments is a signaling
+NaN.  This patch disables generating XSCMP{EQ,GT,GE}{DP,QP} instructions unless
+-ffinite-math-only is in effect so that we do not get a trap.
 
-The root cause of this is we allow floating point comparisons to be reversed
-(i.e. LT will be reversed to UNGE).  Before power9, this was ok because we only
-generated the FCMPU or XSCMPUDP instructions.
-
-But with power9, we can generate the XSCMPEQDP, XSCMPGTDP, or XSCMPGEDP
-instructions.  This code now does not convert an unordered compare into an
-ordered compare.  Instead, it does the opposite comparison and swaps the
-arguments.  I.e. it converts:
-
-   r = (a < b) ? c : d;
-
-into:
-
-   r = (b >= a) ? c : d;
-
-For the following code:
-
-double
-ordered_compare (double a, double b, double c, double d)
-{
-  return __builtin_isgreater (a, b) ? c : d;
-}
-
-/* Verify normal > does generate xscmpgtdp.  */
-
-double
-normal_compare (double a, double b, double c, double d)
-{
-  return a > b ? c : d;
-}
-
-with the following patch, GCC generates the following for power9, power10, and
-power11:
-
-ordered_compare:
-fcmpu 0,1,2
-fmr 1,4
-bnglr 0
-fmr 1,3
-blr
-
-normal_compare:
-xscmpgtdp 1,1,2
-xxsel 1,4,3,1
-blr
-
-I have built bootstrap compilers on big endian power9 systems and little endian
-power9/power10 systems and there were no regressions.  Can I check this patch
-into the GCC trunk, and after a waiting period, can I check this into the 
active
-older branches?
-
-2025-05-21  Michael Meissner  
+2025-05-22  Michael Meissner  
 
 gcc/
 
PR target/118541
-   * config/rs6000/predicates.md (invert_fpmask_comparison_operator):
-   Delete.
-   (fpmask_reverse_args_comparison_operator): New predicate.
-   * config/rs6000/rs6000-proto.h (rs6000_fpmask_reverse_args): New
-   declaration.
-   * config/rs6000/rs6000.cc (rs6000_fpmask_reverse_args): New function.
-   * config/rs6000/rs6000.h (REVERSIBLE_CC_MODE): Do not allow floating
-   point comparisons to be reversed unless -ffinite-math-only is used.
-   * config/rs6000/rs6000.md (movcc_p9): Add
-   comment.
-   (movcc_invert_p9): Reverse the argument order for
-   the comparison, and use an unordered comparison, instead of ordered
-   comparison.
+   * config/rs6000/rs6000.md (movcc_p9): Disable
+   generating XSCMP{EQ,GT,GE}{DP,QP} unless -ffinite-math-only is in
+   effect.
+   (movcc_invert_p9): Likewise.
+   (fpmask, SFDF iterator): Likewise.
+   (xxsel, SFDF iterator): Likewise.
+   (movcc, IEEE128 iterator): Likewise.
+   (movcc_p10): Likewise.
(movcc_invert_p10): Likewise.
+   (fpmask, IEEE128 iterator): Likewise.
+   (xxsel, IEEE128 iterator): Likewise.
 
 gcc/testsuite/
 
PR target/118541
-   * gcc.target/powerpc/pr118541.c: New test.
+   * gcc.target/powerpc/float128-cmove.c: Change optimization flag to
+   -Ofast instead of -O2.
 
+ Branch work206-bugs, patch #112 was reverted 

  Branch work206-bugs, patch #111 was reverted 

  Branch work206-bugs, patch #110 was reverted 



[gcc r16-823] aarch64: Improve rtx_cost for constants in COMPARE [PR120372]

2025-05-22 Thread Andrew Pinski via Gcc-cvs
https://gcc.gnu.org/g:bb7b6d9ad7f89ebc68c9d1eff16bec95f6e81cd9

commit r16-823-gbb7b6d9ad7f89ebc68c9d1eff16bec95f6e81cd9
Author: Andrew Pinski 
Date:   Tue May 20 15:10:15 2025 -0700

aarch64: Improve rtx_cost for constants in COMPARE [PR120372]

The middle-end uses rtx_cost on constants with the outer of being COMPARE
to find out the cost of a constant formation for a comparison instruction.
So for aarch64 backend, we would just return the cost of constant formation
in general. We can improve this by seeing if the outer is COMPARE and if
the constant fits the constraints of the cmp instruction just set the costs
to being one instruction.

Built and tested for aarch64-linux-gnu.

PR target/120372

gcc/ChangeLog:

* config/aarch64/aarch64.cc (aarch64_rtx_costs ): 
Handle
if outer is COMPARE and the constant can be handled by the cmp 
instruction.

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/imm_choice_comparison-2.c: New test.

Signed-off-by: Andrew Pinski 

Diff:
---
 gcc/config/aarch64/aarch64.cc  |  7 ++
 .../gcc.target/aarch64/imm_choice_comparison-2.c   | 90 ++
 2 files changed, 97 insertions(+)

diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc
index 2b837ec8e673..ecb0bac2e550 100644
--- a/gcc/config/aarch64/aarch64.cc
+++ b/gcc/config/aarch64/aarch64.cc
@@ -14578,6 +14578,13 @@ aarch64_rtx_costs (rtx x, machine_mode mode, int outer 
ATTRIBUTE_UNUSED,
 we don't need to consider that here.  */
   if (x == const0_rtx)
*cost = 0;
+  /* If the outer is a COMPARE which is used by the middle-end
+and the constant fits how the cmp instruction allows, say the cost
+is the same as 1 insn.  */
+  else if (outer == COMPARE
+  && (aarch64_uimm12_shift (INTVAL (x))
+  || aarch64_uimm12_shift (-UINTVAL (x
+   *cost = COSTS_N_INSNS (1);
   else
{
  /* To an approximation, building any other constant is
diff --git a/gcc/testsuite/gcc.target/aarch64/imm_choice_comparison-2.c 
b/gcc/testsuite/gcc.target/aarch64/imm_choice_comparison-2.c
new file mode 100644
index ..379fc50563c8
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/imm_choice_comparison-2.c
@@ -0,0 +1,90 @@
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+/* { dg-final { check-function-bodies "**" "" } } */
+
+/* PR target/120372 */
+
+/* Go from 2 moves to none.  */
+
+/*
+** GT:
+** ...
+** cmp w0, 11182080
+** ...
+*/
+
+int
+GT (unsigned int x)
+{
+  return x > 0xaa9fff;
+}
+
+/*
+** LE:
+** ...
+** cmp w0, 11182080
+** ...
+*/
+
+int
+LE (unsigned int x)
+{
+  return x <= 0xaa9fff;
+}
+
+/*
+** GE:
+** ...
+** cmp x0, 11182080
+** ...
+*/
+
+int
+GE (long long x)
+{
+  return x >= 0xaaa000;
+}
+
+/*
+** LT:
+** ...
+** cmp w0, 11182080
+** ...
+*/
+
+int
+LT (int x)
+{
+  return x < 0xaaa000;
+}
+
+/* Optimize the immediate in conditionals.  */
+
+/*
+** check:
+** ...
+** cmp w0, 11182080
+** ...
+*/
+
+int
+check (int x, int y)
+{
+  if (x > y && GT (x))
+return 100;
+
+  return x;
+}
+
+/*
+** tern:
+** ...
+** cmp w0, 11182080
+** ...
+*/
+
+int
+tern (int x)
+{
+  return x >= 0xaaa000 ? 5 : -3;
+}


[gcc/devel/omp/gcc-15] git_repository.py: Fix handling of --last-commit with merges

2025-05-22 Thread Tobias Burnus via Gcc-cvs
https://gcc.gnu.org/g:cc7f48e65b9aadb885461dea201d6028cc008ea1

commit cc7f48e65b9aadb885461dea201d6028cc008ea1
Author: Tobias Burnus 
Date:   Thu May 22 17:06:38 2025 +0200

git_repository.py: Fix handling of --last-commit with merges

contrib/ChangeLog:

* gcc-changelog/git_update_version.py (update_current_branch): Fix
handling of merges.
* gcc-changelog/git_repository.py (parse_git_revisions): Skip over
merge commits for merges from exclude branch.

Diff:
---
 contrib/gcc-changelog/git_repository.py |  9 +++--
 contrib/gcc-changelog/git_update_version.py | 28 ++--
 2 files changed, 21 insertions(+), 16 deletions(-)

diff --git a/contrib/gcc-changelog/git_repository.py 
b/contrib/gcc-changelog/git_repository.py
index dc658af83b9b..c70307d2c30e 100755
--- a/contrib/gcc-changelog/git_repository.py
+++ b/contrib/gcc-changelog/git_repository.py
@@ -77,8 +77,13 @@ def parse_git_revisions(repo_path, revisions, ref_name=None,
 commits = [repo.commit(revisions)]
 
 for commit in commits:
-if exclude_branch is not None and repo.is_ancestor(commit, 
exclude_branch):
-continue
+if exclude_branch is not None:
+if repo.is_ancestor(commit, exclude_branch):
+continue
+# Exlude merge commit
+if (len(commit.parents) == 2
+and repo.is_ancestor(commit.parents[1], exclude_branch)):
+continue
 git_commit = GitCommit(commit_to_info(commit.hexsha),
commit_to_info_hook=commit_to_info,
ref_name=ref_name)
diff --git a/contrib/gcc-changelog/git_update_version.py 
b/contrib/gcc-changelog/git_update_version.py
index ec5951ca2686..ae2630ea5756 100755
--- a/contrib/gcc-changelog/git_update_version.py
+++ b/contrib/gcc-changelog/git_update_version.py
@@ -124,21 +124,19 @@ def update_current_branch(ref_name=None, suffix="", 
last_commit_ref=None,
   exclude_branch=None):
 commit = repo.head.commit
 commit_count = 1
-last_commit = (repo.commit(last_commit_ref)
-   if last_commit_ref is not None else None)
-while commit:
-if last_commit is not None:
-if last_commit == commit:
+if last_commit_ref is not None:
+commit = repo.commit(last_commit_ref)
+else:
+while commit:
+if (commit.author.email == 'gccad...@gcc.gnu.org'
+  and commit.message.strip() == 'Daily bump.'):
 break
-elif (commit.author.email == 'gccad...@gcc.gnu.org'
-  and commit.message.strip() == 'Daily bump.'):
-break
-# We support merge commits but only with 2 parensts
-assert len(commit.parents) <= 2
-commit = commit.parents[-1]
-commit_count += 1
-
-logging.info('%d revisions since last Daily bump' % commit_count)
+# We support merge commits but only with 2 parensts
+assert len(commit.parents) <= 2
+commit = commit.parents[-1]
+commit_count += 1
+logging.info('%d revisions since last Daily bump' % commit_count)
+
 datestamp_path = os.path.join(args.git_path, 'gcc/DATESTAMP')
 if suffix != "":
 if not os.path.exists(datestamp_path + suffix):
@@ -158,6 +156,8 @@ def update_current_branch(ref_name=None, suffix="", 
last_commit_ref=None,
   % (commit.hexsha, head.hexsha), ref_name,
   exclude_branch)
 commits = [c for c in commits if c.info.hexsha not in ignored_commits]
+if last_commit_ref is not None:
+logging.info('%d revisions since last Daily bump' % len(commits))
 for git_commit in reversed(commits):
 prepend_to_changelog_files(repo, args.git_path, git_commit,
not args.dry_mode, args.suffix)


[gcc/devel/omp/gcc-15] ChangeLog.omp bump

2025-05-22 Thread Tobias Burnus via Gcc-cvs
https://gcc.gnu.org/g:cf57f401ab8f44585c443d40aba5e360f89263db

commit cf57f401ab8f44585c443d40aba5e360f89263db
Author: Tobias Burnus 
Date:   Thu May 22 17:10:44 2025 +0200

ChangeLog.omp bump

Diff:
---
 contrib/ChangeLog.omp | 7 +++
 gcc/DATESTAMP.omp | 2 +-
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/contrib/ChangeLog.omp b/contrib/ChangeLog.omp
index 024f5baf2eea..3158ef2eaad6 100644
--- a/contrib/ChangeLog.omp
+++ b/contrib/ChangeLog.omp
@@ -1,3 +1,10 @@
+2025-05-22  Tobias Burnus  
+
+   * gcc-changelog/git_update_version.py (update_current_branch): Fix
+   handling of merges.
+   * gcc-changelog/git_repository.py (parse_git_revisions): Skip over
+   merge commits for merges from exclude branch.
+
 2025-05-15  Tobias Burnus  
 
* gcc-changelog/git_repository.py (parse_git_revisions): Optional
diff --git a/gcc/DATESTAMP.omp b/gcc/DATESTAMP.omp
index e01bdfb865b5..7a7061068fcc 100644
--- a/gcc/DATESTAMP.omp
+++ b/gcc/DATESTAMP.omp
@@ -1 +1 @@
-20250516
+20250522


[gcc r16-825] [RISC-V] Clear both upper and lower bits using 3 shifts

2025-05-22 Thread Jeff Law via Gcc-cvs
https://gcc.gnu.org/g:65f27c18e349e2ccdfac34cef8640d8c6ca1d3c1

commit r16-825-g65f27c18e349e2ccdfac34cef8640d8c6ca1d3c1
Author: Shreya Munnangi 
Date:   Thu May 22 11:51:01 2025 -0600

[RISC-V] Clear both upper and lower bits using 3 shifts

So the next step in Shreya's work.  In the prior patch we used two shifts to
clear bits at the high or low end of an object.  In this patch we use 3 
shifts
to clear bits on both ends.

Nothing really special here.  With mvconst_internal still in the tree it's 
of
marginal value, though Shreya and I have confirmed the code coming out of
expand looks good.  It's just that combine reconstitutes the operation via
mvconst_internal+and which looks cheaper.

When I was playing in this space earlier I definitely saw testsuite cases 
that
need this case handled to not regress with mvconst_internal removed.

This has spun in my tester on rv32 and rv64 and it's bootstrap + testing on 
my
BPI with a mere 23 hours to go.  Waiting on pre-commit testing to render a
verdict before moving forward.

gcc/
* config/riscv/riscv.cc (synthesize_and): When profitable, use a 
three
shift sequence to clear bits at both upper and lower bits rather 
than
synthesizing the constant mask.

Diff:
---
 gcc/config/riscv/riscv.cc | 28 
 1 file changed, 28 insertions(+)

diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc
index 41a164bc7783..358d1ec5d32e 100644
--- a/gcc/config/riscv/riscv.cc
+++ b/gcc/config/riscv/riscv.cc
@@ -14562,6 +14562,34 @@ synthesize_and (rtx operands[3])
   return true;
 }
 
+  /* If there are all zeros, except for a run of 1s somewhere in the middle
+ of the constant, then this is at worst 3 shifts.  */
+  t = INTVAL (operands[2]);
+  if (budget >= 3
+  && consecutive_bits_operand (GEN_INT (t), word_mode)
+  && popcount_hwi (t) > 3)
+{
+  /* Shift right to clear the low order bits.  */
+  int count = ctz_hwi (INTVAL (operands[2]));
+  rtx x = gen_rtx_LSHIFTRT (word_mode, operands[1], GEN_INT (count));
+  output = gen_reg_rtx (word_mode);
+  emit_insn (gen_rtx_SET (output, x));
+  input = output;
+
+  /* Shift left to clear the high order bits.  */
+  count += clz_hwi (INTVAL (operands[2])) % BITS_PER_WORD;
+  x = gen_rtx_ASHIFT (word_mode, input, GEN_INT (count));
+  output = gen_reg_rtx (word_mode);
+  emit_insn (gen_rtx_SET (output, x));
+  input = output;
+
+  /* And shift back right to put the bits into position.  */
+  count = clz_hwi (INTVAL (operands[2])) % BITS_PER_WORD;
+  x = gen_rtx_LSHIFTRT (word_mode, input, GEN_INT (count));
+  emit_insn (gen_rtx_SET (operands[0], x));
+  return true;
+}
+
   /* If the remaining budget has gone to less than zero, it
  forces the value into a register and performs the AND
  operation.  It returns TRUE to the caller so the caller


[gcc r16-826] iesFrom: Alexandre Oliva

2025-05-22 Thread Alexandre Oliva via Gcc-cvs
https://gcc.gnu.org/g:a4f45de95eed90e3d166bb706bb883e3a6cda0bd

commit r16-826-ga4f45de95eed90e3d166bb706bb883e3a6cda0bd
Author: Alexandre Oliva 
Date:   Thu May 22 15:06:24 2025 -0300

iesFrom: Alexandre Oliva 

[aarch64] [vxworks] mark x18 as fixed, adjust tests

VxWorks uses x18 as the TCB, so STATIC_CHAIN_REGNUM has long been set
(in gcc/config/aarch64/aarch64-vxworks.h) to use x9 instead.

This patch marks x18 as fixed if the newly-introduced
TARGET_OS_USES_R18 is defined, so that it is not chosen by the
register allocator, rejects -fsanitize-shadow-call-stack due to the
register conflict, and adjusts tests that depend on x18 or on the
static chain register.


for  gcc/ChangeLog

* config/aarch64/aarch64-vxworks.h (TARGET_OS_USES_R18): Define.
Update comments.
* config/aarch64/aarch64.cc (aarch64_conditional_register_usage):
Mark x18 as fixed on VxWorks.
(aarch64_override_options_internal): Issue sorry message on
-fsanitize=shadow-call-stack if TARGET_OS_USES_R18.

for  gcc/testsuite/ChangeLog

* gcc.dg/cwsc1.c (CHAIN, aarch64): x9 instead x18 for __vxworks.
* gcc.target/aarch64/reg-alloc-4.c: Drop x18-assigned asm
operand on vxworks.
* gcc.target/aarch64/shadow_call_stack_1.c: Don't expect
-ffixed-x18 error on vxworks, but rather the sorry message.
* gcc.target/aarch64/shadow_call_stack_2.c: Skip on vxworks.
* gcc.target/aarch64/shadow_call_stack_3.c: Likewise.
* gcc.target/aarch64/shadow_call_stack_4.c: Likewise.
* gcc.target/aarch64/shadow_call_stack_5.c: Likewise.
* gcc.target/aarch64/shadow_call_stack_6.c: Likewise.
* gcc.target/aarch64/shadow_call_stack_7.c: Likewise.
* gcc.target/aarch64/shadow_call_stack_8.c: Likewise.
* gcc.target/aarch64/stack-check-prologue-19.c: Likewise.
* gcc.target/aarch64/stack-check-prologue-20.c: Likewise.

Diff:
---
 gcc/config/aarch64/aarch64-vxworks.h|  7 +++
 gcc/config/aarch64/aarch64.cc   | 21 ++---
 gcc/testsuite/gcc.dg/cwsc1.c|  6 +-
 gcc/testsuite/gcc.target/aarch64/reg-alloc-4.c  |  2 ++
 .../gcc.target/aarch64/shadow_call_stack_1.c|  4 +++-
 .../gcc.target/aarch64/shadow_call_stack_2.c|  1 +
 .../gcc.target/aarch64/shadow_call_stack_3.c|  1 +
 .../gcc.target/aarch64/shadow_call_stack_4.c|  1 +
 .../gcc.target/aarch64/shadow_call_stack_5.c|  1 +
 .../gcc.target/aarch64/shadow_call_stack_6.c|  1 +
 .../gcc.target/aarch64/shadow_call_stack_7.c|  1 +
 .../gcc.target/aarch64/shadow_call_stack_8.c|  1 +
 .../gcc.target/aarch64/stack-check-prologue-19.c|  1 +
 .../gcc.target/aarch64/stack-check-prologue-20.c|  1 +
 14 files changed, 40 insertions(+), 9 deletions(-)

diff --git a/gcc/config/aarch64/aarch64-vxworks.h 
b/gcc/config/aarch64/aarch64-vxworks.h
index 41adada9b1de..7b4da934b608 100644
--- a/gcc/config/aarch64/aarch64-vxworks.h
+++ b/gcc/config/aarch64/aarch64-vxworks.h
@@ -66,9 +66,8 @@ along with GCC; see the file COPYING3.  If not see
 #define VXWORKS_PERSONALITY "llvm"
 
 /* VxWorks uses R18 as a TCB pointer.  We must pick something else as
-   the static chain and R18 needs to be claimed "fixed".  Until we
-   arrange to override the common parts of the port family to
-   acknowledge the latter, configure --with-specs="-ffixed-r18".  */
+   the static chain and R18 needs to be claimed "fixed" (TARGET_OS_USES_R18
+   does that in aarch64_conditional_register_usage).  */
 #undef  STATIC_CHAIN_REGNUM
 #define STATIC_CHAIN_REGNUM 9
-
+#define TARGET_OS_USES_R18
diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc
index ecb0bac2e550..1fa3ec522c3a 100644
--- a/gcc/config/aarch64/aarch64.cc
+++ b/gcc/config/aarch64/aarch64.cc
@@ -18826,9 +18826,16 @@ aarch64_override_options_internal (struct gcc_options 
*opts)
   aarch64_stack_protector_guard_offset = offs;
 }
 
-  if ((flag_sanitize & SANITIZE_SHADOW_CALL_STACK)
-  && !fixed_regs[R18_REGNUM])
-error ("%<-fsanitize=shadow-call-stack%> requires %<-ffixed-x18%>");
+  if ((flag_sanitize & SANITIZE_SHADOW_CALL_STACK))
+{
+  if (!fixed_regs[R18_REGNUM])
+   error ("%<-fsanitize=shadow-call-stack%> requires %<-ffixed-x18%>");
+#ifdef TARGET_OS_USES_R18
+  else
+   sorry ("%<-fsanitize=shadow-call-stack%> conflicts with the use of"
+  " register x18 by the target operating system");
+#endif
+}
 
   aarch64_feature_flags isa_flags = aarch64_get_isa_flags (opts);
   if ((isa_flags & (AARCH64_FL_SM_ON | AARCH64_FL_ZA_ON))
@@ -22046,6 +22053,14 @@ aarch64_conditional_register_usage (void)
   fixed_regs[SPECULATION_SCRATCH_REGNUM] = 1;
   call_used_regs[SPECULATION_SCRAT

[gcc r16-827] [vxworks] build partial libatomic

2025-05-22 Thread Alexandre Oliva via Gcc-cvs
https://gcc.gnu.org/g:10360c1b0d45ae129df616a9e9b1db5f2a2eaef8

commit r16-827-g10360c1b0d45ae129df616a9e9b1db5f2a2eaef8
Author: Alexandre Oliva 
Date:   Thu May 22 15:15:31 2025 -0300

[vxworks] build partial libatomic

Since vxworks' libc contains much of libatomic, in not-very-granular
modules, building all of libatomic doesn't work very well.

However, some expected entry points are not present in libc, so
arrange for libatomic to build only those missing bits.


for  libatomic/ChangeLog

* configure.tgt: Set partial_libatomic on *-*-vxworks*.
* configure.ac (PARTIAL_VXWORKS): New AM_CONDITIONAL.
* Makefile.am (libatomic_la_SOURCES): Select few sources for
PARTIAL_VXWORKS.
* configure, Makefile.in: Rebuilt.

Diff:
---
 libatomic/Makefile.am   |   8 +++-
 libatomic/Makefile.in   | 109 +++-
 libatomic/configure |  20 -
 libatomic/configure.ac  |   3 ++
 libatomic/configure.tgt |   4 ++
 5 files changed, 93 insertions(+), 51 deletions(-)

diff --git a/libatomic/Makefile.am b/libatomic/Makefile.am
index 0f1a71560848..65dff6ece9ff 100644
--- a/libatomic/Makefile.am
+++ b/libatomic/Makefile.am
@@ -70,11 +70,16 @@ endif
 
 libatomic_la_LDFLAGS = $(libatomic_version_info) $(libatomic_version_script) \
$(lt_host_flags) $(libatomic_darwin_rpath)
+
+SIZES = @SIZES@
+
+if PARTIAL_VXWORKS
+libatomic_la_SOURCES = fenv.c fence.c flag.c
+else
 libatomic_la_SOURCES = gload.c gstore.c gcas.c gexch.c glfree.c lock.c init.c \
fenv.c fence.c flag.c
 
 SIZEOBJS = load store cas exch fadd fsub fand fior fxor fnand tas
-SIZES = @SIZES@
 
 EXTRA_libatomic_la_SOURCES = $(addsuffix _n.c,$(SIZEOBJS))
 libatomic_la_DEPENDENCIES = $(libatomic_la_LIBADD) $(libatomic_version_dep)
@@ -152,6 +157,7 @@ endif
 if ARCH_AARCH64_LINUX
 libatomic_la_SOURCES += atomic_16.S
 endif
+endif
 
 libatomic_convenience_la_SOURCES = $(libatomic_la_SOURCES)
 libatomic_convenience_la_LIBADD = $(libatomic_la_LIBADD)
diff --git a/libatomic/Makefile.in b/libatomic/Makefile.in
index 9798e7c09e99..4344ac4a2e8f 100644
--- a/libatomic/Makefile.in
+++ b/libatomic/Makefile.in
@@ -89,18 +89,18 @@ POST_UNINSTALL = :
 build_triplet = @build@
 host_triplet = @host@
 target_triplet = @target@
-@ARCH_AARCH64_LINUX_TRUE@@HAVE_IFUNC_TRUE@am__append_1 = $(foreach 
s,$(SIZES),$(addsuffix _$(s)_1_.lo,$(SIZEOBJS)))
-@ARCH_ARM_LINUX_TRUE@@HAVE_IFUNC_TRUE@am__append_2 = $(foreach \
-@ARCH_ARM_LINUX_TRUE@@HAVE_IFUNC_TRUE@ s,$(SIZES),$(addsuffix \
-@ARCH_ARM_LINUX_TRUE@@HAVE_IFUNC_TRUE@ _$(s)_1_.lo,$(SIZEOBJS))) \
-@ARCH_ARM_LINUX_TRUE@@HAVE_IFUNC_TRUE@ $(addsuffix \
-@ARCH_ARM_LINUX_TRUE@@HAVE_IFUNC_TRUE@ _8_2_.lo,$(SIZEOBJS)) \
-@ARCH_ARM_LINUX_TRUE@@HAVE_IFUNC_TRUE@ tas_1_2_.lo
-@ARCH_I386_TRUE@@HAVE_IFUNC_TRUE@am__append_3 = $(addsuffix 
_8_1_.lo,$(SIZEOBJS))
-@ARCH_X86_64_TRUE@@HAVE_IFUNC_TRUE@am__append_4 = $(addsuffix 
_16_1_.lo,$(SIZEOBJS)) \
-@ARCH_X86_64_TRUE@@HAVE_IFUNC_TRUE@   $(addsuffix 
_16_2_.lo,$(SIZEOBJS))
-
-@ARCH_AARCH64_LINUX_TRUE@am__append_5 = atomic_16.S
+@ARCH_AARCH64_LINUX_TRUE@@HAVE_IFUNC_TRUE@@PARTIAL_VXWORKS_FALSE@am__append_1 
= $(foreach s,$(SIZES),$(addsuffix _$(s)_1_.lo,$(SIZEOBJS)))
+@ARCH_ARM_LINUX_TRUE@@HAVE_IFUNC_TRUE@@PARTIAL_VXWORKS_FALSE@am__append_2 = 
$(foreach \
+@ARCH_ARM_LINUX_TRUE@@HAVE_IFUNC_TRUE@@PARTIAL_VXWORKS_FALSE@  
s,$(SIZES),$(addsuffix \
+@ARCH_ARM_LINUX_TRUE@@HAVE_IFUNC_TRUE@@PARTIAL_VXWORKS_FALSE@  
_$(s)_1_.lo,$(SIZEOBJS))) \
+@ARCH_ARM_LINUX_TRUE@@HAVE_IFUNC_TRUE@@PARTIAL_VXWORKS_FALSE@  $(addsuffix \
+@ARCH_ARM_LINUX_TRUE@@HAVE_IFUNC_TRUE@@PARTIAL_VXWORKS_FALSE@  
_8_2_.lo,$(SIZEOBJS)) \
+@ARCH_ARM_LINUX_TRUE@@HAVE_IFUNC_TRUE@@PARTIAL_VXWORKS_FALSE@  tas_1_2_.lo
+@ARCH_I386_TRUE@@HAVE_IFUNC_TRUE@@PARTIAL_VXWORKS_FALSE@am__append_3 = 
$(addsuffix _8_1_.lo,$(SIZEOBJS))
+@ARCH_X86_64_TRUE@@HAVE_IFUNC_TRUE@@PARTIAL_VXWORKS_FALSE@am__append_4 = 
$(addsuffix _16_1_.lo,$(SIZEOBJS)) \
+@ARCH_X86_64_TRUE@@HAVE_IFUNC_TRUE@@PARTIAL_VXWORKS_FALSE@
$(addsuffix _16_2_.lo,$(SIZEOBJS))
+
+@ARCH_AARCH64_LINUX_TRUE@@PARTIAL_VXWORKS_FALSE@am__append_5 = atomic_16.S
 subdir = .
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/../config/acx.m4 \
@@ -156,10 +156,14 @@ am__uninstall_files_from_dir = { \
   }
 am__installdirs = "$(DESTDIR)$(toolexeclibdir)"
 LTLIBRARIES = $(noinst_LTLIBRARIES) $(toolexeclib_LTLIBRARIES)
-@ARCH_AARCH64_LINUX_TRUE@am__objects_1 = atomic_16.lo
-am_libatomic_la_OBJECTS = gload.lo gstore.lo gcas.lo gexch.lo \
-   glfree.lo lock.lo init.lo fenv.lo fence.lo flag.lo \
-   $(am__objects_1)
+@ARCH_AARCH64_LINUX_TRUE@@PARTIAL_VXWORKS_FALSE@am__objects_1 =  \
+@ARCH_AARCH64_LINUX_TRUE@@PARTIAL_VXWORKS_FALSE@   atomic_16.lo
+@PARTIAL_VXWORKS_FALSE@am_libatomic_la_OBJECTS = gload.lo gstore.lo \
+@PARTIAL_VXWORKS_FALSE@gcas.lo gexch.lo glfree.lo lock.lo \
+@PARTIAL_VXW

[gcc r16-829] c++: fix testcase comment

2025-05-22 Thread Jason Merrill via Gcc-cvs
https://gcc.gnu.org/g:f5016d8492e4067faef2f9403370a4b49f7a3898

commit r16-829-gf5016d8492e4067faef2f9403370a4b49f7a3898
Author: Jason Merrill 
Date:   Thu May 22 16:09:51 2025 -0400

c++: fix testcase comment

Typo.

gcc/testsuite/ChangeLog:

* g++.dg/opt/always_inline2.C: Correct PR number.

Diff:
---
 gcc/testsuite/g++.dg/opt/always_inline2.C | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/testsuite/g++.dg/opt/always_inline2.C 
b/gcc/testsuite/g++.dg/opt/always_inline2.C
index 8cfdd67e36ce..1da09b56bf77 100644
--- a/gcc/testsuite/g++.dg/opt/always_inline2.C
+++ b/gcc/testsuite/g++.dg/opt/always_inline2.C
@@ -1,4 +1,4 @@
-// PR c++/120935
+// PR c++/120395
 // { dg-additional-options "-fdump-tree-optimized" }
 // { dg-final { scan-tree-dump-not "goto" "optimized" } }
 // { dg-do compile { target c++11 } }


[gcc r16-828] c++: constexpr always_inline [PR120935]

2025-05-22 Thread Jason Merrill via Gcc-cvs
https://gcc.gnu.org/g:26b50c5fed8b0373c2c6100b5a92d1109bb20783

commit r16-828-g26b50c5fed8b0373c2c6100b5a92d1109bb20783
Author: Jason Merrill 
Date:   Thu May 22 09:11:04 2025 -0400

c++: constexpr always_inline [PR120935]

In cp_fold we do speculative constant evaluation of constexpr calls when
inlining is enabled.  Let's also do it for always_inline functions.

PR c++/120935

gcc/cp/ChangeLog:

* cp-gimplify.cc (cp_fold): Check always_inline.

gcc/testsuite/ChangeLog:

* g++.dg/opt/always_inline2.C: New test.
* g++.dg/debug/dwarf2/pubnames-2.C: Suppress -fimplicit-constexpr.
* g++.dg/debug/dwarf2/pubnames-3.C: Likewise.

Diff:
---
 gcc/cp/cp-gimplify.cc  |  4 +++-
 gcc/testsuite/g++.dg/debug/dwarf2/pubnames-2.C |  2 +-
 gcc/testsuite/g++.dg/debug/dwarf2/pubnames-3.C |  2 +-
 gcc/testsuite/g++.dg/opt/always_inline2.C  | 28 ++
 4 files changed, 33 insertions(+), 3 deletions(-)

diff --git a/gcc/cp/cp-gimplify.cc b/gcc/cp/cp-gimplify.cc
index f7bd453bc5eb..03d5352977b2 100644
--- a/gcc/cp/cp-gimplify.cc
+++ b/gcc/cp/cp-gimplify.cc
@@ -3441,7 +3441,9 @@ cp_fold (tree x, fold_flags_t flags)
   Do constexpr expansion of expressions where the call itself is not
   constant, but the call followed by an INDIRECT_REF is.  */
if (callee && DECL_DECLARED_CONSTEXPR_P (callee)
-   && !flag_no_inline)
+   && (!flag_no_inline
+   || lookup_attribute ("always_inline",
+DECL_ATTRIBUTES (callee
  {
mce_value manifestly_const_eval = mce_unknown;
if (flags & ff_mce_false)
diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/pubnames-2.C 
b/gcc/testsuite/g++.dg/debug/dwarf2/pubnames-2.C
index 1fb5004df401..96469d4d332f 100644
--- a/gcc/testsuite/g++.dg/debug/dwarf2/pubnames-2.C
+++ b/gcc/testsuite/g++.dg/debug/dwarf2/pubnames-2.C
@@ -1,6 +1,6 @@
 // { dg-do compile { target c++11 } }
 // { dg-skip-if "" { powerpc-ibm-aix* } }
-// { dg-options "-gpubnames -gdwarf-4 -fno-debug-types-section -dA 
-fno-inline" }
+// { dg-options "-gpubnames -gdwarf-4 -fno-debug-types-section -dA -fno-inline 
-fno-implicit-constexpr" }
 // { dg-final { scan-assembler-times "\.section\[\t \]\[^\n\]*debug_pubnames" 
1 } }
 // { dg-final { scan-assembler "\"\\(anonymous namespace\\)0\"+\[ 
\t\]+\[#;/|@!]+\[ \t\]+external name" } }
 // { dg-final { scan-assembler "\"one0\"+\[ \t\]+\[#;/|@!]+\[ 
\t\]+external name" } }
diff --git a/gcc/testsuite/g++.dg/debug/dwarf2/pubnames-3.C 
b/gcc/testsuite/g++.dg/debug/dwarf2/pubnames-3.C
index 37e04fb6c972..f635803d45ac 100644
--- a/gcc/testsuite/g++.dg/debug/dwarf2/pubnames-3.C
+++ b/gcc/testsuite/g++.dg/debug/dwarf2/pubnames-3.C
@@ -1,6 +1,6 @@
 // { dg-do compile { target c++11 } }
 // { dg-skip-if "" { powerpc-ibm-aix* } }
-// { dg-options "-gpubnames -gdwarf-4 -fdebug-types-section -dA -fno-inline" }
+// { dg-options "-gpubnames -gdwarf-4 -fdebug-types-section -dA -fno-inline 
-fno-implicit-constexpr" }
 // { dg-final { scan-assembler-times "\.section\[\t \]\[^\n\]*debug_pubnames" 
1 } }
 // { dg-final { scan-assembler "\"\\(anonymous namespace\\)0\"+\[ 
\t\]+\[#;/|@!]+\[ \t\]+external name" } }
 // { dg-final { scan-assembler "\"one0\"+\[ \t\]+\[#;/|@!]+\[ 
\t\]+external name" } }
diff --git a/gcc/testsuite/g++.dg/opt/always_inline2.C 
b/gcc/testsuite/g++.dg/opt/always_inline2.C
new file mode 100644
index ..8cfdd67e36ce
--- /dev/null
+++ b/gcc/testsuite/g++.dg/opt/always_inline2.C
@@ -0,0 +1,28 @@
+// PR c++/120935
+// { dg-additional-options "-fdump-tree-optimized" }
+// { dg-final { scan-tree-dump-not "goto" "optimized" } }
+// { dg-do compile { target c++11 } }
+
+void x(int);
+
+[[gnu::always_inline]] constexpr bool
+is_constant_evaluated()
+{ return __builtin_is_constant_evaluated(); }
+
+struct Iter
+{
+typedef int value_type;
+
+int& operator*() const;
+Iter& operator++();
+bool operator!=(const Iter&) const;
+};
+
+void f(Iter first, Iter last)
+{
+if (__is_trivial(Iter::value_type))
+if (!is_constant_evaluated())
+return;
+for (; first != last; ++first)
+x(*first);
+}


[gcc r16-831] testsuite: Remove obsolete ada/acats/overflow.lst file

2025-05-22 Thread Eric Botcazou via Gcc-cvs
https://gcc.gnu.org/g:05fc1470798601f610653cac4f6a55a9c83928f4

commit r16-831-g05fc1470798601f610653cac4f6a55a9c83928f4
Author: Eric Botcazou 
Date:   Thu May 22 22:11:08 2025 +0200

testsuite: Remove obsolete ada/acats/overflow.lst file

It is used to specify which files are compiled with -gnato, but the switch
has been the default for at least a decade.

gcc/testsuite/
* ada/acats/overflow.lst: Delete.
* ada/acats/run_all.sh: Do not process overflow.lst.

Diff:
---
 gcc/testsuite/ada/acats/overflow.lst | 17 -
 gcc/testsuite/ada/acats/run_all.sh   |  4 
 2 files changed, 21 deletions(-)

diff --git a/gcc/testsuite/ada/acats/overflow.lst 
b/gcc/testsuite/ada/acats/overflow.lst
deleted file mode 100644
index fb76ef177059..
--- a/gcc/testsuite/ada/acats/overflow.lst
+++ /dev/null
@@ -1,17 +0,0 @@
-c45632a
-c45632b
-c45632c
-c45504a
-c45504b
-c45504c
-c45613a
-c45613b
-c45613c
-c45304a
-c45304b
-c45304c
-c46014a
-c460008
-c460011
-c4a012b
-cb20004
diff --git a/gcc/testsuite/ada/acats/run_all.sh 
b/gcc/testsuite/ada/acats/run_all.sh
index 38ec46928997..2f737854c60a 100755
--- a/gcc/testsuite/ada/acats/run_all.sh
+++ b/gcc/testsuite/ada/acats/run_all.sh
@@ -303,10 +303,6 @@ for chapter in $chapters; do
   fi
 
   extraflags="-gnat95"
-  grep $i $testdir/overflow.lst > /dev/null 2>&1
-  if [ $? -eq 0 ]; then
- extraflags="$extraflags -gnato"
-  fi
   grep $i $testdir/elabd.lst > /dev/null 2>&1
   if [ $? -eq 0 ]; then
  extraflags="$extraflags -gnatE"


[gcc(refs/users/mikael/heads/refactor_descriptor_v05)] Correction régression class_transformational_2

2025-05-22 Thread Mikael Morin via Gcc-cvs
https://gcc.gnu.org/g:0c41996ac310a67e5d6c20d2feedd562afa9d8b5

commit 0c41996ac310a67e5d6c20d2feedd562afa9d8b5
Author: Mikael Morin 
Date:   Thu May 22 22:24:42 2025 +0200

Correction régression class_transformational_2

Diff:
---
 libgfortran/intrinsics/eoshift0.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libgfortran/intrinsics/eoshift0.c 
b/libgfortran/intrinsics/eoshift0.c
index 383b7e392b0a..3dfc428a0f9b 100644
--- a/libgfortran/intrinsics/eoshift0.c
+++ b/libgfortran/intrinsics/eoshift0.c
@@ -67,6 +67,7 @@ eoshift0 (gfc_array_char * ret, const gfc_array_char * array,
 
   ret->offset = 0;
   GFC_DTYPE_COPY(ret,array);
+  GFC_DESCRIPTOR_SPAN (ret) = GFC_DESCRIPTOR_SPAN (array);
 
   for (i = 0; i < GFC_DESCRIPTOR_RANK (array); i++)
 {


[gcc(refs/users/mikael/heads/refactor_descriptor_v05)] Correction régression realloc_on_assign_12

2025-05-22 Thread Mikael Morin via Gcc-cvs
https://gcc.gnu.org/g:b360781d9783105bcd7aa2db39a711955e1eed29

commit b360781d9783105bcd7aa2db39a711955e1eed29
Author: Mikael Morin 
Date:   Thu May 22 11:44:55 2025 +0200

Correction régression realloc_on_assign_12

Diff:
---
 libgfortran/generated/reshape_c10.c | 1 +
 libgfortran/generated/reshape_c16.c | 1 +
 libgfortran/generated/reshape_c17.c | 1 +
 libgfortran/generated/reshape_c4.c  | 1 +
 libgfortran/generated/reshape_c8.c  | 1 +
 libgfortran/generated/reshape_i16.c | 1 +
 libgfortran/generated/reshape_i4.c  | 1 +
 libgfortran/generated/reshape_i8.c  | 1 +
 libgfortran/generated/reshape_r10.c | 1 +
 libgfortran/generated/reshape_r16.c | 1 +
 libgfortran/generated/reshape_r17.c | 1 +
 libgfortran/generated/reshape_r4.c  | 1 +
 libgfortran/generated/reshape_r8.c  | 1 +
 libgfortran/m4/reshape.m4   | 1 +
 14 files changed, 14 insertions(+)

diff --git a/libgfortran/generated/reshape_c10.c 
b/libgfortran/generated/reshape_c10.c
index cdcac44f6103..6a736545188f 100644
--- a/libgfortran/generated/reshape_c10.c
+++ b/libgfortran/generated/reshape_c10.c
@@ -120,6 +120,7 @@ reshape_c10 (gfc_array_c10 * const restrict ret,
 
   ret->base_addr = xmallocarray (alloc_size, sizeof (GFC_COMPLEX_10));
   ret->dtype.rank = rdim;
+  ret->span = sizeof (GFC_COMPLEX_10);
 }
 
   if (shape_empty)
diff --git a/libgfortran/generated/reshape_c16.c 
b/libgfortran/generated/reshape_c16.c
index dd726933b75f..e8933eadc6c6 100644
--- a/libgfortran/generated/reshape_c16.c
+++ b/libgfortran/generated/reshape_c16.c
@@ -120,6 +120,7 @@ reshape_c16 (gfc_array_c16 * const restrict ret,
 
   ret->base_addr = xmallocarray (alloc_size, sizeof (GFC_COMPLEX_16));
   ret->dtype.rank = rdim;
+  ret->span = sizeof (GFC_COMPLEX_16);
 }
 
   if (shape_empty)
diff --git a/libgfortran/generated/reshape_c17.c 
b/libgfortran/generated/reshape_c17.c
index ac2d3edf1d4a..0030e5a19aea 100644
--- a/libgfortran/generated/reshape_c17.c
+++ b/libgfortran/generated/reshape_c17.c
@@ -120,6 +120,7 @@ reshape_c17 (gfc_array_c17 * const restrict ret,
 
   ret->base_addr = xmallocarray (alloc_size, sizeof (GFC_COMPLEX_17));
   ret->dtype.rank = rdim;
+  ret->span = sizeof (GFC_COMPLEX_17);
 }
 
   if (shape_empty)
diff --git a/libgfortran/generated/reshape_c4.c 
b/libgfortran/generated/reshape_c4.c
index e51787d19402..9fc5cd056d0b 100644
--- a/libgfortran/generated/reshape_c4.c
+++ b/libgfortran/generated/reshape_c4.c
@@ -120,6 +120,7 @@ reshape_c4 (gfc_array_c4 * const restrict ret,
 
   ret->base_addr = xmallocarray (alloc_size, sizeof (GFC_COMPLEX_4));
   ret->dtype.rank = rdim;
+  ret->span = sizeof (GFC_COMPLEX_4);
 }
 
   if (shape_empty)
diff --git a/libgfortran/generated/reshape_c8.c 
b/libgfortran/generated/reshape_c8.c
index 7be820fa8ab3..65cd8c098ae4 100644
--- a/libgfortran/generated/reshape_c8.c
+++ b/libgfortran/generated/reshape_c8.c
@@ -120,6 +120,7 @@ reshape_c8 (gfc_array_c8 * const restrict ret,
 
   ret->base_addr = xmallocarray (alloc_size, sizeof (GFC_COMPLEX_8));
   ret->dtype.rank = rdim;
+  ret->span = sizeof (GFC_COMPLEX_8);
 }
 
   if (shape_empty)
diff --git a/libgfortran/generated/reshape_i16.c 
b/libgfortran/generated/reshape_i16.c
index 06f83a52beaf..2dcf065f1d0a 100644
--- a/libgfortran/generated/reshape_i16.c
+++ b/libgfortran/generated/reshape_i16.c
@@ -120,6 +120,7 @@ reshape_16 (gfc_array_i16 * const restrict ret,
 
   ret->base_addr = xmallocarray (alloc_size, sizeof (GFC_INTEGER_16));
   ret->dtype.rank = rdim;
+  ret->span = sizeof (GFC_INTEGER_16);
 }
 
   if (shape_empty)
diff --git a/libgfortran/generated/reshape_i4.c 
b/libgfortran/generated/reshape_i4.c
index d4175eabe14a..1812c42ec60c 100644
--- a/libgfortran/generated/reshape_i4.c
+++ b/libgfortran/generated/reshape_i4.c
@@ -120,6 +120,7 @@ reshape_4 (gfc_array_i4 * const restrict ret,
 
   ret->base_addr = xmallocarray (alloc_size, sizeof (GFC_INTEGER_4));
   ret->dtype.rank = rdim;
+  ret->span = sizeof (GFC_INTEGER_4);
 }
 
   if (shape_empty)
diff --git a/libgfortran/generated/reshape_i8.c 
b/libgfortran/generated/reshape_i8.c
index 6ed4f8b2f237..8013ba3af45e 100644
--- a/libgfortran/generated/reshape_i8.c
+++ b/libgfortran/generated/reshape_i8.c
@@ -120,6 +120,7 @@ reshape_8 (gfc_array_i8 * const restrict ret,
 
   ret->base_addr = xmallocarray (alloc_size, sizeof (GFC_INTEGER_8));
   ret->dtype.rank = rdim;
+  ret->span = sizeof (GFC_INTEGER_8);
 }
 
   if (shape_empty)
diff --git a/libgfortran/generated/reshape_r10.c 
b/libgfortran/generated/reshape_r10.c
index 9d9b03b08f10..6b8618fdd0a7 100644
--- a/libgfortran/generated/reshape_r10.c
+++ b/libgfortran/generated/reshape_r10.c
@@ -120,6 +120,7 @@ reshape_r10 (gfc_array_r10 * const restrict ret,
 
   ret->base_addr = xmallocarray (alloc_size, sizeof (GFC_REAL_10));
   ret->dtype.rank = rdim;
+  ret->span = sizeof (GFC_REAL_10);
 }
 
   if (shape_empty)
di

[gcc(refs/users/mikael/heads/refactor_descriptor_v05)] Correction régression inline_sum_2

2025-05-22 Thread Mikael Morin via Gcc-cvs
https://gcc.gnu.org/g:678ca6a45faf6a462b2a792edfb80eb86687743b

commit 678ca6a45faf6a462b2a792edfb80eb86687743b
Author: Mikael Morin 
Date:   Tue May 20 21:14:23 2025 +0200

Correction régression inline_sum_2

Diff:
---
 gcc/fortran/trans-array.cc | 18 --
 1 file changed, 8 insertions(+), 10 deletions(-)

diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc
index 9a20f3a73583..a3d4c007d31e 100644
--- a/gcc/fortran/trans-array.cc
+++ b/gcc/fortran/trans-array.cc
@@ -2902,23 +2902,21 @@ gfc_add_loop_ss_code (gfc_loopinfo * loop, gfc_ss * ss, 
bool subscript,
  trans_array_constructor (ss, where);
  {
gcc_assert (info->shape != nullptr || ss->dimen == 1);
-   tree type = gfc_typenode_for_spec (ss_info->expr->ts.type == 
BT_CLASS
-  ? &CLASS_DATA (ss_info->expr)->ts
-  : &ss_info->expr->ts);
-   if (ss_info->expr->ts.type == BT_CHARACTER
+   tree type = gfc_typenode_for_spec (expr->ts.type == BT_CLASS
+  ? &CLASS_DATA (expr)->ts
+  : &expr->ts);
+   if (expr->ts.type == BT_CHARACTER
&& gfc_is_constant_expr (ss_info->expr))
  type = build_pointer_type (type);
tree spacing = TYPE_SIZE_UNIT (type);
if (spacing == NULL_TREE)
- spacing = ss_info->expr->ts.u.cl->backend_decl;
+ spacing = expr->ts.u.cl->backend_decl;
spacing = fold_convert_loc (input_location, gfc_array_index_type,
spacing);
-   for (n = 0; n < ss->dimen; n++)
+   for (n = 0; n < expr->rank; n++)
  {
-   int dim = ss->dim[n];
-
-   info->spacing[dim] = spacing;
-   if (n < ss->dimen - 1)
+   info->spacing[n] = spacing;
+   if (n < expr->rank - 1)
  {
tree extent = gfc_conv_mpz_to_tree_type (info->shape[n],
gfc_array_index_type);


[gcc r16-830] Fix oversight about big-endian targets in latest change

2025-05-22 Thread Eric Botcazou via Gcc-cvs
https://gcc.gnu.org/g:d7f24e37d4bcb80c21c391d32f0f29594b71c2ee

commit r16-830-gd7f24e37d4bcb80c21c391d32f0f29594b71c2ee
Author: Eric Botcazou 
Date:   Thu May 22 16:25:07 2025 +0200

Fix oversight about big-endian targets in latest change

Bit-fields are stored left-justified for big-endian targets.

gcc/
* dwarf2out.cc (loc_list_from_tree_1) : Add specific
handling of bit-fields for big-endian targets.

Diff:
---
 gcc/dwarf2out.cc | 33 +
 1 file changed, 25 insertions(+), 8 deletions(-)

diff --git a/gcc/dwarf2out.cc b/gcc/dwarf2out.cc
index 713a55108aa2..d1a55dbcbcbf 100644
--- a/gcc/dwarf2out.cc
+++ b/gcc/dwarf2out.cc
@@ -19764,18 +19764,35 @@ loc_list_from_tree_1 (tree loc, int want_address,
{
  if (TYPE_UNSIGNED (TREE_TYPE (loc)))
{
- const unsigned HOST_WIDE_INT mask
-   = (HOST_WIDE_INT_1U << bitsize) - 1;
- add_loc_descr (&deref, uint_loc_descriptor (mask));
- add_loc_descr (&deref, new_loc_descr (DW_OP_and, 0, 0));
+ if (BYTES_BIG_ENDIAN)
+   {
+ const unsigned HOST_WIDE_INT shift
+   = size * BITS_PER_UNIT - bitsize;
+ add_loc_descr (&deref, uint_loc_descriptor (shift));
+ add_loc_descr (&deref, new_loc_descr (DW_OP_shr, 0, 0));
+   }
+ else
+   {
+ const unsigned HOST_WIDE_INT mask
+   = (HOST_WIDE_INT_1U << bitsize) - 1;
+ add_loc_descr (&deref, uint_loc_descriptor (mask));
+ add_loc_descr (&deref, new_loc_descr (DW_OP_and, 0, 0));
+   }
}
  else
{
- const unsigned HOST_WIDE_INT shift
+ const unsigned HOST_WIDE_INT shiftr
= DWARF2_ADDR_SIZE * BITS_PER_UNIT - bitsize;
- add_loc_descr (&deref, uint_loc_descriptor (shift));
- add_loc_descr (&deref, new_loc_descr (DW_OP_shl, 0, 0));
- add_loc_descr (&deref, uint_loc_descriptor (shift));
+ const unsigned HOST_WIDE_INT shiftl
+   = BYTES_BIG_ENDIAN
+ ? (DWARF2_ADDR_SIZE - size) * BITS_PER_UNIT
+ : shiftr;
+ if (shiftl > 0)
+   {
+ add_loc_descr (&deref, uint_loc_descriptor (shiftl));
+ add_loc_descr (&deref, new_loc_descr (DW_OP_shl, 0, 0));
+   }
+ add_loc_descr (&deref, uint_loc_descriptor (shiftr));
  add_loc_descr (&deref, new_loc_descr (DW_OP_shra, 0, 0));
}
}


[gcc(refs/users/mikael/heads/refactor_descriptor_v05)] Mise à jour motif dump allocate_with_mold_2.f90

2025-05-22 Thread Mikael Morin via Gcc-cvs
https://gcc.gnu.org/g:2c39fe3d7c1e933a175fcbf5aeef5d9f5223719d

commit 2c39fe3d7c1e933a175fcbf5aeef5d9f5223719d
Author: Mikael Morin 
Date:   Thu May 22 11:10:44 2025 +0200

Mise à jour motif dump allocate_with_mold_2.f90

Diff:
---
 gcc/testsuite/gfortran.dg/allocate_with_mold_2.f90 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/testsuite/gfortran.dg/allocate_with_mold_2.f90 
b/gcc/testsuite/gfortran.dg/allocate_with_mold_2.f90
index fcf7a8a44250..d4a9959fa37e 100644
--- a/gcc/testsuite/gfortran.dg/allocate_with_mold_2.f90
+++ b/gcc/testsuite/gfortran.dg/allocate_with_mold_2.f90
@@ -59,4 +59,4 @@
   END IF
 END IF
   END PROGRAM MFE
-! { dg-final { scan-tree-dump-times "it_objs->_vptr->_size" 1 "original" } }
+! { dg-final { scan-tree-dump-times {it_objs\._vptr->_size} 1 "original" } }


[gcc(refs/users/mikael/heads/refactor_descriptor_v05)] Correction régression deferred_character_37

2025-05-22 Thread Mikael Morin via Gcc-cvs
https://gcc.gnu.org/g:d146a602c464c00fda09689ea25365e3c51e3f6b

commit d146a602c464c00fda09689ea25365e3c51e3f6b
Author: Mikael Morin 
Date:   Thu May 22 11:30:53 2025 +0200

Correction régression deferred_character_37

Diff:
---
 libgfortran/intrinsics/spread_generic.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/libgfortran/intrinsics/spread_generic.c 
b/libgfortran/intrinsics/spread_generic.c
index 6c2bc4231178..7f63e8b6c4e2 100644
--- a/libgfortran/intrinsics/spread_generic.c
+++ b/libgfortran/intrinsics/spread_generic.c
@@ -71,23 +71,23 @@ spread_internal (gfc_array_char *ret, const gfc_array_char 
*source,
   /* The front end has signalled that we need to populate the
 return array descriptor.  */
 
-  size_t ub, stride;
-  index_type spacing;
+  size_t ub, spacing;
+  index_type next_spacing;
 
   ret->dtype.rank = rrank;
 
   dim = 0;
   rs = 1;
-  spacing = size;
+  next_spacing = size;
   for (n = 0; n < rrank; n++)
{
- stride = rs;
+ spacing = next_spacing;
  if (n == *along - 1)
{
  ub = ncopies - 1;
  rdelta = rs * size;
  rs *= ncopies;
- spacing *= ncopies;
+ next_spacing *= ncopies;
}
  else
{
@@ -98,7 +98,7 @@ spread_internal (gfc_array_char *ret, const gfc_array_char 
*source,
 
  ub = extent[dim]-1;
  rs *= extent[dim];
- spacing *= extent[dim];
+ next_spacing *= extent[dim];
  dim++;
}


[gcc(refs/users/mikael/heads/refactor_descriptor_v05)] Mise à jour motif dump coarray_lib_token_4

2025-05-22 Thread Mikael Morin via Gcc-cvs
https://gcc.gnu.org/g:0fc70a165c5bd2cc42534095d91af81d10c54097

commit 0fc70a165c5bd2cc42534095d91af81d10c54097
Author: Mikael Morin 
Date:   Thu May 22 11:52:57 2025 +0200

Mise à jour motif dump coarray_lib_token_4

Diff:
---
 gcc/testsuite/gfortran.dg/coarray_lib_token_4.f90 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/testsuite/gfortran.dg/coarray_lib_token_4.f90 
b/gcc/testsuite/gfortran.dg/coarray_lib_token_4.f90
index fe500684fb5d..21039e7e38ad 100644
--- a/gcc/testsuite/gfortran.dg/coarray_lib_token_4.f90
+++ b/gcc/testsuite/gfortran.dg/coarray_lib_token_4.f90
@@ -33,7 +33,7 @@ contains
   end subroutine expl
 end program test_caf
 
-! { dg-final { scan-tree-dump-times "expl \\(integer\\(kind=4\\).0:. . 
restrict z, void . restrict caf_token.\[0-9\]+, integer\\(kind=.\\) 
caf_offset.\[0-9\]+\\)" 1 "original" } }
+! { dg-final { scan-tree-dump-times {expl \(integer\(kind=4\).[01]:. . 
restrict z, void . restrict caf_token.[0-9]+, integer\(kind=.\) 
caf_offset.[0-9]+\)} 1 "original" } }
 !
 ! { dg-final { scan-tree-dump-times "bar \\(struct array02_integer\\(kind=4\\) 
& restrict y, void . restrict caf_token.\[0-9\]+, integer\\(kind=.\\) 
caf_offset.\[0-9\]+\\)" 1 "original" } }
 !


[gcc(refs/users/mikael/heads/refactor_descriptor_v05)] Correction partielle class_transformational_2

2025-05-22 Thread Mikael Morin via Gcc-cvs
https://gcc.gnu.org/g:adba604ceca25d2c0ec3a312b8eb0e23aebe2247

commit adba604ceca25d2c0ec3a312b8eb0e23aebe2247
Author: Mikael Morin 
Date:   Thu May 22 17:08:12 2025 +0200

Correction partielle class_transformational_2

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

diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc
index a3d4c007d31e..c1d46b8e98d0 100644
--- a/gcc/fortran/trans-array.cc
+++ b/gcc/fortran/trans-array.cc
@@ -2841,13 +2841,13 @@ gfc_add_loop_ss_code (gfc_loopinfo * loop, gfc_ss * ss, 
bool subscript,
  missing_spacing = true;
  break;
}
-   if (missing_spacing
-   && ss_info->expr->ts.type != BT_CLASS)
+   if (missing_spacing)
  {
tree type = gfc_typenode_for_spec (&ss_info->expr->ts);
if (TYPE_SIZE_UNIT (type) == NULL_TREE
|| !INTEGER_CST_P (TYPE_SIZE_UNIT (type))
-   || gfc_expr_attr (ss_info->expr).pointer)
+   || expr->ts.type == BT_CLASS
+   || gfc_expr_attr (expr).pointer)
  {
for (n = 0; n < ss_info->expr->rank; n++)
  {


[gcc(refs/users/mikael/heads/refactor_descriptor_v05)] Correction partielle régression class_transformational_2

2025-05-22 Thread Mikael Morin via Gcc-cvs
https://gcc.gnu.org/g:26383c0b0a5aaa3248dd4949928faf734291364e

commit 26383c0b0a5aaa3248dd4949928faf734291364e
Author: Mikael Morin 
Date:   Thu May 22 19:28:41 2025 +0200

Correction partielle régression class_transformational_2

Diff:
---
 gcc/fortran/trans-array.cc |  3 ---
 gcc/fortran/trans-expr.cc  | 15 ---
 2 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc
index c1d46b8e98d0..b28d65445bc6 100644
--- a/gcc/fortran/trans-array.cc
+++ b/gcc/fortran/trans-array.cc
@@ -1142,9 +1142,6 @@ gfc_trans_create_temp_array (stmtblock_t * pre, 
stmtblock_t * post, gfc_ss * ss,
 
   class_data = gfc_class_data_get (tmp);
 
-  if (rank_changer)
-   fcn_ss->info->class_container = NULL_TREE;
-
   /* Assign the new descriptor to the _data field. This allows the
 vptr _copy to be used for scalarized assignment since the class
 temporary can be found from the descriptor.  */
diff --git a/gcc/fortran/trans-expr.cc b/gcc/fortran/trans-expr.cc
index 323bec17093c..93420e756361 100644
--- a/gcc/fortran/trans-expr.cc
+++ b/gcc/fortran/trans-expr.cc
@@ -8379,6 +8379,10 @@ gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym,
   !sym->attr.pointer, callee_alloc,
   &se->ss->info->expr->where, true);
 
+ if (se->ss->info->class_container
+ && !se->class_container)
+   se->class_container = se->ss->info->class_container;
+
  /* Pass the temporary as the first argument.  */
  result = info->descriptor;
  tmp = gfc_build_addr_expr (NULL_TREE, result);
@@ -12810,10 +12814,15 @@ gfc_trans_assignment_1 (gfc_expr * expr1, gfc_expr * 
expr2, bool init_flag,
 references. Use the vptr copy function, since this does a deep
 copy of allocatable components, without which the finalizer call
 will deallocate the components.  */
-  tmp = gfc_get_vptr_from_expr (rse.expr);
-  if (tmp != NULL_TREE)
+  tree cls = rse.class_container;
+  tree vptr;
+  if (cls == NULL_TREE)
+   vptr = gfc_get_vptr_from_expr (rse.expr);
+  else
+   vptr = gfc_class_vptr_get (cls);
+  if (vptr != NULL_TREE)
{
- tree fcn = gfc_vptr_copy_get (tmp);
+ tree fcn = gfc_vptr_copy_get (vptr);
  if (POINTER_TYPE_P (TREE_TYPE (fcn)))
fcn = build_fold_indirect_ref_loc (input_location, fcn);
  tmp = build_call_expr_loc (input_location,


[gcc(refs/users/meissner/heads/work206-bugs)] Disable fp cmove on power9

2025-05-22 Thread Michael Meissner via Gcc-cvs
https://gcc.gnu.org/g:6aff7ebb20085661a9f4ca7a4156188d63bfe7eb

commit 6aff7ebb20085661a9f4ca7a4156188d63bfe7eb
Author: Michael Meissner 
Date:   Thu May 22 16:40:42 2025 -0400

Disable fp cmove on power9

2025-05-22  Michael Meissner  

gcc/

PR target/118541
* config/rs6000/rs6000.cc (have_compare_and_set_mask): Disable 
unless
NaNs are disabled.

Diff:
---
 gcc/config/rs6000/rs6000.cc | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc
index 11dfde7f288b..a8a0e153c362 100644
--- a/gcc/config/rs6000/rs6000.cc
+++ b/gcc/config/rs6000/rs6000.cc
@@ -16509,11 +16509,17 @@ rs6000_maybe_emit_fp_cmove (rtx dest, rtx op, rtx 
true_cond, rtx false_cond)
 /* Helper function to return true if the target has instructions to do a
compare and set mask instruction that can be used with XXSEL to implement a
conditional move.  It is also assumed that such a target also supports the
-   "C" minimum and maximum instructions. */
+   "C" minimum and maximum instructions.
+
+   However, these instructions will trap if given a signaling NaN, so we can
+   only use them if NaNs are not expected.  */
 
 static bool
 have_compare_and_set_mask (machine_mode mode)
 {
+  if (!flag_finite_math_only)
+return false;
+
   switch (mode)
 {
 case E_SFmode:


[gcc(refs/users/meissner/heads/work206-bugs)] Update ChangeLog.*

2025-05-22 Thread Michael Meissner via Gcc-cvs
https://gcc.gnu.org/g:be460d43700b1e990b98d0f4b6b4cde831f8b537

commit be460d43700b1e990b98d0f4b6b4cde831f8b537
Author: Michael Meissner 
Date:   Thu May 22 16:41:49 2025 -0400

Update ChangeLog.*

Diff:
---
 gcc/ChangeLog.bugs | 12 
 1 file changed, 12 insertions(+)

diff --git a/gcc/ChangeLog.bugs b/gcc/ChangeLog.bugs
index f9eeb7439c96..607541cbd92c 100644
--- a/gcc/ChangeLog.bugs
+++ b/gcc/ChangeLog.bugs
@@ -1,3 +1,15 @@
+ Branch work206-bugs, patch #114 
+
+Disable fp cmove on power9
+
+2025-05-22  Michael Meissner  
+
+gcc/
+
+   PR target/118541
+   * config/rs6000/rs6000.cc (have_compare_and_set_mask): Disable unless
+   NaNs are disabled.
+
  Branch work206-bugs, patch #113 
 
 Fix PR 118541, do not generate unordered fp cmoves for IEEE compares.


[gcc r16-832] PR modula2/120389 ICE if assigning a constant char to an integer array

2025-05-22 Thread Gaius Mulley via Gcc-cvs
https://gcc.gnu.org/g:895a8abad245365940939911e3d0de850522791e

commit r16-832-g895a8abad245365940939911e3d0de850522791e
Author: Gaius Mulley 
Date:   Thu May 22 22:03:22 2025 +0100

PR modula2/120389 ICE if assigning a constant char to an integer array

This patch fixes an ICE which occurs if a constant char is assigned
into an integer array.  The fix it to introduce type checking in
M2GenGCC.mod:CodeXIndr.

gcc/m2/ChangeLog:

PR modula2/120389
* gm2-compiler/M2GenGCC.mod (CodeXIndr): Check to see that
the type of left is assignment compatible with the type of
right.

gcc/testsuite/ChangeLog:

PR modula2/120389
* gm2/iso/fail/badarray3.mod: New test.

Signed-off-by: Gaius Mulley 

Diff:
---
 gcc/m2/gm2-compiler/M2GenGCC.mod | 8 
 gcc/testsuite/gm2/iso/fail/badarray3.mod | 7 +++
 2 files changed, 15 insertions(+)

diff --git a/gcc/m2/gm2-compiler/M2GenGCC.mod b/gcc/m2/gm2-compiler/M2GenGCC.mod
index bc1d588fce6e..2dfa54a4 100644
--- a/gcc/m2/gm2-compiler/M2GenGCC.mod
+++ b/gcc/m2/gm2-compiler/M2GenGCC.mod
@@ -8229,6 +8229,14 @@ BEGIN
type := SkipType (type) ;
DeclareConstant (rightpos, right) ;
DeclareConstructor (rightpos, quad, right) ;
+   IF StrictTypeChecking AND
+  (NOT AssignmentTypeCompatible (xindrpos, "", GetType (left), right))
+   THEN
+  MetaErrorT2 (tokenno,
+   'assignment check caught mismatch between {%1Ead} and 
{%2ad}',
+   left, right) ;
+  SubQuad (quad)
+   END ;
IF IsProcType(SkipType(type))
THEN
   BuildAssignmentStatement (location, BuildIndirect (location, Mod2Gcc 
(left), GetPointerType ()), Mod2Gcc (right))
diff --git a/gcc/testsuite/gm2/iso/fail/badarray3.mod 
b/gcc/testsuite/gm2/iso/fail/badarray3.mod
new file mode 100644
index ..be53d21e74f3
--- /dev/null
+++ b/gcc/testsuite/gm2/iso/fail/badarray3.mod
@@ -0,0 +1,7 @@
+MODULE badarray3 ;
+
+VAR
+   x: ARRAY [1..5] OF INTEGER ;
+BEGIN
+   x[1] := 'c';
+END badarray3.


[gcc r14-11797] tree-sra: Do not create stores into const aggregates (PR111873)

2025-05-22 Thread Martin Jambor via Gcc-cvs
https://gcc.gnu.org/g:92d8b9970ea2ed59010a5f1a394cb98adffa63e8

commit r14-11797-g92d8b9970ea2ed59010a5f1a394cb98adffa63e8
Author: Martin Jambor 
Date:   Wed May 14 12:08:24 2025 +0200

tree-sra: Do not create stores into const aggregates (PR111873)

This patch fixes (hopefully the) one remaining place where gimple SRA
was still creating a load into const aggregates.  It occurs when there
is a replacement for a load but that replacement is not type
compatible - typically because it is a single field structure.

I have used testcases from duplicates because the original test-case
no longer reproduces for me.

gcc/ChangeLog:

2025-05-13  Martin Jambor  

PR tree-optimization/111873
* tree-sra.cc (sra_modify_expr): When processing a load which has
a type-incompatible replacement, do not store the contents of the
replacement into the original aggregate when that aggregate is
const.

gcc/testsuite/ChangeLog:

2025-05-13  Martin Jambor  

* gcc.dg/ipa/pr120044-1.c: New test.
* gcc.dg/ipa/pr120044-2.c: Likewise.
* gcc.dg/tree-ssa/pr114864.c: Likewise.

(cherry picked from commit 9d039eff453f777c58642ff16178c1ce2a4be6ab)

Diff:
---
 gcc/testsuite/gcc.dg/ipa/pr120044-1.c| 17 +
 gcc/testsuite/gcc.dg/ipa/pr120044-2.c| 17 +
 gcc/testsuite/gcc.dg/tree-ssa/pr114864.c | 15 +++
 gcc/tree-sra.cc  |  4 +++-
 4 files changed, 52 insertions(+), 1 deletion(-)

diff --git a/gcc/testsuite/gcc.dg/ipa/pr120044-1.c 
b/gcc/testsuite/gcc.dg/ipa/pr120044-1.c
new file mode 100644
index ..f9fee3e85afb
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/ipa/pr120044-1.c
@@ -0,0 +1,17 @@
+/* { dg-do run } */
+/* { dg-options "-O3 -fno-early-inlining -fno-tree-fre -fno-tree-pre 
-fno-code-hoisting -fno-inline" } */
+
+struct a {
+  int b;
+} const c;
+void d(char p, struct a e) {
+  while (e.b)
+;
+}
+static unsigned short f(const struct a g) {
+  d(g.b, g);
+  return g.b;
+}
+int main() {
+  return f(c);
+}
diff --git a/gcc/testsuite/gcc.dg/ipa/pr120044-2.c 
b/gcc/testsuite/gcc.dg/ipa/pr120044-2.c
new file mode 100644
index ..5130791f5444
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/ipa/pr120044-2.c
@@ -0,0 +1,17 @@
+/* { dg-do run } */
+/* { dg-options "-O3 -fno-early-inlining -fno-tree-fre -fno-tree-pre 
-fno-code-hoisting -fno-ipa-cp" } */
+
+struct a {
+  int b;
+} const c;
+void d(char p, struct a e) {
+  while (e.b)
+;
+}
+static unsigned short f(const struct a g) {
+  d(g.b, g);
+  return g.b;
+}
+int main() {
+  return f(c);
+}
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr114864.c 
b/gcc/testsuite/gcc.dg/tree-ssa/pr114864.c
new file mode 100644
index ..cd9b94c094fc
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pr114864.c
@@ -0,0 +1,15 @@
+/* { dg-do run } */
+/* { dg-options "-O1 -fno-tree-dce -fno-tree-fre" } */
+
+struct a {
+  int b;
+} const c;
+void d(const struct a f) {}
+void e(const struct a f) {
+  f.b == 0 ? 1 : f.b;
+  d(f);
+}
+int main() {
+  e(c);
+  return 0;
+}
diff --git a/gcc/tree-sra.cc b/gcc/tree-sra.cc
index 46ddd41fdcb9..6e09476418cd 100644
--- a/gcc/tree-sra.cc
+++ b/gcc/tree-sra.cc
@@ -4179,8 +4179,10 @@ sra_modify_expr (tree *expr, bool write, 
gimple_stmt_iterator *stmt_gsi,
}
  else
{
- gassign *stmt;
+ if (TREE_READONLY (access->base))
+   return false;
 
+ gassign *stmt;
  if (access->grp_partial_lhs)
repl = force_gimple_operand_gsi (stmt_gsi, repl, true,
 NULL_TREE, true,


[gcc r16-833] c: Document C23 implementation-defined behavior

2025-05-22 Thread Joseph Myers via Gcc-cvs
https://gcc.gnu.org/g:fbb7f1cb5d3c8b7604e8f966e04330570de3e3ca

commit r16-833-gfbb7f1cb5d3c8b7604e8f966e04330570de3e3ca
Author: Joseph Myers 
Date:   Thu May 22 21:39:37 2025 +

c: Document C23 implementation-defined behavior

Add references to C23 subclauses to the documentation of
implementation-defined behavior, and new entries for
implementation-defined behavior new in C23; change some references in
the text to e.g. "C99 and C11" to encompass C23 as well.

Tested with "make info html pdf".

* doc/implement-c.texi: Document C23 implementation-defined
behavior.
(Constant expressions implementation, Types implementation): New
nodes.

Diff:
---
 gcc/doc/implement-c.texi | 246 +--
 1 file changed, 175 insertions(+), 71 deletions(-)

diff --git a/gcc/doc/implement-c.texi b/gcc/doc/implement-c.texi
index a942a127cc7f..bdfb6342f0df 100644
--- a/gcc/doc/implement-c.texi
+++ b/gcc/doc/implement-c.texi
@@ -10,8 +10,8 @@ A conforming implementation of ISO C is required to document 
its
 choice of behavior in each of the areas that are designated
 ``implementation defined''.  The following lists all such areas,
 along with the section numbers from the ISO/IEC 9899:1990, ISO/IEC
-9899:1999 and ISO/IEC 9899:2011 standards.  Some areas are only
-implementation-defined in one version of the standard.
+9899:1999, ISO/IEC 9899:2011 and ISO/IEC 9899:2024 standards.  Some
+areas are only implementation-defined in one version of the standard.
 
 Some choices depend on the externally determined ABI for the platform
 (including standard character encodings) which GCC follows; these are
@@ -47,15 +47,15 @@ a freestanding environment); refer to their documentation 
for details.
 
 @itemize @bullet
 @item
-@cite{How a diagnostic is identified (C90 3.7, C99 and C11 3.10, C90,
-C99 and C11 5.1.1.3).}
+@cite{How a diagnostic is identified (C90 3.7, C99 and C11 3.10, C23
+3.13, C90, C99 and C11 5.1.1.3, C23 5.2.1.3).}
 
 Diagnostics consist of all the output sent to stderr by GCC@.
 
 @item
 @cite{Whether each nonempty sequence of white-space characters other than
 new-line is retained or replaced by one space character in translation
-phase 3 (C90, C99 and C11 5.1.1.2).}
+phase 3 (C90, C99 and C11 5.1.1.2, C23 5.2.1.2).}
 
 @xref{Implementation-defined behavior, , Implementation-defined
 behavior, cpp, The C Preprocessor}.
@@ -72,7 +72,7 @@ of the C library, and are not defined by GCC itself.
 @item
 @cite{The mapping between physical source file multibyte characters
 and the source character set in translation phase 1 (C90, C99 and C11
-5.1.1.2).}
+5.1.1.2, C23 5.2.1.2).}
 
 @xref{Implementation-defined behavior, , Implementation-defined
 behavior, cpp, The C Preprocessor}.
@@ -85,14 +85,16 @@ behavior, cpp, The C Preprocessor}.
 @itemize @bullet
 @item
 @cite{Which additional multibyte characters may appear in identifiers
-and their correspondence to universal character names (C99 and C11 6.4.2).}
+and their correspondence to universal character names (C99 and C11
+6.4.2, C23 6.4.3).}
 
 @xref{Implementation-defined behavior, , Implementation-defined
 behavior, cpp, The C Preprocessor}.
 
 @item
 @cite{The number of significant initial characters in an identifier
-(C90 6.1.2, C90, C99 and C11 5.2.4.1, C99 and C11 6.4.2).}
+(C90 6.1.2, C90, C99 and C11 5.2.4.1, C23 5.3.5.2, C99 and C11 6.4.2,
+C23 6.4.3).}
 
 For internal names, all characters are significant.  For external names,
 the number of significant characters are defined by the linker; for
@@ -102,7 +104,7 @@ almost all targets, all characters are significant.
 @cite{Whether case distinctions are significant in an identifier with
 external linkage (C90 6.1.2).}
 
-This is a property of the linker.  C99 and C11 require that case distinctions
+This is a property of the linker.  C99 and later require that case distinctions
 are always significant in identifiers with external linkage and
 systems without this property are not supported by GCC@.
 
@@ -113,34 +115,35 @@ systems without this property are not supported by GCC@.
 
 @itemize @bullet
 @item
-@cite{The number of bits in a byte (C90 3.4, C99 and C11 3.6).}
+@cite{The number of bits in a byte (C90 3.4, C99 and C11 3.6, C23 3.7).}
 
 Determined by ABI@.
 
 @item
 @cite{The values of the members of the execution character set (C90,
-C99 and C11 5.2.1).}
+C99 and C11 5.2.1, C23 5.3.1).}
 
 Determined by ABI@.
 
 @item
 @cite{The unique value of the member of the execution character set produced
 for each of the standard alphabetic escape sequences (C90, C99 and C11
-5.2.2).}
+5.2.2, C23 5.3.3).}
 
 Determined by ABI@.
 
 @item
 @cite{The value of a @code{char} object into which has been stored any
 character other than a member of the basic execution character set
-(C90 6.1.2.5, C99 and C11 6.2.5).}
+(C90 6.1.2.5, C99, C11 and C23 6.2.5).}
 
 Determined by ABI@.
 
 @item
 @cite{Which of @cod

[gcc r16-816] testsuite: aarch64: arm: Fix -mcpu=unset support in shared effective targets

2025-05-22 Thread Christophe Lyon via Gcc-cvs
https://gcc.gnu.org/g:f716eb6065aaf62b46f223a08f2666cce3e5ff99

commit r16-816-gf716eb6065aaf62b46f223a08f2666cce3e5ff99
Author: Christophe Lyon 
Date:   Tue May 20 16:42:18 2025 +

testsuite: aarch64: arm: Fix -mcpu=unset support in shared effective targets

Many tests became unsupported on aarch64 when -mcpu=unset was added to
several arm_* effective targets, because this flag is only supported
on arm.

Since these effective targets are used on arm and aarch64, the patch
adds -mcpu=unset on arm only, and restores "" on aarch64.

This re-enables lots of tests:
advsimd-intrinsics/vqrdmlah
fp16 tests
dotprod tests
i8mm tests
aarch64/simd/vmmla.c
bf16 tests
gcc.dg/vect/complex tests

With this change, a few more failures appear, but should be fixed 
separately:
FAIL: gcc.dg/vect/complex/fast-math-complex-mls-double.c -flto 
-ffat-lto-objects  scan-tree-dump vect "Found COMPLEX_ADD_ROT270"
FAIL: gcc.dg/vect/complex/fast-math-complex-mls-double.c scan-tree-dump 
vect "Found COMPLEX_ADD_ROT270"
FAIL: gcc.dg/vect/complex/fast-math-complex-mls-float.c -flto 
-ffat-lto-objects  scan-tree-dump vect "Found COMPLEX_ADD_ROT270"
FAIL: gcc.dg/vect/complex/fast-math-complex-mls-float.c scan-tree-dump vect 
"Found COMPLEX_ADD_ROT270"
FAIL: gcc.dg/vect/complex/fast-math-complex-mls-half-float.c -flto 
-ffat-lto-objects  scan-tree-dump vect "Found COMPLEX_ADD_ROT270"
FAIL: gcc.dg/vect/complex/fast-math-complex-mls-half-float.c scan-tree-dump 
vect "Found COMPLEX_ADD_ROT270"

gcc/testsuite/ChangeLog

* lib/target-supports.exp 
(check_effective_target_arm_v8_1a_neon_ok_nocache): Use
-mcpu=unset on arm only.
(check_effective_target_arm_v8_2a_fp16_scalar_ok_nocache): Likewise.
(check_effective_target_arm_v8_2a_fp16_neon_ok_nocache): Likewise.
(check_effective_target_arm_v8_2a_dotprod_neon_ok_nocache): 
Likewise.
(check_effective_target_arm_v8_2a_i8mm_ok_nocache): Likewise.
(check_effective_target_arm_v8_2a_bf16_neon_ok_nocache): Likewise.
(check_effective_target_arm_v8_3a_complex_neon_ok_nocache): 
Likewise.
(check_effective_target_arm_v8_3a_fp16_complex_neon_ok_nocache): 
Likewise.

Diff:
---
 gcc/testsuite/lib/target-supports.exp | 71 +++
 1 file changed, 56 insertions(+), 15 deletions(-)

diff --git a/gcc/testsuite/lib/target-supports.exp 
b/gcc/testsuite/lib/target-supports.exp
index e0495d8437c9..6286e361fed0 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -6631,17 +6631,23 @@ proc add_options_for_arm_v8_1m_mve_fp { flags } {
 proc check_effective_target_arm_v8_1a_neon_ok_nocache { } {
 global et_arm_v8_1a_neon_flags
 set et_arm_v8_1a_neon_flags ""
+set cpu_unset ""
 
 if { ![istarget arm*-*-*] && ![istarget aarch64*-*-*] } {
return 0;
 }
 
+if { [istarget arm*-*-*] } {
+   set cpu_unset "-mcpu=unset"
+}
+
 # Iterate through sets of options to find the compiler flags that
 # need to be added to the -march option.  Start with the empty set
 # since AArch64 only needs the -march setting.
 foreach flags {"" "-mfpu=neon-fp-armv8" "-mfloat-abi=softfp" \
   "-mfpu=neon-fp-armv8 -mfloat-abi=softfp"} {
-   foreach arches { "-mcpu=unset -march=armv8-a+rdma" "-mcpu=unset 
-march=armv8.1-a" } {
+   foreach arches [list "$cpu_unset -march=armv8-a+rdma" \
+   "$cpu_unset -march=armv8.1-a" ] {
if { [check_no_compiler_messages_nocache arm_v8_1a_neon_ok object {
#if !defined (__ARM_FEATURE_QRDMX)
#error "__ARM_FEATURE_QRDMX not defined"
@@ -6668,11 +6674,16 @@ proc check_effective_target_arm_v8_1a_neon_ok { } {
 proc check_effective_target_arm_v8_2a_fp16_scalar_ok_nocache { } {
 global et_arm_v8_2a_fp16_scalar_flags
 set et_arm_v8_2a_fp16_scalar_flags ""
+set cpu_unset ""
 
 if { ![istarget arm*-*-*] && ![istarget aarch64*-*-*] } {
return 0;
 }
 
+if { [istarget arm*-*-*] } {
+   set cpu_unset "-mcpu=unset"
+}
+
 # Iterate through sets of options to find the compiler flags that
 # need to be added to the -march option.
 foreach flags {"" "-mfpu=fp-armv8" "-mfloat-abi=softfp" \
@@ -6682,8 +6693,8 @@ proc 
check_effective_target_arm_v8_2a_fp16_scalar_ok_nocache { } {
#if !defined (__ARM_FEATURE_FP16_SCALAR_ARITHMETIC)
#error "__ARM_FEATURE_FP16_SCALAR_ARITHMETIC not defined"
#endif
-   } "$flags -mcpu=unset -march=armv8.2-a+fp16"] } {
-   set et_arm_v8_2a_fp16_scalar_flags "$flags -mcpu=unset 
-march=armv8.2-a+fp16"
+   } "$flags $cpu_unset -march=armv8.2-a+fp16"] } {
+   set et_arm_v8_2a_fp16_scalar_flags "$flags $cpu_unset 
-march=armv8.2-a+fp16"
return 1

[gcc r16-815] i386: Extend *cmp_minus_1 optimizations also to plus with CONST_INT [PR120360]

2025-05-22 Thread Jakub Jelinek via Gcc-cvs
https://gcc.gnu.org/g:5f4e794fd3efb0e44a6b5afdead95033df69c41b

commit r16-815-g5f4e794fd3efb0e44a6b5afdead95033df69c41b
Author: Jakub Jelinek 
Date:   Thu May 22 09:09:48 2025 +0200

i386: Extend *cmp_minus_1 optimizations also to plus with CONST_INT 
[PR120360]

As mentioned by Linus, we can't optimize comparison of otherwise unused
result of plus with CONST_INT second operand, compared against zero.
This can be done using just cmp instruction with negated constant and say
js/jns/je/jne etc. conditional jumps (or setcc).
We already have *cmp_minus_1 instruction which handles it when
(as shown in foo in the testcase) the IL has MINUS rather than PLUS,
but for constants except for the minimum value the canonical form is
with PLUS.

The following patch adds a new pattern and predicate to handle this.

2025-05-22  Jakub Jelinek  

PR target/120360
* config/i386/predicates.md (x86_64_neg_const_int_operand): New
predicate.
* config/i386/i386.md (*cmp_plus_1): New pattern.

* gcc.target/i386/pr120360.c: New test.

Diff:
---
 gcc/config/i386/i386.md  | 14 +
 gcc/config/i386/predicates.md| 17 +++
 gcc/testsuite/gcc.target/i386/pr120360.c | 36 
 3 files changed, 67 insertions(+)

diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md
index af4f12956251..b7a18d583da3 100644
--- a/gcc/config/i386/i386.md
+++ b/gcc/config/i386/i386.md
@@ -1599,6 +1599,20 @@
   [(set_attr "type" "icmp")
(set_attr "mode" "")])
 
+(define_insn "*cmp_plus_1"
+  [(set (reg FLAGS_REG)
+   (compare
+ (plus:SWI (match_operand:SWI 0 "nonimmediate_operand" "m")
+   (match_operand:SWI 1 "x86_64_neg_const_int_operand" "n"))
+ (const_int 0)))]
+  "ix86_match_ccmode (insn, CCGOCmode)"
+{
+  operands[1] = gen_int_mode (-INTVAL (operands[1]), mode);
+  return "cmp{}\t{%1, %0|%0, %1}";
+}
+  [(set_attr "type" "icmp")
+   (set_attr "mode" "")])
+
 (define_insn "*cmpqi_ext_1"
   [(set (reg FLAGS_REG)
(compare
diff --git a/gcc/config/i386/predicates.md b/gcc/config/i386/predicates.md
index 10ed6a5de56e..1bd63b2367e1 100644
--- a/gcc/config/i386/predicates.md
+++ b/gcc/config/i386/predicates.md
@@ -393,6 +393,23 @@
   return false;
 })
 
+;; Return true if VALUE is a constant integer whose negation satisfies
+;; x86_64_immediate_operand.
+(define_predicate "x86_64_neg_const_int_operand"
+  (match_code "const_int")
+{
+  HOST_WIDE_INT val = -UINTVAL (op);
+  if (mode == DImode && trunc_int_for_mode (val, SImode) != val)
+return false;
+  if (flag_cf_protection & CF_BRANCH)
+{
+  unsigned HOST_WIDE_INT endbr = TARGET_64BIT ? 0xfa1e0ff3 : 0xfb1e0ff3;
+  if ((val & HOST_WIDE_INT_C (0x)) == endbr)
+   return false;
+}
+  return true;
+})
+
 ;; Return true if VALUE is a constant integer whose low and high words satisfy
 ;; x86_64_immediate_operand.
 (define_predicate "x86_64_hilo_int_operand"
diff --git a/gcc/testsuite/gcc.target/i386/pr120360.c 
b/gcc/testsuite/gcc.target/i386/pr120360.c
new file mode 100644
index ..69c510ef004d
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr120360.c
@@ -0,0 +1,36 @@
+/* PR target/120360 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -fno-stack-protector -masm=att" } */
+/* { dg-additional-options "-fno-pic" { target { ! *-*-darwin* } } } */
+/* { dg-final { scan-assembler-times "\tjn*s\t" 3 } } */
+/* { dg-final { scan-assembler-times "\tcmp\[lq]\t%" 1 } } */
+/* { dg-final { scan-assembler-times "\tcmp\[lq]\t\\\$-1234," 1 } } */
+/* { dg-final { scan-assembler-times "\tcmp\[lq]\t\\\$2345," 1 } } */
+/* { dg-final { scan-assembler-not "\tadd\[lq]\t" { target { ! *-*-darwin* } } 
} } */
+/* { dg-final { scan-assembler-not "\tsub\[lq]\t" { target { ! *-*-darwin* } } 
} } */
+
+void qux (unsigned long);
+
+void
+foo (unsigned long x, unsigned long y)
+{
+  unsigned long z = x - y;
+  if ((long) z < 0)
+qux (x);
+}
+
+void
+bar (unsigned long x)
+{
+  unsigned long z = x + 1234;
+  if ((long) z < 0)
+qux (x);
+}
+
+void
+baz (unsigned long x)
+{
+  unsigned long z = x - 2345;
+  if ((long) z < 0)
+qux (x);
+}


[gcc r16-817] doc: Document the 'q' constraint for LoongArch

2025-05-22 Thread Xi Ruoyao via Gcc-cvs
https://gcc.gnu.org/g:9c621efd2c54879fe4e42eb4c48b11a38931e105

commit r16-817-g9c621efd2c54879fe4e42eb4c48b11a38931e105
Author: Xi Ruoyao 
Date:   Wed May 21 15:05:27 2025 +0800

doc: Document the 'q' constraint for LoongArch

The kernel developers have requested such a constraint to use csrxchg
in inline assembly.

gcc/ChangeLog:

* doc/md.texi: Document the 'q' constraint for LoongArch.

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

diff --git a/gcc/doc/md.texi b/gcc/doc/md.texi
index 1a1c1b730897..2a1f9919c5b2 100644
--- a/gcc/doc/md.texi
+++ b/gcc/doc/md.texi
@@ -2918,6 +2918,9 @@ A signed 16-bit constant.
 A memory operand whose address is formed by a base register and offset
 that is suitable for use in instructions with the same addressing mode
 as @code{st.w} and @code{ld.w}.
+@item q
+A general-purpose register except for $r0 and $r1 (for the csrxchg
+instruction)
 @item I
 A signed 12-bit constant (for arithmetic instructions).
 @item K


[gcc r16-818] bitintlower: Ensure extension of the most significant limb on info->extended targets

2025-05-22 Thread Jakub Jelinek via Gcc-cvs
https://gcc.gnu.org/g:63cd56d487bdea70bf30fb0db8cd4f755338d54b

commit r16-818-g63cd56d487bdea70bf30fb0db8cd4f755338d54b
Author: Jakub Jelinek 
Date:   Thu May 22 11:01:13 2025 +0200

bitintlower: Ensure extension of the most significant limb on 
info->extended targets

Shifts are the only special case I'm aware of where the most
significant limb (if it is has padding bits) is accessed inside of a loop or
with access outside of a loop but with variable idx.  Everything else should
access the most significant limb using INTEGER_CST idx and thus can (and
should) deal with the needed extension on that access directly.
And RSHIFT_EXPR shouldn't really violate the content of the padding bits.

For LSHIFT_EXPR we should IMHO do the following (which fixes the testcase
on s390x-linux).
The LSHIFT_EXPR is
  /* Lower
   dst = src << n;
 as
   unsigned n1 = n % limb_prec;
   size_t n2 = n / limb_prec;
   size_t n3 = n1 != 0;
   unsigned n4 = (limb_prec - n1) % limb_prec;
   size_t idx;
   size_t p = prec / limb_prec - (prec % limb_prec == 0);
   for (idx = p; (ssize_t) idx >= (ssize_t) (n2 + n3); --idx)
 dst[idx] = (src[idx - n2] << n1) | (src[idx - n2 - n3] >> n4);
   if (n1)
 {
   dst[idx] = src[idx - n2] << n1;
   --idx;
 }
   for (; (ssize_t) idx >= 0; --idx)
 dst[idx] = 0;  */
as described in the comment (note, the comments are for the little-endian
lowering only, didn't want to complicate it with endianity).
As can be seen, the most significant limb can be modifier either inside
of the loop or in the if (n1) body if the loop had 0 iterations.
In your patch you've modified I believe just the loop and not the if body,
and made it conditional on every iteration (furthermore through
gimplification of COND_EXPR which is not the way this is done elsewhere in
gimple-lower-bitint.cc, there is if_then helper and it builds
gimple_build_cond etc.).  I think that is way too expensive.  In theory we
could peel off the first iteration manually and do the info->extended
handling in there and do it again inside of the if (n1) case if idx ==
(bitint_big_endian ? size_zero_node : p) in that case, but I think just
doing the extension after the loops is easier.

Note, we don't need to worry about volatile here, the shift is done into
an addressable variable memory only if it is non-volatile, otherwise it
is computed into a temporary and then copied over into the volatile var.

2025-05-22  Jakub Jelinek  

* gimple-lower-bitint.cc (bitint_extended): New variable.
(bitint_large_huge::lower_shift_stmt): For LSHIFT_EXPR with
bitint_extended if lhs has most significant partial limb extend
it afterwards.

* gcc.dg/bitintext.h: New file.
* gcc.dg/torture/bitint-82.c: New test.

Diff:
---
 gcc/gimple-lower-bitint.cc   | 20 ++-
 gcc/testsuite/gcc.dg/bitintext.h | 29 ++
 gcc/testsuite/gcc.dg/torture/bitint-82.c | 94 
 3 files changed, 142 insertions(+), 1 deletion(-)

diff --git a/gcc/gimple-lower-bitint.cc b/gcc/gimple-lower-bitint.cc
index ebd4e9864a19..8fb7a604591d 100644
--- a/gcc/gimple-lower-bitint.cc
+++ b/gcc/gimple-lower-bitint.cc
@@ -77,7 +77,7 @@ enum bitint_prec_kind {
 
 static int small_max_prec, mid_min_prec, large_min_prec, huge_min_prec;
 static int limb_prec;
-static bool bitint_big_endian;
+static bool bitint_big_endian, bitint_extended;
 
 /* Categorize _BitInt(PREC) as small, middle, large or huge.  */
 
@@ -103,6 +103,7 @@ bitint_precision_kind (int prec)
   return bitint_prec_small;
 }
   bitint_big_endian = info.big_endian;
+  bitint_extended = info.extended;
   if (!large_min_prec
   && GET_MODE_PRECISION (limb_mode) < MAX_FIXED_MODE_SIZE)
 large_min_prec = MAX_FIXED_MODE_SIZE + 1;
@@ -3882,6 +3883,23 @@ bitint_large_huge::lower_shift_stmt (tree obj, gimple 
*stmt)
g = gimple_build_cond (GE_EXPR, add_cast (ssizetype, idx_next),
   ssize_int (0), NULL_TREE, NULL_TREE);
   insert_before (g);
+  if (bitint_extended && prec % limb_prec != 0)
+   {
+ /* The most significant limb has been updated either in the
+loop or in the if after it.  To simplify the code, just
+read it back from memory and extend.  */
+ m_gsi = gsi_after_labels (edge_false->dest);
+ idx = bitint_big_endian ? size_zero_node : p;
+ tree l = limb_access (TREE_TYPE (lhs), obj, idx, true);
+ tree type = limb_access_type (TREE_TYPE (lhs), idx);
+ tree v = make_ssa_name (m_limb_type);
+ g = gimple_build_assign (v, l);
+ 

[gcc r16-820] libstdc++: Fix PSTL test iterators

2025-05-22 Thread Jonathan Wakely via Gcc-cvs
https://gcc.gnu.org/g:c0a2526f099dfa52df5daa1432ff583ae6af0d5f

commit r16-820-gc0a2526f099dfa52df5daa1432ff583ae6af0d5f
Author: Jonathan Wakely 
Date:   Tue May 20 13:18:52 2025 +0100

libstdc++: Fix PSTL test iterators

These were fixed upstream by:
https://github.com/uxlfoundation/oneDPL/pull/534
https://github.com/uxlfoundation/oneDPL/pull/546

libstdc++-v3/ChangeLog:

* testsuite/util/pstl/test_utils.h (ForwardIterator::operator++):
Fix return type.
(BidirectionalIterator::operator++): Likewise.
(BidirectionalIterator::operator--): Likewise.

Diff:
---
 libstdc++-v3/testsuite/util/pstl/test_utils.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/libstdc++-v3/testsuite/util/pstl/test_utils.h 
b/libstdc++-v3/testsuite/util/pstl/test_utils.h
index 55b510098a04..9c61a7145f59 100644
--- a/libstdc++-v3/testsuite/util/pstl/test_utils.h
+++ b/libstdc++-v3/testsuite/util/pstl/test_utils.h
@@ -154,7 +154,7 @@ class ForwardIterator
 explicit ForwardIterator(Iterator i) : my_iterator(i) {}
 reference operator*() const { return *my_iterator; }
 Iterator operator->() const { return my_iterator; }
-ForwardIterator
+ForwardIterator&
 operator++()
 {
 ++my_iterator;
@@ -194,13 +194,13 @@ class BidirectionalIterator : public 
ForwardIterator
 explicit BidirectionalIterator(Iterator i) : base_type(i) {}
 BidirectionalIterator(const base_type& i) : base_type(i.iterator()) {}
 
-BidirectionalIterator
+BidirectionalIterator&
 operator++()
 {
 ++base_type::my_iterator;
 return *this;
 }
-BidirectionalIterator
+BidirectionalIterator&
 operator--()
 {
 --base_type::my_iterator;


[gcc r16-819] libstdc++: Fix vector(from_range_t, R&&) for exceptions [PR120367]

2025-05-22 Thread Jonathan Wakely via Libstdc++-cvs
https://gcc.gnu.org/g:04f2be72b1deecd6c6d454e000cfc0cb16db957c

commit r16-819-g04f2be72b1deecd6c6d454e000cfc0cb16db957c
Author: Jonathan Wakely 
Date:   Wed May 21 15:29:02 2025 +0100

libstdc++: Fix vector(from_range_t, R&&) for exceptions [PR120367]

Because this constructor delegates to vector(a) the object has been
fully constructed and the destructor will run if an exception happens.
That means we need to set _M_finish == _M_start so that the destructor
doesn't try to destroy any elements.

libstdc++-v3/ChangeLog:

PR libstdc++/120367
* include/bits/stl_vector.h (_M_range_initialize): Initialize
_M_impl._M_finish.
* testsuite/23_containers/vector/cons/from_range.cc: Check with
a type that throws on construction.
exceptions during construction.

Reviewed-by: Patrick Palka 

Diff:
---
 libstdc++-v3/include/bits/stl_vector.h |  3 ++-
 .../23_containers/vector/cons/from_range.cc| 22 ++
 2 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/libstdc++-v3/include/bits/stl_vector.h 
b/libstdc++-v3/include/bits/stl_vector.h
index 57680b7bbcf3..625c1c93195e 100644
--- a/libstdc++-v3/include/bits/stl_vector.h
+++ b/libstdc++-v3/include/bits/stl_vector.h
@@ -1969,8 +1969,9 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
_M_range_initialize_n(_Iterator __first, _Sentinel __last,
  size_type __n)
{
- pointer __start = this->_M_impl._M_start =
+ pointer __start =
this->_M_allocate(_S_check_init_len(__n, _M_get_Tp_allocator()));
+ this->_M_impl._M_start = this->_M_impl._M_finish = __start;
  this->_M_impl._M_end_of_storage = __start + __n;
  this->_M_impl._M_finish
  = std::__uninitialized_copy_a(_GLIBCXX_MOVE(__first), __last,
diff --git a/libstdc++-v3/testsuite/23_containers/vector/cons/from_range.cc 
b/libstdc++-v3/testsuite/23_containers/vector/cons/from_range.cc
index 7a62645283d2..3784b9cd66ad 100644
--- a/libstdc++-v3/testsuite/23_containers/vector/cons/from_range.cc
+++ b/libstdc++-v3/testsuite/23_containers/vector/cons/from_range.cc
@@ -106,8 +106,30 @@ test_constexpr()
   return true;
 }
 
+void
+test_pr120367()
+{
+#ifdef __cpp_exceptions
+  struct X
+  {
+X(int) { throw 1; } // Cannot successfully construct an X.
+~X() { VERIFY(false); } // So should never need to destroy one.
+  };
+
+  try
+  {
+int i[1]{};
+std::vector v(std::from_range, i);
+  }
+  catch (int)
+  {
+  }
+#endif
+}
+
 int main()
 {
   test_ranges();
   static_assert( test_constexpr() );
+  test_pr120367();
 }


[gcc(refs/users/meissner/heads/work206-bugs)] Update tests.

2025-05-22 Thread Michael Meissner via Gcc-cvs
https://gcc.gnu.org/g:55de8cd717f5201b4e820537c643afaf24b5da0a

commit 55de8cd717f5201b4e820537c643afaf24b5da0a
Author: Michael Meissner 
Date:   Thu May 22 19:21:23 2025 -0400

Update tests.

2025-05-22  Michael Meissner  

gcc/testsuite/

PR target/118541
* gcc.target/powerpc/p9-minmax-2.c: Delete test.
* gcc.target/powerpc/float128-minmax-3.c: Use -Ofast, not -O2.

Diff:
---
 .../gcc.target/powerpc/float128-minmax-3.c |   6 +-
 gcc/testsuite/gcc.target/powerpc/p9-minmax-2.c | 190 -
 2 files changed, 5 insertions(+), 191 deletions(-)

diff --git a/gcc/testsuite/gcc.target/powerpc/float128-minmax-3.c 
b/gcc/testsuite/gcc.target/powerpc/float128-minmax-3.c
index 6f7627c0f2a1..9c7474911981 100644
--- a/gcc/testsuite/gcc.target/powerpc/float128-minmax-3.c
+++ b/gcc/testsuite/gcc.target/powerpc/float128-minmax-3.c
@@ -1,6 +1,10 @@
 /* { dg-require-effective-target ppc_float128_hw } */
 /* { dg-require-effective-target power10_ok } */
-/* { dg-options "-mdejagnu-cpu=power10 -O2" } */
+/* { dg-options "-mdejagnu-cpu=power10 -Ofast" } */
+
+/* The XS{MAX,MIN}}CQP instructions will trap if a signaling NaN is one of the
+   arguments, so this code is now only generated if -Ofast or
+   -ffinite-math-only is used.  */
 
 #ifndef TYPE
 #define TYPE _Float128
diff --git a/gcc/testsuite/gcc.target/powerpc/p9-minmax-2.c 
b/gcc/testsuite/gcc.target/powerpc/p9-minmax-2.c
deleted file mode 100644
index 0684eb501c56..
--- a/gcc/testsuite/gcc.target/powerpc/p9-minmax-2.c
+++ /dev/null
@@ -1,190 +0,0 @@
-/* { dg-do compile } */
-/* { dg-options "-mdejagnu-cpu=power9 -mvsx -O2 -mpower9-minmax" } */
-/* { dg-require-effective-target powerpc_vsx } */
-/* { dg-final { scan-assembler-not "fsel"  } } */
-/* { dg-final { scan-assembler "xscmpeqdp" } } */
-/* { dg-final { scan-assembler "xscmpgtdp" } } */
-/* { dg-final { scan-assembler-not "xscmpodp"  } } */
-/* { dg-final { scan-assembler-not "xscmpudp"  } } */
-/* { dg-final { scan-assembler "xsmaxcdp"  } } */
-/* { dg-final { scan-assembler-not "xsmaxdp"   } } */
-/* { dg-final { scan-assembler "xsmincdp"  } } */
-/* { dg-final { scan-assembler-not "xsmindp"   } } */
-/* { dg-final { scan-assembler "xxsel" } } */
-
-/* Due to NaN support, <= and >= are not handled presently unless -ffast-math
-   is used.  At some point this will be fixed and the xscmpgedp instruction can
-   be generated normally. The <= and >= tests are bracketed with
-   #ifdef DO_GE_LE.  */
-
-#ifdef DO_GE_LE
-double
-dbl_max1 (double a, double b)
-{
-  return (a >= b) ? a : b;
-}
-#endif
-
-double
-dbl_max2 (double a, double b)
-{
-  return (a > b) ? a : b;
-}
-
-double
-dbl_min1 (double a, double b)
-{
-  return (a < b) ? a : b;
-}
-
-#ifdef DO_GE_LE
-double
-dbl_min2 (double a, double b)
-{
-  return (a <= b) ? a : b;
-}
-#endif
-
-double
-dbl_cmp_eq (double a, double b, double c, double d)
-{
-  return (a == b) ? c : d;
-}
-
-double
-dbl_cmp_ne (double a, double b, double c, double d)
-{
-  return (a != b) ? c : d;
-}
-
-double
-dbl_cmp_gt (double a, double b, double c, double d)
-{
-  return (a > b) ? c : d;
-}
-
-#ifdef DO_GE_LE
-double
-dbl_cmp_ge (double a, double b, double c, double d)
-{
-  return (a >= b) ? c : d;
-}
-#endif
-
-double
-dbl_cmp_lt (double a, double b, double c, double d)
-{
-  return (a < b) ? c : d;
-}
-
-#ifdef DO_GE_LE
-double
-dbl_cmp_le (double a, double b, double c, double d)
-{
-  return (a <= b) ? c : d;
-}
-#endif
-
-#ifdef DO_GE_LE
-float
-flt_max1 (float a, float b)
-{
-  return (a >= b) ? a : b;
-}
-#endif
-
-float
-flt_max2 (float a, float b)
-{
-  return (a > b) ? a : b;
-}
-
-float
-flt_min1 (float a, float b)
-{
-  return (a < b) ? a : b;
-}
-
-#ifdef DO_GE_LE
-float
-flt_min2 (float a, float b)
-{
-  return (a <= b) ? a : b;
-}
-#endif
-
-float
-flt_cmp_eq (float a, float b, float c, float d)
-{
-  return (a == b) ? c : d;
-}
-
-float
-flt_cmp_ne (float a, float b, float c, float d)
-{
-  return (a != b) ? c : d;
-}
-
-float
-flt_cmp_gt (float a, float b, float c, float d)
-{
-  return (a > b) ? c : d;
-}
-
-#ifdef DO_GE_LE
-float
-flt_cmp_ge (float a, float b, float c, float d)
-{
-  return (a >= b) ? c : d;
-}
-#endif
-
-float
-flt_cmp_lt (float a, float b, float c, float d)
-{
-  return (a < b) ? c : d;
-}
-
-#ifdef DO_GE_LE
-float
-flt_cmp_le (float a, float b, float c, float d)
-{
-  return (a <= b) ? c : d;
-}
-#endif
-
-double
-dbl_flt_max1 (float a, float b)
-{
-  return (a > b) ? a : b;
-}
-
-double
-dbl_flt_max2 (double a, float b)
-{
-  return (a > b) ? a : b;
-}
-
-double
-dbl_flt_max3 (float a, double b)
-{
-  return (a > b) ? a : b;
-}
-
-double
-dbl_flt_min1 (float a, float b)
-{
-  return (a < b) ? a : b;
-}
-
-double
-dbl_flt_min2 (double a, float b)
-{
-  return (a < b) ? a : b;
-}
-
-double
-dbl_flt_min3 (float a, double b)
-{
-  return (a < b) ? a : b;
-}


[gcc(refs/users/meissner/heads/work206-bugs)] Update ChangeLog.*

2025-05-22 Thread Michael Meissner via Gcc-cvs
https://gcc.gnu.org/g:7430006ce2aca8b9cf9be4f4e3b6de0cc87a1240

commit 7430006ce2aca8b9cf9be4f4e3b6de0cc87a1240
Author: Michael Meissner 
Date:   Thu May 22 19:22:53 2025 -0400

Update ChangeLog.*

Diff:
---
 gcc/ChangeLog.bugs | 12 
 1 file changed, 12 insertions(+)

diff --git a/gcc/ChangeLog.bugs b/gcc/ChangeLog.bugs
index 607541cbd92c..2779be6810bb 100644
--- a/gcc/ChangeLog.bugs
+++ b/gcc/ChangeLog.bugs
@@ -1,3 +1,15 @@
+ Branch work206-bugs, patch #115 
+
+Update tests.
+
+2025-05-22  Michael Meissner  
+
+gcc/testsuite/
+
+   PR target/118541
+   * gcc.target/powerpc/p9-minmax-2.c: Delete test.
+   * gcc.target/powerpc/float128-minmax-3.c: Use -Ofast, not -O2.
+
  Branch work206-bugs, patch #114 
 
 Disable fp cmove on power9


[gcc(refs/users/meissner/heads/work206-submit)] Fix PR 118541, do not generate unordered fp cmoves for IEEE compares.

2025-05-22 Thread Michael Meissner via Gcc-cvs
https://gcc.gnu.org/g:6282b4050761749140de9684accd21aa05d9b607

commit 6282b4050761749140de9684accd21aa05d9b607
Author: Michael Meissner 
Date:   Thu May 22 19:24:45 2025 -0400

Fix PR 118541, do not generate unordered fp cmoves for IEEE compares.

In bug PR target/118541 on power9, power10, and power11 systems, for the
function:

extern double __ieee754_acos (double);

double
__acospi (double x)
{
  double ret = __ieee754_acos (x) / 3.14;
  return __builtin_isgreater (ret, 1.0) ? 1.0 : ret;
}

GCC currently generates the following code:

Power9  Power10 and Power11
==  ===
bl __ieee754_acos   bl __ieee754_acos@notoc
nop plfd 0,.LC0@pcrel
addis 9,2,.LC2@toc@ha   xxspltidp 12,1065353216
addi 1,1,32 addi 1,1,32
lfd 0,.LC2@toc@l(9) ld 0,16(1)
addis 9,2,.LC0@toc@ha   fdiv 0,1,0
ld 0,16(1)  mtlr 0
lfd 12,.LC0@toc@l(9)xscmpgtdp 1,0,12
fdiv 0,1,0  xxsel 1,0,12,1
mtlr 0  blr
xscmpgtdp 1,0,12
xxsel 1,0,12,1
blr

This is because ifcvt.c optimizes the conditional floating point move to 
use the
XSCMPGTDP instruction.

However, the XSCMPGTDP instruction traps if one of the arguments is a 
signaling
NaN.  This patch disables generating XSCMP{EQ,GT,GE}{DP,QP} instructions 
unless
-ffinite-math-only is in effect so that we do not get a trap.

2025-05-22  Michael Meissner  

gcc/

PR target/118541
* config/rs6000/rs6000.md (movcc_p9): Disable
generating XSCMP{EQ,GT,GE}{DP,QP} unless -ffinite-math-only is in
effect.
(movcc_invert_p9): Likewise.
(fpmask, SFDF iterator): Likewise.
(xxsel, SFDF iterator): Likewise.
(movcc, IEEE128 iterator): Likewise.
(movcc_p10): Likewise.
(movcc_invert_p10): Likewise.
(fpmask, IEEE128 iterator): Likewise.
(xxsel, IEEE128 iterator): Likewise.

gcc/testsuite/

PR target/118541
* gcc.target/powerpc/float128-cmove.c: Change optimization flag to
-Ofast instead of -O2.

2025-05-22  Michael Meissner  

gcc/

PR target/118541
* config/rs6000/rs6000.cc (have_compare_and_set_mask): Disable 
unless
NaNs are disabled.

2025-05-22  Michael Meissner  

gcc/testsuite/

PR target/118541
* gcc.target/powerpc/p9-minmax-2.c: Delete test.
* gcc.target/powerpc/float128-minmax-3.c: Use -Ofast, not -O2.

Diff:
---
 gcc/config/rs6000/rs6000.cc|   8 +-
 gcc/config/rs6000/rs6000.md|  27 ++-
 gcc/testsuite/gcc.target/powerpc/float128-cmove.c  |   6 +-
 .../gcc.target/powerpc/float128-minmax-3.c |   6 +-
 gcc/testsuite/gcc.target/powerpc/p9-minmax-2.c | 190 -
 5 files changed, 35 insertions(+), 202 deletions(-)

diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc
index 7ea377781034..0ef509f06230 100644
--- a/gcc/config/rs6000/rs6000.cc
+++ b/gcc/config/rs6000/rs6000.cc
@@ -16409,11 +16409,17 @@ rs6000_maybe_emit_fp_cmove (rtx dest, rtx op, rtx 
true_cond, rtx false_cond)
 /* Helper function to return true if the target has instructions to do a
compare and set mask instruction that can be used with XXSEL to implement a
conditional move.  It is also assumed that such a target also supports the
-   "C" minimum and maximum instructions. */
+   "C" minimum and maximum instructions.
+
+   However, these instructions will trap if given a signaling NaN, so we can
+   only use them if NaNs are not expected.  */
 
 static bool
 have_compare_and_set_mask (machine_mode mode)
 {
+  if (!flag_finite_math_only)
+return false;
+
   switch (mode)
 {
 case E_SFmode:
diff --git a/gcc/config/rs6000/rs6000.md b/gcc/config/rs6000/rs6000.md
index 9c718ca2a226..c13101eb4318 100644
--- a/gcc/config/rs6000/rs6000.md
+++ b/gcc/config/rs6000/rs6000.md
@@ -5653,6 +5653,10 @@
   "fsel %0,%1,%2,%3"
   [(set_attr "type" "fp")])
 
+;; On power9, we can generate XSCMP{EQ,GT,GE}DP and XXSEL to do a floating
+;; point conditional move.  However, these instructions trap if one of the
+;; arguments is a signalling NaN.  Therefore we can only do this optimize if
+;; NaNs are not expected in the code.
 (define_insn_and_split "*movcc_p9"
   [(set (match_operand:SFDF 0 "vsx_register_operand" "=&wa,wa")
(if_then_else:SFDF
@@ -5662,7 +5666,7 @@
 (match_operand:S

[gcc r16-835] [MAINTAINERS] Add myself to write after approval and DCO.

2025-05-22 Thread Dhruv Chawla via Gcc-cvs
https://gcc.gnu.org/g:3213828f74f2f27a2dd91792cef27117ba1a522e

commit r16-835-g3213828f74f2f27a2dd91792cef27117ba1a522e
Author: Dhruv Chawla 
Date:   Fri May 23 09:51:21 2025 +0530

[MAINTAINERS] Add myself to write after approval and DCO.

ChangeLog:

* MAINTAINERS: Add myself to write after approval and DCO.

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

diff --git a/MAINTAINERS b/MAINTAINERS
index 8993d176c22e..f40d63504620 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -402,6 +402,7 @@ Stephane Carrez ciceron 

 Gabriel Charettegchare  
 Arnaud Charlet  charlet 
 Chandra Chavva  -   
+Dhruv Chawladhruvc  
 Dehao Chen  dehao   
 Fabien Chênefabien  
 Bin Cheng   amker   
@@ -932,6 +933,7 @@ information.
 
 
 Soumya AR   
+Dhruv Chawla
 Juergen Christ  
 Giuseppe D'Angelo   
 Robin Dapp