[gcc r12-10406] rs6000: Don't ICE when compiling the __builtin_vsx_splat_2di [PR113950]

2024-04-30 Thread jeevitha via Gcc-cvs
https://gcc.gnu.org/g:1b91818e47119863f827b19ae4c6c91af3962cd6

commit r12-10406-g1b91818e47119863f827b19ae4c6c91af3962cd6
Author: Jeevitha 
Date:   Sun Apr 28 23:38:41 2024 -0500

rs6000: Don't ICE when compiling the __builtin_vsx_splat_2di [PR113950]

When we expand the __builtin_vsx_splat_2di built-in, we were allowing 
immediate
value for second operand which causes an unrecognizable insn ICE. Even 
though
the immediate value was forced into a register, it wasn't correctly assigned
to the second operand. So corrected the assignment of op1 to operands[1].

2024-03-07  Jeevitha Palanisamy  

gcc/
PR target/113950
* config/rs6000/vsx.md (vsx_splat_): Correct assignment to 
operand1
and simplify else if with else.

gcc/testsuite/
PR target/113950
* gcc.target/powerpc/pr113950.c: New testcase.

(cherry picked from commit fa0468877869f52b05742de6deef582e4dd296fc)

Diff:
---
 gcc/config/rs6000/vsx.md|  4 ++--
 gcc/testsuite/gcc.target/powerpc/pr113950.c | 24 
 2 files changed, 26 insertions(+), 2 deletions(-)

diff --git a/gcc/config/rs6000/vsx.md b/gcc/config/rs6000/vsx.md
index c45794fb9ed..e16f893c073 100644
--- a/gcc/config/rs6000/vsx.md
+++ b/gcc/config/rs6000/vsx.md
@@ -4562,8 +4562,8 @@
   rtx op1 = operands[1];
   if (MEM_P (op1))
 operands[1] = rs6000_force_indexed_or_indirect_mem (op1);
-  else if (!REG_P (op1))
-op1 = force_reg (mode, op1);
+  else
+operands[1] = force_reg (mode, op1);
 })
 
 (define_insn "vsx_splat__reg"
diff --git a/gcc/testsuite/gcc.target/powerpc/pr113950.c 
b/gcc/testsuite/gcc.target/powerpc/pr113950.c
new file mode 100644
index 000..359963d1041
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/pr113950.c
@@ -0,0 +1,24 @@
+/* PR target/113950 */
+/* { dg-require-effective-target powerpc_vsx_ok } */
+/* { dg-options "-O2 -mvsx" } */
+
+/* Verify we do not ICE on the following.  */
+
+void abort (void);
+
+int main ()
+{
+  int i;
+  vector signed long long vsll_result, vsll_expected_result;
+  signed long long sll_arg1;
+
+  sll_arg1 = 300;
+  vsll_expected_result = (vector signed long long) {300, 300};
+  vsll_result = __builtin_vsx_splat_2di (sll_arg1);  
+
+  for (i = 0; i < 2; i++)
+if (vsll_result[i] != vsll_expected_result[i])
+  abort();
+
+  return 0;
+}


[gcc r15-84] c++: Implement P2615 'Meaningful Exports' [PR107688]

2024-04-30 Thread Nathaniel Shead via Gcc-cvs
https://gcc.gnu.org/g:79420dd344145819677b3f975bb305a778fcaf91

commit r15-84-g79420dd344145819677b3f975bb305a778fcaf91
Author: Nathaniel Shead 
Date:   Mon Mar 4 23:58:30 2024 +1100

c++: Implement P2615 'Meaningful Exports' [PR107688]

This clarifies which kinds of declarations may and may not be exported
in various contexts. The patch additionally fixes up some small issues
that were clarified by the paper.

Most of the changes are with regards to export-declarations, which are
applied for all standards modes that we support '-fmodules-ts' for.
However there are also a couple of changes made to linkage specifiers
('extern "C"'); I've applied these as since C++20, to line up with when
modules were actually introduced.

PR c++/107688

gcc/cp/ChangeLog:

* name-lookup.cc (push_namespace): Error when exporting
namespace with internal linkage.
* parser.h (struct cp_parser): Add new flag
'in_unbraced_export_declaration_p'.
* parser.cc (cp_debug_parser): Print the new flag.
(cp_parser_new): Initialise the new flag.
(cp_parser_module_export): Set the new flag.
(cp_parser_class_specifier): Clear and restore the new flag.
(cp_parser_import_declaration): Imports can now appear directly
in a linkage specification.
(cp_parser_declaration): Categorise declarations as "name" or
"special"; error on the later in contexts where the former is
required.
(cp_parser_class_head): Error when exporting a partial
specialisation.

gcc/testsuite/ChangeLog:

* g++.dg/modules/contracts-1_a.C: Avoid now-illegal syntax.
* g++.dg/modules/contracts-2_a.C: Likewise.
* g++.dg/modules/contracts-3_a.C: Likewise.
* g++.dg/modules/contracts-4_a.C: Likewise.
* g++.dg/modules/lang-1_c.C: Clarify now-legal syntax.
* g++.dg/modules/pr101582-1.C: Remove now-legal XFAILS.
* g++.dg/template/crash71.C: Update error messages.
* g++.dg/cpp2a/linkage-spec1.C: New test.
* g++.dg/modules/export-3.C: New test.
* g++.dg/modules/export-4_a.C: New test.
* g++.dg/modules/export-4_b.C: New test.

Signed-off-by: Nathaniel Shead 

Diff:
---
 gcc/cp/name-lookup.cc|  10 ++-
 gcc/cp/parser.cc | 105 +--
 gcc/cp/parser.h  |   6 +-
 gcc/testsuite/g++.dg/cpp2a/linkage-spec1.C   |  22 ++
 gcc/testsuite/g++.dg/modules/contracts-1_a.C |   2 +-
 gcc/testsuite/g++.dg/modules/contracts-2_a.C |   2 +-
 gcc/testsuite/g++.dg/modules/contracts-3_a.C |   2 +-
 gcc/testsuite/g++.dg/modules/contracts-4_a.C |   2 +-
 gcc/testsuite/g++.dg/modules/export-3.C  |  30 
 gcc/testsuite/g++.dg/modules/export-4_a.C|  23 ++
 gcc/testsuite/g++.dg/modules/export-4_b.C|  13 
 gcc/testsuite/g++.dg/modules/lang-1_c.C  |   2 +-
 gcc/testsuite/g++.dg/modules/pr101582-1.C|   8 +-
 gcc/testsuite/g++.dg/template/crash71.C  |   4 +-
 14 files changed, 197 insertions(+), 34 deletions(-)

diff --git a/gcc/cp/name-lookup.cc b/gcc/cp/name-lookup.cc
index 4dffc0e9acc..5d2319db43d 100644
--- a/gcc/cp/name-lookup.cc
+++ b/gcc/cp/name-lookup.cc
@@ -9143,8 +9143,14 @@ push_namespace (tree name, bool make_inline)
 {
   /* A public namespace is exported only if explicitly marked, or
 it contains exported entities.  */
-  if (TREE_PUBLIC (ns) && module_exporting_p ())
-   DECL_MODULE_EXPORT_P (ns) = true;
+  if (module_exporting_p ())
+   {
+ if (TREE_PUBLIC (ns))
+   DECL_MODULE_EXPORT_P (ns) = true;
+ else if (!header_module_p ())
+   error_at (input_location,
+ "exporting namespace with internal linkage");
+   }
   if (module_purview_p ())
DECL_MODULE_PURVIEW_P (ns) = true;
 
diff --git a/gcc/cp/parser.cc b/gcc/cp/parser.cc
index aefbffe8330..a2bc6f69000 100644
--- a/gcc/cp/parser.cc
+++ b/gcc/cp/parser.cc
@@ -560,6 +560,8 @@ cp_debug_parser (FILE *file, cp_parser *parser)
   & THIS_FORBIDDEN));
   cp_debug_print_flag (file, "In unbraced linkage specification",
  parser->in_unbraced_linkage_specification_p);
+  cp_debug_print_flag (file, "In unbraced export declaration",
+ parser->in_unbraced_export_declaration_p);
   cp_debug_print_flag (file, "Parsing a declarator",
  parser->in_declarator_p);
   cp_debug_print_flag (file, "In template argument list",
@@ -4425,6 +4427,9 @@ cp_parser_new (cp_lexer *lexer)
   /* We are not processing an `extern "C"' declaration.  */
   parser->in_unbraced_linkage_specification_p = false;
 
+  /* We aren't parsing an export-declara

[gcc r15-82] Remove incorrect asserts.

2024-04-30 Thread Andrew Macleod via Gcc-cvs
https://gcc.gnu.org/g:7b3ac57852052822e3845bcd8d50b83d7724dfde

commit r15-82-g7b3ac57852052822e3845bcd8d50b83d7724dfde
Author: Andrew MacLeod 
Date:   Tue Feb 13 10:07:11 2024 -0500

Remove incorrect asserts.

Gimple_range_op handles builtin functions, and a couple of asserts that
are in place are incorrect in this context, so just remove them.

* gimple-range-op.cc (gimple_range_op_handler::calc_op1): Don't
assert that here are less than 3 operands.
(gimple_range_op_handler::maybe_builtin_call): Simply return if
there is no type for the function call.

Diff:
---
 gcc/gimple-range-op.cc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gcc/gimple-range-op.cc b/gcc/gimple-range-op.cc
index 9c50c00549e..587de186db2 100644
--- a/gcc/gimple-range-op.cc
+++ b/gcc/gimple-range-op.cc
@@ -178,7 +178,6 @@ gimple_range_op_handler::gimple_range_op_handler (gimple *s)
 bool
 gimple_range_op_handler::calc_op1 (vrange &r, const vrange &lhs_range)
 {
-  gcc_checking_assert (gimple_num_ops (m_stmt) < 3);
   // Give up on empty ranges.
   if (lhs_range.undefined_p ())
 return false;
@@ -1213,7 +1212,8 @@ gimple_range_op_handler::maybe_builtin_call ()
   if (func == CFN_LAST)
 return;
   tree type = gimple_range_type (call);
-  gcc_checking_assert (type);
+  if (!type)
+return;
   if (!Value_Range::supports_type_p (type))
 return;


[gcc r15-80] Invoke range_of_stmt on ssa_names with no context.

2024-04-30 Thread Andrew Macleod via Gcc-cvs
https://gcc.gnu.org/g:0ade358cd72ffa591dd2f1404765b379bbf709d4

commit r15-80-g0ade358cd72ffa591dd2f1404765b379bbf709d4
Author: Andrew MacLeod 
Date:   Wed Mar 13 14:13:28 2024 -0400

Invoke range_of_stmt on ssa_names with no context.

Evalaute ssa-names when range_of_expr is called with no context statement
by calling range_of_stmt to get an initial value.

* gimple-range.cc (gimple_ranger::range_of_expr): Call range_of_stmt
when there is no context stmt.

Diff:
---
 gcc/gimple-range.cc | 10 +-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/gcc/gimple-range.cc b/gcc/gimple-range.cc
index 4d3b1ce8588..3966cfbd14c 100644
--- a/gcc/gimple-range.cc
+++ b/gcc/gimple-range.cc
@@ -102,7 +102,15 @@ gimple_ranger::range_of_expr (vrange &r, tree expr, gimple 
*stmt)
   if (!stmt)
 {
   Value_Range tmp (TREE_TYPE (expr));
-  m_cache.get_global_range (r, expr);
+  // If there is no global range for EXPR yet, try to evaluate it.
+  // This call sets R to a global range regardless.
+  if (!m_cache.get_global_range (r, expr))
+   {
+ gimple *s = SSA_NAME_DEF_STMT (expr);
+ // Calculate a range for S if it is safe to do so.
+ if (s && gimple_bb (s) && gimple_get_lhs (s) == expr)
+   return range_of_stmt (r, s);
+   }
   // Pick up implied context information from the on-entry cache
   // if current_bb is set.  Do not attempt any new calculations.
   if (current_bb && m_cache.block_range (tmp, current_bb, expr, false))


[gcc r15-81] Add range_on_entry/exit to value_query API.

2024-04-30 Thread Andrew Macleod via Gcc-cvs
https://gcc.gnu.org/g:39fe620963b29e7bdc8dcfa2037490df26b4edf2

commit r15-81-g39fe620963b29e7bdc8dcfa2037490df26b4edf2
Author: Andrew MacLeod 
Date:   Wed Mar 13 14:18:48 2024 -0400

Add range_on_entry/exit to value_query API.

Add range_on_entry and range_on_exit to the value_query API.  These will
also work with generic trees like range_of_expr does.

* gimple-range.cc (gimple_ranger::range_on_entry): Adjust for new
API and support non-SSA expressions.
(gimple_ranger::range_on_exit): Ditto.
* gimple-range.h (range_on_entry, range_on_exit): Adjust API.
* value-query.cc (range_query::range_on_entry): New.
(range_query::range_on_exit): New.
(range_query::value_on_entry): New.
(range_query::value_on_exit): New.
(range_query::invoke_range_of_expr): New.
(range_query::get_tree_range): Allow stmt, on_entry or on_exit
range queries.
SSA_NAMES should invoke range_of_expr if possible.
* value-query.h (class range_query): Adjust prototypes.

Diff:
---
 gcc/gimple-range.cc |  14 +---
 gcc/gimple-range.h  |   4 +--
 gcc/value-query.cc  | 100 
 gcc/value-query.h   |   9 -
 4 files changed, 112 insertions(+), 15 deletions(-)

diff --git a/gcc/gimple-range.cc b/gcc/gimple-range.cc
index 3966cfbd14c..e75e2e17dc3 100644
--- a/gcc/gimple-range.cc
+++ b/gcc/gimple-range.cc
@@ -152,11 +152,13 @@ gimple_ranger::range_of_expr (vrange &r, tree expr, 
gimple *stmt)
 
 // Return the range of NAME on entry to block BB in R.
 
-void
+bool
 gimple_ranger::range_on_entry (vrange &r, basic_block bb, tree name)
 {
+  if (!gimple_range_ssa_p (name))
+return get_tree_range (r, name, NULL, bb, NULL);
+
   Value_Range entry_range (TREE_TYPE (name));
-  gcc_checking_assert (gimple_range_ssa_p (name));
 
   unsigned idx;
   if ((idx = tracer.header ("range_on_entry (")))
@@ -174,16 +176,17 @@ gimple_ranger::range_on_entry (vrange &r, basic_block bb, 
tree name)
 
   if (idx)
 tracer.trailer (idx, "range_on_entry", true, name, r);
+  return true;
 }
 
 // Calculate the range for NAME at the end of block BB and return it in R.
 // Return false if no range can be calculated.
 
-void
+bool
 gimple_ranger::range_on_exit (vrange &r, basic_block bb, tree name)
 {
-  // on-exit from the exit block?
-  gcc_checking_assert (gimple_range_ssa_p (name));
+  if (!gimple_range_ssa_p (name))
+return get_tree_range (r, name, NULL, NULL, bb);
 
   unsigned idx;
   if ((idx = tracer.header ("range_on_exit (")))
@@ -208,6 +211,7 @@ gimple_ranger::range_on_exit (vrange &r, basic_block bb, 
tree name)
   
   if (idx)
 tracer.trailer (idx, "range_on_exit", true, name, r);
+  return true;
 }
 
 // Calculate a range for NAME on edge E and return it in R.
diff --git a/gcc/gimple-range.h b/gcc/gimple-range.h
index 8739ab6a2ef..167b54b2a37 100644
--- a/gcc/gimple-range.h
+++ b/gcc/gimple-range.h
@@ -52,8 +52,8 @@ public:
   virtual bool range_of_stmt (vrange &r, gimple *, tree name = NULL) override;
   virtual bool range_of_expr (vrange &r, tree name, gimple * = NULL) override;
   virtual bool range_on_edge (vrange &r, edge e, tree name) override;
-  void range_on_entry (vrange &r, basic_block bb, tree name);
-  void range_on_exit (vrange &r, basic_block bb, tree name);
+  virtual bool range_on_entry (vrange &r, basic_block bb, tree name) override;
+  virtual bool range_on_exit (vrange &r, basic_block bb, tree name) override;
   void export_global_ranges ();
   inline gori_compute &gori ()  { return m_cache.m_gori; }
   virtual void dump (FILE *f) override;
diff --git a/gcc/value-query.cc b/gcc/value-query.cc
index e88c8e25789..c2ab745a466 100644
--- a/gcc/value-query.cc
+++ b/gcc/value-query.cc
@@ -41,6 +41,18 @@ range_query::range_on_edge (vrange &r, edge, tree expr)
   return range_of_expr (r, expr);
 }
 
+bool
+range_query::range_on_entry (vrange &r, basic_block, tree expr)
+{
+  return range_of_expr (r, expr);
+}
+
+bool
+range_query::range_on_exit (vrange &r, basic_block, tree expr)
+{
+  return range_of_expr (r, expr);
+}
+
 bool
 range_query::range_of_stmt (vrange &r, gimple *stmt, tree name)
 {
@@ -54,6 +66,9 @@ range_query::range_of_stmt (vrange &r, gimple *stmt, tree 
name)
   return false;
 }
 
+// If the range of expr EXPR at STMT is a single value, return it.
+// Otherwise return NULL_TREE.
+
 tree
 range_query::value_of_expr (tree expr, gimple *stmt)
 {
@@ -76,6 +91,9 @@ range_query::value_of_expr (tree expr, gimple *stmt)
   return NULL_TREE;
 }
 
+// If the range on edge E for EXPR is a single value, return it.
+// Otherwise return NULL_TREE.
+
 tree
 range_query::value_on_edge (edge e, tree expr)
 {
@@ -94,9 +112,11 @@ range_query::value_on_edge (edge e, tree expr)
return t;
 }
   return NULL_TREE;
-
 }
 
+// If the range of STMT for NAME is a single value, return it.
+// Otherwise return NU

[gcc r15-79] Fix ranger when called from SCEV.

2024-04-30 Thread Andrew Macleod via Gcc-cvs
https://gcc.gnu.org/g:e8ae56a7dc46e39a48017bb5159e4dc672ec7fad

commit r15-79-ge8ae56a7dc46e39a48017bb5159e4dc672ec7fad
Author: Andrew MacLeod 
Date:   Wed Mar 13 14:10:41 2024 -0400

Fix ranger when called from SCEV.

Do not pre-evaluate PHIs in the cache, and allow fill_block_cache to
be re-entrant.  This allows SCEV to call into ranger with a context
and not produce cycles or loops.

* gimple-range-cache.cc (ranger_cache::get_global_range): Do not
pre-evaluate PHI nodes from the cache.
(ranger_cache::fill_block_cache): Make re-entrant.

Diff:
---
 gcc/gimple-range-cache.cc | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/gcc/gimple-range-cache.cc b/gcc/gimple-range-cache.cc
index a33b7a73872..72ac2552311 100644
--- a/gcc/gimple-range-cache.cc
+++ b/gcc/gimple-range-cache.cc
@@ -1047,7 +1047,9 @@ ranger_cache::get_global_range (vrange &r, tree name, 
bool ¤t_p)
   if (r.varying_p () && !cfun->after_inlining)
{
  gimple *s = SSA_NAME_DEF_STMT (name);
- if (gimple_get_lhs (s) == name)
+ // Do not process PHIs as SCEV may be in use and it can
+ // spawn cyclic lookups.
+ if (gimple_get_lhs (s) == name && !is_a (s))
{
  if (!fold_range (r, s, get_global_range_query ()))
gimple_range_global (r, name);
@@ -1413,7 +1415,7 @@ ranger_cache::fill_block_cache (tree name, basic_block 
bb, basic_block def_bb)
 
   // At this point we shouldn't be looking at the def, entry block.
   gcc_checking_assert (bb != def_bb && bb != ENTRY_BLOCK_PTR_FOR_FN (cfun));
-  gcc_checking_assert (m_workback.length () == 0);
+  unsigned start_length = m_workback.length ();
 
   // If the block cache is set, then we've already visited this block.
   if (m_on_entry.bb_range_p (name, bb))
@@ -1500,7 +1502,7 @@ ranger_cache::fill_block_cache (tree name, basic_block 
bb, basic_block def_bb)
}
 
   m_on_entry.set_bb_range (name, bb, block_result);
-  gcc_checking_assert (m_workback.length () == 0);
+  gcc_checking_assert (m_workback.length () == start_length);
   return;
 }
 
@@ -1512,7 +1514,7 @@ ranger_cache::fill_block_cache (tree name, basic_block 
bb, basic_block def_bb)
   m_on_entry.set_bb_range (name, bb, undefined);
   gcc_checking_assert (m_update->empty_p ());
 
-  while (m_workback.length () > 0)
+  while (m_workback.length () > start_length)
 {
   basic_block node = m_workback.pop ();
   if (DEBUG_RANGE_CACHE)


[gcc r15-78] Remove wrapper around gimple_range_global.

2024-04-30 Thread Andrew Macleod via Gcc-cvs
https://gcc.gnu.org/g:56aa8ad7cd91fbc42123f1190d3238e293020085

commit r15-78-g56aa8ad7cd91fbc42123f1190d3238e293020085
Author: Andrew MacLeod 
Date:   Tue Feb 20 12:27:51 2024 -0500

Remove wrapper around gimple_range_global.

Now that legacy EVRP has been removed, we can remove the wrapper which
prevented us from using global names before inlining except under
some specific conditions.  See discussion:
 https://gcc.gnu.org/pipermail/gcc-patches/2021-June/571709.html

* value-query.cc (get_range_global): Rename to gimple_range_global.
(gimple_range_global): Remove wrapper function.
(global_range_query::range_of_expr): Call gimple_range_global.

Diff:
---
 gcc/value-query.cc | 40 +++-
 1 file changed, 7 insertions(+), 33 deletions(-)

diff --git a/gcc/value-query.cc b/gcc/value-query.cc
index 052b7511565..e88c8e25789 100644
--- a/gcc/value-query.cc
+++ b/gcc/value-query.cc
@@ -280,11 +280,15 @@ get_ssa_name_ptr_info_nonnull (const_tree name)
 // Update the global range for NAME into the SSA_RANGE_NAME_INFO and
 // Return the legacy global range for NAME if it has one, otherwise
 // return VARYING.
+// See discussion here regarding why there use to be a wrapper function:
+// https://gcc.gnu.org/pipermail/gcc-patches/2021-June/571709.html
+// Legacy EVRP has been removed, leaving just this function.
 
-static void
-get_range_global (vrange &r, tree name, struct function *fun = cfun)
+void
+gimple_range_global (vrange &r, tree name, struct function *fun)
 {
   tree type = TREE_TYPE (name);
+  gcc_checking_assert (TREE_CODE (name) == SSA_NAME);
 
   if (SSA_NAME_IS_DEFAULT_DEF (name))
 {
@@ -332,36 +336,6 @@ get_range_global (vrange &r, tree name, struct function 
*fun = cfun)
 r.set_varying (type);
 }
 
-// This is where the ranger picks up global info to seed initial
-// requests.  It is a slightly restricted version of
-// get_range_global() above.
-//
-// The reason for the difference is that we can always pick the
-// default definition of an SSA with no adverse effects, but for other
-// SSAs, if we pick things up to early, we may prematurely eliminate
-// builtin_unreachables.
-//
-// Without this restriction, the test in g++.dg/tree-ssa/pr61034.C has
-// all of its unreachable calls removed too early.
-//
-// See discussion here:
-// https://gcc.gnu.org/pipermail/gcc-patches/2021-June/571709.html
-
-void
-gimple_range_global (vrange &r, tree name, struct function *fun)
-{
-  tree type = TREE_TYPE (name);
-  gcc_checking_assert (TREE_CODE (name) == SSA_NAME);
-
-  if (SSA_NAME_IS_DEFAULT_DEF (name) || (fun && fun->after_inlining)
-  || is_a (SSA_NAME_DEF_STMT (name)))
-{
-  get_range_global (r, name, fun);
-  return;
-}
-  r.set_varying (type);
-}
-
 // --
 // global_range_query implementation.
 
@@ -373,7 +347,7 @@ global_range_query::range_of_expr (vrange &r, tree expr, 
gimple *stmt)
   if (!gimple_range_ssa_p (expr))
 return get_tree_range (r, expr, stmt);
 
-  get_range_global (r, expr);
+  gimple_range_global (r, expr);
 
   return true;
 }


[gcc r13-8665] libstdc++: Do not apply localized formatting to NaN and inf [PR114863]

2024-04-30 Thread Jonathan Wakely via Libstdc++-cvs
https://gcc.gnu.org/g:61c38a231d2df60cb6e914b3ecc73a0229c17ff6

commit r13-8665-g61c38a231d2df60cb6e914b3ecc73a0229c17ff6
Author: Jonathan Wakely 
Date:   Fri Apr 26 11:42:26 2024 +0100

libstdc++: Do not apply localized formatting to NaN and inf [PR114863]

We don't want to add grouping to strings like "-inf", and there is no
radix character to replace either.

libstdc++-v3/ChangeLog:

PR libstdc++/114863
* include/std/format (__formatter_fp::format): Only use
_M_localized for finite values.
* testsuite/std/format/functions/format.cc: Check localized
formatting of NaN and initiny.

(cherry picked from commit 7501c0a397fcf609a1ff5f083746b6330b89ee11)

Diff:
---
 libstdc++-v3/include/std/format   | 2 +-
 libstdc++-v3/testsuite/std/format/functions/format.cc | 8 
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/libstdc++-v3/include/std/format b/libstdc++-v3/include/std/format
index a938d65a7b9..d69703a283e 100644
--- a/libstdc++-v3/include/std/format
+++ b/libstdc++-v3/include/std/format
@@ -1666,7 +1666,7 @@ namespace __format
  __str = __wstr;
}
 
- if (_M_spec._M_localized)
+ if (_M_spec._M_localized && __builtin_isfinite(__v))
{
  if constexpr (is_same_v)
__wstr = _M_localize(__str, __expc, __fc.locale());
diff --git a/libstdc++-v3/testsuite/std/format/functions/format.cc 
b/libstdc++-v3/testsuite/std/format/functions/format.cc
index 1f1802e561c..16f5cda39f1 100644
--- a/libstdc++-v3/testsuite/std/format/functions/format.cc
+++ b/libstdc++-v3/testsuite/std/format/functions/format.cc
@@ -231,6 +231,14 @@ test_locale()
   s = std::format(cloc, "{:05L}", -1.0); // PR libstdc++/110968
   VERIFY( s == "-0001" );
 
+  // PR libstdc++/114863 grouping applied to nan and inf
+  double inf = std::numeric_limits::infinity();
+  s = std::format(eloc, "{0:Le} {0:Lf} {0:Lg}", -inf);
+  VERIFY( s == "-inf -inf -inf" );
+  double nan = std::numeric_limits::quiet_NaN();
+  s = std::format(eloc, "{0:Le} {0:Lf} {0:Lg}", -nan);
+  VERIFY( s == "-nan -nan -nan" );
+
   // Restore
   std::locale::global(cloc);
 }


[gcc r15-77] Fix the build: error message `quote`

2024-04-30 Thread Andrew Pinski via Gcc-cvs
https://gcc.gnu.org/g:1ff71f71a13f5ed423389d20ed34f3217e632777

commit r15-77-g1ff71f71a13f5ed423389d20ed34f3217e632777
Author: Andrew Pinski 
Date:   Tue Apr 30 09:44:52 2024 -0700

Fix the build: error message `quote`

The problem here is the quote mark is for English's
possessiveness rather than a quote but the error message
format detection is too simple so it warns which causes
-Werror to fail.

Committed as obvious after a quick build.

gcc/ChangeLog:

* tree-cfg.cc (verify_gimple_assign): Remove quote
mark to shut up the warning.

Signed-off-by: Andrew Pinski 

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

diff --git a/gcc/tree-cfg.cc b/gcc/tree-cfg.cc
index 1c5b7df8541..b2d47b72084 100644
--- a/gcc/tree-cfg.cc
+++ b/gcc/tree-cfg.cc
@@ -4842,7 +4842,7 @@ verify_gimple_assign (gassign *stmt)
   tree lhs = gimple_assign_lhs (stmt);
   if (is_gimple_reg (lhs))
{
- error ("nontemporal store's lhs cannot be a gimple register");
+ error ("nontemporal store lhs cannot be a gimple register");
  debug_generic_stmt (lhs);
  return true;
}


[gcc r15-74] MATCH: change single_non_singleton_phi_for_edges for singleton phis

2024-04-30 Thread Andrew Pinski via Gcc-cvs
https://gcc.gnu.org/g:9c18bdb07e299b25e7526fea16659c7ff8f0d14e

commit r15-74-g9c18bdb07e299b25e7526fea16659c7ff8f0d14e
Author: Andrew Pinski 
Date:   Sat Apr 27 18:54:44 2024 -0700

MATCH: change single_non_singleton_phi_for_edges for singleton phis

I noticed that single_non_singleton_phi_for_edges could
return a phi whos entry are all the same for the edge.
This happens only if there was a single phis in the first place.
Also gimple_seq_singleton_p walks the sequence to see if it the one
element in the sequence so there is removing that check actually
reduces the number of pointer walks needed.

Bootstrapped and tested on x86_64-linux-gnu with no regressions.

gcc/ChangeLog:

* tree-ssa-phiopt.cc (single_non_singleton_phi_for_edges):
Remove the special case of gimple_seq_singleton_p.

Signed-off-by: Andrew Pinski 

Diff:
---
 gcc/tree-ssa-phiopt.cc | 8 
 1 file changed, 8 deletions(-)

diff --git a/gcc/tree-ssa-phiopt.cc b/gcc/tree-ssa-phiopt.cc
index d1746c4b468..f1e07502b02 100644
--- a/gcc/tree-ssa-phiopt.cc
+++ b/gcc/tree-ssa-phiopt.cc
@@ -62,14 +62,6 @@ single_non_singleton_phi_for_edges (gimple_seq seq, edge e0, 
edge e1)
 {
   gimple_stmt_iterator i;
   gphi *phi = NULL;
-  if (gimple_seq_singleton_p (seq))
-{
-  phi = as_a  (gsi_stmt (gsi_start (seq)));
-  /* Never return virtual phis.  */
-  if (virtual_operand_p (gimple_phi_result (phi)))
-   return NULL;
-  return phi;
-}
   for (i = gsi_start (seq); !gsi_end_p (i); gsi_next (&i))
 {
   gphi *p = as_a  (gsi_stmt (i));


[gcc r15-76] PHIOPT: Value-replacement check undef

2024-04-30 Thread Andrew Pinski via Gcc-cvs
https://gcc.gnu.org/g:a30d2e6bd0b965e7687f58530a767a3c3b079158

commit r15-76-ga30d2e6bd0b965e7687f58530a767a3c3b079158
Author: Andrew Pinski 
Date:   Sun Apr 28 20:21:02 2024 -0700

PHIOPT: Value-replacement check undef

While moving value replacement part of PHIOPT over
to use match-and-simplify, I ran into the case where
we would have an undef use that was conditional become
unconditional. This prevents that. I can't remember at this
point what the testcase was though.

Bootstrapped and tested on x86_64-linux-gnu with no regressions.

gcc/ChangeLog:

* tree-ssa-phiopt.cc (value_replacement): Reject undef variables
so they don't become unconditional used.

Signed-off-by: Andrew Pinski 

Diff:
---
 gcc/tree-ssa-phiopt.cc | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/gcc/tree-ssa-phiopt.cc b/gcc/tree-ssa-phiopt.cc
index a2bdcb5eae8..f166c3132cb 100644
--- a/gcc/tree-ssa-phiopt.cc
+++ b/gcc/tree-ssa-phiopt.cc
@@ -1146,6 +1146,13 @@ value_replacement (basic_block cond_bb, basic_block 
middle_bb,
   if (code != NE_EXPR && code != EQ_EXPR)
 return 0;
 
+  /* Do not make conditional undefs unconditional.  */
+  if ((TREE_CODE (arg0) == SSA_NAME
+   && ssa_name_maybe_undef_p (arg0))
+  || (TREE_CODE (arg1) == SSA_NAME
+ && ssa_name_maybe_undef_p (arg1)))
+return false;
+
   /* If the type says honor signed zeros we cannot do this
  optimization.  */
   if (HONOR_SIGNED_ZEROS (arg1))


[gcc r15-75] PHI-OPT: speed up value_replacement slightly

2024-04-30 Thread Andrew Pinski via Gcc-cvs
https://gcc.gnu.org/g:611815e0233302e1fa113e6f865fa450b7ae

commit r15-75-g611815e0233302e1fa113e6f865fa450b7ae
Author: Andrew Pinski 
Date:   Sat Apr 27 18:54:45 2024 -0700

PHI-OPT: speed up value_replacement slightly

This adds a few early outs to value_replacement that I noticed
while rewriting this to use match-and-simplify but could be committed
seperately.
* virtual operands won't change so return early for them
* special case `A ? B : B` as that is already just `B`

Also moves the check for NE/EQ earlier as calculating 
empty_or_with_defined_p
is an IR walk for a BB and that might be big.

Bootstrapped and tested on x86_64-linux-gnu with no regressions.

gcc/ChangeLog:

* tree-ssa-phiopt.cc (value_replacement): Move check for
NE/EQ earlier.

Signed-off-by: Andrew Pinski 

Diff:
---
 gcc/tree-ssa-phiopt.cc | 22 +++---
 1 file changed, 15 insertions(+), 7 deletions(-)

diff --git a/gcc/tree-ssa-phiopt.cc b/gcc/tree-ssa-phiopt.cc
index f1e07502b02..a2bdcb5eae8 100644
--- a/gcc/tree-ssa-phiopt.cc
+++ b/gcc/tree-ssa-phiopt.cc
@@ -1131,6 +1131,21 @@ value_replacement (basic_block cond_bb, basic_block 
middle_bb,
   enum tree_code code;
   bool empty_or_with_defined_p = true;
 
+  /* Virtual operands don't need to be handled. */
+  if (virtual_operand_p (arg1))
+return 0;
+
+  /* Special case A ? B : B as this will always simplify to B. */
+  if (operand_equal_for_phi_arg_p (arg0, arg1))
+return 0;
+
+  gcond *cond = as_a  (*gsi_last_bb (cond_bb));
+  code = gimple_cond_code (cond);
+
+  /* This transformation is only valid for equality comparisons.  */
+  if (code != NE_EXPR && code != EQ_EXPR)
+return 0;
+
   /* If the type says honor signed zeros we cannot do this
  optimization.  */
   if (HONOR_SIGNED_ZEROS (arg1))
@@ -1161,13 +1176,6 @@ value_replacement (basic_block cond_bb, basic_block 
middle_bb,
empty_or_with_defined_p = false;
 }
 
-  gcond *cond = as_a  (*gsi_last_bb (cond_bb));
-  code = gimple_cond_code (cond);
-
-  /* This transformation is only valid for equality comparisons.  */
-  if (code != NE_EXPR && code != EQ_EXPR)
-return 0;
-
   /* We need to know which is the true edge and which is the false
   edge so that we know if have abs or negative abs.  */
   extract_true_false_edges_from_block (cond_bb, &true_edge, &false_edge);


[gcc r15-73] Remove support for nontemporal stores with ssa_names on lhs [PR112976]

2024-04-30 Thread Andrew Pinski via Gcc-cvs
https://gcc.gnu.org/g:8614d60233a64afd7e28ae7af2ab74c4a5b06010

commit r15-73-g8614d60233a64afd7e28ae7af2ab74c4a5b06010
Author: Andrew Pinski 
Date:   Wed Apr 17 14:30:06 2024 -0700

Remove support for nontemporal stores with ssa_names on lhs [PR112976]

When cfgexpand was changed to support expanding from tuple gimple
(r0-95521-g28ed065ef9f345), the code was added to support
doing nontemporal stores with LHS of a SSA_NAME but that will
never be a nontemporal store.
This patch removes that and asserts that expanding with a LHS
of a SSA_NAME is not a nontemporal store.

Bootstrapped and tested on x86_64-linux-gnu.

gcc/ChangeLog:

PR middle-end/112976
* cfgexpand.cc (expand_gimple_stmt_1): Remove
support for expanding nontemporal "moves" with
ssa names on the LHS.

Signed-off-by: Andrew Pinski 

Diff:
---
 gcc/cfgexpand.cc | 11 ---
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/gcc/cfgexpand.cc b/gcc/cfgexpand.cc
index eef565eddb5..cfc5291aa0c 100644
--- a/gcc/cfgexpand.cc
+++ b/gcc/cfgexpand.cc
@@ -4002,17 +4002,16 @@ expand_gimple_stmt_1 (gimple *stmt)
else
  {
rtx target, temp;
-   bool nontemporal = gimple_assign_nontemporal_move_p (assign_stmt);
+   gcc_assert (!gimple_assign_nontemporal_move_p (assign_stmt));
bool promoted = false;
 
target = expand_expr (lhs, NULL_RTX, VOIDmode, EXPAND_WRITE);
if (GET_CODE (target) == SUBREG && SUBREG_PROMOTED_VAR_P (target))
  promoted = true;
 
-  /* If we want to use a nontemporal store, force the value to
- register first.  If we store into a promoted register,
- don't directly expand to target.  */
-   temp = nontemporal || promoted ? NULL_RTX : target;
+  /* If we store into a promoted register, don't directly
+ expand to target.  */
+   temp = promoted ? NULL_RTX : target;
temp = expand_expr_real_gassign (assign_stmt, temp,
 GET_MODE (target), EXPAND_NORMAL);
 
@@ -4034,8 +4033,6 @@ expand_gimple_stmt_1 (gimple *stmt)
 
convert_move (SUBREG_REG (target), temp, unsignedp);
  }
-   else if (nontemporal && emit_storent_insn (target, temp))
- ;
else
  {
temp = force_operand (temp, target);


[gcc r15-72] Add verification of gimple_assign_nontemporal_move_p [PR112976]

2024-04-30 Thread Andrew Pinski via Gcc-cvs
https://gcc.gnu.org/g:e3a7f359c18bf347f6ac8fcda05e9839fac5bd62

commit r15-72-ge3a7f359c18bf347f6ac8fcda05e9839fac5bd62
Author: Andrew Pinski 
Date:   Wed Apr 17 14:12:17 2024 -0700

Add verification of gimple_assign_nontemporal_move_p [PR112976]

Currently the middle-end only knows how to support temporal stores
(the undocumented storent optab) so let's verify that the only time
we set nontemporal_move on an assign is if the the lhs is not a
gimple reg.

Bootstrapped and tested on x86_64-linux-gnu no regressions.

gcc/ChangeLog:

PR middle-end/112976
* tree-cfg.cc (verify_gimple_assign): Verify that
nontmporal moves are stores.
* gimple.h (struct gimple): Note that only
nontemporal stores are supported.

Signed-off-by: Andrew Pinski 

Diff:
---
 gcc/gimple.h|  3 ++-
 gcc/tree-cfg.cc | 11 +++
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/gcc/gimple.h b/gcc/gimple.h
index 8a8ca109bbf..bd315ffc2dd 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -236,7 +236,8 @@ struct GTY((desc ("gimple_statement_structure (&%h)"), tag 
("GSS_BASE"),
  for clearing this bit before using it.  */
   unsigned int visited : 1;
 
-  /* Nonzero if this tuple represents a non-temporal move.  */
+  /* Nonzero if this tuple represents a non-temporal move; currently
+ only stores are supported.  */
   unsigned int nontemporal_move: 1;
 
   /* Pass local flags.  These flags are free for any pass to use as
diff --git a/gcc/tree-cfg.cc b/gcc/tree-cfg.cc
index b1ba33018fd..1c5b7df8541 100644
--- a/gcc/tree-cfg.cc
+++ b/gcc/tree-cfg.cc
@@ -4837,6 +4837,17 @@ verify_gimple_assign_single (gassign *stmt)
 static bool
 verify_gimple_assign (gassign *stmt)
 {
+  if (gimple_assign_nontemporal_move_p (stmt))
+{
+  tree lhs = gimple_assign_lhs (stmt);
+  if (is_gimple_reg (lhs))
+   {
+ error ("nontemporal store's lhs cannot be a gimple register");
+ debug_generic_stmt (lhs);
+ return true;
+   }
+}
+
   switch (gimple_assign_rhs_class (stmt))
 {
 case GIMPLE_SINGLE_RHS:


[gcc(refs/vendors/riscv/heads/gcc-14-with-riscv-opts)] This is almost exclusively Jivan's work. His original post:

2024-04-30 Thread Jeff Law via Gcc-cvs
https://gcc.gnu.org/g:ece3a7538a6414d13dc2ac92c6e88fe7c203fcd1

commit ece3a7538a6414d13dc2ac92c6e88fe7c203fcd1
Author: Jivan Hakobyan 
Date:   Tue Apr 30 09:44:02 2024 -0600

This is almost exclusively Jivan's work.  His original post:

> https://www.mail-archive.com/gcc-patches@gcc.gnu.org/msg336483.html

This patch is primarily meant to improve the code we generate for FP 
rounding
such as ceil/floor.  It also addresses some unnecessary sign extensions in 
the
same areas.

RISC-V's FP conversions have a bit of undesirable behavior that make them
non-suitable as-is for ceil/floor and other related functions. These
deficiencies are addressed in the Zfa extension, but there's no reason not 
to
pick up a nice improvement when we can.

Basically we can still use the basic FP conversions for floor/ceil and 
friends
when we don't care about inexact exceptions by checking for the special 
cases
first, then emitting the conversion when the special cases don't apply.  
That's
still much faster than calling into glibc.

The redundant sign extensions are eliminated using the same trick Jivan 
added
last year, just in a few more places ;-)

This eliminates roughly 10% of the dynamic instruction count for imagick.  
But
more importantly it's about a 17% performance improvement for that workload
within spec.

This has been bootstrapped as well as regression tested in a cross 
environment.
It's also successfully built & run specint/specfp correctly.

Pushing to the trunk and the coordination branch momentarily.

gcc/
* config/riscv/iterators.md (fix_ops, fix_uns): New iterators.
(RINT, rint_pattern, rint_rm): Remove unused iterators.
* config/riscv/riscv-protos.h (get_fp_rounding_coefficient): 
Prototype.
* config/riscv/riscv-v.cc (get_fp_rounding_coefficient): 
Externalize.
external linkage.
* config/riscv/riscv.md (UNSPEC_LROUND): Remove.
(fix_trunc2): Replace with ...
(_truncsi2): New expander & associated insn.
(_truncsi2_ext): New insn.
(_truncdi2): Likewise.
(l2): Replace with ...
(lrintsi2): New expander and associated insn.
(lrintsi2_ext, lrintdi2): New insns.
(2): Replace with
(lsi2): New expander and associated insn.
(lsi2_sext): New insn.
(ldi2): Likewise.
(2): New expander.

gcc/testsuite/
* gcc.target/riscv/fix.c: New test.
* gcc.target/riscv/round.c: New test.
* gcc.target/riscv/round_32.c: New test.
* gcc.target/riscv/round_64.c: New test.

(cherry picked from commit f652a35877e32d470d649d1aee5d94fa0169a478)

Diff:
---
 gcc/config/riscv/iterators.md |  12 +-
 gcc/config/riscv/riscv-protos.h   |   1 +
 gcc/config/riscv/riscv-v.cc   |   2 +-
 gcc/config/riscv/riscv.md | 211 +++---
 gcc/testsuite/gcc.target/riscv/fix.c  |  34 +
 gcc/testsuite/gcc.target/riscv/round.c| 144 
 gcc/testsuite/gcc.target/riscv/round_32.c |  22 
 gcc/testsuite/gcc.target/riscv/round_64.c |  23 
 8 files changed, 427 insertions(+), 22 deletions(-)

diff --git a/gcc/config/riscv/iterators.md b/gcc/config/riscv/iterators.md
index a7694137685..75e119e407a 100644
--- a/gcc/config/riscv/iterators.md
+++ b/gcc/config/riscv/iterators.md
@@ -196,6 +196,13 @@
 
 (define_code_iterator bitmanip_rotate [rotate rotatert])
 
+;; These code iterators allow the signed and unsigned fix operations to use
+;; the same template.
+(define_code_iterator fix_ops [fix unsigned_fix])
+
+(define_code_attr fix_uns [(fix "fix") (unsigned_fix "fixuns")])
+
+
 ;; ---
 ;; Code Attributes
 ;; ---
@@ -312,11 +319,6 @@
 ;; Int Iterators.
 ;; ---
 
-;; Iterator and attributes for floating-point rounding instructions.
-(define_int_iterator RINT [UNSPEC_LRINT UNSPEC_LROUND])
-(define_int_attr rint_pattern [(UNSPEC_LRINT "rint") (UNSPEC_LROUND "round")])
-(define_int_attr rint_rm [(UNSPEC_LRINT "dyn") (UNSPEC_LROUND "rmm")])
-
 ;; Iterator and attributes for quiet comparisons.
 (define_int_iterator QUIET_COMPARISON [UNSPEC_FLT_QUIET UNSPEC_FLE_QUIET])
 (define_int_attr quiet_pattern [(UNSPEC_FLT_QUIET "lt") (UNSPEC_FLE_QUIET 
"le")])
diff --git a/gcc/config/riscv/riscv-protos.h b/gcc/config/riscv/riscv-protos.h
index 5d46a29d8b7..e5aebf3fc3d 100644
--- a/gcc/config/riscv/riscv-protos.h
+++ b/gcc/config/riscv/riscv-protos.h
@@ -711,6 +711,7 @@ bool gather_scatter_valid_offset_p (machine_mode);
 HOST_WIDE_INT estimated_poly_value (poly_int64, unsigned int);
 bool whole_reg

[gcc(refs/vendors/riscv/heads/gcc-14-with-riscv-opts)] RISC-V: Refine the condition for add additional vars in RVV cost model

2024-04-30 Thread Jeff Law via Gcc-cvs
https://gcc.gnu.org/g:5009e02a5d556fac7d0b56e3c3614427332502d5

commit 5009e02a5d556fac7d0b56e3c3614427332502d5
Author: demin.han 
Date:   Tue Mar 26 16:52:12 2024 +0800

RISC-V: Refine the condition for add additional vars in RVV cost model

The adjacent_dr_p is sufficient and unnecessary condition for contiguous 
access.
So unnecessary live-ranges are added and result in smaller LMUL.

This patch uses MEMORY_ACCESS_TYPE as condition and constrains segment
load/store.

Tested on RV64 and no regression.

PR target/114506

gcc/ChangeLog:

* config/riscv/riscv-vector-costs.cc 
(non_contiguous_memory_access_p): Rename
(need_additional_vector_vars_p): Rename and refine condition

gcc/testsuite/ChangeLog:

* gcc.dg/vect/costmodel/riscv/rvv/pr114506.c: New test.

Signed-off-by: demin.han 
(cherry picked from commit ca2f531cc5db4f1020d4329976610356033e0246)

Diff:
---
 gcc/config/riscv/riscv-vector-costs.cc | 23 ++
 .../gcc.dg/vect/costmodel/riscv/rvv/pr114506.c | 23 ++
 2 files changed, 38 insertions(+), 8 deletions(-)

diff --git a/gcc/config/riscv/riscv-vector-costs.cc 
b/gcc/config/riscv/riscv-vector-costs.cc
index d27bb68a7b9..4582b0db425 100644
--- a/gcc/config/riscv/riscv-vector-costs.cc
+++ b/gcc/config/riscv/riscv-vector-costs.cc
@@ -563,14 +563,24 @@ get_store_value (gimple *stmt)
 return gimple_assign_rhs1 (stmt);
 }
 
-/* Return true if it is non-contiguous load/store.  */
+/* Return true if addtional vector vars needed.  */
 static bool
-non_contiguous_memory_access_p (stmt_vec_info stmt_info)
+need_additional_vector_vars_p (stmt_vec_info stmt_info)
 {
   enum stmt_vec_info_type type
 = STMT_VINFO_TYPE (vect_stmt_to_vectorize (stmt_info));
-  return ((type == load_vec_info_type || type == store_vec_info_type)
- && !adjacent_dr_p (STMT_VINFO_DATA_REF (stmt_info)));
+  if (type == load_vec_info_type || type == store_vec_info_type)
+{
+  if (STMT_VINFO_GATHER_SCATTER_P (stmt_info)
+ && STMT_VINFO_MEMORY_ACCESS_TYPE (stmt_info) == VMAT_GATHER_SCATTER)
+   return true;
+
+  machine_mode mode = TYPE_MODE (STMT_VINFO_VECTYPE (stmt_info));
+  int lmul = riscv_get_v_regno_alignment (mode);
+  if (DR_GROUP_SIZE (stmt_info) * lmul > RVV_M8)
+   return true;
+}
+  return false;
 }
 
 /* Return the LMUL of the current analysis.  */
@@ -739,10 +749,7 @@ update_local_live_ranges (
  stmt_vec_info stmt_info = vinfo->lookup_stmt (gsi_stmt (si));
  enum stmt_vec_info_type type
= STMT_VINFO_TYPE (vect_stmt_to_vectorize (stmt_info));
- if (non_contiguous_memory_access_p (stmt_info)
- /* LOAD_LANES/STORE_LANES doesn't need a perm indice.  */
- && STMT_VINFO_MEMORY_ACCESS_TYPE (stmt_info)
-  != VMAT_LOAD_STORE_LANES)
+ if (need_additional_vector_vars_p (stmt_info))
{
  /* For non-adjacent load/store STMT, we will potentially
 convert it into:
diff --git a/gcc/testsuite/gcc.dg/vect/costmodel/riscv/rvv/pr114506.c 
b/gcc/testsuite/gcc.dg/vect/costmodel/riscv/rvv/pr114506.c
new file mode 100644
index 000..a88d24b2d2d
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/costmodel/riscv/rvv/pr114506.c
@@ -0,0 +1,23 @@
+/* { dg-do compile } */
+/* { dg-options "-march=rv64gcv -mabi=lp64d -O3 -ftree-vectorize 
-mrvv-max-lmul=dynamic -fdump-tree-vect-details" } */
+
+float a[32000], b[32000], c[32000], d[32000];
+float aa[256][256], bb[256][256], cc[256][256];
+
+void
+s2275 ()
+{
+  for (int i = 0; i < 256; i++)
+{
+  for (int j = 0; j < 256; j++)
+   {
+ aa[j][i] = aa[j][i] + bb[j][i] * cc[j][i];
+   }
+  a[i] = b[i] + c[i] * d[i];
+}
+}
+
+/* { dg-final { scan-assembler-times {e32,m8} 1 } } */
+/* { dg-final { scan-assembler-not {e32,m4} } } */
+/* { dg-final { scan-assembler-not {csrr} } } */
+/* { dg-final { scan-tree-dump-not "Preferring smaller LMUL loop because it 
has unexpected spills" "vect" } } */


[gcc(refs/vendors/riscv/heads/gcc-14-with-riscv-opts)] RISC-V: Fix parsing of Zic* extensions

2024-04-30 Thread Jeff Law via Gcc-cvs
https://gcc.gnu.org/g:7cae85835c5b6a5bb3231efc0121073f5054c26f

commit 7cae85835c5b6a5bb3231efc0121073f5054c26f
Author: Christoph Müllner 
Date:   Mon Apr 29 00:46:06 2024 +0200

RISC-V: Fix parsing of Zic* extensions

The extension parsing table entries for a range of Zic* extensions
does not match the mask definition in riscv.opt.
This results in broken TARGET_ZIC* macros, because the values of
riscv_zi_subext and riscv_zicmo_subext are set wrong.

This patch fixes this by moving Zic64b into riscv_zicmo_subext
and all other affected Zic* extensions to riscv_zi_subext.

gcc/ChangeLog:

* common/config/riscv/riscv-common.cc: Move ziccamoa, ziccif,
zicclsm, and ziccrse into riscv_zi_subext.
* config/riscv/riscv.opt: Define MASK_ZIC64B for
riscv_ziccmo_subext.

Signed-off-by: Christoph Müllner 
(cherry picked from commit 285300eb928b171236e895f28c960ad02dcb0d67)

Diff:
---
 gcc/common/config/riscv/riscv-common.cc | 8 
 gcc/config/riscv/riscv.opt  | 4 ++--
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/gcc/common/config/riscv/riscv-common.cc 
b/gcc/common/config/riscv/riscv-common.cc
index 43b7549e3ec..8cc0e727737 100644
--- a/gcc/common/config/riscv/riscv-common.cc
+++ b/gcc/common/config/riscv/riscv-common.cc
@@ -1638,15 +1638,15 @@ static const riscv_ext_flag_table_t 
riscv_ext_flag_table[] =
 
   {"zihintntl", &gcc_options::x_riscv_zi_subext, MASK_ZIHINTNTL},
   {"zihintpause", &gcc_options::x_riscv_zi_subext, MASK_ZIHINTPAUSE},
+  {"ziccamoa", &gcc_options::x_riscv_zi_subext, MASK_ZICCAMOA},
+  {"ziccif", &gcc_options::x_riscv_zi_subext, MASK_ZICCIF},
+  {"zicclsm", &gcc_options::x_riscv_zi_subext, MASK_ZICCLSM},
+  {"ziccrse", &gcc_options::x_riscv_zi_subext, MASK_ZICCRSE},
 
   {"zicboz", &gcc_options::x_riscv_zicmo_subext, MASK_ZICBOZ},
   {"zicbom", &gcc_options::x_riscv_zicmo_subext, MASK_ZICBOM},
   {"zicbop", &gcc_options::x_riscv_zicmo_subext, MASK_ZICBOP},
   {"zic64b", &gcc_options::x_riscv_zicmo_subext, MASK_ZIC64B},
-  {"ziccamoa", &gcc_options::x_riscv_zicmo_subext, MASK_ZICCAMOA},
-  {"ziccif", &gcc_options::x_riscv_zicmo_subext, MASK_ZICCIF},
-  {"zicclsm", &gcc_options::x_riscv_zicmo_subext, MASK_ZICCLSM},
-  {"ziccrse", &gcc_options::x_riscv_zicmo_subext, MASK_ZICCRSE},
 
   {"zve32x",   &gcc_options::x_target_flags, MASK_VECTOR},
   {"zve32f",   &gcc_options::x_target_flags, MASK_VECTOR},
diff --git a/gcc/config/riscv/riscv.opt b/gcc/config/riscv/riscv.opt
index b14888e9816..ee824756381 100644
--- a/gcc/config/riscv/riscv.opt
+++ b/gcc/config/riscv/riscv.opt
@@ -237,8 +237,6 @@ Mask(ZIHINTPAUSE) Var(riscv_zi_subext)
 
 Mask(ZICOND)  Var(riscv_zi_subext)
 
-Mask(ZIC64B)  Var(riscv_zi_subext)
-
 Mask(ZICCAMOA)Var(riscv_zi_subext)
 
 Mask(ZICCIF)  Var(riscv_zi_subext)
@@ -390,6 +388,8 @@ Mask(ZICBOM) Var(riscv_zicmo_subext)
 
 Mask(ZICBOP) Var(riscv_zicmo_subext)
 
+Mask(ZIC64B) Var(riscv_zicmo_subext)
+
 TargetVariable
 int riscv_zf_subext


[gcc(refs/vendors/riscv/heads/gcc-14-with-riscv-opts)] RISC-V: Add -X to link spec

2024-04-30 Thread Jeff Law via Gcc-cvs
https://gcc.gnu.org/g:355f858c80fbdd3b4c67002e9685631fd10a6641

commit 355f858c80fbdd3b4c67002e9685631fd10a6641
Author: Fangrui Song 
Date:   Fri Apr 26 18:14:33 2024 -0700

RISC-V: Add -X to link spec

--discard-locals (-X) instructs the linker to remove local .L* symbols,
which occur a lot due to label differences for linker relaxation. The
arm port has a similar need and passes -X to ld.

In contrast, the RISC-V port does not pass -X to ld and rely on the
default --discard-locals in GNU ld's riscv port. The arm way is more
conventional (compiler driver instead of the linker customizes the
default linker behavior) and works with lld.

gcc/ChangeLog:

* config/riscv/elf.h (LINK_SPEC): Add -X.
* config/riscv/freebsd.h (LINK_SPEC): Add -X.
* config/riscv/linux.h (LINK_SPEC): Add -X.

Diff:
---
 gcc/config/riscv/elf.h | 1 +
 gcc/config/riscv/freebsd.h | 1 +
 gcc/config/riscv/linux.h   | 1 +
 3 files changed, 3 insertions(+)

diff --git a/gcc/config/riscv/elf.h b/gcc/config/riscv/elf.h
index f533764d9f8..c97f13c0cca 100644
--- a/gcc/config/riscv/elf.h
+++ b/gcc/config/riscv/elf.h
@@ -20,6 +20,7 @@ along with GCC; see the file COPYING3.  If not see
 #define LINK_SPEC "\
 -melf" XLEN_SPEC DEFAULT_ENDIAN_SPEC "riscv \
 %{mno-relax:--no-relax} \
+-X \
 %{mbig-endian:-EB} \
 %{mlittle-endian:-EL} \
 %{shared}"
diff --git a/gcc/config/riscv/freebsd.h b/gcc/config/riscv/freebsd.h
index bd08a985285..5dd4d51c42b 100644
--- a/gcc/config/riscv/freebsd.h
+++ b/gcc/config/riscv/freebsd.h
@@ -44,6 +44,7 @@ along with GCC; see the file COPYING3.  If not see
   %{p:%nconsider using `-pg' instead of `-p' with gprof (1)}   \
   %{v:-V}  \
   %{assert*} %{R*} %{rpath*} %{defsym*}\
+  -X   \
   %{mbig-endian:-EB}   \
   %{mlittle-endian:-EL}\
   %{shared:-Bshareable %{h*} %{soname*}}   \
diff --git a/gcc/config/riscv/linux.h b/gcc/config/riscv/linux.h
index 15851f653bc..3c356227134 100644
--- a/gcc/config/riscv/linux.h
+++ b/gcc/config/riscv/linux.h
@@ -50,6 +50,7 @@ along with GCC; see the file COPYING3.  If not see
 #define LINK_SPEC "\
 -melf" XLEN_SPEC DEFAULT_ENDIAN_SPEC "riscv" LD_EMUL_SUFFIX " \
 %{mno-relax:--no-relax} \
+-X \
 %{mbig-endian:-EB} \
 %{mlittle-endian:-EL} \
 %{shared} \


[gcc r15-71] This is almost exclusively Jivan's work. His original post:

2024-04-30 Thread Jeff Law via Gcc-cvs
https://gcc.gnu.org/g:f652a35877e32d470d649d1aee5d94fa0169a478

commit r15-71-gf652a35877e32d470d649d1aee5d94fa0169a478
Author: Jivan Hakobyan 
Date:   Tue Apr 30 09:44:02 2024 -0600

This is almost exclusively Jivan's work.  His original post:

> https://www.mail-archive.com/gcc-patches@gcc.gnu.org/msg336483.html

This patch is primarily meant to improve the code we generate for FP 
rounding
such as ceil/floor.  It also addresses some unnecessary sign extensions in 
the
same areas.

RISC-V's FP conversions have a bit of undesirable behavior that make them
non-suitable as-is for ceil/floor and other related functions. These
deficiencies are addressed in the Zfa extension, but there's no reason not 
to
pick up a nice improvement when we can.

Basically we can still use the basic FP conversions for floor/ceil and 
friends
when we don't care about inexact exceptions by checking for the special 
cases
first, then emitting the conversion when the special cases don't apply.  
That's
still much faster than calling into glibc.

The redundant sign extensions are eliminated using the same trick Jivan 
added
last year, just in a few more places ;-)

This eliminates roughly 10% of the dynamic instruction count for imagick.  
But
more importantly it's about a 17% performance improvement for that workload
within spec.

This has been bootstrapped as well as regression tested in a cross 
environment.
It's also successfully built & run specint/specfp correctly.

Pushing to the trunk and the coordination branch momentarily.

gcc/
* config/riscv/iterators.md (fix_ops, fix_uns): New iterators.
(RINT, rint_pattern, rint_rm): Remove unused iterators.
* config/riscv/riscv-protos.h (get_fp_rounding_coefficient): 
Prototype.
* config/riscv/riscv-v.cc (get_fp_rounding_coefficient): 
Externalize.
external linkage.
* config/riscv/riscv.md (UNSPEC_LROUND): Remove.
(fix_trunc2): Replace with ...
(_truncsi2): New expander & associated insn.
(_truncsi2_ext): New insn.
(_truncdi2): Likewise.
(l2): Replace with ...
(lrintsi2): New expander and associated insn.
(lrintsi2_ext, lrintdi2): New insns.
(2): Replace with
(lsi2): New expander and associated insn.
(lsi2_sext): New insn.
(ldi2): Likewise.
(2): New expander.

gcc/testsuite/
* gcc.target/riscv/fix.c: New test.
* gcc.target/riscv/round.c: New test.
* gcc.target/riscv/round_32.c: New test.
* gcc.target/riscv/round_64.c: New test.

Diff:
---
 gcc/config/riscv/iterators.md |  12 +-
 gcc/config/riscv/riscv-protos.h   |   1 +
 gcc/config/riscv/riscv-v.cc   |   2 +-
 gcc/config/riscv/riscv.md | 211 +++---
 gcc/testsuite/gcc.target/riscv/fix.c  |  34 +
 gcc/testsuite/gcc.target/riscv/round.c| 144 
 gcc/testsuite/gcc.target/riscv/round_32.c |  22 
 gcc/testsuite/gcc.target/riscv/round_64.c |  23 
 8 files changed, 427 insertions(+), 22 deletions(-)

diff --git a/gcc/config/riscv/iterators.md b/gcc/config/riscv/iterators.md
index a7694137685..75e119e407a 100644
--- a/gcc/config/riscv/iterators.md
+++ b/gcc/config/riscv/iterators.md
@@ -196,6 +196,13 @@
 
 (define_code_iterator bitmanip_rotate [rotate rotatert])
 
+;; These code iterators allow the signed and unsigned fix operations to use
+;; the same template.
+(define_code_iterator fix_ops [fix unsigned_fix])
+
+(define_code_attr fix_uns [(fix "fix") (unsigned_fix "fixuns")])
+
+
 ;; ---
 ;; Code Attributes
 ;; ---
@@ -312,11 +319,6 @@
 ;; Int Iterators.
 ;; ---
 
-;; Iterator and attributes for floating-point rounding instructions.
-(define_int_iterator RINT [UNSPEC_LRINT UNSPEC_LROUND])
-(define_int_attr rint_pattern [(UNSPEC_LRINT "rint") (UNSPEC_LROUND "round")])
-(define_int_attr rint_rm [(UNSPEC_LRINT "dyn") (UNSPEC_LROUND "rmm")])
-
 ;; Iterator and attributes for quiet comparisons.
 (define_int_iterator QUIET_COMPARISON [UNSPEC_FLT_QUIET UNSPEC_FLE_QUIET])
 (define_int_attr quiet_pattern [(UNSPEC_FLT_QUIET "lt") (UNSPEC_FLE_QUIET 
"le")])
diff --git a/gcc/config/riscv/riscv-protos.h b/gcc/config/riscv/riscv-protos.h
index 5d46a29d8b7..e5aebf3fc3d 100644
--- a/gcc/config/riscv/riscv-protos.h
+++ b/gcc/config/riscv/riscv-protos.h
@@ -711,6 +711,7 @@ bool gather_scatter_valid_offset_p (machine_mode);
 HOST_WIDE_INT estimated_poly_value (poly_int64, unsigned int);
 bool whole_reg_to_reg_move_p (rtx *, machine_mode, int);
 bool splat_to_scalar_move_

[gcc] Created branch 'riscv/heads/gcc-14-with-riscv-opts' in namespace 'refs/vendors'

2024-04-30 Thread Jeff Law via Gcc-cvs
The branch 'riscv/heads/gcc-14-with-riscv-opts' was created in namespace 
'refs/vendors' pointing to:

 7a00c459cbb... libstdc++: Do not apply localized formatting to NaN and inf


[gcc r15-70] Change int_range<2> to infinite precision.

2024-04-30 Thread Aldy Hernandez via Gcc-cvs
https://gcc.gnu.org/g:0b2735e0797fee9b4ec5cd74f22afe0483f888dd

commit r15-70-g0b2735e0797fee9b4ec5cd74f22afe0483f888dd
Author: Aldy Hernandez 
Date:   Tue Apr 30 10:36:58 2024 +0200

Change int_range<2> to infinite precision.

In my previous change I mistakenly changed Value_Range to
int_range<2>.  The former has "infinite" precision for integer ranges,
whereas int_range<2> has two sub-ranges.  This should have been
int_range_max.

gcc/ChangeLog:

* gimple-ssa-warn-access.cc (check_nul_terminated_array): Change
int_range<2> to int_range_max.
(memmodel_to_uhwi): Same.
* tree-ssa-loop-niter.cc (refine_value_range_using_guard): Same.
(determine_value_range): Same.
(infer_loop_bounds_from_signedness): Same.
(scev_var_range_cant_overflow): Same.

Diff:
---
 gcc/gimple-ssa-warn-access.cc |  4 ++--
 gcc/tree-ssa-loop-niter.cc| 12 ++--
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/gcc/gimple-ssa-warn-access.cc b/gcc/gimple-ssa-warn-access.cc
index 450c1caa765..2c10d19e7f3 100644
--- a/gcc/gimple-ssa-warn-access.cc
+++ b/gcc/gimple-ssa-warn-access.cc
@@ -330,7 +330,7 @@ check_nul_terminated_array (GimpleOrTree expr, tree src, 
tree bound)
   wide_int bndrng[2];
   if (bound)
 {
-  int_range<2> r (TREE_TYPE (bound));
+  int_range_max r (TREE_TYPE (bound));
 
   get_range_query (cfun)->range_of_expr (r, bound);
 
@@ -2816,7 +2816,7 @@ memmodel_to_uhwi (tree ord, gimple *stmt, unsigned 
HOST_WIDE_INT *cstval)
 {
   /* Use the range query to determine constant values in the absence
 of constant propagation (such as at -O0).  */
-  int_range<2> rng (TREE_TYPE (ord));
+  int_range_max rng (TREE_TYPE (ord));
   if (!get_range_query (cfun)->range_of_expr (rng, ord, stmt)
  || !rng.singleton_p (&ord))
return false;
diff --git a/gcc/tree-ssa-loop-niter.cc b/gcc/tree-ssa-loop-niter.cc
index adbc1936982..0fde07e626f 100644
--- a/gcc/tree-ssa-loop-niter.cc
+++ b/gcc/tree-ssa-loop-niter.cc
@@ -214,7 +214,7 @@ refine_value_range_using_guard (tree type, tree var,
   get_type_static_bounds (type, mint, maxt);
   mpz_init (minc1);
   mpz_init (maxc1);
-  int_range<2> r (TREE_TYPE (varc1));
+  int_range_max r (TREE_TYPE (varc1));
   /* Setup range information for varc1.  */
   if (integer_zerop (varc1))
 {
@@ -368,7 +368,7 @@ determine_value_range (class loop *loop, tree type, tree 
var, mpz_t off,
   gphi_iterator gsi;
 
   /* Either for VAR itself...  */
-  int_range<2> var_range (TREE_TYPE (var));
+  int_range_max var_range (TREE_TYPE (var));
   get_range_query (cfun)->range_of_expr (var_range, var);
   if (var_range.varying_p () || var_range.undefined_p ())
rtype = VR_VARYING;
@@ -382,7 +382,7 @@ determine_value_range (class loop *loop, tree type, tree 
var, mpz_t off,
 
   /* Or for PHI results in loop->header where VAR is used as
 PHI argument from the loop preheader edge.  */
-  int_range<2> phi_range (TREE_TYPE (var));
+  int_range_max phi_range (TREE_TYPE (var));
   for (gsi = gsi_start_phis (loop->header); !gsi_end_p (gsi); gsi_next 
(&gsi))
{
  gphi *phi = gsi.phi ();
@@ -408,7 +408,7 @@ determine_value_range (class loop *loop, tree type, tree 
var, mpz_t off,
 involved.  */
  if (wi::gt_p (minv, maxv, sgn))
{
- int_range<2> vr (TREE_TYPE (var));
+ int_range_max vr (TREE_TYPE (var));
  get_range_query (cfun)->range_of_expr (vr, var);
  if (vr.varying_p () || vr.undefined_p ())
rtype = VR_VARYING;
@@ -4367,7 +4367,7 @@ infer_loop_bounds_from_signedness (class loop *loop, 
gimple *stmt)
 
   low = lower_bound_in_type (type, type);
   high = upper_bound_in_type (type, type);
-  int_range<2> r (TREE_TYPE (def));
+  int_range_max r (TREE_TYPE (def));
   get_range_query (cfun)->range_of_expr (r, def);
   if (!r.varying_p () && !r.undefined_p ())
 {
@@ -5426,7 +5426,7 @@ scev_var_range_cant_overflow (tree var, tree step, class 
loop *loop)
   if (!def_bb || !dominated_by_p (CDI_DOMINATORS, loop->latch, def_bb))
 return false;
 
-  int_range<2> r (TREE_TYPE (var));
+  int_range_max r (TREE_TYPE (var));
   get_range_query (cfun)->range_of_expr (r, var);
   if (r.varying_p () || r.undefined_p ())
 return false;


[gcc r15-69] testsuite: gm2: Remove timeout overrides [PR114886]

2024-04-30 Thread Rainer Orth via Gcc-cvs
https://gcc.gnu.org/g:aff63ac11099d100b6891f3bcc3dc6cbc4fad654

commit r15-69-gaff63ac11099d100b6891f3bcc3dc6cbc4fad654
Author: Rainer Orth 
Date:   Tue Apr 30 13:49:28 2024 +0200

testsuite: gm2: Remove timeout overrides [PR114886]

A large number of gm2 tests are timing out even on current Solaris/SPARC
systems.  As detailed in the PR, the problem is that the gm2 testsuite
artificially lowers many timeouts way below the DejaGnu default of 300
seconds, often as short as 10 seconds.  The problem lies both in the
values (they may be appropriate for some targets, but too low for
others, especially under high load) and the fact that it uses absolute
values, overriding e.g. settings from a build-wide site.exp.

Therefore this patch removes all those overrides, restoring the
defaults.

Tested on sparc-sun-solaris2.11 (where all the previous timeouts are
gone) and i386-pc-solaris2.11.

2024-04-29  Rainer Orth  

gcc/testsuite:
PR modula2/114886
* lib/gm2.exp: Don't load timeout-dg.exp.
Don't set gm2_previous_timeout.
Don't call dg-timeout.
(gm2_push_timeout, gm2_pop_timeout): Remove.
(gm2_init): Don't call dg-timeout.
* lib/gm2-torture.exp: Don't load timeout-dg.exp.
Don't set gm2_previous_timeout.
Don't call dg-timeout.
(gm2_push_timeout, gm2_pop_timeout): Remove.

* gm2/coroutines/pim/run/pass/coroutines-pim-run-pass.exp: Don't
load timeout-dg.exp.
Don't call gm2_push_timeout, gm2_pop_timeout.
* gm2/examples/map/pass/examples-map-pass.exp: Don't call
gm2_push_timeout, gm2_pop_timeout.
* gm2/iso/run/pass/iso-run-pass.exp: Don't load timeout-dg.exp.
Don't call gm2_push_timeout, gm2_pop_timeout.
* gm2/pimlib/base/run/pass/pimlib-base-run-pass.exp: Don't load
timeout-dg.exp.
Don't call gm2_push_timeout, gm2_pop_timeout.
* gm2/projects/iso/run/pass/halma/projects-iso-run-pass-halma.exp:
Don't call gm2_push_timeout, gm2_pop_timeout.
* 
gm2/switches/whole-program/pass/run/switches-whole-program-pass-run.exp:
Don't load timeout-dg.exp.
Don't call gm2_push_timeout, gm2_pop_timeout.

Diff:
---
 .../pim/run/pass/coroutines-pim-run-pass.exp   |  7 -
 .../gm2/examples/map/pass/examples-map-pass.exp|  5 
 gcc/testsuite/gm2/iso/run/pass/iso-run-pass.exp|  6 
 .../pimlib/base/run/pass/pimlib-base-run-pass.exp  |  6 
 .../run/pass/halma/projects-iso-run-pass-halma.exp |  7 -
 .../pass/run/switches-whole-program-pass-run.exp   |  4 ---
 gcc/testsuite/lib/gm2-torture.exp  | 28 --
 gcc/testsuite/lib/gm2.exp  | 34 --
 8 files changed, 97 deletions(-)

diff --git 
a/gcc/testsuite/gm2/coroutines/pim/run/pass/coroutines-pim-run-pass.exp 
b/gcc/testsuite/gm2/coroutines/pim/run/pass/coroutines-pim-run-pass.exp
index 6b3a8ebefe2..db2ba6314c1 100644
--- a/gcc/testsuite/gm2/coroutines/pim/run/pass/coroutines-pim-run-pass.exp
+++ b/gcc/testsuite/gm2/coroutines/pim/run/pass/coroutines-pim-run-pass.exp
@@ -24,16 +24,11 @@ if $tracelevel then {
 
 # load support procs
 load_lib gm2-torture.exp
-load_lib timeout-dg.exp
 
 set gm2src ${srcdir}/../gm2
 
 gm2_init_cor ""
 
-# We should be able to compile, link or run in 20 seconds.
-gm2_push_timeout 20
-
-
 foreach testcase [lsort [glob -nocomplain $srcdir/$subdir/*.mod]] {
 # If we're only testing specific files and this isn't one of them, skip it.
 if ![runtest_file_p $runtests $testcase] then {
@@ -42,5 +37,3 @@ foreach testcase [lsort [glob -nocomplain 
$srcdir/$subdir/*.mod]] {
 
 gm2-torture-execute $testcase "" "pass"
 }
-
-gm2_pop_timeout
diff --git a/gcc/testsuite/gm2/examples/map/pass/examples-map-pass.exp 
b/gcc/testsuite/gm2/examples/map/pass/examples-map-pass.exp
index 432518d7133..fabcf96f6d1 100644
--- a/gcc/testsuite/gm2/examples/map/pass/examples-map-pass.exp
+++ b/gcc/testsuite/gm2/examples/map/pass/examples-map-pass.exp
@@ -27,9 +27,6 @@ load_lib gm2-torture.exp
 
 gm2_init_pim "${srcdir}/${subdir}"
 
-# We should be able to compile, link or run in 30 seconds.
-gm2_push_timeout 30
-
 foreach testcase [lsort [glob -nocomplain $srcdir/$subdir/*.mod]] {
 # If we're only testing specific files and this isn't one of them, skip it.
 if ![runtest_file_p $runtests $testcase] then {
@@ -38,5 +35,3 @@ foreach testcase [lsort [glob -nocomplain 
$srcdir/$subdir/*.mod]] {
 
 gm2-torture $testcase
 }
-
-gm2_pop_timeout
diff --git a/gcc/testsuite/gm2/iso/run/pass/iso-run-pass.exp 
b/gcc/testsuite/gm2/iso/run/pass/iso-run-pass.exp
index af387e54b24..2c79b69ab6a 100644
--- a/gcc/testsuite/gm2/iso/run/pass/iso-run-pass.exp
+++ b/gcc/testsuite/gm2/iso/run/pass/iso-run-pass.exp
@@ -23,14

[gcc(refs/vendors/redhat/heads/gcc-14-branch)] Merge commit 'r14-10154-g7a00c459cbb913ac165a39d344a48fc27800bb0a' into redhat/gcc-14-branch

2024-04-30 Thread Jakub Jelinek via Gcc-cvs
https://gcc.gnu.org/g:748fd0ecf84c5484621adeeaca105d7d50f0e409

commit 748fd0ecf84c5484621adeeaca105d7d50f0e409
Merge: 9fad7d8c7bd 7a00c459cbb
Author: Jakub Jelinek 
Date:   Tue Apr 30 13:11:27 2024 +0200

Merge commit 'r14-10154-g7a00c459cbb913ac165a39d344a48fc27800bb0a' into 
redhat/gcc-14-branch

Diff:

 ChangeLog  |   16 +
 config/ChangeLog   |9 +
 config/acx.m4  |   10 +
 configure  |   80 +
 configure.ac   |   30 +
 contrib/ChangeLog  |   13 +
 contrib/check-params-in-docs.py|   19 +-
 contrib/config-list.mk |3 +-
 gcc/ChangeLog  |  727 +++
 gcc/DATESTAMP  |2 +-
 gcc/DEV-PHASE  |2 +-
 gcc/ada/ChangeLog  |9 +
 .../doc/gnat_rm/implementation_defined_aspects.rst |   12 +
 .../doc/gnat_rm/implementation_defined_pragmas.rst |   18 +
 gcc/ada/gnat_rm.texi   | 1649 ++---
 gcc/ada/gnat_ugn.texi  |4 +-
 gcc/analyzer/ChangeLog |5 +
 gcc/analyzer/region-model.cc   |4 +
 gcc/asan.cc|3 +
 gcc/attribs.cc |7 +-
 gcc/btfout.cc  |  134 +-
 gcc/c-family/ChangeLog |   25 +
 gcc/c-family/c-attribs.cc  |2 +-
 gcc/c-family/c-common.cc   |1 +
 gcc/c-family/c.opt |6 +-
 gcc/c-family/c.opt.urls|3 +
 gcc/c/ChangeLog|   15 +
 gcc/c/c-decl.cc|   49 +-
 gcc/c/c-typeck.cc  |4 +-
 gcc/common/config/i386/i386-common.cc  |2 +-
 gcc/config.gcc |   43 +-
 gcc/config/aarch64/aarch64-arches.def  |2 +-
 gcc/config/aarch64/aarch64-option-extensions.def   |2 +-
 gcc/config/aarch64/aarch64.cc  |   20 +-
 gcc/config/aarch64/aarch64.h   |3 +-
 gcc/config/aarch64/aarch64.md  |   23 +-
 gcc/config/arm/arm.cc  |   69 +
 gcc/config/avr/avr-mcus.def|8 +
 gcc/config/avr/avr.cc  |   17 +-
 gcc/config/bpf/bpf-c.cc|   88 +
 gcc/config/bpf/bpf-protos.h|2 +-
 gcc/config/bpf/bpf.cc  |   78 +-
 gcc/config/bpf/bpf.h   |9 +-
 gcc/config/bpf/bpf.md  |   56 +-
 gcc/config/bpf/bpf.opt |2 +-
 gcc/config/bpf/constraints.md  |   20 +
 gcc/config/bpf/core-builtins.cc|  128 +-
 gcc/config/bpf/core-builtins.h |2 +
 gcc/config/bpf/predicates.md   |7 +-
 gcc/config/bpf/t-bpf   |4 +
 gcc/config/darwin.opt  |2 +-
 gcc/config/epiphany/epiphany.opt   |2 +-
 gcc/config/gcn/gcn-hsa.h   |2 +-
 gcc/config/gcn/gcn-opts.h  |2 +
 gcc/config/gcn/gcn.cc  |8 +
 gcc/config/gcn/gcn.h   |2 +
 gcc/config/gcn/gcn.opt |3 +
 gcc/config/gcn/mkoffload.cc|9 +
 gcc/config/gcn/t-omp-device|2 +-
 gcc/config/i386/i386-options.cc|1 +
 gcc/config/i386/i386.md|   45 +-
 gcc/config/i386/sse.md |2 +-
 gcc/config/loongarch/genopts/gen-evolution.awk |  230 +
 gcc/config/loongarch/genopts/genstr.sh |   82 +-
 gcc/config/loongarch/genopts/isa-evolution.in  |   10 +-
 gcc/config/loongarch/genopts/loongarch-strings |5 +-
 gcc/config/loongarch/genopts/loongarch.opt.in  |   43 +-
 gcc/config/loongarch/loongarch-c.cc|   60 +-
 gcc/config/loongarch/loongarch-cpu.cc  |   37 +-
 gcc/config/loongarch/loongarch-def.cc  |   83 +-
 gcc/config/loongarch/loongarch-def.h   |   37 +-
 gcc/config/loongarch/loongarch-driver.cc   |8 +-
 gcc/config/loongarch/loongarch-evolution.cc|   60 +
 ...oongarch-cpucfg-map.h => loongarch-evolution.h} |   46 +-
 gcc/config/loongarch/loongarch-opts.cc |   66 +-
 gcc/config/loongarch/loongarch-opts.h  |   15 +-
 

[gcc(refs/vendors/redhat/heads/gcc-14-branch)] Revert "vect: Adjust vect_transform_reduction assertion [PR114883]"

2024-04-30 Thread Jakub Jelinek via Gcc-cvs
https://gcc.gnu.org/g:9fad7d8c7bdda850f2c131cf97757d740766d6dd

commit 9fad7d8c7bdda850f2c131cf97757d740766d6dd
Author: Jakub Jelinek 
Date:   Tue Apr 30 13:11:08 2024 +0200

Revert "vect: Adjust vect_transform_reduction assertion [PR114883]"

This reverts commit f7b939b4351d6ea38c58cefcc55c79325912d087.

Diff:
---
 gcc/testsuite/gfortran.dg/pr114883.f90 | 53 --
 gcc/tree-vect-loop.cc  |  3 +-
 2 files changed, 1 insertion(+), 55 deletions(-)

diff --git a/gcc/testsuite/gfortran.dg/pr114883.f90 
b/gcc/testsuite/gfortran.dg/pr114883.f90
deleted file mode 100644
index 3fec1d278b3..000
--- a/gcc/testsuite/gfortran.dg/pr114883.f90
+++ /dev/null
@@ -1,53 +0,0 @@
-! PR tree-optimization/114883
-! { dg-do compile }
-! { dg-options "-O2 -fvect-cost-model=cheap" }
-! { dg-additional-options "-march=x86-64-v4" { target i?86-*-* x86_64-*-* } }
-
-subroutine pr114883_1(a, b, c, d, e, f, g, h, o)
-  real(8) :: c(1011), d(1011), e(0:1011)
-  real(8) :: p, q, f, r, g(1011), h(1011), b, bar
-  integer :: o(100), a, t, u
-  p = 0.0_8
-  r = bar()
-  u = 1
-  do i = 1,a
-do k = 1,1011
-  km1 = max0(k-1,1)
-  h(k) = c(k) * e(k-1) * d(km1)
-  f = g(k) + h(k)
-  if(f.gt.1.e-6)then
-p = min(p,r)
-  endif
-end do
-q = 0.9_8 * p
-t = integer(b/q + 1)
-if(t>100)then
-  u = t
-endif
-o(u) = o(u) + 1
-  end do
-end subroutine pr114883_1
-subroutine pr114883_2(a, b, c, d, e, f, g, h, o)
-  real(8) :: c(1011), d(1011), e(0:1011)
-  real(8) :: p, q, f, r, g(1011), h(1011), b, bar
-  integer :: o(100), a, t, u
-  p = 0.0_8
-  r = bar()
-  u = 1
-  do i = 1,a
-do k = 1,1011
-  km1 = max0(k-1,1)
-  h(k) = c(k) * e(k-1) * d(km1)
-  f = g(k) + h(k)
-  if(f.gt.1.e-6)then
-p = max(p,r)
-  endif
-end do
-q = 0.9_8 * p
-t = integer(b/q + 1)
-if(t>100)then
-  u = t
-endif
-o(u) = o(u) + 1
-  end do
-end subroutine pr114883_2
diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc
index 6a912f2c2d7..3ffcac8c613 100644
--- a/gcc/tree-vect-loop.cc
+++ b/gcc/tree-vect-loop.cc
@@ -8504,8 +8504,7 @@ vect_transform_reduction (loop_vec_info loop_vinfo,
 {
   gcc_assert (code == IFN_COND_ADD || code == IFN_COND_SUB
  || code == IFN_COND_MUL || code == IFN_COND_AND
- || code == IFN_COND_IOR || code == IFN_COND_XOR
- || code == IFN_COND_MIN || code == IFN_COND_MAX);
+ || code == IFN_COND_IOR || code == IFN_COND_XOR);
   gcc_assert (op.num_ops == 4
  && (op.ops[reduc_index]
  == op.ops[internal_fn_else_index ((internal_fn) code)]));


[gcc/redhat/heads/gcc-14-branch] (232 commits) Merge commit 'r14-10154-g7a00c459cbb913ac165a39d344a48fc278

2024-04-30 Thread Jakub Jelinek via Gcc-cvs
The branch 'redhat/heads/gcc-14-branch' was updated to point to:

 748fd0ecf84... Merge commit 'r14-10154-g7a00c459cbb913ac165a39d344a48fc278

It previously pointed to:

 f7b939b4351... vect: Adjust vect_transform_reduction assertion [PR114883]

Diff:

Summary of changes (added commits):
---

  748fd0e... Merge commit 'r14-10154-g7a00c459cbb913ac165a39d344a48fc278
  9fad7d8... Revert "vect: Adjust vect_transform_reduction assertion [PR
  7a00c45... libstdc++: Do not apply localized formatting to NaN and inf (*)
  e976bef... Fortran: Fix regression caused by r14-9752 [PR114959] (*)
  a795a7b... vect: Adjust vect_transform_reduction assertion [PR114883] (*)
  af925ba... libgcc: Do use weakrefs for glibc 2.34 on GNU Hurd (*)
  501fed8... Set DEV-PHASE to prerelease. (*)
  3c925ac... c++: ICE with templated sizeof(E1) / sizeof(E2) [PR114888] (*)
  0062f83... Daily bump. (*)
  330c04d... libstdc++: Update Solaris baselines for GCC 14.0 (*)
  c3e9b86... libstdc++: Update Solaris baselines for GCC 13.2 (*)
  d40073b... RISC-V: Fix ICE for legitimize move on subreg const_poly_in (*)
  41d7a8c... Daily bump. (*)
  8cec90c... Daily bump. (*)
  3e04b6f... LoongArch: Add constraints for bit string operation define_ (*)
  457e907... Daily bump. (*)
  c014cfd... c++: fix source printing for "required from here" message (*)
  5e5f33a... libstdc++: Update status tables to refer to GCC 14 not main (*)
  b8e9fd5... amdgcn: Add gfx90c target (*)
  4a2e55b... i386: Fix array index overflow in pr105354-2.c (*)
  9353f6f... Daily bump. (*)
  1604f7c... bpf: set PREFERRED_DEBUGGING_TYPE to BTF_DEBUG (*)
  f541757... c++: Fix constexpr evaluation of parameters passed by invis (*)
  fe02f6c... libgcc: Don't use weakrefs for glibc 2.34 (*)
  c39654e... c++: Retry the aliasing of base/complete cdtor optimization (*)
  f175622... bpf: avoid issues with CO-RE and -gtoggle (*)
  14d4851... openmp: Copy DECL_LANG_SPECIFIC and DECL_LANG_FLAG_? to tre (*)
  8d80e3c... libstdc++: Rename man pages to use '::' instead of '_' (*)
  6391cf8... libstdc++: Fix typo in Doxygen comment (*)
  c9cc1c8... libstdc++: Fix run_doxygen for Doxygen 1.10 man page format (*)
  d5b2c6b... libstdc++: Update Doxygen config for new headers (*)
  f3021e6... libstdc++: Add comment to #include in  (*)
  d0e1e12... PR modula2/114836 Avoid concatenation of error strings to a (*)
  c96c2a3... bpf: default to using pseudo-C assembly syntax by default (*)
  ad45086... arm: Zero/Sign extends for CMSE security (*)
  070dd5c... modula2: issue the parameter incompatibility error message  (*)
  59ff818... tree-optimization/114792 - order loops to unloops in CH (*)
  1d238c8... Fix calling convention incompatibility with vendor compiler (*)
  af7d981... RISC-V: Add test cases for insn does not satisfy its constr (*)
  10ad46b... RISC-V: Add early clobber to the dest of vwsll (*)
  c058105... Fortran: Fix ICE in gfc_trans_create_temp_array from bad ty (*)
  1fd5a07... Fortran: Generate new charlens for shared symbol typespecs  (*)
  09680e3... rs6000: Use bcdsub. instead of bcdadd. for bcd invalid numb (*)
  d44c205... RISC-V: Add xfail test case for highpart register overlap o (*)
  5123cfa... Daily bump. (*)
  26a3edb... c++/modules testsuite: restrict expensive pr99023 test (*)
  0844170... c++: constexpr union member access folding [PR114709] (*)
  97a54c0... v2: DOCUMENTATION_ROOT_URL vs. release branches [PR114738] (*)
  bc17a92... Revert "RISC-V: Support highpart register overlap for vwcvt (*)
  152d945... bpf: define BPF feature pre-processor macros (*)
  cc48418... tree-optimization/114787 - more careful loop update with CF (*)
  e28e8ab... tree-optimization/114832 - wrong dominator info with vect p (*)
  d279c9d... i386: Fix behavior for both using AVX10.1-256 in options an (*)
  f952745... RISC-V: Add xfail test case for highpart overlap of vext.vf (*)
  8bcefc2... Revert "RISC-V: Support highpart overlap for vext.vf" (*)
  3091f1d... Daily bump. (*)
  7318f1a... c++: Fix ICE with xobj parms and maybe incomplete decl-spec (*)
  628c222... i386: Avoid =&r,r,r andn double-word alternative for ia32 [ (*)
  f7a5c99... Regenerate gcc.pot (*)
  0bf94da... Fortran: check C_SIZEOF on additions from TS29113/F2018 [PR (*)
  4f9401d... c++/modules: deduced return type merging [PR114795] (*)
  d2f05fe... libbacktrace: test --compress-debug-sections=ARG for each A (*)
  0c8e99e... testsuite: Adjust testsuite expectations for diagnostic spe (*)
  6f0a646... Remove repeated information in -ftree-loop-distribute-patte (*)
  f994094... Further spelling fixes in translatable strings (*)
  4338ac1... Spelling fixes for translatable strings (*)
  3d56999... s390: testsuite: Xfail forwprop-4{0,1}.c (*)
  ca00bf0... Fortran: Check that the ICE does not reappear [PR102597] (*)
  18e8e55... tree-optimization/114799 - SLP and patterns (*)
  42189f2... s390x: Fix vec_xl/vec_xst type aliasing [PR114676] (*)
  aa73eb9... c++: Copy over DECL_DISREGARD_INLINE_LIM

[gcc r15-68] Support {CEIL, FLOOR, ROUND}_{DIV, MOD}_EXPR and EXACT_DIV_EXPR in GIMPLE FE

2024-04-30 Thread Richard Biener via Gcc-cvs
https://gcc.gnu.org/g:ab785f9a3901ca29710592a2d5480b5a44328bf2

commit r15-68-gab785f9a3901ca29710592a2d5480b5a44328bf2
Author: Richard Biener 
Date:   Wed Apr 17 11:22:00 2024 +0200

Support {CEIL,FLOOR,ROUND}_{DIV,MOD}_EXPR and EXACT_DIV_EXPR in GIMPLE FE

The following adds support for the various division and modulo operators
to the GIMPLE frontend via __{CEIL,FLOOR,ROUND}_{DIV,MOD} and
__EXACT_DIV operators.

gcc/c/
* gimple-parser.cc (c_parser_gimple_binary_expression):
Parse __{CEIL,FLOOR,ROUND}_{DIV,MOD} and __EXACT_DIV.

gcc/testsuite/
* gcc.dg/gimplefe-53.c: New testcase.

Diff:
---
 gcc/c/gimple-parser.cc | 35 +++
 gcc/testsuite/gcc.dg/gimplefe-53.c | 16 
 2 files changed, 51 insertions(+)

diff --git a/gcc/c/gimple-parser.cc b/gcc/c/gimple-parser.cc
index 2dac41a335a..d156d83cd37 100644
--- a/gcc/c/gimple-parser.cc
+++ b/gcc/c/gimple-parser.cc
@@ -1055,6 +1055,41 @@ c_parser_gimple_binary_expression (gimple_parser 
&parser, tree ret_type)
code = LTGT_EXPR;
break;
  }
+   else if (strcmp (IDENTIFIER_POINTER (id), "__FLOOR_DIV") == 0)
+ {
+   code = FLOOR_DIV_EXPR;
+   break;
+ }
+   else if (strcmp (IDENTIFIER_POINTER (id), "__ROUND_DIV") == 0)
+ {
+   code = ROUND_DIV_EXPR;
+   break;
+ }
+   else if (strcmp (IDENTIFIER_POINTER (id), "__EXACT_DIV") == 0)
+ {
+   code = EXACT_DIV_EXPR;
+   break;
+ }
+   else if (strcmp (IDENTIFIER_POINTER (id), "__CEIL_DIV") == 0)
+ {
+   code = CEIL_DIV_EXPR;
+   break;
+ }
+   else if (strcmp (IDENTIFIER_POINTER (id), "__FLOOR_MOD") == 0)
+ {
+   code = FLOOR_MOD_EXPR;
+   break;
+ }
+   else if (strcmp (IDENTIFIER_POINTER (id), "__ROUND_MOD") == 0)
+ {
+   code = ROUND_MOD_EXPR;
+   break;
+ }
+   else if (strcmp (IDENTIFIER_POINTER (id), "__CEIL_MOD") == 0)
+ {
+   code = CEIL_MOD_EXPR;
+   break;
+ }
   }
   /* Fallthru.  */
 default:
diff --git a/gcc/testsuite/gcc.dg/gimplefe-53.c 
b/gcc/testsuite/gcc.dg/gimplefe-53.c
new file mode 100644
index 000..926c77c74d4
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/gimplefe-53.c
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+/* { dg-options "-fgimple" } */
+
+int __GIMPLE
+foo (int a, int b)
+{
+  int tem;
+  tem = a __EXACT_DIV b;
+  tem = tem __CEIL_DIV b;
+  tem = tem __FLOOR_DIV b;
+  tem = tem __ROUND_DIV b;
+  tem = tem __FLOOR_MOD b;
+  tem = tem __CEIL_MOD b;
+  tem = tem __ROUND_MOD b;
+  return tem;
+}


[gcc r15-67] middle-end/13421 - -ftrapv vs. POINTER_DIFF_EXPR

2024-04-30 Thread Richard Biener via Gcc-cvs
https://gcc.gnu.org/g:667c19de86b33648f5f4599f589a5e02adbb35cb

commit r15-67-g667c19de86b33648f5f4599f589a5e02adbb35cb
Author: Richard Biener 
Date:   Tue Apr 16 14:05:35 2024 +0200

middle-end/13421 - -ftrapv vs. POINTER_DIFF_EXPR

Currently we expand POINTER_DIFF_EXPR using subv_optab when -ftrapv
(but -fsanitize=undefined does nothing).  That's not consistent
with the behavior of POINTER_PLUS_EXPR which never uses addv_optab
with -ftrapv.  Both are because of the way we select whether to use
the trapping or the non-trapping optab - we look at the result type
of the expression and check

  trapv = INTEGRAL_TYPE_P (type) && TYPE_OVERFLOW_TRAPS (type);

the bugreport correctly complains that -ftrapv affects pointer
subtraction (there's no -ftrapv-pointer).  Now that we have
POINTER_DIFF_EXPR we can honor that appropriately.

The patch moves both POINTER_DIFF_EXPR and POINTER_PLUS_EXPR
handling so they will never consider trapping (or saturating)
optabs.

PR middle-end/13421
* optabs-tree.cc (optab_for_tree_code): Do not consider
{add,sub}v or {us,ss}{add,sub} optabs for POINTER_DIFF_EXPR
or POINTER_PLUS_EXPR.

Diff:
---
 gcc/optabs-tree.cc | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/gcc/optabs-tree.cc b/gcc/optabs-tree.cc
index e7bd0d10892..b69a5bc3676 100644
--- a/gcc/optabs-tree.cc
+++ b/gcc/optabs-tree.cc
@@ -135,6 +135,12 @@ optab_for_tree_code (enum tree_code code, const_tree type,
 case MIN_EXPR:
   return TYPE_UNSIGNED (type) ? umin_optab : smin_optab;
 
+case POINTER_PLUS_EXPR:
+  return add_optab;
+
+case POINTER_DIFF_EXPR:
+  return sub_optab;
+
 case REALIGN_LOAD_EXPR:
   return vec_realign_load_optab;
 
@@ -249,13 +255,11 @@ optab_for_tree_code (enum tree_code code, const_tree type,
   trapv = INTEGRAL_TYPE_P (type) && TYPE_OVERFLOW_TRAPS (type);
   switch (code)
 {
-case POINTER_PLUS_EXPR:
 case PLUS_EXPR:
   if (TYPE_SATURATING (type))
return TYPE_UNSIGNED (type) ? usadd_optab : ssadd_optab;
   return trapv ? addv_optab : add_optab;
 
-case POINTER_DIFF_EXPR:
 case MINUS_EXPR:
   if (TYPE_SATURATING (type))
return TYPE_UNSIGNED (type) ? ussub_optab : sssub_optab;


[gcc r12-10404] match.pd: Only merge truncation with conversion for -fno-signed-zeros

2024-04-30 Thread Richard Biener via Gcc-cvs
https://gcc.gnu.org/g:e8482b86ef5641b1e0041f2712011b9389ac1e40

commit r12-10404-ge8482b86ef5641b1e0041f2712011b9389ac1e40
Author: Joe Ramsay 
Date:   Fri Mar 15 09:20:45 2024 +

match.pd: Only merge truncation with conversion for -fno-signed-zeros

This optimisation does not honour signed zeros, so should not be
enabled except with -fno-signed-zeros.

gcc/ChangeLog:

* match.pd: Fix truncation pattern for -fno-signed-zeroes

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/no_merge_trunc_signed_zero.c: New test.

(cherry picked from commit 7dd3b2b09cbeb6712ec680a0445cb0ad41070423)

Diff:
---
 gcc/match.pd   |  1 +
 .../aarch64/no_merge_trunc_signed_zero.c   | 24 ++
 2 files changed, 25 insertions(+)

diff --git a/gcc/match.pd b/gcc/match.pd
index c5a4426e76b..0938d56fa45 100644
--- a/gcc/match.pd
+++ b/gcc/match.pd
@@ -3825,6 +3825,7 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
 (simplify
(float (fix_trunc @0))
(if (!flag_trapping_math
+   && !HONOR_SIGNED_ZEROS (type)
&& types_match (type, TREE_TYPE (@0))
&& direct_internal_fn_supported_p (IFN_TRUNC, type,
  OPTIMIZE_FOR_BOTH))
diff --git a/gcc/testsuite/gcc.target/aarch64/no_merge_trunc_signed_zero.c 
b/gcc/testsuite/gcc.target/aarch64/no_merge_trunc_signed_zero.c
new file mode 100644
index 000..b2c93e55567
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/no_merge_trunc_signed_zero.c
@@ -0,0 +1,24 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fno-trapping-math -fsigned-zeros" } */
+
+#include 
+
+float
+f1 (float x)
+{
+  return (int) rintf(x);
+}
+
+double
+f2 (double x)
+{
+  return (long) rint(x);
+}
+
+/* { dg-final { scan-assembler "frintx\\ts\[0-9\]+, s\[0-9\]+" } } */
+/* { dg-final { scan-assembler "cvtzs\\ts\[0-9\]+, s\[0-9\]+" } } */
+/* { dg-final { scan-assembler "scvtf\\ts\[0-9\]+, s\[0-9\]+" } } */
+/* { dg-final { scan-assembler "frintx\\td\[0-9\]+, d\[0-9\]+" } } */
+/* { dg-final { scan-assembler "cvtzs\\td\[0-9\]+, d\[0-9\]+" } } */
+/* { dg-final { scan-assembler "scvtf\\td\[0-9\]+, d\[0-9\]+" } } */
+


[gcc r13-8664] match.pd: Only merge truncation with conversion for -fno-signed-zeros

2024-04-30 Thread Richard Biener via Gcc-cvs
https://gcc.gnu.org/g:13bf9232fc1ec2cb7be85b628a6f2d5ed15510d9

commit r13-8664-g13bf9232fc1ec2cb7be85b628a6f2d5ed15510d9
Author: Joe Ramsay 
Date:   Fri Mar 15 09:20:45 2024 +

match.pd: Only merge truncation with conversion for -fno-signed-zeros

This optimisation does not honour signed zeros, so should not be
enabled except with -fno-signed-zeros.

gcc/ChangeLog:

* match.pd: Fix truncation pattern for -fno-signed-zeroes

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/no_merge_trunc_signed_zero.c: New test.

(cherry picked from commit 7dd3b2b09cbeb6712ec680a0445cb0ad41070423)

Diff:
---
 gcc/match.pd   |  1 +
 .../aarch64/no_merge_trunc_signed_zero.c   | 24 ++
 2 files changed, 25 insertions(+)

diff --git a/gcc/match.pd b/gcc/match.pd
index 47e48fa2ca5..dc34e7ead9f 100644
--- a/gcc/match.pd
+++ b/gcc/match.pd
@@ -4188,6 +4188,7 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
 (simplify
(float (fix_trunc @0))
(if (!flag_trapping_math
+   && !HONOR_SIGNED_ZEROS (type)
&& types_match (type, TREE_TYPE (@0))
&& direct_internal_fn_supported_p (IFN_TRUNC, type,
  OPTIMIZE_FOR_BOTH))
diff --git a/gcc/testsuite/gcc.target/aarch64/no_merge_trunc_signed_zero.c 
b/gcc/testsuite/gcc.target/aarch64/no_merge_trunc_signed_zero.c
new file mode 100644
index 000..b2c93e55567
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/no_merge_trunc_signed_zero.c
@@ -0,0 +1,24 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fno-trapping-math -fsigned-zeros" } */
+
+#include 
+
+float
+f1 (float x)
+{
+  return (int) rintf(x);
+}
+
+double
+f2 (double x)
+{
+  return (long) rint(x);
+}
+
+/* { dg-final { scan-assembler "frintx\\ts\[0-9\]+, s\[0-9\]+" } } */
+/* { dg-final { scan-assembler "cvtzs\\ts\[0-9\]+, s\[0-9\]+" } } */
+/* { dg-final { scan-assembler "scvtf\\ts\[0-9\]+, s\[0-9\]+" } } */
+/* { dg-final { scan-assembler "frintx\\td\[0-9\]+, d\[0-9\]+" } } */
+/* { dg-final { scan-assembler "cvtzs\\td\[0-9\]+, d\[0-9\]+" } } */
+/* { dg-final { scan-assembler "scvtf\\td\[0-9\]+, d\[0-9\]+" } } */
+


[gcc r15-66] gimple-ssa-sprintf: Use [0, 1] range for %lc with (wint_t) 0 argument [PR114876]

2024-04-30 Thread Jakub Jelinek via Gcc-cvs
https://gcc.gnu.org/g:6c6b70f07208ca14ba783933988c04c6fc2fff42

commit r15-66-g6c6b70f07208ca14ba783933988c04c6fc2fff42
Author: Jakub Jelinek 
Date:   Tue Apr 30 11:22:32 2024 +0200

gimple-ssa-sprintf: Use [0, 1] range for %lc with (wint_t) 0 argument 
[PR114876]

Seems when Martin S. implemented this, he coded there strict reading
of the standard, which said that %lc with (wint_t) 0 argument is handled
as wchar_t[2] temp = { arg, 0 }; %ls with temp arg and so shouldn't print
any values.  But, most of the libc implementations actually handled that
case like %c with '\0' argument, adding a single NUL character, the only
known exception is musl.
Recently, C23 changed this in response to GB-141 and POSIX in
https://austingroupbugs.net/view.php?id=1647
so that it should have the same behavior as %c with '\0'.

Because there is implementation divergence, the following patch uses
a range rather than hardcoding it to all 1s (i.e. the %c behavior),
though the likely case is still 1 (forward looking plus most of
implementations).
The res.knownrange = true; assignment removed is redundant due to
the same assignment done unconditionally before the if statement,
rest is formatting fixes.

I don't think the min >= 0 && min < 128 case is right either, I'd think
it should be min >= 0 && max < 128, otherwise it is just some possible
inputs are (maybe) ASCII and there can be others, but this code is a total
mess anyway, with the min, max, likely (somewhere in [min, max]?) and then
unlikely possibly larger than max, dunno, perhaps for at least some chars
in the ASCII range the likely case could be for the ascii case; so perhaps
just the one_2_one_ascii shouldn't set max to 1 and mayfail should be true
for max >= 128.  Anyway, didn't feel I should touch that right now.

2024-04-30  Jakub Jelinek  

PR tree-optimization/114876
* gimple-ssa-sprintf.cc (format_character): For min == 0 && max == 
0,
set max, likely and unlikely members to 1 rather than 0.  Remove
useless res.knownrange = true;.  Formatting fixes.

* gcc.dg/pr114876.c: New test.
* gcc.dg/tree-ssa/builtin-sprintf-warn-1.c: Adjust expected
diagnostics.

Diff:
---
 gcc/gimple-ssa-sprintf.cc  | 20 +++--
 gcc/testsuite/gcc.dg/pr114876.c| 34 ++
 .../gcc.dg/tree-ssa/builtin-sprintf-warn-1.c   | 12 
 3 files changed, 51 insertions(+), 15 deletions(-)

diff --git a/gcc/gimple-ssa-sprintf.cc b/gcc/gimple-ssa-sprintf.cc
index abb934b08d5..3b19f4d3f35 100644
--- a/gcc/gimple-ssa-sprintf.cc
+++ b/gcc/gimple-ssa-sprintf.cc
@@ -2177,8 +2177,7 @@ format_character (const directive &dir, tree arg, 
pointer_query &ptr_qry)
 
   res.knownrange = true;
 
-  if (dir.specifier == 'C'
-  || dir.modifier == FMT_LEN_l)
+  if (dir.specifier == 'C' || dir.modifier == FMT_LEN_l)
 {
   /* A wide character can result in as few as zero bytes.  */
   res.range.min = 0;
@@ -2189,10 +2188,13 @@ format_character (const directive &dir, tree arg, 
pointer_query &ptr_qry)
{
  if (min == 0 && max == 0)
{
- /* The NUL wide character results in no bytes.  */
- res.range.max = 0;
- res.range.likely = 0;
- res.range.unlikely = 0;
+ /* In strict reading of older ISO C or POSIX, this required
+no characters to be emitted.  ISO C23 changes that, so
+does POSIX, to match what has been implemented in most of the
+implementations, namely emitting a single NUL character.
+Let's use 0 for minimum and 1 for all the other values.  */
+ res.range.max = 1;
+ res.range.likely = res.range.unlikely = 1;
}
  else if (min >= 0 && min < 128)
{
@@ -2200,11 +2202,12 @@ format_character (const directive &dir, tree arg, 
pointer_query &ptr_qry)
 is not a 1-to-1 mapping to the source character set or
 if the source set is not ASCII.  */
  bool one_2_one_ascii
-   = (target_to_host_charmap[0] == 1 && target_to_host ('a') == 
97);
+   = (target_to_host_charmap[0] == 1
+  && target_to_host ('a') == 97);
 
  /* A wide character in the ASCII range most likely results
 in a single byte, and only unlikely in up to MB_LEN_MAX.  */
- res.range.max = one_2_one_ascii ? 1 : target_mb_len_max ();;
+ res.range.max = one_2_one_ascii ? 1 : target_mb_len_max ();
  res.range.likely = 1;
  res.range.unlikely = target_mb_len_max ();
  res.mayfail = !one_2_one_ascii;
@@ -2235,7 +2238,6 @@ format_character (const directive &dir, tree arg, 
pointer_query &ptr_qry)
   

[gcc r13-8663] [PATCH v3] RISC-V: Add split pattern to generate SFB instructions. [PR113095]

2024-04-30 Thread Kito Cheng via Gcc-cvs
https://gcc.gnu.org/g:6335baaf31c0f1f0952d1a3f507b0e5655b1136f

commit r13-8663-g6335baaf31c0f1f0952d1a3f507b0e5655b1136f
Author: Monk Chiang 
Date:   Wed Jan 24 10:19:28 2024 -0700

[PATCH v3] RISC-V: Add split pattern to generate SFB instructions. 
[PR113095]

Since the match.pd transforms (zero_one == 0) ? y : z  y,
into ((typeof(y))zero_one * z)  y. Add splitters to recongize
this expression to generate SFB instructions.

gcc/ChangeLog:
PR target/113095
* config/riscv/riscv.md: New splitters to rewrite single bit
sign extension as the condition to SFB instructions.

gcc/testsuite/ChangeLog:
* gcc.target/riscv/sfb.c: New test.
* gcc.target/riscv/pr113095.c: New test.

(cherry picked from commit fb54b9772816968032518d4008be5090e0d95109)

Diff:
---
 gcc/config/riscv/riscv.md | 32 +++
 gcc/testsuite/gcc.target/riscv/pr113095.c | 21 
 gcc/testsuite/gcc.target/riscv/sfb.c  | 24 +++
 3 files changed, 77 insertions(+)

diff --git a/gcc/config/riscv/riscv.md b/gcc/config/riscv/riscv.md
index bc384d9aedf..9a121c13d3b 100644
--- a/gcc/config/riscv/riscv.md
+++ b/gcc/config/riscv/riscv.md
@@ -2350,6 +2350,38 @@
(set_attr "type" "sfb_alu")
(set_attr "mode" "")])
 
+;; Combine creates this form ((typeof(y))zero_one * z)  y
+;; for SiFive short forward branches.
+
+(define_split
+  [(set (match_operand:X 0 "register_operand")
+   (and:X (sign_extract:X (match_operand:X 1 "register_operand")
+  (const_int 1)
+  (match_operand 2 "immediate_operand"))
+  (match_operand:X 3 "register_operand")))
+   (clobber (match_operand:X 4 "register_operand"))]
+  "TARGET_SFB_ALU"
+  [(set (match_dup 4) (zero_extract:X (match_dup 1) (const_int 1) (match_dup 
2)))
+   (set (match_dup 0) (if_then_else:X (ne (match_dup 4) (const_int 0))
+ (match_dup 3)
+ (const_int 0)))])
+
+(define_split
+  [(set (match_operand:X 0 "register_operand")
+   (and:X (sign_extract:X (match_operand:X 1 "register_operand")
+  (const_int 1)
+  (match_operand 2 "immediate_operand"))
+  (match_operand:X 3 "register_operand")))
+   (clobber (match_operand:X 4 "register_operand"))]
+  "TARGET_SFB_ALU && (UINTVAL (operands[2]) < 11)"
+  [(set (match_dup 4) (and:X (match_dup 1) (match_dup 2)))
+   (set (match_dup 0) (if_then_else:X (ne (match_dup 4) (const_int 0))
+ (match_dup 3)
+ (const_int 0)))]
+{
+  operands[2] = GEN_INT (1 << UINTVAL(operands[2]));
+})
+
 ;; Used to implement built-in functions.
 (define_expand "condjump"
   [(set (pc)
diff --git a/gcc/testsuite/gcc.target/riscv/pr113095.c 
b/gcc/testsuite/gcc.target/riscv/pr113095.c
new file mode 100644
index 000..04321b58dc7
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/pr113095.c
@@ -0,0 +1,21 @@
+/* { dg-do run } */
+/* { dg-options "-O2 -march=rv32gc -mabi=ilp32d -mtune=sifive-7-series" { 
target { rv32 } } } */
+/* { dg-options "-O2 -march=rv64gc -mabi=lp64d -mtune=sifive-7-series" {target 
{ rv64 } } } */
+
+extern void abort (void);
+extern void exit (int);
+
+unsigned short __attribute__ ((noinline, noclone))
+foo (unsigned short x) {
+  if (x == 1)
+x ^= 0x4002;
+
+  return x;
+}
+
+int main () {
+  if (foo(1) != 0x4003)
+abort ();
+
+  exit(0);
+}
diff --git a/gcc/testsuite/gcc.target/riscv/sfb.c 
b/gcc/testsuite/gcc.target/riscv/sfb.c
new file mode 100644
index 000..22f164051f4
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/sfb.c
@@ -0,0 +1,24 @@
+//* { dg-do compile } */
+/* { dg-options "-O2 -march=rv32gc -mabi=ilp32d -mtune=sifive-7-series" } */
+
+int f1(unsigned int x, unsigned int y, unsigned int z)
+{
+  return ((x & 1) == 0) ? y : z ^ y;
+}
+
+int f2(unsigned int x, unsigned int y, unsigned int z)
+{
+  return ((x & 1) != 0) ? z ^ y : y;
+}
+
+int f3(unsigned int x, unsigned int y, unsigned int z)
+{
+  return ((x & 1) == 0) ? y : z | y;
+}
+
+int f4(unsigned int x, unsigned int y, unsigned int z)
+{
+  return ((x & 1) != 0) ? z | y : y;
+}
+/* { dg-final { scan-assembler-times "bne" 4 } } */
+/* { dg-final { scan-assembler-times "movcc" 4 } } */


[gcc r15-65] Fix pretty printers regexp for GDB output

2024-04-30 Thread Christophe Lyon via Libstdc++-cvs
https://gcc.gnu.org/g:6d4593a178b49cab205d81cdf36f52e12eabbc6d

commit r15-65-g6d4593a178b49cab205d81cdf36f52e12eabbc6d
Author: Christophe Lyon 
Date:   Thu Jan 25 15:43:56 2024 +

Fix pretty printers regexp for GDB output

GDB emits end of lines as \r\n, we currently match any >0 number of
either \n or \r, possibly leading to mismatches under racy conditions.

I noticed this while running the GCC testsuite using the equivalent of
GDB's READ1 feature [1] which helps detecting bufferization issues.

We try to match
\n$1 = empty std::tuple\r

against {^(type|\$([0-9]+)) = ([^\n\r]*)[\n\r]+} which fails because
of the leading \n (which was left in the buffer after the previous
"skipping" pattern matched the preceding \r).

This patch accepts any number of leading \n and/or \r in the "got" clause.

Also take this opportunity to quote \r and \r in the logs, to make
debugging such issues easier.

Tested on aarch64-linux-gnu.

[1] 
https//github.com/bminor/binutils-gdb/blob/master/gdb/testsuite/README#L269

2024-01-24  Christophe Lyon  

libstdc++-v3/
* testsuite/lib/gdb-test.exp (gdb-test): Fix regexp.  Quote
newlines in logs.

Diff:
---
 libstdc++-v3/testsuite/lib/gdb-test.exp | 12 +---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/libstdc++-v3/testsuite/lib/gdb-test.exp 
b/libstdc++-v3/testsuite/lib/gdb-test.exp
index 31206f2fc32..2ec5596983d 100644
--- a/libstdc++-v3/testsuite/lib/gdb-test.exp
+++ b/libstdc++-v3/testsuite/lib/gdb-test.exp
@@ -194,8 +194,11 @@ proc gdb-test { marker {selector {}} {load_xmethods 0} } {
 
 set test_counter 0
 remote_expect target [timeout_value] {
-   -re {^(type|\$([0-9]+)) = ([^\n\r]*)[\n\r]+} {
-   send_log "got: $expect_out(buffer)"
+   -re {^[\n\r]*(type|\$([0-9]+)) = ([^\n\r]*)[\n\r]+} {
+   # Escape newlines so that we can print them.
+   set escaped [string map {"\n" "\\n"} $expect_out(buffer)]
+   set escaped2 [string map {"\r" "\\r"} $escaped]
+   send_log "got: $escaped2"
 
incr test_counter
set first $expect_out(3,string)
@@ -251,7 +254,10 @@ proc gdb-test { marker {selector {}} {load_xmethods 0} } {
}
 
-re {^[^$][^\n\r]*[\n\r]+} {
-   send_log "skipping: $expect_out(buffer)"
+   # Escape newlines so that we can print them.
+   set escaped [string map {"\n" "\\n"} $expect_out(buffer)]
+   set escaped2 [string map {"\r" "\\r"} $escaped]
+   send_log "skipping: $escaped2"
exp_continue
}


[gcc r14-10154] libstdc++: Do not apply localized formatting to NaN and inf [PR114863]

2024-04-30 Thread Jonathan Wakely via Libstdc++-cvs
https://gcc.gnu.org/g:7a00c459cbb913ac165a39d344a48fc27800bb0a

commit r14-10154-g7a00c459cbb913ac165a39d344a48fc27800bb0a
Author: Jonathan Wakely 
Date:   Fri Apr 26 11:42:26 2024 +0100

libstdc++: Do not apply localized formatting to NaN and inf [PR114863]

We don't want to add grouping to strings like "-inf", and there is no
radix character to replace either.

libstdc++-v3/ChangeLog:

PR libstdc++/114863
* include/std/format (__formatter_fp::format): Only use
_M_localized for finite values.
* testsuite/std/format/functions/format.cc: Check localized
formatting of NaN and initiny.

(cherry picked from commit 7501c0a397fcf609a1ff5f083746b6330b89ee11)

Diff:
---
 libstdc++-v3/include/std/format   | 2 +-
 libstdc++-v3/testsuite/std/format/functions/format.cc | 8 
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/libstdc++-v3/include/std/format b/libstdc++-v3/include/std/format
index 22dcb5f24bd..48deba2bcb2 100644
--- a/libstdc++-v3/include/std/format
+++ b/libstdc++-v3/include/std/format
@@ -1734,7 +1734,7 @@ namespace __format
}
 #endif
 
- if (_M_spec._M_localized)
+ if (_M_spec._M_localized && __builtin_isfinite(__v))
{
  __wstr = _M_localize(__str, __expc, __fc.locale());
  if (!__wstr.empty())
diff --git a/libstdc++-v3/testsuite/std/format/functions/format.cc 
b/libstdc++-v3/testsuite/std/format/functions/format.cc
index 4499397aaf9..78cc1ab482a 100644
--- a/libstdc++-v3/testsuite/std/format/functions/format.cc
+++ b/libstdc++-v3/testsuite/std/format/functions/format.cc
@@ -248,6 +248,14 @@ test_locale()
   s = std::format(cloc, "{:05L}", -1.0); // PR libstdc++/110968
   VERIFY( s == "-0001" );
 
+  // PR libstdc++/114863 grouping applied to nan and inf
+  double inf = std::numeric_limits::infinity();
+  s = std::format(eloc, "{0:Le} {0:Lf} {0:Lg}", -inf);
+  VERIFY( s == "-inf -inf -inf" );
+  double nan = std::numeric_limits::quiet_NaN();
+  s = std::format(eloc, "{0:Le} {0:Lf} {0:Lg}", -nan);
+  VERIFY( s == "-nan -nan -nan" );
+
   // Restore
   std::locale::global(cloc);
 }


[gcc r13-8662] target/111600 - avoid deep recursion in access diagnostics

2024-04-30 Thread Richard Biener via Gcc-cvs
https://gcc.gnu.org/g:440a612dbadfae5887ec7c9b3ab2fca88b065366

commit r13-8662-g440a612dbadfae5887ec7c9b3ab2fca88b065366
Author: Richard Biener 
Date:   Thu Sep 28 11:51:30 2023 +0200

target/111600 - avoid deep recursion in access diagnostics

pass_waccess::check_dangling_stores uses recursion to traverse the CFG.
The following changes this to use a heap allocated worklist to avoid
blowing the stack.

Instead of using a better iteration order it tries hard to preserve
the current iteration order to avoid new false positives to pop up
since the set of stores we keep track isn't properly modeling flow,
so what is diagnosed and what not is quite random.  We are also
lacking the ideal RPO compute on the inverted graph that would just
ignore reverse unreachable code (as the current iteration scheme does).

PR target/111600
* gimple-ssa-warn-access.cc (pass_waccess::check_dangling_stores):
Use a heap allocated worklist for CFG traversal instead of
recursion.

(cherry picked from commit f194c684a28a5d449bd034a2c604d04ba465e4fe)

Diff:
---
 gcc/gimple-ssa-warn-access.cc | 51 +++
 1 file changed, 32 insertions(+), 19 deletions(-)

diff --git a/gcc/gimple-ssa-warn-access.cc b/gcc/gimple-ssa-warn-access.cc
index cd02a02b1da..5a3b9a37b6c 100644
--- a/gcc/gimple-ssa-warn-access.cc
+++ b/gcc/gimple-ssa-warn-access.cc
@@ -2143,7 +2143,7 @@ private:
   void check_dangling_uses (tree, tree, bool = false, bool = false);
   void check_dangling_uses ();
   void check_dangling_stores ();
-  void check_dangling_stores (basic_block, hash_set &, auto_bitmap &);
+  bool check_dangling_stores (basic_block, hash_set &);
 
   void warn_invalid_pointer (tree, gimple *, gimple *, tree, bool, bool = 
false);
 
@@ -4526,17 +4526,13 @@ pass_waccess::check_dangling_uses (tree var, tree decl, 
bool maybe /* = false */
 
 /* Diagnose stores in BB and (recursively) its predecessors of the addresses
of local variables into nonlocal pointers that are left dangling after
-   the function returns.  BBS is a bitmap of basic blocks visited.  */
+   the function returns.  Returns true when we can continue walking
+   the CFG to predecessors.  */
 
-void
+bool
 pass_waccess::check_dangling_stores (basic_block bb,
-hash_set &stores,
-auto_bitmap &bbs)
+hash_set &stores)
 {
-  if (!bitmap_set_bit (bbs, bb->index))
-/* Avoid cycles. */
-return;
-
   /* Iterate backwards over the statements looking for a store of
  the address of a local variable into a nonlocal pointer.  */
   for (auto gsi = gsi_last_nondebug_bb (bb); ; gsi_prev_nondebug (&gsi))
@@ -4552,7 +4548,7 @@ pass_waccess::check_dangling_stores (basic_block bb,
  && !(gimple_call_flags (stmt) & (ECF_CONST | ECF_PURE)))
/* Avoid looking before nonconst, nonpure calls since those might
   use the escaped locals.  */
-   return;
+   return false;
 
   if (!is_gimple_assign (stmt) || gimple_clobber_p (stmt)
  || !gimple_store_p (stmt))
@@ -4578,7 +4574,7 @@ pass_waccess::check_dangling_stores (basic_block bb,
  gimple *def_stmt = SSA_NAME_DEF_STMT (lhs_ref.ref);
  if (!gimple_nop_p (def_stmt))
/* Avoid looking at or before stores into unknown objects.  */
-   return;
+   return false;
 
  lhs_ref.ref = SSA_NAME_VAR (lhs_ref.ref);
}
@@ -4622,13 +4618,7 @@ pass_waccess::check_dangling_stores (basic_block bb,
}
 }
 
-  edge e;
-  edge_iterator ei;
-  FOR_EACH_EDGE (e, ei, bb->preds)
-{
-  basic_block pred = e->src;
-  check_dangling_stores (pred, stores, bbs);
-}
+  return true;
 }
 
 /* Diagnose stores of the addresses of local variables into nonlocal
@@ -4637,9 +4627,32 @@ pass_waccess::check_dangling_stores (basic_block bb,
 void
 pass_waccess::check_dangling_stores ()
 {
+  if (EDGE_COUNT (EXIT_BLOCK_PTR_FOR_FN (m_func)->preds) == 0)
+return;
+
   auto_bitmap bbs;
   hash_set stores;
-  check_dangling_stores (EXIT_BLOCK_PTR_FOR_FN (m_func), stores, bbs);
+  auto_vec worklist (n_basic_blocks_for_fn (cfun) + 1);
+  worklist.quick_push (ei_start (EXIT_BLOCK_PTR_FOR_FN (m_func)->preds));
+  do
+{
+  edge_iterator ei = worklist.last ();
+  basic_block src = ei_edge (ei)->src;
+  if (bitmap_set_bit (bbs, src->index))
+   {
+ if (check_dangling_stores (src, stores)
+ && EDGE_COUNT (src->preds) > 0)
+   worklist.quick_push (ei_start (src->preds));
+   }
+  else
+   {
+ if (ei_one_before_end_p (ei))
+   worklist.pop ();
+ else
+   ei_next (&worklist.last ());
+   }
+}
+  while (!worklist.is_empty ());
 }
 
 /* Check for and diagnose uses of dangling pointers to auto objects


[gcc r14-10153] Fortran: Fix regression caused by r14-9752 [PR114959]

2024-04-30 Thread Jakub Jelinek via Gcc-cvs
https://gcc.gnu.org/g:e976bef1579086e6e83c6a47f6c5f8f996208f99

commit r14-10153-ge976bef1579086e6e83c6a47f6c5f8f996208f99
Author: Paul Thomas 
Date:   Mon Apr 29 11:52:11 2024 +0100

Fortran: Fix regression caused by r14-9752 [PR114959]

2024-04-29  Paul Thomas  

gcc/fortran
PR fortran/114959
* trans-expr.cc (gfc_trans_class_init_assign): Return NULL_TREE
if the default initializer has all NULL fields. Guard this
by a requirement that the code not be EXEC_INIT_ASSIGN and that
the object be an INTENT_OUT dummy.
* trans-stmt.cc (gfc_trans_allocate): Change the initializer
code for allocate with mold to EXEC_ALLOCATE to allow an
initializer with all NULL fields.

gcc/testsuite/
PR fortran/114959
* gfortran.dg/pr114959.f90: New test.

(cherry picked from commit bca41a8d55e830c882b0f39246afead4fcfae6f7)

Diff:
---
 gcc/fortran/trans-expr.cc  | 28 ++--
 gcc/fortran/trans-stmt.cc  |  5 +++--
 gcc/testsuite/gfortran.dg/pr114959.f90 | 33 +
 3 files changed, 54 insertions(+), 12 deletions(-)

diff --git a/gcc/fortran/trans-expr.cc b/gcc/fortran/trans-expr.cc
index 072adf3fe77..0280c441ced 100644
--- a/gcc/fortran/trans-expr.cc
+++ b/gcc/fortran/trans-expr.cc
@@ -1720,6 +1720,7 @@ gfc_trans_class_init_assign (gfc_code *code)
   gfc_se dst,src,memsz;
   gfc_expr *lhs, *rhs, *sz;
   gfc_component *cmp;
+  gfc_symbol *sym;
 
   gfc_start_block (&block);
 
@@ -1736,18 +1737,25 @@ gfc_trans_class_init_assign (gfc_code *code)
   /* The _def_init is always scalar.  */
   rhs->rank = 0;
 
-  /* Check def_init for initializers.  If this is a dummy with all default
- initializer components NULL, return NULL_TREE and use the passed value as
- required by F2018(8.5.10).  */
-  if (!lhs->ref && lhs->symtree->n.sym->attr.dummy)
+  /* Check def_init for initializers.  If this is an INTENT(OUT) dummy with all
+ default initializer components NULL, return NULL_TREE and use the passed
+ value as required by F2018(8.5.10).  */
+  sym = code->expr1->expr_type == EXPR_VARIABLE ? code->expr1->symtree->n.sym
+   : NULL;
+  if (code->op != EXEC_ALLOCATE
+  && sym && sym->attr.dummy
+  && sym->attr.intent == INTENT_OUT)
 {
-  cmp = rhs->ref->next->u.c.component->ts.u.derived->components;
-  for (; cmp; cmp = cmp->next)
+  if (!lhs->ref && lhs->symtree->n.sym->attr.dummy)
{
- if (cmp->initializer)
-   break;
- else if (!cmp->next)
-   return build_empty_stmt (input_location);
+ cmp = rhs->ref->next->u.c.component->ts.u.derived->components;
+ for (; cmp; cmp = cmp->next)
+   {
+ if (cmp->initializer)
+   break;
+ else if (!cmp->next)
+   return NULL_TREE;
+   }
}
 }
 
diff --git a/gcc/fortran/trans-stmt.cc b/gcc/fortran/trans-stmt.cc
index c34e0b4c0cd..d355009fa5e 100644
--- a/gcc/fortran/trans-stmt.cc
+++ b/gcc/fortran/trans-stmt.cc
@@ -7262,11 +7262,12 @@ gfc_trans_allocate (gfc_code * code, gfc_omp_namelist 
*omp_allocate)
{
  /* Use class_init_assign to initialize expr.  */
  gfc_code *ini;
- ini = gfc_get_code (EXEC_INIT_ASSIGN);
+ ini = gfc_get_code (EXEC_ALLOCATE);
  ini->expr1 = gfc_find_and_cut_at_last_class_ref (expr, true);
  tmp = gfc_trans_class_init_assign (ini);
  gfc_free_statements (ini);
- gfc_add_expr_to_block (&block, tmp);
+ if (tmp != NULL_TREE)
+   gfc_add_expr_to_block (&block, tmp);
}
   else if ((init_expr = allocate_get_initializer (code, expr)))
{
diff --git a/gcc/testsuite/gfortran.dg/pr114959.f90 
b/gcc/testsuite/gfortran.dg/pr114959.f90
new file mode 100644
index 000..5cc3c052c1d
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr114959.f90
@@ -0,0 +1,33 @@
+! { dg-do compile }
+! { dg-options "-fdump-tree-original" }
+!
+! Fix the regression caused by r14-9752 (fix for PR112407)
+! Contributed by Orion Poplawski  
+! Problem isolated by Jakub Jelinek   and further
+! reduced here.
+!
+module m
+  type :: smoother_type
+integer :: i
+  end type
+  type :: onelev_type
+class(smoother_type), allocatable :: sm
+class(smoother_type), allocatable :: sm2a
+  end type
+contains
+  subroutine save_smoothers(level,save1, save2)
+Implicit None
+type(onelev_type), intent(inout) :: level
+class(smoother_type), allocatable , intent(inout) :: save1, save2
+integer(4) :: info
+
+info  = 0
+! r14-9752 causes the 'stat' declaration from the first ALLOCATE statement
+! to disappear, which triggers an ICE in gimplify_var_or_parm_decl. The
+! second ALLOCATE statement has to be present for the ICE to occur.
+allocate(save1, mold=level%sm,sta

[gcc r14-10152] vect: Adjust vect_transform_reduction assertion [PR114883]

2024-04-30 Thread Jakub Jelinek via Gcc-cvs
https://gcc.gnu.org/g:a795a7b67027bc976a353b5fa927ac8c5f29347d

commit r14-10152-ga795a7b67027bc976a353b5fa927ac8c5f29347d
Author: Jakub Jelinek 
Date:   Tue Apr 30 10:11:47 2024 +0200

vect: Adjust vect_transform_reduction assertion [PR114883]

The assertion doesn't allow IFN_COND_MIN/IFN_COND_MAX, which are
commutative conditional binary operations like ADD/MUL/AND/IOR/XOR,
and can be handled just fine.
In particular, we emit
vminpd  %zmm3, %zmm5, %zmm0{%k2}
vminpd  %zmm0, %zmm3, %zmm5{%k1}
and
vmaxpd  %zmm3, %zmm5, %zmm0{%k2}
vmaxpd  %zmm0, %zmm3, %zmm5{%k1}
in the vectorized loops of the first and second subroutine.

2024-04-30  Jakub Jelinek  
Hongtao Liu  

PR tree-optimization/114883
* tree-vect-loop.cc (vect_transform_reduction): Allow IFN_COND_MIN 
and
IFN_COND_MAX in the assert.

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

(cherry picked from commit 04ef92a62af3a815b86a2037267cd4e747ae225c)

Diff:
---
 gcc/testsuite/gfortran.dg/pr114883.f90 | 53 ++
 gcc/tree-vect-loop.cc  |  3 +-
 2 files changed, 55 insertions(+), 1 deletion(-)

diff --git a/gcc/testsuite/gfortran.dg/pr114883.f90 
b/gcc/testsuite/gfortran.dg/pr114883.f90
new file mode 100644
index 000..3fec1d278b3
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr114883.f90
@@ -0,0 +1,53 @@
+! PR tree-optimization/114883
+! { dg-do compile }
+! { dg-options "-O2 -fvect-cost-model=cheap" }
+! { dg-additional-options "-march=x86-64-v4" { target i?86-*-* x86_64-*-* } }
+
+subroutine pr114883_1(a, b, c, d, e, f, g, h, o)
+  real(8) :: c(1011), d(1011), e(0:1011)
+  real(8) :: p, q, f, r, g(1011), h(1011), b, bar
+  integer :: o(100), a, t, u
+  p = 0.0_8
+  r = bar()
+  u = 1
+  do i = 1,a
+do k = 1,1011
+  km1 = max0(k-1,1)
+  h(k) = c(k) * e(k-1) * d(km1)
+  f = g(k) + h(k)
+  if(f.gt.1.e-6)then
+p = min(p,r)
+  endif
+end do
+q = 0.9_8 * p
+t = integer(b/q + 1)
+if(t>100)then
+  u = t
+endif
+o(u) = o(u) + 1
+  end do
+end subroutine pr114883_1
+subroutine pr114883_2(a, b, c, d, e, f, g, h, o)
+  real(8) :: c(1011), d(1011), e(0:1011)
+  real(8) :: p, q, f, r, g(1011), h(1011), b, bar
+  integer :: o(100), a, t, u
+  p = 0.0_8
+  r = bar()
+  u = 1
+  do i = 1,a
+do k = 1,1011
+  km1 = max0(k-1,1)
+  h(k) = c(k) * e(k-1) * d(km1)
+  f = g(k) + h(k)
+  if(f.gt.1.e-6)then
+p = max(p,r)
+  endif
+end do
+q = 0.9_8 * p
+t = integer(b/q + 1)
+if(t>100)then
+  u = t
+endif
+o(u) = o(u) + 1
+  end do
+end subroutine pr114883_2
diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc
index a6cf0a5546c..29c03c246d4 100644
--- a/gcc/tree-vect-loop.cc
+++ b/gcc/tree-vect-loop.cc
@@ -8505,7 +8505,8 @@ vect_transform_reduction (loop_vec_info loop_vinfo,
 {
   gcc_assert (code == IFN_COND_ADD || code == IFN_COND_SUB
  || code == IFN_COND_MUL || code == IFN_COND_AND
- || code == IFN_COND_IOR || code == IFN_COND_XOR);
+ || code == IFN_COND_IOR || code == IFN_COND_XOR
+ || code == IFN_COND_MIN || code == IFN_COND_MAX);
   gcc_assert (op.num_ops == 4
  && (op.ops[reduc_index]
  == op.ops[internal_fn_else_index ((internal_fn) code)]));


[gcc(refs/vendors/redhat/heads/gcc-14-branch)] vect: Adjust vect_transform_reduction assertion [PR114883]

2024-04-30 Thread Jakub Jelinek via Gcc-cvs
https://gcc.gnu.org/g:f7b939b4351d6ea38c58cefcc55c79325912d087

commit f7b939b4351d6ea38c58cefcc55c79325912d087
Author: Jakub Jelinek 
Date:   Tue Apr 30 10:11:47 2024 +0200

vect: Adjust vect_transform_reduction assertion [PR114883]

The assertion doesn't allow IFN_COND_MIN/IFN_COND_MAX, which are
commutative conditional binary operations like ADD/MUL/AND/IOR/XOR,
and can be handled just fine.
In particular, we emit
vminpd  %zmm3, %zmm5, %zmm0{%k2}
vminpd  %zmm0, %zmm3, %zmm5{%k1}
and
vmaxpd  %zmm3, %zmm5, %zmm0{%k2}
vmaxpd  %zmm0, %zmm3, %zmm5{%k1}
in the vectorized loops of the first and second subroutine.

2024-04-30  Jakub Jelinek  
Hongtao Liu  

PR tree-optimization/114883
* tree-vect-loop.cc (vect_transform_reduction): Allow IFN_COND_MIN 
and
IFN_COND_MAX in the assert.

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

(cherry picked from commit 04ef92a62af3a815b86a2037267cd4e747ae225c)

Diff:
---
 gcc/testsuite/gfortran.dg/pr114883.f90 | 53 ++
 gcc/tree-vect-loop.cc  |  3 +-
 2 files changed, 55 insertions(+), 1 deletion(-)

diff --git a/gcc/testsuite/gfortran.dg/pr114883.f90 
b/gcc/testsuite/gfortran.dg/pr114883.f90
new file mode 100644
index 000..3fec1d278b3
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr114883.f90
@@ -0,0 +1,53 @@
+! PR tree-optimization/114883
+! { dg-do compile }
+! { dg-options "-O2 -fvect-cost-model=cheap" }
+! { dg-additional-options "-march=x86-64-v4" { target i?86-*-* x86_64-*-* } }
+
+subroutine pr114883_1(a, b, c, d, e, f, g, h, o)
+  real(8) :: c(1011), d(1011), e(0:1011)
+  real(8) :: p, q, f, r, g(1011), h(1011), b, bar
+  integer :: o(100), a, t, u
+  p = 0.0_8
+  r = bar()
+  u = 1
+  do i = 1,a
+do k = 1,1011
+  km1 = max0(k-1,1)
+  h(k) = c(k) * e(k-1) * d(km1)
+  f = g(k) + h(k)
+  if(f.gt.1.e-6)then
+p = min(p,r)
+  endif
+end do
+q = 0.9_8 * p
+t = integer(b/q + 1)
+if(t>100)then
+  u = t
+endif
+o(u) = o(u) + 1
+  end do
+end subroutine pr114883_1
+subroutine pr114883_2(a, b, c, d, e, f, g, h, o)
+  real(8) :: c(1011), d(1011), e(0:1011)
+  real(8) :: p, q, f, r, g(1011), h(1011), b, bar
+  integer :: o(100), a, t, u
+  p = 0.0_8
+  r = bar()
+  u = 1
+  do i = 1,a
+do k = 1,1011
+  km1 = max0(k-1,1)
+  h(k) = c(k) * e(k-1) * d(km1)
+  f = g(k) + h(k)
+  if(f.gt.1.e-6)then
+p = max(p,r)
+  endif
+end do
+q = 0.9_8 * p
+t = integer(b/q + 1)
+if(t>100)then
+  u = t
+endif
+o(u) = o(u) + 1
+  end do
+end subroutine pr114883_2
diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc
index 3ffcac8c613..6a912f2c2d7 100644
--- a/gcc/tree-vect-loop.cc
+++ b/gcc/tree-vect-loop.cc
@@ -8504,7 +8504,8 @@ vect_transform_reduction (loop_vec_info loop_vinfo,
 {
   gcc_assert (code == IFN_COND_ADD || code == IFN_COND_SUB
  || code == IFN_COND_MUL || code == IFN_COND_AND
- || code == IFN_COND_IOR || code == IFN_COND_XOR);
+ || code == IFN_COND_IOR || code == IFN_COND_XOR
+ || code == IFN_COND_MIN || code == IFN_COND_MAX);
   gcc_assert (op.num_ops == 4
  && (op.ops[reduc_index]
  == op.ops[internal_fn_else_index ((internal_fn) code)]));


[gcc r15-64] vect: Adjust vect_transform_reduction assertion [PR114883]

2024-04-30 Thread Jakub Jelinek via Gcc-cvs
https://gcc.gnu.org/g:04ef92a62af3a815b86a2037267cd4e747ae225c

commit r15-64-g04ef92a62af3a815b86a2037267cd4e747ae225c
Author: Jakub Jelinek 
Date:   Tue Apr 30 10:11:47 2024 +0200

vect: Adjust vect_transform_reduction assertion [PR114883]

The assertion doesn't allow IFN_COND_MIN/IFN_COND_MAX, which are
commutative conditional binary operations like ADD/MUL/AND/IOR/XOR,
and can be handled just fine.
In particular, we emit
vminpd  %zmm3, %zmm5, %zmm0{%k2}
vminpd  %zmm0, %zmm3, %zmm5{%k1}
and
vmaxpd  %zmm3, %zmm5, %zmm0{%k2}
vmaxpd  %zmm0, %zmm3, %zmm5{%k1}
in the vectorized loops of the first and second subroutine.

2024-04-30  Jakub Jelinek  
Hongtao Liu  

PR tree-optimization/114883
* tree-vect-loop.cc (vect_transform_reduction): Allow IFN_COND_MIN 
and
IFN_COND_MAX in the assert.

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

Diff:
---
 gcc/testsuite/gfortran.dg/pr114883.f90 | 53 ++
 gcc/tree-vect-loop.cc  |  3 +-
 2 files changed, 55 insertions(+), 1 deletion(-)

diff --git a/gcc/testsuite/gfortran.dg/pr114883.f90 
b/gcc/testsuite/gfortran.dg/pr114883.f90
new file mode 100644
index 000..3fec1d278b3
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr114883.f90
@@ -0,0 +1,53 @@
+! PR tree-optimization/114883
+! { dg-do compile }
+! { dg-options "-O2 -fvect-cost-model=cheap" }
+! { dg-additional-options "-march=x86-64-v4" { target i?86-*-* x86_64-*-* } }
+
+subroutine pr114883_1(a, b, c, d, e, f, g, h, o)
+  real(8) :: c(1011), d(1011), e(0:1011)
+  real(8) :: p, q, f, r, g(1011), h(1011), b, bar
+  integer :: o(100), a, t, u
+  p = 0.0_8
+  r = bar()
+  u = 1
+  do i = 1,a
+do k = 1,1011
+  km1 = max0(k-1,1)
+  h(k) = c(k) * e(k-1) * d(km1)
+  f = g(k) + h(k)
+  if(f.gt.1.e-6)then
+p = min(p,r)
+  endif
+end do
+q = 0.9_8 * p
+t = integer(b/q + 1)
+if(t>100)then
+  u = t
+endif
+o(u) = o(u) + 1
+  end do
+end subroutine pr114883_1
+subroutine pr114883_2(a, b, c, d, e, f, g, h, o)
+  real(8) :: c(1011), d(1011), e(0:1011)
+  real(8) :: p, q, f, r, g(1011), h(1011), b, bar
+  integer :: o(100), a, t, u
+  p = 0.0_8
+  r = bar()
+  u = 1
+  do i = 1,a
+do k = 1,1011
+  km1 = max0(k-1,1)
+  h(k) = c(k) * e(k-1) * d(km1)
+  f = g(k) + h(k)
+  if(f.gt.1.e-6)then
+p = max(p,r)
+  endif
+end do
+q = 0.9_8 * p
+t = integer(b/q + 1)
+if(t>100)then
+  u = t
+endif
+o(u) = o(u) + 1
+  end do
+end subroutine pr114883_2
diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc
index a6cf0a5546c..29c03c246d4 100644
--- a/gcc/tree-vect-loop.cc
+++ b/gcc/tree-vect-loop.cc
@@ -8505,7 +8505,8 @@ vect_transform_reduction (loop_vec_info loop_vinfo,
 {
   gcc_assert (code == IFN_COND_ADD || code == IFN_COND_SUB
  || code == IFN_COND_MUL || code == IFN_COND_AND
- || code == IFN_COND_IOR || code == IFN_COND_XOR);
+ || code == IFN_COND_IOR || code == IFN_COND_XOR
+ || code == IFN_COND_MIN || code == IFN_COND_MAX);
   gcc_assert (op.num_ops == 4
  && (op.ops[reduc_index]
  == op.ops[internal_fn_else_index ((internal_fn) code)]));


[gcc r14-10151] libgcc: Do use weakrefs for glibc 2.34 on GNU Hurd

2024-04-30 Thread Jakub Jelinek via Gcc-cvs
https://gcc.gnu.org/g:af925ba8e2b1e76d33a83a85df398f23a2ea2b34

commit r14-10151-gaf925ba8e2b1e76d33a83a85df398f23a2ea2b34
Author: Jakub Jelinek 
Date:   Tue Apr 30 09:00:07 2024 +0200

libgcc: Do use weakrefs for glibc 2.34 on GNU Hurd

On Mon, Apr 29, 2024 at 01:44:24PM +, Joseph Myers wrote:
> > glibc 2.34 and later doesn't have separate libpthread (libpthread.so.0 
is a
> > dummy shared library with just some symbol versions for compatibility, 
but
> > all the pthread_* APIs are in libc.so.6).
>
> I suspect this has caused link failures in the glibc testsuite for Hurd,
> which still has separate libpthread.
>
> https://sourceware.org/pipermail/libc-testresults/2024q2/012556.html

So like this then?

2024-04-30  Jakub Jelinek  

* gthr.h (GTHREAD_USE_WEAK): Don't redefine to 0 for glibc 2.34+
on GNU Hurd.

(cherry picked from commit 3146a92a77f1fccec71a880c7f890a1251aeab41)

Diff:
---
 libgcc/gthr.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libgcc/gthr.h b/libgcc/gthr.h
index 53a5f0f7458..33c2d8ff630 100644
--- a/libgcc/gthr.h
+++ b/libgcc/gthr.h
@@ -142,7 +142,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  
If not, see
 #endif
 
 #ifdef __GLIBC_PREREQ
-#if __GLIBC_PREREQ(2, 34)
+#if __GLIBC_PREREQ(2, 34) && !defined(__gnu_hurd__)
 /* glibc 2.34 and later has all pthread_* APIs inside of libc,
no need to link separately with -lpthread.  */
 #undef GTHREAD_USE_WEAK


[gcc r14-10150] Set DEV-PHASE to prerelease.

2024-04-30 Thread Jakub Jelinek via Gcc-cvs
https://gcc.gnu.org/g:501fed8078d4217873e44537b0a9437c66cf39be

commit r14-10150-g501fed8078d4217873e44537b0a9437c66cf39be
Author: Jakub Jelinek 
Date:   Fri Apr 26 11:49:28 2024 +0200

Set DEV-PHASE to prerelease.

2024-04-26  Jakub Jelinek  

* DEV-PHASE: Set to prerelease.

Diff:
---
 gcc/DEV-PHASE | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/DEV-PHASE b/gcc/DEV-PHASE
index 9839eb20815..373fbc60bb9 100644
--- a/gcc/DEV-PHASE
+++ b/gcc/DEV-PHASE
@@ -1 +1 @@
-experimental
+prerelease


[gcc r15-63] libgcc: Do use weakrefs for glibc 2.34 on GNU Hurd

2024-04-30 Thread Jakub Jelinek via Gcc-cvs
https://gcc.gnu.org/g:3146a92a77f1fccec71a880c7f890a1251aeab41

commit r15-63-g3146a92a77f1fccec71a880c7f890a1251aeab41
Author: Jakub Jelinek 
Date:   Tue Apr 30 09:00:07 2024 +0200

libgcc: Do use weakrefs for glibc 2.34 on GNU Hurd

On Mon, Apr 29, 2024 at 01:44:24PM +, Joseph Myers wrote:
> > glibc 2.34 and later doesn't have separate libpthread (libpthread.so.0 
is a
> > dummy shared library with just some symbol versions for compatibility, 
but
> > all the pthread_* APIs are in libc.so.6).
>
> I suspect this has caused link failures in the glibc testsuite for Hurd,
> which still has separate libpthread.
>
> https://sourceware.org/pipermail/libc-testresults/2024q2/012556.html

So like this then?

2024-04-30  Jakub Jelinek  

* gthr.h (GTHREAD_USE_WEAK): Don't redefine to 0 for glibc 2.34+
on GNU Hurd.

Diff:
---
 libgcc/gthr.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libgcc/gthr.h b/libgcc/gthr.h
index 53a5f0f7458..33c2d8ff630 100644
--- a/libgcc/gthr.h
+++ b/libgcc/gthr.h
@@ -142,7 +142,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  
If not, see
 #endif
 
 #ifdef __GLIBC_PREREQ
-#if __GLIBC_PREREQ(2, 34)
+#if __GLIBC_PREREQ(2, 34) && !defined(__gnu_hurd__)
 /* glibc 2.34 and later has all pthread_* APIs inside of libc,
no need to link separately with -lpthread.  */
 #undef GTHREAD_USE_WEAK