[gcc r15-9000] testsuite, riscv: fix broken dg directives

2025-03-28 Thread Sam James via Gcc-cvs
https://gcc.gnu.org/g:04e51876108ed0ae422856ce7440ed708e9b0cf8

commit r15-9000-g04e51876108ed0ae422856ce7440ed708e9b0cf8
Author: David Malcolm 
Date:   Wed Mar 26 14:34:53 2025 -0400

testsuite, riscv: fix broken dg directives

Found by dg-lint.

gcc/testsuite/ChangeLog:
* gcc.target/riscv/cmo-zicbop-1.c: Fix missing space before
trailing } in dg-do directive.
* gcc.target/riscv/cmo-zicbop-2.c: Likewise.
* gcc.target/riscv/prefetch-zicbop.c: Likewise.
* gcc.target/riscv/prefetch-zihintntl.c: Likewise.

Diff:
---
 gcc/testsuite/gcc.target/riscv/cmo-zicbop-1.c   | 2 +-
 gcc/testsuite/gcc.target/riscv/cmo-zicbop-2.c   | 2 +-
 gcc/testsuite/gcc.target/riscv/prefetch-zicbop.c| 2 +-
 gcc/testsuite/gcc.target/riscv/prefetch-zihintntl.c | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/gcc/testsuite/gcc.target/riscv/cmo-zicbop-1.c 
b/gcc/testsuite/gcc.target/riscv/cmo-zicbop-1.c
index 97181154d85b..e40874fc3df9 100644
--- a/gcc/testsuite/gcc.target/riscv/cmo-zicbop-1.c
+++ b/gcc/testsuite/gcc.target/riscv/cmo-zicbop-1.c
@@ -1,4 +1,4 @@
-/* { dg-do compile target { { rv64-*-*}}} */
+/* { dg-do compile target { { rv64-*-*}} } */
 /* { dg-options "-march=rv64gc_zicbop -mabi=lp64" } */
 
 void foo (char *p)
diff --git a/gcc/testsuite/gcc.target/riscv/cmo-zicbop-2.c 
b/gcc/testsuite/gcc.target/riscv/cmo-zicbop-2.c
index 4871a97b21aa..dd6e1eafd44a 100644
--- a/gcc/testsuite/gcc.target/riscv/cmo-zicbop-2.c
+++ b/gcc/testsuite/gcc.target/riscv/cmo-zicbop-2.c
@@ -1,4 +1,4 @@
-/* { dg-do compile target { { rv32-*-*}}} */
+/* { dg-do compile target { { rv32-*-*}} } */
 /* { dg-options "-march=rv32gc_zicbop -mabi=ilp32" } */
 
 void foo (char *p)
diff --git a/gcc/testsuite/gcc.target/riscv/prefetch-zicbop.c 
b/gcc/testsuite/gcc.target/riscv/prefetch-zicbop.c
index 0faa120f1f79..250f9ec6b0a8 100644
--- a/gcc/testsuite/gcc.target/riscv/prefetch-zicbop.c
+++ b/gcc/testsuite/gcc.target/riscv/prefetch-zicbop.c
@@ -1,4 +1,4 @@
-/* { dg-do compile target { { rv64-*-*}}} */
+/* { dg-do compile target { { rv64-*-*}} } */
 /* { dg-options "-march=rv64gc_zicbop -mabi=lp64" } */
 
 void foo (char *p)
diff --git a/gcc/testsuite/gcc.target/riscv/prefetch-zihintntl.c 
b/gcc/testsuite/gcc.target/riscv/prefetch-zihintntl.c
index 78a3afe68333..54e809f43535 100644
--- a/gcc/testsuite/gcc.target/riscv/prefetch-zihintntl.c
+++ b/gcc/testsuite/gcc.target/riscv/prefetch-zihintntl.c
@@ -1,4 +1,4 @@
-/* { dg-do compile target { { rv64-*-*}}} */
+/* { dg-do compile target { { rv64-*-*}} } */
 /* { dg-options "-march=rv64gc_zicbop_zihintntl -mabi=lp64" } */
 
 void foo (char *p)


[gcc r15-8999] testsuite, i386: fix broken dg directives

2025-03-28 Thread Sam James via Gcc-cvs
https://gcc.gnu.org/g:d6220c413bf6530bf88270ca5202801db01479e3

commit r15-8999-gd6220c413bf6530bf88270ca5202801db01479e3
Author: David Malcolm 
Date:   Wed Mar 26 14:34:50 2025 -0400

testsuite, i386: fix broken dg directives

Found by dg-lint.

gcc/testsuite/ChangeLog:
* gcc.target/i386/strub-pr118006.c: Fix ordering of dg-do and
dg-require- directive so that dg-do is first.

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

diff --git a/gcc/testsuite/gcc.target/i386/strub-pr118006.c 
b/gcc/testsuite/gcc.target/i386/strub-pr118006.c
index f1167906629c..88f66c153193 100644
--- a/gcc/testsuite/gcc.target/i386/strub-pr118006.c
+++ b/gcc/testsuite/gcc.target/i386/strub-pr118006.c
@@ -1,5 +1,5 @@
-/* { dg-require-effective-target strub } */
 /* { dg-do compile } */
+/* { dg-require-effective-target strub } */
 /* { dg-options "-fstrub=all -O2 -mno-accumulate-outgoing-args" } */
 
 __attribute__((noipa))


[gcc r15-9001] Export native_encode_real operating on REAL_VALUE_TYPE

2025-03-28 Thread Richard Biener via Gcc-cvs
https://gcc.gnu.org/g:9ac0ff5ea5f5a2c96f1599d271a42e226929d30b

commit r15-9001-g9ac0ff5ea5f5a2c96f1599d271a42e226929d30b
Author: Richard Biener 
Date:   Fri Mar 21 19:30:31 2025 +0100

Export native_encode_real operating on REAL_VALUE_TYPE

The following exports the native_encode_real worker, and makes it
take a scalar float mode and REAL_VALUE_TYPE data instead of a tree
for use in the COBOL frontend, avoiding creating of a temporary tree.

* fold-const.h (native_encode_real): Export.
* fold-const.cc (native_encode_real): Change API to take
mode and REAL_VALUE_TYPE.
(native_encode_expr): Adjust.

Diff:
---
 gcc/fold-const.cc | 13 +++--
 gcc/fold-const.h  |  2 ++
 2 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/gcc/fold-const.cc b/gcc/fold-const.cc
index fef7a6cc48ef..a4fb0147a0b1 100644
--- a/gcc/fold-const.cc
+++ b/gcc/fold-const.cc
@@ -7572,11 +7572,11 @@ native_encode_fixed (const_tree expr, unsigned char 
*ptr, int len, int off)
Return the number of bytes placed in the buffer, or zero
upon failure.  */
 
-static int
-native_encode_real (const_tree expr, unsigned char *ptr, int len, int off)
+int
+native_encode_real (scalar_float_mode mode, const REAL_VALUE_TYPE *val,
+   unsigned char *ptr, int len, int off)
 {
-  tree type = TREE_TYPE (expr);
-  int total_bytes = GET_MODE_SIZE (SCALAR_FLOAT_TYPE_MODE (type));
+  int total_bytes = GET_MODE_SIZE (mode);
   int byte, offset, word, words, bitpos;
   unsigned char value;
 
@@ -7596,7 +7596,7 @@ native_encode_real (const_tree expr, unsigned char *ptr, 
int len, int off)
 
   words = (32 / BITS_PER_UNIT) / UNITS_PER_WORD;
 
-  real_to_target (tmp, TREE_REAL_CST_PTR (expr), TYPE_MODE (type));
+  real_to_target (tmp, val, mode);
 
   for (bitpos = 0; bitpos < total_bytes * BITS_PER_UNIT;
bitpos += BITS_PER_UNIT)
@@ -7836,7 +7836,8 @@ native_encode_expr (const_tree expr, unsigned char *ptr, 
int len, int off)
   return native_encode_int (expr, ptr, len, off);
 
 case REAL_CST:
-  return native_encode_real (expr, ptr, len, off);
+  return native_encode_real (SCALAR_FLOAT_TYPE_MODE (TREE_TYPE (expr)),
+TREE_REAL_CST_PTR (expr), ptr, len, off);
 
 case FIXED_CST:
   return native_encode_fixed (expr, ptr, len, off);
diff --git a/gcc/fold-const.h b/gcc/fold-const.h
index f20fb58271df..43deea4d69c5 100644
--- a/gcc/fold-const.h
+++ b/gcc/fold-const.h
@@ -35,6 +35,8 @@ extern bool folding_cxx_constexpr;
 extern int native_encode_expr (const_tree, unsigned char *, int, int off = -1);
 extern int native_encode_initializer (tree, unsigned char *, int,
  int off = -1, unsigned char * = nullptr);
+extern int native_encode_real (scalar_float_mode, const REAL_VALUE_TYPE *,
+  unsigned char *, int, int off = -1);
 extern tree native_interpret_expr (tree, const unsigned char *, int);
 extern tree native_interpret_real (tree, const unsigned char *, int);
 extern bool can_native_interpret_type_p (tree);


[gcc r14-11422] c++: memfn pointer as NTTP argument considered unused [PR119233]

2025-03-28 Thread Patrick Palka via Gcc-cvs
https://gcc.gnu.org/g:9a69c36417ad597ea2dce20fd704878c3727bc38

commit r14-11422-g9a69c36417ad597ea2dce20fd704878c3727bc38
Author: Patrick Palka 
Date:   Tue Mar 18 11:38:33 2025 -0400

c++: memfn pointer as NTTP argument considered unused [PR119233]

This is just the member function pointer version of PR c++/105848,
in which our non-dependent call pruning may cause us to not mark an
otherwise unused function pointer template argument as used.

PR c++/119233

gcc/cp/ChangeLog:

* pt.cc (mark_template_arguments_used): Also handle member
function pointers.

gcc/testsuite/ChangeLog:

* g++.dg/template/fn-ptr5.C: New test.

Reviewed-by: Jason Merrill 
(cherry picked from commit 51b1c0a2dde8ada0856c8a8cf2c1d26ac1657787)

Diff:
---
 gcc/cp/pt.cc|  6 ++
 gcc/testsuite/g++.dg/template/fn-ptr5.C | 28 
 2 files changed, 34 insertions(+)

diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc
index a1dd428cd10e..ca34ed75d659 100644
--- a/gcc/cp/pt.cc
+++ b/gcc/cp/pt.cc
@@ -22060,6 +22060,12 @@ mark_template_arguments_used (tree tmpl, tree args)
  gcc_checking_assert (ok || seen_error ());
}
}
+  /* A member function pointer.  */
+  else if (TREE_CODE (arg) == PTRMEM_CST)
+   {
+ bool ok = mark_used (PTRMEM_CST_MEMBER (arg), tf_none);
+ gcc_checking_assert (ok || seen_error ());
+   }
   /* A class NTTP argument.  */
   else if (VAR_P (arg)
   && DECL_NTTP_OBJECT_P (arg))
diff --git a/gcc/testsuite/g++.dg/template/fn-ptr5.C 
b/gcc/testsuite/g++.dg/template/fn-ptr5.C
new file mode 100644
index ..db3113109ef9
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/fn-ptr5.C
@@ -0,0 +1,28 @@
+// PR c++/119233
+// A version of fn-ptr3a.C using member instead of non-member function
+// pointers.
+
+struct B {
+  template
+  void f(T) { T::fail; } // { dg-error "fail" }
+};
+
+template
+struct A {
+  // P not called
+};
+
+template
+void wrap() {
+  // P not called
+}
+
+template
+void g() {
+  A<&B::f> a; // { dg-message "required from" }
+  wrap<&B::f>(); // { dg-message "required from" }
+}
+
+int main() {
+  g<0>();
+}


[gcc r15-9003] tailc: Handle musttail noreturn calls [PR119483]

2025-03-28 Thread Jakub Jelinek via Gcc-cvs
https://gcc.gnu.org/g:e176456cfe5b1013bbfc24853265dfb13673011c

commit r15-9003-ge176456cfe5b1013bbfc24853265dfb13673011c
Author: Jakub Jelinek 
Date:   Fri Mar 28 10:49:40 2025 +0100

tailc: Handle musttail noreturn calls [PR119483]

The following (first) testcase is accepted by clang (if clang::musttail)
and rejected by gcc, because we discover the call is noreturn and then bail
out because we don't want noreturn tailcalls.
The general reason not to support noreturn tail calls is for cases like
abort where we want nicer backtrace, but if user asks explicitly to
musttail a call which either is explicitly noreturn or is implicitly
determined to be noreturn, I don't see a reason why we couldn't do that.
Both for tail calls and tail recursions.

An alternative would be to keep rejecting musttail to explicit noreturn,
but not actually implicitly mark anything as noreturn if it has any musttail
calls.  But it is unclear how we could do that, such marking is I think done
typically before IPA and e.g. for LTO we won't know whether some other TU
could have musttail calls to it.  And keeping around both explicit and
implicit noreturn bits would be ugly.  Well, I guess we could differentiate
between presence of noreturn/_Noreturn attributes and just ECF_NORETURN
without those, but then tailc would still need to support it, just error out
if it was explicit.

2025-03-28  Jakub Jelinek  

PR tree-optimization/119483
* tree-tailcall.cc (find_tail_calls): Handle noreturn musttail
calls.
(eliminate_tail_call): Likewise.
(tree_optimize_tail_calls_1): If cfun->has_musttail and
diag_musttail, handle also basic blocks with no successors
with noreturn musttail calls.
* calls.cc (can_implement_as_sibling_call_p): Allow ECF_NORETURN
calls if they are musttail calls.

* c-c++-common/pr119483-1.c: New test.
* c-c++-common/pr119483-2.c: New test.

Diff:
---
 gcc/calls.cc|  2 +-
 gcc/testsuite/c-c++-common/pr119483-1.c | 29 
 gcc/testsuite/c-c++-common/pr119483-2.c | 12 +
 gcc/tree-tailcall.cc| 82 -
 4 files changed, 102 insertions(+), 23 deletions(-)

diff --git a/gcc/calls.cc b/gcc/calls.cc
index fa538df33e06..b3dccd85ec8e 100644
--- a/gcc/calls.cc
+++ b/gcc/calls.cc
@@ -2568,7 +2568,7 @@ can_implement_as_sibling_call_p (tree exp,
   maybe_complain_about_tail_call (exp, _("callee returns twice"));
   return false;
 }
-  if (flags & ECF_NORETURN)
+  if ((flags & ECF_NORETURN) && !CALL_EXPR_MUST_TAIL_CALL (exp))
 {
   maybe_complain_about_tail_call (exp, _("callee does not return"));
   return false;
diff --git a/gcc/testsuite/c-c++-common/pr119483-1.c 
b/gcc/testsuite/c-c++-common/pr119483-1.c
new file mode 100644
index ..b2d7b57795a5
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/pr119483-1.c
@@ -0,0 +1,29 @@
+/* PR tree-optimization/119483 */
+/* { dg-do compile { target musttail } } */
+/* { dg-options "-O2 -fdump-tree-optimized" } */
+/* { dg-final { scan-tree-dump-times "bar\[.a-z0-9]* \\\(\[^\n\r]*\\\); 
\\\[tail call\\\] \\\[must tail call\\\]" 1 "optimized" } } */
+/* { dg-final { scan-tree-dump-times "baz \\\(\[^\n\r]*\\\); \\\[tail call\\\] 
\\\[must tail call\\\]" 1 "optimized" } } */
+
+[[gnu::noreturn]] extern void foo (void);
+
+[[gnu::noinline]] static int
+bar (int x)
+{
+  (void) x;
+  foo ();
+  return 0;
+}
+
+[[gnu::noipa]] int
+baz (int x)
+{
+  return x + 42;
+}
+
+int
+qux (int x)
+{
+  if (x == 1)
+[[gnu::musttail]] return bar (1);
+  [[gnu::musttail]] return baz (x);
+}
diff --git a/gcc/testsuite/c-c++-common/pr119483-2.c 
b/gcc/testsuite/c-c++-common/pr119483-2.c
new file mode 100644
index ..e7b692dc80bd
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/pr119483-2.c
@@ -0,0 +1,12 @@
+/* PR tree-optimization/119483 */
+/* { dg-do compile { target musttail } } */
+/* { dg-options "-O2" } */
+
+[[noreturn]] int
+foo (int x)
+{
+  if (x > 10)
+[[gnu::musttail]] return foo (x - 1);  /* { dg-warning "function 
declared 'noreturn' has a 'return' statement" } */
+  for (;;)
+;
+}
diff --git a/gcc/tree-tailcall.cc b/gcc/tree-tailcall.cc
index 3efbe9042f20..8ba675221915 100644
--- a/gcc/tree-tailcall.cc
+++ b/gcc/tree-tailcall.cc
@@ -484,7 +484,8 @@ find_tail_calls (basic_block bb, struct tailcall **ret, 
bool only_musttail,
   size_t idx;
   tree var;
 
-  if (!single_succ_p (bb))
+  if (!single_succ_p (bb)
+  && (EDGE_COUNT (bb->succs) || !cfun->has_musttail || !diag_musttail))
 {
   /* If there is an abnormal edge assume it's the only extra one.
 Tolerate that case so that we can give better error messages
@@ -605,7 +606,7 @@ find_tail_calls (basic_block bb, struct tailcall **ret, 
bool only_musttail,
   /* If the

[gcc r15-9002] ipa-sra: Don't change return type to void if there are musttail calls [PR119484]

2025-03-28 Thread Jakub Jelinek via Gcc-cvs
https://gcc.gnu.org/g:c95f5a0c0719ad5b23f605b4d8f8dd3689a0066b

commit r15-9002-gc95f5a0c0719ad5b23f605b4d8f8dd3689a0066b
Author: Jakub Jelinek 
Date:   Fri Mar 28 10:48:31 2025 +0100

ipa-sra: Don't change return type to void if there are musttail calls 
[PR119484]

The following testcase is rejected, because IPA-SRA decides to
turn bar.constprop call into bar.constprop.isra which returns void.
While there is no explicit lhs on the call, as it is a musttail call
the tailc pass checks if IPA-VRP returns singleton from that function
and the function returns the same value and in that case it still turns
it into a tail call.  This can't work with IPA-SRA changing it into
void returning function though.

The following patch fixes this by forcing returning the original type
if there are musttail calls.

2025-03-28  Jakub Jelinek  

PR ipa/119484
* ipa-sra.cc (isra_analyze_call): Don't set m_return_ignored if
gimple_call_must_tail_p even if it doesn't have lhs.

* c-c++-common/pr119484.c: New test.

Diff:
---
 gcc/ipa-sra.cc|  6 +-
 gcc/testsuite/c-c++-common/pr119484.c | 21 +
 2 files changed, 26 insertions(+), 1 deletion(-)

diff --git a/gcc/ipa-sra.cc b/gcc/ipa-sra.cc
index 5d1703ed394f..1331ba49b507 100644
--- a/gcc/ipa-sra.cc
+++ b/gcc/ipa-sra.cc
@@ -2242,7 +2242,11 @@ isra_analyze_call (cgraph_edge *cs)
  BITMAP_FREE (analyzed);
}
 }
-  else
+  /* Don't set m_return_ignored for musttail calls.  The tailc/musttail passes
+ compare the returned value against the IPA-VRP return value range if
+ it is a singleton, but if the call is changed to something which doesn't
+ return anything, it will always fail.  */
+  else if (!gimple_call_must_tail_p (call_stmt))
 csum->m_return_ignored = true;
 }
 
diff --git a/gcc/testsuite/c-c++-common/pr119484.c 
b/gcc/testsuite/c-c++-common/pr119484.c
new file mode 100644
index ..6ae7c9a7491f
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/pr119484.c
@@ -0,0 +1,21 @@
+/* PR ipa/119484 */
+/* { dg-do compile { target musttail } } */
+/* { dg-options "-O2 -fdump-tree-optimized" } */
+/* { dg-final { scan-tree-dump-times "bar\[.a-z0-9]* \\\(\[^\n\r]*\\\); 
\\\[tail call\\\] \\\[must tail call\\\]" 1 "optimized" } } */
+
+void foo (int);
+
+[[gnu::noinline]] static int
+bar (int x)
+{
+  foo (x);
+  return 0;
+}
+
+int
+baz (int x)
+{
+  if (x == 1)
+[[gnu::musttail]] return bar (x);
+  return 0;
+}


[gcc r15-8584] gccrs: ast-builder: Add more methods

2025-03-28 Thread Arthur Cohen via Gcc-cvs
https://gcc.gnu.org/g:ea356df6265ed362b523c81bd0869f5a4b9d4034

commit r15-8584-gea356df6265ed362b523c81bd0869f5a4b9d4034
Author: Arthur Cohen 
Date:   Sat Dec 21 22:52:57 2024 +

gccrs: ast-builder: Add more methods

This commit adds new methods for building pattern nodes, match expressions 
and more precise call expressions.

gcc/rust/ChangeLog:

* ast/rust-ast-builder.cc: Add new functions.
* ast/rust-ast-builder.h: Declare them.

Diff:
---
 gcc/rust/ast/rust-ast-builder.cc | 91 
 gcc/rust/ast/rust-ast-builder.h  | 30 +
 2 files changed, 121 insertions(+)

diff --git a/gcc/rust/ast/rust-ast-builder.cc b/gcc/rust/ast/rust-ast-builder.cc
index 529c686db1b2..2fb041abcc0d 100644
--- a/gcc/rust/ast/rust-ast-builder.cc
+++ b/gcc/rust/ast/rust-ast-builder.cc
@@ -20,6 +20,7 @@
 #include "rust-ast-builder-type.h"
 #include "rust-common.h"
 #include "rust-expr.h"
+#include "rust-path.h"
 #include "rust-token.h"
 #include "rust-make-unique.h"
 
@@ -42,6 +43,33 @@ Builder::call (std::unique_ptr &&path,
 new CallExpr (std::move (path), std::move (args), {}, loc));
 }
 
+std::unique_ptr
+Builder::call (std::unique_ptr &&path,
+  std::vector> &&args) const
+{
+  return call (std::unique_ptr (
+new PathInExpression (std::move (path), {}, loc)),
+  std::move (args));
+}
+
+std::unique_ptr
+Builder::call (std::unique_ptr &&path, std::unique_ptr &&arg) const
+{
+  auto args = std::vector> ();
+  args.emplace_back (std::move (arg));
+
+  return call (std::move (path), std::move (args));
+}
+
+std::unique_ptr
+Builder::call (std::unique_ptr &&path, std::unique_ptr &&arg) const
+{
+  auto args = std::vector> ();
+  args.emplace_back (std::move (arg));
+
+  return call (std::move (path), std::move (args));
+}
+
 std::unique_ptr
 Builder::array (std::vector> &&members) const
 {
@@ -56,6 +84,13 @@ Builder::identifier (std::string name) const
   return std::unique_ptr (new IdentifierExpr (name, {}, loc));
 }
 
+std::unique_ptr
+Builder::identifier_pattern (std::string name, bool mut) const
+{
+  return std::unique_ptr (
+new IdentifierPattern (name, loc, false, mut));
+}
+
 std::unique_ptr
 Builder::tuple_idx (std::string receiver, int idx) const
 {
@@ -117,6 +152,22 @@ Builder::path_in_expression (std::vector 
&&segments) const
   return PathInExpression (std::move (path_segments), {}, loc);
 }
 
+PathInExpression
+Builder::path_in_expression (LangItem::Kind lang_item) const
+{
+  return PathInExpression (lang_item, {}, loc);
+}
+
+std::unique_ptr
+Builder::block (std::unique_ptr &&stmt,
+   std::unique_ptr &&tail_expr) const
+{
+  auto stmts = std::vector> ();
+  stmts.emplace_back (std::move (stmt));
+
+  return block (std::move (stmts), std::move (tail_expr));
+}
+
 std::unique_ptr
 Builder::block (std::vector> &&stmts,
std::unique_ptr &&tail_expr) const
@@ -189,6 +240,46 @@ Builder::wildcard () const
   return std::unique_ptr (new WildcardPattern (loc));
 }
 
+std::unique_ptr
+Builder::lang_item_path (LangItem::Kind kind) const
+{
+  return std::unique_ptr (new LangItemPath (kind, loc));
+}
+
+std::unique_ptr
+Builder::match (std::unique_ptr &&scrutinee,
+   std::vector &&cases)
+{
+  return std::unique_ptr (
+new MatchExpr (std::move (scrutinee), std::move (cases), {}, {}, loc));
+}
+
+MatchArm
+Builder::match_arm (std::unique_ptr &&pattern)
+{
+  auto patterns = std::vector> ();
+  patterns.emplace_back (std::move (pattern));
+
+  return MatchArm (std::move (patterns), loc);
+}
+
+MatchCase
+Builder::match_case (std::unique_ptr &&pattern,
+std::unique_ptr &&expr)
+{
+  return MatchCase (match_arm (std::move (pattern)), std::move (expr));
+}
+
+std::unique_ptr
+Builder::loop (std::vector> &&stmts)
+{
+  auto block = std::unique_ptr (
+new BlockExpr (std::move (stmts), nullptr, {}, {}, LoopLabel::error (), 
loc,
+  loc));
+
+  return std::unique_ptr (new LoopExpr (std::move (block), loc));
+}
+
 std::unique_ptr
 Builder::new_type (Type &type)
 {
diff --git a/gcc/rust/ast/rust-ast-builder.h b/gcc/rust/ast/rust-ast-builder.h
index bad79d067adc..6e07df6e1824 100644
--- a/gcc/rust/ast/rust-ast-builder.h
+++ b/gcc/rust/ast/rust-ast-builder.h
@@ -20,6 +20,7 @@
 #define AST_BUILDER_H
 
 #include "rust-ast-full.h"
+#include "rust-expr.h"
 
 namespace Rust {
 namespace AST {
@@ -38,6 +39,8 @@ public:
 
   /* Create an identifier expression (`variable`) */
   std::unique_ptr identifier (std::string name) const;
+  std::unique_ptr identifier_pattern (std::string name,
+  bool mut = false) const;
 
   /* Create a tuple index expression (`receiver.0`) */
   std::unique_ptr tuple_idx (std::string receiver, int idx) const;
@@ -53,6 +56,9 @@ public:
   std::unique_ptr block (std::vector> &&stmts,
   std::unique_ptr &&tail_expr
  

[gcc/devel/omp/gcc-14] Merge commit '8a624a127990aee47d02b3d64892f8de9031975e' into HEAD

2025-03-28 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:5f75d28c9d03fffad3a3fc03e4850ae44d057486

commit 5f75d28c9d03fffad3a3fc03e4850ae44d057486
Merge: d3998fce2d0b 8a624a127990
Author: Thomas Schwinge 
Date:   Fri Mar 28 12:56:07 2025 +0100

Merge commit '8a624a127990aee47d02b3d64892f8de9031975e' into HEAD

Diff:


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

2025-03-28 Thread Michael Meissner via Gcc-cvs
https://gcc.gnu.org/g:54e6fc57d0c53eefdb5bfd26207bba7660293344

commit 54e6fc57d0c53eefdb5bfd26207bba7660293344
Author: Michael Meissner 
Date:   Mon Mar 24 19:08:34 2025 -0400

Change TARGET_POPCNTD to TARGET_POWER7.

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

2025-03-24  Michael Meissner  

gcc/

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

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

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

[gcc r15-9015] testsuite: Don't cycle through option list for gfortran.dg and libgomp.fortran dg-do run tests with

2025-03-28 Thread Jakub Jelinek via Gcc-cvs
https://gcc.gnu.org/g:2cb728e14b5640849dad7571b9bbb0091ff5fcab

commit r15-9015-g2cb728e14b5640849dad7571b9bbb0091ff5fcab
Author: Jakub Jelinek 
Date:   Fri Mar 28 20:29:31 2025 +0100

testsuite: Don't cycle through option list for gfortran.dg and 
libgomp.fortran dg-do run tests with -O in dg*options

Here is a new version of the patch.

The current behavior in gfortran.dg/ and 
libgomp.fortran/libgomp.oacc-fortran
is that tests without any dg-do directive are implicitly dg-do compile
and tests with dg-do compile or without dg-do don't cycle through options
(-O is implicitly added but can be overridden), while test with dg-do run
cycle through the optimization options.
The following patch modifies this, so that even tests with dg-do run
with -O in dg-options or dg-additional-options (after [ \t"{]) don't cycle
either and also get implicit -O which is overridden by that
-O{,0,1,2,3,s,z,g,fast} in dg-{,additional-}options.  Previously we were
mostly wasting test time on those, because e.g.
-O0 -O2
-O1 -O2
-O2 -O2
-Os -O2
are still effectively -O2 and so the same thing, while
-O3 -fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer 
-finline-functions -O2
and
-O3 -g -O2
are not the same thing (effectively
-fomit-frame-pointer -funroll-loops -fpeel-loops -ftracer 
-finline-functions -O2
and
-g -O2) I think it isn't worth to test those combinations (especially when
with e.g. -O0 in dg-options it mostly doesn't do much).

Tested with make check-gfortran where this results in slight decrease of
tests:
 # of expected passes73809
 # of expected failures  343
 # of unsupported tests  78
with unmodified trunk vs.
 # of expected passes72734
 # of expected failures  343
 # of unsupported tests  73
with the patch, and on the libgomp side
 # of expected passes11162
 # of expected failures  238
 # of unsupported tests  274
to
 # of expected passes11092
 # of expected failures  238
 # of unsupported tests  274
(when counting just fortran.exp tests).

Before the patch I see
grep -- '-O[^ ].*-O' testsuite/gfortran/gfortran.log | grep -v 
'/vect/\|/graphite/' | wc -l
1008
and with the patch
grep -- '-O[^ ].*-O' testsuite/gfortran/gfortran.log | grep -v 
'/vect/\|/graphite/' | wc -l
0
(vect and graphite have a few occurrences, but not too much).

2025-03-28  Jakub Jelinek  

* lib/gfortran-dg.exp: Don't cycle through the option list if
dg-options or dg-additional-options contains -O after space, tab,
double quote or open curly bracket.
* gfortran.dg/cray_pointers_2.f90: Remove extraneous space between
dg-do and run and remove comment about it.

Diff:
---
 gcc/testsuite/gfortran.dg/cray_pointers_2.f90 | 4 +---
 gcc/testsuite/lib/gfortran-dg.exp | 8 +++-
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/gcc/testsuite/gfortran.dg/cray_pointers_2.f90 
b/gcc/testsuite/gfortran.dg/cray_pointers_2.f90
index 4351874825ed..e646fc86b802 100644
--- a/gcc/testsuite/gfortran.dg/cray_pointers_2.f90
+++ b/gcc/testsuite/gfortran.dg/cray_pointers_2.f90
@@ -1,6 +1,4 @@
-! Using two spaces between dg-do and run is a hack to keep gfortran-dg-runtest
-! from cycling through optimization options for this expensive test.
-! { dg-do  run }
+! { dg-do run }
 ! { dg-options "-O3 -fcray-pointer -fbounds-check -fno-inline" }
 ! { dg-timeout-factor 4 }
 !
diff --git a/gcc/testsuite/lib/gfortran-dg.exp 
b/gcc/testsuite/lib/gfortran-dg.exp
index a516babdc3be..4abf2fe5dccf 100644
--- a/gcc/testsuite/lib/gfortran-dg.exp
+++ b/gcc/testsuite/lib/gfortran-dg.exp
@@ -149,7 +149,13 @@ proc gfortran-dg-runtest { testcases flags 
default-extra-flags } {
# look if this is dg-do run test, in which case
# we cycle through the option list, otherwise we don't
if [expr [search_for $test "dg-do run"]] {
-   set option_list $torture_with_loops
+   if { [ expr [search_for $test "dg-options*\[ \t\"\{]-O"] ] \
+|| [ expr [search_for $test \
+   "dg-additional-options*\[ \t\"\{]-O"] ] } {
+   set option_list [list { -O } ]
+   } else {
+   set option_list $torture_with_loops
+   }
} else {
set option_list [list { -O } ]
}


[gcc(refs/users/omachota/heads/rtl-ssa-dce)] rtl-ssa-dce: partial cleanup, prepare transform to debug insns

2025-03-28 Thread Ondrej Machota via Gcc-cvs
https://gcc.gnu.org/g:122b4dfca4b1a3e8e6e838ff068f0a016406b699

commit 122b4dfca4b1a3e8e6e838ff068f0a016406b699
Author: Ondřej Machota 
Date:   Fri Mar 28 20:13:27 2025 +0100

rtl-ssa-dce: partial cleanup, prepare transform to debug insns

Diff:
---
 gcc/dce.cc | 86 +-
 1 file changed, 69 insertions(+), 17 deletions(-)

diff --git a/gcc/dce.cc b/gcc/dce.cc
index f227fc214e99..bb7040ae653d 100644
--- a/gcc/dce.cc
+++ b/gcc/dce.cc
@@ -1306,6 +1306,32 @@ public:
 
 } // namespace
 
+struct offset_bitmap {
+  private:
+const int m_offset;
+sbitmap m_bitmap;
+  
+  public:
+offset_bitmap(size_t size, int offset) : m_bitmap{sbitmap_alloc(size)} {}
+offset_bitmap(int min_index, int max_index) : offset_bitmap(max_index - 
min_index, 0) {}
+
+void clear_bit(int index) {
+  bitmap_clear_bit(m_bitmap, index + m_offset);
+}
+
+void set_bit(int index) {
+  bitmap_set_bit(m_bitmap, index + m_offset);
+}
+
+bool get_bit(int index) {
+  return bitmap_bit_p(m_bitmap, index + m_offset);
+}
+
+~offset_bitmap() {
+  sbitmap_free(m_bitmap);
+}
+};
+
 bool sets_global_register(rtx_insn* insn) {
   rtx set = single_set(insn);
   if (!set)
@@ -1409,13 +1435,9 @@ bool is_ssa_prelive(const_rtx insn) {
 bool is_rtx_insn_prelive(rtx_insn *insn) {
   gcc_assert(insn != nullptr);
 
-  // Jumps, notes, barriers should not be deleted
-  // According to the docs, rtl ssa does not contain noteS and barrierS 
   if (!NONJUMP_INSN_P (insn))
   {
 // This handles jumps, debug_insns, call_insn, ...
-//std::cerr << "found jump instruction\n";
-//debug(insn);
 return true;
   }
 
@@ -1446,10 +1468,6 @@ bool is_rtx_insn_prelive(rtx_insn *insn) {
   if (RTX_FRAME_RELATED_P (insn) && crtl->shrink_wrapped_separate && 
find_reg_note (insn, REG_CFA_RESTORE, NULL))
 return true;
 
-  // Mark set of a global register
-  // if (sets_global_register(insn)) // check rtx_class with GET_RTX_CLASS if 
RTX_ISNS and convert if needed
-  //   return true;
-
   // TODO : asm_noperands???
 
   rtx body = PATTERN(insn);
@@ -1561,8 +1579,8 @@ rtl_ssa_dce_prelive(std::unordered_set 
&marked)
 next = insn->next_any_insn();
 if (is_prelive(insn))
   {
-// std::cout << "insn is prelive: " << insn->uid() << '\n';
-rtl_ssa_dce_mark_live(insn, worklist, marked);}
+rtl_ssa_dce_mark_live(insn, worklist, marked);
+  }
 
 // if (insn->can_be_optimized () || insn->is_debug_insn ())
 //  if (fwprop_insn (insn, fwprop_addr_p))
@@ -1575,9 +1593,6 @@ rtl_ssa_dce_prelive(std::unordered_set 
&marked)
 static std::unordered_set
 rtl_ssa_dce_mark()
 {
-  std::unordered_set marked_sets{};
-
-
   std::unordered_set marked{};
   // phi insn might have more that one phi node: 
gcc/gcc/testsuite/gcc.c-torture/execute/2224-1.c
   std::unordered_set marked_phi_nodes{};
@@ -1586,7 +1601,6 @@ rtl_ssa_dce_mark()
   auto_vec worklist_new{};
   for (auto && item : worklist) {
 insn_info * insn = item;
-// std::cerr << "cp Current: " << insn->uid() << '\n';
 for (auto&& use : insn->uses()) {
   set_info* set = use->def();
   if (set) {
@@ -1621,6 +1635,8 @@ rtl_ssa_dce_mark()
 
 use_array uses = insn->uses();
 if (insn->is_phi()) {
+  // Each phi node has a unique uid, yeeey
+  // So, only one bitmap (with shift) in needed.
   phi_info* pi = as_a (set);
   if (marked_phi_nodes.count(pi) > 0) {
 continue;
@@ -1710,6 +1726,41 @@ rtl_ssa_dce_sweep(std::unordered_set marked)
   }
 }
 
+static void
+rtl_ssa_dce_transform_insns_to_debug() {
+  // TODO : bude nejspise zase treba rozdelit phi a ostatni insns
+  std::unordered_set is_debug;
+
+  // chceme prochazet v post orderu, abychom nejdrive zpracovali zavislosti a 
pak az definici
+  // nelze jen menit instrukce, protoze musime informaci propagovat pres phi 
node
+  for (insn_info * insn : crtl->ssa->reverse_all_insns()) {
+if (insn->is_debug_insn()) { // phi is never debug
+// TODO : store info about this insn
+
+is_debug.emplace(insn->uid());
+continue;
+}
+
+if (insn->is_phi()) {
+  // TODO : special handling for phi_node required
+}
+
+bool is_debug = true;
+for (def_info *def : insn->defs()) {
+  // TODO : how to cast this correctly? - clobber_info
+  if (def->mode() == access_kind::CLOBBER)
+continue;
+  set_info* set = as_a(def);
+  for (use_info * use : set->all_uses()) {
+auto iii = use->insn()->uid();
+  }
+}
+
+// TODO : projit vsechny set_infa a podivat se, zda jsou zavisloti jen 
debug
+// Musime si dat pozor na phi - tam je treba se podivat na kontretni phi 
node
+  }
+}
+
 static void
 rtl_ssa_dce_init()
 {
@@ -1738,8 +1789,9 @@ static unsigned int
 rtl_ssa_dce()
 {
   rtl_ssa_dce_init();
-  // debug(crtl->ssa);
-  // std::cout << "\033[31m" << "Before rtl ssa dce pass" << "\033[0m" << "\n";

[gcc r15-9013] Regenerate common.opt.urls

2025-03-28 Thread Jakub Jelinek via Gcc-cvs
https://gcc.gnu.org/g:58b59251ea22913ce0d5871db64f5d24f2b15493

commit r15-9013-g58b59251ea22913ce0d5871db64f5d24f2b15493
Author: Jakub Jelinek 
Date:   Fri Mar 28 17:23:29 2025 +0100

Regenerate common.opt.urls

The r15-8947 commit has not regenerate-opt-urls.

2025-03-28  Jakub Jelinek  

* common.opt.urls: Regenerate.

Diff:
---
 gcc/common.opt.urls | 9 +
 1 file changed, 9 insertions(+)

diff --git a/gcc/common.opt.urls b/gcc/common.opt.urls
index ac602631179c..e7900c825c17 100644
--- a/gcc/common.opt.urls
+++ b/gcc/common.opt.urls
@@ -289,6 +289,12 @@ 
UrlSuffix(gcc/Warning-Options.html#index-Wcoverage-invalid-line-number)
 Wcoverage-too-many-conditions
 UrlSuffix(gcc/Warning-Options.html#index-Wcoverage-too-many-conditions)
 
+fpath-coverage-limit=
+UrlSuffix(gcc/Instrumentation-Options.html#index-fpath-coverage-limit)
+
+Wcoverage-too-many-paths
+UrlSuffix(gcc/Warning-Options.html#index-Wcoverage-too-many-paths)
+
 Wmissing-profile
 UrlSuffix(gcc/Warning-Options.html#index-Wmissing-profile)
 
@@ -1037,6 +1043,9 @@ UrlSuffix(gcc/Optimize-Options.html#index-foptimize-crc)
 foptimize-sibling-calls
 UrlSuffix(gcc/Optimize-Options.html#index-foptimize-sibling-calls)
 
+fpath-coverage
+UrlSuffix(gcc/Instrumentation-Options.html#index-fpath-coverage)
+
 fpartial-inlining
 UrlSuffix(gcc/Optimize-Options.html#index-fpartial-inlining)


[gcc r15-9016] Fortran: fix spelling of flag -fallow-invalid-boz

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

commit r15-9016-gfb132276d173907d575ea61fda3b846a9bc6e456
Author: Harald Anlauf 
Date:   Fri Mar 28 20:31:08 2025 +0100

Fortran: fix spelling of flag -fallow-invalid-boz

gcc/fortran/ChangeLog:

* check.cc (gfc_invalid_boz): Correct spelling of compiler flag in
hint to -fallow-invalid-boz.

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

diff --git a/gcc/fortran/check.cc b/gcc/fortran/check.cc
index d2c8816da2b4..9c66c25e0596 100644
--- a/gcc/fortran/check.cc
+++ b/gcc/fortran/check.cc
@@ -67,7 +67,7 @@ gfc_invalid_boz (const char *msg, locus *loc)
   return false;
 }
 
-  const char *hint = _(" [see %<-fno-allow-invalid-boz%>]");
+  const char *hint = _(" [see %<-fallow-invalid-boz%>]");
   size_t len = strlen (msg) + strlen (hint) + 1;
   char *msg2 = (char *) alloca (len);
   strcpy (msg2, msg);


[gcc r15-9006] testsuite: Add options for float16 for test [PR119133]

2025-03-28 Thread Christophe Lyon via Gcc-cvs
https://gcc.gnu.org/g:4981d8dfcfd34486d431930be3381eb73df958d0

commit r15-9006-g4981d8dfcfd34486d431930be3381eb73df958d0
Author: Christophe Lyon 
Date:   Thu Mar 27 14:44:18 2025 +

testsuite: Add options for float16 for test [PR119133]

Some targets (like arm) need some flags to enable _Float16 support.

gcc/testsuite/ChangeLog:

PR target/119133
* gcc.dg/torture/pr119133.c: Add options for float16.

Diff:
---
 gcc/testsuite/gcc.dg/torture/pr119133.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/gcc/testsuite/gcc.dg/torture/pr119133.c 
b/gcc/testsuite/gcc.dg/torture/pr119133.c
index 5369becd350d..f0c8f734c866 100644
--- a/gcc/testsuite/gcc.dg/torture/pr119133.c
+++ b/gcc/testsuite/gcc.dg/torture/pr119133.c
@@ -1,5 +1,6 @@
 /* { dg-additional-options "-fno-tree-ter" } */
 /* { dg-require-effective-target float16 } */
+/* { dg-add-options float16 } */
 
 int
 foo(_Float16 f, int i)


[gcc r15-9004] [COBOL] use native_encode_real

2025-03-28 Thread Richard Biener via Gcc-cvs
https://gcc.gnu.org/g:8b4a84388c7ef9c441491b9c258212b3c2318ee3

commit r15-9004-g8b4a84388c7ef9c441491b9c258212b3c2318ee3
Author: Richard Biener 
Date:   Fri Mar 28 08:52:16 2025 +0100

[COBOL] use native_encode_real

The following avoids the round-trip through a newly built tree and
instead directly uses the now exported native_encode_real.

gcc/cobol/
* genapi.cc (initial_from_float128): Use native_encode_real.

Diff:
---
 gcc/cobol/genapi.cc | 13 ++---
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/gcc/cobol/genapi.cc b/gcc/cobol/genapi.cc
index 032236b15dba..bc9153381588 100644
--- a/gcc/cobol/genapi.cc
+++ b/gcc/cobol/genapi.cc
@@ -15680,24 +15680,23 @@ initial_from_float128(cbl_field_t *field)
 
 case FldFloat:
   {
-  tree tem;
   retval = (char *)xmalloc(field->data.capacity);
   switch( field->data.capacity )
 {
 case 4:
   value = real_value_truncate (TYPE_MODE (FLOAT), value);
-  tem = build_real (FLOAT, value);
-  native_encode_expr (tem, (unsigned char *)retval, 4, 0);
+  native_encode_real (SCALAR_FLOAT_TYPE_MODE (FLOAT), &value,
+ (unsigned char *)retval, 4, 0);
   break;
 case 8:
   value = real_value_truncate (TYPE_MODE (DOUBLE), value);
-  tem = build_real (DOUBLE, value);
-  native_encode_expr (tem, (unsigned char *)retval, 8, 0);
+  native_encode_real (SCALAR_FLOAT_TYPE_MODE (DOUBLE), &value,
+ (unsigned char *)retval, 8, 0);
   break;
 case 16:
   value = real_value_truncate (TYPE_MODE (FLOAT128), value);
-  tem = build_real (FLOAT128, value);
-  native_encode_expr (tem, (unsigned char *)retval, 16, 0);
+  native_encode_real (SCALAR_FLOAT_TYPE_MODE (FLOAT128), &value,
+ (unsigned char *)retval, 16, 0);
   break;
 }
   break;


[gcc r15-8592] gccrs: ast: Add new Kind enums for more precise downcasting

2025-03-28 Thread Arthur Cohen via Gcc-cvs
https://gcc.gnu.org/g:9c50565e333621a8f7715db38adda442b1fe8a00

commit r15-8592-g9c50565e333621a8f7715db38adda442b1fe8a00
Author: Arthur Cohen 
Date:   Sat Dec 21 22:56:52 2024 +

gccrs: ast: Add new Kind enums for more precise downcasting

This commit adds things like Item::Kind, Expr::Kind, etc, and implements 
the associated `get_*_kind` functions.
It also removes the more generic AST::Kind enum we were using, which was 
incomplete and painful to use.

gcc/rust/ChangeLog:

* ast/rust-ast.h: Add new Kind enums, remove Node class.
* ast/rust-builtin-ast-nodes.h: Use new Kind enums.
* ast/rust-expr.h (class LoopLabel): Likewise.
* ast/rust-item.h: Likewise.
* ast/rust-macro.h: Likewise.
* ast/rust-path.h: Likewise.
* expand/rust-macro-builtins-helpers.cc: Likewise.
* expand/rust-macro-builtins-utility.cc 
(MacroBuiltin::concat_handler): Likewise.
(MacroBuiltin::stringify_handler): Likewise.
* resolve/rust-ast-resolve-expr.cc (ResolveExpr::visit): Likewise.
* resolve/rust-early-name-resolver.cc: Likewise.
* hir/rust-ast-lower.cc (ASTLoweringBlock::visit): Likewise.

Diff:
---
 gcc/rust/ast/rust-ast.h| 94 ++
 gcc/rust/ast/rust-builtin-ast-nodes.h  |  2 +
 gcc/rust/ast/rust-expr.h   | 84 ++-
 gcc/rust/ast/rust-item.h   | 36 +-
 gcc/rust/ast/rust-macro.h  | 34 ++
 gcc/rust/ast/rust-path.h   | 10 +++
 gcc/rust/expand/rust-macro-builtins-helpers.cc |  2 +-
 gcc/rust/expand/rust-macro-builtins-utility.cc |  4 +-
 gcc/rust/hir/rust-ast-lower.cc |  6 +-
 gcc/rust/resolve/rust-ast-resolve-expr.cc  |  2 +-
 gcc/rust/resolve/rust-early-name-resolver.cc   | 10 +--
 11 files changed, 229 insertions(+), 55 deletions(-)

diff --git a/gcc/rust/ast/rust-ast.h b/gcc/rust/ast/rust-ast.h
index 42ad0119231b..5e724d184de5 100644
--- a/gcc/rust/ast/rust-ast.h
+++ b/gcc/rust/ast/rust-ast.h
@@ -70,16 +70,6 @@ namespace AST {
 class ASTVisitor;
 using AttrVec = std::vector;
 
-// The available kinds of AST Nodes
-enum class Kind
-{
-  UNKNOWN,
-  MODULE,
-  MACRO_RULES_DEFINITION,
-  MACRO_INVOCATION,
-  IDENTIFIER,
-};
-
 class Visitable
 {
 public:
@@ -87,20 +77,6 @@ public:
   virtual void accept_vis (ASTVisitor &vis) = 0;
 };
 
-// Abstract base class for all AST elements
-class Node : public Visitable
-{
-public:
-  /**
-   * Get the kind of Node this is. This is used to differentiate various AST
-   * elements with very little overhead when extracting the derived type
-   * through static casting is not necessary.
-   */
-  // FIXME: Mark this as `= 0` in the future to make sure every node
-  // implements it
-  virtual Kind get_ast_kind () const { return Kind::UNKNOWN; }
-};
-
 // Delimiter types - used in macros and whatever.
 enum DelimType
 {
@@ -1092,7 +1068,7 @@ class MetaListNameValueStr;
 /* Base statement abstract class. Note that most "statements" are not allowed
  * in top-level module scope - only a subclass of statements called "items"
  * are. */
-class Stmt : public Node
+class Stmt : public Visitable
 {
 public:
   enum class Kind
@@ -1141,6 +1117,28 @@ protected:
 class Item : public Stmt
 {
 public:
+  enum class Kind
+  {
+MacroRulesDefinition,
+MacroInvocation,
+Module,
+ExternCrate,
+UseDeclaration,
+Function,
+TypeAlias,
+Struct,
+EnumItem,
+Enum,
+Union,
+ConstantItem,
+StaticItem,
+Trait,
+Impl,
+ExternBlock,
+  };
+
+  virtual Kind get_item_kind () const = 0;
+
   // Unique pointer custom clone function
   std::unique_ptr clone_item () const
   {
@@ -1221,14 +1219,54 @@ public:
   {
 return outer_attrs;
   }
+
+  virtual Item::Kind get_item_kind () const override = 0;
 };
+
 // forward decl of ExprWithoutBlock
 class ExprWithoutBlock;
 
 // Base expression AST node - abstract
-class Expr : public Node
+class Expr : public Visitable
 {
 public:
+  enum class Kind
+  {
+PathInExpression,
+QualifiedPathInExpression,
+Literal,
+Operator,
+Grouped,
+Array,
+ArrayIndex,
+Tuple,
+TupleIndex,
+Struct,
+Call,
+MethodCall,
+FieldAccess,
+Closure,
+Block,
+Continue,
+Break,
+Range,
+Box,
+Return,
+UnsafeBlock,
+Loop,
+If,
+IfLet,
+Match,
+Await,
+AsyncBlock,
+InlineAsm,
+Identifier,
+FormatArgs,
+MacroInvocation,
+  };
+
+  virtual Kind get_expr_kind () const = 0;
+
   // Unique pointer custom clone function
   std::unique_ptr clone_expr () const
   {
@@ -1343,7 +1381,7 @@ public:
 outer_attrs = std::move (new_attrs);
   }
 
-  Kind get_ast_kind () const override { return Kind::IDENTIFIER; }
+  Expr::Kind get_expr_kind () const override { return Expr::Kind::Id

[gcc r15-9012] cobol: Confine all __int128/_Float128 references to libgcobol.

2025-03-28 Thread Robert Dubner via Gcc-cvs
https://gcc.gnu.org/g:137e294883407d227ad20767ea3363a37d22c1e9

commit r15-9012-g137e294883407d227ad20767ea3363a37d22c1e9
Author: Bob Dubner 
Date:   Fri Mar 28 12:09:39 2025 -0400

cobol: Confine all __int128/_Float128 references to libgcobol.

These changes are part of the effort to make possible cross compilation for
hosts that don't support __int128 or _Float128.

gcc/cobol

* Make-lang.in: Eliminate libgcobol.h from gcc/cobol files.
* genapi.cc: Eliminate "#include libgcobol.h".
(parser_display_internal): Change comment.
* genmath.cc: Eliminate "#include libgcobol.h".
* genutil.cc: Likewise.
(get_power_of_ten): Change comment.
* structs.cc: Eliminate cblc_int128_type_node.
* structs.h: Likewise.
* symbols.h: Receive comment from libgcobol.h

libgcobol

* charmaps.cc:Eliminate "#include libgcobol.h".
Change comment about _Float128.
* common-defs.h: Change comment about _Float128. Receive
#defines from libgcobol.h.
* constants.cc: Eliminate #include libgcobol.h. Eliminate other
unneeded #includes.
* ec.h: Receive declarations from libgcobol.h.
* gcobolio.h: Likewise.
* gfileio.cc: (__gg__file_init): Use file_flag_none_e instead of
zero in assignment.  (__gg__file_reopen): Likewise.
(__io__file_open): Likewise.
* gfileio.h: Receive declarations from libgcobol.h.
* libgcobol.h: Numerous declarations moved elsewhere.

Diff:
---
 gcc/cobol/Make-lang.in  |   2 -
 gcc/cobol/genapi.cc |   8 +--
 gcc/cobol/genmath.cc|   1 -
 gcc/cobol/genutil.cc|   3 +-
 gcc/cobol/structs.cc|  30 -
 gcc/cobol/structs.h |   1 -
 gcc/cobol/symbols.h |   8 +++
 libgcobol/charmaps.cc   |   1 -
 libgcobol/common-defs.h |  24 +++-
 libgcobol/constants.cc  |   9 ---
 libgcobol/ec.h  |  60 ++
 libgcobol/gcobolio.h|  38 
 libgcobol/gfileio.cc|   8 +--
 libgcobol/gfileio.h |  24 
 libgcobol/libgcobol.h   | 157 +++-
 15 files changed, 169 insertions(+), 205 deletions(-)

diff --git a/gcc/cobol/Make-lang.in b/gcc/cobol/Make-lang.in
index 02c867ea22a1..ee048b09d9de 100644
--- a/gcc/cobol/Make-lang.in
+++ b/gcc/cobol/Make-lang.in
@@ -93,7 +93,6 @@ cobol/charmaps.cc: $(LIB_SOURCE)/charmaps.cc
sed -i "s|\"common-defs[.]h\"|\"$(LIB_SOURCE)/common-defs.h\"|g" $@
sed -i "s|\"io[.]h\"|\"$(LIB_SOURCE)/io.h\"|g" $@
sed -i "s|\"gcobolio[.]h\"|\"$(LIB_SOURCE)/gcobolio.h\"|g" $@
-   sed -i "s|\"libgcobol[.]h\"|\"$(LIB_SOURCE)/libgcobol.h\"|g" $@
sed -i "s|\"gfileio[.]h\"|\"$(LIB_SOURCE)/gfileio.h\"|g" $@
sed -i "s|\"charmaps[.]h\"|\"$(LIB_SOURCE)/charmaps.h\"|g" $@
sed -i "s|\"valconv[.]h\"|\"$(LIB_SOURCE)/valconv.h\"|g" $@
@@ -105,7 +104,6 @@ cobol/valconv.cc: $(LIB_SOURCE)/valconv.cc
sed -i "s|\"common-defs[.]h\"|\"$(LIB_SOURCE)/common-defs.h\"|g" $@
sed -i "s|\"io[.]h\"|\"$(LIB_SOURCE)/io.h\"|g" $@
sed -i "s|\"gcobolio[.]h\"|\"$(LIB_SOURCE)/gcobolio.h\"|g" $@
-   sed -i "s|\"libgcobol[.]h\"|\"$(LIB_SOURCE)/libgcobol.h\"|g" $@
sed -i "s|\"gfileio[.]h\"|\"$(LIB_SOURCE)/gfileio.h\"|g" $@
sed -i "s|\"charmaps[.]h\"|\"$(LIB_SOURCE)/charmaps.h\"|g" $@
sed -i "s|\"valconv[.]h\"|\"$(LIB_SOURCE)/valconv.h\"|g" $@
diff --git a/gcc/cobol/genapi.cc b/gcc/cobol/genapi.cc
index 8adc07ec57fa..be463f26bdfd 100644
--- a/gcc/cobol/genapi.cc
+++ b/gcc/cobol/genapi.cc
@@ -48,7 +48,6 @@
 #include "genmath.h"
 #include "structs.h"
 #include "../../libgcobol/gcobolio.h"
-#include "../../libgcobol/libgcobol.h"
 #include "../../libgcobol/charmaps.h"
 #include "../../libgcobol/valconv.h"
 #include "show_parse.h"
@@ -4800,14 +4799,13 @@ parser_display_internal(tree file_descriptor,
   else if( refer.field->type == FldLiteralN )
 {
 // The parser found the string of digits from the source code and converted
-// it to a _Float128.
+// it to a 128-bit binary floating point number.
 
 // The bad news is that something like 555.55 can't be expressed exactly;
 // internally it is 555.54
 
-// The good news is that we know any string of 33 or fewer digits is
-// converted to _Float128 and then converted back again, you get the same
-// string.
+// The good news is that we know any string of 33 or fewer decimal digits
+// can be converted to and from IEEE 754 binary128 without being changes
 
 // We make use of that here
 
diff --git a/gcc/cobol/genmath.cc b/gcc/cobol/genmath.cc
index 56254e88cc6c..9725754eae15 100644
--- a/gcc/cobol/genmath.cc
+++ b/gcc/cobol/genmath.cc
@@ -42,7 +42,6 @@
 #include "gengen.h"
 #include "structs.h"
 #include "../../libgcobol/gcobolio.h"
-#include "../../libgc

[gcc r15-9017] libstdc++: Add testcase for bogus -Wstringop-overflow in std::vector [PR117983]

2025-03-28 Thread Jonathan Wakely via Gcc-cvs
https://gcc.gnu.org/g:878812b6f6905774ab37cb78903e3e11bf1c508c

commit r15-9017-g878812b6f6905774ab37cb78903e3e11bf1c508c
Author: Jonathan Wakely 
Date:   Fri Mar 28 21:46:46 2025 +

libstdc++: Add testcase for bogus -Wstringop-overflow in std::vector 
[PR117983]

This was fixed on trunk by r15-4473-g3abe751ea86e34, just add the
testcase.

libstdc++-v3/ChangeLog:

PR libstdc++/117983
* testsuite/23_containers/vector/modifiers/insert/117983.cc: New
test.

Diff:
---
 .../23_containers/vector/modifiers/insert/117983.cc | 17 +
 1 file changed, 17 insertions(+)

diff --git 
a/libstdc++-v3/testsuite/23_containers/vector/modifiers/insert/117983.cc 
b/libstdc++-v3/testsuite/23_containers/vector/modifiers/insert/117983.cc
new file mode 100644
index ..e6027a677eed
--- /dev/null
+++ b/libstdc++-v3/testsuite/23_containers/vector/modifiers/insert/117983.cc
@@ -0,0 +1,17 @@
+// { dg-options "-O3 -Werror=stringop-overflow" }
+// { dg-do compile }
+
+// PR libstdc++/117983
+// -Wstringop-overflow false positive for __builtin_memmove from vector::insert
+
+#include 
+
+typedef std::vector bytes;
+
+void push(bytes chunk, bytes& data) {
+  if (data.empty()) {
+data.swap(chunk);
+  } else {
+data.insert(data.end(), chunk.begin(), chunk.end());
+  }
+}


[gcc r15-9011] PR modula2/119504: ICE when attempting to access an element of a constant string

2025-03-28 Thread Gaius Mulley via Gcc-cvs
https://gcc.gnu.org/g:b69945d511b394ef092c888c6475f8c72bee0c03

commit r15-9011-gb69945d511b394ef092c888c6475f8c72bee0c03
Author: Gaius Mulley 
Date:   Fri Mar 28 15:25:55 2025 +

PR modula2/119504: ICE when attempting to access an element of a constant 
string

This patch prevents an ICE and generates an error if an array access to a
constant string is attempted.  The patch also allows HIGH ("string").

gcc/m2/ChangeLog:

PR modula2/119504
* gm2-compiler/M2Quads.mod (BuildHighFunction): Defend against
Type = NulSym and fall into BuildConstHighFromSym.
(BuildDesignatorArray): Rewrite to detect an array access to
a constant string.
(BuildDesignatorArrayStaticDynamic): New procedure.

gcc/testsuite/ChangeLog:

PR modula2/119504
* gm2/iso/fail/conststrarray2.mod: New test.
* gm2/iso/run/pass/constarray2.mod: New test.
* gm2/pim/pass/hexstring.mod: New test.

Signed-off-by: Gaius Mulley 

Diff:
---
 gcc/m2/gm2-compiler/M2Quads.mod| 51 +-
 gcc/testsuite/gm2/iso/fail/conststrarray2.mod  | 30 +++
 gcc/testsuite/gm2/iso/run/pass/constarray2.mod | 33 +
 gcc/testsuite/gm2/pim/pass/hexstring.mod   | 16 
 4 files changed, 120 insertions(+), 10 deletions(-)

diff --git a/gcc/m2/gm2-compiler/M2Quads.mod b/gcc/m2/gm2-compiler/M2Quads.mod
index 573fd74e4f15..9bb8c4d35a64 100644
--- a/gcc/m2/gm2-compiler/M2Quads.mod
+++ b/gcc/m2/gm2-compiler/M2Quads.mod
@@ -8474,7 +8474,7 @@ BEGIN
   THEN
  (* we cannot test for IsConst(Param) AND (GetSType(Param)=Char)  as 
the type might not be assigned yet *)
  MetaError1 ('base procedure {%EkHIGH} expects a variable or string 
constant as its parameter {%1d:rather than {%1d}} {%1asa}', Param)
-  ELSIF IsUnbounded(Type)
+  ELSIF (Type # NulSym) AND IsUnbounded(Type)
   THEN
  BuildHighFromUnbounded (combinedtok)
   ELSE
@@ -11481,13 +11481,12 @@ END BuildDesignatorPointerError ;
 (*
BuildDesignatorArray - Builds the array referencing.
   The purpose of this procedure is to work out
-  whether the DesignatorArray is a static or
-  dynamic array and to call the appropriate
+  whether the DesignatorArray is a constant string or
+  dynamic array/static array and to call the 
appropriate
   BuildRoutine.
 
   The Stack is expected to contain:
 
-
   Entry   Exit
   =   
 
@@ -11500,6 +11499,41 @@ END BuildDesignatorPointerError ;
 *)
 
 PROCEDURE BuildDesignatorArray ;
+BEGIN
+   IF IsConst (OperandT (2)) AND IsConstString (OperandT (2))
+   THEN
+  MetaErrorT1 (OperandTtok (2),
+   '{%1Ead} is not an array, but a constant string.  Hint use 
a string constant created with an array constructor',
+   OperandT (2)) ;
+  BuildDesignatorError ('bad array access')
+   ELSE
+  BuildDesignatorArrayStaticDynamic
+   END
+END BuildDesignatorArray ;
+
+
+(*
+   BuildDesignatorArrayStaticDynamic - Builds the array referencing.
+   The purpose of this procedure is to 
work out
+   whether the DesignatorArray is a static 
or
+   dynamic array and to call the 
appropriate
+   BuildRoutine.
+
+   The Stack is expected to contain:
+
+
+   Entry   Exit
+   =   
+
+Ptr ->
+   +--+
+   | e|
<- Ptr
+   |--|++
+   | Sym  | Type  || S| T   |
+   |--|||
+*)
+
+PROCEDURE BuildDesignatorArrayStaticDynamic ;
 VAR
combinedTok,
arrayTok,
@@ -11512,10 +11546,7 @@ BEGIN
IF IsConst (OperandT (2))
THEN
   type := GetDType (OperandT (2)) ;
-  IF type = NulSym
-  THEN
- InternalError ('constant type should have been resolved')
-  ELSIF IsArray (type)
+  IF (type # NulSym) AND IsArray (type)
   THEN
  PopTtok (e, exprTok) ;
  PopTFDtok (Sym, Type, dim, arrayTok) ;
@@ -11533,7 +11564,7 @@ BEGIN
IF (NOT IsVar (OperandT (2))) AND (NOT IsTemporary (OperandT (2)))
THEN
   MetaErrorT1 (OperandTtok (2),
-   'can only access arrays using va

[gcc r15-9008] If the LHS does not contain zero, neither do multiply operands.

2025-03-28 Thread Andrew Macleod via Gcc-cvs
https://gcc.gnu.org/g:dd9ed951f4002419ceff744bbd87ae9b8affdaf4

commit r15-9008-gdd9ed951f4002419ceff744bbd87ae9b8affdaf4
Author: Andrew MacLeod 
Date:   Wed Mar 26 10:34:42 2025 -0400

If the LHS does not contain zero, neither do multiply operands.

Given ~[0,0] = op1 * op2, range-ops should determine that neither op1 nor
op2 is zero.  Add this to the operator_mult for op1_range.  op2_range
simply invokes op1_range, so both will be covered.

PR tree-optimzation/110992.c
PR tree-optimzation/119471.c
gcc/
* range-op.cc (operator_mult::op1_range): If the LHS does not
contain zero, return non-zero.

gcc/testsuite/
* gcc.dg/pr110992.c: New.
* gcc.dg/pr119471.c: New.

Diff:
---
 gcc/range-op.cc |  7 +++
 gcc/testsuite/gcc.dg/pr110992.c | 18 ++
 gcc/testsuite/gcc.dg/pr119471.c | 19 +++
 3 files changed, 44 insertions(+)

diff --git a/gcc/range-op.cc b/gcc/range-op.cc
index 6310ce27f03c..f72b4ae92cfd 100644
--- a/gcc/range-op.cc
+++ b/gcc/range-op.cc
@@ -2220,6 +2220,13 @@ operator_mult::op1_range (irange &r, tree type,
   wide_int offset;
   if (op2.singleton_p (offset) && offset != 0)
 return range_op_handler (TRUNC_DIV_EXPR).fold_range (r, type, lhs, op2);
+
+  //  ~[0, 0] = op1 * op2  defines op1 and op2 as non-zero.
+  if (!lhs.contains_p (wi::zero (TYPE_PRECISION (lhs.type ()
+{
+  r.set_nonzero (type);
+  return true;
+}
   return false;
 }
 
diff --git a/gcc/testsuite/gcc.dg/pr110992.c b/gcc/testsuite/gcc.dg/pr110992.c
new file mode 100644
index ..05e9b9267e6f
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr110992.c
@@ -0,0 +1,18 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-evrp" } */
+
+void foo (int);
+
+int f(unsigned b, short c)
+{
+  int bt = b;
+  int bt1 = bt;
+  int t = bt1 & -(c!=0);
+ // int t = bt1 * (c!=0);
+
+  if (!t) return 0;
+  foo(bt == 0);
+  return 0;
+}
+
+/* { dg-final { scan-tree-dump-times "foo \\(0\\)" 1 "evrp" } } */
diff --git a/gcc/testsuite/gcc.dg/pr119471.c b/gcc/testsuite/gcc.dg/pr119471.c
new file mode 100644
index ..4c55d85f77c4
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr119471.c
@@ -0,0 +1,19 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-evrp" } */
+
+int fa(int a, int b)
+{
+  int c = a * b;
+  if (c != 0)
+return (a != 0);
+  return 0;
+}
+int fb(int a, int b)
+{
+  int c = a * b;
+  if (c != 0)
+return (b != 0);
+  return 0;
+}
+
+/* { dg-final { scan-tree-dump-times "PHI <1" 2 "evrp" } } */


[gcc r15-9010] srcextra fixes

2025-03-28 Thread Jakub Jelinek via Gcc-cvs
https://gcc.gnu.org/g:b9f08c8631c2c1a393d7d2bdd41b1b0fe76b1663

commit r15-9010-gb9f08c8631c2c1a393d7d2bdd41b1b0fe76b1663
Author: Jakub Jelinek 
Date:   Fri Mar 28 15:45:03 2025 +0100

srcextra fixes

Here is a patch which uses sed to fix up the copies of the generated
files by flex/bison in the source directories (i.e. what we ship in
release tarballs).
In that case the generated files are in the same directory as the
files they are generated from, so there should be no absolute or relative
directories, just the filenames.

Furthermore, c.srcextra was duplicating the work of gcc.srcextra, there is
nothing C FE specific on gengtype-lex.l.

2025-03-28  Jakub Jelinek  

gcc/
* Makefile.in (gcc.srcextra): Use sed to turn .../gcc/gengtype-lex.l
in #line directives into just gengtype-lex.l.
gcc/c/
* Make-lang.in (c.srcextra): Don't depend on anything and don't copy
anything.
gcc/cobol/
* Make-lang.in (cobol.srcextra): Use sed to turn
.../gcc/cobol/*.{y,l,h,cc} and cobol/*.{y,l,h,cc} in #line 
directives
into just *.{y,l,h,cc}.

Diff:
---
 gcc/Makefile.in| 2 +-
 gcc/c/Make-lang.in | 3 +--
 gcc/cobol/Make-lang.in | 5 +++--
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index ead9c015fb25..ebfcd8a8a0d3 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -2508,7 +2508,7 @@ s-mlib: $(srcdir)/genmultilib Makefile
 srcextra: gcc.srcextra lang.srcextra
 
 gcc.srcextra: gengtype-lex.cc
-   -cp -p $^ $(srcdir)
+   -sed -e '/^#line/s,".*/gcc/gengtype-lex\.l","gengtype-lex.l",' $^ > 
$(srcdir)/$^
 
 AR_OBJS = file-find.o
 AR_LIBS = @COLLECT2_LIBS@
diff --git a/gcc/c/Make-lang.in b/gcc/c/Make-lang.in
index 049b266dd710..2517b64439fe 100644
--- a/gcc/c/Make-lang.in
+++ b/gcc/c/Make-lang.in
@@ -131,8 +131,7 @@ c.all.cross:
 c.start.encap:
 c.rest.encap:
 c.srcinfo:
-c.srcextra: gengtype-lex.cc
-   -cp -p $^ $(srcdir)
+c.srcextra:
 c.tags: force
cd $(srcdir)/c; $(ETAGS) -o TAGS.sub *.cc *.h; \
$(ETAGS) --include TAGS.sub --include ../TAGS.sub
diff --git a/gcc/cobol/Make-lang.in b/gcc/cobol/Make-lang.in
index eb64554f33bc..02c867ea22a1 100644
--- a/gcc/cobol/Make-lang.in
+++ b/gcc/cobol/Make-lang.in
@@ -272,8 +272,9 @@ cobol/scan.o: cobol/scan.cc \
 # output, and do not require those tools to be installed.
 #
 cobol.srcextra: cobol/parse.cc cobol/cdf.cc cobol/scan.cc
-   -cp -p $^ cobol/parse.h cobol/cdf.h $(srcdir)/cobol/
-
+   -for i in $^ cobol/parse.h cobol/cdf.h; do \
+ sed -e '/^#line/s,"\(.*gcc/\)\?cobol/\([^/]*\.\([ylh]\|cc\)\)","\2",' 
$$i \
+   > $(srcdir)/$$i; done
 
 # And the cobol1 front end


[gcc r15-9009] other/119510 - use --enable-languages=default, cobol for release tarballs

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

commit r15-9009-gbb389fb04b07a491d2ca0380db08b8c43b4239b9
Author: Richard Biener 
Date:   Fri Mar 28 15:20:16 2025 +0100

other/119510 - use --enable-languages=default,cobol for release tarballs

The following adds cobol to the set of languages built during release
tarball building so the bison and flex generated sources for cobol
are included in the tarball.

PR other/119510
maintainer-scripts/
* gcc_release: Use --enable-languages=default,cobol
when building generated files.

Diff:
---
 maintainer-scripts/gcc_release | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/maintainer-scripts/gcc_release b/maintainer-scripts/gcc_release
index 42bb7f68f171..471a10cc39e4 100755
--- a/maintainer-scripts/gcc_release
+++ b/maintainer-scripts/gcc_release
@@ -267,7 +267,7 @@ EOF
   esac
 fi
 contrib/gcc_build -d ${SOURCE_DIRECTORY} -o ${OBJECT_DIRECTORY} \
-  -c "--enable-generated-files-in-srcdir --disable-multilib" \
+  -c "--enable-languages=default,cobol --enable-generated-files-in-srcdir 
--disable-multilib" \
   -m "-j$num_cpus" build || \
   error "Could not rebuild GCC"
   fi


[gcc r15-9005] cobol: Eliminate check-cobol -Os failure in EVALUATE testcase

2025-03-28 Thread Robert Dubner via Gcc-cvs
https://gcc.gnu.org/g:ae2f951cc22ba9b0b1c8650d4de553344fc4fb95

commit r15-9005-gae2f951cc22ba9b0b1c8650d4de553344fc4fb95
Author: Bob Dubner 
Date:   Fri Mar 28 08:57:24 2025 -0400

cobol: Eliminate check-cobol -Os failure in EVALUATE testcase

The coding error was the lack of a necessary cast from unsigned
char to int.

gcc/cobol

* genapi.cc: (create_and_call): cast unsigned char to int

gcc/testsuite

* cobol.dg/group2/Complex_EVALUATE__1_.cob: New EVALUTE testcase.
* cobol.dg/group2/Complex_EVALUATE__2_.cob: Likewise.
* cobol.dg/group2/EVALUATE_WHEN_NEGATIVE.cob: Likewise.
* cobol.dg/group2/EVALUATE_condition__2_.cob: Likewise.
* cobol.dg/group2/EVALUATE_doubled_WHEN.cob: Likewise.
* cobol.dg/group2/EVALUATE_with_WHEN_using_condition-1.cob: 
Likewise.
* cobol.dg/group2/Complex_EVALUATE__1_.out: Known-good data for 
testcase.
* cobol.dg/group2/Complex_EVALUATE__2_.out: Likewise.
* cobol.dg/group2/EVALUATE_WHEN_NEGATIVE.out: Likewise.
* cobol.dg/group2/EVALUATE_condition__2_.out: Likewise.
* cobol.dg/group2/EVALUATE_doubled_WHEN.out: Likewise.
* cobol.dg/group2/EVALUATE_with_WHEN_using_condition-1.out: 
Likewise.

Diff:
---
 gcc/cobol/genapi.cc|  3 +-
 .../cobol.dg/group2/Complex_EVALUATE__1_.cob   | 46 +++
 .../cobol.dg/group2/Complex_EVALUATE__1_.out   |  5 +++
 .../cobol.dg/group2/Complex_EVALUATE__2_.cob   | 52 ++
 .../cobol.dg/group2/Complex_EVALUATE__2_.out   | 15 +++
 .../cobol.dg/group2/EVALUATE_WHEN_NEGATIVE.cob | 16 +++
 .../cobol.dg/group2/EVALUATE_WHEN_NEGATIVE.out |  2 +
 .../cobol.dg/group2/EVALUATE_condition__2_.cob | 38 
 .../cobol.dg/group2/EVALUATE_condition__2_.out |  5 +++
 .../cobol.dg/group2/EVALUATE_doubled_WHEN.cob  | 30 +
 .../cobol.dg/group2/EVALUATE_doubled_WHEN.out  |  5 +++
 .../EVALUATE_with_WHEN_using_condition-1.cob   | 18 
 .../EVALUATE_with_WHEN_using_condition-1.out   |  2 +
 13 files changed, 236 insertions(+), 1 deletion(-)

diff --git a/gcc/cobol/genapi.cc b/gcc/cobol/genapi.cc
index bc9153381588..8adc07ec57fa 100644
--- a/gcc/cobol/genapi.cc
+++ b/gcc/cobol/genapi.cc
@@ -12395,13 +12395,14 @@ create_and_call(size_t narg,
   // We got back a 64-bit or 128-bit integer.  The called and calling
   // programs have to agree on size, but other than that, integer numeric
   // types are converted one to the other.
+
   gg_call(VOID,
   "__gg__int128_to_qualified_field",
   gg_get_address_of(returned.field->var_decl_node),
   refer_offset_dest(returned),
   refer_size_dest(returned),
   gg_cast(INT128, returned_value),
-  member(returned.field->var_decl_node, "rdigits"),
+  gg_cast(INT, member(returned.field->var_decl_node, "rdigits")),
   build_int_cst_type(INT, truncation_e),
   null_pointer_node,
   NULL_TREE );
diff --git a/gcc/testsuite/cobol.dg/group2/Complex_EVALUATE__1_.cob 
b/gcc/testsuite/cobol.dg/group2/Complex_EVALUATE__1_.cob
new file mode 100644
index ..a070d16108e9
--- /dev/null
+++ b/gcc/testsuite/cobol.dg/group2/Complex_EVALUATE__1_.cob
@@ -0,0 +1,46 @@
+   *> { dg-do run }
+   *> { dg-output-file "group2/Complex_EVALUATE__1_.out" }
+
+identification  division.
+function-id.bumper.
+datadivision.
+working-storage section.
+77 bump pic value zero.
+linkage section.
+77 bumped   pic .
+procedure division returning bumped.
+add 1 to bump.
+move bump to bumped.
+goback.
+end functionbumper.
+
+identification  division.
+program-id. prog.
+environment division.
+configuration   section.
+repository.
+function bumper.
+data division.
+working-storage section.
+77 bump pic value zero.
+77 bump1pic value zero.
+77 bump2pic value zero.
+77 bump3pic value zero.
+procedure division.
+move function bumper to bump
+display bump
+move function bumper to bump
+display bump
+move function bumper to bump
+display bump
+evaluate function bumper also function bumper also function bumper
+when 4 also 5 also 6
+display "properly 4 also 5 also 6"
+when 7 also 8 also 9
+display "IMPROPERLY 6 then 7 then 8"
+when othe

[gcc r15-9018] libcpp: Fix incorrect line numbers in large files [PR108900]

2025-03-28 Thread Jason Merrill via Gcc-cvs
https://gcc.gnu.org/g:d9b56c65a2697e0d7a6c0f15f1977803dc94579b

commit r15-9018-gd9b56c65a2697e0d7a6c0f15f1977803dc94579b
Author: Jeremy Bettis 
Date:   Fri Mar 28 00:54:27 2025 -0700

libcpp: Fix incorrect line numbers in large files [PR108900]

This patch addresses an issue in the C preprocessor where incorrect
line number information is generated when processing files with a
large number of lines. The problem arises from improper handling
of location intervals in the line map, particularly when locations
exceed LINE_MAP_MAX_LOCATION_WITH_PACKED_RANGES.

By ensuring that the highest location is not decremented if it
would move to a different ordinary map, this fix resolves
the line number discrepancies observed in certain test cases.
This change improves the accuracy of line number reporting, benefiting
users relying on precise code coverage and debugging information.

libcpp/ChangeLog:

PR preprocessor/108900
* files.cc (_cpp_stack_file): Do not decrement highest_location
across distinct maps.

Signed-off-by: Jeremy Bettis 
Signed-off-by: Yash Shinde 

Diff:
---
 libcpp/files.cc | 9 +
 1 file changed, 9 insertions(+)

diff --git a/libcpp/files.cc b/libcpp/files.cc
index 1ed19ca1..c1abde6639fe 100644
--- a/libcpp/files.cc
+++ b/libcpp/files.cc
@@ -1046,6 +1046,15 @@ _cpp_stack_file (cpp_reader *pfile, _cpp_file *file, 
include_type type,
&& type < IT_DIRECTIVE_HWM
&& (pfile->line_table->highest_location
!= LINE_MAP_MAX_LOCATION - 1));
+
+  if (decrement && LINEMAPS_ORDINARY_USED (pfile->line_table))
+{
+  const line_map_ordinary *map
+   = LINEMAPS_LAST_ORDINARY_MAP (pfile->line_table);
+  if (map && map->start_location == pfile->line_table->highest_location)
+   decrement = false;
+}
+
   if (decrement)
 pfile->line_table->highest_location--;


[gcc r15-9019] cobol: Fix up cobol/{charmaps,valconv}.cc rules

2025-03-28 Thread Jakub Jelinek via Gcc-cvs
https://gcc.gnu.org/g:ea46ef1d21ce3bc6b7584cdf21b7b26d5daf72db

commit r15-9019-gea46ef1d21ce3bc6b7584cdf21b7b26d5daf72db
Author: Jakub Jelinek 
Date:   Sat Mar 29 00:47:57 2025 +0100

cobol: Fix up cobol/{charmaps,valconv}.cc rules

sed -i is not portable, it is supported by GNU sed and perhaps some BSDs,
but not elsewhere.
Furthermore, I think it is far better to always use
 #include "../../libgcobol/something.h"
paths rather than something depending on the build directory.
And because we require GNU make, we don't have to have two different
rules for those, can use just one for both.
The l variable in there is just to make it fit into 80 columns.

2025-03-28  Jakub Jelinek  

* Make-lang.in (cobol/charmaps.cc, cobol/valconv.cc): Used sed -e
instead of cp and multiple sed -i commands.  Always prefix libgcobol
header names in #include directives with ../../libgcobol/ rather 
than
something depending on $(LIB_SOURCE).

Diff:
---
 gcc/cobol/Make-lang.in | 25 -
 1 file changed, 4 insertions(+), 21 deletions(-)

diff --git a/gcc/cobol/Make-lang.in b/gcc/cobol/Make-lang.in
index ee048b09d9de..990d51a85788 100644
--- a/gcc/cobol/Make-lang.in
+++ b/gcc/cobol/Make-lang.in
@@ -87,27 +87,10 @@ cobol1_OBJS =\
 # Various #includes in the files copied from gcc/libgcobol need to be modified
 # so that the .h files can be found.
 
-cobol/charmaps.cc: $(LIB_SOURCE)/charmaps.cc
-   cp $^ $@
-   sed -i "s|\"ec[.]h\"|\"$(LIB_SOURCE)/ec.h\"|g" $@
-   sed -i "s|\"common-defs[.]h\"|\"$(LIB_SOURCE)/common-defs.h\"|g" $@
-   sed -i "s|\"io[.]h\"|\"$(LIB_SOURCE)/io.h\"|g" $@
-   sed -i "s|\"gcobolio[.]h\"|\"$(LIB_SOURCE)/gcobolio.h\"|g" $@
-   sed -i "s|\"gfileio[.]h\"|\"$(LIB_SOURCE)/gfileio.h\"|g" $@
-   sed -i "s|\"charmaps[.]h\"|\"$(LIB_SOURCE)/charmaps.h\"|g" $@
-   sed -i "s|\"valconv[.]h\"|\"$(LIB_SOURCE)/valconv.h\"|g" $@
-   sed -i "s|\"exceptl[.]h\"|\"$(LIB_SOURCE)/exceptl.h\"|g" $@
-
-cobol/valconv.cc: $(LIB_SOURCE)/valconv.cc
-   cp $^ $@
-   sed -i "s|\"ec[.]h\"|\"$(LIB_SOURCE)/ec.h\"|g" $@
-   sed -i "s|\"common-defs[.]h\"|\"$(LIB_SOURCE)/common-defs.h\"|g" $@
-   sed -i "s|\"io[.]h\"|\"$(LIB_SOURCE)/io.h\"|g" $@
-   sed -i "s|\"gcobolio[.]h\"|\"$(LIB_SOURCE)/gcobolio.h\"|g" $@
-   sed -i "s|\"gfileio[.]h\"|\"$(LIB_SOURCE)/gfileio.h\"|g" $@
-   sed -i "s|\"charmaps[.]h\"|\"$(LIB_SOURCE)/charmaps.h\"|g" $@
-   sed -i "s|\"valconv[.]h\"|\"$(LIB_SOURCE)/valconv.h\"|g" $@
-   sed -i "s|\"exceptl[.]h\"|\"$(LIB_SOURCE)/exceptl.h\"|g" $@
+cobol/charmaps.cc cobol/valconv.cc: cobol/%.cc: $(LIB_SOURCE)/%.cc
+   -l='ec\|common-defs\|io\|gcobolio\|gfileio\|charmaps'; \
+   l=$$l'\|valconv\|exceptl'; \
+   sed -e '/^#include/s,"\('$$l'\)\.h","../../libgcobol/\1.h",' $^ > $@
 
 LIB_SOURCE_H=$(wildcard $(LIB_SOURCE)/*.h)


[gcc r15-8688] MAINTAINERS: Add myself

2025-03-28 Thread James K. Lowden via Gcc-cvs
https://gcc.gnu.org/g:eda74cd05447475d385b8a8216e3412da96a46da

commit r15-8688-geda74cd05447475d385b8a8216e3412da96a46da
Author: James K. Lowden 
Date:   Sun Mar 23 16:24:36 2025 -0400

MAINTAINERS: Add myself

ChangeLog:

* MAINTAINERS: Add myself.

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

diff --git a/MAINTAINERS b/MAINTAINERS
index 5b3fe407860f..90c8e2aa9950 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -163,6 +163,7 @@ Ada front end   Eric Botcazou   

 Ada front end   Marc Poulhiès   
 Ada front end   Pierre-Marie de Rodat   
 COBOL front end Robert Dubner   
+COBOL front end James K. Lowden 
 c++ Jason Merrill   
 c++ Nathan Sidwell  
 D front end Iain Buclaw 


[gcc r15-9022] LoongArch: Set default alignment for functions jumps loops and labels.

2025-03-28 Thread LuluCheng via Gcc-cvs
https://gcc.gnu.org/g:6525b408b25945970d84ed1f534616fd63b03a50

commit r15-9022-g6525b408b25945970d84ed1f534616fd63b03a50
Author: Lulu Cheng 
Date:   Thu Mar 27 11:27:40 2025 +0800

LoongArch: Set default alignment for functions jumps loops and labels.

Based on r15-7624, a set of align combinations with better performance
was tested through spec2006.

LA464: -falign-loops=8 -falign-functions=32 -falign-jumps=32 
-falign-labels=8
LA664: -falign-loops=16 -falign-functions=16 -falign-jumps=32 
-falign-labels=8

gcc/ChangeLog:

* config/loongarch/loongarch-def.cc
(la464_align): Add settings for labels.
(la664_align): Likewise.
* config/loongarch/loongarch-opts.cc
(loongarch_target_option_override): Likewise.
* config/loongarch/loongarch-tune.h
(struct loongarch_align): Implement the function `label_`.

Diff:
---
 gcc/config/loongarch/loongarch-def.cc  | 4 ++--
 gcc/config/loongarch/loongarch-opts.cc | 3 +++
 gcc/config/loongarch/loongarch-tune.h  | 9 -
 3 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/gcc/config/loongarch/loongarch-def.cc 
b/gcc/config/loongarch/loongarch-def.cc
index 5f235a04ef2f..04b277eb7425 100644
--- a/gcc/config/loongarch/loongarch-def.cc
+++ b/gcc/config/loongarch/loongarch-def.cc
@@ -107,12 +107,12 @@ array_tune loongarch_cpu_cache =
 
 static inline loongarch_align la464_align ()
 {
-  return loongarch_align ().function_ ("32").loop_ ("16").jump_ ("16");
+  return loongarch_align ().function_ ("32").loop_ ("8").jump_ ("32").label_ 
("8");
 }
 
 static inline loongarch_align la664_align ()
 {
-  return loongarch_align ().function_ ("8").loop_ ("8").jump_ ("32");
+  return loongarch_align ().function_ ("16").loop_ ("16").jump_ ("32").label_ 
("8");
 }
 
 array_tune loongarch_cpu_align =
diff --git a/gcc/config/loongarch/loongarch-opts.cc 
b/gcc/config/loongarch/loongarch-opts.cc
index c2a63f75fc24..6e72084b9beb 100644
--- a/gcc/config/loongarch/loongarch-opts.cc
+++ b/gcc/config/loongarch/loongarch-opts.cc
@@ -965,6 +965,9 @@ loongarch_target_option_override (struct loongarch_target 
*target,
 
   if (opts->x_flag_align_jumps && !opts->x_str_align_jumps)
opts->x_str_align_jumps = loongarch_cpu_align[target->cpu_tune].jump;
+
+  if (opts->x_flag_align_labels && !opts->x_str_align_labels)
+   opts->x_str_align_labels = loongarch_cpu_align[target->cpu_tune].label;
 }
 
   /* Set up parameters to be used in prefetching algorithm.  */
diff --git a/gcc/config/loongarch/loongarch-tune.h 
b/gcc/config/loongarch/loongarch-tune.h
index f7819fe76783..0ae74e77f996 100644
--- a/gcc/config/loongarch/loongarch-tune.h
+++ b/gcc/config/loongarch/loongarch-tune.h
@@ -177,8 +177,9 @@ struct loongarch_align {
   const char *function;/* default value for -falign-functions */
   const char *loop;/* default value for -falign-loops */
   const char *jump;/* default value for -falign-jumps */
+  const char *label;   /* default value for -falign-labels */
 
-  loongarch_align () : function (nullptr), loop (nullptr), jump (nullptr) {}
+  loongarch_align () : function (nullptr), loop (nullptr), jump (nullptr), 
label (nullptr) {}
 
   loongarch_align function_ (const char *_function)
   {
@@ -197,6 +198,12 @@ struct loongarch_align {
 jump = _jump;
 return *this;
   }
+
+  loongarch_align label_ (const char *_label)
+  {
+label = _label;
+return *this;
+  }
 };
 
 #endif /* LOONGARCH_TUNE_H */


[gcc r15-9023] LoongArch: doc: Add same-address constraint to the description of '-mld-seq-sa'.

2025-03-28 Thread LuluCheng via Gcc-cvs
https://gcc.gnu.org/g:8ad8f74972923bf2b6d6291d31ef53c4ded4

commit r15-9023-g8ad8f74972923bf2b6d6291d31ef53c4ded4
Author: Lulu Cheng 
Date:   Thu Mar 27 11:42:11 2025 +0800

LoongArch: doc: Add same-address constraint to the description of 
'-mld-seq-sa'.

gcc/ChangeLog:

* doc/invoke.texi: Modify the description of '-mld-seq-sa'.

Diff:
---
 gcc/doc/invoke.texi | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 2397e5ddf5ff..df4610908243 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -28000,8 +28000,8 @@ Use (do not use) @code{amcas[_db].@{b/h/w/d@}} 
instructions.  When build with
 @opindex mno-ld-seq-sa
 @item -mld-seq-sa
 @itemx -mno-ld-seq-sa
-Whether a load-load barrier (@code{dbar 0x700}) is needed.  When build with
-@option{-march=la664}, it is enabled by default.  The default is
+Whether a same-address load-load barrier (@code{dbar 0x700}) is needed.  When
+build with @option{-march=la664}, it is enabled by default.  The default is
 @option{-mno-ld-seq-sa}, the load-load barrier is needed.
 
 @opindex mtls-dialect


[gcc r15-9020] testsuite: Fix up musttail2.C test

2025-03-28 Thread Jakub Jelinek via Gcc-cvs
https://gcc.gnu.org/g:1a4aff76a2b104ff0b103c685b6c2ce8006fe6bb

commit r15-9020-g1a4aff76a2b104ff0b103c685b6c2ce8006fe6bb
Author: Jakub Jelinek 
Date:   Sat Mar 29 00:49:27 2025 +0100

testsuite: Fix up musttail2.C test

On Wed, Mar 26, 2025 at 10:10:07AM -0700, Andi Kleen wrote:
> I think this needs to be target external_tailcall, otherwise you will
> fail on targets that don't support that.
>
> Or alternatively make this not extern.

You're right (although I don't remember which targets are
non-external_musttail).

Here is a patch to define the function.

2025-03-28  Jakub Jelinek  

* g++.dg/opt/musttail2.C (foo): Define the function instead of
just declaring it, add [[gnu::noipa]] attribute to it.

Diff:
---
 gcc/testsuite/g++.dg/opt/musttail2.C | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/gcc/testsuite/g++.dg/opt/musttail2.C 
b/gcc/testsuite/g++.dg/opt/musttail2.C
index ee55c1a18df1..d12fcb2e397d 100644
--- a/gcc/testsuite/g++.dg/opt/musttail2.C
+++ b/gcc/testsuite/g++.dg/opt/musttail2.C
@@ -4,7 +4,12 @@
 // { dg-final { scan-tree-dump-times "  \[^\n\r]* = foo \\\(\[^\n\r]*\\\); 
\\\[tail call\\\] \\\[must tail call\\\]" 1 "optimized" } }
 
 struct S { S () {} };
-char *foo (S);
+
+[[gnu::noipa]] char *
+foo (S)
+{
+  return 0;
+}
 
 char *
 bar (S)


[gcc r15-8998] testsuite, arm: fix broken dg directives

2025-03-28 Thread Sam James via Gcc-cvs
https://gcc.gnu.org/g:39d4c1ff491662b1e167740647b2e0077e2c3739

commit r15-8998-g39d4c1ff491662b1e167740647b2e0077e2c3739
Author: David Malcolm 
Date:   Wed Mar 26 14:34:48 2025 -0400

testsuite, arm: fix broken dg directives

Found by dg-lint.

gcc/testsuite/ChangeLog:
* gcc.target/arm/cmse/cmse-17.c: Fix missing space before trailing
"}" in dg-options.

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

diff --git a/gcc/testsuite/gcc.target/arm/cmse/cmse-17.c 
b/gcc/testsuite/gcc.target/arm/cmse/cmse-17.c
index a2cce09afae5..c5be8101f56a 100644
--- a/gcc/testsuite/gcc.target/arm/cmse/cmse-17.c
+++ b/gcc/testsuite/gcc.target/arm/cmse/cmse-17.c
@@ -1,5 +1,5 @@
 /* { dg-do compile } */
-/* { dg-options "-mcmse"}  */
+/* { dg-options "-mcmse" }  */
 
 #include 


[gcc r15-8997] testsuite, aarch64: fix broken dg directives

2025-03-28 Thread Sam James via Gcc-cvs
https://gcc.gnu.org/g:8ac6399970ff39bc72bee5b9efee067325fdee74

commit r15-8997-g8ac6399970ff39bc72bee5b9efee067325fdee74
Author: David Malcolm 
Date:   Wed Mar 26 14:34:46 2025 -0400

testsuite, aarch64: fix broken dg directives

Found by dg-lint.

gcc/testsuite/ChangeLog:
* gcc.target/aarch64/saturating_arithmetic_1.c: Fix dg-do compile.
* gcc.target/aarch64/saturating_arithmetic_2.c: Likewise.

Diff:
---
 gcc/testsuite/gcc.target/aarch64/saturating_arithmetic_1.c | 4 ++--
 gcc/testsuite/gcc.target/aarch64/saturating_arithmetic_2.c | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/gcc/testsuite/gcc.target/aarch64/saturating_arithmetic_1.c 
b/gcc/testsuite/gcc.target/aarch64/saturating_arithmetic_1.c
index 2ac0c376d126..acd2e11f41d3 100644
--- a/gcc/testsuite/gcc.target/aarch64/saturating_arithmetic_1.c
+++ b/gcc/testsuite/gcc.target/aarch64/saturating_arithmetic_1.c
@@ -1,4 +1,4 @@
-/* { dg-do-compile } */
+/* { dg-do compile } */
 /* { dg-options "-O2 --save-temps -fno-schedule-insns2" } */
 /* { dg-final { check-function-bodies "**" "" "" } } */
 
@@ -33,4 +33,4 @@
 #define UMAX UCHAR_MAX
 #define UMIN 0
 
-#include "saturating_arithmetic.inc"
\ No newline at end of file
+#include "saturating_arithmetic.inc"
diff --git a/gcc/testsuite/gcc.target/aarch64/saturating_arithmetic_2.c 
b/gcc/testsuite/gcc.target/aarch64/saturating_arithmetic_2.c
index 2a55aa9f2218..86c88f8447c3 100644
--- a/gcc/testsuite/gcc.target/aarch64/saturating_arithmetic_2.c
+++ b/gcc/testsuite/gcc.target/aarch64/saturating_arithmetic_2.c
@@ -1,4 +1,4 @@
-/* { dg-do-compile } */
+/* { dg-do compile } */
 /* { dg-options "-O2 --save-temps -fno-schedule-insns2" } */
 /* { dg-final { check-function-bodies "**" "" "" } } */
 
@@ -33,4 +33,4 @@
 #define UMAX USHRT_MAX
 #define UMIN 0
 
-#include "saturating_arithmetic.inc"
\ No newline at end of file
+#include "saturating_arithmetic.inc"


[gcc r15-8996] cobol: Do not include (no longer needed)

2025-03-28 Thread Iain D Sandoe via Gcc-cvs
https://gcc.gnu.org/g:7ba5d70266107de7226e0a163305a17d8bd22331

commit r15-8996-g7ba5d70266107de7226e0a163305a17d8bd22331
Author: Iain Sandoe 
Date:   Thu Mar 20 17:08:57 2025 +

cobol: Do not include  (no longer needed)

Several of enumerators in parse.y conflict with ones declared in at
least some versions of  .. e.g. "OVERFLOW".  The header is no
longer needed since the FE is not trying to do host arithmetic.

gcc/cobol/ChangeLog:

* cobol-system.h: Remove .

Signed-off-by: Iain Sandoe 

Diff:
---
 gcc/cobol/cobol-system.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/gcc/cobol/cobol-system.h b/gcc/cobol/cobol-system.h
index 81529bd3a67a..ff9583530e25 100644
--- a/gcc/cobol/cobol-system.h
+++ b/gcc/cobol/cobol-system.h
@@ -53,7 +53,6 @@
 #include 
 #include 
 #include 
-#include 
 
 #include 
 #include 


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

2025-03-28 Thread Michael Meissner via Gcc-cvs
https://gcc.gnu.org/g:e33b662269ba4629e7c5600424a6d70fb95b73b6

commit e33b662269ba4629e7c5600424a6d70fb95b73b6
Author: Michael Meissner 
Date:   Fri Mar 28 13:24:44 2025 -0400

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

This is version 5 of the patch.

In versions 4 and 5, I made the following changes:

1:  I changed the use of enums to match current C++.

In version 3, I made the following changes:

1:  The new argument to rs6000_reverse_condition that says whether we 
should
allow ordered floating point compares to be reversed is now an
enumeration instead of a boolean.

2:  I tried to make the code in rs6000_reverse_condition clearer.

3:  I added checks in invert_fpmask_comparison_operator to prevent 
ordered
floating point compares from being reversed unless -ffast-math.

4:  I split the test cases into 4 separate tests (ordered vs. unordered
compare and -O2 vs. -Ofast).

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

extern double __ieee754_acos (double);

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

GCC currently generates the following code:

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

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

However, the XSCMPGTDP instruction will generate an interrupt if one of the
arguments is a signalling NaN and signalling NaNs can generate an interrupt.
The IEEE comparison functions (isgreater, etc.) require that the comparison 
not
raise an interrupt.

The following patch changes the PowerPC back end so that ifcvt.c will not 
change
the if/then test and move into a conditional move if the comparison is one 
of
the comparisons that do not raise an error with signalling NaNs and -Ofast 
is
not used.  If a normal comparison is used or -Ofast is used, GCC will 
continue
to generate XSCMPGTDP and XXSEL.

For the following code:

double
ordered_compare (double a, double b, double c, double d)
{
  return __builtin_isgreater (a, b) ? c : d;
}

/* Verify normal > does generate xscmpgtdp.  */

double
normal_compare (double a, double b, double c, double d)
{
  return a > b ? c : d;
}

with the following patch, GCC generates the following for power9, power10, 
and
power11:

ordered_compare:
fcmpu 0,1,2
fmr 1,4
bnglr 0
fmr 1,3
blr

normal_compare:
xscmpgtdp 1,1,2
xxsel 1,4,3,1
blr

I have built bootstrap compilers on big endian power9 systems and little 
endian
power9/power10 systems and there were no regressions.  Can I check this 
patch
into the GCC trunk, and after a waiting period, can I check this into the 
active
older branches?

2025-03-28  Michael Meissner  

gcc/

PR target/118541
* config/rs6000/predicates.md (invert_fpmask_comparison_operator): 
Do
not allow UNLT and UNLE unless -ffast-math.
* config/rs6000/rs6000-protos.h (enum rev_cond_ordered): New 
enumeration.
(rs6000_reverse_condition): Add argument.
* config/rs6000/rs6000.cc (rs6000_reverse_condition): Do not allow
ordered comparisons to be reversed for floating point conditional 
moves,
but allow ordered comparisons to be reversed on jumps.
(rs6000_emit_sCOND): Adjust rs6000_reverse_condition call.
* config/rs6000/rs6000.h (REVERSE_CONDITION): Likewise.
* config/rs6000/rs6000.md (reverse_branch_comparison): Name insn.
Adjust rs6000_reverse_condition cal

[gcc(refs/users/meissner/heads/work198-submit)] PR 99293: Optimize splat of a V2DF/V2DI extract with constant element

2025-03-28 Thread Michael Meissner via Gcc-cvs
https://gcc.gnu.org/g:66b52eacc5ed1756655d784b8b5673d63a7841b8

commit 66b52eacc5ed1756655d784b8b5673d63a7841b8
Author: Michael Meissner 
Date:   Fri Mar 28 13:26:34 2025 -0400

PR 99293: Optimize splat of a V2DF/V2DI extract with constant element

We had optimizations for splat of a vector extract for the other vector
types, but we missed having one for V2DI and V2DF.  This patch adds a
combiner insn to do this optimization.

In looking at the source, we had similar optimizations for V4SI and V4SF
extract and splats, but we missed doing V2DI/V2DF.

Without the patch for the code:

vector long long splat_dup_l_0 (vector long long v)
{
  return __builtin_vec_splats (__builtin_vec_extract (v, 0));
}

the compiler generates (on a little endian power9):

splat_dup_l_0:
mfvsrld 9,34
mtvsrdd 34,9,9
blr

Now it generates:

splat_dup_l_0:
xxpermdi 34,34,34,3
blr

2025-03-28  Michael Meissner  

gcc/

PR target/99293
* config/rs6000/vsx.md (vsx_splat_extract_): New insn.

gcc/testsuite/

PR target/99293
* gcc.target/powerpc/builtins-1.c: Adjust insn count.
* gcc.target/powerpc/pr99293.c: New test.

Diff:
---
 gcc/config/rs6000/vsx.md  | 18 ++
 gcc/testsuite/gcc.target/powerpc/builtins-1.c |  2 +-
 gcc/testsuite/gcc.target/powerpc/pr99293.c| 22 ++
 3 files changed, 41 insertions(+), 1 deletion(-)

diff --git a/gcc/config/rs6000/vsx.md b/gcc/config/rs6000/vsx.md
index dd3573b80868..d84a2a357a31 100644
--- a/gcc/config/rs6000/vsx.md
+++ b/gcc/config/rs6000/vsx.md
@@ -4798,6 +4798,24 @@
   "lxvdsx %x0,%y1"
   [(set_attr "type" "vecload")])
 
+;; Optimize SPLAT of an extract from a V2DF/V2DI vector with a constant element
+(define_insn "*vsx_splat_extract_"
+  [(set (match_operand:VSX_D 0 "vsx_register_operand" "=wa")
+   (vec_duplicate:VSX_D
+(vec_select:
+ (match_operand:VSX_D 1 "vsx_register_operand" "wa")
+ (parallel [(match_operand 2 "const_0_to_1_operand" "n")]]
+  "VECTOR_MEM_VSX_P (mode)"
+{
+  int which_word = INTVAL (operands[2]);
+  if (!BYTES_BIG_ENDIAN)
+which_word = 1 - which_word;
+
+  operands[3] = GEN_INT (which_word ? 3 : 0);
+  return "xxpermdi %x0,%x1,%x1,%3";
+}
+  [(set_attr "type" "vecperm")])
+
 ;; V4SI splat support
 (define_insn "vsx_splat_v4si"
   [(set (match_operand:V4SI 0 "vsx_register_operand" "=wa,wa")
diff --git a/gcc/testsuite/gcc.target/powerpc/builtins-1.c 
b/gcc/testsuite/gcc.target/powerpc/builtins-1.c
index 8410a5fd4319..4e7e5384675f 100644
--- a/gcc/testsuite/gcc.target/powerpc/builtins-1.c
+++ b/gcc/testsuite/gcc.target/powerpc/builtins-1.c
@@ -1035,4 +1035,4 @@ foo156 (vector unsigned short usa)
 /* { dg-final { scan-assembler-times {\mvmrglb\M} 3 } } */
 /* { dg-final { scan-assembler-times {\mvmrgew\M} 4 } } */
 /* { dg-final { scan-assembler-times {\mvsplth|xxsplth\M} 4 } } */
-/* { dg-final { scan-assembler-times {\mxxpermdi\M} 44 } } */
+/* { dg-final { scan-assembler-times {\mxxpermdi\M} 42 } } */
diff --git a/gcc/testsuite/gcc.target/powerpc/pr99293.c 
b/gcc/testsuite/gcc.target/powerpc/pr99293.c
new file mode 100644
index ..20adc1f27f65
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/pr99293.c
@@ -0,0 +1,22 @@
+/* { dg-do compile { target powerpc*-*-* } } */
+/* { dg-require-effective-target powerpc_vsx_ok } */
+/* { dg-options "-O2 -mvsx" } */
+
+/* Test for PR 99263, which wants to do:
+   __builtin_vec_splats (__builtin_vec_extract (v, n))
+
+   where v is a V2DF or V2DI vector and n is either 0 or 1.  Previously the
+   compiler would do a direct move to the GPR registers to select the item and 
a
+   direct move from the GPR registers to do the splat.  */
+
+vector long long splat_dup_l_0 (vector long long v)
+{
+  return __builtin_vec_splats (__builtin_vec_extract (v, 0));
+}
+
+vector long long splat_dup_l_1 (vector long long v)
+{
+  return __builtin_vec_splats (__builtin_vec_extract (v, 1));
+}
+
+/* { dg-final { scan-assembler-times "xxpermdi" 2 } } */


[gcc(refs/users/meissner/heads/work198-submit)] PR target/108958 -- use mtvsrdd to zero extend GPR DImode to VSX TImode

2025-03-28 Thread Michael Meissner via Gcc-cvs
https://gcc.gnu.org/g:4b1e708e5b585b756722b4960af88867e44bdd1c

commit 4b1e708e5b585b756722b4960af88867e44bdd1c
Author: Michael Meissner 
Date:   Fri Mar 28 13:25:35 2025 -0400

PR target/108958 -- use mtvsrdd to zero extend GPR DImode to VSX TImode

Previously GCC would zero externd a DImode GPR value to TImode by first zero
extending the DImode value into a GPR TImode value, and then do a MTVSRDD to
move this value to a VSX register.

This patch does the move directly, since if the middle argument to MTVSRDD 
is 0,
it does the zero extend.

If the DImode value is already in a vector register, it does a XXSPLTIB and
XXPERMDI to get the value into the bottom 64-bits of the register.

I have built GCC with the patches in this patch set applied on both little 
and
big endian PowerPC systems and there were no regressions.  Can I apply this
patch to GCC 15?

2025-03-28  Michael Meissner  

gcc/

PR target/108598
* gcc/config/rs6000/rs6000.md (zero_extendditi2): New insn.

gcc/testsuite/

PR target/108598
* gcc.target/powerpc/pr108958.c: New test.

Diff:
---
 gcc/config/rs6000/rs6000.md | 46 +
 gcc/testsuite/gcc.target/powerpc/pr108958.c | 27 +
 2 files changed, 73 insertions(+)

diff --git a/gcc/config/rs6000/rs6000.md b/gcc/config/rs6000/rs6000.md
index e8f1a5ec375b..7fd1db596578 100644
--- a/gcc/config/rs6000/rs6000.md
+++ b/gcc/config/rs6000/rs6000.md
@@ -1026,6 +1026,52 @@
(set_attr "dot" "yes")
(set_attr "length" "4,8")])
 
+(define_insn_and_split "zero_extendditi2"
+  [(set (match_operand:TI 0 "gpc_reg_operand" "=r,wa,&wa")
+   (zero_extend:TI
+(match_operand:DI 1 "gpc_reg_operand" "rwa,r,wa")))]
+  "TARGET_P9_VECTOR && TARGET_POWERPC64"
+  "@
+  #
+  mtvsrdd %x0,0,%1
+  #"
+  "&& reload_completed
+   && (int_reg_operand (operands[0], TImode)
+   || vsx_register_operand (operands[1], DImode))"
+  [(set (match_dup 2)
+   (match_dup 3))
+   (set (match_dup 4)
+   (match_dup 5))]
+{
+  rtx op0 = operands[0];
+  rtx op1 = operands[1];
+  int r = reg_or_subregno (op0);
+
+  if (int_reg_operand (op0, TImode))
+{
+  int lo = BYTES_BIG_ENDIAN ? 1 : 0;
+  int hi = 1 - lo;
+
+  operands[2] = gen_rtx_REG (DImode, r + lo);
+  operands[3] = op1;
+  operands[4] = gen_rtx_REG (DImode, r + hi);
+  operands[5] = const0_rtx;
+}
+  else
+{
+  rtx op0_di = gen_rtx_REG (DImode, r);
+  rtx op0_v2di = gen_rtx_REG (V2DImode, r);
+  rtx lo = WORDS_BIG_ENDIAN ? op1 : op0_di;
+  rtx hi = WORDS_BIG_ENDIAN ? op0_di : op1;
+
+  operands[2] = op0_v2di;
+  operands[3] = CONST0_RTX (V2DImode);
+  operands[4] = op0_v2di;
+  operands[5] = gen_rtx_VEC_CONCAT (V2DImode, hi, lo);
+}
+}
+  [(set_attr "type" "*,mtvsr,vecperm")
+   (set_attr "length" "8,*,8")])
 
 (define_insn "extendqi2"
   [(set (match_operand:EXTQI 0 "gpc_reg_operand" "=r,?*v")
diff --git a/gcc/testsuite/gcc.target/powerpc/pr108958.c 
b/gcc/testsuite/gcc.target/powerpc/pr108958.c
new file mode 100644
index ..03eb58d069e7
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/pr108958.c
@@ -0,0 +1,27 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target int128 } */
+/* { dg-require-effective-target lp64 } */
+/* { dg-options "-mdejagnu-cpu=power9 -O2" } */
+
+/* PR target/108958, use mtvsrdd to zero extend gpr to vsx register.  */
+
+void
+gpr_to_vsx (unsigned long long x, __uint128_t *p)
+{
+  /* mtvsrdd vsx,0,gpr.  */
+  __uint128_t y = x;
+  __asm__ (" # %x0" : "+wa" (y));
+  *p = y;
+}
+
+void
+gpr_to_gpr (unsigned long long x, __uint128_t *p)
+{
+  /* mr and li.  */
+  __uint128_t y = x;
+  __asm__ (" # %0" : "+r" (y));
+  *p = y;
+}
+
+/* { dg-final { scan-assembler-times {\mli\M}  1 } } */
+/* { dg-final { scan-assembler-times {\mmtvsrdd .*,0,.*\M} 1 } } */


[gcc r15-9014] PR modula2/118045: libm2iso.so.20.0.0 contains an unresolvable reference to symbol casin

2025-03-28 Thread Gaius Mulley via Gcc-cvs
https://gcc.gnu.org/g:7e7ac815d2051308ccb7a7469f7e7a1f0b69f7e5

commit r15-9014-g7e7ac815d2051308ccb7a7469f7e7a1f0b69f7e5
Author: Gaius Mulley 
Date:   Fri Mar 28 17:47:05 2025 +

PR modula2/118045: libm2iso.so.20.0.0 contains an unresolvable reference to 
symbol casin

This patch adds -lm to the libm2iso, libm2log and libm2pim libraries.

libgm2/ChangeLog:

PR modula2/118045
* libm2iso/Makefile.am (libm2iso_la_LINK): Add -lm.
* libm2log/Makefile.am (libm2log_la_LINK): Ditto.
* libm2pim/Makefile.am (libm2pim_la_LINK): Ditto.
* libm2iso/Makefile.in: Regenerate.
* libm2log/Makefile.in: Regenerate.
* libm2pim/Makefile.in: Regenerate.

Signed-off-by: Gaius Mulley 

Diff:
---
 libgm2/libm2iso/Makefile.am | 2 +-
 libgm2/libm2iso/Makefile.in | 2 +-
 libgm2/libm2log/Makefile.am | 2 +-
 libgm2/libm2log/Makefile.in | 2 +-
 libgm2/libm2pim/Makefile.am | 2 +-
 libgm2/libm2pim/Makefile.in | 2 +-
 6 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/libgm2/libm2iso/Makefile.am b/libgm2/libm2iso/Makefile.am
index ee9afde85168..12ea38f43a84 100644
--- a/libgm2/libm2iso/Makefile.am
+++ b/libgm2/libm2iso/Makefile.am
@@ -215,7 +215,7 @@ if ENABLE_DARWIN_AT_RPATH
 libm2iso_la_link_flags += -nodefaultrpaths -Wl,-rpath,@loader_path/
 endif
 
-libm2iso_la_LINK = $(LINK) -version-info $(libtool_VERSION) 
$(libm2iso_la_link_flags)
+libm2iso_la_LINK = $(LINK) -version-info $(libtool_VERSION) 
$(libm2iso_la_link_flags) -lm
 CLEANFILES = SYSTEM.def
 BUILT_SOURCES = SYSTEM.def
 
diff --git a/libgm2/libm2iso/Makefile.in b/libgm2/libm2iso/Makefile.in
index 370837f15b82..628d94240149 100644
--- a/libgm2/libm2iso/Makefile.in
+++ b/libgm2/libm2iso/Makefile.in
@@ -597,7 +597,7 @@ FLAGS_TO_PASS = $(AM_MAKEFLAGS)
 @BUILD_ISOLIB_TRUE@@TARGET_DARWIN_FALSE@   $(am__append_1)
 @BUILD_ISOLIB_TRUE@@TARGET_DARWIN_TRUE@libm2iso_la_link_flags = 
-Wl,-undefined,dynamic_lookup \
 @BUILD_ISOLIB_TRUE@@TARGET_DARWIN_TRUE@$(am__append_1)
-@BUILD_ISOLIB_TRUE@libm2iso_la_LINK = $(LINK) -version-info $(libtool_VERSION) 
$(libm2iso_la_link_flags)
+@BUILD_ISOLIB_TRUE@libm2iso_la_LINK = $(LINK) -version-info $(libtool_VERSION) 
$(libm2iso_la_link_flags) -lm
 @BUILD_ISOLIB_TRUE@CLEANFILES = SYSTEM.def
 @BUILD_ISOLIB_TRUE@BUILT_SOURCES = SYSTEM.def
 @BUILD_ISOLIB_TRUE@M2LIBDIR = /m2/m2iso/
diff --git a/libgm2/libm2log/Makefile.am b/libgm2/libm2log/Makefile.am
index ac690c89d2e0..8da0d1489e4a 100644
--- a/libgm2/libm2log/Makefile.am
+++ b/libgm2/libm2log/Makefile.am
@@ -147,7 +147,7 @@ endif
 if ENABLE_DARWIN_AT_RPATH
 libm2log_la_link_flags += -nodefaultrpaths -Wl,-rpath,@loader_path/
 endif
-libm2log_la_LINK = $(LINK) -version-info $(libtool_VERSION) 
$(libm2log_la_link_flags)
+libm2log_la_LINK = $(LINK) -version-info $(libtool_VERSION) 
$(libm2log_la_link_flags) -lm
 BUILT_SOURCES = ../libm2pim/SYSTEM.def
 
 M2LIBDIR = /m2/m2log/
diff --git a/libgm2/libm2log/Makefile.in b/libgm2/libm2log/Makefile.in
index 45260a667e4f..6df3f16f8fe8 100644
--- a/libgm2/libm2log/Makefile.in
+++ b/libgm2/libm2log/Makefile.in
@@ -492,7 +492,7 @@ FLAGS_TO_PASS = $(AM_MAKEFLAGS)
 @BUILD_LOGLIB_TRUE@@TARGET_DARWIN_FALSE@   $(am__append_1)
 @BUILD_LOGLIB_TRUE@@TARGET_DARWIN_TRUE@libm2log_la_link_flags = 
-Wl,-undefined,dynamic_lookup \
 @BUILD_LOGLIB_TRUE@@TARGET_DARWIN_TRUE@$(am__append_1)
-@BUILD_LOGLIB_TRUE@libm2log_la_LINK = $(LINK) -version-info $(libtool_VERSION) 
$(libm2log_la_link_flags)
+@BUILD_LOGLIB_TRUE@libm2log_la_LINK = $(LINK) -version-info $(libtool_VERSION) 
$(libm2log_la_link_flags) -lm
 @BUILD_LOGLIB_TRUE@BUILT_SOURCES = ../libm2pim/SYSTEM.def
 @BUILD_LOGLIB_TRUE@M2LIBDIR = /m2/m2log/
 all: $(BUILT_SOURCES)
diff --git a/libgm2/libm2pim/Makefile.am b/libgm2/libm2pim/Makefile.am
index b575cabe2db4..2252f28d6e2f 100644
--- a/libgm2/libm2pim/Makefile.am
+++ b/libgm2/libm2pim/Makefile.am
@@ -183,7 +183,7 @@ endif
 if ENABLE_DARWIN_AT_RPATH
 libm2pim_la_link_flags += -nodefaultrpaths -Wl,-rpath,@loader_path/
 endif
-libm2pim_la_LINK = $(LINK) -version-info $(libtool_VERSION) 
$(libm2pim_la_link_flags)
+libm2pim_la_LINK = $(LINK) -version-info $(libtool_VERSION) 
$(libm2pim_la_link_flags) -lm
 BUILT_SOURCES = SYSTEM.def
 CLEANFILES = SYSTEM.def
 
diff --git a/libgm2/libm2pim/Makefile.in b/libgm2/libm2pim/Makefile.in
index 67a882e65e7e..f4313e934698 100644
--- a/libgm2/libm2pim/Makefile.in
+++ b/libgm2/libm2pim/Makefile.in
@@ -556,7 +556,7 @@ FLAGS_TO_PASS = $(AM_MAKEFLAGS)
 @BUILD_PIMLIB_TRUE@@TARGET_DARWIN_FALSE@   $(am__append_1)
 @BUILD_PIMLIB_TRUE@@TARGET_DARWIN_TRUE@libm2pim_la_link_flags = 
-Wl,-undefined,dynamic_lookup \
 @BUILD_PIMLIB_TRUE@@TARGET_DARWIN_TRUE@$(am__append_1)
-@BUILD_PIMLIB_TRUE@libm2pim_la_LINK = $(LINK) -version-info $(libtool_VERSION) 
$(libm2pim_la_link_flags)
+@BUILD_PIMLIB_TRUE@libm2pim_la_LINK = $(LINK) -version-info $(libtool_VERSION) 
$(libm2pim_la_link_flags) -lm
 @BUILD_PIMLIB_T