[gcc r15-9436] rust: Use error_operand_p in rust-gcc.cc

2025-04-14 Thread Arthur Cohen via Gcc-cvs
https://gcc.gnu.org/g:a2db03fdf37ba823c9acf479aaed841b7d0de761

commit r15-9436-ga2db03fdf37ba823c9acf479aaed841b7d0de761
Author: Andrew Pinski 
Date:   Wed Mar 19 17:30:00 2025 -0700

rust: Use error_operand_p in rust-gcc.cc

Just a simple cleanupof the code to use error_operand_p
instead of directly comparing against error_mark_node.

This also moves some cdoe around when dealing with error_operand_p
just to be faster and/or slightly tighten up the code slightly.

gcc/rust/ChangeLog:

* rust-gcc.cc (Bvariable::get_tree): Use error_operand_p.
(pointer_type): Likewise.
(reference_type): Likewise.
(immutable_type): Likewise.
(function_type): Likewise.
(function_type_variadic): Likewise.
Cleanup the check for receiver.type first.
(function_ptr_type): Use error_operand_p.
(fill_in_fields): Likewise.
(fill_in_array): Likewise.
(named_type): Likewise.
(type_size): Likewise.
(type_alignment): Likewise.
(type_field_alignment): Likewise.
(type_field_offset): Likewise.
(zero_expression): Likewise.
(float_constant_expression): Likewise.
(convert_expression): Likewise.
(struct_field_expression): Likewise.
(compound_expression): Likewise.
(conditional_expression): Likewise.
(negation_expression): Likewise.
(arithmetic_or_logical_expression): Likewise.
(arithmetic_or_logical_expression_checked): Likewise.
(comparison_expression): Likewise.
(lazy_boolean_expression): Likewise.
(constructor_expression): Likewise.
(array_constructor_expression): Likewise.
(array_index_expression): Likewise.
(call_expression): Likewise.
(init_statement): Likewise.
(assignment_statement): Likewise.
(return_statement): Likewise.
(exception_handler_statement): Likewise.
(if_statement): Likewise.
(compound_statement): Likewise.
Tighten up the code, removing t variable.
(statement_list): Use error_operand_p.
(block): Likewise.
(block_add_statements): Likewise.
(convert_tree): Likewise.
(global_variable): Likewise.
(global_variable_set_init): Likewise.
(local_variable): Likewise.
(parameter_variable): Likewise.
(static_chain_variable): Likewise.
(temporary_variable): Likewise.
(function): Likewise. Tighten up the code.
(function_defer_statement): Use error_operand_p.
(function_set_parameters): Use error_operand_p.
(write_global_definitions): Use error_operand_p.
Tighten up the code around the loop.

Signed-off-by: Andrew Pinski 

Diff:
---
 gcc/rust/rust-gcc.cc | 189 ---
 1 file changed, 88 insertions(+), 101 deletions(-)

diff --git a/gcc/rust/rust-gcc.cc b/gcc/rust/rust-gcc.cc
index 7c5af211bbc7..13b7cea6a3fc 100644
--- a/gcc/rust/rust-gcc.cc
+++ b/gcc/rust/rust-gcc.cc
@@ -61,7 +61,7 @@
 tree
 Bvariable::get_tree (location_t location) const
 {
-  if (this->t_ == error_mark_node)
+  if (error_operand_p (this->t_))
 return error_mark_node;
 
   TREE_USED (this->t_) = 1;
@@ -431,7 +431,7 @@ float_type (int bits)
 tree
 pointer_type (tree to_type)
 {
-  if (to_type == error_mark_node)
+  if (error_operand_p (to_type))
 return error_mark_node;
   tree type = build_pointer_type (to_type);
   return type;
@@ -442,7 +442,7 @@ pointer_type (tree to_type)
 tree
 reference_type (tree to_type)
 {
-  if (to_type == error_mark_node)
+  if (error_operand_p (to_type))
 return error_mark_node;
   tree type = build_reference_type (to_type);
   return type;
@@ -453,7 +453,7 @@ reference_type (tree to_type)
 tree
 immutable_type (tree base)
 {
-  if (base == error_mark_node)
+  if (error_operand_p (base))
 return error_mark_node;
   tree constified = build_qualified_type (base, TYPE_QUAL_CONST);
   return constified;
@@ -472,7 +472,7 @@ function_type (const typed_identifier &receiver,
   if (receiver.type != NULL_TREE)
 {
   tree t = receiver.type;
-  if (t == error_mark_node)
+  if (error_operand_p (t))
return error_mark_node;
   *pp = tree_cons (NULL_TREE, t, NULL_TREE);
   pp = &TREE_CHAIN (*pp);
@@ -482,7 +482,7 @@ function_type (const typed_identifier &receiver,
p != parameters.end (); ++p)
 {
   tree t = p->type;
-  if (t == error_mark_node)
+  if (error_operand_p (t))
return error_mark_node;
   *pp = tree_cons (NULL_TREE, t, NULL_TREE);
   pp = &TREE_CHAIN (*pp);
@@ -502,11 +502,11 @@ function_type (const typed_identifier &receiver,
   gcc_assert (result_struc

[gcc r15-9435] rust: Use FLOAT_TYPE_P instead of manual checking

2025-04-14 Thread Arthur Cohen via Gcc-cvs
https://gcc.gnu.org/g:3eb76b8c62a2b3a9c6c7292e6692b48b3483fde0

commit r15-9435-g3eb76b8c62a2b3a9c6c7292e6692b48b3483fde0
Author: Andrew Pinski 
Date:   Wed Mar 19 17:29:59 2025 -0700

rust: Use FLOAT_TYPE_P instead of manual checking

This moves is_floating_point over to using FLOAT_TYPE_P instead
of manually checking. Note before it would return true for all
COMPLEX_TYPE but complex types' inner type could be integral.

Also fixes up the comment to be in more of the GNU style.

Bootstrapped and tested on x86_64-linux-gnu.

gcc/rust/ChangeLog:

* rust-gcc.cc (is_floating_point): Use FLOAT_TYPE_P
instead of manually checking the type.

Signed-off-by: Andrew Pinski 

Diff:
---
 gcc/rust/rust-gcc.cc | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/gcc/rust/rust-gcc.cc b/gcc/rust/rust-gcc.cc
index 72aef08e35a0..7c5af211bbc7 100644
--- a/gcc/rust/rust-gcc.cc
+++ b/gcc/rust/rust-gcc.cc
@@ -1021,12 +1021,12 @@ operator_to_tree_code (LazyBooleanOperator op)
 }
 }
 
-/* Helper function for deciding if a tree is a floating point node. */
+/* Returns true if the type of EXP is a floating point type.
+   False otherwise.  */
 bool
-is_floating_point (tree t)
+is_floating_point (tree exp)
 {
-  auto tree_type = TREE_CODE (TREE_TYPE (t));
-  return tree_type == REAL_TYPE || tree_type == COMPLEX_TYPE;
+  return FLOAT_TYPE_P (TREE_TYPE (exp));
 }
 
 // Return an expression for the negation operation OP EXPR.


[gcc r15-9463] Add test cases for exception handling constructs in dead code for GCN, nvptx target and OpenMP 'targ

2025-04-14 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:aa3e72f943032e5f074b2bd2fd06d130dda8760b

commit r15-9463-gaa3e72f943032e5f074b2bd2fd06d130dda8760b
Author: Thomas Schwinge 
Date:   Thu Mar 27 23:06:37 2025 +0100

Add test cases for exception handling constructs in dead code for GCN, 
nvptx target and OpenMP 'target' offloading [PR118794]

PR target/118794
gcc/testsuite/
* g++.target/gcn/exceptions-pr118794-1.C: New.
* g++.target/nvptx/exceptions-pr118794-1.C: Likewise.
libgomp/
* testsuite/libgomp.c++/target-exceptions-pr118794-1.C: New.
* 
testsuite/libgomp.c++/target-exceptions-pr118794-1-offload-sorry-GCN.C:
Likewise.
* 
testsuite/libgomp.c++/target-exceptions-pr118794-1-offload-sorry-nvptx.C:
Likewise.

Diff:
---
 .../g++.target/gcn/exceptions-pr118794-1.C | 16 ++
 .../g++.target/nvptx/exceptions-pr118794-1.C   | 16 ++
 ...arget-exceptions-pr118794-1-offload-sorry-GCN.C | 23 +
 ...get-exceptions-pr118794-1-offload-sorry-nvptx.C | 23 +
 .../libgomp.c++/target-exceptions-pr118794-1.C | 58 ++
 5 files changed, 136 insertions(+)

diff --git a/gcc/testsuite/g++.target/gcn/exceptions-pr118794-1.C 
b/gcc/testsuite/g++.target/gcn/exceptions-pr118794-1.C
new file mode 100644
index ..a7013791511d
--- /dev/null
+++ b/gcc/testsuite/g++.target/gcn/exceptions-pr118794-1.C
@@ -0,0 +1,16 @@
+/* Exception handling constructs in dead code.  */
+
+/* Via the magic string "-std=*++" indicate that testing one (the default) C++ 
standard is sufficient.  */
+/* { dg-additional-options -fexceptions } */
+/* { dg-additional-options -O0 } */
+/* { dg-additional-options -fdump-tree-optimized-raw } */
+
+#include 
"../../../../libgomp/testsuite/libgomp.c++/target-exceptions-pr118794-1.C"
+
+/* In this specific C++ arrangement, distilled from PR118794, GCC synthesizes
+   '__builtin_eh_pointer', '__builtin_unwind_resume' calls as dead code in 'f':
+   { dg-final { scan-tree-dump-times {gimple_call <__builtin_eh_pointer, } 1 
optimized } }
+   { dg-final { scan-tree-dump-times {gimple_call <__builtin_unwind_resume, } 
1 optimized } }
+   Given '-O0', compilation fails:
+   { dg-regexp {[^\r\n]+: In function 'void f\(\)':[\r\n]+(?:[^\r\n]+: sorry, 
unimplemented: exception handling not supported[\r\n]+)+} }
+   (Note, using 'dg-regexp' instead of 'dg-message', as the former runs before 
the auto-mark-UNSUPPORTED.)  */
diff --git a/gcc/testsuite/g++.target/nvptx/exceptions-pr118794-1.C 
b/gcc/testsuite/g++.target/nvptx/exceptions-pr118794-1.C
new file mode 100644
index ..a7013791511d
--- /dev/null
+++ b/gcc/testsuite/g++.target/nvptx/exceptions-pr118794-1.C
@@ -0,0 +1,16 @@
+/* Exception handling constructs in dead code.  */
+
+/* Via the magic string "-std=*++" indicate that testing one (the default) C++ 
standard is sufficient.  */
+/* { dg-additional-options -fexceptions } */
+/* { dg-additional-options -O0 } */
+/* { dg-additional-options -fdump-tree-optimized-raw } */
+
+#include 
"../../../../libgomp/testsuite/libgomp.c++/target-exceptions-pr118794-1.C"
+
+/* In this specific C++ arrangement, distilled from PR118794, GCC synthesizes
+   '__builtin_eh_pointer', '__builtin_unwind_resume' calls as dead code in 'f':
+   { dg-final { scan-tree-dump-times {gimple_call <__builtin_eh_pointer, } 1 
optimized } }
+   { dg-final { scan-tree-dump-times {gimple_call <__builtin_unwind_resume, } 
1 optimized } }
+   Given '-O0', compilation fails:
+   { dg-regexp {[^\r\n]+: In function 'void f\(\)':[\r\n]+(?:[^\r\n]+: sorry, 
unimplemented: exception handling not supported[\r\n]+)+} }
+   (Note, using 'dg-regexp' instead of 'dg-message', as the former runs before 
the auto-mark-UNSUPPORTED.)  */
diff --git 
a/libgomp/testsuite/libgomp.c++/target-exceptions-pr118794-1-offload-sorry-GCN.C
 
b/libgomp/testsuite/libgomp.c++/target-exceptions-pr118794-1-offload-sorry-GCN.C
new file mode 100644
index ..a588016210c4
--- /dev/null
+++ 
b/libgomp/testsuite/libgomp.c++/target-exceptions-pr118794-1-offload-sorry-GCN.C
@@ -0,0 +1,23 @@
+/* Exception handling constructs in dead code.  */
+
+/* As this test case involves an expected offload compilation failure, we have 
to handle each offload target individually.
+   { dg-do link { target offload_target_amdgcn } }
+   { dg-additional-options -foffload=amdgcn-amdhsa } */
+/* { dg-require-effective-target exceptions }
+   { dg-additional-options -fexceptions } */
+/* { dg-additional-options -O0 } */
+/* { dg-additional-options -fdump-tree-optimized-raw }
+   { dg-additional-options -foffload-options=-fdump-tree-optimized-raw } */
+
+#include "target-exceptions-pr118794-1.C"
+
+/* In this specific C++ arrangement, distilled from PR118794, GCC synthesizes
+   '__builtin_eh_pointer', '__builtin_unwind_resume' calls as dead code in 'f':
+   { dg-final { scan-tree-dump-times {gimple_call <__builtin_eh_pointer, } 1 
opt

[gcc r15-9462] Add PR119692 "C++ 'typeinfo', 'vtable' vs. OpenACC, OpenMP 'target' offloading" test cases [PR119692

2025-04-14 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:a304c88b6feb9ee580d3e389f08a6ed40dfe2292

commit r15-9462-ga304c88b6feb9ee580d3e389f08a6ed40dfe2292
Author: Thomas Schwinge 
Date:   Thu Apr 10 09:46:56 2025 +0200

Add PR119692 "C++ 'typeinfo', 'vtable' vs. OpenACC, OpenMP 'target' 
offloading" test cases [PR119692]

... documenting the status quo.

PR c++/119692
gcc/testsuite/
* g++.target/gcn/pr119692-1-1.C: New.
* g++.target/nvptx/pr119692-1-1.C: Likewise.
libgomp/
* testsuite/libgomp.c++/pr119692-1-1.C: New.
* testsuite/libgomp.c++/pr119692-1-2.C: Likewise.
* testsuite/libgomp.c++/pr119692-1-3.C: Likewise.
* testsuite/libgomp.c++/pr119692-1-4.C: Likewise.
* testsuite/libgomp.c++/pr119692-1-5.C: Likewise.
* testsuite/libgomp.oacc-c++/pr119692-1-1.C: Likewise.
* testsuite/libgomp.oacc-c++/pr119692-1-2.C: Likewise.
* testsuite/libgomp.oacc-c++/pr119692-1-3.C: Likewise.

Diff:
---
 gcc/testsuite/g++.target/gcn/pr119692-1-1.C   |  6 
 gcc/testsuite/g++.target/nvptx/pr119692-1-1.C |  6 
 libgomp/testsuite/libgomp.c++/pr119692-1-1.C  | 10 ++
 libgomp/testsuite/libgomp.c++/pr119692-1-2.C  | 11 ++
 libgomp/testsuite/libgomp.c++/pr119692-1-3.C  | 10 ++
 libgomp/testsuite/libgomp.c++/pr119692-1-4.C  | 10 ++
 libgomp/testsuite/libgomp.c++/pr119692-1-5.C  | 10 ++
 libgomp/testsuite/libgomp.oacc-c++/pr119692-1-1.C | 42 +++
 libgomp/testsuite/libgomp.oacc-c++/pr119692-1-2.C | 12 +++
 libgomp/testsuite/libgomp.oacc-c++/pr119692-1-3.C | 12 +++
 10 files changed, 129 insertions(+)

diff --git a/gcc/testsuite/g++.target/gcn/pr119692-1-1.C 
b/gcc/testsuite/g++.target/gcn/pr119692-1-1.C
new file mode 100644
index ..b44b08d667dd
--- /dev/null
+++ b/gcc/testsuite/g++.target/gcn/pr119692-1-1.C
@@ -0,0 +1,6 @@
+/* PR119692 "C++ 'typeinfo', 'vtable' vs. OpenACC, OpenMP 'target' offloading" 
*/
+
+/* { dg-do run } */
+/* Via the magic string "-std=*++" indicate that testing one (the default) C++ 
standard is sufficient.  */
+
+#include "../../../../libgomp/testsuite/libgomp.oacc-c++/pr119692-1-1.C"
diff --git a/gcc/testsuite/g++.target/nvptx/pr119692-1-1.C 
b/gcc/testsuite/g++.target/nvptx/pr119692-1-1.C
new file mode 100644
index ..b44b08d667dd
--- /dev/null
+++ b/gcc/testsuite/g++.target/nvptx/pr119692-1-1.C
@@ -0,0 +1,6 @@
+/* PR119692 "C++ 'typeinfo', 'vtable' vs. OpenACC, OpenMP 'target' offloading" 
*/
+
+/* { dg-do run } */
+/* Via the magic string "-std=*++" indicate that testing one (the default) C++ 
standard is sufficient.  */
+
+#include "../../../../libgomp/testsuite/libgomp.oacc-c++/pr119692-1-1.C"
diff --git a/libgomp/testsuite/libgomp.c++/pr119692-1-1.C 
b/libgomp/testsuite/libgomp.c++/pr119692-1-1.C
new file mode 100644
index ..1f59b1515405
--- /dev/null
+++ b/libgomp/testsuite/libgomp.c++/pr119692-1-1.C
@@ -0,0 +1,10 @@
+/* PR119692 "C++ 'typeinfo', 'vtable' vs. OpenACC, OpenMP 'target' offloading" 
*/
+
+/* { dg-additional-options -UDEFAULT }
+   Wrong code for offloading execution.
+   { dg-additional-options -foffload=disable } */
+/* { dg-additional-options -fdump-tree-gimple } */
+
+#include "../libgomp.oacc-c++/pr119692-1-1.C"
+
+/* { dg-final { scan-tree-dump-not {(?n)#pragma omp target .* 
map\(tofrom:_ZTI2C2 \[len: [0-9]+\] \[runtime_implicit\]\) map\(tofrom:_ZTI2C1 
\[len: [0-9]+\] \[runtime_implicit\]\) map\(tofrom:_ZTV2C1 \[len: [0-9]+\] 
\[runtime_implicit\]\)$} gimple { xfail *-*-* } } } */
diff --git a/libgomp/testsuite/libgomp.c++/pr119692-1-2.C 
b/libgomp/testsuite/libgomp.c++/pr119692-1-2.C
new file mode 100644
index ..e7ac818435e4
--- /dev/null
+++ b/libgomp/testsuite/libgomp.c++/pr119692-1-2.C
@@ -0,0 +1,11 @@
+/* PR119692 "C++ 'typeinfo', 'vtable' vs. OpenACC, OpenMP 'target' offloading" 
*/
+
+/* { dg-additional-options -DDEFAULT=defaultmap(none) }
+   Fails to compile.
+   { dg-do compile } */
+
+#include "pr119692-1-1.C"
+
+/* { dg-bogus {error: '_ZTV2C1' not specified in enclosing 'target'} PR119692 
{ xfail *-*-* } 0 }
+   { dg-bogus {error: '_ZTI2C2' not specified in enclosing 'target'} PR119692 
{ xfail *-*-* } 0 }
+   { dg-bogus {error: '_ZTI2C1' not specified in enclosing 'target'} PR119692 
{ xfail *-*-* } 0 } */
diff --git a/libgomp/testsuite/libgomp.c++/pr119692-1-3.C 
b/libgomp/testsuite/libgomp.c++/pr119692-1-3.C
new file mode 100644
index ..733feb800433
--- /dev/null
+++ b/libgomp/testsuite/libgomp.c++/pr119692-1-3.C
@@ -0,0 +1,10 @@
+/* PR119692 "C++ 'typeinfo', 'vtable' vs. OpenACC, OpenMP 'target' offloading" 
*/
+
+/* { dg-additional-options -DDEFAULT=defaultmap(present) }
+   Wrong code for offloading execution.
+   { dg-xfail-run-if PR119692 { offload_device } } */
+/* { dg-additional-options -fdump-tree-gimple } */
+
+#include "pr119692-1-1.C"
+
+/* { dg-final { scan-tree-dump-not {(?n)

[gcc r15-9461] Add 'g++.target/gcn/gcn.exp' for GCN-specific C++ test cases

2025-04-14 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:785448f0465cf9802f1ccfea798f5b732f73f62c

commit r15-9461-g785448f0465cf9802f1ccfea798f5b732f73f62c
Author: Thomas Schwinge 
Date:   Fri Mar 28 09:15:19 2025 +0100

Add 'g++.target/gcn/gcn.exp' for GCN-specific C++ test cases

Like 'gcc.target/gcn/gcn.exp' is modeled after 'gcc.dg/dg.exp', this new
'g++.target/gcn/gcn.exp' is modeled after 'g++.dg/dg.exp'.

gcc/testsuite/
* g++.target/gcn/gcn.exp: New.

Diff:
---
 gcc/testsuite/g++.target/gcn/gcn.exp | 56 
 1 file changed, 56 insertions(+)

diff --git a/gcc/testsuite/g++.target/gcn/gcn.exp 
b/gcc/testsuite/g++.target/gcn/gcn.exp
new file mode 100644
index ..a3bd75f2a79e
--- /dev/null
+++ b/gcc/testsuite/g++.target/gcn/gcn.exp
@@ -0,0 +1,56 @@
+# Specific regression driver for GCN.
+#   Copyright (C) 2000-2025 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GCC; see the file COPYING3.  If not see
+# .
+
+# G++ testsuite that uses the `dg.exp' driver.
+
+# Exit immediately if this isn't a GCN target.
+if ![istarget amdgcn*-*-*] then {
+  return
+}
+
+# Load support procs.
+load_lib g++-dg.exp
+
+# If a testcase doesn't have special options, use these.
+global DEFAULT_CXXFLAGS
+if ![info exists DEFAULT_CXXFLAGS] then {
+set DEFAULT_CXXFLAGS " -pedantic-errors -Wno-long-long"
+}
+
+# Initialize `dg'.
+dg-init
+
+# Recursively find files in $dir and subdirs, do not walk into subdirs
+# that contain their own .exp file.
+proc find-cxx-tests { dir suffix } {
+set tests [lsort [glob -nocomplain -directory $dir "*.$suffix" ]]
+foreach subdir [lsort [glob -nocomplain -type d -directory $dir *]] {
+   if { [glob -nocomplain -directory $subdir *.exp] eq "" } {
+   eval lappend tests [find-cxx-tests $subdir $suffix]
+   }
+}
+return $tests
+}
+
+set tests [find-cxx-tests $srcdir/$subdir {C}]
+
+# Main loop.
+g++-dg-runtest $tests "" $DEFAULT_CXXFLAGS
+
+
+# All done.
+dg-finish


[gcc r15-9469] Add 'throw', dead code test cases for GCN, nvptx target and OpenACC, OpenMP 'target' offloading

2025-04-14 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:6c0ea840265454b01d9ef4eb8850a4f015788788

commit r15-9469-g6c0ea840265454b01d9ef4eb8850a4f015788788
Author: Thomas Schwinge 
Date:   Thu Mar 27 14:46:20 2025 +0100

Add 'throw', dead code test cases for GCN, nvptx target and OpenACC, OpenMP 
'target' offloading

gcc/testsuite/
* g++.target/gcn/exceptions-throw-3.C: New.
* g++.target/nvptx/exceptions-throw-3.C: Likewise.
libgomp/
* testsuite/libgomp.c++/target-exceptions-throw-3.C: New.
* testsuite/libgomp.oacc-c++/exceptions-throw-3.C: Likewise.

Diff:
---
 gcc/testsuite/g++.target/gcn/exceptions-throw-3.C  | 11 ++
 .../g++.target/nvptx/exceptions-throw-3.C  | 11 ++
 .../libgomp.c++/target-exceptions-throw-3.C| 19 ++
 .../libgomp.oacc-c++/exceptions-throw-3.C  | 43 ++
 4 files changed, 84 insertions(+)

diff --git a/gcc/testsuite/g++.target/gcn/exceptions-throw-3.C 
b/gcc/testsuite/g++.target/gcn/exceptions-throw-3.C
new file mode 100644
index ..5c1ad7a8fde4
--- /dev/null
+++ b/gcc/testsuite/g++.target/gcn/exceptions-throw-3.C
@@ -0,0 +1,11 @@
+/* 'throw', dead code.  */
+
+/* { dg-do run } */
+/* Via the magic string "-std=*++" indicate that testing one (the default) C++ 
standard is sufficient.  */
+/* { dg-additional-options -fexceptions } */
+/* { dg-additional-options -fdump-tree-optimized-raw } */
+
+#include "../../../../libgomp/testsuite/libgomp.oacc-c++/exceptions-throw-3.C"
+
+/* { dg-final { scan-tree-dump-times {gimple_call <__cxa_allocate_exception, } 
1 optimized } }
+   { dg-final { scan-tree-dump-times {gimple_call <__cxa_throw, } 1 optimized 
} } */
diff --git a/gcc/testsuite/g++.target/nvptx/exceptions-throw-3.C 
b/gcc/testsuite/g++.target/nvptx/exceptions-throw-3.C
new file mode 100644
index ..5c1ad7a8fde4
--- /dev/null
+++ b/gcc/testsuite/g++.target/nvptx/exceptions-throw-3.C
@@ -0,0 +1,11 @@
+/* 'throw', dead code.  */
+
+/* { dg-do run } */
+/* Via the magic string "-std=*++" indicate that testing one (the default) C++ 
standard is sufficient.  */
+/* { dg-additional-options -fexceptions } */
+/* { dg-additional-options -fdump-tree-optimized-raw } */
+
+#include "../../../../libgomp/testsuite/libgomp.oacc-c++/exceptions-throw-3.C"
+
+/* { dg-final { scan-tree-dump-times {gimple_call <__cxa_allocate_exception, } 
1 optimized } }
+   { dg-final { scan-tree-dump-times {gimple_call <__cxa_throw, } 1 optimized 
} } */
diff --git a/libgomp/testsuite/libgomp.c++/target-exceptions-throw-3.C 
b/libgomp/testsuite/libgomp.c++/target-exceptions-throw-3.C
new file mode 100644
index ..c35180de28d3
--- /dev/null
+++ b/libgomp/testsuite/libgomp.c++/target-exceptions-throw-3.C
@@ -0,0 +1,19 @@
+/* 'throw' in OpenMP 'target' region, dead code.  */
+
+/* { dg-require-effective-target exceptions }
+   { dg-additional-options -fexceptions } */
+/* { dg-additional-options -DDEFAULT=defaultmap(to) }
+   ... to avoid wrong code for offloading execution; PR119692.
+   With this, the device code still isn't correct, but the defects are in dead 
code.
+   { dg-additional-options -fdump-tree-gimple } */
+/* { dg-additional-options -fdump-tree-optimized-raw }
+   { dg-additional-options -foffload-options=-fdump-tree-optimized-raw } */
+
+#include "../libgomp.oacc-c++/exceptions-throw-3.C"
+
+/* { dg-final { scan-tree-dump-not {(?n)#pragma omp target .* defaultmap\(to\) 
map\(to:_ZTI11MyException \[len: [0-9]+\] \[runtime_implicit\]\)$} gimple { 
xfail *-*-* } } } */
+
+/* { dg-final { scan-tree-dump-times {gimple_call <__cxa_allocate_exception, } 
1 optimized } }
+   { dg-final { scan-tree-dump-times {gimple_call <__cxa_throw, } 1 optimized 
} }
+   { dg-final { scan-offload-tree-dump-times {gimple_call 
<__cxa_allocate_exception, } 1 optimized } }
+   { dg-final { scan-offload-tree-dump-times {gimple_call <__cxa_throw, } 1 
optimized } } */
diff --git a/libgomp/testsuite/libgomp.oacc-c++/exceptions-throw-3.C 
b/libgomp/testsuite/libgomp.oacc-c++/exceptions-throw-3.C
new file mode 100644
index ..74a62b3abfac
--- /dev/null
+++ b/libgomp/testsuite/libgomp.oacc-c++/exceptions-throw-3.C
@@ -0,0 +1,43 @@
+/* 'throw' in OpenACC compute region, dead code.  */
+
+/* { dg-require-effective-target exceptions }
+   { dg-additional-options -fexceptions } */
+/* Wrong code for offloading execution.
+   { dg-skip-if PR119692 { ! openacc_host_selected } }
+   { dg-additional-options -fdump-tree-gimple } */
+/* { dg-additional-options -fdump-tree-optimized-raw } */
+
+/* See also '../libgomp.c++/target-exceptions-throw-3.C'.  */
+
+/* See also '../../../gcc/testsuite/g++.target/gcn/exceptions-throw-3.C',
+   '../../../gcc/testsuite/g++.target/nvptx/exceptions-throw-3.C'.  */
+
+/* For PR119692 workarounds.  */
+#ifndef DEFAULT
+# define DEFAULT
+#endif
+
+class MyException
+{
+};
+
+int main()
+{
+#pragma omp target DEFAULT
+#pragma acc serial DEFAULT
+  /* { dg-bogus {usi

[gcc r15-9470] GCN, nvptx: Support '-mfake-exceptions', and use it for offloading compilation [PR118794]

2025-04-14 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:fe283dba774be57b705a7a871b000d2894d2e553

commit r15-9470-gfe283dba774be57b705a7a871b000d2894d2e553
Author: Thomas Schwinge 
Date:   Fri Mar 28 09:20:49 2025 +0100

GCN, nvptx: Support '-mfake-exceptions', and use it for offloading 
compilation [PR118794]

With '-mfake-exceptions' enabled, the user-visible behavior in presence of
exception handling constructs changes such that the compile-time
'sorry, unimplemented: exception handling not supported' is skipped, code
generation proceeds, and instead, exception handling constructs 'abort' at
run time.  (..., or don't, if they're in dead code.)

PR target/118794
gcc/
* config/gcn/gcn.opt (-mfake-exceptions): Support.
* config/nvptx/nvptx.opt (-mfake-exceptions): Likewise.
* config/gcn/gcn.md (define_expand "exception_receiver"): Use it.
* config/nvptx/nvptx.md (define_expand "exception_receiver"):
Likewise.
* config/gcn/mkoffload.cc (main): Set it.
* config/nvptx/mkoffload.cc (main): Likewise.
* config/nvptx/nvptx.cc (nvptx_assemble_integer)
: Special handling for
'SYMBOL_REF's.
* except.cc (expand_dw2_landing_pad_for_region): Don't generate
bogus code for (default)
'#define EH_RETURN_DATA_REGNO(N) INVALID_REGNUM'.
libgcc/
* config/gcn/unwind-gcn.c (_Unwind_Resume): New.
* config/nvptx/unwind-nvptx.c (_Unwind_Resume): Likewise.
gcc/testsuite/
* g++.target/gcn/exceptions-bad_cast-2.C: Set
'-mno-fake-exceptions'.
* g++.target/gcn/exceptions-pr118794-1.C: Likewise.
* g++.target/gcn/exceptions-throw-2.C: Likewise.
* g++.target/nvptx/exceptions-bad_cast-2.C: Likewise.
* g++.target/nvptx/exceptions-pr118794-1.C: Likewise.
* g++.target/nvptx/exceptions-throw-2.C: Likewise.
* g++.target/gcn/exceptions-bad_cast-2_-mfake-exceptions.C: New.
* g++.target/gcn/exceptions-pr118794-1_-mfake-exceptions.C:
Likewise.
* g++.target/gcn/exceptions-throw-2_-mfake-exceptions.C: Likewise.
* g++.target/nvptx/exceptions-bad_cast-2_-mfake-exceptions.C:
Likewise.
* g++.target/nvptx/exceptions-pr118794-1_-mfake-exceptions.C:
Likewise.
* g++.target/nvptx/exceptions-throw-2_-mfake-exceptions.C:
Likewise.
libgomp/
* 
testsuite/libgomp.c++/target-exceptions-bad_cast-2-offload-sorry-GCN.C:
Set '-foffload-options=-mno-fake-exceptions'.
* 
testsuite/libgomp.c++/target-exceptions-bad_cast-2-offload-sorry-nvptx.C:
Likewise.
* 
testsuite/libgomp.c++/target-exceptions-pr118794-1-offload-sorry-GCN.C:
Likewise.
* 
testsuite/libgomp.c++/target-exceptions-pr118794-1-offload-sorry-nvptx.C:
Likewise.
* 
testsuite/libgomp.c++/target-exceptions-throw-2-offload-sorry-GCN.C:
Likewise.
* 
testsuite/libgomp.c++/target-exceptions-throw-2-offload-sorry-nvptx.C:
Likewise.
* 
testsuite/libgomp.oacc-c++/exceptions-bad_cast-2-offload-sorry-GCN.C:
Likewise.
* 
testsuite/libgomp.oacc-c++/exceptions-bad_cast-2-offload-sorry-nvptx.C:
Likewise.
* testsuite/libgomp.oacc-c++/exceptions-throw-2-offload-sorry-GCN.C:
Likewise.
* 
testsuite/libgomp.oacc-c++/exceptions-throw-2-offload-sorry-nvptx.C:
Likewise.
* testsuite/libgomp.c++/target-exceptions-bad_cast-2.C: Adjust.
* testsuite/libgomp.c++/target-exceptions-pr118794-1.C: Likewise.
* testsuite/libgomp.c++/target-exceptions-throw-2.C: Likewise.
* testsuite/libgomp.oacc-c++/exceptions-bad_cast-2.C: Likewise.
* testsuite/libgomp.oacc-c++/exceptions-throw-2.C: Likewise.
* testsuite/libgomp.c++/target-exceptions-throw-2-O0.C: New.

Diff:
---
 gcc/config/gcn/gcn.md  |  4 ++-
 gcc/config/gcn/gcn.opt |  8 ++
 gcc/config/gcn/mkoffload.cc|  3 +++
 gcc/config/nvptx/mkoffload.cc  |  3 +++
 gcc/config/nvptx/nvptx.cc  | 20 ++-
 gcc/config/nvptx/nvptx.md  |  4 ++-
 gcc/config/nvptx/nvptx.opt |  8 ++
 gcc/except.cc  | 24 +
 .../g++.target/gcn/exceptions-bad_cast-2.C |  1 +
 .../gcn/exceptions-bad_cast-2_-mfake-exceptions.C  | 18 +
 .../g++.target/gcn/exceptions-pr118794-1.C |  1 +
 .../gcn/exceptions-pr118794-1_-mfake-exceptions.C  | 16 
 gcc/testsuite/g++.target/gcn/exceptions-throw-2.C  |  1 +
 .../gcn/exceptions-t

[gcc r15-9467] Add 'throw' test cases for GCN, nvptx target and OpenACC, OpenMP 'target' offloading

2025-04-14 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:1362d9d49449bec12741ef158f4bf81a8b3ff2cd

commit r15-9467-g1362d9d49449bec12741ef158f4bf81a8b3ff2cd
Author: Thomas Schwinge 
Date:   Thu Mar 27 14:46:20 2025 +0100

Add 'throw' test cases for GCN, nvptx target and OpenACC, OpenMP 'target' 
offloading

gcc/testsuite/
* g++.target/gcn/exceptions-throw-1.C: New.
* g++.target/nvptx/exceptions-throw-1.C: Likewise.
libgomp/
* testsuite/libgomp.c++/target-exceptions-throw-1.C: New.
* testsuite/libgomp.c++/target-exceptions-throw-1-O0.C: Likewise.
* testsuite/libgomp.oacc-c++/exceptions-throw-1.C: Likewise.

Diff:
---
 gcc/testsuite/g++.target/gcn/exceptions-throw-1.C  | 16 
 .../g++.target/nvptx/exceptions-throw-1.C  | 16 
 .../libgomp.c++/target-exceptions-throw-1-O0.C | 23 +++
 .../libgomp.c++/target-exceptions-throw-1.C| 25 
 .../libgomp.oacc-c++/exceptions-throw-1.C  | 46 ++
 5 files changed, 126 insertions(+)

diff --git a/gcc/testsuite/g++.target/gcn/exceptions-throw-1.C 
b/gcc/testsuite/g++.target/gcn/exceptions-throw-1.C
new file mode 100644
index ..6cadf589bb0d
--- /dev/null
+++ b/gcc/testsuite/g++.target/gcn/exceptions-throw-1.C
@@ -0,0 +1,16 @@
+/* 'throw'.  */
+
+/* { dg-do run } */
+/* Via the magic string "-std=*++" indicate that testing one (the default) C++ 
standard is sufficient.  */
+/* { dg-additional-options -fexceptions } */
+/* { dg-additional-options -fdump-tree-optimized-raw } */
+
+#include "../../../../libgomp/testsuite/libgomp.oacc-c++/exceptions-throw-1.C"
+
+/* { dg-output {CheCKpOInT[\r\n]+} }
+
+   { dg-final { scan-tree-dump-times {gimple_call <__cxa_allocate_exception, } 
1 optimized } }
+   { dg-final { scan-tree-dump-times {gimple_call <__cxa_throw, } 1 optimized 
} }
+   We don't print anything, but just 'abort'.
+
+   { dg-shouldfail {'MyException' exception} } */
diff --git a/gcc/testsuite/g++.target/nvptx/exceptions-throw-1.C 
b/gcc/testsuite/g++.target/nvptx/exceptions-throw-1.C
new file mode 100644
index ..6cadf589bb0d
--- /dev/null
+++ b/gcc/testsuite/g++.target/nvptx/exceptions-throw-1.C
@@ -0,0 +1,16 @@
+/* 'throw'.  */
+
+/* { dg-do run } */
+/* Via the magic string "-std=*++" indicate that testing one (the default) C++ 
standard is sufficient.  */
+/* { dg-additional-options -fexceptions } */
+/* { dg-additional-options -fdump-tree-optimized-raw } */
+
+#include "../../../../libgomp/testsuite/libgomp.oacc-c++/exceptions-throw-1.C"
+
+/* { dg-output {CheCKpOInT[\r\n]+} }
+
+   { dg-final { scan-tree-dump-times {gimple_call <__cxa_allocate_exception, } 
1 optimized } }
+   { dg-final { scan-tree-dump-times {gimple_call <__cxa_throw, } 1 optimized 
} }
+   We don't print anything, but just 'abort'.
+
+   { dg-shouldfail {'MyException' exception} } */
diff --git a/libgomp/testsuite/libgomp.c++/target-exceptions-throw-1-O0.C 
b/libgomp/testsuite/libgomp.c++/target-exceptions-throw-1-O0.C
new file mode 100644
index ..00d7c13859da
--- /dev/null
+++ b/libgomp/testsuite/libgomp.c++/target-exceptions-throw-1-O0.C
@@ -0,0 +1,23 @@
+/* 'throw' in OpenMP 'target' region.  */
+
+/* { dg-additional-options -O0 } */
+/* { dg-require-effective-target exceptions }
+   { dg-additional-options -fexceptions } */
+/* { dg-additional-options -fdump-tree-optimized-raw }
+   { dg-additional-options -foffload-options=-fdump-tree-optimized-raw } */
+
+#include "target-exceptions-throw-1.C"
+
+/* { dg-output {CheCKpOInT[\r\n]+} }
+
+   { dg-final { scan-tree-dump-times {gimple_call <__cxa_allocate_exception, } 
1 optimized } }
+   { dg-final { scan-tree-dump-times {gimple_call <__cxa_throw, } 1 optimized 
} }
+   { dg-final { scan-offload-tree-dump-times {gimple_call 
<__cxa_allocate_exception, } 1 optimized } }
+   { dg-final { scan-offload-tree-dump-times {gimple_call <__cxa_throw, } 1 
optimized } }
+   For host execution, we print something like:
+   terminate called after throwing an instance of 'MyException'
+   Aborted (core dumped)
+   { dg-output {.*MyException} { target { ! offload_device } } }
+   For GCN, nvptx offload execution, we don't print anything, but just 'abort'.
+
+   { dg-shouldfail {'MyException' exception} } */
diff --git a/libgomp/testsuite/libgomp.c++/target-exceptions-throw-1.C 
b/libgomp/testsuite/libgomp.c++/target-exceptions-throw-1.C
new file mode 100644
index ..246706150cc9
--- /dev/null
+++ b/libgomp/testsuite/libgomp.c++/target-exceptions-throw-1.C
@@ -0,0 +1,25 @@
+/* 'throw' in OpenMP 'target' region.  */
+
+/* { dg-require-effective-target exceptions }
+   { dg-additional-options -fexceptions } */
+/* { dg-additional-options -fdump-tree-optimized-raw }
+   { dg-additional-options -foffload-options=-fdump-tree-optimized-raw } */
+/* { dg-bogus {Size expression must be absolute\.} PR119737 { target 
offload_target_amdgcn xfail *-*-* } 0 }
+   { dg-ice PR119737

[gcc/meissner/heads/work201-sha] (14 commits) Merge commit 'refs/users/meissner/heads/work201-sha' of git

2025-04-14 Thread Michael Meissner via Gcc-cvs
The branch 'meissner/heads/work201-sha' was updated to point to:

 e326d72a05dc... Merge commit 'refs/users/meissner/heads/work201-sha' of git

It previously pointed to:

 0339a910393a... Add ChangeLog.sha and update REVISION.

Diff:

Summary of changes (added commits):
---

  e326d72... Merge commit 'refs/users/meissner/heads/work201-sha' of git
  00f2387... Add ChangeLog.sha and update REVISION.
  a6ffd50... Update ChangeLog.* (*)
  ccc8b43... Use architecture flags for defining _ARCH_PWR macros. (*)
  680d73b... Add rs6000 architecture masks. (*)
  c8a6cb0... xUse vector pair load/store for memcpy with -mcpu=future (*)
  7880c5c... Add -mcpu=future tests. (*)
  3e1e33a... Add -mcpu=future tuning support. (*)
  51126db... Add support for -mcpu=future (*)
  754bb7e... Change TARGET_MODULO to TARGET_POWER9. (*)
  4bc7533... Change TARGET_POPCNTD to TARGET_POWER7. (*)
  d1ebe30... Change TARGET_CMPB to TARGET_POWER6. (*)
  aa02d95... Change TARGET_FPRND to TARGET_POWER5X. (*)
  40b94e8... Change TARGET_POPCNTB to TARGET_POWER5. (*)

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


[gcc(refs/users/meissner/heads/work201-test)] Merge commit 'refs/users/meissner/heads/work201-test' of git+ssh://gcc.gnu.org/git/gcc into me/work2

2025-04-14 Thread Michael Meissner via Gcc-cvs
https://gcc.gnu.org/g:8616368e94047994ab9d6b53fd9d50a8ac5a8e76

commit 8616368e94047994ab9d6b53fd9d50a8ac5a8e76
Merge: 3f1549119891 bf8ac60a11f3
Author: Michael Meissner 
Date:   Mon Apr 14 20:51:05 2025 -0400

Merge commit 'refs/users/meissner/heads/work201-test' of 
git+ssh://gcc.gnu.org/git/gcc into me/work201-test

Diff:


[gcc r15-9427] ipa-cp: Make propagation of bits in IPA-CP aware of type conversions (PR119318)

2025-04-14 Thread Martin Jambor via Gcc-cvs
https://gcc.gnu.org/g:de1c734a8ae034c92f485e7f58b7fcb1c921ecd2

commit r15-9427-gde1c734a8ae034c92f485e7f58b7fcb1c921ecd2
Author: Martin Jambor 
Date:   Mon Apr 14 14:21:15 2025 +0200

ipa-cp: Make propagation of bits in IPA-CP aware of type conversions 
(PR119318)

After the propagation of constants and value ranges, it turns out
that the propagation of known bits also needs to be made aware of any
intermediate types in which any arithmetic operations are made and
must limit its precision there.  This implements just that, using the
newly collected and streamed types of the operations involved.

This version removed the extra check that the type of a formal
parameter is known pointed out in Honza in his review because I agree
it is currently always known.  I have also added the testcase of PR
119530 which is a duplicate of this bug.

gcc/ChangeLog:

2025-04-11  Martin Jambor  

PR ipa/119318
* ipa-cp.cc (ipcp_bits_lattice::meet_with_1): Set all mask bits
not covered by precision to one.
(ipcp_bits_lattice::meet_with): Likewise.
(propagate_bits_across_jump_function): Use the stored operation
type to perform meet with other lattices.

gcc/testsuite/ChangeLog:

2025-04-11  Martin Jambor  

PR ipa/119318
* gcc.dg/ipa/pr119318.c: New test.
* gcc.dg/ipa/pr119530.c: Likwise.

Diff:
---
 gcc/ipa-cp.cc   | 21 +++-
 gcc/testsuite/gcc.dg/ipa/pr119318.c | 38 +
 gcc/testsuite/gcc.dg/ipa/pr119530.c | 21 
 3 files changed, 75 insertions(+), 5 deletions(-)

diff --git a/gcc/ipa-cp.cc b/gcc/ipa-cp.cc
index 264568989a96..fd2c4cca1365 100644
--- a/gcc/ipa-cp.cc
+++ b/gcc/ipa-cp.cc
@@ -918,6 +918,8 @@ ipcp_bits_lattice::meet_with_1 (widest_int value, 
widest_int mask,
 m_mask |= m_value;
   m_value &= ~m_mask;
 
+  widest_int cap_mask = wi::bit_not (wi::sub (wi::lshift (1, precision), 1));
+  m_mask |= cap_mask;
   if (wi::sext (m_mask, precision) == -1)
 return set_to_bottom ();
 
@@ -996,6 +998,8 @@ ipcp_bits_lattice::meet_with (ipcp_bits_lattice& other, 
unsigned precision,
  adjusted_mask |= adjusted_value;
  adjusted_value &= ~adjusted_mask;
}
+  widest_int cap_mask = wi::bit_not (wi::sub (wi::lshift (1, precision), 
1));
+  adjusted_mask |= cap_mask;
   if (wi::sext (adjusted_mask, precision) == -1)
return set_to_bottom ();
   return set_to_constant (adjusted_value, adjusted_mask);
@@ -2507,14 +2511,12 @@ propagate_bits_across_jump_function (cgraph_edge *cs, 
int idx,
   return dest_lattice->set_to_bottom ();
 }
 
-  unsigned precision = TYPE_PRECISION (parm_type);
-  signop sgn = TYPE_SIGN (parm_type);
-
   if (jfunc->type == IPA_JF_PASS_THROUGH
   || jfunc->type == IPA_JF_ANCESTOR)
 {
   ipa_node_params *caller_info = ipa_node_params_sum->get (cs->caller);
   tree operand = NULL_TREE;
+  tree op_type = NULL_TREE;
   enum tree_code code;
   unsigned src_idx;
   bool keep_null = false;
@@ -2524,7 +2526,10 @@ propagate_bits_across_jump_function (cgraph_edge *cs, 
int idx,
  code = ipa_get_jf_pass_through_operation (jfunc);
  src_idx = ipa_get_jf_pass_through_formal_id (jfunc);
  if (code != NOP_EXPR)
-   operand = ipa_get_jf_pass_through_operand (jfunc);
+   {
+ operand = ipa_get_jf_pass_through_operand (jfunc);
+ op_type = ipa_get_jf_pass_through_op_type (jfunc);
+   }
}
   else
{
@@ -2551,6 +2556,11 @@ propagate_bits_across_jump_function (cgraph_edge *cs, 
int idx,
 
   if (!src_lats->bits_lattice.bottom_p ())
{
+ if (!op_type)
+   op_type = ipa_get_type (caller_info, src_idx);
+
+ unsigned precision = TYPE_PRECISION (op_type);
+ signop sgn = TYPE_SIGN (op_type);
  bool drop_all_ones
= keep_null && !src_lats->bits_lattice.known_nonzero_p ();
 
@@ -2570,7 +2580,8 @@ propagate_bits_across_jump_function (cgraph_edge *cs, int 
idx,
= widest_int::from (bm.mask (), TYPE_SIGN (parm_type));
  widest_int value
= widest_int::from (bm.value (), TYPE_SIGN (parm_type));
- return dest_lattice->meet_with (value, mask, precision);
+ return dest_lattice->meet_with (value, mask,
+ TYPE_PRECISION (parm_type));
}
 }
   return dest_lattice->set_to_bottom ();
diff --git a/gcc/testsuite/gcc.dg/ipa/pr119318.c 
b/gcc/testsuite/gcc.dg/ipa/pr119318.c
new file mode 100644
index ..8e62ec5e3503
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/ipa/pr119318.c
@@ -0,0 +1,38 @@
+/* { dg-do run } */
+/* { dg-require-effective-target int128 } */
+/* { dg-additional-options "-Wno-psabi -w" } */
+/* { dg-options "-Wno-psabi

[gcc(refs/users/meissner/heads/work201-math)] Merge commit 'refs/users/meissner/heads/work201-math' of git+ssh://gcc.gnu.org/git/gcc into me/work2

2025-04-14 Thread Michael Meissner via Gcc-cvs
https://gcc.gnu.org/g:882e2314109a0f6876a191334655ef99070eaf57

commit 882e2314109a0f6876a191334655ef99070eaf57
Merge: af080c41f051 faf9364c9875
Author: Michael Meissner 
Date:   Mon Apr 14 20:42:45 2025 -0400

Merge commit 'refs/users/meissner/heads/work201-math' of 
git+ssh://gcc.gnu.org/git/gcc into me/work201-math

Diff:


[gcc r15-9473] Revert documents from r11-344-g0fec3f62b9bfc0

2025-04-14 Thread hongtao Liu via Gcc-cvs
https://gcc.gnu.org/g:fa58ff249a0e63a721ccb6d770c86523d84a212a

commit r15-9473-gfa58ff249a0e63a721ccb6d770c86523d84a212a
Author: liuhongt 
Date:   Sun Apr 13 19:40:51 2025 -0700

Revert documents from r11-344-g0fec3f62b9bfc0

gcc/ChangeLog:

PR target/108134
* doc/extend.texi: Remove documents from r11-344-g0fec3f62b9bfc0.

Diff:
---
 gcc/doc/extend.texi | 94 ++---
 1 file changed, 2 insertions(+), 92 deletions(-)

diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
index ae3357f83bff..3a8e57065150 100644
--- a/gcc/doc/extend.texi
+++ b/gcc/doc/extend.texi
@@ -12299,15 +12299,6 @@ for the @samp{att} and @samp{intel} dialects of 
assembler:
 @item @code{%3}
 @tab @code{$.L3}
 @tab @code{OFFSET FLAT:.L3}
-@item @code{%4}
-@tab @code{$8}
-@tab @code{8}
-@item @code{%5}
-@tab @code{%xmm0}
-@tab @code{xmm0}
-@item @code{%7}
-@tab @code{$0}
-@tab @code{0}
 @end multitable
 
 The table below shows the list of supported modifiers and their effects.
@@ -12324,32 +12315,17 @@ The table below shows the list of supported modifiers 
and their effects.
 @tab @code{%b0}
 @tab @code{%al}
 @tab @code{al}
-@item @code{B}
-@tab print the opcode suffix of b.
-@tab @code{%B0}
-@tab @code{b}
-@tab
 @item @code{c}
 @tab Require a constant operand and print the constant expression with no 
punctuation.
 @tab @code{%c1}
 @tab @code{2}
 @tab @code{2}
-@item @code{d}
-@tab print duplicated register operand for AVX instruction.
-@tab @code{%d5}
-@tab @code{%xmm0, %xmm0}
-@tab @code{xmm0, xmm0}
 @item @code{E}
 @tab Print the address in Double Integer (DImode) mode (8 bytes) when the 
target is 64-bit.
 Otherwise mode is unspecified (VOIDmode).
 @tab @code{%E1}
 @tab @code{%(rax)}
 @tab @code{[rax]}
-@item @code{g}
-@tab Print the V16SFmode name of the register.
-@tab @code{%g0}
-@tab @code{%zmm0}
-@tab @code{zmm0}
 @item @code{h}
 @tab Print the QImode name for a ``high'' register.
 @tab @code{%h0}
@@ -12371,16 +12347,6 @@ high 8 bytes of SSE values. For a memref in (%rax), it 
generates
 @tab @code{%l3}
 @tab @code{.L3}
 @tab @code{.L3}
-@item @code{L}
-@tab print the opcode suffix of l.
-@tab @code{%L0}
-@tab @code{l}
-@tab
-@item @code{N}
-@tab print maskz.
-@tab @code{%N7}
-@tab @code{@{z@}}
-@tab @code{@{z@}}
 @item @code{p}
 @tab Print raw symbol name (without syntax-specific prefixes).
 @tab @code{%p2}
@@ -12396,76 +12362,20 @@ issue the bare constant. See @code{p} above.
 @tab @code{%q0}
 @tab @code{%rax}
 @tab @code{rax}
-@item @code{Q}
-@tab print the opcode suffix of q.
-@tab @code{%Q0}
-@tab @code{q}
-@tab
-@item @code{R}
-@tab print embedded rounding and sae.
-@tab @code{%R4}
-@tab @code{@{rn-sae@}, }
-@tab @code{, @{rn-sae@}}
-@item @code{r}
-@tab print only sae.
-@tab @code{%r4}
-@tab @code{@{sae@}, }
-@tab @code{, @{sae@}}
-@item @code{s}
-@tab print a shift double count, followed by the assemblers argument
-delimiterprint the opcode suffix of s.
-@tab @code{%s1}
-@tab @code{$2, }
-@tab @code{2, }
-@item @code{S}
-@tab print the opcode suffix of s.
-@tab @code{%S0}
-@tab @code{s}
-@tab
-@item @code{t}
-@tab print the V8SFmode name of the register.
-@tab @code{%t5}
-@tab @code{%ymm0}
-@tab @code{ymm0}
-@item @code{T}
-@tab print the opcode suffix of t.
-@tab @code{%T0}
-@tab @code{t}
-@tab
-@item @code{V}
-@tab print naked full integer register name without %.
-@tab @code{%V0}
-@tab @code{eax}
-@tab @code{eax}
 @item @code{w}
 @tab Print the HImode name of the register.
 @tab @code{%w0}
 @tab @code{%ax}
 @tab @code{ax}
-@item @code{W}
-@tab print the opcode suffix of w.
-@tab @code{%W0}
-@tab @code{w}
-@tab
-@item @code{x}
-@tab print the V4SFmode name of the register.
-@tab @code{%x5}
-@tab @code{%xmm0}
-@tab @code{xmm0}
-@item @code{y}
-@tab print "st(0)" instead of "st" as a register.
-@tab @code{%y6}
-@tab @code{%st(0)}
-@tab @code{st(0)}
 @item @code{z}
 @tab Print the opcode suffix for the size of the current integer operand (one 
of @code{b}/@code{w}/@code{l}/@code{q}).
 @tab @code{%z0}
 @tab @code{l}
 @tab 
-@item @code{Z}
-@tab Like @code{z}, with special suffixes for x87 instructions.
 @end multitable
 
+@code{V} is a special modifier which prints the name of the full integer
+register without @code{%}.
 
 @anchor{x86floatingpointasmoperands}
 @subsubsection x86 Floating-Point @code{asm} Operands


[gcc(refs/users/meissner/heads/work201)] Add -mcpu=future tuning support.

2025-04-14 Thread Michael Meissner via Gcc-cvs
https://gcc.gnu.org/g:3e1e33a3cd6104b61f426c5ebfcca9914bbfb0b7

commit 3e1e33a3cd6104b61f426c5ebfcca9914bbfb0b7
Author: Michael Meissner 
Date:   Mon Apr 14 20:28:29 2025 -0400

Add -mcpu=future tuning support.

This patch makes -mtune=future use the same tuning decision as 
-mtune=power11.

2025-04-14  Michael Meissner  

gcc/

* config/rs6000/power10.md (all reservations): Add future as an
alterntive to power10 and power11.

Diff:
---
 gcc/config/rs6000/power10.md | 145 ++-
 1 file changed, 73 insertions(+), 72 deletions(-)

diff --git a/gcc/config/rs6000/power10.md b/gcc/config/rs6000/power10.md
index fd31b16b3314..bdd7e58145ba 100644
--- a/gcc/config/rs6000/power10.md
+++ b/gcc/config/rs6000/power10.md
@@ -1,4 +1,5 @@
-;; Scheduling description for the IBM Power10 and Power11 processors.
+;; Scheduling description for the IBM Power10, Power11, and
+;; potential future processors.
 ;; Copyright (C) 2020-2025 Free Software Foundation, Inc.
 ;;
 ;; Contributed by Pat Haugen (pthau...@us.ibm.com).
@@ -97,12 +98,12 @@
(eq_attr "update" "no")
(eq_attr "size" "!128")
(eq_attr "prefixed" "no")
-   (eq_attr "cpu" "power10,power11"))
+   (eq_attr "cpu" "power10,power11,future"))
   "DU_any_power10,LU_power10")
 
 (define_insn_reservation "power10-fused-load" 4
   (and (eq_attr "type" "fused_load_cmpi,fused_addis_load,fused_load_load")
-   (eq_attr "cpu" "power10,power11"))
+   (eq_attr "cpu" "power10,power11,future"))
   "DU_even_power10,LU_power10")
 
 (define_insn_reservation "power10-prefixed-load" 4
@@ -110,13 +111,13 @@
(eq_attr "update" "no")
(eq_attr "size" "!128")
(eq_attr "prefixed" "yes")
-   (eq_attr "cpu" "power10,power11"))
+   (eq_attr "cpu" "power10,power11,future"))
   "DU_even_power10,LU_power10")
 
 (define_insn_reservation "power10-load-update" 4
   (and (eq_attr "type" "load")
(eq_attr "update" "yes")
-   (eq_attr "cpu" "power10,power11"))
+   (eq_attr "cpu" "power10,power11,future"))
   "DU_even_power10,LU_power10+SXU_power10")
 
 (define_insn_reservation "power10-fpload-double" 4
@@ -124,7 +125,7 @@
(eq_attr "update" "no")
(eq_attr "size" "64")
(eq_attr "prefixed" "no")
-   (eq_attr "cpu" "power10,power11"))
+   (eq_attr "cpu" "power10,power11,future"))
   "DU_any_power10,LU_power10")
 
 (define_insn_reservation "power10-prefixed-fpload-double" 4
@@ -132,14 +133,14 @@
(eq_attr "update" "no")
(eq_attr "size" "64")
(eq_attr "prefixed" "yes")
-   (eq_attr "cpu" "power10,power11"))
+   (eq_attr "cpu" "power10,power11,future"))
   "DU_even_power10,LU_power10")
 
 (define_insn_reservation "power10-fpload-update-double" 4
   (and (eq_attr "type" "fpload")
(eq_attr "update" "yes")
(eq_attr "size" "64")
-   (eq_attr "cpu" "power10,power11"))
+   (eq_attr "cpu" "power10,power11,future"))
   "DU_even_power10,LU_power10+SXU_power10")
 
 ; SFmode loads are cracked and have additional 3 cycles over DFmode
@@ -148,27 +149,27 @@
   (and (eq_attr "type" "fpload")
(eq_attr "update" "no")
(eq_attr "size" "32")
-   (eq_attr "cpu" "power10,power11"))
+   (eq_attr "cpu" "power10,power11,future"))
   "DU_even_power10,LU_power10")
 
 (define_insn_reservation "power10-fpload-update-single" 7
   (and (eq_attr "type" "fpload")
(eq_attr "update" "yes")
(eq_attr "size" "32")
-   (eq_attr "cpu" "power10,power11"))
+   (eq_attr "cpu" "power10,power11,future"))
   "DU_even_power10,LU_power10+SXU_power10")
 
 (define_insn_reservation "power10-vecload" 4
   (and (eq_attr "type" "vecload")
(eq_attr "size" "!256")
-   (eq_attr "cpu" "power10,power11"))
+   (eq_attr "cpu" "power10,power11,future"))
   "DU_any_power10,LU_power10")
 
 ; lxvp
 (define_insn_reservation "power10-vecload-pair" 4
   (and (eq_attr "type" "vecload")
(eq_attr "size" "256")
-   (eq_attr "cpu" "power10,power11"))
+   (eq_attr "cpu" "power10,power11,future"))
   "DU_even_power10,LU_power10+SXU_power10")
 
 ; Store Unit
@@ -178,12 +179,12 @@
(eq_attr "prefixed" "no")
(eq_attr "size" "!128")
(eq_attr "size" "!256")
-   (eq_attr "cpu" "power10,power11"))
+   (eq_attr "cpu" "power10,power11,future"))
   "DU_any_power10,STU_power10")
 
 (define_insn_reservation "power10-fused-store" 0
   (and (eq_attr "type" "fused_store_store")
-   (eq_attr "cpu" "power10,power11"))
+   (eq_attr "cpu" "power10,power11,future"))
   "DU_even_power10,STU_power10")
 
 (define_insn_reservation "power10-prefixed-store" 0
@@ -191,52 +192,52 @@
(eq_attr "prefixed" "yes")
(eq_attr "size" "!128")
(eq_attr "size" "!256")
-   (eq_attr "cpu" "power10,power11"))
+   (eq_attr "cpu" "power10,power11,future"))
   "DU_even_power10,STU_power10")
 
 ; Update forms have 2 cycle lat

[gcc r15-9466] Add 'std::bad_cast' exception, dead code test cases for GCN, nvptx target and OpenACC, OpenMP 'targe

2025-04-14 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:27f88cc79934b689a92e08342e25b2ee947a1bce

commit r15-9466-g27f88cc79934b689a92e08342e25b2ee947a1bce
Author: Thomas Schwinge 
Date:   Thu Mar 27 14:46:20 2025 +0100

Add 'std::bad_cast' exception, dead code test cases for GCN, nvptx target 
and OpenACC, OpenMP 'target' offloading

gcc/testsuite/
* g++.target/gcn/exceptions-bad_cast-3.C: New.
* g++.target/nvptx/exceptions-bad_cast-3.C: Likewise.
libgomp/
* testsuite/libgomp.c++/target-exceptions-bad_cast-3.C: New.
* testsuite/libgomp.oacc-c++/exceptions-bad_cast-3.C: Likewise.

Diff:
---
 .../g++.target/gcn/exceptions-bad_cast-3.C | 10 +
 .../g++.target/nvptx/exceptions-bad_cast-3.C   | 10 +
 .../libgomp.c++/target-exceptions-bad_cast-3.C | 17 
 .../libgomp.oacc-c++/exceptions-bad_cast-3.C   | 49 ++
 4 files changed, 86 insertions(+)

diff --git a/gcc/testsuite/g++.target/gcn/exceptions-bad_cast-3.C 
b/gcc/testsuite/g++.target/gcn/exceptions-bad_cast-3.C
new file mode 100644
index ..3d0118c4505a
--- /dev/null
+++ b/gcc/testsuite/g++.target/gcn/exceptions-bad_cast-3.C
@@ -0,0 +1,10 @@
+/* 'std::bad_cast' exception, dead code.  */
+
+/* { dg-do run } */
+/* Via the magic string "-std=*++" indicate that testing one (the default) C++ 
standard is sufficient.  */
+/* { dg-additional-options -fexceptions } */
+/* { dg-additional-options -fdump-tree-optimized-raw } */
+
+#include 
"../../../../libgomp/testsuite/libgomp.oacc-c++/exceptions-bad_cast-3.C"
+
+/* { dg-final { scan-tree-dump-times {gimple_call <__cxa_bad_cast, } 1 
optimized } } */
diff --git a/gcc/testsuite/g++.target/nvptx/exceptions-bad_cast-3.C 
b/gcc/testsuite/g++.target/nvptx/exceptions-bad_cast-3.C
new file mode 100644
index ..3d0118c4505a
--- /dev/null
+++ b/gcc/testsuite/g++.target/nvptx/exceptions-bad_cast-3.C
@@ -0,0 +1,10 @@
+/* 'std::bad_cast' exception, dead code.  */
+
+/* { dg-do run } */
+/* Via the magic string "-std=*++" indicate that testing one (the default) C++ 
standard is sufficient.  */
+/* { dg-additional-options -fexceptions } */
+/* { dg-additional-options -fdump-tree-optimized-raw } */
+
+#include 
"../../../../libgomp/testsuite/libgomp.oacc-c++/exceptions-bad_cast-3.C"
+
+/* { dg-final { scan-tree-dump-times {gimple_call <__cxa_bad_cast, } 1 
optimized } } */
diff --git a/libgomp/testsuite/libgomp.c++/target-exceptions-bad_cast-3.C 
b/libgomp/testsuite/libgomp.c++/target-exceptions-bad_cast-3.C
new file mode 100644
index ..efed64fa2e85
--- /dev/null
+++ b/libgomp/testsuite/libgomp.c++/target-exceptions-bad_cast-3.C
@@ -0,0 +1,17 @@
+/* 'std::bad_cast' exception in OpenMP 'target' region, dead code.  */
+
+/* { dg-require-effective-target exceptions }
+   { dg-additional-options -fexceptions } */
+/* { dg-additional-options -DDEFAULT=defaultmap(to) }
+   ... to avoid wrong code for offloading execution; PR119692.
+   With this, the device code still isn't correct, but the defects are in dead 
code.
+   { dg-additional-options -fdump-tree-gimple } */
+/* { dg-additional-options -fdump-tree-optimized-raw }
+   { dg-additional-options -foffload-options=-fdump-tree-optimized-raw } */
+
+#include "../libgomp.oacc-c++/exceptions-bad_cast-3.C"
+
+/* { dg-final { scan-tree-dump-not {(?n)#pragma omp target .* defaultmap\(to\) 
map\(to:_ZTI2C2 \[len: [0-9]+\] \[runtime_implicit\]\) map\(to:_ZTI2C1 \[len: 
[0-9]+\] \[runtime_implicit\]\) map\(to:_ZTV2C1 \[len: [0-9]+\] 
\[runtime_implicit\]\)$} gimple { xfail *-*-* } } } */
+
+/* { dg-final { scan-tree-dump-times {gimple_call <__cxa_bad_cast, } 1 
optimized } }
+   { dg-final { scan-offload-tree-dump-times {gimple_call <__cxa_bad_cast, } 1 
optimized } } */
diff --git a/libgomp/testsuite/libgomp.oacc-c++/exceptions-bad_cast-3.C 
b/libgomp/testsuite/libgomp.oacc-c++/exceptions-bad_cast-3.C
new file mode 100644
index ..4fa419f245fc
--- /dev/null
+++ b/libgomp/testsuite/libgomp.oacc-c++/exceptions-bad_cast-3.C
@@ -0,0 +1,49 @@
+/* 'std::bad_cast' exception in OpenACC compute region, dead code.  */
+
+/* { dg-require-effective-target exceptions }
+   { dg-additional-options -fexceptions } */
+/* Wrong code for offloading execution.
+   { dg-skip-if PR119692 { ! openacc_host_selected } }
+   { dg-additional-options -fdump-tree-gimple } */
+/* { dg-additional-options -fdump-tree-optimized-raw } */
+
+/* See also '../libgomp.c++/target-exceptions-bad_cast-3.C'.  */
+
+/* See also '../../../gcc/testsuite/g++.target/gcn/exceptions-bad_cast-3.C',
+   '../../../gcc/testsuite/g++.target/nvptx/exceptions-bad_cast-3.C'.  */
+
+/* For PR119692 workarounds.  */
+#ifndef DEFAULT
+# define DEFAULT
+#endif
+
+struct C1
+{
+  virtual void f()
+  {}
+};
+
+struct C2 : C1
+{
+};
+
+int main()
+{
+#pragma omp target DEFAULT
+#pragma acc serial DEFAULT
+  {
+C1 c1;
+bool a = false;
+asm volatile ("" : : "r" (&a) : "memory");
+if (a)
+  {

[gcc(refs/users/meissner/heads/work201-paddis)] Add ChangeLog.paddis and update REVISION.

2025-04-14 Thread Michael Meissner via Gcc-cvs
https://gcc.gnu.org/g:47361653dd9cd23813f96782f1326459563525ed

commit 47361653dd9cd23813f96782f1326459563525ed
Author: Michael Meissner 
Date:   Mon Apr 14 15:19:36 2025 -0400

Add ChangeLog.paddis and update REVISION.

2025-04-14  Michael Meissner  

gcc/

* ChangeLog.paddis: New file for branch.
* REVISION: Update.

Diff:
---
 gcc/ChangeLog.paddis | 5 +
 gcc/REVISION | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/gcc/ChangeLog.paddis b/gcc/ChangeLog.paddis
new file mode 100644
index ..b8c9b5293f20
--- /dev/null
+++ b/gcc/ChangeLog.paddis
@@ -0,0 +1,5 @@
+ Branch work201-paddis, baseline 
+
+2025-04-14   Michael Meissner  
+
+   Clone branch
diff --git a/gcc/REVISION b/gcc/REVISION
index 5f8715c4844d..d90dc19a4f8f 100644
--- a/gcc/REVISION
+++ b/gcc/REVISION
@@ -1 +1 @@
-work201 branch
+work201-paddis branch


[gcc r15-9475] Doc: always_inline attribute vs multiple TUs and LTO [PR113203]

2025-04-14 Thread Sandra Loosemore via Gcc-cvs
https://gcc.gnu.org/g:fc89b1face0d207710eaa3d8f5af3adcffd5c5c9

commit r15-9475-gfc89b1face0d207710eaa3d8f5af3adcffd5c5c9
Author: Sandra Loosemore 
Date:   Tue Apr 15 03:49:06 2025 +

Doc: always_inline attribute vs multiple TUs and LTO [PR113203]

gcc/ChangeLog
PR ipa/113203
* doc/extend.texi (Common Function Attributes): Explain how to
use always_inline in programs that have multiple translation
units, and that LTO inlining additionally needs optimization
enabled.

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

diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
index 3a8e57065150..5bc2785f8025 100644
--- a/gcc/doc/extend.texi
+++ b/gcc/doc/extend.texi
@@ -1933,6 +1933,13 @@ Note that if such a function is called indirectly the 
compiler may
 or may not inline it depending on optimization level and a failure
 to inline an indirect call may or may not be diagnosed.
 
+If you need to use the inlined function in multiple translation units,
+you should put the @code{always_inline} attribute on a function
+definition in a header file that is included in all translation units
+where the function is used.  Link-time optimization can inline
+functions across translation units, but only if an optimization level
+that normally enables inlining is additionally specified.
+
 @cindex @code{artificial} function attribute
 @item artificial
 This attribute is useful for small inline wrappers that if possible


[gcc(refs/users/meissner/heads/work201)] Change TARGET_POPCNTD to TARGET_POWER7.

2025-04-14 Thread Michael Meissner via Gcc-cvs
https://gcc.gnu.org/g:4bc753374fbc2f21012efd258255860735ae1d03

commit 4bc753374fbc2f21012efd258255860735ae1d03
Author: Michael Meissner 
Date:   Mon Apr 14 20:23:40 2025 -0400

Change TARGET_POPCNTD to TARGET_POWER7.

This patch changes TARGET_POPCNTD to TARGET_POWER7.  The -mpopcntd switch 
is not
being changed, just the name of the macros used to determine if the PowerPC
processor supports ISA 2.6 (Power7).

2025-04-14  Michael Meissner  

gcc/

* gcc/config/rs6000/dfp.md (cmp_internal1): Change 
TARGET_POPCNTD
to TARGET_POWER7.
* gcc/config/rs6000/rs6000-builtin.cc (rs6000_builtin_is_supported):
Likewise.
* gcc/config/rs6000/rs6000-string.cc (expand_block_compare): 
Likewise.
* gcc/config/rs6000/rs6000.cc (rs6000_hard_regno_mode_ok_uncached):
Likewise.
(rs6000_option_override_internal): Likewise.
(rs6000_rtx_costs): Likewise.
* gcc/config/rs6000/rs6000.h (TARGET_LDBRX): Likewise.
(TARGET_FCFID): Likewise.
(TARGET_LFIWZX): Likewise.
(TARGET_FCFIDS): Likewise.
(TARGET_FCFIDU): Likewise.
(TARGET_FCFIDUS): Likewise.
(TARGET_FCTIDUZ): Likewise.
(TARGET_FCTIWUZ): Likewise.
(TARGET_FCTIDUZ): Likewise.
(TARGET_POWER7): New macro.
(TARGET_EXTRA_BUILTINS): Change TARGET_POPCNTD to TARGET_POWER7.
(CTZ_DEFINED_VALUE_AT_ZERO): Likewise.
* gcc/config/rs6000/rs6000.md (enabled attribute): Likewise.
(lrintsi2): Likewise.
(lrintsi): Likewise.
(lrintsi_di): Likewise.
(cmpmemsi): Likewise.
(bpermd_): Likewise.
(addg6s): Likewise.
(cdtbcd): Likewise.
(cbcdtd): Likewise.
(div_): Likewise.

Diff:
---
 gcc/config/rs6000/dfp.md|  2 +-
 gcc/config/rs6000/rs6000-builtin.cc |  4 ++--
 gcc/config/rs6000/rs6000-string.cc  |  2 +-
 gcc/config/rs6000/rs6000.cc |  8 
 gcc/config/rs6000/rs6000.h  | 21 +++--
 gcc/config/rs6000/rs6000.md | 20 ++--
 6 files changed, 29 insertions(+), 28 deletions(-)

diff --git a/gcc/config/rs6000/dfp.md b/gcc/config/rs6000/dfp.md
index 59fa66ae15c8..5919149682b2 100644
--- a/gcc/config/rs6000/dfp.md
+++ b/gcc/config/rs6000/dfp.md
@@ -214,7 +214,7 @@
 (define_insn "floatdidd2"
   [(set (match_operand:DD 0 "gpc_reg_operand" "=d")
(float:DD (match_operand:DI 1 "gpc_reg_operand" "d")))]
-  "TARGET_DFP && TARGET_POPCNTD"
+  "TARGET_DFP && TARGET_POWER7"
   "dcffix %0,%1"
   [(set_attr "type" "dfp")])
 
diff --git a/gcc/config/rs6000/rs6000-builtin.cc 
b/gcc/config/rs6000/rs6000-builtin.cc
index dbb8520ab039..2366b2aee00a 100644
--- a/gcc/config/rs6000/rs6000-builtin.cc
+++ b/gcc/config/rs6000/rs6000-builtin.cc
@@ -161,9 +161,9 @@ rs6000_builtin_is_supported (enum rs6000_gen_builtins 
fncode)
 case ENB_P6_64:
   return TARGET_POWER6 && TARGET_POWERPC64;
 case ENB_P7:
-  return TARGET_POPCNTD;
+  return TARGET_POWER7;
 case ENB_P7_64:
-  return TARGET_POPCNTD && TARGET_POWERPC64;
+  return TARGET_POWER7 && TARGET_POWERPC64;
 case ENB_P8:
   return TARGET_POWER8;
 case ENB_P8V:
diff --git a/gcc/config/rs6000/rs6000-string.cc 
b/gcc/config/rs6000/rs6000-string.cc
index 3d2911ca08a0..703f77fa0bf1 100644
--- a/gcc/config/rs6000/rs6000-string.cc
+++ b/gcc/config/rs6000/rs6000-string.cc
@@ -1949,7 +1949,7 @@ bool
 expand_block_compare (rtx operands[])
 {
   /* TARGET_POPCNTD is already guarded at expand cmpmemsi.  */
-  gcc_assert (TARGET_POPCNTD);
+  gcc_assert (TARGET_POWER7);
 
   /* For P8, this case is complicated to handle because the subtract
  with carry instructions do not generate the 64-bit carry and so
diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc
index c01af37200ac..503b07339647 100644
--- a/gcc/config/rs6000/rs6000.cc
+++ b/gcc/config/rs6000/rs6000.cc
@@ -1924,7 +1924,7 @@ rs6000_hard_regno_mode_ok_uncached (int regno, 
machine_mode mode)
  if(GET_MODE_SIZE (mode) == UNITS_PER_FP_WORD)
return 1;
 
- if (TARGET_POPCNTD && mode == SImode)
+ if (TARGET_POWER7 && mode == SImode)
return 1;
 
  if (TARGET_P9_VECTOR && (mode == QImode || mode == HImode))
@@ -3918,7 +3918,7 @@ rs6000_option_override_internal (bool global_init_p)
 rs6000_isa_flags |= (ISA_2_7_MASKS_SERVER & ~ignore_masks);
   else if (TARGET_VSX)
 rs6000_isa_flags |= (ISA_2_6_MASKS_SERVER & ~ignore_masks);
-  else if (TARGET_POPCNTD)
+  else if (TARGET_POWER7)
 rs6000_isa_flags |= (ISA_2_6_MASKS_EMBEDDED & ~ignore_masks);
   else if (TARGET_DFP)
 rs6000_isa_flags |= (ISA_2_5_MASKS_SERVER & ~ignore_masks);
@@ -4131,7 +4131,7 @@ rs6000_option_override_internal (bool global_init_p)
   else if (TARGET_LONG_DOUBLE_128)
 

[gcc(refs/users/meissner/heads/work201)] Change TARGET_FPRND to TARGET_POWER5X.

2025-04-14 Thread Michael Meissner via Gcc-cvs
https://gcc.gnu.org/g:aa02d954ad086708668465e7c4d2aa0f33b9a9f6

commit aa02d954ad086708668465e7c4d2aa0f33b9a9f6
Author: Michael Meissner 
Date:   Mon Apr 14 20:21:49 2025 -0400

Change TARGET_FPRND to TARGET_POWER5X.

This patch changes TARGET_POWER5X to TARGET_POWER5.  The -mfprnd switch is 
not
being changed, just the name of the macros used to determine if the PowerPC
processor supports ISA 2.4 (Power5x).

2025-04-14  Michael Meissner  

gcc/

* gcc/config/rs6000/rs6000.cc (rs6000_option_override_internal):
Change TARGET_FPRND to TARGET_POWER5X.
* gcc/config/rs6000/rs6000.h (TARGET_POWERP5X): New macro.
* gcc/config/rs6000/rs6000.md (fmod3): Change TARGET_FPRND to
TARGET_POWER5X.
(remainder3): Likewise.
(fctiwuz_): Likewise.
(ceil2): Likewise.
(floor2): Likewise.
(round2): Likewise.

Diff:
---
 gcc/config/rs6000/rs6000.cc |  4 ++--
 gcc/config/rs6000/rs6000.h  |  1 +
 gcc/config/rs6000/rs6000.md | 14 +++---
 3 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc
index a5ed93702494..b2811d963fcf 100644
--- a/gcc/config/rs6000/rs6000.cc
+++ b/gcc/config/rs6000/rs6000.cc
@@ -3924,7 +3924,7 @@ rs6000_option_override_internal (bool global_init_p)
 rs6000_isa_flags |= (ISA_2_5_MASKS_SERVER & ~ignore_masks);
   else if (TARGET_CMPB)
 rs6000_isa_flags |= (ISA_2_5_MASKS_EMBEDDED & ~ignore_masks);
-  else if (TARGET_FPRND)
+  else if (TARGET_POWER5X)
 rs6000_isa_flags |= (ISA_2_4_MASKS & ~ignore_masks);
   else if (TARGET_POWER5)
 rs6000_isa_flags |= (ISA_2_2_MASKS & ~ignore_masks);
@@ -3951,7 +3951,7 @@ rs6000_option_override_internal (bool global_init_p)
   rs6000_isa_flags &= ~OPTION_MASK_CRYPTO;
 }
 
-  if (!TARGET_FPRND && TARGET_VSX)
+  if (!TARGET_POWER5X && TARGET_VSX)
 {
   if (rs6000_isa_flags_explicit & OPTION_MASK_FPRND)
/* TARGET_VSX = 1 implies Power 7 and newer */
diff --git a/gcc/config/rs6000/rs6000.h b/gcc/config/rs6000/rs6000.h
index d9a0ffe9f5b2..3794e3c0658d 100644
--- a/gcc/config/rs6000/rs6000.h
+++ b/gcc/config/rs6000/rs6000.h
@@ -501,6 +501,7 @@ extern int rs6000_vector_align[];
 
 /* Convert ISA bits like POPCNTB to PowerPC processors like POWER5.  */
 #define TARGET_POWER5  TARGET_POPCNTB
+#define TARGET_POWER5X TARGET_FPRND
 
 /* In switching from using target_flags to using rs6000_isa_flags, the options
machinery creates OPTION_MASK_ instead of MASK_.  The MASK_
diff --git a/gcc/config/rs6000/rs6000.md b/gcc/config/rs6000/rs6000.md
index c5bd273be8b3..045ce22a03c8 100644
--- a/gcc/config/rs6000/rs6000.md
+++ b/gcc/config/rs6000/rs6000.md
@@ -5171,7 +5171,7 @@
(use (match_operand:SFDF 1 "gpc_reg_operand"))
(use (match_operand:SFDF 2 "gpc_reg_operand"))]
   "TARGET_HARD_FLOAT
-   && TARGET_FPRND
+   && TARGET_POWER5X
&& flag_unsafe_math_optimizations"
 {
   rtx div = gen_reg_rtx (mode);
@@ -5189,7 +5189,7 @@
(use (match_operand:SFDF 1 "gpc_reg_operand"))
(use (match_operand:SFDF 2 "gpc_reg_operand"))]
   "TARGET_HARD_FLOAT
-   && TARGET_FPRND
+   && TARGET_POWER5X
&& flag_unsafe_math_optimizations"
 {
   rtx div = gen_reg_rtx (mode);
@@ -6689,7 +6689,7 @@
 (define_insn "*friz"
   [(set (match_operand:DF 0 "gpc_reg_operand" "=d,wa")
(float:DF (fix:DI (match_operand:DF 1 "gpc_reg_operand" "d,wa"]
-  "TARGET_HARD_FLOAT && TARGET_FPRND
+  "TARGET_HARD_FLOAT && TARGET_POWER5X
&& flag_unsafe_math_optimizations && !flag_trapping_math && TARGET_FRIZ"
   "@
friz %0,%1
@@ -6817,7 +6817,7 @@
   [(set (match_operand:SFDF 0 "gpc_reg_operand" "=d,wa")
(unspec:SFDF [(match_operand:SFDF 1 "gpc_reg_operand" "d,wa")]
 UNSPEC_FRIZ))]
-  "TARGET_HARD_FLOAT && TARGET_FPRND"
+  "TARGET_HARD_FLOAT && TARGET_POWER5X"
   "@
friz %0,%1
xsrdpiz %x0,%x1"
@@ -6827,7 +6827,7 @@
   [(set (match_operand:SFDF 0 "gpc_reg_operand" "=d,wa")
(unspec:SFDF [(match_operand:SFDF 1 "gpc_reg_operand" "d,wa")]
 UNSPEC_FRIP))]
-  "TARGET_HARD_FLOAT && TARGET_FPRND"
+  "TARGET_HARD_FLOAT && TARGET_POWER5X"
   "@
frip %0,%1
xsrdpip %x0,%x1"
@@ -6837,7 +6837,7 @@
   [(set (match_operand:SFDF 0 "gpc_reg_operand" "=d,wa")
(unspec:SFDF [(match_operand:SFDF 1 "gpc_reg_operand" "d,wa")]
 UNSPEC_FRIM))]
-  "TARGET_HARD_FLOAT && TARGET_FPRND"
+  "TARGET_HARD_FLOAT && TARGET_POWER5X"
   "@
frim %0,%1
xsrdpim %x0,%x1"
@@ -6848,7 +6848,7 @@
   [(set (match_operand:SFDF 0 "gpc_reg_operand" "=")
(unspec:SFDF [(match_operand:SFDF 1 "gpc_reg_operand" "")]
 UNSPEC_FRIN))]
-  "TARGET_HARD_FLOAT && TARGET_FPRND"
+  "TARGET_HARD_FLOAT && TARGET_POWER5X"
   "frin %0,%1"
   [(set_attr "type" "fp")])


[gcc(refs/users/meissner/heads/work201)] Change TARGET_CMPB to TARGET_POWER6.

2025-04-14 Thread Michael Meissner via Gcc-cvs
https://gcc.gnu.org/g:d1ebe305c1b918fdd91eb534c382c388e82c3321

commit d1ebe305c1b918fdd91eb534c382c388e82c3321
Author: Michael Meissner 
Date:   Mon Apr 14 20:22:47 2025 -0400

Change TARGET_CMPB to TARGET_POWER6.

This patch changes TARGET_CMPB to TARGET_POWER6.  The -mcmpb switch is not 
being
changed, just the name of the macros used to determine if the PowerPC 
processor
supports ISA 2.5 (Power6).

2025-04-14  Michael Meissner  

gcc/

* gcc/config/rs6000/rs6000-builtin.cc (rs6000_builtin_is_supported):
Change TARGET_CMPB to TARGET_POWER6.
* gcc/config/rs6000/rs6000.cc (rs6000_option_override_internal):
Likewise.
(rs6000_rtx_costs): Likewise.
(rs6000_emit_parity): Likewise.
* gcc/config/rs6000/rs6000.h (TARGET_FCFID): Likewise.
(TARGET_LFIWAX): Likewise.
(TARGET_POWER6): New macro.
(TARGET_EXTRA_BUILTINS): Change TARGET_CMPB to TARGET_POWER6.
* gcc/config/rs6000/rs6000.md (enabled attribute): Likewise.
(parity2_cmp): Likewise.
(cmpb3): Likewise.
(copysign3): Likewise.
(copysign3_fcpsgn): Likewise.
(cmpstrnsi): Likewise.
(cmpstrsi): Likewise.

Diff:
---
 gcc/config/rs6000/rs6000-builtin.cc |  4 ++--
 gcc/config/rs6000/rs6000.cc |  8 
 gcc/config/rs6000/rs6000.h  |  7 ---
 gcc/config/rs6000/rs6000.md | 16 
 4 files changed, 18 insertions(+), 17 deletions(-)

diff --git a/gcc/config/rs6000/rs6000-builtin.cc 
b/gcc/config/rs6000/rs6000-builtin.cc
index 4ed2bc1ca89e..dbb8520ab039 100644
--- a/gcc/config/rs6000/rs6000-builtin.cc
+++ b/gcc/config/rs6000/rs6000-builtin.cc
@@ -157,9 +157,9 @@ rs6000_builtin_is_supported (enum rs6000_gen_builtins 
fncode)
 case ENB_P5:
   return TARGET_POWER5;
 case ENB_P6:
-  return TARGET_CMPB;
+  return TARGET_POWER6;
 case ENB_P6_64:
-  return TARGET_CMPB && TARGET_POWERPC64;
+  return TARGET_POWER6 && TARGET_POWERPC64;
 case ENB_P7:
   return TARGET_POPCNTD;
 case ENB_P7_64:
diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc
index b2811d963fcf..c01af37200ac 100644
--- a/gcc/config/rs6000/rs6000.cc
+++ b/gcc/config/rs6000/rs6000.cc
@@ -3922,7 +3922,7 @@ rs6000_option_override_internal (bool global_init_p)
 rs6000_isa_flags |= (ISA_2_6_MASKS_EMBEDDED & ~ignore_masks);
   else if (TARGET_DFP)
 rs6000_isa_flags |= (ISA_2_5_MASKS_SERVER & ~ignore_masks);
-  else if (TARGET_CMPB)
+  else if (TARGET_POWER6)
 rs6000_isa_flags |= (ISA_2_5_MASKS_EMBEDDED & ~ignore_masks);
   else if (TARGET_POWER5X)
 rs6000_isa_flags |= (ISA_2_4_MASKS & ~ignore_masks);
@@ -4797,7 +4797,7 @@ rs6000_option_override_internal (bool global_init_p)
  DERAT mispredict penalty.  However the LVE and STVE altivec instructions
  need indexed accesses and the type used is the scalar type of the element
  being loaded or stored.  */
-TARGET_AVOID_XFORM = (rs6000_tune == PROCESSOR_POWER6 && TARGET_CMPB
+TARGET_AVOID_XFORM = (rs6000_tune == PROCESSOR_POWER6 && TARGET_POWER6
  && !TARGET_ALTIVEC);
 
   /* Set the -mrecip options.  */
@@ -22396,7 +22396,7 @@ rs6000_rtx_costs (rtx x, machine_mode mode, int 
outer_code,
   return false;
 
 case PARITY:
-  *total = COSTS_N_INSNS (TARGET_CMPB ? 2 : 6);
+  *total = COSTS_N_INSNS (TARGET_POWER6 ? 2 : 6);
   return false;
 
 case NOT:
@@ -23223,7 +23223,7 @@ rs6000_emit_parity (rtx dst, rtx src)
   tmp = gen_reg_rtx (mode);
 
   /* Use the PPC ISA 2.05 prtyw/prtyd instruction if we can.  */
-  if (TARGET_CMPB)
+  if (TARGET_POWER6)
 {
   if (mode == SImode)
{
diff --git a/gcc/config/rs6000/rs6000.h b/gcc/config/rs6000/rs6000.h
index 3794e3c0658d..5b8cf054f98a 100644
--- a/gcc/config/rs6000/rs6000.h
+++ b/gcc/config/rs6000/rs6000.h
@@ -449,12 +449,12 @@ extern int rs6000_vector_align[];
 #define TARGET_FCFID   (TARGET_POWERPC64   \
 || TARGET_PPC_GPOPT/* 970/power4 */\
 || TARGET_POWER5   /* ISA 2.02 */  \
-|| TARGET_CMPB /* ISA 2.05 */  \
+|| TARGET_POWER6   /* ISA 2.05 */  \
 || TARGET_POPCNTD) /* ISA 2.06 */
 
 #define TARGET_FCTIDZ  TARGET_FCFID
 #define TARGET_STFIWX  TARGET_PPC_GFXOPT
-#define TARGET_LFIWAX  TARGET_CMPB
+#define TARGET_LFIWAX  TARGET_POWER6
 #define TARGET_LFIWZX  TARGET_POPCNTD
 #define TARGET_FCFIDS  TARGET_POPCNTD
 #define TARGET_FCFIDU  TARGET_POPCNTD
@@ -502,6 +502,7 @@ extern int rs6000_vector_align[];
 /* Convert ISA bits like POPCNTB to PowerPC processors like POWER5.  */
 #define TARGET_POWER5  TARGET_POPCNTB
 #define TARGET_POWER5X TARGET_FPRND
+#define TARGET_POWER6

[gcc(refs/users/meissner/heads/work201)] Change TARGET_MODULO to TARGET_POWER9.

2025-04-14 Thread Michael Meissner via Gcc-cvs
https://gcc.gnu.org/g:754bb7ee044e916602c47347e7717d4aa17850f5

commit 754bb7ee044e916602c47347e7717d4aa17850f5
Author: Michael Meissner 
Date:   Mon Apr 14 20:24:37 2025 -0400

Change TARGET_MODULO to TARGET_POWER9.

This patch changes TARGET_MODULO to TARGET_POWER9.  The -mmodulo switch is 
not
being changed, just the name of the macros used to determine if the PowerPC
processor supports ISA 3.0 (Power9).

2025-04-14  Michael Meissner  

gcc/

* gcc/config/rs6000/rs6000-builtin.cc (rs6000_builtin_is_supported):
Change TARGET_MODULO to TARGET_POWER9.
* gcc/config/rs6000/rs6000.cc (rs6000_option_override_internal):
Likewise.
* gcc/config/rs6000/rs6000.h (TARGET_CTZ): Likewise.
(TARGET_EXTSWSLI): Likewise.
(TARGET_MADDLD): Likewise.
(TARGET_POWER9): New macro.
* gcc/config/rs6000/rs6000.md (enabled attribute): Change 
TARGET_MODULO
to TARGET_POWER9.
(mod3): Likewise.
(umod3): Likewise.
(divide/modulo peephole2): Likewise.

Diff:
---
 gcc/config/rs6000/rs6000-builtin.cc |  4 ++--
 gcc/config/rs6000/rs6000.cc |  4 ++--
 gcc/config/rs6000/rs6000.h  |  7 ---
 gcc/config/rs6000/rs6000.md | 14 +++---
 4 files changed, 15 insertions(+), 14 deletions(-)

diff --git a/gcc/config/rs6000/rs6000-builtin.cc 
b/gcc/config/rs6000/rs6000-builtin.cc
index 2366b2aee00a..d8ff7cf32dfd 100644
--- a/gcc/config/rs6000/rs6000-builtin.cc
+++ b/gcc/config/rs6000/rs6000-builtin.cc
@@ -169,9 +169,9 @@ rs6000_builtin_is_supported (enum rs6000_gen_builtins 
fncode)
 case ENB_P8V:
   return TARGET_P8_VECTOR;
 case ENB_P9:
-  return TARGET_MODULO;
+  return TARGET_POWER9;
 case ENB_P9_64:
-  return TARGET_MODULO && TARGET_POWERPC64;
+  return TARGET_POWER9 && TARGET_POWERPC64;
 case ENB_P9V:
   return TARGET_P9_VECTOR;
 case ENB_P10:
diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc
index 503b07339647..8d97b265ac91 100644
--- a/gcc/config/rs6000/rs6000.cc
+++ b/gcc/config/rs6000/rs6000.cc
@@ -3888,7 +3888,7 @@ rs6000_option_override_internal (bool global_init_p)
 
   /* For the newer switches (vsx, dfp, etc.) set some of the older options,
  unless the user explicitly used the -mno- to disable the code.  */
-  if (TARGET_P9_VECTOR || TARGET_MODULO || TARGET_P9_MISC)
+  if (TARGET_P9_VECTOR || TARGET_POWER9 || TARGET_P9_MISC)
 rs6000_isa_flags |= (ISA_3_0_MASKS_SERVER & ~ignore_masks);
   else if (TARGET_P9_MINMAX)
 {
@@ -22377,7 +22377,7 @@ rs6000_rtx_costs (rtx x, machine_mode mode, int 
outer_code,
*total = rs6000_cost->divsi;
}
   /* Add in shift and subtract for MOD unless we have a mod instruction. */
-  if ((!TARGET_MODULO
+  if ((!TARGET_POWER9
   || (RS6000_DISABLE_SCALAR_MODULO && SCALAR_INT_MODE_P (mode)))
 && (code == MOD || code == UMOD))
*total += COSTS_N_INSNS (2);
diff --git a/gcc/config/rs6000/rs6000.h b/gcc/config/rs6000/rs6000.h
index f1da5d31441a..c2f1910b0ea2 100644
--- a/gcc/config/rs6000/rs6000.h
+++ b/gcc/config/rs6000/rs6000.h
@@ -463,9 +463,9 @@ extern int rs6000_vector_align[];
 #define TARGET_FCTIWUZ TARGET_POWER7
 /* Only powerpc64 and powerpc476 support fctid.  */
 #define TARGET_FCTID   (TARGET_POWERPC64 || rs6000_cpu == PROCESSOR_PPC476)
-#define TARGET_CTZ TARGET_MODULO
-#define TARGET_EXTSWSLI(TARGET_MODULO && TARGET_POWERPC64)
-#define TARGET_MADDLD  TARGET_MODULO
+#define TARGET_CTZ TARGET_POWER9
+#define TARGET_EXTSWSLI(TARGET_POWER9 && TARGET_POWERPC64)
+#define TARGET_MADDLD  TARGET_POWER9
 
 /* TARGET_DIRECT_MOVE is redundant to TARGET_P8_VECTOR, so alias it to that.  
*/
 #define TARGET_DIRECT_MOVE TARGET_P8_VECTOR
@@ -504,6 +504,7 @@ extern int rs6000_vector_align[];
 #define TARGET_POWER5X TARGET_FPRND
 #define TARGET_POWER6  TARGET_CMPB
 #define TARGET_POWER7  TARGET_POPCNTD
+#define TARGET_POWER9  TARGET_MODULO
 
 /* In switching from using target_flags to using rs6000_isa_flags, the options
machinery creates OPTION_MASK_ instead of MASK_.  The MASK_
diff --git a/gcc/config/rs6000/rs6000.md b/gcc/config/rs6000/rs6000.md
index 87ec37a9f8e4..db1b6c2d1164 100644
--- a/gcc/config/rs6000/rs6000.md
+++ b/gcc/config/rs6000/rs6000.md
@@ -403,7 +403,7 @@
  (const_int 1)
 
  (and (eq_attr "isa" "p9")
- (match_test "TARGET_MODULO"))
+ (match_test "TARGET_POWER9"))
  (const_int 1)
 
  (and (eq_attr "isa" "p9v")
@@ -3457,7 +3457,7 @@
   || INTVAL (operands[2]) <= 0
   || (i = exact_log2 (INTVAL (operands[2]))) < 0)
 {
-  if (!TARGET_MODULO)
+  if (!TARGET_POWER9)
FAIL;
 
   operands[2] = force_reg (mode, operands[2]);
@@ -3491,7 +3491,7 @@
   [(set (match_operand:GPR 0 "gpc_reg_operand" "=&r,r")
 (mod:GPR (match_oper

[gcc(refs/users/meissner/heads/work201)] Add -mcpu=future tests.

2025-04-14 Thread Michael Meissner via Gcc-cvs
https://gcc.gnu.org/g:7880c5c612d1eee0d70a2b9071ab7fd57df150e0

commit 7880c5c612d1eee0d70a2b9071ab7fd57df150e0
Author: Michael Meissner 
Date:   Mon Apr 14 20:29:30 2025 -0400

Add -mcpu=future tests.

This patch adds simple tests for -mcpu=future.

2025-04-14  Michael Meissner  

gcc/testsuite/

* gcc.target/powerpc/future-1.c: New test.
* gcc.target/powerpc/future-2.c: Likewise.

Diff:
---
 gcc/testsuite/gcc.target/powerpc/future-1.c | 13 +
 gcc/testsuite/gcc.target/powerpc/future-2.c | 24 
 2 files changed, 37 insertions(+)

diff --git a/gcc/testsuite/gcc.target/powerpc/future-1.c 
b/gcc/testsuite/gcc.target/powerpc/future-1.c
new file mode 100644
index ..f1b940d7bebf
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/future-1.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-options "-mdejagnu-cpu=future -O2" } */
+
+/* Basic check to see if the compiler supports -mcpu=future and if it defines
+   _ARCH_PWR11.  */
+
+#ifndef _ARCH_FUTURE
+#error "-mcpu=future is not supported"
+#endif
+
+void foo (void)
+{
+}
diff --git a/gcc/testsuite/gcc.target/powerpc/future-2.c 
b/gcc/testsuite/gcc.target/powerpc/future-2.c
new file mode 100644
index ..5552cefa3c2e
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/future-2.c
@@ -0,0 +1,24 @@
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+/* Check if we can set the future target via a target attribute.  */
+
+__attribute__((__target__("cpu=power9")))
+void foo_p9 (void)
+{
+}
+
+__attribute__((__target__("cpu=power10")))
+void foo_p10 (void)
+{
+}
+
+__attribute__((__target__("cpu=power11")))
+void foo_p11 (void)
+{
+}
+
+__attribute__((__target__("cpu=future")))
+void foo_future (void)
+{
+}


[gcc(refs/users/meissner/heads/work201)] xUse vector pair load/store for memcpy with -mcpu=future

2025-04-14 Thread Michael Meissner via Gcc-cvs
https://gcc.gnu.org/g:c8a6cb09a701300cf3bcf552b8e78fadd43bc2ac

commit c8a6cb09a701300cf3bcf552b8e78fadd43bc2ac
Author: Michael Meissner 
Date:   Mon Apr 14 20:30:13 2025 -0400

xUse vector pair load/store for memcpy with -mcpu=future

In the development for the power10 processor, GCC did not enable using the 
load
vector pair and store vector pair instructions when optimizing things like
memory copy.  This patch enables using those instructions if -mcpu=future is
used.

2025-04-14  Michael Meissner  

gcc/

* config/rs6000/rs6000-cpus.def (ISA_FUTURE_MASKS_SERVER): Enable 
using
load vector pair and store vector pair instructions for memory copy
operations.
(POWERPC_MASKS): Make the bit for enabling using load vector pair 
and
store vector pair operations set and reset when the PowerPC 
processor is
changed.
* gcc/config/rs6000/rs6000.cc (rs6000_machine_from_flags): Disable
-mblock-ops-vector-pair from influcing .machine selection.

gcc/testsuite/

* gcc.target/powerpc/future-3.c: New test.

Diff:
---
 gcc/config/rs6000/rs6000-cpus.def   |  4 +++-
 gcc/config/rs6000/rs6000.cc |  2 +-
 gcc/testsuite/gcc.target/powerpc/future-3.c | 22 ++
 3 files changed, 26 insertions(+), 2 deletions(-)

diff --git a/gcc/config/rs6000/rs6000-cpus.def 
b/gcc/config/rs6000/rs6000-cpus.def
index 228d0b5e7b54..063591f5c094 100644
--- a/gcc/config/rs6000/rs6000-cpus.def
+++ b/gcc/config/rs6000/rs6000-cpus.def
@@ -84,7 +84,8 @@
  | OPTION_MASK_POWER11)
 
 #define FUTURE_MASKS_SERVER(POWER11_MASKS_SERVER   \
-| OPTION_MASK_FUTURE)
+| OPTION_MASK_FUTURE   \
+| OPTION_MASK_BLOCK_OPS_VECTOR_PAIR)
 
 /* Flags that need to be turned off if -mno-vsx.  */
 #define OTHER_VSX_VECTOR_MASKS (OPTION_MASK_EFFICIENT_UNALIGNED_VSX\
@@ -114,6 +115,7 @@
 
 /* Mask of all options to set the default isa flags based on -mcpu=.  */
 #define POWERPC_MASKS  (OPTION_MASK_ALTIVEC\
+| OPTION_MASK_BLOCK_OPS_VECTOR_PAIR\
 | OPTION_MASK_CMPB \
 | OPTION_MASK_CRYPTO   \
 | OPTION_MASK_DFP  \
diff --git a/gcc/config/rs6000/rs6000.cc b/gcc/config/rs6000/rs6000.cc
index 4cea1775f110..011f67d290e9 100644
--- a/gcc/config/rs6000/rs6000.cc
+++ b/gcc/config/rs6000/rs6000.cc
@@ -5908,7 +5908,7 @@ rs6000_machine_from_flags (void)
 
   /* Disable the flags that should never influence the .machine selection.  */
   flags &= ~(OPTION_MASK_PPC_GFXOPT | OPTION_MASK_PPC_GPOPT | OPTION_MASK_ISEL
-| OPTION_MASK_ALTIVEC);
+| OPTION_MASK_ALTIVEC | OPTION_MASK_BLOCK_OPS_VECTOR_PAIR);
 
   if ((flags & (FUTURE_MASKS_SERVER & ~ISA_3_1_MASKS_SERVER)) != 0)
 return "future";
diff --git a/gcc/testsuite/gcc.target/powerpc/future-3.c 
b/gcc/testsuite/gcc.target/powerpc/future-3.c
new file mode 100644
index ..afa8b96d
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/future-3.c
@@ -0,0 +1,22 @@
+/* 32-bit doesn't generate vector pair instructions.  */
+/* { dg-do compile { target lp64 } } */
+/* { dg-options "-mdejagnu-cpu=future -O2" } */
+
+/* Test to see that memcpy will use load/store vector pair with
+   -mcpu=future.  */
+
+#ifndef SIZE
+#define SIZE 4
+#endif
+
+extern vector double to[SIZE], from[SIZE];
+
+void
+copy (void)
+{
+  __builtin_memcpy (to, from, sizeof (to));
+  return;
+}
+
+/* { dg-final { scan-assembler {\mlxvpx?\M}  } } */
+/* { dg-final { scan-assembler {\mstxvpx?\M} } } */


[gcc r14-11613] phiopt: Fix value_replacement for middle bb having phi nodes [PR118922]

2025-04-14 Thread Andrew Pinski via Gcc-cvs
https://gcc.gnu.org/g:0d931663498d2f95fb7ea0ae0ef8473f88eed26a

commit r14-11613-g0d931663498d2f95fb7ea0ae0ef8473f88eed26a
Author: Andrew Pinski 
Date:   Sat Mar 8 22:43:54 2025 -0800

phiopt: Fix value_replacement for middle bb having phi nodes [PR118922]

After r12-5300-gf98f373dd822b3, value_replacement would be able to look at 
the
following cfg structure:
```
   [local count: 1014686024]:
  if (h_6 != 0)
goto ; [94.50%]
  else
goto ; [5.50%]

   [local count: 114863530]:
  # h_6 = PHI <0(4), 1(5)>

   [local count: 1073741824]:
  # f_8 = PHI <0(5), h_6(6)>
  _9 = f_8 ^ 1;
  a.0_10 = a;
  _11 = _9 + a.0_10;
  if (_11 != -117)
goto ; [94.50%]
  else
goto ; [5.50%]
```

value_replacement would incorrectly think the middle bb (6) was empty and 
so it decides
to remove condition in bb5 and replacing it with 0 as the function thought 
it was `h_6 ? 0 : h_6`.
But since the there is an incoming phi node to bb6 defining h_6 that is 
incorrect.

The fix is to check if there is phi nodes in the middle bb and set 
empty_or_with_defined_p to false.
This was not needed before r12-5300-gf98f373dd822b3 because the phi would 
have been dead otherwise due to
other checks.

Bootstrapped and tested on x86_64-linux-gnu.

PR tree-optimization/118922

gcc/ChangeLog:

* tree-ssa-phiopt.cc (value_replacement): Set 
empty_or_with_defined_p
to false when there is phi nodes for the middle bb.

gcc/testsuite/ChangeLog:

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

Signed-off-by: Andrew Pinski 
(cherry picked from commit 7232c005afb5002cdfd0a2dbd0e8b8f2d80250ce)

Diff:
---
 gcc/testsuite/gcc.dg/torture/pr118922-1.c | 57 +++
 gcc/tree-ssa-phiopt.cc|  4 +++
 2 files changed, 61 insertions(+)

diff --git a/gcc/testsuite/gcc.dg/torture/pr118922-1.c 
b/gcc/testsuite/gcc.dg/torture/pr118922-1.c
new file mode 100644
index ..27e8c78c0e4e
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr118922-1.c
@@ -0,0 +1,57 @@
+/* { dg-do run } */
+/* PR tree-optimization/118922 */
+
+/* Phi-opt would convert:
+   [local count: 1014686024]:
+  if (h_6 != 0)
+goto ; [94.50%]
+  else
+goto ; [5.50%]
+
+   [local count: 114863530]:
+  # h_6 = PHI <0(4), 1(5)>
+
+   [local count: 1073741824]:
+  # f_8 = PHI <0(5), h_6(6)>
+  _9 = f_8 ^ 1;
+  a.0_10 = a;
+  _11 = _9 + a.0_10;
+  if (_11 != -117)
+goto ; [94.50%]
+  else
+goto ; [5.50%]
+
+into:
+
+   [local count: 59055799]:
+  c = d_3;
+
+   [local count: 1073741824]:
+  # f_8 = PHI <0(5), 0(4)>
+  _9 = f_8 ^ 1;
+  a.0_10 = a;
+  _11 = _9 + a.0_10;
+  if (_11 != -117)
+goto ; [94.50%]
+  else
+goto ; [5.50%]
+
+as it thought the middle bb was empty as there was only a phi node there. */
+
+
+int a = -117, b, c, e;
+void g(int h) {
+  int f = 0;
+  while (!f + a - -117) {
+f = h == 0;
+if (h == 0)
+  h = 1;
+  }
+}
+int main() {
+  int d = 8;
+  for (; e;)
+d = 0;
+  c = d;
+  g(0);
+}
diff --git a/gcc/tree-ssa-phiopt.cc b/gcc/tree-ssa-phiopt.cc
index fa8dc2c8a4e3..14bb8442a395 100644
--- a/gcc/tree-ssa-phiopt.cc
+++ b/gcc/tree-ssa-phiopt.cc
@@ -1195,6 +1195,10 @@ value_replacement (basic_block cond_bb, basic_block 
middle_bb,
empty_or_with_defined_p = false;
 }
 
+  /* The middle bb is not empty if there are any phi nodes. */
+  if (phi_nodes (middle_bb))
+empty_or_with_defined_p = false;
+
   gcond *cond = as_a  (*gsi_last_bb (cond_bb));
   code = gimple_cond_code (cond);


[gcc(refs/users/meissner/heads/work201-bugs)] Add ChangeLog.bugs and update REVISION.

2025-04-14 Thread Michael Meissner via Gcc-cvs
https://gcc.gnu.org/g:954acd83eabaacca62cd5cbba11e9bc10cf4119b

commit 954acd83eabaacca62cd5cbba11e9bc10cf4119b
Author: Michael Meissner 
Date:   Mon Apr 14 15:14:06 2025 -0400

Add ChangeLog.bugs and update REVISION.

2025-04-14  Michael Meissner  

gcc/

* ChangeLog.bugs: New file for branch.
* REVISION: Update.

Diff:
---
 gcc/ChangeLog.bugs | 5 +
 gcc/REVISION   | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/gcc/ChangeLog.bugs b/gcc/ChangeLog.bugs
new file mode 100644
index ..6f3c5d84f221
--- /dev/null
+++ b/gcc/ChangeLog.bugs
@@ -0,0 +1,5 @@
+ Branch work201-bugs, baseline 
+
+2025-04-14   Michael Meissner  
+
+   Clone branch
diff --git a/gcc/REVISION b/gcc/REVISION
index 5f8715c4844d..028186c1b5c7 100644
--- a/gcc/REVISION
+++ b/gcc/REVISION
@@ -1 +1 @@
-work201 branch
+work201-bugs branch


[gcc r13-9528] phiopt: Fix value_replacement for middle bb having phi nodes [PR118922]

2025-04-14 Thread Andrew Pinski via Gcc-cvs
https://gcc.gnu.org/g:7b9a1f91efe34051bc512def7ef883f62cf698fd

commit r13-9528-g7b9a1f91efe34051bc512def7ef883f62cf698fd
Author: Andrew Pinski 
Date:   Sat Mar 8 22:43:54 2025 -0800

phiopt: Fix value_replacement for middle bb having phi nodes [PR118922]

After r12-5300-gf98f373dd822b3, value_replacement would be able to look at 
the
following cfg structure:
```
   [local count: 1014686024]:
  if (h_6 != 0)
goto ; [94.50%]
  else
goto ; [5.50%]

   [local count: 114863530]:
  # h_6 = PHI <0(4), 1(5)>

   [local count: 1073741824]:
  # f_8 = PHI <0(5), h_6(6)>
  _9 = f_8 ^ 1;
  a.0_10 = a;
  _11 = _9 + a.0_10;
  if (_11 != -117)
goto ; [94.50%]
  else
goto ; [5.50%]
```

value_replacement would incorrectly think the middle bb (6) was empty and 
so it decides
to remove condition in bb5 and replacing it with 0 as the function thought 
it was `h_6 ? 0 : h_6`.
But since the there is an incoming phi node to bb6 defining h_6 that is 
incorrect.

The fix is to check if there is phi nodes in the middle bb and set 
empty_or_with_defined_p to false.
This was not needed before r12-5300-gf98f373dd822b3 because the phi would 
have been dead otherwise due to
other checks.

Bootstrapped and tested on x86_64-linux-gnu.

PR tree-optimization/118922

gcc/ChangeLog:

* tree-ssa-phiopt.cc (value_replacement): Set 
empty_or_with_defined_p
to false when there is phi nodes for the middle bb.

gcc/testsuite/ChangeLog:

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

Signed-off-by: Andrew Pinski 
(cherry picked from commit 7232c005afb5002cdfd0a2dbd0e8b8f2d80250ce)

Diff:
---
 gcc/testsuite/gcc.dg/torture/pr118922-1.c | 57 +++
 gcc/tree-ssa-phiopt.cc|  4 +++
 2 files changed, 61 insertions(+)

diff --git a/gcc/testsuite/gcc.dg/torture/pr118922-1.c 
b/gcc/testsuite/gcc.dg/torture/pr118922-1.c
new file mode 100644
index ..27e8c78c0e4e
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr118922-1.c
@@ -0,0 +1,57 @@
+/* { dg-do run } */
+/* PR tree-optimization/118922 */
+
+/* Phi-opt would convert:
+   [local count: 1014686024]:
+  if (h_6 != 0)
+goto ; [94.50%]
+  else
+goto ; [5.50%]
+
+   [local count: 114863530]:
+  # h_6 = PHI <0(4), 1(5)>
+
+   [local count: 1073741824]:
+  # f_8 = PHI <0(5), h_6(6)>
+  _9 = f_8 ^ 1;
+  a.0_10 = a;
+  _11 = _9 + a.0_10;
+  if (_11 != -117)
+goto ; [94.50%]
+  else
+goto ; [5.50%]
+
+into:
+
+   [local count: 59055799]:
+  c = d_3;
+
+   [local count: 1073741824]:
+  # f_8 = PHI <0(5), 0(4)>
+  _9 = f_8 ^ 1;
+  a.0_10 = a;
+  _11 = _9 + a.0_10;
+  if (_11 != -117)
+goto ; [94.50%]
+  else
+goto ; [5.50%]
+
+as it thought the middle bb was empty as there was only a phi node there. */
+
+
+int a = -117, b, c, e;
+void g(int h) {
+  int f = 0;
+  while (!f + a - -117) {
+f = h == 0;
+if (h == 0)
+  h = 1;
+  }
+}
+int main() {
+  int d = 8;
+  for (; e;)
+d = 0;
+  c = d;
+  g(0);
+}
diff --git a/gcc/tree-ssa-phiopt.cc b/gcc/tree-ssa-phiopt.cc
index 9856d3e139e6..fd472771b1eb 100644
--- a/gcc/tree-ssa-phiopt.cc
+++ b/gcc/tree-ssa-phiopt.cc
@@ -1364,6 +1364,10 @@ value_replacement (basic_block cond_bb, basic_block 
middle_bb,
empty_or_with_defined_p = false;
 }
 
+  /* The middle bb is not empty if there are any phi nodes. */
+  if (phi_nodes (middle_bb))
+empty_or_with_defined_p = false;
+
   cond = last_stmt (cond_bb);
   code = gimple_cond_code (cond);


[gcc r13-9526] backprop: Fix deleting of a phi node [PR116922]

2025-04-14 Thread Andrew Pinski via Gcc-cvs
https://gcc.gnu.org/g:f6f61d99f576c1caef507f86f7feec0420cc0a43

commit r13-9526-gf6f61d99f576c1caef507f86f7feec0420cc0a43
Author: Andrew Pinski 
Date:   Tue Oct 1 14:48:19 2024 -0700

backprop: Fix deleting of a phi node [PR116922]

The problem here is remove_unused_var is called on a name that is
defined by a phi node but it deletes it like removing a normal statement.
remove_phi_node should be called rather than gsi_remove for phinodes.

Note there is a possibility of using simple_dce_from_worklist instead
but that is for another day.

Bootstrapped and tested on x86_64-linux-gnu.

PR tree-optimization/116922

gcc/ChangeLog:

* gimple-ssa-backprop.cc (remove_unused_var): Handle phi
nodes correctly.

gcc/testsuite/ChangeLog:

* gcc.dg/torture/pr116922.c: New test.

Signed-off-by: Andrew Pinski 
(cherry picked from commit cea87c84eacdb422caeada734ba5138c994d7022)

Diff:
---
 gcc/gimple-ssa-backprop.cc  | 10 --
 gcc/testsuite/gcc.dg/torture/pr116922.c | 19 +++
 2 files changed, 27 insertions(+), 2 deletions(-)

diff --git a/gcc/gimple-ssa-backprop.cc b/gcc/gimple-ssa-backprop.cc
index dcb15ed4f619..d82ad293884e 100644
--- a/gcc/gimple-ssa-backprop.cc
+++ b/gcc/gimple-ssa-backprop.cc
@@ -663,8 +663,14 @@ remove_unused_var (tree var)
   print_gimple_stmt (dump_file, stmt, 0, TDF_SLIM);
 }
   gimple_stmt_iterator gsi = gsi_for_stmt (stmt);
-  gsi_remove (&gsi, true);
-  release_defs (stmt);
+  if (gimple_code (stmt) == GIMPLE_PHI)
+remove_phi_node (&gsi, true);
+  else
+{
+  unlink_stmt_vdef (stmt);
+  gsi_remove (&gsi, true);
+  release_defs (stmt);
+}
 }
 
 /* Note that we're replacing OLD_RHS with NEW_RHS in STMT.  */
diff --git a/gcc/testsuite/gcc.dg/torture/pr116922.c 
b/gcc/testsuite/gcc.dg/torture/pr116922.c
new file mode 100644
index ..0fcf912930f4
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr116922.c
@@ -0,0 +1,19 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-ffast-math" } */
+/* PR tree-optimization/116922 */
+
+
+static int g;
+
+void
+foo (int c, double v, double *r)
+{
+b:
+  do
+v /= g - v;
+  while (c);
+  *r = v;
+
+  double x;
+  foo (5, (double)0, &x);
+}


[gcc r14-11611] Revert very recent backport of changes to the type system

2025-04-14 Thread Eric Botcazou via Gcc-cvs
https://gcc.gnu.org/g:5457388f58262bee41ae1d744ff6f3da34119e2d

commit r14-11611-g5457388f58262bee41ae1d744ff6f3da34119e2d
Author: Eric Botcazou 
Date:   Mon Apr 14 23:35:43 2025 +0200

Revert very recent backport of changes to the type system

The backport of the change made for PR c/113688 onto the 14 branch a couple
of weeks ago has seriously broken the LTO compiler for the Ada language on
the 14 branch, because it changes the GCC type system for the sake of C in
a way that is not compatible with simple discriminated types in Ada.  To be
more precise, useless_type_conversion_p now returns true for some (view-)
conversions that are needed by the rest of the compiler.

gcc/
PR lto/119792
Revert

Backported from master:
2024-12-12  Martin Uecker  

PR c/113688
PR c/114014
PR c/114713
PR c/117724
* tree.cc (gimple_canonical_types_compatible_p): Add exception.
(verify_type): Add exception.

gcc/lto/
PR lto/119792
Revert

Backported from master:
2024-12-12  Martin Uecker  
* lto-common.cc (hash_canonical_type): Add exception.

gcc/testsuite/
* gcc.dg/pr113688.c: Delete.
* gcc.dg/pr114014.c: Likewise.
* gcc.dg/pr114713.c: Likewise.
* gcc.dg/pr117724.c: Likewise

Diff:
---
 gcc/lto/lto-common.cc   |  9 ++--
 gcc/testsuite/gcc.dg/pr113688.c |  8 ---
 gcc/testsuite/gcc.dg/pr114014.c | 14 
 gcc/testsuite/gcc.dg/pr114713.c | 35 -
 gcc/testsuite/gcc.dg/pr117724.c | 16 --
 gcc/tree.cc | 49 +
 6 files changed, 12 insertions(+), 119 deletions(-)

diff --git a/gcc/lto/lto-common.cc b/gcc/lto/lto-common.cc
index 7697a7d6ea02..2ce94cc32828 100644
--- a/gcc/lto/lto-common.cc
+++ b/gcc/lto/lto-common.cc
@@ -254,8 +254,7 @@ hash_canonical_type (tree type)
  checked.  */
   code = tree_code_for_canonical_type_merging (TREE_CODE (type));
   hstate.add_int (code);
-  if (!RECORD_OR_UNION_TYPE_P (type))
-hstate.add_int (TYPE_MODE (type));
+  hstate.add_int (TYPE_MODE (type));
 
   /* Incorporate common features of numerical types.  */
   if (INTEGRAL_TYPE_P (type)
@@ -333,11 +332,7 @@ hash_canonical_type (tree type)
&& (! DECL_SIZE (f)
|| ! integer_zerop (DECL_SIZE (f
  {
-   tree t = TREE_TYPE (f);
-   if (!TREE_CHAIN (f)
-   && TREE_CODE (t) == ARRAY_TYPE)
- t = TREE_TYPE  (t);
-   iterative_hash_canonical_type (t, hstate);
+   iterative_hash_canonical_type (TREE_TYPE (f), hstate);
nf++;
  }
 
diff --git a/gcc/testsuite/gcc.dg/pr113688.c b/gcc/testsuite/gcc.dg/pr113688.c
deleted file mode 100644
index 8dee8c86f1bf..
--- a/gcc/testsuite/gcc.dg/pr113688.c
+++ /dev/null
@@ -1,8 +0,0 @@
-/* { dg-do compile } */
-/* { dg-options "-g" } */
-
-struct S{int x,y[1];}*a;
-int main(void){
-   struct S{int x,y[];};
-}
-
diff --git a/gcc/testsuite/gcc.dg/pr114014.c b/gcc/testsuite/gcc.dg/pr114014.c
deleted file mode 100644
index 1531ffab1b75..
--- a/gcc/testsuite/gcc.dg/pr114014.c
+++ /dev/null
@@ -1,14 +0,0 @@
-/* PR c/114014
- * { dg-do compile }
- * { dg-options "-std=gnu23 -g" } */
-
-struct r {
-  int a;
-  char b[];
-};
-struct r {
-  int a;
-  char b[0];
-};
-
-
diff --git a/gcc/testsuite/gcc.dg/pr114713.c b/gcc/testsuite/gcc.dg/pr114713.c
deleted file mode 100644
index 78e3237de948..
--- a/gcc/testsuite/gcc.dg/pr114713.c
+++ /dev/null
@@ -1,35 +0,0 @@
-/* { dg-do run } */
-/* { dg-require-effective-target lto } */
-/* { dg-options "-std=c23 -flto -O2" } */
-
-struct foo { int x; char a[]; };
-
-void test_bar(void* b);
-
-__attribute__((noinline))
-int test_foo(struct foo* a, void* b)
-{
-a->x = 1;
-test_bar(b);
-return a->x;
-}
-
-int main()
-{
-struct foo y;
-
-if (2 != test_foo(&y, &y))
-__builtin_abort();
-
-return 0;
-}
-
-// TU2
-struct foo { int x; char a[0]; };
-
-void test_bar(void* b)
-{
-struct foo *p = b;
-p->x = 2;
-}
-
diff --git a/gcc/testsuite/gcc.dg/pr117724.c b/gcc/testsuite/gcc.dg/pr117724.c
deleted file mode 100644
index d631daeb644d..
--- a/gcc/testsuite/gcc.dg/pr117724.c
+++ /dev/null
@@ -1,16 +0,0 @@
-/* { dg-do compile } */
-/* { dg-options "-g" } */
-
-struct {
-  unsigned long len;
-  unsigned long size;
-  char data[];
-}; /* { dg-warning "unnamed struct" } */
-struct {
-  struct {
-unsigned long len;
-unsigned long size;
-char data[6];
-  };
-}; /* { dg-warning "unnamed struct" } */
-
diff --git a/gcc/tree.cc b/gcc/tree.cc
index a4c62e1f0681..d716d7ccfe31 100644
--- a/gcc/tree.cc

[gcc r15-9474] c++: shortcut constexpr vector ctor [PR113835]

2025-04-14 Thread Jason Merrill via Gcc-cvs
https://gcc.gnu.org/g:764f02327f7b2dc6ac5abaf89038e51cf0ee6d13

commit r15-9474-g764f02327f7b2dc6ac5abaf89038e51cf0ee6d13
Author: Jason Merrill 
Date:   Sat Apr 12 11:35:18 2025 -0400

c++: shortcut constexpr vector ctor [PR113835]

Since std::vector became usable in constant evaluation in C++20, a vector
variable with static storage duration might be manifestly
constant-evaluated, so we properly try to constant-evaluate its initializer.
But it can never succeed since the result will always refer to the result of
operator new, so trying is a waste of time.  Potentially a large waste of
time for a large vector, as in the testcase in the PR.

So, let's recognize this case and skip trying constant-evaluation.  I do
this only for the case of an integer argument, as that's the case that's
easy to write but slow to (fail to) evaluate.

In the test, I use dg-timeout-factor to lower the default timeout from 300
seconds to 15; on my laptop, compilation without the patch takes about 20
seconds versus about 2 with the patch.

PR c++/113835

gcc/cp/ChangeLog:

* constexpr.cc (cxx_eval_outermost_constant_expr): Bail out early
for std::vector(N).

gcc/testsuite/ChangeLog:

* g++.dg/cpp2a/constexpr-vector1.C: New test.

Diff:
---
 gcc/cp/constexpr.cc| 9 +
 gcc/testsuite/g++.dg/cpp2a/constexpr-vector1.C | 8 
 2 files changed, 17 insertions(+)

diff --git a/gcc/cp/constexpr.cc b/gcc/cp/constexpr.cc
index 7e375823d648..dc59f59aa3f3 100644
--- a/gcc/cp/constexpr.cc
+++ b/gcc/cp/constexpr.cc
@@ -9127,6 +9127,15 @@ cxx_eval_outermost_constant_expr (tree t, bool 
allow_non_constant,
   tree fndecl = cp_get_callee_fndecl_nofold (x);
   if (fndecl && DECL_IMMEDIATE_FUNCTION_P (fndecl))
is_consteval = true;
+  /* Don't try to evaluate a std::vector constructor taking an integer, it
+will fail in the 'if (heap_var)' block below after doing all the work
+(c++/113835).  This will need adjustment if P3554 is accepted.  Note
+that evaluation of e.g. the vector default constructor can succeed, so
+we don't shortcut all vector constructors.  */
+  if (fndecl && DECL_CONSTRUCTOR_P (fndecl) && allow_non_constant
+ && is_std_class (type, "vector") && call_expr_nargs (x) > 1
+ && TREE_CODE (TREE_TYPE (get_nth_callarg (x, 1))) == INTEGER_TYPE)
+   return t;
 }
   if (AGGREGATE_TYPE_P (type) || VECTOR_TYPE_P (type))
 {
diff --git a/gcc/testsuite/g++.dg/cpp2a/constexpr-vector1.C 
b/gcc/testsuite/g++.dg/cpp2a/constexpr-vector1.C
new file mode 100644
index ..196c6ec51fcf
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp2a/constexpr-vector1.C
@@ -0,0 +1,8 @@
+// PR c++/113835
+// { dg-timeout-factor 0.05 }
+// { dg-do compile { target c++20_only } }
+
+#include 
+const std::size_t N = 1'000'000;
+std::vector x(N);
+int main() {}


[gcc r15-9450] gccrs: attributes: Add missing attributes used in `core`

2025-04-14 Thread Arthur Cohen via Gcc-cvs
https://gcc.gnu.org/g:34c516efbb8dce4bffe09045e6b941806744d1fd

commit r15-9450-g34c516efbb8dce4bffe09045e6b941806744d1fd
Author: Arthur Cohen 
Date:   Fri Apr 4 14:20:04 2025 +0200

gccrs: attributes: Add missing attributes used in `core`

gcc/rust/ChangeLog:

* util/rust-attribute-values.h: Add missing attributes.
* util/rust-attributes.cc: Likewise.
* util/rust-attributes.h (enum CompilerPass): Mention adding 
something for const
functions.

Diff:
---
 gcc/rust/util/rust-attribute-values.h | 24 
 gcc/rust/util/rust-attributes.cc  | 20 +++-
 gcc/rust/util/rust-attributes.h   |  2 ++
 3 files changed, 45 insertions(+), 1 deletion(-)

diff --git a/gcc/rust/util/rust-attribute-values.h 
b/gcc/rust/util/rust-attribute-values.h
index d579fa298013..50ccb4ab6dc0 100644
--- a/gcc/rust/util/rust-attribute-values.h
+++ b/gcc/rust/util/rust-attribute-values.h
@@ -40,12 +40,14 @@ public:
   static constexpr auto &NO_MANGLE = "no_mangle";
   static constexpr auto &REPR = "repr";
   static constexpr auto &RUSTC_BUILTIN_MACRO = "rustc_builtin_macro";
+  static constexpr auto &RUSTC_MACRO_TRANSPARENCY = "rustc_macro_transparency";
   static constexpr auto &PATH = "path";
   static constexpr auto &MACRO_USE = "macro_use";
   static constexpr auto &MACRO_EXPORT = "macro_export";
   static constexpr auto &PROC_MACRO = "proc_macro";
   static constexpr auto &PROC_MACRO_DERIVE = "proc_macro_derive";
   static constexpr auto &PROC_MACRO_ATTRIBUTE = "proc_macro_attribute";
+
   static constexpr auto &TARGET_FEATURE = "target_feature";
   // From now on, these are reserved by the compiler and gated through
   // #![feature(rustc_attrs)]
@@ -54,11 +56,33 @@ public:
 = "rustc_inherit_overflow_checks";
   static constexpr auto &STABLE = "stable";
   static constexpr auto &UNSTABLE = "unstable";
+
+  static constexpr auto &RUSTC_PROMOTABLE = "rustc_promotable";
   static constexpr auto &RUSTC_CONST_STABLE = "rustc_const_stable";
   static constexpr auto &RUSTC_CONST_UNSTABLE = "rustc_const_unstable";
+
+  static constexpr auto &RUSTC_SPECIALIZATION_TRAIT
+= "rustc_specialization_trait";
+  static constexpr auto &RUSTC_UNSAFE_SPECIALIZATION_MARKER
+= "rustc_unsafe_specialization_marker";
+  static constexpr auto &RUSTC_RESERVATION_IMPL = "rustc_reservation_impl";
+  static constexpr auto &RUSTC_PAREN_SUGAR = "rustc_paren_sugar";
+  static constexpr auto &RUSTC_NONNULL_OPTIMIZATION_GUARANTEED
+= "rustc_nonnull_optimization_guaranteed";
+
+  static constexpr auto &RUSTC_LAYOUT_SCALAR_VALID_RANGE_START
+= "rustc_layout_scalar_valid_range_start";
+
   static constexpr auto &MAY_DANGLE = "may_dangle";
   static constexpr auto &PRELUDE_IMPORT = "prelude_import";
   static constexpr auto &TRACK_CALLER = "track_caller";
+
+  static constexpr auto &RUSTC_DIAGNOSTIC_ITEM = "rustc_diagnostic_item";
+  static constexpr auto &RUSTC_ON_UNIMPLEMENTED = "rustc_on_unimplemented";
+
+  static constexpr auto &FUNDAMENTAL = "fundamental";
+
+  static constexpr auto &NON_EXHAUSTIVE = "non_exhaustive";
 };
 } // namespace Values
 } // namespace Rust
diff --git a/gcc/rust/util/rust-attributes.cc b/gcc/rust/util/rust-attributes.cc
index df0fe1b0bcac..7ddb476bbe6f 100644
--- a/gcc/rust/util/rust-attributes.cc
+++ b/gcc/rust/util/rust-attributes.cc
@@ -57,6 +57,7 @@ static const BuiltinAttrDefinition __definitions[]
  {Attrs::NO_MANGLE, CODE_GENERATION},
  {Attrs::REPR, CODE_GENERATION},
  {Attrs::RUSTC_BUILTIN_MACRO, EXPANSION},
+ {Attrs::RUSTC_MACRO_TRANSPARENCY, EXPANSION},
  {Attrs::PATH, EXPANSION},
  {Attrs::MACRO_USE, NAME_RESOLUTION},
  {Attrs::MACRO_EXPORT, NAME_RESOLUTION},
@@ -72,11 +73,28 @@ static const BuiltinAttrDefinition __definitions[]
  {Attrs::RUSTC_INHERIT_OVERFLOW_CHECKS, CODE_GENERATION},
  {Attrs::STABLE, STATIC_ANALYSIS},
  {Attrs::UNSTABLE, STATIC_ANALYSIS},
+
  // assuming we keep these for static analysis
+ {Attrs::RUSTC_PROMOTABLE, CODE_GENERATION},
  {Attrs::RUSTC_CONST_STABLE, STATIC_ANALYSIS},
  {Attrs::RUSTC_CONST_UNSTABLE, STATIC_ANALYSIS},
  {Attrs::PRELUDE_IMPORT, NAME_RESOLUTION},
- {Attrs::TRACK_CALLER, CODE_GENERATION}};
+ {Attrs::TRACK_CALLER, CODE_GENERATION},
+ {Attrs::RUSTC_SPECIALIZATION_TRAIT, TYPE_CHECK},
+ {Attrs::RUSTC_UNSAFE_SPECIALIZATION_MARKER, TYPE_CHECK},
+ {Attrs::RUSTC_RESERVATION_IMPL, TYPE_CHECK},
+ {Attrs::RUSTC_PAREN_SUGAR, TYPE_CHECK},
+ {Attrs::RUSTC_NONNULL_OPTIMIZATION_GUARANTEED, TYPE_CHECK},
+
+ {Attrs::RUSTC_LAYOUT_SCALAR_VALID_RANGE_START, CODE_GENERATION},
+
+ {Attrs::PRELUDE_IMPORT, NAME_RESOLUTION},
+
+ {Attrs::RUSTC_DIAGNOSTIC_ITEM, STATIC_ANALYSIS},
+ {Attrs::RUSTC_ON_UNIMPLEMENTED, STATIC_ANALYSIS},
+
+ {Attrs::FUNDAMENTAL, TYPE_CHECK},
+ {Attrs::NON_EXHAUSTIVE, TYPE_CHECK}};
 
 BuiltinAttributeMappings *
 BuiltinAttributeMappings::get ()
diff --

[gcc r15-9451] gccrs: nr2.0: Only insert derive macros if they exist

2025-04-14 Thread Arthur Cohen via Gcc-cvs
https://gcc.gnu.org/g:9ed95c06977068cce86b5d35aee905533c757d57

commit r15-9451-g9ed95c06977068cce86b5d35aee905533c757d57
Author: Arthur Cohen 
Date:   Wed Apr 9 14:48:55 2025 +0200

gccrs: nr2.0: Only insert derive macros if they exist

This causes an assertion failure when compiling core with nr2.0, but should
probably be improved. I'm not sure how this code enables built-in derive
macros to be resolved so this is a temporary fix.

gcc/rust/ChangeLog:

* resolve/rust-early-name-resolver-2.0.cc 
(Early::visit_attributes): Remove assertion.

Diff:
---
 gcc/rust/resolve/rust-early-name-resolver-2.0.cc | 7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/gcc/rust/resolve/rust-early-name-resolver-2.0.cc 
b/gcc/rust/resolve/rust-early-name-resolver-2.0.cc
index afaca1f71f03..36456e10ff26 100644
--- a/gcc/rust/resolve/rust-early-name-resolver-2.0.cc
+++ b/gcc/rust/resolve/rust-early-name-resolver-2.0.cc
@@ -325,10 +325,9 @@ Early::visit_attributes (std::vector 
&attrs)
  auto pm_def = mappings.lookup_derive_proc_macro_def (
definition->get_node_id ());
 
- rust_assert (pm_def.has_value ());
-
- mappings.insert_derive_proc_macro_invocation (trait,
-   pm_def.value ());
+ if (pm_def.has_value ())
+   mappings.insert_derive_proc_macro_invocation (trait,
+ pm_def.value ());
}
}
   else if (Analysis::BuiltinAttributeMappings::get ()


[gcc r15-9448] gccrs: install.texi: Mention Rust requirement for building gccrs

2025-04-14 Thread Arthur Cohen via Gcc-cvs
https://gcc.gnu.org/g:497ed6099b2c9f8f37b0acca5b7e2800ee1d9331

commit r15-9448-g497ed6099b2c9f8f37b0acca5b7e2800ee1d9331
Author: Arthur Cohen 
Date:   Tue Apr 1 13:00:56 2025 +0200

gccrs: install.texi: Mention Rust requirement for building gccrs

Addresses PR#117869

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117869

gcc/ChangeLog:

* doc/install.texi: Add requirements for building gccrs.

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

diff --git a/gcc/doc/install.texi b/gcc/doc/install.texi
index b5509ff0c86b..1af0082ed772 100644
--- a/gcc/doc/install.texi
+++ b/gcc/doc/install.texi
@@ -350,6 +350,12 @@ documentation including the target @code{SYSTEM} 
definition module.
 If Python3 is unavailable Modula-2 documentation will include a target
 independent version of the SYSTEM modules.
 
+@item @anchor{gccrs-prerequisite}gccrs
+
+The official Rust compiler and Rust build system (cargo) are required for
+building various parts of the gccrs frontend, until gccrs can compile them
+by itself. The minimum supported Rust version is 1.49.
+
 @item A ``working'' POSIX compatible shell, or GNU bash
 
 Necessary when running @command{configure} because some


[gcc r15-9453] gccrs: lang-items: Add ManuallyDrop

2025-04-14 Thread Arthur Cohen via Gcc-cvs
https://gcc.gnu.org/g:901d94e8b4eb9a273e9e75d5586cb5abde73a7a6

commit r15-9453-g901d94e8b4eb9a273e9e75d5586cb5abde73a7a6
Author: Arthur Cohen 
Date:   Tue Apr 8 17:04:09 2025 +0200

gccrs: lang-items: Add ManuallyDrop

gcc/rust/ChangeLog:

* util/rust-lang-item.h: Add new manually_drop lang item.
* util/rust-lang-item.cc: Likewise.

Diff:
---
 gcc/rust/util/rust-lang-item.cc | 1 +
 gcc/rust/util/rust-lang-item.h  | 2 ++
 2 files changed, 3 insertions(+)

diff --git a/gcc/rust/util/rust-lang-item.cc b/gcc/rust/util/rust-lang-item.cc
index a76cc7ff6519..9aff31b657c8 100644
--- a/gcc/rust/util/rust-lang-item.cc
+++ b/gcc/rust/util/rust-lang-item.cc
@@ -118,6 +118,7 @@ const BiMap 
Rust::LangItem::lang_items = {{
 
   {"discriminant_kind", Kind::DISCRIMINANT_KIND},
   {"discriminant_type", Kind::DISCRIMINANT_TYPE},
+  {"manually_drop", Kind::MANUALLY_DROP},
 }};
 
 tl::optional
diff --git a/gcc/rust/util/rust-lang-item.h b/gcc/rust/util/rust-lang-item.h
index 8f3af3615bb2..67a5d9c438f8 100644
--- a/gcc/rust/util/rust-lang-item.h
+++ b/gcc/rust/util/rust-lang-item.h
@@ -150,6 +150,8 @@ public:
 
 DISCRIMINANT_TYPE,
 DISCRIMINANT_KIND,
+
+MANUALLY_DROP,
   };
 
   static const BiMap lang_items;


[gcc r15-9457] cobol: Fix -fmax-errors option [PR119776]

2025-04-14 Thread Jakub Jelinek via Gcc-cvs
https://gcc.gnu.org/g:e0b57c75e6daa1664bea03ce96733bf1ebb38ced

commit r15-9457-ge0b57c75e6daa1664bea03ce96733bf1ebb38ced
Author: Jakub Jelinek 
Date:   Mon Apr 14 19:33:11 2025 +0200

cobol: Fix -fmax-errors option [PR119776]

There seems to be inconsistency in the -fmax-errors option
naming.  It is a generic option in common.opt (so applies
to all languages) but with the = character in it.
The gcobol.1 man page in one spot documents the generic
option (in the syntax, -fmax-errors=nerror) but in another
spot without the = character.

In common.opt it is
fmax-errors=
Common Joined RejectNegative UInteger Var(flag_max_errors)
-fmax-errors=   Maximum number of errors to report.

I hope the cobol addition is just a mistake, having -fmax-errors variant
without = character when Joined Separate would allow to specify
-fmax-errors 10 with the same meaning as -fmax-errors=10
but also -fmax-errors10 with the same meaning which is just weird.
Also, there is no UInteger and RejectNegative on it, so one can
also specific -fno-max-errors42 or -fmax-errors blah.

So, unless the spelling without = is intentional, here is a patch
to just remove it, the common option already should have arranged
for flag_max_errors to be set to the right number.

Or if it is intentional, I guess we'd need to at least add
RejectNegative UInteger (plus using atoi is generally undesirable
anywhere in the compiler because it does no error checking).
And the man page would need to be updated to specify both forms.

2025-04-14  Jakub Jelinek  

PR cobol/119776
* lang.opt (fmax-errors): Remove.
* lang.opt.urls: Regenerate.
* cobol1.cc (cobol_langhook_handle_option) :
Remove.
* gcobol.1: Document -fmax-errors=nerror rather than
-fmax-errors nerror.

Diff:
---
 gcc/cobol/cobol1.cc | 4 
 gcc/cobol/gcobol.1  | 2 +-
 gcc/cobol/lang.opt  | 4 
 gcc/cobol/lang.opt.urls | 3 ---
 4 files changed, 1 insertion(+), 12 deletions(-)

diff --git a/gcc/cobol/cobol1.cc b/gcc/cobol/cobol1.cc
index 7d742b907764..3bd21c783ded 100644
--- a/gcc/cobol/cobol1.cc
+++ b/gcc/cobol/cobol1.cc
@@ -385,10 +385,6 @@ cobol_langhook_handle_option (size_t scode,
 return true;
 }
 
-case OPT_fmax_errors:
-flag_max_errors = atoi(arg);
-return true;
-
 case OPT_ffixed_form:
 cobol_set_indicator_column(-7);
 return true;
diff --git a/gcc/cobol/gcobol.1 b/gcc/cobol/gcobol.1
index 64c017c22144..4377c1401efe 100644
--- a/gcc/cobol/gcobol.1
+++ b/gcc/cobol/gcobol.1
@@ -224,7 +224,7 @@ had appeared.
 Not all exception conditions are implemented.  Any that are not
 produce a warning message.
 .
-.It Fl fmax-errors Ar nerror
+.It Fl fmax-errors Ns Li = Ns Ar nerror
 .Ar nerror
 represents the number of error messages produced.  Without this option,
 .Nm
diff --git a/gcc/cobol/lang.opt b/gcc/cobol/lang.opt
index 1d33f34aceeb..59278a147e99 100644
--- a/gcc/cobol/lang.opt
+++ b/gcc/cobol/lang.opt
@@ -89,10 +89,6 @@ finternal-ebcdic
 Cobol Var(cobol_ebcdic, 1) Init(0)
 -finternal-ebcdic  Internal processing is in EBCDIC Code Page 1140
 
-fmax-errors
-Cobol Joined Separate
-; Documented in C
-
 fstatic-call
 Cobol Var(cobol_static_call, 1) Init(1)
 Enable/disable static linkage for CALL literals
diff --git a/gcc/cobol/lang.opt.urls b/gcc/cobol/lang.opt.urls
index 75df59643eab..69f52973c025 100644
--- a/gcc/cobol/lang.opt.urls
+++ b/gcc/cobol/lang.opt.urls
@@ -16,9 +16,6 @@ 
LangUrlSuffix_Fortran(gfortran/Fortran-Dialect-Options.html#index-ffixed-form)
 ffree-form
 LangUrlSuffix_Fortran(gfortran/Fortran-Dialect-Options.html#index-ffree-form)
 
-fmax-errors
-UrlSuffix(gcc/Warning-Options.html#index-fmax-errors) 
LangUrlSuffix_D(gdc/Warnings.html#index-fmax-errors)
-
 iprefix
 UrlSuffix(gcc/Directory-Options.html#index-iprefix) 
LangUrlSuffix_D(gdc/Directory-Options.html#index-iprefix) 
LangUrlSuffix_Fortran(gfortran/Preprocessing-Options.html#index-iprefix)


[gcc r15-9458] expmed: Always use QImode for init_expmed set_zero_cost [PR119785]

2025-04-14 Thread Jakub Jelinek via Gcc-cvs
https://gcc.gnu.org/g:f96a54350afcf7f3c90d0ecb51d7683d826acc00

commit r15-9458-gf96a54350afcf7f3c90d0ecb51d7683d826acc00
Author: Jakub Jelinek 
Date:   Mon Apr 14 19:34:22 2025 +0200

expmed: Always use QImode for init_expmed set_zero_cost [PR119785]

This is a regression on some targets introduced I believe by r6-2055
which added mode argument to set_src_cost.

The problem here is that in the first iteration, mode is always QImode
and we get as -Os zero cost set_src_cost (const0_rtx, QImode, false).
But then we use the mode variable for iterating over int, partial int
and vector int modes, so for the second iteration we call set_src_cost
with mode which is at that time (machine_mode) (MAX_MODE_VECTOR_INT + 1).

In the x86 case that happens to be V2HFmode and we don't crash (and
compute the same 0 cost as we would for QImode).
But e.g. in the SPARC case (machine_mode) (MAX_MODE_VECTOR_INT + 1) is
MAX_MACHINE_MODE and that does all kinds of weird things especially
when doing ubsan bootstrap.

Fixed by always using QImode.

2025-04-14  Jakub Jelinek  

PR rtl-optimization/119785
* expmed.cc (init_expmed): Always pass QImode rather than mode to
set_src_cost passed to set_zero_cost.

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

diff --git a/gcc/expmed.cc b/gcc/expmed.cc
index df09cbccd083..8cf10d9c73bf 100644
--- a/gcc/expmed.cc
+++ b/gcc/expmed.cc
@@ -285,7 +285,7 @@ init_expmed (void)
   for (speed = 0; speed < 2; speed++)
 {
   crtl->maybe_hot_insn_p = speed;
-  set_zero_cost (speed, set_src_cost (const0_rtx, mode, speed));
+  set_zero_cost (speed, set_src_cost (const0_rtx, QImode, speed));
 
   for (mode = MIN_MODE_INT; mode <= MAX_MODE_INT;
   mode = (machine_mode)(mode + 1))


[gcc r15-9455] cobol: Drop -fsyntax-only from COBOL lang.opt [PR119777]

2025-04-14 Thread Jakub Jelinek via Gcc-cvs
https://gcc.gnu.org/g:e96cb35ceb08bb6d12670172115f27819c806e82

commit r15-9455-ge96cb35ceb08bb6d12670172115f27819c806e82
Author: Jakub Jelinek 
Date:   Mon Apr 14 19:32:06 2025 +0200

cobol: Drop -fsyntax-only from COBOL lang.opt [PR119777]

The comment is incorrect, fsyntax-only is not documented in c.opt,
but in common.opt:
fsyntax-only
Common Var(flag_syntax_only)
Check for syntax errors, then stop.
and as such it applies to all languages, so adding CL_Cobol to
the CL_COMMON is both unnecessary and because of RejectNegative which
contradicts the generic option very harmful, because it makes
-fno-syntax-only invalid for all languages.

Fixed by just dropping it.

2025-04-14  Jakub Jelinek  

PR cobol/119777
* lang.opt (fsyntax-only): Remove.
* lang.opt.urls: Regenerate.

Diff:
---
 gcc/cobol/lang.opt  | 4 
 gcc/cobol/lang.opt.urls | 3 ---
 2 files changed, 7 deletions(-)

diff --git a/gcc/cobol/lang.opt b/gcc/cobol/lang.opt
index 42c402037b5c..142ec4f34bf2 100644
--- a/gcc/cobol/lang.opt
+++ b/gcc/cobol/lang.opt
@@ -77,10 +77,6 @@ ffixed-form
 Cobol RejectNegative
 Assume that the source file is fixed form.
 
-fsyntax-only
-Cobol RejectNegative
-; Documented in c.opt
-
 ffree-form
 Cobol RejectNegative
 Assume that the source file is free form.
diff --git a/gcc/cobol/lang.opt.urls b/gcc/cobol/lang.opt.urls
index 6a5dc1c0f580..75df59643eab 100644
--- a/gcc/cobol/lang.opt.urls
+++ b/gcc/cobol/lang.opt.urls
@@ -13,9 +13,6 @@ UrlSuffix(gcc/Directory-Options.html#index-I) 
LangUrlSuffix_D(gdc/Directory-Opti
 ffixed-form
 LangUrlSuffix_Fortran(gfortran/Fortran-Dialect-Options.html#index-ffixed-form)
 
-fsyntax-only
-UrlSuffix(gcc/Warning-Options.html#index-fsyntax-only) 
LangUrlSuffix_D(gdc/Warnings.html#index-fno-syntax-only) 
LangUrlSuffix_Fortran(gfortran/Error-and-Warning-Options.html#index-fsyntax-only)
-
 ffree-form
 LangUrlSuffix_Fortran(gfortran/Fortran-Dialect-Options.html#index-ffree-form)


[gcc r15-9454] pretty-print, expand: Print [must tail call] for CALL_EXPRs and fix up maybe_complain_about_tail_cal

2025-04-14 Thread Jakub Jelinek via Gcc-cvs
https://gcc.gnu.org/g:2e3c91786a981f2d68600e2d7b2e25a766e59c21

commit r15-9454-g2e3c91786a981f2d68600e2d7b2e25a766e59c21
Author: Jakub Jelinek 
Date:   Mon Apr 14 19:31:23 2025 +0200

pretty-print, expand: Print [must tail call] for CALL_EXPRs and fix up 
maybe_complain_about_tail_call [PR119718]

Andrew P. mentioned earlier he'd like to see in the dump files a note
whether it was a failed must tail call or not.
We already print that on the tailc/musttail pass side, because
print_gimple_stmt prints [must tail call] after the musttail calls.
The first hunk below does it for GENERIC CALL_EXPRs too (which is needed
for the expand diagnostics).  That isn't enough though, because the
error on it was done first and then CALL_EXPR_MUST_TAIL_CALL flag was
cleared, so the dump didn't have it anymore.  I've reordered the
dump printing with error, so that it works properly.

2025-04-14  Jakub Jelinek  

PR tree-optimization/119718
* tree-pretty-print.cc (dump_generic_node) : Dump
also CALL_EXPR_MUST_TAIL_CALL flag.
* calls.cc (maybe_complain_about_tail_call): Emit error about
CALL_EXPR_MUST_TAIL_CALL only after emitting dump message, not 
before
it.

Diff:
---
 gcc/calls.cc | 10 +-
 gcc/tree-pretty-print.cc |  2 ++
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/gcc/calls.cc b/gcc/calls.cc
index 372fab317f6f..076e046a8ef1 100644
--- a/gcc/calls.cc
+++ b/gcc/calls.cc
@@ -1273,11 +1273,6 @@ void
 maybe_complain_about_tail_call (tree call_expr, const char *reason)
 {
   gcc_assert (TREE_CODE (call_expr) == CALL_EXPR);
-  if (CALL_EXPR_MUST_TAIL_CALL (call_expr))
-{
-  error_at (EXPR_LOCATION (call_expr), "cannot tail-call: %s", reason);
-  CALL_EXPR_MUST_TAIL_CALL (call_expr) = 0;
-}
   if (CALL_EXPR_TAILCALL (call_expr)
   && dump_file
   && (dump_flags & TDF_DETAILS))
@@ -1286,6 +1281,11 @@ maybe_complain_about_tail_call (tree call_expr, const 
char *reason)
   print_generic_expr (dump_file, call_expr, TDF_SLIM);
   fprintf (dump_file, "\n");
 }
+  if (CALL_EXPR_MUST_TAIL_CALL (call_expr))
+{
+  error_at (EXPR_LOCATION (call_expr), "cannot tail-call: %s", reason);
+  CALL_EXPR_MUST_TAIL_CALL (call_expr) = 0;
+}
 }
 
 /* Fill in ARGS_SIZE and ARGS array based on the parameters found in
diff --git a/gcc/tree-pretty-print.cc b/gcc/tree-pretty-print.cc
index a2a4f5bfa2f1..c1a21e77bd29 100644
--- a/gcc/tree-pretty-print.cc
+++ b/gcc/tree-pretty-print.cc
@@ -3201,6 +3201,8 @@ dump_generic_node (pretty_printer *pp, tree node, int 
spc, dump_flags_t flags,
pp_string (pp, " [return slot optimization]");
   if (CALL_EXPR_TAILCALL (node))
pp_string (pp, " [tail call]");
+  if (CALL_EXPR_MUST_TAIL_CALL (node))
+   pp_string (pp, " [must tail call]");
   break;
 
 case WITH_CLEANUP_EXPR:


[gcc(refs/users/meissner/heads/work201)] Add ChangeLog.meissner and REVISION.

2025-04-14 Thread Michael Meissner via Gcc-cvs
https://gcc.gnu.org/g:b5abb63c30bd6dba56d6d7fedada5e9c4ef34e11

commit b5abb63c30bd6dba56d6d7fedada5e9c4ef34e11
Author: Michael Meissner 
Date:   Mon Apr 14 15:11:21 2025 -0400

Add ChangeLog.meissner and REVISION.

2025-04-14  Michael Meissner  

gcc/

* REVISION: New file for branch.
* ChangeLog.meissner: New file.

gcc/c-family/

* ChangeLog.meissner: New file.

gcc/c/

* ChangeLog.meissner: New file.

gcc/cp/

* ChangeLog.meissner: New file.

gcc/fortran/

* ChangeLog.meissner: New file.

gcc/testsuite/

* ChangeLog.meissner: New file.

libgcc/

* ChangeLog.meissner: New file.

Diff:
---
 gcc/ChangeLog.meissner   | 5 +
 gcc/REVISION | 1 +
 gcc/c-family/ChangeLog.meissner  | 5 +
 gcc/c/ChangeLog.meissner | 5 +
 gcc/cp/ChangeLog.meissner| 5 +
 gcc/fortran/ChangeLog.meissner   | 5 +
 gcc/testsuite/ChangeLog.meissner | 5 +
 libgcc/ChangeLog.meissner| 5 +
 libstdc++-v3/ChangeLog.meissner  | 5 +
 9 files changed, 41 insertions(+)

diff --git a/gcc/ChangeLog.meissner b/gcc/ChangeLog.meissner
new file mode 100644
index ..8fe7da956044
--- /dev/null
+++ b/gcc/ChangeLog.meissner
@@ -0,0 +1,5 @@
+ Branch work201, baseline 
+
+2025-04-14   Michael Meissner  
+
+   Clone branch
diff --git a/gcc/REVISION b/gcc/REVISION
new file mode 100644
index ..5f8715c4844d
--- /dev/null
+++ b/gcc/REVISION
@@ -0,0 +1 @@
+work201 branch
diff --git a/gcc/c-family/ChangeLog.meissner b/gcc/c-family/ChangeLog.meissner
new file mode 100644
index ..8fe7da956044
--- /dev/null
+++ b/gcc/c-family/ChangeLog.meissner
@@ -0,0 +1,5 @@
+ Branch work201, baseline 
+
+2025-04-14   Michael Meissner  
+
+   Clone branch
diff --git a/gcc/c/ChangeLog.meissner b/gcc/c/ChangeLog.meissner
new file mode 100644
index ..8fe7da956044
--- /dev/null
+++ b/gcc/c/ChangeLog.meissner
@@ -0,0 +1,5 @@
+ Branch work201, baseline 
+
+2025-04-14   Michael Meissner  
+
+   Clone branch
diff --git a/gcc/cp/ChangeLog.meissner b/gcc/cp/ChangeLog.meissner
new file mode 100644
index ..8fe7da956044
--- /dev/null
+++ b/gcc/cp/ChangeLog.meissner
@@ -0,0 +1,5 @@
+ Branch work201, baseline 
+
+2025-04-14   Michael Meissner  
+
+   Clone branch
diff --git a/gcc/fortran/ChangeLog.meissner b/gcc/fortran/ChangeLog.meissner
new file mode 100644
index ..8fe7da956044
--- /dev/null
+++ b/gcc/fortran/ChangeLog.meissner
@@ -0,0 +1,5 @@
+ Branch work201, baseline 
+
+2025-04-14   Michael Meissner  
+
+   Clone branch
diff --git a/gcc/testsuite/ChangeLog.meissner b/gcc/testsuite/ChangeLog.meissner
new file mode 100644
index ..8fe7da956044
--- /dev/null
+++ b/gcc/testsuite/ChangeLog.meissner
@@ -0,0 +1,5 @@
+ Branch work201, baseline 
+
+2025-04-14   Michael Meissner  
+
+   Clone branch
diff --git a/libgcc/ChangeLog.meissner b/libgcc/ChangeLog.meissner
new file mode 100644
index ..8fe7da956044
--- /dev/null
+++ b/libgcc/ChangeLog.meissner
@@ -0,0 +1,5 @@
+ Branch work201, baseline 
+
+2025-04-14   Michael Meissner  
+
+   Clone branch
diff --git a/libstdc++-v3/ChangeLog.meissner b/libstdc++-v3/ChangeLog.meissner
new file mode 100644
index ..8fe7da956044
--- /dev/null
+++ b/libstdc++-v3/ChangeLog.meissner
@@ -0,0 +1,5 @@
+ Branch work201, baseline 
+
+2025-04-14   Michael Meissner  
+
+   Clone branch


[gcc] Created branch 'meissner/heads/work201' in namespace 'refs/users'

2025-04-14 Thread Michael Meissner via Gcc-cvs
The branch 'meissner/heads/work201' was created in namespace 'refs/users' 
pointing to:

 ebdf92b6067a... testsuite: Fix up ipa/pr119530.c testcase [PR119318]


[gcc] Created branch 'meissner/heads/work201-dmf' in namespace 'refs/users'

2025-04-14 Thread Michael Meissner via Gcc-cvs
The branch 'meissner/heads/work201-dmf' was created in namespace 'refs/users' 
pointing to:

 b5abb63c30bd... Add ChangeLog.meissner and REVISION.


[gcc(refs/users/meissner/heads/work201-dmf)] Add ChangeLog.dmf and update REVISION.

2025-04-14 Thread Michael Meissner via Gcc-cvs
https://gcc.gnu.org/g:0d37093f29db1cc49d1fdbdec65563d2468082f6

commit 0d37093f29db1cc49d1fdbdec65563d2468082f6
Author: Michael Meissner 
Date:   Mon Apr 14 15:12:24 2025 -0400

Add ChangeLog.dmf and update REVISION.

2025-04-14  Michael Meissner  

gcc/

* ChangeLog.dmf: New file for branch.
* REVISION: Update.

Diff:
---
 gcc/ChangeLog.dmf | 5 +
 gcc/REVISION  | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/gcc/ChangeLog.dmf b/gcc/ChangeLog.dmf
new file mode 100644
index ..211e3edc44fc
--- /dev/null
+++ b/gcc/ChangeLog.dmf
@@ -0,0 +1,5 @@
+ Branch work201-dmf, baseline 
+
+2025-04-14   Michael Meissner  
+
+   Clone branch
diff --git a/gcc/REVISION b/gcc/REVISION
index 5f8715c4844d..c257804fb56a 100644
--- a/gcc/REVISION
+++ b/gcc/REVISION
@@ -1 +1 @@
-work201 branch
+work201-dmf branch


[gcc] Created branch 'meissner/heads/work201-bugs' in namespace 'refs/users'

2025-04-14 Thread Michael Meissner via Gcc-cvs
The branch 'meissner/heads/work201-bugs' was created in namespace 'refs/users' 
pointing to:

 b5abb63c30bd... Add ChangeLog.meissner and REVISION.


[gcc] Created branch 'meissner/heads/work201-vpair' in namespace 'refs/users'

2025-04-14 Thread Michael Meissner via Gcc-cvs
The branch 'meissner/heads/work201-vpair' was created in namespace 'refs/users' 
pointing to:

 b5abb63c30bd... Add ChangeLog.meissner and REVISION.


[gcc(refs/users/meissner/heads/work201-bugs)] Add ChangeLog.bugs and update REVISION.

2025-04-14 Thread Michael Meissner via Gcc-cvs
https://gcc.gnu.org/g:7e0a10be75e40e83e6f87b0ea493fdae5855a69a

commit 7e0a10be75e40e83e6f87b0ea493fdae5855a69a
Author: Michael Meissner 
Date:   Mon Apr 14 15:14:06 2025 -0400

Add ChangeLog.bugs and update REVISION.

2025-04-14  Michael Meissner  

gcc/

* ChangeLog.bugs: New file for branch.
* REVISION: Update.

Diff:
---
 gcc/ChangeLog.bugs | 5 +
 gcc/REVISION   | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/gcc/ChangeLog.bugs b/gcc/ChangeLog.bugs
new file mode 100644
index ..6f3c5d84f221
--- /dev/null
+++ b/gcc/ChangeLog.bugs
@@ -0,0 +1,5 @@
+ Branch work201-bugs, baseline 
+
+2025-04-14   Michael Meissner  
+
+   Clone branch
diff --git a/gcc/REVISION b/gcc/REVISION
index 5f8715c4844d..028186c1b5c7 100644
--- a/gcc/REVISION
+++ b/gcc/REVISION
@@ -1 +1 @@
-work201 branch
+work201-bugs branch


[gcc r14-11609] match: Reject non-ssa name/min invariants in gimple_extract [PR116412]

2025-04-14 Thread Andrew Pinski via Gcc-cvs
https://gcc.gnu.org/g:f6efcd3d4855e57646a9e3561404ad735d702c60

commit r14-11609-gf6efcd3d4855e57646a9e3561404ad735d702c60
Author: Andrew Pinski 
Date:   Mon Aug 19 08:06:36 2024 -0700

match: Reject non-ssa name/min invariants in gimple_extract [PR116412]

After the conversion for phiopt's conditional operand
to use maybe_push_res_to_seq, it was found that gimple_extract
will extract out from REALPART_EXPR/IMAGPART_EXPR/VCE and BIT_FIELD_REF,
a memory load. But that extraction was not needed as memory loads are not
simplified in match and simplify. So gimple_extract should return false
in those cases.

Changes since v1:
* Move the rejection to gimple_extract from 
factor_out_conditional_operation.

Bootstrapped and tested on x86_64-linux-gnu.

PR tree-optimization/116412

gcc/ChangeLog:

* gimple-match-exports.cc (gimple_extract): Return false if op0
was not a SSA name nor a min invariant for 
REALPART_EXPR/IMAGPART_EXPR/VCE
and BIT_FIELD_REF.

gcc/testsuite/ChangeLog:

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

Signed-off-by: Andrew Pinski 
(cherry picked from commit c7b76a076cb2c6ded7ae208464019b04cb0531a2)

Diff:
---
 gcc/gimple-match-exports.cc   | 6 ++
 gcc/testsuite/gcc.dg/torture/pr116412-1.c | 6 ++
 2 files changed, 12 insertions(+)

diff --git a/gcc/gimple-match-exports.cc b/gcc/gimple-match-exports.cc
index 1fe6c0e38833..d81f8bc40d62 100644
--- a/gcc/gimple-match-exports.cc
+++ b/gcc/gimple-match-exports.cc
@@ -732,6 +732,9 @@ gimple_extract (gimple *stmt, gimple_match_op *res_op,
|| code == VIEW_CONVERT_EXPR)
  {
tree op0 = TREE_OPERAND (gimple_assign_rhs1 (stmt), 0);
+   /* op0 needs to be a SSA name or an min invariant. */
+   if (TREE_CODE (op0) != SSA_NAME && !is_gimple_min_invariant 
(op0))
+ return false;
res_op->set_op (code, type, valueize_op (op0));
return true;
  }
@@ -739,6 +742,9 @@ gimple_extract (gimple *stmt, gimple_match_op *res_op,
  {
tree rhs1 = gimple_assign_rhs1 (stmt);
tree op0 = valueize_op (TREE_OPERAND (rhs1, 0));
+   /* op0 needs to be a SSA name or an min invariant. */
+   if (TREE_CODE (op0) != SSA_NAME && !is_gimple_min_invariant 
(op0))
+ return false;
res_op->set_op (code, type, op0,
TREE_OPERAND (rhs1, 1),
TREE_OPERAND (rhs1, 2),
diff --git a/gcc/testsuite/gcc.dg/torture/pr116412-1.c 
b/gcc/testsuite/gcc.dg/torture/pr116412-1.c
new file mode 100644
index ..3bc26ecd8b83
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr116412-1.c
@@ -0,0 +1,6 @@
+/* { dg-do compile } */
+double f(_Complex double a, _Complex double *b, int c)
+{
+  if (c) return __real__ a;
+  return __real__ *b;
+}


[gcc(refs/users/meissner/heads/work201-test)] Add ChangeLog.test and update REVISION.

2025-04-14 Thread Michael Meissner via Gcc-cvs
https://gcc.gnu.org/g:bf8ac60a11f33c94f981c6ad2d828eef5755700a

commit bf8ac60a11f33c94f981c6ad2d828eef5755700a
Author: Michael Meissner 
Date:   Mon Apr 14 15:17:00 2025 -0400

Add ChangeLog.test and update REVISION.

2025-04-14  Michael Meissner  

gcc/

* ChangeLog.test: New file for branch.
* REVISION: Update.

Diff:
---
 gcc/ChangeLog.test | 5 +
 gcc/REVISION   | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/gcc/ChangeLog.test b/gcc/ChangeLog.test
new file mode 100644
index ..b7353453a268
--- /dev/null
+++ b/gcc/ChangeLog.test
@@ -0,0 +1,5 @@
+ Branch work201-test, baseline 
+
+2025-04-14   Michael Meissner  
+
+   Clone branch
diff --git a/gcc/REVISION b/gcc/REVISION
index 5f8715c4844d..a43f066a082a 100644
--- a/gcc/REVISION
+++ b/gcc/REVISION
@@ -1 +1 @@
-work201 branch
+work201-test branch


[gcc(refs/users/meissner/heads/work201-vpair)] Add ChangeLog.vpair and update REVISION.

2025-04-14 Thread Michael Meissner via Gcc-cvs
https://gcc.gnu.org/g:7804b9c15da58030675556042158a34dc77f15ff

commit 7804b9c15da58030675556042158a34dc77f15ff
Author: Michael Meissner 
Date:   Mon Apr 14 15:13:15 2025 -0400

Add ChangeLog.vpair and update REVISION.

2025-04-14  Michael Meissner  

gcc/

* ChangeLog.vpair: New file for branch.
* REVISION: Update.

Diff:
---
 gcc/ChangeLog.vpair | 5 +
 gcc/REVISION| 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/gcc/ChangeLog.vpair b/gcc/ChangeLog.vpair
new file mode 100644
index ..07257f300349
--- /dev/null
+++ b/gcc/ChangeLog.vpair
@@ -0,0 +1,5 @@
+ Branch work201-vpair, baseline 
+
+2025-04-14   Michael Meissner  
+
+   Clone branch
diff --git a/gcc/REVISION b/gcc/REVISION
index 5f8715c4844d..260696cdbbdd 100644
--- a/gcc/REVISION
+++ b/gcc/REVISION
@@ -1 +1 @@
-work201 branch
+work201-vpair branch


[gcc r15-9429] ipa-cp: Use the stored and streamed pass-through types in ipa-vr (PR118785)

2025-04-14 Thread Martin Jambor via Gcc-cvs
https://gcc.gnu.org/g:4f19487f2606d25516d31f0279101deea9772da4

commit r15-9429-g4f19487f2606d25516d31f0279101deea9772da4
Author: Martin Jambor 
Date:   Mon Apr 14 14:21:15 2025 +0200

ipa-cp: Use the stored and streamed pass-through types in ipa-vr (PR118785)

This patch revisits the fix for PR 118785 and intead of deducing the
necessary operation type it just uses the value collected and streamed
by an earlier patch.  The main advantage is that we do not rely on
expr_type_first_operand_type_p enumarating all operations.

gcc/ChangeLog:

2025-03-20  Martin Jambor  

PR ipa/118785
* ipa-cp.cc (ipa_vr_intersect_with_arith_jfunc): Use the stored
and streamed type of arithmetic pass-through functions.

Diff:
---
 gcc/ipa-cp.cc | 28 ++--
 1 file changed, 2 insertions(+), 26 deletions(-)

diff --git a/gcc/ipa-cp.cc b/gcc/ipa-cp.cc
index 637bc49f0482..21033c666bf4 100644
--- a/gcc/ipa-cp.cc
+++ b/gcc/ipa-cp.cc
@@ -1735,24 +1735,7 @@ ipa_vr_intersect_with_arith_jfunc (vrange &vr,
   const value_range *inter_vr;
   if (operation != NOP_EXPR)
{
- /* Since we construct arithmetic jump functions even when there is a
- type conversion in between the operation encoded in the jump
- function and when it is passed in a call argument, the IPA
- propagation phase must also perform the operation and conversion
- in two separate steps.
-
-TODO: In order to remove the use of expr_type_first_operand_type_p
-predicate we would need to stream the operation type, ideally
-encoding the whole jump function as a series of expr_eval_op
-structures.  */
-
- tree operation_type;
- if (expr_type_first_operand_type_p (operation))
-   operation_type = src_type;
- else if (operation == ABSU_EXPR)
-   operation_type = unsigned_type_for (src_type);
- else
-   return;
+ tree operation_type = ipa_get_jf_pass_through_op_type (jfunc);
  op_res.set_varying (operation_type);
  if (!ipa_vr_operation_and_type_effects (op_res, src_vr, operation,
  operation_type, src_type))
@@ -1782,14 +1765,7 @@ ipa_vr_intersect_with_arith_jfunc (vrange &vr,
   value_range op_vr (TREE_TYPE (operand));
   ipa_get_range_from_ip_invariant (op_vr, operand, context_node);
 
-  tree operation_type;
-  if (TREE_CODE_CLASS (operation) == tcc_comparison)
-operation_type = boolean_type_node;
-  else if (expr_type_first_operand_type_p (operation))
-operation_type = src_type;
-  else
-return;
-
+  tree operation_type = ipa_get_jf_pass_through_op_type (jfunc);
   value_range op_res (operation_type);
   if (!ipa_vr_supported_type_p (operation_type)
   || !handler.operand_check_p (operation_type, src_type, op_vr.type ())


[gcc r15-9431] APX: Don't use red-zone with 32 GPRs and no caller-saved registers

2025-04-14 Thread H.J. Lu via Gcc-cvs
https://gcc.gnu.org/g:0a074b8c7e79f9d9359d044f1499b0a9ce9d2801

commit r15-9431-g0a074b8c7e79f9d9359d044f1499b0a9ce9d2801
Author: H.J. Lu 
Date:   Sun Apr 13 12:20:42 2025 -0700

APX: Don't use red-zone with 32 GPRs and no caller-saved registers

Don't use red-zone when there are no caller-saved registers with 32 GPRs
since 128-byte red-zone is too small for 31 GPRs.

gcc/

PR target/119784
* config/i386/i386.cc (ix86_using_red_zone): Don't use red-zone
with 32 GPRs and no caller-saved registers.

gcc/testsuite/

PR target/119784
* gcc.target/i386/pr119784a.c: New test.
* gcc.target/i386/pr119784b.c: Likewise.

Signed-off-by: H.J. Lu 

Diff:
---
 gcc/config/i386/i386.cc   |  6 ++
 gcc/testsuite/gcc.target/i386/pr119784a.c | 96 +++
 gcc/testsuite/gcc.target/i386/pr119784b.c | 87 
 3 files changed, 189 insertions(+)

diff --git a/gcc/config/i386/i386.cc b/gcc/config/i386/i386.cc
index 4f8380c4a58b..b172f716c683 100644
--- a/gcc/config/i386/i386.cc
+++ b/gcc/config/i386/i386.cc
@@ -458,6 +458,9 @@ int ix86_arch_specified;
indirect thunk pushes the return address onto stack, destroying
red-zone.
 
+   NB: Don't use red-zone for functions with no_caller_saved_registers
+   and 32 GPRs since 128-byte red-zone is too small for 31 GPRs.
+
TODO: If we can reserve the first 2 WORDs, for PUSH and, another
for CALL, in red-zone, we can allow local indirect jumps with
indirect thunk.  */
@@ -467,6 +470,9 @@ ix86_using_red_zone (void)
 {
   return (TARGET_RED_ZONE
  && !TARGET_64BIT_MS_ABI
+ && (!TARGET_APX_EGPR
+ || (cfun->machine->call_saved_registers
+ != TYPE_NO_CALLER_SAVED_REGISTERS))
  && (!cfun->machine->has_local_indirect_jump
  || cfun->machine->indirect_branch_type == indirect_branch_keep));
 }
diff --git a/gcc/testsuite/gcc.target/i386/pr119784a.c 
b/gcc/testsuite/gcc.target/i386/pr119784a.c
new file mode 100644
index ..8a119d4cc1f8
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/pr119784a.c
@@ -0,0 +1,96 @@
+/* { dg-do compile { target { *-*-linux* && lp64 } } } */
+/* { dg-options "-O2 -fno-pic -mtune=generic -mgeneral-regs-only -mapxf 
-mtune-ctrl=prologue_using_move,epilogue_using_move" } */
+/* Keep labels and directives ('.cfi_startproc', '.cfi_endproc').  */
+/* { dg-final { check-function-bodies "**" "" "" { target "*-*-*" } {^\t?\.}  
} } */
+
+/* start must save and restore all caller saved registers.  */
+
+/*
+**start:
+**.LFB[0-9]+:
+** .cfi_startproc
+** subq\$248, %rsp
+**...
+** movq%rax, \(%rsp\)
+** movq%rdx, 8\(%rsp\)
+** movq%rcx, 16\(%rsp\)
+** movq%rbx, 24\(%rsp\)
+** movq%rsi, 32\(%rsp\)
+** movq%rdi, 40\(%rsp\)
+**...
+** movq%rbp, 48\(%rsp\)
+** movq%r8, 56\(%rsp\)
+** movq%r9, 64\(%rsp\)
+** movq%r10, 72\(%rsp\)
+** movq%r11, 80\(%rsp\)
+** movq%r12, 88\(%rsp\)
+** movq%r13, 96\(%rsp\)
+** movq%r14, 104\(%rsp\)
+** movq%r15, 112\(%rsp\)
+** movq%r16, 120\(%rsp\)
+** movq%r17, 128\(%rsp\)
+** movq%r18, 136\(%rsp\)
+** movq%r19, 144\(%rsp\)
+** movq%r20, 152\(%rsp\)
+** movq%r21, 160\(%rsp\)
+** movq%r22, 168\(%rsp\)
+** movq%r23, 176\(%rsp\)
+** movq%r24, 184\(%rsp\)
+** movq%r25, 192\(%rsp\)
+** movq%r26, 200\(%rsp\)
+** movq%r27, 208\(%rsp\)
+** movq%r28, 216\(%rsp\)
+** movq%r29, 224\(%rsp\)
+** movq%r30, 232\(%rsp\)
+** movq%r31, 240\(%rsp\)
+**...
+** call\*code\(%rip\)
+** movq\(%rsp\), %rax
+** movq8\(%rsp\), %rdx
+** movq16\(%rsp\), %rcx
+** movq24\(%rsp\), %rbx
+** movq32\(%rsp\), %rsi
+** movq40\(%rsp\), %rdi
+** movq48\(%rsp\), %rbp
+** movq56\(%rsp\), %r8
+** movq64\(%rsp\), %r9
+** movq72\(%rsp\), %r10
+** movq80\(%rsp\), %r11
+** movq88\(%rsp\), %r12
+** movq96\(%rsp\), %r13
+** movq104\(%rsp\), %r14
+** movq112\(%rsp\), %r15
+** movq120\(%rsp\), %r16
+** movq128\(%rsp\), %r17
+** movq136\(%rsp\), %r18
+** movq144\(%rsp\), %r19
+** movq152\(%rsp\), %r20
+** movq160\(%rsp\), %r21
+** movq168\(%rsp\), %r22
+** movq176\(%rsp\), %r23
+** movq184\(%rsp\), %r24
+** movq192\(%rsp\), %r25
+** movq200\(%rsp\), %r26
+** movq208\(%rsp\), %r27
+** movq216\(%rsp\), %r28
+** movq224\(%rsp\), %r29
+** movq232\(%rsp\), %r30
+** movq240\(%rsp\), %r31
+** addq\$248, %rsp
+**...
+** ret
+** .cfi_endproc
+**...
+*/
+
+#define DONT_SAVE_REGS __attribute__((no_callee_saved_registers))

[gcc r15-9432] libgcobol: Add missing float128 suffix

2025-04-14 Thread Andreas Schwab via Gcc-cvs
https://gcc.gnu.org/g:6518799b2dfe8cf6dd7afa96041c5842bb4b9a49

commit r15-9432-g6518799b2dfe8cf6dd7afa96041c5842bb4b9a49
Author: Andreas Schwab 
Date:   Mon Apr 14 14:20:08 2025 +0200

libgcobol: Add missing float128 suffix

* libgcobol.cc (__gg__float64_from_128): Mark literal as float128
literal.

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

diff --git a/libgcobol/libgcobol.cc b/libgcobol/libgcobol.cc
index 1d4cdf849cbf..07d4e8ba9fc8 100644
--- a/libgcobol/libgcobol.cc
+++ b/libgcobol/libgcobol.cc
@@ -11708,7 +11708,7 @@ __gg__float64_from_128( cblc_field_t *dest,
   // _Float128 value = *(_Float128*)(source->data+source_offset);
   GCOB_FP128 value;
   memcpy(&value, source->data+source_offset, 16);
-  if( FP128_FUNC(fabs)(value) > 1.7976931348623157E308 )
+  if( FP128_FUNC(fabs)(value) > GCOB_FP128_LITERAL(1.7976931348623157E308) )
 {
 retval = 1;
 }


[gcc r15-9437] rust: use range for inside rust-gcc.cc [PR119341]

2025-04-14 Thread Arthur Cohen via Gcc-cvs
https://gcc.gnu.org/g:ec2edeffedeaaeceecf8c85fded9fd2ee3c1aa52

commit r15-9437-gec2edeffedeaaeceecf8c85fded9fd2ee3c1aa52
Author: Andrew Pinski 
Date:   Wed Mar 19 17:30:01 2025 -0700

rust: use range for inside rust-gcc.cc [PR119341]

There are some places inside rust-gcc.cc which are candidates
to use range for instead of iterators directly. This changes
the locations I saw and makes the code slightly more readable.

gcc/rust/ChangeLog:

PR rust/119341
* rust-gcc.cc (function_type): Use range fors.
(function_type_variadic): Likewise.
(fill_in_fields): Likewise.
(statement_list): Likewise.
(block): Likewise.
(block_add_statements): Likewise.
(function_set_parameters): Likewise.
(write_global_definitions): Likewise.

Signed-off-by: Andrew Pinski 

Diff:
---
 gcc/rust/rust-gcc.cc | 57 +++-
 1 file changed, 21 insertions(+), 36 deletions(-)

diff --git a/gcc/rust/rust-gcc.cc b/gcc/rust/rust-gcc.cc
index 13b7cea6a3fc..bd1f13920bfe 100644
--- a/gcc/rust/rust-gcc.cc
+++ b/gcc/rust/rust-gcc.cc
@@ -478,10 +478,9 @@ function_type (const typed_identifier &receiver,
   pp = &TREE_CHAIN (*pp);
 }
 
-  for (std::vector::const_iterator p = parameters.begin ();
-   p != parameters.end (); ++p)
+  for (const auto &p : parameters)
 {
-  tree t = p->type;
+  tree t = p.type;
   if (error_operand_p (t))
return error_mark_node;
   *pp = tree_cons (NULL_TREE, t, NULL_TREE);
@@ -527,10 +526,9 @@ function_type_variadic (const typed_identifier &receiver,
   if (receiver.type != NULL_TREE)
 args[offs++] = receiver.type;
 
-  for (std::vector::const_iterator p = parameters.begin ();
-   p != parameters.end (); ++p)
+  for (const auto &p : parameters)
 {
-  tree t = p->type;
+  tree t = p.type;
   if (error_operand_p (t))
return error_mark_node;
   args[offs++] = t;
@@ -609,14 +607,13 @@ fill_in_fields (tree fill, const 
std::vector &fields,
 {
   tree field_trees = NULL_TREE;
   tree *pp = &field_trees;
-  for (std::vector::const_iterator p = fields.begin ();
-   p != fields.end (); ++p)
+  for (const auto &p : fields)
 {
-  tree name_tree = get_identifier_from_string (p->name);
-  tree type_tree = p->type;
+  tree name_tree = get_identifier_from_string (p.name);
+  tree type_tree = p.type;
   if (error_operand_p (type_tree))
return error_mark_node;
-  tree field = build_decl (p->location, FIELD_DECL, name_tree, type_tree);
+  tree field = build_decl (p.location, FIELD_DECL, name_tree, type_tree);
   DECL_CONTEXT (field) = fill;
   *pp = field;
   pp = &DECL_CHAIN (field);
@@ -1741,10 +1738,8 @@ tree
 statement_list (const std::vector &statements)
 {
   tree stmt_list = NULL_TREE;
-  for (std::vector::const_iterator p = statements.begin ();
-   p != statements.end (); ++p)
+  for (tree t : statements)
 {
-  tree t = (*p);
   if (error_operand_p (t))
return error_mark_node;
   append_to_statement_list (t, &stmt_list);
@@ -1798,10 +1793,9 @@ block (tree fndecl, tree enclosing, const 
std::vector &vars,
 }
 
   tree *pp = &BLOCK_VARS (block_tree);
-  for (std::vector::const_iterator pv = vars.begin ();
-   pv != vars.end (); ++pv)
+  for (Bvariable *bv : vars)
 {
-  *pp = (*pv)->get_decl ();
+  *pp = bv->get_decl ();
   if (!error_operand_p (*pp))
pp = &DECL_CHAIN (*pp);
 }
@@ -1821,10 +1815,8 @@ void
 block_add_statements (tree bind_tree, const std::vector &statements)
 {
   tree stmt_list = NULL_TREE;
-  for (std::vector::const_iterator p = statements.begin ();
-   p != statements.end (); ++p)
+  for (tree s : statements)
 {
-  tree s = (*p);
   if (!error_operand_p (s))
append_to_statement_list (s, &stmt_list);
 }
@@ -2268,10 +2260,9 @@ function_set_parameters (tree function,
 
   tree params = NULL_TREE;
   tree *pp = ¶ms;
-  for (std::vector::const_iterator pv = param_vars.begin ();
-   pv != param_vars.end (); ++pv)
+  for (Bvariable *bv : param_vars)
 {
-  *pp = (*pv)->get_decl ();
+  *pp = bv->get_decl ();
   gcc_assert (!error_operand_p (*pp));
   pp = &DECL_CHAIN (*pp);
 }
@@ -2297,10 +2288,9 @@ write_global_definitions (const std::vector 
&type_decls,
 
   // Convert all non-erroneous declarations into Gimple form.
   size_t i = 0;
-  for (std::vector::const_iterator p = variable_decls.begin ();
-   p != variable_decls.end (); ++p)
+  for (Bvariable *bv : variable_decls)
 {
-  tree v = (*p)->get_decl ();
+  tree v = bv->get_decl ();
   if (error_operand_p (v))
continue;
   defs[i] = v;
@@ -2308,10 +2298,8 @@ write_global_definitions (const std::vector 
&type_decls,
   ++i;
 }
 
-  for (std::vector::const_iterator p = type_decls.begin ();
- 

[gcc r15-9442] gccrs: ast: Add get_locus() to DelimTokenTree

2025-04-14 Thread Arthur Cohen via Gcc-cvs
https://gcc.gnu.org/g:4aa6cae27bd1ca3513dcb512158ed27a4afe800d

commit r15-9442-g4aa6cae27bd1ca3513dcb512158ed27a4afe800d
Author: Arthur Cohen 
Date:   Wed Apr 9 14:44:11 2025 +0200

gccrs: ast: Add get_locus() to DelimTokenTree

gcc/rust/ChangeLog:

* ast/rust-ast.h (DelimTokenTree::get_locus): New function.

Diff:
---
 gcc/rust/ast/rust-ast.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/gcc/rust/ast/rust-ast.h b/gcc/rust/ast/rust-ast.h
index 09e0fce4f190..91611ec6a622 100644
--- a/gcc/rust/ast/rust-ast.h
+++ b/gcc/rust/ast/rust-ast.h
@@ -1018,6 +1018,7 @@ public:
   }
 
   DelimType get_delim_type () const { return delim_type; }
+  location_t get_locus () const { return locus; }
 };
 
 /* Forward decl - definition moved to rust-expr.h as it requires LiteralExpr


[gcc r15-9441] gccrs: ast: Support outer attributes for AST::RangeExpr

2025-04-14 Thread Arthur Cohen via Gcc-cvs
https://gcc.gnu.org/g:09c4a7a58b4dd6a95b72224d83c715308da9838a

commit r15-9441-g09c4a7a58b4dd6a95b72224d83c715308da9838a
Author: Arthur Cohen 
Date:   Wed Apr 9 14:44:56 2025 +0200

gccrs: ast: Support outer attributes for AST::RangeExpr

gcc/rust/ChangeLog:

* ast/rust-expr.h (class RangeExpr): Add empty outer attributes and 
allow getting them
and setting them.

Diff:
---
 gcc/rust/ast/rust-expr.h | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/gcc/rust/ast/rust-expr.h b/gcc/rust/ast/rust-expr.h
index 84cdfdb46780..69538df63e5c 100644
--- a/gcc/rust/ast/rust-expr.h
+++ b/gcc/rust/ast/rust-expr.h
@@ -3004,6 +3004,10 @@ class RangeExpr : public ExprWithoutBlock
 {
   location_t locus;
 
+  // Some visitors still check for attributes on RangeExprs, and they will need
+  // to be supported in the future - so keep that for now
+  std::vector empty_attributes = {};
+
 protected:
   // outer attributes not allowed before range expressions
   RangeExpr (location_t locus) : locus (locus) {}
@@ -3013,15 +3017,11 @@ public:
 
   std::vector &get_outer_attrs () override final
   {
-// RangeExpr cannot have any outer attributes
-rust_assert (false);
+return empty_attributes;
   }
 
   // should never be called - error if called
-  void set_outer_attrs (std::vector /* new_attrs */) override
-  {
-rust_assert (false);
-  }
+  void set_outer_attrs (std::vector /* new_attrs */) override {}
 
   Expr::Kind get_expr_kind () const override { return Expr::Kind::Range; }
 };


[gcc r15-9443] gccrs: session: Desugar question mark operator after expansion instead.

2025-04-14 Thread Arthur Cohen via Gcc-cvs
https://gcc.gnu.org/g:76477f965552b5872bb14255f272bff78978ef0c

commit r15-9443-g76477f965552b5872bb14255f272bff78978ef0c
Author: Arthur Cohen 
Date:   Fri Apr 4 14:21:00 2025 +0200

gccrs: session: Desugar question mark operator after expansion instead.

gcc/rust/ChangeLog:

* rust-session-manager.cc (Session::compile_crate): Call the 
visitor later in the pipeline.

Diff:
---
 gcc/rust/rust-session-manager.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/rust/rust-session-manager.cc b/gcc/rust/rust-session-manager.cc
index 15f21ef12a96..48acbf34 100644
--- a/gcc/rust/rust-session-manager.cc
+++ b/gcc/rust/rust-session-manager.cc
@@ -611,7 +611,6 @@ Session::compile_crate (const char *filename)
 return;
 
   AST::CollectLangItems ().go (parsed_crate);
-  AST::DesugarQuestionMark ().go (parsed_crate);
 
   auto name_resolution_ctx = Resolver2_0::NameResolutionContext ();
   // expansion pipeline stage
@@ -619,6 +618,7 @@ Session::compile_crate (const char *filename)
   expansion (parsed_crate, name_resolution_ctx);
 
   AST::DesugarForLoops ().go (parsed_crate);
+  AST::DesugarQuestionMark ().go (parsed_crate);
 
   rust_debug ("\033[0;31mSUCCESSFULLY FINISHED EXPANSION \033[0m");
   if (options.dump_option_enabled (CompileOptions::EXPANSION_DUMP))


[gcc r15-9438] rust: Add comment inside block [PR119342]

2025-04-14 Thread Arthur Cohen via Gcc-cvs
https://gcc.gnu.org/g:9e367223ce5c42e0598ef52637af34f74e14acc1

commit r15-9438-g9e367223ce5c42e0598ef52637af34f74e14acc1
Author: Andrew Pinski 
Date:   Wed Mar 19 17:30:02 2025 -0700

rust: Add comment inside block [PR119342]

Inside a BLOCK node, all of the variables of the scope/block
are chained together and that connects them to the block.
This just adds a comment to that effect as reading the code
it is not so obvious why they need to be chained together.

gcc/rust/ChangeLog:

PR rust/119342
* rust-gcc.cc (block): Add comment on why chaining
the variables of the scope toether.

Signed-off-by: Andrew Pinski 

Diff:
---
 gcc/rust/rust-gcc.cc | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/gcc/rust/rust-gcc.cc b/gcc/rust/rust-gcc.cc
index bd1f13920bfe..234721c585fd 100644
--- a/gcc/rust/rust-gcc.cc
+++ b/gcc/rust/rust-gcc.cc
@@ -1792,6 +1792,8 @@ block (tree fndecl, tree enclosing, const 
std::vector &vars,
   *pp = block_tree;
 }
 
+  // Chain the variables of the scope together so they are all connected
+  // to the block.
   tree *pp = &BLOCK_VARS (block_tree);
   for (Bvariable *bv : vars)
 {


[gcc r15-9445] gccrs: expansion: Desugar doc comments into attributes before expansion

2025-04-14 Thread Arthur Cohen via Gcc-cvs
https://gcc.gnu.org/g:9710cf3e3419954fb543224faa9efd3c8d97a800

commit r15-9445-g9710cf3e3419954fb543224faa9efd3c8d97a800
Author: Arthur Cohen 
Date:   Tue Apr 8 16:20:18 2025 +0200

gccrs: expansion: Desugar doc comments into attributes before expansion

gcc/rust/ChangeLog:

* expand/rust-macro-expand.cc (MacroExpander::expand_decl_macro): 
Call into
TokenTreeDesugar.
* expand/rust-token-tree-desugar.cc: New file.
* expand/rust-token-tree-desugar.h: New file.
* Make-lang.in: Compile them.

gcc/testsuite/ChangeLog:

* rust/compile/macros/mbe/macro-issue3709-1.rs: New test.
* rust/compile/macros/mbe/macro-issue3709-2.rs: New test.

Diff:
---
 gcc/rust/Make-lang.in  |  1 +
 gcc/rust/expand/rust-macro-expand.cc   |  6 +-
 gcc/rust/expand/rust-token-tree-desugar.cc | 72 +++
 gcc/rust/expand/rust-token-tree-desugar.h  | 55 +++
 .../rust/compile/macros/mbe/macro-issue3693.rs | 10 +++
 .../rust/compile/macros/mbe/macro-issue3709-1.rs   | 10 +++
 .../rust/compile/macros/mbe/macro-issue3709-2.rs   | 81 ++
 7 files changed, 234 insertions(+), 1 deletion(-)

diff --git a/gcc/rust/Make-lang.in b/gcc/rust/Make-lang.in
index 4028b47fa87f..835e113aee2c 100644
--- a/gcc/rust/Make-lang.in
+++ b/gcc/rust/Make-lang.in
@@ -115,6 +115,7 @@ GRS_OBJS = \
 rust/rust-macro-builtins-format-args.o \
 rust/rust-macro-builtins-location.o \
 rust/rust-macro-builtins-include.o \
+rust/rust-token-tree-desugar.o \
rust/rust-fmt.o \
 rust/rust-hir.o \
 rust/rust-hir-map.o \
diff --git a/gcc/rust/expand/rust-macro-expand.cc 
b/gcc/rust/expand/rust-macro-expand.cc
index 6e62a083ae7a..673b8fb20fa3 100644
--- a/gcc/rust/expand/rust-macro-expand.cc
+++ b/gcc/rust/expand/rust-macro-expand.cc
@@ -28,6 +28,7 @@
 #include "rust-cfg-strip.h"
 #include "rust-early-name-resolver.h"
 #include "rust-proc-macro.h"
+#include "rust-token-tree-desugar.h"
 
 namespace Rust {
 
@@ -78,7 +79,10 @@ MacroExpander::expand_decl_macro (location_t invoc_locus,
* trees.
*/
 
-  AST::DelimTokenTree &invoc_token_tree = invoc.get_delim_tok_tree ();
+  AST::DelimTokenTree &invoc_token_tree_sugar = invoc.get_delim_tok_tree ();
+
+  // We must first desugar doc comments into proper attributes
+  auto invoc_token_tree = AST::TokenTreeDesugar ().go (invoc_token_tree_sugar);
 
   // find matching arm
   AST::MacroRule *matched_rule = nullptr;
diff --git a/gcc/rust/expand/rust-token-tree-desugar.cc 
b/gcc/rust/expand/rust-token-tree-desugar.cc
new file mode 100644
index ..3b471805924a
--- /dev/null
+++ b/gcc/rust/expand/rust-token-tree-desugar.cc
@@ -0,0 +1,72 @@
+// Copyright (C) 2025 Free Software Foundation, Inc.
+
+// This file is part of GCC.
+
+// GCC is free software; you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 3, or (at your option) any later
+// version.
+
+// GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+// WARRANTY; without even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+// for more details.
+
+// You should have received a copy of the GNU General Public License
+// along with GCC; see the file COPYING3.  If not see
+// .
+
+#include "rust-token-tree-desugar.h"
+#include "rust-ast.h"
+#include "rust-token.h"
+
+namespace Rust {
+namespace AST {
+
+DelimTokenTree
+TokenTreeDesugar::go (DelimTokenTree &tts)
+{
+  tts.accept_vis (*this);
+
+  return DelimTokenTree (tts.get_delim_type (), std::move (desugared),
+tts.get_locus ());
+}
+
+void
+TokenTreeDesugar::append (TokenPtr &&new_token)
+{
+  desugared.emplace_back (std::make_unique (std::move (new_token)));
+}
+
+void
+TokenTreeDesugar::append (std::unique_ptr &&new_token)
+{
+  desugared.emplace_back (std::move (new_token));
+}
+
+void
+TokenTreeDesugar::visit (Token &tts)
+{
+  if (tts.get_id () == TokenId::OUTER_DOC_COMMENT
+  || tts.get_id () == TokenId::INNER_DOC_COMMENT)
+{
+  append (Rust::Token::make (TokenId::HASH, tts.get_locus ()));
+
+  if (tts.get_id () == TokenId::INNER_DOC_COMMENT)
+   append (Rust::Token::make (EXCLAM, tts.get_locus ()));
+
+  append (Rust::Token::make (TokenId::LEFT_SQUARE, tts.get_locus ()));
+  append (Rust::Token::make_identifier (tts.get_locus (), "doc"));
+  append (Rust::Token::make (TokenId::EQUAL, tts.get_locus ()));
+  append (Rust::Token::make_string (tts.get_locus (),
+   std::string (tts.get_str (;
+  append (Rust::Token::make (TokenId::RIGHT_SQUARE, tts.get_locus ()));
+}
+  else
+{
+  append (tts.clone_token ());
+}
+}
+
+}; // namespace AST

[gcc r15-9440] gccrs: nr2.0: Do not resolve modules this run if they are unloaded

2025-04-14 Thread Arthur Cohen via Gcc-cvs
https://gcc.gnu.org/g:6dcbbcd27c534df3a4b8d0d0d0319677b8edee08

commit r15-9440-g6dcbbcd27c534df3a4b8d0d0d0319677b8edee08
Author: Arthur Cohen 
Date:   Fri Apr 4 14:18:33 2025 +0200

gccrs: nr2.0: Do not resolve modules this run if they are unloaded

Instead, mark the visitor as dirty and wait for the next round of the fixed 
point to take care of
them. This avoids issues with module items being loaded while not being 
stripped yet.

gcc/rust/ChangeLog:

* resolve/rust-toplevel-name-resolver-2.0.cc (TopLevel::visit): 
Return if module
is unloaded.

Diff:
---
 gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc | 12 +++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc 
b/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc
index 8863be768a1a..ba37dee88faf 100644
--- a/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc
+++ b/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc
@@ -113,7 +113,17 @@ TopLevel::visit (AST::Module &module)
   // This was copied from the old early resolver method
   // 'accumulate_escaped_macros'
   if (module.get_kind () == AST::Module::UNLOADED)
-module.load_items ();
+{
+  module.load_items ();
+
+  // If the module was previously unloaded, then we don't want to visit it
+  // this time around as the CfgStrip hasn't run on its inner items yet.
+  // Skip it for now, mark the visitor as dirty and try again
+
+  dirty = true;
+
+  return;
+}
 
   DefaultResolver::visit (module);


[gcc r15-9439] gccrs: typecheck: Properly select methods when dealing with specialization

2025-04-14 Thread Arthur Cohen via Gcc-cvs
https://gcc.gnu.org/g:eb5eee065b3e5fe189ea1f51dc88eae7dc4c25d6

commit r15-9439-geb5eee065b3e5fe189ea1f51dc88eae7dc4c25d6
Author: Arthur Cohen 
Date:   Thu Apr 3 16:22:10 2025 +0200

gccrs: typecheck: Properly select methods when dealing with specialization

gcc/rust/ChangeLog:

* typecheck/rust-hir-type-check-expr.cc (is_default_fn): New.
(emit_ambiguous_resolution_error): New.
(handle_multiple_candidates): Properly handle multiple candidates in
the case of specialization.
(TypeCheckExpr::visit): Call `handle_multiple_candidates`.

gcc/testsuite/ChangeLog:

* rust/execute/torture/min_specialization2.rs: New test.
* rust/execute/torture/min_specialization3.rs: New test.

Diff:
---
 gcc/rust/typecheck/rust-hir-type-check-expr.cc | 129 +
 .../rust/execute/torture/min_specialization2.rs|  31 +
 .../rust/execute/torture/min_specialization3.rs|  36 ++
 3 files changed, 172 insertions(+), 24 deletions(-)

diff --git a/gcc/rust/typecheck/rust-hir-type-check-expr.cc 
b/gcc/rust/typecheck/rust-hir-type-check-expr.cc
index 791795f3b0e0..b2bcac065eb2 100644
--- a/gcc/rust/typecheck/rust-hir-type-check-expr.cc
+++ b/gcc/rust/typecheck/rust-hir-type-check-expr.cc
@@ -16,6 +16,8 @@
 // along with GCC; see the file COPYING3.  If not see
 // .
 
+#include "optional.h"
+#include "rust-hir-expr.h"
 #include "rust-system.h"
 #include "rust-tyty-call.h"
 #include "rust-hir-type-check-struct-field.h"
@@ -1154,6 +1156,94 @@ TypeCheckExpr::visit (HIR::FieldAccessExpr &expr)
   infered = lookup->get_field_type ();
 }
 
+bool
+is_default_fn (const MethodCandidate &candidate)
+{
+  if (candidate.candidate.is_impl_candidate ())
+{
+  auto *item = candidate.candidate.item.impl.impl_item;
+
+  if (item->get_impl_item_type () == HIR::ImplItem::FUNCTION)
+   {
+ auto &fn = static_cast (*item);
+
+ return fn.is_default ();
+   }
+}
+
+  return false;
+}
+
+void
+emit_ambiguous_resolution_error (HIR::MethodCallExpr &expr,
+std::set &candidates)
+{
+  rich_location r (line_table, expr.get_method_name ().get_locus ());
+  std::string rich_msg = "multiple "
++ expr.get_method_name ().get_segment ().as_string ()
++ " found";
+
+  // We have to filter out default candidates
+  for (auto &c : candidates)
+if (!is_default_fn (c))
+  r.add_range (c.candidate.locus);
+
+  r.add_fixit_replace (rich_msg.c_str ());
+
+  rust_error_at (r, ErrorCode::E0592, "duplicate definitions with name %qs",
+expr.get_method_name ().get_segment ().as_string ().c_str ());
+}
+
+// We are allowed to have multiple candidates if they are all specializable
+// functions or if all of them except one are specializable functions.
+// In the later case, we just return a valid candidate without erroring out
+// about ambiguity. If there are two or more specialized functions, then we
+// error out.
+//
+// FIXME: The first case is not handled at the moment, so we error out
+tl::optional
+handle_multiple_candidates (HIR::MethodCallExpr &expr,
+   std::set &candidates)
+{
+  auto all_default = true;
+  tl::optional found = tl::nullopt;
+
+  for (auto &c : candidates)
+{
+  if (!is_default_fn (c))
+   {
+ all_default = false;
+
+ // We haven't found a final candidate yet, so we can select
+ // this one. However, if we already have a candidate, then
+ // that means there are multiple non-default candidates - we
+ // must error out
+ if (!found)
+   {
+ found = c;
+   }
+ else
+   {
+ emit_ambiguous_resolution_error (expr, candidates);
+ return tl::nullopt;
+   }
+   }
+}
+
+  // None of the candidates were a non-default (specialized) function, so we
+  // error out
+  if (all_default)
+{
+  rust_sorry_at (expr.get_locus (),
+"cannot resolve method calls to non-specialized methods "
+"(all function candidates are %qs)",
+"default");
+  return tl::nullopt;
+}
+
+  return found;
+}
+
 void
 TypeCheckExpr::visit (HIR::MethodCallExpr &expr)
 {
@@ -1181,34 +1271,25 @@ TypeCheckExpr::visit (HIR::MethodCallExpr &expr)
   return;
 }
 
-  if (candidates.size () > 1)
-{
-  rich_location r (line_table, expr.get_method_name ().get_locus ());
-  std::string rich_msg
-   = "multiple " + expr.get_method_name ().get_segment ().as_string ()
- + " found";
+  tl::optional candidate = *candidates.begin ();
 
-  for (auto &c : candidates)
-   r.add_range (c.candidate.locus);
+  if (candidates.size () > 1)
+candidate = handle_multiple_candidates (expr, candidates);
 
-  r.add_fixit_replace (rich_

[gcc r15-9446] gccrs: format_args: Allow extraneous commas, improve safety

2025-04-14 Thread Arthur Cohen via Gcc-cvs
https://gcc.gnu.org/g:5074a85e0380a4ba97d367a76f4a4efba7424e79

commit r15-9446-g5074a85e0380a4ba97d367a76f4a4efba7424e79
Author: Arthur Cohen 
Date:   Wed Apr 9 14:42:08 2025 +0200

gccrs: format_args: Allow extraneous commas, improve safety

gcc/rust/ChangeLog:

* expand/rust-macro-builtins-format-args.cc 
(format_args_parse_arguments): Improve safety,
allow extra commas after end of argument list.

gcc/testsuite/ChangeLog:

* rust/compile/format_args_extra_comma.rs: New test.

Diff:
---
 gcc/rust/expand/rust-macro-builtins-format-args.cc |  7 
 .../rust/compile/format_args_extra_comma.rs| 47 ++
 2 files changed, 54 insertions(+)

diff --git a/gcc/rust/expand/rust-macro-builtins-format-args.cc 
b/gcc/rust/expand/rust-macro-builtins-format-args.cc
index 8eb32d5f1b31..3e1249d3d36f 100644
--- a/gcc/rust/expand/rust-macro-builtins-format-args.cc
+++ b/gcc/rust/expand/rust-macro-builtins-format-args.cc
@@ -55,6 +55,8 @@ format_args_parse_arguments (AST::MacroInvocData &invoc)
   if (parser.peek_current_token ()->get_id () == STRING_LITERAL)
 format_expr = parser.parse_literal_expr ();
 
+  rust_assert (format_expr);
+
   // TODO(Arthur): Clean this up - if we haven't parsed a string literal but a
   // macro invocation, what do we do here? return a tl::unexpected?
   auto format_str = static_cast (*format_expr)
@@ -81,6 +83,11 @@ format_args_parse_arguments (AST::MacroInvocData &invoc)
 {
   parser.skip_token (COMMA);
 
+  // Check in case of an extraneous comma in the args list, which is
+  // allowed - format_args!("fmt", arg, arg2,)
+  if (parser.peek_current_token ()->get_id () == last_token_id)
+   break;
+
   if (parser.peek_current_token ()->get_id () == IDENTIFIER
  && parser.peek (1)->get_id () == EQUAL)
{
diff --git a/gcc/testsuite/rust/compile/format_args_extra_comma.rs 
b/gcc/testsuite/rust/compile/format_args_extra_comma.rs
new file mode 100644
index ..fcc435c074c2
--- /dev/null
+++ b/gcc/testsuite/rust/compile/format_args_extra_comma.rs
@@ -0,0 +1,47 @@
+#![feature(rustc_attrs)]
+
+#[rustc_builtin_macro]
+macro_rules! format_args {
+() => {};
+}
+
+#[lang = "sized"]
+trait Sized {}
+
+pub mod core {
+pub mod fmt {
+pub struct Formatter;
+pub struct Result;
+
+pub struct Arguments<'a>;
+
+impl<'a> Arguments<'a> {
+pub fn new_v1(_: &'a [&'static str], _: &'a [ArgumentV1<'a>]) -> 
Arguments<'a> {
+Arguments
+}
+}
+
+pub struct ArgumentV1<'a>;
+
+impl<'a> ArgumentV1<'a> {
+pub fn new<'b, T>(_: &'b T, _: fn(&T, &mut Formatter) -> Result) 
-> ArgumentV1 {
+ArgumentV1
+}
+}
+
+pub trait Display {
+fn fmt(&self, _: &mut Formatter) -> Result;
+}
+
+impl Display for i32 {
+fn fmt(&self, _: &mut Formatter) -> Result {
+// { dg-warning "unused name .self." "" { target *-*-* } .-1 }
+Result
+}
+}
+}
+}
+
+fn main() {
+let _formatted = format_args!("extra commas {} {}", 15, 14,);
+}


[gcc r15-9434] testcase: Add testcase for already fixed PR [PR118476]

2025-04-14 Thread Andrew Pinski via Gcc-cvs
https://gcc.gnu.org/g:d45a6502d1ec87d43f1a39f87cca58f1e28369c8

commit r15-9434-gd45a6502d1ec87d43f1a39f87cca58f1e28369c8
Author: Andrew Pinski 
Date:   Mon Apr 14 08:40:24 2025 -0700

testcase: Add testcase for already fixed PR [PR118476]

This testcase was fixed by r15-3052-gc7b76a076cb2c6ded but is
a testcase that failed in a different fashion and a much older
failure than the one added with r15-3052.

Pushed as obvious after a quick test.

PR tree-optimization/118476

gcc/testsuite/ChangeLog:

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

Signed-off-by: Andrew Pinski 

Diff:
---
 gcc/testsuite/gcc.dg/torture/pr118476-1.c | 14 ++
 1 file changed, 14 insertions(+)

diff --git a/gcc/testsuite/gcc.dg/torture/pr118476-1.c 
b/gcc/testsuite/gcc.dg/torture/pr118476-1.c
new file mode 100644
index ..33509403b61a
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr118476-1.c
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+
+/* PR tree-optimization/118476 */
+
+typedef unsigned long long poly64x1 
__attribute__((__vector_size__(1*sizeof(long long;
+
+poly64x1 vext_p64(poly64x1 a, poly64x1 b, const int n)
+{
+  poly64x1 r = a;
+  unsigned src = (unsigned)n;
+  long long t = b[0];
+  r[0] = (src < 1) ? a[src] : t;
+  return r;
+}


[gcc r15-9449] gccrs: Add `#[track_caller]` as known attribute

2025-04-14 Thread Arthur Cohen via Gcc-cvs
https://gcc.gnu.org/g:e84f76dc584192826700ebb89f726984b0788259

commit r15-9449-ge84f76dc584192826700ebb89f726984b0788259
Author: beamandala 
Date:   Thu Mar 20 17:34:48 2025 -0500

gccrs: Add `#[track_caller]` as known attribute

gcc/rust/ChangeLog:

* expand/rust-macro-builtins.cc 
(MacroBuiltin::builtin_transcribers):
Add entry for track_caller.
* util/rust-attribute-values.h: add `TRACK_CALLER` attribute.
* util/rust-attributes.cc: add `track_caller` attribute definition.

gcc/testsuite/ChangeLog:

* rust/compile/track_caller.rs: New test.

Signed-off-by: Bhavesh Mandalapu 

Diff:
---
 gcc/rust/expand/rust-macro-builtins.cc | 1 +
 gcc/rust/util/rust-attribute-values.h  | 1 +
 gcc/rust/util/rust-attributes.cc   | 3 ++-
 gcc/testsuite/rust/compile/track_caller.rs | 6 ++
 4 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/gcc/rust/expand/rust-macro-builtins.cc 
b/gcc/rust/expand/rust-macro-builtins.cc
index 39c4c46b8e0d..a1388fb1dfb3 100644
--- a/gcc/rust/expand/rust-macro-builtins.cc
+++ b/gcc/rust/expand/rust-macro-builtins.cc
@@ -137,6 +137,7 @@ std::unordered_map
 {"cfg_accessible", MacroBuiltin::sorry},
 {"rustc_const_stable", MacroBuiltin::sorry},
 {"rustc_const_unstable", MacroBuiltin::sorry},
+{"track_caller", MacroBuiltin::sorry},
 /* Derive builtins do not need a real transcriber, but still need one. It
should however never be called since builtin derive macros get expanded
differently, and benefit from knowing on what kind of items they are
diff --git a/gcc/rust/util/rust-attribute-values.h 
b/gcc/rust/util/rust-attribute-values.h
index 9ef5cc52e81a..d579fa298013 100644
--- a/gcc/rust/util/rust-attribute-values.h
+++ b/gcc/rust/util/rust-attribute-values.h
@@ -58,6 +58,7 @@ public:
   static constexpr auto &RUSTC_CONST_UNSTABLE = "rustc_const_unstable";
   static constexpr auto &MAY_DANGLE = "may_dangle";
   static constexpr auto &PRELUDE_IMPORT = "prelude_import";
+  static constexpr auto &TRACK_CALLER = "track_caller";
 };
 } // namespace Values
 } // namespace Rust
diff --git a/gcc/rust/util/rust-attributes.cc b/gcc/rust/util/rust-attributes.cc
index 03452c75bd8a..df0fe1b0bcac 100644
--- a/gcc/rust/util/rust-attributes.cc
+++ b/gcc/rust/util/rust-attributes.cc
@@ -75,7 +75,8 @@ static const BuiltinAttrDefinition __definitions[]
  // assuming we keep these for static analysis
  {Attrs::RUSTC_CONST_STABLE, STATIC_ANALYSIS},
  {Attrs::RUSTC_CONST_UNSTABLE, STATIC_ANALYSIS},
- {Attrs::PRELUDE_IMPORT, NAME_RESOLUTION}};
+ {Attrs::PRELUDE_IMPORT, NAME_RESOLUTION},
+ {Attrs::TRACK_CALLER, CODE_GENERATION}};
 
 BuiltinAttributeMappings *
 BuiltinAttributeMappings::get ()
diff --git a/gcc/testsuite/rust/compile/track_caller.rs 
b/gcc/testsuite/rust/compile/track_caller.rs
new file mode 100644
index ..fd1d84295887
--- /dev/null
+++ b/gcc/testsuite/rust/compile/track_caller.rs
@@ -0,0 +1,6 @@
+#[track_caller]
+fn foo() {}
+
+fn main() {
+foo();
+}


[gcc r14-11608] vec-lowering: Fix ABSU lowering [PR111285]

2025-04-14 Thread Andrew Pinski via Gcc-cvs
https://gcc.gnu.org/g:8ee9d7b26342b96f462ebafa1304a26d83b4e833

commit r14-11608-g8ee9d7b26342b96f462ebafa1304a26d83b4e833
Author: Andrew Pinski 
Date:   Sun Oct 27 13:16:22 2024 -0700

vec-lowering: Fix ABSU lowering [PR111285]

ABSU_EXPR lowering incorrectly used the resulting type
for the new expression but in the case of ABSU the resulting
type is an unsigned type and with ABSU is folded away. The fix
is to use a signed type for the expression instead.

Bootstrapped and tested on x86_64-linux-gnu.

PR middle-end/111285

gcc/ChangeLog:

* tree-vect-generic.cc (do_unop): Use a signed type for the
operand if the operation was ABSU_EXPR.

gcc/testsuite/ChangeLog:

* g++.dg/torture/vect-absu-1.C: New test.

Signed-off-by: Andrew Pinski 
(cherry picked from commit ad0084337e901ddaedd48c14e7a5dad9fc2a093e)

Diff:
---
 gcc/testsuite/g++.dg/torture/vect-absu-1.C | 29 +
 gcc/tree-vect-generic.cc   | 10 +-
 2 files changed, 38 insertions(+), 1 deletion(-)

diff --git a/gcc/testsuite/g++.dg/torture/vect-absu-1.C 
b/gcc/testsuite/g++.dg/torture/vect-absu-1.C
new file mode 100644
index ..0b2035f638f5
--- /dev/null
+++ b/gcc/testsuite/g++.dg/torture/vect-absu-1.C
@@ -0,0 +1,29 @@
+// { dg-do run }
+// PR middle-end/111285
+
+// The lowering of vect absu was done incorrectly
+
+#define vect1 __attribute__((vector_size(sizeof(int
+
+#define negabs(a) a < 0 ? a : -a
+
+__attribute__((noinline))
+int s(int a)
+{
+  return negabs(a);
+}
+__attribute__((noinline))
+vect1 int v(vect1 int a)
+{
+  return negabs(a);
+}
+
+int main(void)
+{
+for(int i = -10; i < 10; i++)
+{
+  vect1 int t = {i};
+  if (v(t)[0] != s(i))
+__builtin_abort();
+}
+}
diff --git a/gcc/tree-vect-generic.cc b/gcc/tree-vect-generic.cc
index 86d273923bb5..84361dd5781a 100644
--- a/gcc/tree-vect-generic.cc
+++ b/gcc/tree-vect-generic.cc
@@ -165,7 +165,15 @@ do_unop (gimple_stmt_iterator *gsi, tree inner_type, tree 
a,
 tree b ATTRIBUTE_UNUSED, tree bitpos, tree bitsize,
 enum tree_code code, tree type ATTRIBUTE_UNUSED)
 {
-  a = tree_vec_extract (gsi, inner_type, a, bitsize, bitpos);
+  tree rhs_type = inner_type;
+
+  /* For ABSU_EXPR, use the signed type for the rhs if the rhs was signed. */
+  if (code == ABSU_EXPR
+  && ANY_INTEGRAL_TYPE_P (TREE_TYPE (a))
+  && !TYPE_UNSIGNED (TREE_TYPE (a)))
+rhs_type = signed_type_for (rhs_type);
+
+  a = tree_vec_extract (gsi, rhs_type, a, bitsize, bitpos);
   return gimplify_build1 (gsi, code, inner_type, a);
 }


[gcc] Created branch 'meissner/heads/work201-math' in namespace 'refs/users'

2025-04-14 Thread Michael Meissner via Gcc-cvs
The branch 'meissner/heads/work201-math' was created in namespace 'refs/users' 
pointing to:

 b5abb63c30bd... Add ChangeLog.meissner and REVISION.


[gcc r14-11606] aarch64: Fix early ra for -fno-delete-dead-exceptions [PR116927]

2025-04-14 Thread Andrew Pinski via Gcc-cvs
https://gcc.gnu.org/g:16446f19f1313c57a312857026b6982aaa7241c7

commit r14-11606-g16446f19f1313c57a312857026b6982aaa7241c7
Author: Andrew Pinski 
Date:   Wed Oct 2 14:21:24 2024 -0700

aarch64: Fix early ra for -fno-delete-dead-exceptions [PR116927]

Early-RA was considering throwing instructions as being dead and removing
them even if -fno-delete-dead-exceptions was in use. This fixes that 
oversight.

Built and tested for aarch64-linux-gnu.

PR target/116927

gcc/ChangeLog:

* config/aarch64/aarch64-early-ra.cc (early_ra::is_dead_insn): Insns
that throw are not dead with -fno-delete-dead-exceptions.

gcc/testsuite/ChangeLog:

* g++.dg/torture/pr116927-1.C: New test.

Signed-off-by: Andrew Pinski 
(cherry picked from commit edec4bfc99744b48da3ffde1e4f39c9aceecfd42)

Diff:
---
 gcc/config/aarch64/aarch64-early-ra.cc|  6 ++
 gcc/testsuite/g++.dg/torture/pr116927-1.C | 15 +++
 2 files changed, 21 insertions(+)

diff --git a/gcc/config/aarch64/aarch64-early-ra.cc 
b/gcc/config/aarch64/aarch64-early-ra.cc
index dd2ed762f8ac..427b6a13aecd 100644
--- a/gcc/config/aarch64/aarch64-early-ra.cc
+++ b/gcc/config/aarch64/aarch64-early-ra.cc
@@ -3437,6 +3437,12 @@ early_ra::is_dead_insn (rtx_insn *insn)
   if (side_effects_p (set))
 return false;
 
+  /* If we can't delete dead exceptions and the insn throws,
+ then the instruction is not dead.  */
+  if (!cfun->can_delete_dead_exceptions
+  && !insn_nothrow_p (insn))
+return false;
+
   return true;
 }
 
diff --git a/gcc/testsuite/g++.dg/torture/pr116927-1.C 
b/gcc/testsuite/g++.dg/torture/pr116927-1.C
new file mode 100644
index ..22fa1dbd7e1a
--- /dev/null
+++ b/gcc/testsuite/g++.dg/torture/pr116927-1.C
@@ -0,0 +1,15 @@
+// { dg-do compile }
+// { dg-additional-options "-fnon-call-exceptions -fno-delete-dead-exceptions" 
}
+
+// PR target/116927
+// aarch64's Early ra was removing possiblely trapping
+// floating point insn
+
+void
+foo (float f)
+{
+  try {
+f ++;
+  }catch(...)
+  {}
+}


[gcc r14-11607] backprop: Fix deleting of a phi node [PR116922]

2025-04-14 Thread Andrew Pinski via Gcc-cvs
https://gcc.gnu.org/g:aaef5d6409742574c2ff6acbc75a2a0f597ce8a3

commit r14-11607-gaaef5d6409742574c2ff6acbc75a2a0f597ce8a3
Author: Andrew Pinski 
Date:   Tue Oct 1 14:48:19 2024 -0700

backprop: Fix deleting of a phi node [PR116922]

The problem here is remove_unused_var is called on a name that is
defined by a phi node but it deletes it like removing a normal statement.
remove_phi_node should be called rather than gsi_remove for phinodes.

Note there is a possibility of using simple_dce_from_worklist instead
but that is for another day.

Bootstrapped and tested on x86_64-linux-gnu.

PR tree-optimization/116922

gcc/ChangeLog:

* gimple-ssa-backprop.cc (remove_unused_var): Handle phi
nodes correctly.

gcc/testsuite/ChangeLog:

* gcc.dg/torture/pr116922.c: New test.

Signed-off-by: Andrew Pinski 
(cherry picked from commit cea87c84eacdb422caeada734ba5138c994d7022)

Diff:
---
 gcc/gimple-ssa-backprop.cc  | 10 --
 gcc/testsuite/gcc.dg/torture/pr116922.c | 19 +++
 2 files changed, 27 insertions(+), 2 deletions(-)

diff --git a/gcc/gimple-ssa-backprop.cc b/gcc/gimple-ssa-backprop.cc
index fe27ef51cdf2..e3374b181386 100644
--- a/gcc/gimple-ssa-backprop.cc
+++ b/gcc/gimple-ssa-backprop.cc
@@ -663,8 +663,14 @@ remove_unused_var (tree var)
   print_gimple_stmt (dump_file, stmt, 0, TDF_SLIM);
 }
   gimple_stmt_iterator gsi = gsi_for_stmt (stmt);
-  gsi_remove (&gsi, true);
-  release_defs (stmt);
+  if (gimple_code (stmt) == GIMPLE_PHI)
+remove_phi_node (&gsi, true);
+  else
+{
+  unlink_stmt_vdef (stmt);
+  gsi_remove (&gsi, true);
+  release_defs (stmt);
+}
 }
 
 /* Note that we're replacing OLD_RHS with NEW_RHS in STMT.  */
diff --git a/gcc/testsuite/gcc.dg/torture/pr116922.c 
b/gcc/testsuite/gcc.dg/torture/pr116922.c
new file mode 100644
index ..0fcf912930f4
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr116922.c
@@ -0,0 +1,19 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-ffast-math" } */
+/* PR tree-optimization/116922 */
+
+
+static int g;
+
+void
+foo (int c, double v, double *r)
+{
+b:
+  do
+v /= g - v;
+  while (c);
+  *r = v;
+
+  double x;
+  foo (5, (double)0, &x);
+}


[gcc] Created branch 'meissner/heads/work201-paddis' in namespace 'refs/users'

2025-04-14 Thread Michael Meissner via Gcc-cvs
The branch 'meissner/heads/work201-paddis' was created in namespace 
'refs/users' pointing to:

 b5abb63c30bd... Add ChangeLog.meissner and REVISION.


[gcc(refs/users/meissner/heads/work201-math)] Add ChangeLog.math and update REVISION.

2025-04-14 Thread Michael Meissner via Gcc-cvs
https://gcc.gnu.org/g:faf9364c987569b9f6807649b10902f7e20b2afb

commit faf9364c987569b9f6807649b10902f7e20b2afb
Author: Michael Meissner 
Date:   Mon Apr 14 15:17:52 2025 -0400

Add ChangeLog.math and update REVISION.

2025-04-14  Michael Meissner  

gcc/

* ChangeLog.math: New file for branch.
* REVISION: Update.

Diff:
---
 gcc/ChangeLog.math | 5 +
 gcc/REVISION   | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/gcc/ChangeLog.math b/gcc/ChangeLog.math
new file mode 100644
index ..fe8cef4665ad
--- /dev/null
+++ b/gcc/ChangeLog.math
@@ -0,0 +1,5 @@
+ Branch work201-math, baseline 
+
+2025-04-14   Michael Meissner  
+
+   Clone branch
diff --git a/gcc/REVISION b/gcc/REVISION
index 5f8715c4844d..6f5edba6571c 100644
--- a/gcc/REVISION
+++ b/gcc/REVISION
@@ -1 +1 @@
-work201 branch
+work201-math branch


[gcc] Created branch 'meissner/heads/work201-sha' in namespace 'refs/users'

2025-04-14 Thread Michael Meissner via Gcc-cvs
The branch 'meissner/heads/work201-sha' was created in namespace 'refs/users' 
pointing to:

 b5abb63c30bd... Add ChangeLog.meissner and REVISION.


[gcc(refs/users/meissner/heads/work201-paddis)] Add ChangeLog.paddis and update REVISION.

2025-04-14 Thread Michael Meissner via Gcc-cvs
https://gcc.gnu.org/g:f20a5086a2cf96e96dc36d320b0a6d434a6aa877

commit f20a5086a2cf96e96dc36d320b0a6d434a6aa877
Author: Michael Meissner 
Date:   Mon Apr 14 15:19:36 2025 -0400

Add ChangeLog.paddis and update REVISION.

2025-04-14  Michael Meissner  

gcc/

* ChangeLog.paddis: New file for branch.
* REVISION: Update.

Diff:
---
 gcc/ChangeLog.paddis | 5 +
 gcc/REVISION | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/gcc/ChangeLog.paddis b/gcc/ChangeLog.paddis
new file mode 100644
index ..b8c9b5293f20
--- /dev/null
+++ b/gcc/ChangeLog.paddis
@@ -0,0 +1,5 @@
+ Branch work201-paddis, baseline 
+
+2025-04-14   Michael Meissner  
+
+   Clone branch
diff --git a/gcc/REVISION b/gcc/REVISION
index 5f8715c4844d..d90dc19a4f8f 100644
--- a/gcc/REVISION
+++ b/gcc/REVISION
@@ -1 +1 @@
-work201 branch
+work201-paddis branch


[gcc] Created branch 'meissner/heads/work201-orig' in namespace 'refs/users'

2025-04-14 Thread Michael Meissner via Gcc-cvs
The branch 'meissner/heads/work201-orig' was created in namespace 'refs/users' 
pointing to:

 ebdf92b6067a... testsuite: Fix up ipa/pr119530.c testcase [PR119318]


[gcc(refs/users/meissner/heads/work201-libs)] Add ChangeLog.libs and update REVISION.

2025-04-14 Thread Michael Meissner via Gcc-cvs
https://gcc.gnu.org/g:95d53c351e59dd8649b88702c9cf8df17f775ef8

commit 95d53c351e59dd8649b88702c9cf8df17f775ef8
Author: Michael Meissner 
Date:   Mon Apr 14 15:15:07 2025 -0400

Add ChangeLog.libs and update REVISION.

2025-04-14  Michael Meissner  

gcc/

* ChangeLog.libs: New file for branch.
* REVISION: Update.

Diff:
---
 gcc/ChangeLog.libs | 5 +
 gcc/REVISION   | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/gcc/ChangeLog.libs b/gcc/ChangeLog.libs
new file mode 100644
index ..69f46576250c
--- /dev/null
+++ b/gcc/ChangeLog.libs
@@ -0,0 +1,5 @@
+ Branch work201-libs, baseline 
+
+2025-04-14   Michael Meissner  
+
+   Clone branch
diff --git a/gcc/REVISION b/gcc/REVISION
index 5f8715c4844d..7dae70785b31 100644
--- a/gcc/REVISION
+++ b/gcc/REVISION
@@ -1 +1 @@
-work201 branch
+work201-libs branch


[gcc] Created branch 'meissner/heads/work201-submit' in namespace 'refs/users'

2025-04-14 Thread Michael Meissner via Gcc-cvs
The branch 'meissner/heads/work201-submit' was created in namespace 
'refs/users' pointing to:

 b5abb63c30bd... Add ChangeLog.meissner and REVISION.


[gcc r14-11610] testcase: Add testcase for already fixed PR [PR118476]

2025-04-14 Thread Andrew Pinski via Gcc-cvs
https://gcc.gnu.org/g:52b97f984f2f2dfd1e1d815a2c75153568718462

commit r14-11610-g52b97f984f2f2dfd1e1d815a2c75153568718462
Author: Andrew Pinski 
Date:   Mon Apr 14 08:40:24 2025 -0700

testcase: Add testcase for already fixed PR [PR118476]

This testcase was fixed by r15-3052-gc7b76a076cb2c6ded but is
a testcase that failed in a different fashion and a much older
failure than the one added with r15-3052.

Pushed as obvious after a quick test.

PR tree-optimization/118476

gcc/testsuite/ChangeLog:

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

Signed-off-by: Andrew Pinski 
(cherry picked from commit d45a6502d1ec87d43f1a39f87cca58f1e28369c8)

Diff:
---
 gcc/testsuite/gcc.dg/torture/pr118476-1.c | 14 ++
 1 file changed, 14 insertions(+)

diff --git a/gcc/testsuite/gcc.dg/torture/pr118476-1.c 
b/gcc/testsuite/gcc.dg/torture/pr118476-1.c
new file mode 100644
index ..33509403b61a
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr118476-1.c
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+
+/* PR tree-optimization/118476 */
+
+typedef unsigned long long poly64x1 
__attribute__((__vector_size__(1*sizeof(long long;
+
+poly64x1 vext_p64(poly64x1 a, poly64x1 b, const int n)
+{
+  poly64x1 r = a;
+  unsigned src = (unsigned)n;
+  long long t = b[0];
+  r[0] = (src < 1) ? a[src] : t;
+  return r;
+}


[gcc] Created branch 'meissner/heads/work201-test' in namespace 'refs/users'

2025-04-14 Thread Michael Meissner via Gcc-cvs
The branch 'meissner/heads/work201-test' was created in namespace 'refs/users' 
pointing to:

 b5abb63c30bd... Add ChangeLog.meissner and REVISION.


[gcc(refs/users/mikael/heads/refactor_descriptor_v05)] Retour en arrière délinearisation tableaux compil' OK.

2025-04-14 Thread Mikael Morin via Gcc-cvs
https://gcc.gnu.org/g:22ce751b60bba098a6e0c2a75cd4d1e882eaa51a

commit 22ce751b60bba098a6e0c2a75cd4d1e882eaa51a
Author: Mikael Morin 
Date:   Mon Apr 14 13:52:49 2025 +0200

Retour en arrière délinearisation tableaux compil' OK.

Diff:
---
 gcc/fortran/trans-array.cc  | 353 +---
 gcc/fortran/trans-decl.cc   |  35 +---
 gcc/fortran/trans-descriptor.cc |  33 
 gcc/fortran/trans-types.cc  |  60 +++
 libgfortran/caf/single.c|   4 +-
 5 files changed, 136 insertions(+), 349 deletions(-)

diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc
index fa84f007bee5..41d0a612edf5 100644
--- a/gcc/fortran/trans-array.cc
+++ b/gcc/fortran/trans-array.cc
@@ -2169,43 +2169,6 @@ gfc_build_constant_array_constructor (gfc_expr * expr, 
tree type)
   gfc_free_expr (as.upper[i]);
 }
 
-  if (expr->shape && expr->rank > 1)
-{
-  vec *vsrc = v;
-
-  for (int r = 0; r < expr->rank - 1; r++)
-   {
- vec *vdest = nullptr;
- unsigned sidx = 0;
-
- tree type = tmptype;
- for (int j = expr->rank - 1; j > r; j--)
-   {
- gcc_assert (TREE_CODE (type) == ARRAY_TYPE); 
- type = TREE_TYPE (type);
-   }
-
- int len = (int) mpz_get_si (expr->shape[r]);
-
- while (sidx != vec_safe_length (vsrc))
-   {
- vec *vtmp = nullptr;
-
- for (int i = 0; i < len; i++)
-   {
- append_constructor (vtmp, (*vsrc)[sidx].value);
- sidx++;
-   }
-
- append_constructor (vdest, build_constructor (type, vtmp));
-   }
-
- vsrc = vdest;
-   }
-
-  v = vsrc;
-}
-
   init = build_constructor (tmptype, v);
 
   TREE_CONSTANT (init) = 1;
@@ -3007,6 +2970,11 @@ gfc_conv_ss_descriptor (stmtblock_t * block, gfc_ss * 
ss, int base)
   if (!ss->is_alloc_lhs)
tmp = gfc_evaluate_now (tmp, block);
   info->offset = tmp;
+
+  /* Make absolutely sure that the saved_offset is indeed saved
+so that the variable is still accessible after the loops
+are translated.  */
+  info->saved_data = info->data;
 }
 }
 
@@ -3359,82 +3327,6 @@ array_bound_check_elemental (gfc_se * se, gfc_ss * ss, 
gfc_expr * expr)
 }
 
 
-/* Build a scalarized array reference using the vptr 'size'.  */
-
-static bool
-build_class_array_ref (gfc_se *se, tree base, tree index)
-{
-  tree size;
-  tree decl = NULL_TREE;
-  tree tmp;
-  gfc_expr *expr = se->ss->info->expr;
-  gfc_expr *class_expr;
-  gfc_typespec *ts;
-  gfc_symbol *sym;
-
-  tmp = !VAR_P (base) ? gfc_get_class_from_expr (base) : NULL_TREE;
-
-  if (tmp != NULL_TREE)
-decl = tmp;
-  else
-{
-  /* The base expression does not contain a class component, either
-because it is a temporary array or array descriptor.  Class
-array functions are correctly resolved above.  */
-  if (!expr
- || (expr->ts.type != BT_CLASS
- && !gfc_is_class_array_ref (expr, NULL)))
-   return false;
-
-  /* Obtain the expression for the class entity or component that is
-followed by an array reference, which is not an element, so that
-the span of the array can be obtained.  */
-  class_expr = gfc_find_and_cut_at_last_class_ref (expr, false, &ts);
-
-  if (!ts)
-   return false;
-
-  sym = (!class_expr && expr) ? expr->symtree->n.sym : NULL;
-  if (sym && sym->attr.function
- && sym == sym->result
- && sym->backend_decl == current_function_decl)
-   /* The temporary is the data field of the class data component
-  of the current function.  */
-   decl = gfc_get_fake_result_decl (sym, 0);
-  else if (sym)
-   {
- if (decl == NULL_TREE)
-   decl = expr->symtree->n.sym->backend_decl;
- /* For class arrays the tree containing the class is stored in
-GFC_DECL_SAVED_DESCRIPTOR of the sym's backend_decl.
-For all others it's sym's backend_decl directly.  */
- if (DECL_LANG_SPECIFIC (decl) && GFC_DECL_SAVED_DESCRIPTOR (decl))
-   decl = GFC_DECL_SAVED_DESCRIPTOR (decl);
-   }
-  else
-   decl = gfc_get_class_from_gfc_expr (class_expr);
-
-  if (POINTER_TYPE_P (TREE_TYPE (decl)))
-   decl = build_fold_indirect_ref_loc (input_location, decl);
-
-  if (!GFC_CLASS_TYPE_P (TREE_TYPE (decl)))
-   return false;
-}
-
-  se->class_vptr = gfc_evaluate_now (gfc_class_vptr_get (decl), &se->pre);
-
-  size = gfc_class_vtab_size_get (decl);
-  /* For unlimited polymorphic entities then _len component needs to be
- multiplied with the size.  */
-  size = gfc_resize_class_size_with_len (&se->pre, decl, size);
-  size = fold_convert (gfc_array_index_type, size);
-
-  /* Return the element in the se expression.  */
-  se->expr = gfc_build_spanned_array_ref (base, index, size);
-  return true;
-}
-
-
 /* Ind

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

2025-04-14 Thread Mikael Morin via Gcc-cvs
https://gcc.gnu.org/g:650dc7274c9d7bab9a010ae93fca1aee7e2ee1f0

commit 650dc7274c9d7bab9a010ae93fca1aee7e2ee1f0
Author: Mikael Morin 
Date:   Mon Apr 14 17:43:04 2025 +0200

Correction régression ISO_Fortran_binding_14.f90

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

diff --git a/gcc/fortran/trans-types.cc b/gcc/fortran/trans-types.cc
index c8d56ec55999..0c07de4bd18a 100644
--- a/gcc/fortran/trans-types.cc
+++ b/gcc/fortran/trans-types.cc
@@ -1994,6 +1994,26 @@ gfc_get_nodesc_array_type (tree etype, gfc_array_spec * 
as, gfc_packed packed,
   else
 GFC_TYPE_ARRAY_SIZE (type) = NULL_TREE;
 
+  if (as->rank != 0)
+{
+  tree max_idx;
+  if (known_stride)
+   {
+ mpz_t size;
+ mpz_init (size);
+ mpz_sub_ui (size, stride, 1);
+ max_idx = gfc_conv_mpz_to_tree (size, gfc_index_integer_kind);
+   }
+  else
+   max_idx = NULL_TREE;
+
+  TYPE_DOMAIN (type) = build_range_type (gfc_array_index_type,
+gfc_index_zero_node, max_idx);
+  TREE_TYPE (type) = etype;
+}
+
+  layout_type (type);
+
   if (packed != PACKED_NO)
 GFC_TYPE_ARRAY_ELEM_LEN (type) = TYPE_SIZE_UNIT (etype);


[gcc(refs/users/mikael/heads/refactor_descriptor_v05)] Correction ISO_Fortran_binding_18.f90

2025-04-14 Thread Mikael Morin via Gcc-cvs
https://gcc.gnu.org/g:84a4b72e8e5b98e35554044aa42a7592a79557b9

commit 84a4b72e8e5b98e35554044aa42a7592a79557b9
Author: Mikael Morin 
Date:   Mon Apr 14 18:16:13 2025 +0200

Correction ISO_Fortran_binding_18.f90

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

diff --git a/gcc/fortran/trans-array.cc b/gcc/fortran/trans-array.cc
index 41d0a612edf5..8cd7de71fe4a 100644
--- a/gcc/fortran/trans-array.cc
+++ b/gcc/fortran/trans-array.cc
@@ -3722,6 +3722,8 @@ add_array_offset (stmtblock_t *pblock, gfc_loopinfo 
*loop, gfc_ss *ss,
 
   info = &ss->info->data.array;
 
+  tree type = TREE_TYPE (info->data);
+
   gfc_init_se (&se, NULL);
   se.loop = loop;
   se.expr = info->descriptor;
@@ -3731,6 +3733,7 @@ add_array_offset (stmtblock_t *pblock, gfc_loopinfo 
*loop, gfc_ss *ss,
 
   tree tmp = build_array_ref_dim (ss, index, info->spacing[array_dim]);
   tmp = gfc_build_addr_expr (NULL_TREE, tmp);
+  tmp = fold_convert_loc (input_location, type, tmp);
   info->data = gfc_evaluate_now (tmp, pblock);
 }


[gcc r14-11604] Fortran: fix issue with impure elemental subroutine and interface [PR119656]

2025-04-14 Thread Harald Anlauf via Gcc-cvs
https://gcc.gnu.org/g:477d8ba89ff71592f7d66fb01a4d10018e86e502

commit r14-11604-g477d8ba89ff71592f7d66fb01a4d10018e86e502
Author: Harald Anlauf 
Date:   Tue Apr 8 22:30:15 2025 +0200

Fortran: fix issue with impure elemental subroutine and interface [PR119656]

PR fortran/119656

gcc/fortran/ChangeLog:

* interface.cc (gfc_compare_actual_formal): Fix front-end memleak
when searching for matching interfaces.
* trans-expr.cc (gfc_conv_procedure_call): If there is a formal
dummy corresponding to an absent argument, use its type, and only
fall back to inferred type otherwise.

gcc/testsuite/ChangeLog:

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

(cherry picked from commit 334545194d9023fb9b2f72ee0dcde8af94930f25)

Diff:
---
 gcc/fortran/interface.cc |  6 ++-
 gcc/fortran/trans-expr.cc| 18 ++---
 gcc/testsuite/gfortran.dg/optional_absent_13.f90 | 48 
 3 files changed, 65 insertions(+), 7 deletions(-)

diff --git a/gcc/fortran/interface.cc b/gcc/fortran/interface.cc
index c4f3a3b03fbe..25f27f83458c 100644
--- a/gcc/fortran/interface.cc
+++ b/gcc/fortran/interface.cc
@@ -3291,7 +3291,11 @@ gfc_compare_actual_formal (gfc_actual_arglist **ap, 
gfc_formal_arglist *formal,
  return false;
}
   else
-   a->associated_dummy = get_nonintrinsic_dummy_arg (f);
+   {
+ if (a->associated_dummy)
+   free (a->associated_dummy);
+ a->associated_dummy = get_nonintrinsic_dummy_arg (f);
+   }
 
   if (a->expr == NULL)
{
diff --git a/gcc/fortran/trans-expr.cc b/gcc/fortran/trans-expr.cc
index cf6511852132..1f0361d55d8b 100644
--- a/gcc/fortran/trans-expr.cc
+++ b/gcc/fortran/trans-expr.cc
@@ -6543,10 +6543,18 @@ gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym,
{
  /* Pass a NULL pointer for an absent arg.  */
  parmse.expr = null_pointer_node;
+
+ /* Is it an absent character dummy?  */
+ bool absent_char = false;
  gfc_dummy_arg * const dummy_arg = arg->associated_dummy;
- if (dummy_arg
- && gfc_dummy_arg_get_typespec (*dummy_arg).type
-== BT_CHARACTER)
+
+ /* Fall back to inferred type only if no formal.  */
+ if (fsym)
+   absent_char = (fsym->ts.type == BT_CHARACTER);
+ else if (dummy_arg)
+   absent_char = (gfc_dummy_arg_get_typespec (*dummy_arg).type
+  == BT_CHARACTER);
+ if (absent_char)
parmse.string_length = build_int_cst (gfc_charlen_type_node,
  0);
}
@@ -6563,9 +6571,7 @@ gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym,
  || !CLASS_DATA (fsym)->attr.allocatable));
  gfc_init_se (&parmse, NULL);
  parmse.expr = null_pointer_node;
- if (arg->associated_dummy
- && gfc_dummy_arg_get_typespec (*arg->associated_dummy).type
-== BT_CHARACTER)
+ if (fsym->ts.type == BT_CHARACTER)
parmse.string_length = build_int_cst (gfc_charlen_type_node, 0);
}
   else if (fsym && fsym->ts.type == BT_CLASS
diff --git a/gcc/testsuite/gfortran.dg/optional_absent_13.f90 
b/gcc/testsuite/gfortran.dg/optional_absent_13.f90
new file mode 100644
index ..9c2039bfb3f6
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/optional_absent_13.f90
@@ -0,0 +1,48 @@
+! { dg-do run }
+! PR fortran/119656 - wrong code with impure elemental subroutine and interface
+!
+! Derived from testcase at:
+!   https://fortran-lang.discourse.group/t/
+! problem-with-impure-elemental-subroutine-in-interface-with-gfortran/9545
+
+module m2
+  implicit none
+  interface foo
+ module procedure foo_mat
+ module procedure foo_df
+ module procedure foo_cmat
+  end interface foo
+contains
+
+  subroutine foo_mat(x, nacf, label)
+real, intent(in)   :: x(:,:)
+integer,  intent(in)   :: nacf
+character(len=*), intent(in), optional :: label
+  end subroutine foo_mat
+
+  impure elemental subroutine foo_df(nacf, outu, xstr)
+integer , intent(in)   :: nacf
+integer , intent(in), optional :: outu
+character(len=*), intent(in), optional :: xstr
+if (present(xstr)) then
+   if (len (xstr) /= 2) then
+  print *,"nacf, len(xstr) =", nacf, len(xstr)
+  stop nacf
+   end if
+end if
+  end subroutine foo_df
+
+  subroutine foo_cmat(x, nacf, label)
+complex,  intent(in)   :: x(:,:)
+integer,  intent(in)   :: nacf
+character(len=*), intent(in), optional :: lab

[gcc r15-9433] c++: wrong targs in satisfaction diagnostic context line [PR99214]

2025-04-14 Thread Patrick Palka via Gcc-cvs
https://gcc.gnu.org/g:00966a7fdb1478b3af5254ff3a80a3ef336c5a94

commit r15-9433-g00966a7fdb1478b3af5254ff3a80a3ef336c5a94
Author: Patrick Palka 
Date:   Mon Apr 14 11:20:13 2025 -0400

c++: wrong targs in satisfaction diagnostic context line [PR99214]

In the three-parameter version of satisfy_declaration_constraints, when
't' isn't the most general template, then 't' won't correspond with
'args' after we augment the latter via add_outermost_template_args, and
so the instantiation context that we push via push_tinst_level isn't
quite correct: 'args' is a complete set of template arguments, but 't'
is not necessarily the most general template.  This manifests as
misleading diagnostic context lines when issuing a satisfaction failure
error, e.g.  the below testcase without this patch we emit:
  In substitution of '... void A::f() ... [with U = int]'
and with this patch we emit:
  In substitution of '... void A::f() ... [with U = char]'.

This patch fixes this by passing the original 'args' to push_tinst_level,
which ought to properly correspond to 't'.

PR c++/99214

gcc/cp/ChangeLog:

* constraint.cc (satisfy_declaration_constraints): Pass the
original ARGS to push_tinst_level.

gcc/testsuite/ChangeLog:

* g++.dg/concepts/diagnostic20.C: New test.

Reviewed-by: Jason Merrill 

Diff:
---
 gcc/cp/constraint.cc |  4 +++-
 gcc/testsuite/g++.dg/concepts/diagnostic20.C | 13 +
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/gcc/cp/constraint.cc b/gcc/cp/constraint.cc
index 2f1678ce4ff9..44fb086c6306 100644
--- a/gcc/cp/constraint.cc
+++ b/gcc/cp/constraint.cc
@@ -2704,6 +2704,8 @@ satisfy_declaration_constraints (tree t, sat_info info)
 static tree
 satisfy_declaration_constraints (tree t, tree args, sat_info info)
 {
+  tree orig_args = args;
+
   /* Update the declaration for diagnostics.  */
   info.in_decl = t;
 
@@ -2732,7 +2734,7 @@ satisfy_declaration_constraints (tree t, tree args, 
sat_info info)
   tree result = boolean_true_node;
   if (tree norm = get_normalized_constraints_from_decl (t, info.noisy ()))
 {
-  if (!push_tinst_level (t, args))
+  if (!push_tinst_level (t, orig_args))
return result;
   tree pattern = DECL_TEMPLATE_RESULT (t);
   push_to_top_level ();
diff --git a/gcc/testsuite/g++.dg/concepts/diagnostic20.C 
b/gcc/testsuite/g++.dg/concepts/diagnostic20.C
new file mode 100644
index ..2bb01db44dec
--- /dev/null
+++ b/gcc/testsuite/g++.dg/concepts/diagnostic20.C
@@ -0,0 +1,13 @@
+// PR c++/99214
+// { dg-do compile { target c++20 } }
+
+template 
+struct A {
+  template  static void f() requires requires { T::fail; };
+};
+
+int main() {
+  A::f(); // { dg-error "no match" }
+}
+
+// { dg-message "In substitution of '\[^\r\n\]* \\\[with U = char\\\]'" "" { 
target *-*-* } 0 }


[gcc r15-9447] gccrs: Fix const checking of enum discriminants

2025-04-14 Thread Arthur Cohen via Gcc-cvs
https://gcc.gnu.org/g:85a57bf4708085cc522732a9b7b2b0f6b1882125

commit r15-9447-g85a57bf4708085cc522732a9b7b2b0f6b1882125
Author: Owen Avery 
Date:   Sat Apr 5 17:20:44 2025 -0400

gccrs: Fix const checking of enum discriminants

gcc/rust/ChangeLog:

* checks/errors/rust-const-checker.cc
(ConstChecker::visit): Visit the enum items of enums.
* resolve/rust-ast-resolve-item.cc
(ResolveItem::visit): Resolve enum discriminants during nr1.0.

gcc/testsuite/ChangeLog:

* rust/compile/enum_discriminant2.rs: New test.

Signed-off-by: Owen Avery 

Diff:
---
 gcc/rust/checks/errors/rust-const-checker.cc | 3 +++
 gcc/rust/resolve/rust-ast-resolve-item.cc| 2 ++
 gcc/testsuite/rust/compile/enum_discriminant2.rs | 9 +
 3 files changed, 14 insertions(+)

diff --git a/gcc/rust/checks/errors/rust-const-checker.cc 
b/gcc/rust/checks/errors/rust-const-checker.cc
index 4904322b9382..4c2257a24556 100644
--- a/gcc/rust/checks/errors/rust-const-checker.cc
+++ b/gcc/rust/checks/errors/rust-const-checker.cc
@@ -646,6 +646,9 @@ ConstChecker::visit (Enum &enum_item)
 {
   check_default_const_generics (enum_item.get_generic_params (),
ConstGenericCtx::Enum);
+
+  for (auto &item : enum_item.get_variants ())
+item->accept_vis (*this);
 }
 
 void
diff --git a/gcc/rust/resolve/rust-ast-resolve-item.cc 
b/gcc/rust/resolve/rust-ast-resolve-item.cc
index d584961354fd..30f6d430b861 100644
--- a/gcc/rust/resolve/rust-ast-resolve-item.cc
+++ b/gcc/rust/resolve/rust-ast-resolve-item.cc
@@ -356,6 +356,8 @@ ResolveItem::visit (AST::EnumItemDiscriminant &item)
   auto cpath = canonical_prefix.append (decl);
 
   mappings.insert_canonical_path (item.get_node_id (), cpath);
+
+  ResolveExpr::go (item.get_expr (), path, cpath);
 }
 
 void
diff --git a/gcc/testsuite/rust/compile/enum_discriminant2.rs 
b/gcc/testsuite/rust/compile/enum_discriminant2.rs
new file mode 100644
index ..351dfbb6f85d
--- /dev/null
+++ b/gcc/testsuite/rust/compile/enum_discriminant2.rs
@@ -0,0 +1,9 @@
+fn test() -> isize {
+1
+}
+
+enum Foo {
+Bar = test() // { dg-error "only functions marked as .const." }
+}
+
+fn main() {}


[gcc r15-9456] cobol: Fix up COBOL -include [PR119777]

2025-04-14 Thread Jakub Jelinek via Gcc-cvs
https://gcc.gnu.org/g:d0b41f3d6d0ace2b0ca57d105cd7fd8361d0b2a8

commit r15-9456-gd0b41f3d6d0ace2b0ca57d105cd7fd8361d0b2a8
Author: Jakub Jelinek 
Date:   Mon Apr 14 19:32:43 2025 +0200

cobol: Fix up COBOL -include [PR119777]

I was looking through options.cc diff between GCC 14 and 15, looking for
entries with added CL_Cobol where at least one other language is present
and was present before too.  Besides the -fsyntax-only changes this is
the only other one I found, COBOL adds Var(cobol_include) to something
which didn't have a Var at all before and IMHO it is actively harmful.
Because one can specify multiple -include file1 -include file2 options,
both in C/C++ etc. and in COBOL as well (as documented in the man
page).  A Var can track just one entry.  cobol_langhook_handle_option
should use arg instead.

2025-04-14  Jakub Jelinek  

PR cobol/119777
* lang.opt (include): Remove Var(cobol_include).
* cobol1.cc (cobol_langhook_handle_option) : Use
arg instead of cobol_include.

Diff:
---
 gcc/cobol/cobol1.cc | 4 ++--
 gcc/cobol/lang.opt  | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/gcc/cobol/cobol1.cc b/gcc/cobol/cobol1.cc
index 98d15a8d1eda..7d742b907764 100644
--- a/gcc/cobol/cobol1.cc
+++ b/gcc/cobol/cobol1.cc
@@ -413,8 +413,8 @@ cobol_langhook_handle_option (size_t scode,
   }
   return true;
 case OPT_include:
-  if( ! include_file_add(cobol_include) ) {
-cbl_errx( "could not include %s", cobol_include);
+  if( ! include_file_add(arg) ) {
+cbl_errx( "could not include %s", arg);
   }
 return true;
 
diff --git a/gcc/cobol/lang.opt b/gcc/cobol/lang.opt
index 142ec4f34bf2..1d33f34aceeb 100644
--- a/gcc/cobol/lang.opt
+++ b/gcc/cobol/lang.opt
@@ -114,7 +114,7 @@ Cobol Joined Separate
 ; Documented in C
 
 include
-Cobol Joined Separate Var(cobol_include)
+Cobol Joined Separate
 ; Documented in C
 
 isysroot


[gcc r15-9459] testsuite: Fix up ipa/pr119530.c testcase [PR119318]

2025-04-14 Thread Jakub Jelinek via Gcc-cvs
https://gcc.gnu.org/g:ebdf92b6067a357e7bb08bfde294cc19b50e6abb

commit r15-9459-gebdf92b6067a357e7bb08bfde294cc19b50e6abb
Author: Jakub Jelinek 
Date:   Mon Apr 14 19:35:20 2025 +0200

testsuite: Fix up ipa/pr119530.c testcase [PR119318]

I'm seeing
+FAIL: gcc.dg/ipa/pr119530.c execution test
on i686-linux.  The problem is that when long is just 32-bit and
so is unsigned, the testcase then behaves differently and should abort.
Fixed by making the argument long long instead.
While at it, just in case I've changed type of d variable to signed char
as well just in case there is -funsigned-char 8-bit int target or something
similar.

2025-04-14  Jakub Jelinek  

PR ipa/119318
* gcc.dg/ipa/pr119530.c (d): Change type from char to signed char.
(e): Change argument type from long to long long.

Diff:
---
 gcc/testsuite/gcc.dg/ipa/pr119530.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gcc/testsuite/gcc.dg/ipa/pr119530.c 
b/gcc/testsuite/gcc.dg/ipa/pr119530.c
index 70f158a2de84..f99c4fdbe20c 100644
--- a/gcc/testsuite/gcc.dg/ipa/pr119530.c
+++ b/gcc/testsuite/gcc.dg/ipa/pr119530.c
@@ -5,8 +5,8 @@ struct a {
   int b;
 };
 int c;
-char d;
-static int e(long f) { return f < 0; }
+signed char d;
+static int e(long long f) { return f < 0; }
 static void g(unsigned f) { c = e(~f); }
 int main() {
   int h;


[gcc(refs/users/meissner/heads/work201-orig)] Add REVISION.

2025-04-14 Thread Michael Meissner via Gcc-cvs
https://gcc.gnu.org/g:7cfd776ecfdadf03f835e0547b1e2b901d19c671

commit 7cfd776ecfdadf03f835e0547b1e2b901d19c671
Author: Michael Meissner 
Date:   Mon Apr 14 15:20:36 2025 -0400

Add REVISION.

2025-04-14  Michael Meissner  

gcc/

* REVISION: New file for branch.

Diff:
---
 gcc/REVISION | 1 +
 1 file changed, 1 insertion(+)

diff --git a/gcc/REVISION b/gcc/REVISION
new file mode 100644
index ..311ed3c92ba2
--- /dev/null
+++ b/gcc/REVISION
@@ -0,0 +1 @@
+work201-orig branch


[gcc] Created branch 'meissner/heads/work201-libs' in namespace 'refs/users'

2025-04-14 Thread Michael Meissner via Gcc-cvs
The branch 'meissner/heads/work201-libs' was created in namespace 'refs/users' 
pointing to:

 b5abb63c30bd... Add ChangeLog.meissner and REVISION.


[gcc(refs/users/meissner/heads/work201-sha)] Add ChangeLog.sha and update REVISION.

2025-04-14 Thread Michael Meissner via Gcc-cvs
https://gcc.gnu.org/g:0339a910393a1f7eb4dd09dc6bbd624909557b40

commit 0339a910393a1f7eb4dd09dc6bbd624909557b40
Author: Michael Meissner 
Date:   Mon Apr 14 15:16:10 2025 -0400

Add ChangeLog.sha and update REVISION.

2025-04-14  Michael Meissner  

gcc/

* ChangeLog.sha: New file for branch.
* REVISION: Update.

Diff:
---
 gcc/ChangeLog.sha | 5 +
 gcc/REVISION  | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/gcc/ChangeLog.sha b/gcc/ChangeLog.sha
new file mode 100644
index ..389f91f54250
--- /dev/null
+++ b/gcc/ChangeLog.sha
@@ -0,0 +1,5 @@
+ Branch work201-sha, baseline 
+
+2025-04-14   Michael Meissner  
+
+   Clone branch
diff --git a/gcc/REVISION b/gcc/REVISION
index 5f8715c4844d..4363e39c6b26 100644
--- a/gcc/REVISION
+++ b/gcc/REVISION
@@ -1 +1 @@
-work201 branch
+work201-sha branch


[gcc r14-11605] phiopt: Fix VCE moving by rewriting it into cast [PR116098]

2025-04-14 Thread Andrew Pinski via Gcc-cvs
https://gcc.gnu.org/g:c2c1046b83a92283cd0863942efe9df453d78a78

commit r14-11605-gc2c1046b83a92283cd0863942efe9df453d78a78
Author: Andrew Pinski 
Date:   Tue Oct 1 18:34:00 2024 +

phiopt: Fix VCE moving by rewriting it into cast [PR116098]

Phiopt match_and_simplify might move a well defined VCE assign statement
from being conditional to being uncondtitional; that VCE might no longer
being defined. It will need a rewrite into a cast instead.

This adds the rewriting code to move_stmt for the VCE case.
This is enough to fix the issue at hand. It should also be using 
rewrite_to_defined_overflow
but first I need to move the check to see a rewrite is needed into its own 
function
and that is causing issues (see 
https://gcc.gnu.org/pipermail/gcc-patches/2024-September/663938.html).
Plus this version is easiest to backport.

Bootstrapped and tested on x86_64-linux-gnu.

PR tree-optimization/116098

gcc/ChangeLog:

* tree-ssa-phiopt.cc (move_stmt): Rewrite VCEs from integer to 
integer
types to case.

gcc/testsuite/ChangeLog:

* c-c++-common/torture/pr116098-2.c: New test.
* g++.dg/torture/pr116098-1.C: New test.

Signed-off-by: Andrew Pinski 
(cherry picked from commit 1f619fe25925a5f79b9c33962e7a72e1f9fa)

Diff:
---
 gcc/testsuite/c-c++-common/torture/pr116098-2.c | 46 +
 gcc/testsuite/g++.dg/torture/pr116098-1.C   | 33 ++
 gcc/tree-ssa-phiopt.cc  | 28 ++-
 3 files changed, 106 insertions(+), 1 deletion(-)

diff --git a/gcc/testsuite/c-c++-common/torture/pr116098-2.c 
b/gcc/testsuite/c-c++-common/torture/pr116098-2.c
new file mode 100644
index ..614ed0491717
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/torture/pr116098-2.c
@@ -0,0 +1,46 @@
+/* { dg-do run } */
+/* PR tree-optimization/116098 */
+
+
+#include 
+
+struct Value {
+int type;
+union {
+bool boolean;
+long long t;
+};
+};
+
+static struct Value s_item_mem;
+
+/* truthy was being miscompiled for the value.type==2 case,
+   because we would have a VCE from unsigned char to bool
+   that went from being conditional in the value.type==1 case
+   to unconditional when `value.type!=0`.
+   The move of the VCE from conditional to unconditional,
+   needs to changed into a convert (NOP_EXPR). */
+static bool truthy(void) __attribute__((noipa));
+static bool
+truthy(void)
+{
+struct Value value = s_item_mem;
+if (value.type == 0)
+  return 0;
+if (value.type == 1)
+  return value.boolean;
+return 1;
+}
+
+int
+main(void)
+{
+s_item_mem.type = 2;
+s_item_mem.t = -1;
+bool b1 = !truthy();
+s_item_mem.type = 1;
+s_item_mem.boolean = b1;
+bool b = truthy();
+if (b1 != b)  __builtin_abort();
+if (b) __builtin_abort();
+}
diff --git a/gcc/testsuite/g++.dg/torture/pr116098-1.C 
b/gcc/testsuite/g++.dg/torture/pr116098-1.C
new file mode 100644
index ..90e44a6eeedb
--- /dev/null
+++ b/gcc/testsuite/g++.dg/torture/pr116098-1.C
@@ -0,0 +1,33 @@
+// { dg-do run }
+/* PR tree-optimization/116098 */
+
+
+static bool truthy(int type, unsigned char data) __attribute__((noipa));
+/* truthy was being miscompiled for the type==2 case,
+   because we would have a VCE from unsigned char to bool
+   that went from being conditional in the type==1 case
+   to unconditional when `type!=0`.
+   The move of the VCE from conditional to unconditional,
+   needs to changed into a convert (NOP_EXPR). */
+
+static bool truthy(void) __attribute__((noipa));
+static bool
+truthy(int type, unsigned char data)
+{
+if (type == 0)
+  return 0;
+if (type == 1)
+  /* Emulate what SRA does, so this can be
+tested without depending on SRA. */
+  return __builtin_bit_cast (bool, data);
+return 1;
+}
+
+int
+main(void)
+{
+bool b1 = !truthy(2, -1);
+bool b = truthy(1, b1);
+if (b1 != b)  __builtin_abort();
+if (b) __builtin_abort();
+}
diff --git a/gcc/tree-ssa-phiopt.cc b/gcc/tree-ssa-phiopt.cc
index f01979aa0038..fa8dc2c8a4e3 100644
--- a/gcc/tree-ssa-phiopt.cc
+++ b/gcc/tree-ssa-phiopt.cc
@@ -728,7 +728,8 @@ empty_bb_or_one_feeding_into_p (basic_block bb,
 }
 
 /* Move STMT to before GSI and insert its defining
-   name into INSERTED_EXPRS bitmap. */
+   name into INSERTED_EXPRS bitmap.
+   Also rewrite its if it might be undefined when unconditionalized.  */
 static void
 move_stmt (gimple *stmt, gimple_stmt_iterator *gsi, auto_bitmap 
&inserted_exprs)
 {
@@ -747,6 +748,31 @@ move_stmt (gimple *stmt, gimple_stmt_iterator *gsi, 
auto_bitmap &inserted_exprs)
   gimple_stmt_iterator gsi1 = gsi_for_stmt (stmt);
   gsi_move_before (&gsi1, gsi);
   reset_flow_sensitive_info (name);
+
+  /* Rewrite some code which might be undefined when
+ unconditionalized. */
+  if (gimple_assign_single_p (stmt))
+{
+  

[gcc r15-9452] gccrs: attributes: Handle external tool annotations like rustfmt::

2025-04-14 Thread Arthur Cohen via Gcc-cvs
https://gcc.gnu.org/g:73d72498f97f601414919607ebf150b69694ce16

commit r15-9452-g73d72498f97f601414919607ebf150b69694ce16
Author: Arthur Cohen 
Date:   Wed Apr 9 15:17:38 2025 +0200

gccrs: attributes: Handle external tool annotations like rustfmt::

gcc/rust/ChangeLog:

* util/rust-attribute-values.h: Add RUSTFMT value.
* util/rust-attributes.cc: Define the attribute.
* util/rust-attributes.h (enum CompilerPass): Add EXTERNAL variant.
* expand/rust-macro-builtins.cc: Fix formatting.

Diff:
---
 gcc/rust/expand/rust-macro-builtins.cc | 1 -
 gcc/rust/util/rust-attribute-values.h  | 2 ++
 gcc/rust/util/rust-attributes.cc   | 3 ++-
 gcc/rust/util/rust-attributes.h| 5 -
 4 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/gcc/rust/expand/rust-macro-builtins.cc 
b/gcc/rust/expand/rust-macro-builtins.cc
index a1388fb1dfb3..8b406fff9e63 100644
--- a/gcc/rust/expand/rust-macro-builtins.cc
+++ b/gcc/rust/expand/rust-macro-builtins.cc
@@ -83,7 +83,6 @@ const BiMap MacroBuiltin::builtins 
= {{
   {"Ord", BuiltinMacro::Ord},
   {"PartialOrd", BuiltinMacro::PartialOrd},
   {"Hash", BuiltinMacro::Hash},
-
 }};
 
 AST::MacroTranscriberFunc
diff --git a/gcc/rust/util/rust-attribute-values.h 
b/gcc/rust/util/rust-attribute-values.h
index 50ccb4ab6dc0..47e6a175396c 100644
--- a/gcc/rust/util/rust-attribute-values.h
+++ b/gcc/rust/util/rust-attribute-values.h
@@ -83,6 +83,8 @@ public:
   static constexpr auto &FUNDAMENTAL = "fundamental";
 
   static constexpr auto &NON_EXHAUSTIVE = "non_exhaustive";
+
+  static constexpr auto &RUSTFMT = "rustfmt";
 };
 } // namespace Values
 } // namespace Rust
diff --git a/gcc/rust/util/rust-attributes.cc b/gcc/rust/util/rust-attributes.cc
index 7ddb476bbe6f..c77e99c1ca5a 100644
--- a/gcc/rust/util/rust-attributes.cc
+++ b/gcc/rust/util/rust-attributes.cc
@@ -94,7 +94,8 @@ static const BuiltinAttrDefinition __definitions[]
  {Attrs::RUSTC_ON_UNIMPLEMENTED, STATIC_ANALYSIS},
 
  {Attrs::FUNDAMENTAL, TYPE_CHECK},
- {Attrs::NON_EXHAUSTIVE, TYPE_CHECK}};
+ {Attrs::NON_EXHAUSTIVE, TYPE_CHECK},
+ {Attrs::RUSTFMT, EXTERNAL}};
 
 BuiltinAttributeMappings *
 BuiltinAttributeMappings::get ()
diff --git a/gcc/rust/util/rust-attributes.h b/gcc/rust/util/rust-attributes.h
index 7e7cd2c3c633..7c7a1fc3f6b1 100644
--- a/gcc/rust/util/rust-attributes.h
+++ b/gcc/rust/util/rust-attributes.h
@@ -40,7 +40,10 @@ enum CompilerPass
   HIR_LOWERING,
   TYPE_CHECK,
   STATIC_ANALYSIS,
-  CODE_GENERATION
+  CODE_GENERATION,
+
+  // External Rust tooling attributes, like #[rustfmt::skip]
+  EXTERNAL,
 
   // Do we need to add something here for const fns?
 };


[gcc(refs/users/meissner/heads/work201-submit)] Add ChangeLog.submit and update REVISION.

2025-04-14 Thread Michael Meissner via Gcc-cvs
https://gcc.gnu.org/g:23957de2218d4f56ffabac9888d4694fb2f28869

commit 23957de2218d4f56ffabac9888d4694fb2f28869
Author: Michael Meissner 
Date:   Mon Apr 14 15:18:41 2025 -0400

Add ChangeLog.submit and update REVISION.

2025-04-14  Michael Meissner  

gcc/

* ChangeLog.submit: New file for branch.
* REVISION: Update.

Diff:
---
 gcc/ChangeLog.submit | 5 +
 gcc/REVISION | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/gcc/ChangeLog.submit b/gcc/ChangeLog.submit
new file mode 100644
index ..8cada4ac5598
--- /dev/null
+++ b/gcc/ChangeLog.submit
@@ -0,0 +1,5 @@
+ Branch work201-submit, baseline 
+
+2025-04-14   Michael Meissner  
+
+   Clone branch
diff --git a/gcc/REVISION b/gcc/REVISION
index 5f8715c4844d..e53943b0c13c 100644
--- a/gcc/REVISION
+++ b/gcc/REVISION
@@ -1 +1 @@
-work201 branch
+work201-submit branch


[gcc r15-9418] Add testcase for PR lto/119792

2025-04-14 Thread Eric Botcazou via Gcc-cvs
https://gcc.gnu.org/g:ec4bf5b6c22e205c9396fc7250da971ec75e3aa3

commit r15-9418-gec4bf5b6c22e205c9396fc7250da971ec75e3aa3
Author: Eric Botcazou 
Date:   Mon Apr 14 09:23:30 2025 +0200

Add testcase for PR lto/119792

It demonstrates a serious LTO breakage for the Ada language.

gcc/testsuite/
PR lto/119792
* gnat.dg/lto29.adb: New test.
* gnat.dg/lto29_pkg.ads: New helper.

Diff:
---
 gcc/testsuite/gnat.dg/lto29.adb |  9 +
 gcc/testsuite/gnat.dg/lto29_pkg.ads | 15 +++
 2 files changed, 24 insertions(+)

diff --git a/gcc/testsuite/gnat.dg/lto29.adb b/gcc/testsuite/gnat.dg/lto29.adb
new file mode 100644
index ..44f556f04b6e
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/lto29.adb
@@ -0,0 +1,9 @@
+-- { dg-do run }
+-- { dg-options "-O -flto" { target lto } }
+
+with Lto29_Pkg;
+
+procedure Lto29 is
+begin
+  null;
+end;
diff --git a/gcc/testsuite/gnat.dg/lto29_pkg.ads 
b/gcc/testsuite/gnat.dg/lto29_pkg.ads
new file mode 100644
index ..6008dc58a74e
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/lto29_pkg.ads
@@ -0,0 +1,15 @@
+with Ada.Strings.Bounded;
+
+package Lto29_Pkg is
+
+  package M is new Ada.Strings.Bounded.Generic_Bounded_Length (10);
+
+  type T is new M.Bounded_String;
+
+  Null_T : constant T;
+
+private
+
+  Null_T : constant T := To_Bounded_String ("");
+
+end Lto29_Pkg;


[gcc r15-9419] Fix implementation of Win32 thread model for C++ modules

2025-04-14 Thread Eric Botcazou via Gcc-cvs
https://gcc.gnu.org/g:5c82694319a168a1369bafa4c6e21b664a5d0bc8

commit r15-9419-g5c82694319a168a1369bafa4c6e21b664a5d0bc8
Author: Eric Botcazou 
Date:   Mon Apr 14 09:32:20 2025 +0200

Fix implementation of Win32 thread model for C++ modules

This applies the same magic to config/i386/gthr-win32.h that was applied
to gthr-posix.h (https://gcc.gnu.org/cgit/gcc/commit/?id=6a4d1c374eed17)
for the sake of C++ modules.

libgcc/
PR target/119673
* config/i386/gthr-win32.h (__GTHREAD_ALWAYS_INLINE): New macro.
(__GTHREAD_INLINE): Likewise.
(__GTHR_W32_InterlockedCompareExchange): Delete.
(__gthread_active_p): Mark as __GTHREAD_INLINE instead of
static inline.
(__gthread_create): Likewise.
(__gthread_join): Likewise.
(__gthread_self): Likewise.
(__gthread_detach): Likewise.
(__gthread_equal): Likewise.
(__gthread_yield): Likewise.
(__gthread_once): Likewise.
(__gthread_key_create): Likewise.
(__gthread_key_delete): Likewise.
(__gthread_getspecific): Likewise.
(__gthread_setspecific): Likewise.
(__gthread_mutex_init_function): Likewise.
(__gthread_mutex_destroy): Likewise.
(__gthread_mutex_lock): Likewise.
(__gthread_mutex_trylock): Likewise.
(__gthread_mutex_timedlock): Likewise.
(__gthread_mutex_unlock): Likewise.
(__gthread_recursive_mutex_trylock): Likewise.
(__gthread_cond_init_function): Likewise.
(__gthread_cond_broadcast): Likewise.
(__gthread_cond_signal): Likewise.
(__gthread_cond_wait): Likewise.
(__gthread_cond_timedwait): Likewise.
(__GTHREAD_WIN32_INLINE): Likewise.
(__GTHREAD_WIN32_COND_INLINE): Likewise.
(__gthread_recursive_mutex_init_function): Likewise.
(__gthread_recursive_mutex_destroy): Likewise.
(__gthread_recursive_mutex_lock): Likewise.
(__gthread_recursive_mutex_unlock): Likewise.
(__gthread_cond_destroy): Likewise.
(__gthread_cond_wait_recursive): Likewise.

Diff:
---
 libgcc/config/i386/gthr-win32.h | 81 +++--
 1 file changed, 46 insertions(+), 35 deletions(-)

diff --git a/libgcc/config/i386/gthr-win32.h b/libgcc/config/i386/gthr-win32.h
index 98e11b42e5c5..34988d4c3df6 100644
--- a/libgcc/config/i386/gthr-win32.h
+++ b/libgcc/config/i386/gthr-win32.h
@@ -71,6 +71,21 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If 
not, see
 #error Timed lock primitives are not supported on Windows targets
 #endif
 
+#ifdef __has_attribute
+# if __has_attribute(__always_inline__)
+#  define __GTHREAD_ALWAYS_INLINE __attribute__((__always_inline__))
+# endif
+#endif
+#ifndef __GTHREAD_ALWAYS_INLINE
+# define __GTHREAD_ALWAYS_INLINE
+#endif
+
+#ifdef __cplusplus
+# define __GTHREAD_INLINE inline __GTHREAD_ALWAYS_INLINE
+#else
+# define __GTHREAD_INLINE static inline
+#endif
+
 /* Make sure CONST_CAST2 (origin in system.h) is declared.  */
 #ifndef CONST_CAST2
 #ifdef __cplusplus
@@ -398,11 +413,7 @@ extern int _CRT_MT;
 extern int __mingwthr_key_dtor (unsigned long, void (*) (void *));
 #endif /* _WIN32 && !__CYGWIN__ */
 
-/* __GTHR_W32_InterlockedCompareExchange is left over from win95,
-   which did not support InterlockedCompareExchange. */
-#define __GTHR_W32_InterlockedCompareExchange InterlockedCompareExchange
-
-static inline int
+__GTHREAD_INLINE int
 __gthread_active_p (void)
 {
 #ifdef MINGW32_SUPPORTS_MT_EH
@@ -438,20 +449,20 @@ extern int __gthr_win32_cond_timedwait (__gthread_cond_t 
*, __gthread_mutex_t *,
const __gthread_time_t *);
 #endif
 
-static inline int
+__GTHREAD_INLINE int
 __gthread_create (__gthread_t *__thr, void *(*__func) (void*),
  void *__args)
 {
   return __gthr_win32_create (__thr, __func, __args);
 }
 
-static inline int
+__GTHREAD_INLINE int
 __gthread_join (__gthread_t __thr, void **__value_ptr)
 {
   return __gthr_win32_join (__thr, __value_ptr);
 }
 
-static inline __gthread_t
+__GTHREAD_INLINE __gthread_t
 __gthread_self (void)
 {
   return __gthr_win32_self ();
@@ -463,25 +474,25 @@ __gthread_self (void)
Only stubs are exposed to avoid polluting the C++ namespace with
Win32 API definitions.  */
 
-static inline int
+__GTHREAD_INLINE int
 __gthread_detach (__gthread_t __thr)
 {
   return __gthr_win32_detach (__thr);
 }
 
-static inline int
+__GTHREAD_INLINE int
 __gthread_equal (__gthread_t __thr1, __gthread_t __thr2)
 {
   return __gthr_win32_equal (__thr1, __thr2);
 }
 
-static inline int
+__GTHREAD_INLINE int
 __gthread_yield (void)
 {
   return __gthr_win32_yield ();
 }
 
-static inline int
+__GTHREAD_INLINE int
 __gthread_once (__gthread_once_t *__once, void (*__func) (void))
 {
   i

[gcc r15-9426] ipa: Record and stream result types of arithemetic jump functions

2025-04-14 Thread Martin Jambor via Gcc-cvs
https://gcc.gnu.org/g:f33d2e6b532304d487193667e6b5d8f8d7df2bf4

commit r15-9426-gf33d2e6b532304d487193667e6b5d8f8d7df2bf4
Author: Martin Jambor 
Date:   Mon Apr 14 14:21:14 2025 +0200

ipa: Record and stream result types of arithemetic jump functions

In order to replace the use of somewhat unweildy
expr_type_first_operand_type_p we need to record and stream the types
of results of operations recorded in arithmetic jump functions.  This
is necessary so that we can then simulate them at the IPA stage with
the corresponding precision and signedness.  This patch does the
recorsing and streaming, the following one adds the use of the date.

Per Honza's request this version also checks that we do not put VLA
types into the global LTO stream, even though I was not able to
actually craft a test-case that would do that without them.

gcc/ChangeLog:

2025-04-11  Martin Jambor  

PR ipa/118097
PR ipa/118785
PR ipa/119318
* lto-streamer.h (lto_variably_modified_type_p): Declare.
* ipa-prop.h (ipa_pass_through_data): New field op_type.
(ipa_get_jf_pass_through_op_type): New function.
* ipa-prop.cc: Include lto-streamer.h.
(ipa_dump_jump_function): Dump also pass-through
operation types, if any.  Dump pass-through operands only if not 
NULL.
(ipa_set_jf_simple_pass_through): Set op_type accordingly.
(compute_complex_assign_jump_func): Set op_type of arithmetic
pass-through jump_functions.
(analyze_agg_content_value): Update lhs when walking assighment
copies.  Set op_type of aggregate arithmetic pass-through
jump_functions.
(update_jump_functions_after_inlining): Also transfer the operation
type from the source arithmentic pass-through jump function to the
destination jump function.
(ipa_write_jump_function): Stream also the op_type when necessary.
(ipa_read_jump_function): Likewise.
(ipa_agg_pass_through_jf_equivalent_p): Also compare operation 
types.
* lto-streamer-out.cc (lto_variably_modified_type_p): Make public.

Diff:
---
 gcc/ipa-prop.cc | 76 -
 gcc/ipa-prop.h  | 15 ++
 gcc/lto-streamer-out.cc |  2 +-
 gcc/lto-streamer.h  |  1 +
 4 files changed, 80 insertions(+), 14 deletions(-)

diff --git a/gcc/ipa-prop.cc b/gcc/ipa-prop.cc
index a120f942dc25..49d68ab044b7 100644
--- a/gcc/ipa-prop.cc
+++ b/gcc/ipa-prop.cc
@@ -60,6 +60,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "gimple-range.h"
 #include "value-range-storage.h"
 #include "vr-values.h"
+#include "lto-streamer.h"
 
 /* Function summary where the parameter infos are actually stored. */
 ipa_node_params_t *ipa_node_params_sum = NULL;
@@ -454,7 +455,11 @@ ipa_dump_jump_function (FILE *f, ipa_jump_func *jump_func,
   if (jump_func->value.pass_through.operation != NOP_EXPR)
{
  fprintf (f, " ");
- print_generic_expr (f, jump_func->value.pass_through.operand);
+ if (jump_func->value.pass_through.operand)
+   print_generic_expr (f, jump_func->value.pass_through.operand);
+ fprintf (f, " (in type ");
+ print_generic_expr (f, jump_func->value.pass_through.op_type);
+ fprintf (f, ")");
}
   if (jump_func->value.pass_through.agg_preserved)
fprintf (f, ", agg_preserved");
@@ -510,7 +515,11 @@ ipa_dump_jump_function (FILE *f, ipa_jump_func *jump_func,
  if (item->value.pass_through.operation != NOP_EXPR)
{
  fprintf (f, " ");
- print_generic_expr (f, item->value.pass_through.operand);
+ if (item->value.pass_through.operand)
+   print_generic_expr (f, item->value.pass_through.operand);
+ fprintf (f, " (in type ");
+ print_generic_expr (f, jump_func->value.pass_through.op_type);
+ fprintf (f, ")");
}
}
  else if (item->jftype == IPA_JF_CONST)
@@ -682,6 +691,7 @@ ipa_set_jf_simple_pass_through (struct ipa_jump_func 
*jfunc, int formal_id,
 {
   jfunc->type = IPA_JF_PASS_THROUGH;
   jfunc->value.pass_through.operand = NULL_TREE;
+  jfunc->value.pass_through.op_type = NULL_TREE;
   jfunc->value.pass_through.formal_id = formal_id;
   jfunc->value.pass_through.operation = NOP_EXPR;
   jfunc->value.pass_through.agg_preserved = agg_preserved;
@@ -692,10 +702,11 @@ ipa_set_jf_simple_pass_through (struct ipa_jump_func 
*jfunc, int formal_id,
 
 static void
 ipa_set_jf_unary_pass_through (struct ipa_jump_func *jfunc, int formal_id,
-  enum tree_code operation)
+  enum tree_code operation, tree op_type)
 {
   jfunc->type = IPA_JF_PASS_THROUGH;
   j

[gcc r15-9428] ipa-cp: Make dumping of widest_ints even more sane

2025-04-14 Thread Martin Jambor via Gcc-cvs
https://gcc.gnu.org/g:044d0d1ee1a61c21670068485d4a250edfbb695a

commit r15-9428-g044d0d1ee1a61c21670068485d4a250edfbb695a
Author: Martin Jambor 
Date:   Mon Apr 14 14:21:15 2025 +0200

ipa-cp: Make dumping of widest_ints even more sane

This patch just introduces a form of dumping of widest ints that only
have zeros in the lowest 128 bits so that instead of printing
thousands of f's the output looks like:

   Bits: value = 0x, mask = all ones folled by 
0x

and then makes sure we use the function not only to print bits but
also to print masks where values like these can also occur.

gcc/ChangeLog:

2025-03-21  Martin Jambor  

* ipa-cp.cc (ipcp_print_widest_int): Also add a truncated form of
dumping of widest ints which only have zeros in the lowest 128 bits.
Update the comment.
(ipcp_bits_lattice::print): Also dump the mask using
ipcp_print_widest_int.
(ipcp_store_vr_results): Likewise.

Diff:
---
 gcc/ipa-cp.cc | 15 +++
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/gcc/ipa-cp.cc b/gcc/ipa-cp.cc
index fd2c4cca1365..637bc49f0482 100644
--- a/gcc/ipa-cp.cc
+++ b/gcc/ipa-cp.cc
@@ -307,14 +307,21 @@ ipcp_lattice::print (FILE * f, bool 
dump_sources, bool dump_benefits)
 fprintf (f, "\n");
 }
 
-/* If VALUE has all bits set to one, print "-1" to F, otherwise simply print it
-   hexadecimally to F. */
+/* Print VALUE to F in a form which in usual cases does not take thousands of
+   characters. */
 
 static void
 ipcp_print_widest_int (FILE *f, const widest_int &value)
 {
   if (wi::eq_p (wi::bit_not (value), 0))
 fprintf (f, "-1");
+  else if (wi::eq_p (wi::bit_not (wi::bit_or (value,
+ wi::sub (wi::lshift (1, 128),
+  1))), 0))
+{
+  fprintf (f, "all ones folled by ");
+  print_hex (wi::bit_and (value, wi::sub (wi::lshift (1, 128), 1)), f);
+}
   else
 print_hex (value, f);
 }
@@ -331,7 +338,7 @@ ipcp_bits_lattice::print (FILE *f)
   fprintf (f, " Bits: value = ");
   ipcp_print_widest_int (f, get_value ());
   fprintf (f, ", mask = ");
-  print_hex (get_mask (), f);
+  ipcp_print_widest_int (f, get_mask ());
   fprintf (f, "\n");
 }
 }
@@ -6437,7 +6444,7 @@ ipcp_store_vr_results (void)
  fprintf (dump_file, " param %i: value = ", i);
  ipcp_print_widest_int (dump_file, bits->get_value ());
  fprintf (dump_file, ", mask = ");
- print_hex (bits->get_mask (), dump_file);
+ ipcp_print_widest_int (dump_file, bits->get_mask ());
  fprintf (dump_file, "\n");
}
 }


[gcc r15-9430] ipa-cp: Use the collected pass-through types to propgate constants (PR118097)

2025-04-14 Thread Martin Jambor via Gcc-cvs
https://gcc.gnu.org/g:6b6611f81476b6375c90859d85331c2981a2ce51

commit r15-9430-g6b6611f81476b6375c90859d85331c2981a2ce51
Author: Martin Jambor 
Date:   Mon Apr 14 14:21:15 2025 +0200

ipa-cp: Use the collected pass-through types to propgate constants 
(PR118097)

This patch revisits the fix for PR 118097 and instead of deducing the
necessary operation type it just uses the value collected and streamed
by an earlier patch.

It is bigger than the ones for propagating value ranges and known bits
because we track constants both in parameters themselves and also in
memory they point to or within aggregates, we clone functions for them
and we do fancy things for some types of recursive calls.

In the case of constants in aggregates or passed by reference, the
situation should not change because the code creating jump functions
for them does not allow type-casts, unlike for the plain ones.
However, this patch changes how we handle them for the sake of
consistency and also so that we can try and eliminate this limitation
in the next stage 1.

gcc/ChangeLog:

2025-03-20  Martin Jambor  

PR ipa/118097
* ipa-cp.cc (ipa_get_jf_arith_result): Require res_operand for
anything except NOP_EXPR or ADDR_EXPR, document it and remove the 
code
trying to deduce it.
(ipa_value_from_jfunc): Use the stored and streamed type of 
arithmetic
pass-through functions.
(ipa_agg_value_from_jfunc): Use the stored and streamed type of
arithmetic pass-through functions, convert to the type used to store
the value if necessary.
(get_val_across_arith_op): New parameter op_type, pass it to
ipa_get_jf_arith_result.
(propagate_vals_across_arith_jfunc): New parameter op_type, pass it 
to
get_val_across_arith_op.
(propagate_vals_across_pass_through): Use the stored and streamed 
type
of arithmetic pass-through functions.
(propagate_aggregate_lattice): Likewise.
(push_agg_values_for_index_from_edge): Use the stored and streamed
type of arithmetic pass-through functions, convert to the type used 
to
store the value if necessary.

Diff:
---
 gcc/ipa-cp.cc | 94 +--
 1 file changed, 52 insertions(+), 42 deletions(-)

diff --git a/gcc/ipa-cp.cc b/gcc/ipa-cp.cc
index 21033c666bf4..26b1496f29bb 100644
--- a/gcc/ipa-cp.cc
+++ b/gcc/ipa-cp.cc
@@ -1478,10 +1478,12 @@ ipacp_value_safe_for_type (tree param_type, tree value)
 return NULL_TREE;
 }
 
-/* Return the result of a (possibly arithmetic) operation on the constant value
-   INPUT.  OPERAND is 2nd operand for binary operation.  RES_TYPE is the type
-   in which any operation is to be performed.  Return NULL_TREE if that cannot
-   be determined or be considered an interprocedural invariant.  */
+/* Return the result of a (possibly arithmetic) operation determined by OPCODE
+   on the constant value INPUT.  OPERAND is 2nd operand for binary operation
+   and is required for binary operations.  RES_TYPE, required when opcode is
+   not NOP_EXPR, is the type in which any operation is to be performed.  Return
+   NULL_TREE if that cannot be determined or be considered an interprocedural
+   invariant.  */
 
 static tree
 ipa_get_jf_arith_result (enum tree_code opcode, tree input, tree operand,
@@ -1502,16 +1504,6 @@ ipa_get_jf_arith_result (enum tree_code opcode, tree 
input, tree operand,
return NULL_TREE;
 }
 
-  if (!res_type)
-{
-  if (TREE_CODE_CLASS (opcode) == tcc_comparison)
-   res_type = boolean_type_node;
-  else if (expr_type_first_operand_type_p (opcode))
-   res_type = TREE_TYPE (input);
-  else
-   return NULL_TREE;
-}
-
   if (TREE_CODE_CLASS (opcode) == tcc_unary)
 res = fold_unary (opcode, res_type, input);
   else
@@ -1595,7 +1587,10 @@ ipa_value_from_jfunc (class ipa_node_params *info, 
struct ipa_jump_func *jfunc,
return NULL_TREE;
  enum tree_code opcode = ipa_get_jf_pass_through_operation (jfunc);
  tree op2 = ipa_get_jf_pass_through_operand (jfunc);
- tree cstval = ipa_get_jf_arith_result (opcode, input, op2, NULL_TREE);
+ tree op_type
+   = (opcode == NOP_EXPR) ? NULL_TREE
+   : ipa_get_jf_pass_through_op_type (jfunc);
+ tree cstval = ipa_get_jf_arith_result (opcode, input, op2, op_type);
  return ipacp_value_safe_for_type (parm_type, cstval);
}
   else
@@ -1905,10 +1900,11 @@ ipa_agg_value_from_jfunc (ipa_node_params *info, 
cgraph_node *node,
return NULL_TREE;
 }
 
-  return ipa_get_jf_arith_result (item->value.pass_through.operation,
- value,
- item->value.pass_through.operand,
-   

[gcc r15-9420] driver: On linux hosts disable ASLR during -freport-bug [PR119727]

2025-04-14 Thread Jakub Jelinek via Gcc-cvs
https://gcc.gnu.org/g:5a32e85810d33dc46b1b5fe2803ee787d40709d5

commit r15-9420-g5a32e85810d33dc46b1b5fe2803ee787d40709d5
Author: Jakub Jelinek 
Date:   Mon Apr 14 10:18:13 2025 +0200

driver: On linux hosts disable ASLR during -freport-bug [PR119727]

Andi had a useful comment that even with the PR119727 workaround to
ignore differences in libbacktrace printed addresses, it is still better
to turn off ASLR when easily possible, e.g. in case some address leaks
in somewhere in the ICE message elsewhere, or to verify the ICE doesn't
depend on a particular library/binary load addresses.

The following patch adds a configure check and uses personality syscall
to turn off randomization for further -freport-bug subprocesses.

2025-04-14  Jakub Jelinek  

PR driver/119727
* configure.ac (HOST_HAS_PERSONALITY_ADDR_NO_RANDOMIZE): New check.
* gcc.cc: Include sys/personality.h if
HOST_HAS_PERSONALITY_ADDR_NO_RANDOMIZE is defined.
(try_generate_repro): Call
personality (personality (0xU) | ADDR_NO_RANDOMIZE)
if HOST_HAS_PERSONALITY_ADDR_NO_RANDOMIZE is defined.
* config.in: Regenerate.
* configure: Regenerate.

Diff:
---
 gcc/config.in|  7 +++
 gcc/configure| 40 ++--
 gcc/configure.ac | 15 +++
 gcc/gcc.cc   |  7 +++
 4 files changed, 67 insertions(+), 2 deletions(-)

diff --git a/gcc/config.in b/gcc/config.in
index 7c89cab7717f..a79c51adb2b3 100644
--- a/gcc/config.in
+++ b/gcc/config.in
@@ -2320,6 +2320,13 @@
 #endif
 
 
+/* Define if personality and ADDR_NO_RANDOMIZE are declared in
+   sys/personality.h. */
+#ifndef USED_FOR_TARGET
+#undef HOST_HAS_PERSONALITY_ADDR_NO_RANDOMIZE
+#endif
+
+
 /* Define which stat syscall is able to handle 64bit indodes. */
 #ifndef USED_FOR_TARGET
 #undef HOST_STAT_FOR_64BIT_INODES
diff --git a/gcc/configure b/gcc/configure
index ab6bec1f0ae7..821f8b44bc6a 100755
--- a/gcc/configure
+++ b/gcc/configure
@@ -12694,6 +12694,42 @@ $as_echo "#define HOST_HAS_O_NONBLOCK 1" >>confdefs.h
 
 fi
 
+# Check if personality and ADDR_NO_RANDOMIZE are declared
+# in sys/personality.h
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for personality 
ADDR_NO_RANDOMIZE" >&5
+$as_echo_n "checking for personality ADDR_NO_RANDOMIZE... " >&6; }
+if ${ac_cv_personality_addr_no_randomize+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#include 
+int
+main ()
+{
+
+personality (personality (0xU) | ADDR_NO_RANDOMIZE);
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+  ac_cv_personality_addr_no_randomize=yes
+else
+  ac_cv_personality_addr_no_randomize=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: 
$ac_cv_personality_addr_no_randomize" >&5
+$as_echo "$ac_cv_personality_addr_no_randomize" >&6; }
+if test $ac_cv_personality_addr_no_randomize = yes; then
+
+$as_echo "#define HOST_HAS_PERSONALITY_ADDR_NO_RANDOMIZE 1" >>confdefs.h
+
+fi
+
 
 # C++ Modules would like some networking features to provide the mapping
 # server.  You can still use modules without them though.
@@ -21484,7 +21520,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 21487 "configure"
+#line 21523 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -21590,7 +21626,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 21593 "configure"
+#line 21629 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
diff --git a/gcc/configure.ac b/gcc/configure.ac
index fca0579574fa..3d0a4e6f8f55 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -1781,6 +1781,21 @@ if test $ac_cv_have_decl_O_NONBLOCK = yes; then
   [Define if O_NONBLOCK supported by fcntl.])
 fi
 
+# Check if personality and ADDR_NO_RANDOMIZE are declared
+# in sys/personality.h
+AC_CACHE_CHECK(for personality ADDR_NO_RANDOMIZE,
+  ac_cv_personality_addr_no_randomize, [
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+#include ]], [[
+personality (personality (0xU) | ADDR_NO_RANDOMIZE);]])],
+[ac_cv_personality_addr_no_randomize=yes],
+[ac_cv_personality_addr_no_randomize=no])])
+if test $ac_cv_personality_addr_no_randomize = yes; then
+  AC_DEFINE(HOST_HAS_PERSONALITY_ADDR_NO_RANDOMIZE, 1,
+  [Define if personality and ADDR_NO_RANDOMIZE are declared in
+sys/personality.h.])
+fi
+
 
 # C++ Modules would like some networking features to provide the mapping
 # server.  You can still use modules without them though.
diff --git a/gcc/gcc.cc b/gcc/gcc.cc
index 9064671b86cf..4fd87f2c4a13 100644
--- a/gcc/gcc.cc
+++ b/gcc/gcc.cc
@@ -30,6 +30,9 @@ compilation is specified by a string called a

[gcc r15-9423] libstdc++: Use UTF-32BE as wide encoding for big-endian machines [PR119725]

2025-04-14 Thread Tomasz Kaminski via Libstdc++-cvs
https://gcc.gnu.org/g:c2f1dda34defe739db6016dda97a6516243372e6

commit r15-9423-gc2f1dda34defe739db6016dda97a6516243372e6
Author: Tomasz Kamiński 
Date:   Mon Apr 14 08:43:58 2025 +0200

libstdc++: Use UTF-32BE as wide encoding for big-endian machines [PR119725]

This changes the `dg-options` line so UTF-32 with byte order native to the
machine is used as wide encoding.

We still do not handle mismatch in the byte order of the Unicode encodings
(UTF32-BE on little-endian machines). This would require larger changes,
as for example `unicode-data.h` tables are encoded with native byte order.

PR libstdc++/119725

libstdc++-v3/ChangeLog:

* testsuite/std/format/debug.cc: Updated dg-options.
* testsuite/std/format/debug_nonunicode.cc: Updated dg-options.

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

Diff:
---
 libstdc++-v3/testsuite/std/format/debug.cc| 3 ++-
 libstdc++-v3/testsuite/std/format/debug_nonunicode.cc | 2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/libstdc++-v3/testsuite/std/format/debug.cc 
b/libstdc++-v3/testsuite/std/format/debug.cc
index 07cd1e0e349e..71bb7f4a0fe8 100644
--- a/libstdc++-v3/testsuite/std/format/debug.cc
+++ b/libstdc++-v3/testsuite/std/format/debug.cc
@@ -1,4 +1,5 @@
-// { dg-options "-fexec-charset=UTF-8 -fwide-exec-charset=UTF-32LE 
-DUNICODE_ENC" }
+// { dg-options "-fexec-charset=UTF-8 -fwide-exec-charset=UTF-32LE 
-DUNICODE_ENC" { target le } }
+// { dg-options "-fexec-charset=UTF-8 -fwide-exec-charset=UTF-32BE 
-DUNICODE_ENC" { target be } }
 // { dg-do run { target c++23 } }
 // { dg-add-options no_pch }
 
diff --git a/libstdc++-v3/testsuite/std/format/debug_nonunicode.cc 
b/libstdc++-v3/testsuite/std/format/debug_nonunicode.cc
index 5c03171d71a1..2ac7e757ea8d 100644
--- a/libstdc++-v3/testsuite/std/format/debug_nonunicode.cc
+++ b/libstdc++-v3/testsuite/std/format/debug_nonunicode.cc
@@ -1,4 +1,4 @@
-// { dg-options "-fexec-charset=ISO8859-1 -fwide-exec-charset=UTF-32LE" }
+// { dg-options "-fexec-charset=ISO8859-1" }
 // { dg-do run { target c++23 } }
 // { dg-add-options no_pch }


[gcc r14-11603] Add testcase for PR lto/119792

2025-04-14 Thread Eric Botcazou via Gcc-cvs
https://gcc.gnu.org/g:569f826774a90e18d6a020a30efd6075587ebcb3

commit r14-11603-g569f826774a90e18d6a020a30efd6075587ebcb3
Author: Eric Botcazou 
Date:   Mon Apr 14 09:23:30 2025 +0200

Add testcase for PR lto/119792

It demonstrates a serious LTO breakage for the Ada language.

gcc/testsuite/
PR lto/119792
* gnat.dg/lto29.adb: New test.
* gnat.dg/lto29_pkg.ads: New helper.

Diff:
---
 gcc/testsuite/gnat.dg/lto29.adb |  9 +
 gcc/testsuite/gnat.dg/lto29_pkg.ads | 15 +++
 2 files changed, 24 insertions(+)

diff --git a/gcc/testsuite/gnat.dg/lto29.adb b/gcc/testsuite/gnat.dg/lto29.adb
new file mode 100644
index ..44f556f04b6e
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/lto29.adb
@@ -0,0 +1,9 @@
+-- { dg-do run }
+-- { dg-options "-O -flto" { target lto } }
+
+with Lto29_Pkg;
+
+procedure Lto29 is
+begin
+  null;
+end;
diff --git a/gcc/testsuite/gnat.dg/lto29_pkg.ads 
b/gcc/testsuite/gnat.dg/lto29_pkg.ads
new file mode 100644
index ..6008dc58a74e
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/lto29_pkg.ads
@@ -0,0 +1,15 @@
+with Ada.Strings.Bounded;
+
+package Lto29_Pkg is
+
+  package M is new Ada.Strings.Bounded.Generic_Bounded_Length (10);
+
+  type T is new M.Bounded_String;
+
+  Null_T : constant T;
+
+private
+
+  Null_T : constant T := To_Bounded_String ("");
+
+end Lto29_Pkg;


[gcc r15-9424] tree-optimization/119757 - reject mixed mask/non-mask ldst SLP

2025-04-14 Thread Richard Biener via Gcc-cvs
https://gcc.gnu.org/g:2f334a10bce0409c2cb4616496aafcb78f7db3d8

commit r15-9424-g2f334a10bce0409c2cb4616496aafcb78f7db3d8
Author: Richard Biener 
Date:   Mon Apr 14 12:44:02 2025 +0200

tree-optimization/119757 - reject mixed mask/non-mask ldst SLP

The following makes sure to not mix masked/non-masked stmts when
forming a SLP node.

PR tree-optimization/119757
* tree-vect-slp.cc (vect_build_slp_tree_1): Record and compare
whether a stmt uses a maks.

* gcc.dg/vect/pr119757.c: New testcase.

Diff:
---
 gcc/testsuite/gcc.dg/vect/pr119757.c | 17 +
 gcc/tree-vect-slp.cc | 24 
 2 files changed, 33 insertions(+), 8 deletions(-)

diff --git a/gcc/testsuite/gcc.dg/vect/pr119757.c 
b/gcc/testsuite/gcc.dg/vect/pr119757.c
new file mode 100644
index ..86442998628b
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/pr119757.c
@@ -0,0 +1,17 @@
+/* { dg-do compile } */
+
+void base64_encode(const char *table64,
+   const char *inputbuff, int insize,
+   char * __restrict output)
+{
+  const unsigned char *in = (const unsigned char *)inputbuff;
+
+  while(insize >= 3) {
+*output++ = table64[ in[0] >> 2 ];
+*output++ = table64[ ((in[0] & 0x03) << 4) | (in[1] >> 4) ];
+*output++ = table64[ ((in[1] & 0x0F) << 2) | ((in[2] & 0xC0) >> 6) ];
+*output++ = table64[ in[2] & 0x3F ];
+insize -= 3;
+in += 3;
+  }
+}
diff --git a/gcc/tree-vect-slp.cc b/gcc/tree-vect-slp.cc
index ecb4a6521dec..19beeed8a3a9 100644
--- a/gcc/tree-vect-slp.cc
+++ b/gcc/tree-vect-slp.cc
@@ -1099,7 +1099,7 @@ vect_build_slp_tree_1 (vec_info *vinfo, unsigned char 
*swap,
   tree first_lhs = NULL_TREE;
   tree first_op1 = NULL_TREE;
   stmt_vec_info first_load = NULL, prev_first_load = NULL;
-  bool first_stmt_ldst_p = false;
+  bool first_stmt_ldst_p = false, first_stmt_ldst_masklen_p = false;
   bool first_stmt_phi_p = false;
   int first_reduc_idx = -1;
   bool maybe_soft_fail = false;
@@ -1133,6 +1133,7 @@ vect_build_slp_tree_1 (vec_info *vinfo, unsigned char 
*swap,
   FOR_EACH_VEC_ELT (stmts, i, stmt_info)
 {
   bool ldst_p = false;
+  bool ldst_masklen_p = false;
   bool phi_p = false;
   code_helper rhs_code = ERROR_MARK;
 
@@ -1195,17 +1196,22 @@ vect_build_slp_tree_1 (vec_info *vinfo, unsigned char 
*swap,
  else
rhs_code = CALL_EXPR;
 
- if (cfn == CFN_MASK_LOAD
- || cfn == CFN_GATHER_LOAD
- || cfn == CFN_MASK_GATHER_LOAD
- || cfn == CFN_MASK_LEN_GATHER_LOAD
- || cfn == CFN_SCATTER_STORE
- || cfn == CFN_MASK_SCATTER_STORE
- || cfn == CFN_MASK_LEN_SCATTER_STORE)
+ if (cfn == CFN_GATHER_LOAD
+ || cfn == CFN_SCATTER_STORE)
ldst_p = true;
+ else if (cfn == CFN_MASK_LOAD
+  || cfn == CFN_MASK_GATHER_LOAD
+  || cfn == CFN_MASK_LEN_GATHER_LOAD
+  || cfn == CFN_MASK_SCATTER_STORE
+  || cfn == CFN_MASK_LEN_SCATTER_STORE)
+   {
+ ldst_p = true;
+ ldst_masklen_p = true;
+   }
  else if (cfn == CFN_MASK_STORE)
{
  ldst_p = true;
+ ldst_masklen_p = true;
  rhs_code = CFN_MASK_STORE;
}
  else if (cfn == CFN_GOMP_SIMD_LANE)
@@ -1246,6 +1252,7 @@ vect_build_slp_tree_1 (vec_info *vinfo, unsigned char 
*swap,
  first_lhs = lhs;
  first_stmt_code = rhs_code;
  first_stmt_ldst_p = ldst_p;
+ first_stmt_ldst_masklen_p = ldst_masklen_p;
  first_stmt_phi_p = phi_p;
  first_reduc_idx = STMT_VINFO_REDUC_IDX (stmt_info);
 
@@ -1364,6 +1371,7 @@ vect_build_slp_tree_1 (vec_info *vinfo, unsigned char 
*swap,
  && (STMT_VINFO_GATHER_SCATTER_P (stmt_info)
  != STMT_VINFO_GATHER_SCATTER_P (first_stmt_info)))
  || first_stmt_ldst_p != ldst_p
+ || (ldst_p && first_stmt_ldst_masklen_p != ldst_masklen_p)
  || first_stmt_phi_p != phi_p)
{
  if (dump_enabled_p ())


[gcc r15-9425] libstdc++: Document thread-safety for COW std::string [PR21334]

2025-04-14 Thread Jonathan Wakely via Gcc-cvs
https://gcc.gnu.org/g:dd35f66287b7cca196a720c9641e463255dceb1c

commit r15-9425-gdd35f66287b7cca196a720c9641e463255dceb1c
Author: Jonathan Wakely 
Date:   Fri Apr 11 11:08:34 2025 +0100

libstdc++: Document thread-safety for COW std::string [PR21334]

The gcc4-compatible copy-on-write std::string does not conform to the
C++11 requirements on data race avoidance in standard containers.
Specifically, calling non-const member functions such as begin() and
data() needs to do the "copy on write" operation and so is most
definitely a modification of the object. As such, those non-const
members must not be called concurrently with any other uses of the
string object.

libstdc++-v3/ChangeLog:

PR libstdc++/21334
* doc/xml/manual/using.xml: Document that container data race
avoidance rules do not apply to COW std::string.
* doc/html/*: Regenerate.

Diff:
---
 libstdc++-v3/doc/html/manual/using_concurrency.html | 10 ++
 libstdc++-v3/doc/xml/manual/using.xml   | 12 
 2 files changed, 22 insertions(+)

diff --git a/libstdc++-v3/doc/html/manual/using_concurrency.html 
b/libstdc++-v3/doc/html/manual/using_concurrency.html
index d21f15884949..d570d3a2b84d 100644
--- a/libstdc++-v3/doc/html/manual/using_concurrency.html
+++ b/libstdc++-v3/doc/html/manual/using_concurrency.html
@@ -126,6 +126,16 @@ gcc version 4.1.2 20070925 (Red Hat 4.1.2-33)
  the container the iterator refers to (for example incrementing a
  list iterator must access the pointers between nodes, which are part
  of the container and so conflict with other accesses to the 
container).
+  
+The Copy-On-Write std::string 
implementation
+used before GCC 5 (and with
+_GLIBCXX_USE_CXX11_ABI=0)
+is not a standard container and does not conform to the data race
+avoidance rules described above. For the Copy-On-Write
+std::string, non-const member functions 
such as
+begin() are considered to be modifying 
accesses
+and so must not be used concurrently with any other accesses to the
+same object.
   Programs which follow the rules above will not encounter data
  races in library code, even when using library types which share
  state between distinct objects.  In the example below the
diff --git a/libstdc++-v3/doc/xml/manual/using.xml 
b/libstdc++-v3/doc/xml/manual/using.xml
index 7ca3a3f4b4c0..bf92c495f6d3 100644
--- a/libstdc++-v3/doc/xml/manual/using.xml
+++ b/libstdc++-v3/doc/xml/manual/using.xml
@@ -2069,6 +2069,18 @@ gcc version 4.1.2 20070925 (Red Hat 4.1.2-33)
  of the container and so conflict with other accesses to the 
container).
   
 
+  
+The Copy-On-Write std::string implementation
+used before GCC 5 (and with
+_GLIBCXX_USE_CXX11_ABI=0)
+is not a standard container and does not conform to the data race
+avoidance rules described above. For the Copy-On-Write
+std::string, non-const member functions such as
+begin() are considered to be modifying accesses
+and so must not be used concurrently with any other accesses to the
+same object.
+  
+
   Programs which follow the rules above will not encounter data
  races in library code, even when using library types which share
  state between distinct objects.  In the example below the


[gcc r14-11602] c++: Properly fold .* [PR114525]

2025-04-14 Thread Simon Martin via Gcc-cvs
https://gcc.gnu.org/g:7e79c32ac1cc84f933000d5cc45249b2eb338aad

commit r14-11602-g7e79c32ac1cc84f933000d5cc45249b2eb338aad
Author: Simon Martin 
Date:   Mon Apr 14 08:36:06 2025 +0200

c++: Properly fold .* [PR114525]

We've been miscompiling the following since r0-51314-gd6b4ea8592e338 (I
did not go compile something that old, and identified this change via
git blame, so might be wrong)

=== cut here ===
struct Foo { int x; };
Foo& get (Foo &v) { return v; }
void bar () {
  Foo v; v.x = 1;
  (true ? get (v) : get (v)).*(&Foo::x) = 2;
  // v.x still equals 1 here...
}
=== cut here ===

The problem lies in build_m_component_ref, that computes the address of
the COND_EXPR using build_address to build the representation of
  (true ? get (v) : get (v)).*(&Foo::x);
and gets something like
  &(true ? get (v) : get (v))  // #1
instead of
  (true ? &get (v) : &get (v)) // #2
and the write does not go where want it to, hence the miscompile.

This patch replaces the call to build_address by a call to
cp_build_addr_expr, which gives #2, that is properly handled.

PR c++/114525

gcc/cp/ChangeLog:

* typeck2.cc (build_m_component_ref): Call cp_build_addr_expr
instead of build_address.

gcc/testsuite/ChangeLog:

* g++.dg/expr/cond18.C: New test.

(cherry picked from commit 35ce9afc84a63fb647a90cbecb2adf3e748178be)

Diff:
---
 gcc/cp/typeck2.cc  |  2 +-
 gcc/testsuite/g++.dg/expr/cond18.C | 36 
 2 files changed, 37 insertions(+), 1 deletion(-)

diff --git a/gcc/cp/typeck2.cc b/gcc/cp/typeck2.cc
index e32a4c638c59..3adb8dec1616 100644
--- a/gcc/cp/typeck2.cc
+++ b/gcc/cp/typeck2.cc
@@ -2347,7 +2347,7 @@ build_m_component_ref (tree datum, tree component, 
tsubst_flags_t complain)
  (cp_type_quals (type)
   | cp_type_quals (TREE_TYPE (datum;
 
-  datum = build_address (datum);
+  datum = cp_build_addr_expr (datum, complain);
 
   /* Convert object to the correct base.  */
   if (binfo)
diff --git a/gcc/testsuite/g++.dg/expr/cond18.C 
b/gcc/testsuite/g++.dg/expr/cond18.C
new file mode 100644
index ..326985eed506
--- /dev/null
+++ b/gcc/testsuite/g++.dg/expr/cond18.C
@@ -0,0 +1,36 @@
+/* PR c++/114525 */
+/* { dg-do run } */
+
+struct Foo {
+  int x;
+};
+
+Foo& get (Foo& v) {
+  return v;
+}
+
+int main () {
+  bool cond = true;
+
+  /* Testcase from PR; v.x would wrongly remain equal to 1.  */
+  Foo v_ko;
+  v_ko.x = 1;
+  (cond ? get (v_ko) : get (v_ko)).*(&Foo::x) = 2;
+  if (v_ko.x != 2)
+__builtin_abort ();
+
+  /* Those would already work, i.e. x be changed to 2.  */
+  Foo v_ok_1;
+  v_ok_1.x = 1;
+  (cond ? get (v_ok_1) : get (v_ok_1)).x = 2;
+  if (v_ok_1.x != 2)
+__builtin_abort ();
+
+  Foo v_ok_2;
+  v_ok_2.x = 1;
+  get (v_ok_2).*(&Foo::x) = 2;
+  if (v_ok_2.x != 2)
+__builtin_abort ();
+
+  return 0;
+}


[gcc r15-9421] PR modula2/119779 ASM examples no longer work

2025-04-14 Thread Gaius Mulley via Gcc-cvs
https://gcc.gnu.org/g:9e0a98a47c98fd159a26de4433a3ed1d85afb8c3

commit r15-9421-g9e0a98a47c98fd159a26de4433a3ed1d85afb8c3
Author: Gaius Mulley 
Date:   Mon Apr 14 10:13:40 2025 +0100

PR modula2/119779 ASM examples no longer work

This patch introduces four dejagnu tests matching four
documentation examples.  Both asm examples are added and only built if
the x86_64 target is available.  The other two are hello world using
libc and StrIO.  The doc/gm2.texi asm examples are changed to
use eax rather than rax.

gcc/ChangeLog:

PR modula2/119779
* doc/gm2.texi (Interface to assembly language): Use eax
rather than rax in both examples.

gcc/testsuite/ChangeLog:

PR modula2/119779
* gm2.dg/doc/examples/pass/doc-examples-pass.exp: New test.
* gm2.dg/doc/examples/pass/exampleadd.mod: New test.
* gm2.dg/doc/examples/pass/exampleadd2.mod: New test.
* gm2.dg/doc/examples/pass/hello.mod: New test.
* gm2.dg/doc/examples/pass/hellopim.mod: New test.

Signed-off-by: Gaius Mulley 

Diff:
---
 gcc/doc/gm2.texi   |  8 +++---
 .../gm2.dg/doc/examples/pass/doc-examples-pass.exp | 18 
 .../gm2.dg/doc/examples/pass/exampleadd.mod| 32 ++
 .../gm2.dg/doc/examples/pass/exampleadd2.mod   | 32 ++
 gcc/testsuite/gm2.dg/doc/examples/pass/hello.mod   | 10 +++
 .../gm2.dg/doc/examples/pass/hellopim.mod  | 10 +++
 6 files changed, 106 insertions(+), 4 deletions(-)

diff --git a/gcc/doc/gm2.texi b/gcc/doc/gm2.texi
index 8baee24f14e0..cb52e8c0d3e4 100644
--- a/gcc/doc/gm2.texi
+++ b/gcc/doc/gm2.texi
@@ -2699,10 +2699,10 @@ PROCEDURE Example (foo, bar: CARDINAL) : CARDINAL ;
 VAR
myout: CARDINAL ;
 BEGIN
-   ASM VOLATILE ("movq %1,%%rax; addq %2,%%rax; movq %%rax,%0"
+   ASM VOLATILE ("movl %1,%%eax; addl %2,%%eax; movl %%eax,%0"
   : "=rm" (myout)(* outputs *)
   : "rm" (foo), "rm" (bar)   (* inputs  *)
-  : "rax") ; (* we trash *)
+  : "eax") ; (* we trash *)
RETURN( myout )
 END Example ;
 @end example
@@ -2720,10 +2720,10 @@ VAR
myout: CARDINAL ;
 BEGIN
ASM VOLATILE (
-"movq %[left],%%rax; addq %[right],%%rax; movq %%rax,%[output]"
+"movl %[left],%%eax; addl %[right],%%eax; movl %%eax,%[output]"
   : [output] "=rm" (myout)  (* outputs *)
   : [left] "rm" (foo), [right] "rm" (bar)   (* inputs  *)
-  : "rax") ;(* we trash *)
+  : "eax") ;(* we trash *)
RETURN( myout )
 END Example ;
 @end example
diff --git a/gcc/testsuite/gm2.dg/doc/examples/pass/doc-examples-pass.exp 
b/gcc/testsuite/gm2.dg/doc/examples/pass/doc-examples-pass.exp
new file mode 100644
index ..0bfcea0f1250
--- /dev/null
+++ b/gcc/testsuite/gm2.dg/doc/examples/pass/doc-examples-pass.exp
@@ -0,0 +1,18 @@
+# Compile tests, no torture testing.
+#
+# These tests should all pass.
+
+# Load support procs.
+load_lib gm2-dg.exp
+
+gm2_init_pim4 $srcdir/$subdir
+
+# Initialize `dg'.
+dg-init
+
+# Main loop.
+
+dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.mod]] "" ""
+
+# All done.
+dg-finish
diff --git a/gcc/testsuite/gm2.dg/doc/examples/pass/exampleadd.mod 
b/gcc/testsuite/gm2.dg/doc/examples/pass/exampleadd.mod
new file mode 100644
index ..84020a85907d
--- /dev/null
+++ b/gcc/testsuite/gm2.dg/doc/examples/pass/exampleadd.mod
@@ -0,0 +1,32 @@
+(* { dg-do assemble { target { x86_64-*-* } } } *)
+(* { dg-options "-g" } *)
+
+MODULE exampleadd ;  
+
+FROM libc IMPORT printf, exit ;
+
+
+PROCEDURE Example (foo, bar: CARDINAL) : CARDINAL ;
+VAR
+   myout: CARDINAL ;
+BEGIN
+   ASM VOLATILE ("movl %1,%%eax; addl %2,%%eax; movl %%eax,%0"
+  : "=rm" (myout)(* outputs *)
+  : "rm" (foo), "rm" (bar)   (* inputs  *)
+  : "eax") ; (* we trash *)
+   RETURN( myout )
+END Example ;
+
+
+VAR
+   a, b, c: CARDINAL ;
+BEGIN
+   a := 1 ;
+   b := 2 ;
+   c := Example (a, b) ;
+   IF c # 3
+   THEN
+  printf ("Example procedure function failed to return 3, seen %d", c) ;
+  exit (1)
+   END
+END exampleadd.
diff --git a/gcc/testsuite/gm2.dg/doc/examples/pass/exampleadd2.mod 
b/gcc/testsuite/gm2.dg/doc/examples/pass/exampleadd2.mod
new file mode 100644
index ..f25397fa8ba0
--- /dev/null
+++ b/gcc/testsuite/gm2.dg/doc/examples/pass/exampleadd2.mod
@@ -0,0 +1,32 @@
+(* { dg-do assemble { target { x86_64-*-* } } } *)
+(* { dg-options "-g" } *)
+
+MODULE exampleadd2 ;  
+
+FROM libc IMPORT printf, exit ;
+
+
+PROCEDURE Example (foo, bar: CARDINAL) : CARDINAL ;
+VAR
+   myout: CARDINAL ;
+BEGIN
+   ASM VOLATILE (
+"movl %[left],%%eax; addl %[right],%%eax; movl %%eax,%[output]"
+  : [output] "=rm" (myout)  (* outputs *)
+  : [left] 

  1   2   >