[gcc r15-6864] MAINTAINERS: Make contrib/check-MAINTAINERS.py happy

2025-01-13 Thread Martin Jambor via Gcc-cvs
https://gcc.gnu.org/g:539fc490690d825ab2d299a0f577c5e9d3fa33d0

commit r15-6864-g539fc490690d825ab2d299a0f577c5e9d3fa33d0
Author: Martin Jambor 
Date:   Mon Jan 13 13:47:27 2025 +0100

MAINTAINERS: Make contrib/check-MAINTAINERS.py happy

This commit makes the contrib/check-MAINTAINERS.py script happy about
our MAINTAINERS file.  I hope that it knows best how things ought to
be and so am committing this as obvious.

ChangeLog:

2025-01-13  Martin Jambor  

* MAINTAINERS: Fix the name order of the Write After Approval 
section.

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

diff --git a/MAINTAINERS b/MAINTAINERS
index 0c571bde8bce..256a03957d59 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -327,12 +327,12 @@ from other maintainers or reviewers.
 
 NameBZ account  Email
 
+Soumya AR   soumyaa 
 Mark G. Adams   mgadams 
 Ajit Kumar Agarwal  aagarwa 
 Pedro Alves palves  
 John David Anglin   danglin 
 Harald Anlauf   anlauf  
-Soumya AR   soumyaa 
 Paul-Antoine Arras  parras  
 Arsen Arsenović arsen   
 Raksit Ashokraksit  


[gcc r15-6865] expr: Fix up the divmod cost debugging note [PR115910]

2025-01-13 Thread Jakub Jelinek via Gcc-cvs
https://gcc.gnu.org/g:41a5a97dba6873d928675fd789a2d884c6d20a8d

commit r15-6865-g41a5a97dba6873d928675fd789a2d884c6d20a8d
Author: Jakub Jelinek 
Date:   Mon Jan 13 13:57:18 2025 +0100

expr: Fix up the divmod cost debugging note [PR115910]

Something I've noticed during working on the crc wrong-code fix.
My first version of the patch failed because of no longer matching some
expected strings in the assembly, so I had to add TDF_DETAILS debugging
into the -fdump-rtl-expand-details dump which the crc tests can use.

For PR115910 Andrew has added similar note for the division/modulo case
if it is positive and we can choose either unsigned or signed
division.  The problem is that unlike most other TDF_DETAILS diagnostics,
this is not done before emitting the IL for the function, but during it.

Other messages there are prefixed with ;;, both details on what it is doing
and the GIMPLE IL for which it expands RTL, so the
;; Generating RTL for gimple basic block 4

;;

(code_label 13 12 14 2 (nil) [0 uses])

(note 14 13 0 NOTE_INSN_BASIC_BLOCK)
positive division: unsigned cost: 30; signed cost: 28

;; return _4;

message in between just looks weird and IMHO should be ;; prefixed.

2025-01-13  Jakub Jelinek  

PR target/115910
* expr.cc (expand_expr_divmod): Prefix the TDF_DETAILS note with
";; " and add a space before (needed tie breaker).  Formatting 
fixes.

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

diff --git a/gcc/expr.cc b/gcc/expr.cc
index 07fc85712e6b..a310b2d91315 100644
--- a/gcc/expr.cc
+++ b/gcc/expr.cc
@@ -9710,9 +9710,9 @@ expand_expr_divmod (tree_code code, machine_mode mode, 
tree treeop0,
}
 
   if (dump_file && (dump_flags & TDF_DETAILS))
- fprintf(dump_file, "positive division:%s unsigned cost: %u; "
- "signed cost: %u\n", was_tie ? "(needed tie breaker)" : "",
- uns_cost, sgn_cost);
+   fprintf (dump_file, ";; positive division:%s unsigned cost: %u; "
+   "signed cost: %u\n",
+was_tie ? " (needed tie breaker)" : "", uns_cost, sgn_cost);
 
   if (uns_cost < sgn_cost || (uns_cost == sgn_cost && unsignedp))
{


[gcc r15-6869] Add missing target directive in OpenMP dispatch Fortran runtime test

2025-01-13 Thread Paul-Antoine Arras via Gcc-cvs
https://gcc.gnu.org/g:655a8a024dd49ddf73e745f3c7486596d68ae3e8

commit r15-6869-g655a8a024dd49ddf73e745f3c7486596d68ae3e8
Author: Paul-Antoine Arras 
Date:   Mon Jan 13 12:57:15 2025 +0100

Add missing target directive in OpenMP dispatch Fortran runtime test

Without the target directive, the test would run on the host but still try 
to
use device pointers, which causes a segfault.

libgomp/ChangeLog:

* testsuite/libgomp.fortran/dispatch-1.f90: Add missing target
directive.

Diff:
---
 libgomp/testsuite/libgomp.fortran/dispatch-1.f90 | 21 +
 1 file changed, 13 insertions(+), 8 deletions(-)

diff --git a/libgomp/testsuite/libgomp.fortran/dispatch-1.f90 
b/libgomp/testsuite/libgomp.fortran/dispatch-1.f90
index 7b2f03f9d687..f56477e49722 100644
--- a/libgomp/testsuite/libgomp.fortran/dispatch-1.f90
+++ b/libgomp/testsuite/libgomp.fortran/dispatch-1.f90
@@ -48,16 +48,21 @@ module procedures
 integer :: res, n, i
 type(c_ptr) :: d_bv
 type(c_ptr) :: d_av
-real(8), pointer :: fp_bv(:), fp_av(:)  ! Fortran pointers for array access
 
-! Associate C pointers with Fortran pointers
-call c_f_pointer(d_bv, fp_bv, [n])
-call c_f_pointer(d_av, fp_av, [n])
+!$omp target is_device_ptr(d_bv, d_av)
+block
+  real(8), pointer :: fp_bv(:), fp_av(:)  ! Fortran pointers for array 
access
+
+  ! Associate C pointers with Fortran pointers
+  call c_f_pointer(d_bv, fp_bv, [n])
+  call c_f_pointer(d_av, fp_av, [n])
+
+  ! Perform operations on target
+  do i = 1, n
+fp_bv(i) = fp_av(i) * i
+  end do
+end block
 
-! Perform operations on target
-do i = 1, n
-  fp_bv(i) = fp_av(i) * i
-end do
 res = -2
   end function bar


[gcc r15-6885] c++: Add support for vec_dup to constexpr [PR118445]

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

commit r15-6885-gf7b7fe16579ac13d7fd48e7f9a6082778a0a99f7
Author: Andrew Pinski 
Date:   Mon Jan 13 10:14:45 2025 -0800

c++: Add support for vec_dup to constexpr [PR118445]

With the addition of supporting operations on the SVE scalable vector types,
the vec_duplicate tree will show up in expressions and the constexpr 
handling
was not done for this tree code.
This is a simple fix to treat VEC_DUPLICATE like any other unary operator 
and allows
the constexpr-add-1.C testcase to work.

Built and tested for aarch64-linux-gnu.

PR c++/118445

gcc/cp/ChangeLog:

* constexpr.cc (cxx_eval_constant_expression): Handle VEC_DUPLICATE 
like
a "normal" unary operator.
(potential_constant_expression_1): Likewise.

gcc/testsuite/ChangeLog:

* g++.target/aarch64/sve/constexpr-add-1.C: New test.

Signed-off-by: Andrew Pinski 

Diff:
---
 gcc/cp/constexpr.cc|  2 ++
 gcc/testsuite/g++.target/aarch64/sve/constexpr-add-1.C | 16 
 2 files changed, 18 insertions(+)

diff --git a/gcc/cp/constexpr.cc b/gcc/cp/constexpr.cc
index 1345bc124efb..0896576fd28e 100644
--- a/gcc/cp/constexpr.cc
+++ b/gcc/cp/constexpr.cc
@@ -8005,6 +8005,7 @@ cxx_eval_constant_expression (const constexpr_ctx *ctx, 
tree t,
 case BIT_NOT_EXPR:
 case TRUTH_NOT_EXPR:
 case FIXED_CONVERT_EXPR:
+case VEC_DUPLICATE_EXPR:
   r = cxx_eval_unary_expression (ctx, t, lval,
 non_constant_p, overflow_p);
   break;
@@ -10344,6 +10345,7 @@ potential_constant_expression_1 (tree t, bool 
want_rval, bool strict, bool now,
 case UNARY_PLUS_EXPR:
 case UNARY_LEFT_FOLD_EXPR:
 case UNARY_RIGHT_FOLD_EXPR:
+case VEC_DUPLICATE_EXPR:
 unary:
   return RECUR (TREE_OPERAND (t, 0), rval);
 
diff --git a/gcc/testsuite/g++.target/aarch64/sve/constexpr-add-1.C 
b/gcc/testsuite/g++.target/aarch64/sve/constexpr-add-1.C
new file mode 100644
index ..43489560c8a8
--- /dev/null
+++ b/gcc/testsuite/g++.target/aarch64/sve/constexpr-add-1.C
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+
+/* PR C++/118445 */
+
+#include 
+
+/* See if constexpr handles VEC_DUPLICATE and SVE. */
+constexpr svfloat32_t f(svfloat32_t b, float a)
+{
+  return b + a;
+}
+
+svfloat32_t g(void)
+{
+  return f((svfloat32_t){1.0}, 2.0);
+}


[gcc r15-6886] c: improve UX for -Wincompatible-pointer-types (v3) [PR116871]

2025-01-13 Thread David Malcolm via Gcc-cvs
https://gcc.gnu.org/g:bbc7900ce7e2c3d906286674f80789f057e86c0a

commit r15-6886-gbbc7900ce7e2c3d906286674f80789f057e86c0a
Author: David Malcolm 
Date:   Mon Jan 13 19:47:25 2025 -0500

c: improve UX for -Wincompatible-pointer-types (v3) [PR116871]

PR c/116871 notes that our diagnostics about incompatible function types
could be improved.

In particular, for the case of migrating to C23 I'm seeing a lot of
build failures with signal handlers similar to this (simplified from
alsa-tools-1.2.11, envy24control/profiles.c; see rhbz#2336278):

typedef void (*__sighandler_t) (int);

extern __sighandler_t signal (int __sig, __sighandler_t __handler)
 __attribute__ ((__nothrow__ , __leaf__));

void new_process(void)
{
  void (*int_stat)();

  int_stat = signal(2,  ((__sighandler_t) 1));

  signal(2, int_stat);
}

Before this patch, cc1 fails with this message:

t.c: In function 'new_process':
t.c:18:12: error: assignment to 'void (*)(void)' from incompatible pointer 
type '__sighandler_t' {aka 'void (*)(int)'} [-Wincompatible-pointer-types]
   18 |   int_stat = signal(2,  ((__sighandler_t) 1));
  |^
t.c:20:13: error: passing argument 2 of 'signal' from incompatible pointer 
type [-Wincompatible-pointer-types]
   20 |   signal(2, int_stat);
  | ^~~~
  | |
  | void (*)(void)
t.c:11:57: note: expected '__sighandler_t' {aka 'void (*)(int)'} but 
argument is of type 'void (*)(void)'
   11 | extern __sighandler_t signal (int __sig, __sighandler_t __handler)
  |  ~~~^

With this patch, cc1 emits:

t.c: In function 'new_process':
t.c:18:12: error: assignment to 'void (*)(void)' from incompatible pointer 
type '__sighandler_t' {aka 'void (*)(int)'} [-Wincompatible-pointer-types]
   18 |   int_stat = signal(2,  ((__sighandler_t) 1));
  |^
t.c:9:16: note: '__sighandler_t' declared here
9 | typedef void (*__sighandler_t) (int);
  |^~
t.c:20:13: error: passing argument 2 of 'signal' from incompatible pointer 
type [-Wincompatible-pointer-types]
   20 |   signal(2, int_stat);
  | ^~~~
  | |
  | void (*)(void)
t.c:11:57: note: expected '__sighandler_t' {aka 'void (*)(int)'} but 
argument is of type 'void (*)(void)'
   11 | extern __sighandler_t signal (int __sig, __sighandler_t __handler)
  |  ~~~^
t.c:9:16: note: '__sighandler_t' declared here
9 | typedef void (*__sighandler_t) (int);
  |^~

showing the location of the pertinent typedef ("__sighandler_t")

Another example, simplfied from a52dec-0.7.4: src/a52dec.c
(rhbz#2336013):

typedef void (*__sighandler_t) (int);

extern __sighandler_t signal (int __sig, __sighandler_t __handler)
 __attribute__ ((__nothrow__ , __leaf__));

/* Mismatching return type.  */
static RETSIGTYPE signal_handler (int sig)
{
}

static void print_fps (int final)
{
  signal (42, signal_handler);
}

Before this patch, cc1 emits:

t2.c: In function 'print_fps':
t2.c:22:15: error: passing argument 2 of 'signal' from incompatible pointer 
type [-Wincompatible-pointer-types]
   22 |   signal (42, signal_handler);
  |   ^~
  |   |
  |   int (*)(int)
t2.c:11:57: note: expected '__sighandler_t' {aka 'void (*)(int)'} but 
argument is of type 'int (*)(int)'
   11 | extern __sighandler_t signal (int __sig, __sighandler_t __handler)
  |  ~~~^

With this patch cc1 emits:

t2.c: In function 'print_fps':
t2.c:22:15: error: passing argument 2 of 'signal' from incompatible pointer 
type [-Wincompatible-pointer-types]
   22 |   signal (42, signal_handler);
  |   ^~
  |   |
  |   int (*)(int)
t2.c:11:57: note: expected '__sighandler_t' {aka 'void (*)(int)'} but 
argument is of type 'int (*)(int)'
   11 | extern __sighandler_t signal (int __sig, __sighandler_t __handler)
  |  ~~~^
t2.c:16:19: note: 'signal_handler' declared here
   16 | static RETSIGTYPE signal_handler (int sig)
  |   ^~
t2.c:9:16: note: '__sighandler_t' declared here
9 | typedef void (*__sighandler_t) (int);
  |^~

showing the location of the pertinent fndecl ("signal_handler

[gcc(refs/users/aoliva/heads/testme)] [ifcombine] robustify decode_field_reference

2025-01-13 Thread Alexandre Oliva via Gcc-cvs
https://gcc.gnu.org/g:c8f631560b4d4d8dbfd0eddf3e9157f6ebebf1ca

commit c8f631560b4d4d8dbfd0eddf3e9157f6ebebf1ca
Author: Alexandre Oliva 
Date:   Mon Jan 13 22:15:17 2025 -0300

[ifcombine] robustify decode_field_reference

Arrange for decode_field_reference to use local variables throughout,
to modify the out parms only when we're about to return non-NULL, and
to drop the unused case of NULL pand_mask, that had a latent failure
to detect signbit masking.


for  gcc/ChangeLog

* gimple-fold.cc (decode_field_reference): Rebustify to set
out parms only when returning non-NULL.
(fold_truth_andor_for_ifcombine): Add complementary assert on
r_const's not being set when l_const isn't.

Diff:
---
 gcc/gimple-fold.cc | 136 -
 1 file changed, 71 insertions(+), 65 deletions(-)

diff --git a/gcc/gimple-fold.cc b/gcc/gimple-fold.cc
index 5b1fbe6db1df..497b2ecb8363 100644
--- a/gcc/gimple-fold.cc
+++ b/gcc/gimple-fold.cc
@@ -7510,18 +7510,17 @@ gimple_binop_def_p (enum tree_code code, tree t, tree 
op[2])
*PREVERSEP is set to the storage order of the field.
 
*PAND_MASK is set to the mask found in a BIT_AND_EXPR, if any.  If
-   PAND_MASK *is NULL, BIT_AND_EXPR is not recognized.  If *PAND_MASK
-   is initially set to a mask with nonzero precision, that mask is
+   *PAND_MASK is initially set to a mask with nonzero precision, that mask is
combined with the found mask, or adjusted in precision to match.
 
*PSIGNBIT is set to TRUE if, before clipping to *PBITSIZE, the mask
encompassed bits that corresponded to extensions of the sign bit.
 
-   *XOR_P is to be FALSE if EXP might be a XOR used in a compare, in which
-   case, if XOR_CMP_OP is a zero constant, it will be overridden with *PEXP,
-   *XOR_P will be set to TRUE, *XOR_PAND_MASK will be copied from *PAND_MASK,
-   and the left-hand operand of the XOR will be decoded.  If *XOR_P is TRUE,
-   XOR_CMP_OP and XOR_PAND_MASK are supposed to be NULL, and then the
+   *PXORP is to be FALSE if EXP might be a XOR used in a compare, in which
+   case, if PXOR_CMP_OP is a zero constant, it will be overridden with *PEXP,
+   *PXORP will be set to TRUE, *PXOR_AND_MASK will be copied from *PAND_MASK,
+   and the left-hand operand of the XOR will be decoded.  If *PXORP is TRUE,
+   PXOR_CMP_OP and PXOR_AND_MASK are supposed to be NULL, and then the
right-hand operand of the XOR will be decoded.
 
*LOAD is set to the load stmt of the innermost reference, if any,
@@ -7538,8 +7537,8 @@ decode_field_reference (tree *pexp, HOST_WIDE_INT 
*pbitsize,
HOST_WIDE_INT *pbitpos,
bool *punsignedp, bool *preversep, bool *pvolatilep,
wide_int *pand_mask, bool *psignbit,
-   bool *xor_p, tree *xor_cmp_op, wide_int *xor_pand_mask,
-   gimple **load, location_t loc[4])
+   bool *pxorp, tree *pxor_cmp_op, wide_int *pxor_and_mask,
+   gimple **pload, location_t loc[4])
 {
   tree exp = *pexp;
   tree outer_type = 0;
@@ -7549,9 +7548,11 @@ decode_field_reference (tree *pexp, HOST_WIDE_INT 
*pbitsize,
   tree res_ops[2];
   machine_mode mode;
   bool convert_before_shift = false;
-
-  *load = NULL;
-  *psignbit = false;
+  bool signbit = false;
+  bool xorp = false;
+  tree xor_op;
+  wide_int xor_mask;
+  gimple *load = NULL;
 
   /* All the optimizations using this function assume integer fields.
  There are problems with FP fields since the type_for_size call
@@ -7576,7 +7577,7 @@ decode_field_reference (tree *pexp, HOST_WIDE_INT 
*pbitsize,
 
   /* Recognize and save a masking operation.  Combine it with an
  incoming mask.  */
-  if (pand_mask && gimple_binop_def_p (BIT_AND_EXPR, exp, res_ops)
+  if (gimple_binop_def_p (BIT_AND_EXPR, exp, res_ops)
   && TREE_CODE (res_ops[1]) == INTEGER_CST)
 {
   loc[1] = gimple_location (SSA_NAME_DEF_STMT (exp));
@@ -7596,29 +7597,29 @@ decode_field_reference (tree *pexp, HOST_WIDE_INT 
*pbitsize,
and_mask &= wide_int::from (*pand_mask, prec_op, UNSIGNED);
}
 }
-  else if (pand_mask)
+  else
 and_mask = *pand_mask;
 
   /* Turn (a ^ b) [!]= 0 into a [!]= b.  */
-  if (xor_p && gimple_binop_def_p (BIT_XOR_EXPR, exp, res_ops))
+  if (xorp && gimple_binop_def_p (BIT_XOR_EXPR, exp, res_ops))
 {
   /* No location recorded for this one, it's entirely subsumed by the
 compare.  */
-  if (*xor_p)
+  if (*xorp)
{
  exp = res_ops[1];
  gcc_checking_assert (!xor_cmp_op && !xor_pand_mask);
}
-  else if (!xor_cmp_op)
+  else if (!*pxor_cmp_op)
/* Not much we can do when xor appears in the right-hand compare
   operand.  */
return NULL_TREE;
-  else if (integer_zerop (*xor_cmp_op))
+  else if (integer_zerop (*pxor_cmp_o

[gcc/aoliva/heads/testme] [ifcombine] robustify decode_field_reference

2025-01-13 Thread Alexandre Oliva via Gcc-cvs
The branch 'aoliva/heads/testme' was updated to point to:

 db645e2ec5b0... [ifcombine] robustify decode_field_reference

It previously pointed to:

 df55a9a2e371... [ifcombine] robustify decode_field_reference

Diff:

!!! WARNING: THE FOLLOWING COMMITS ARE NO LONGER ACCESSIBLE (LOST):
---

  df55a9a... [ifcombine] robustify decode_field_reference


Summary of changes (added commits):
---

  db645e2... [ifcombine] robustify decode_field_reference


[gcc(refs/users/aoliva/heads/testme)] [ifcombine] robustify decode_field_reference

2025-01-13 Thread Alexandre Oliva via Gcc-cvs
https://gcc.gnu.org/g:db645e2ec5b002f44887e09b926e0127d1648b54

commit db645e2ec5b002f44887e09b926e0127d1648b54
Author: Alexandre Oliva 
Date:   Mon Jan 13 22:15:17 2025 -0300

[ifcombine] robustify decode_field_reference

Arrange for decode_field_reference to use local variables throughout,
to modify the out parms only when we're about to return non-NULL, and
to drop the unused case of NULL pand_mask, that had a latent failure
to detect signbit masking.


for  gcc/ChangeLog

* gimple-fold.cc (decode_field_reference): Rebustify to set
out parms only when returning non-NULL.
(fold_truth_andor_for_ifcombine): Bail if
decode_field_reference returns NULL.  Add complementary assert
on r_const's not being set when l_const isn't.

Diff:
---
 gcc/gimple-fold.cc | 155 +++--
 1 file changed, 80 insertions(+), 75 deletions(-)

diff --git a/gcc/gimple-fold.cc b/gcc/gimple-fold.cc
index 5b1fbe6db1df..d566a5f5bc3b 100644
--- a/gcc/gimple-fold.cc
+++ b/gcc/gimple-fold.cc
@@ -7510,18 +7510,17 @@ gimple_binop_def_p (enum tree_code code, tree t, tree 
op[2])
*PREVERSEP is set to the storage order of the field.
 
*PAND_MASK is set to the mask found in a BIT_AND_EXPR, if any.  If
-   PAND_MASK *is NULL, BIT_AND_EXPR is not recognized.  If *PAND_MASK
-   is initially set to a mask with nonzero precision, that mask is
+   *PAND_MASK is initially set to a mask with nonzero precision, that mask is
combined with the found mask, or adjusted in precision to match.
 
*PSIGNBIT is set to TRUE if, before clipping to *PBITSIZE, the mask
encompassed bits that corresponded to extensions of the sign bit.
 
-   *XOR_P is to be FALSE if EXP might be a XOR used in a compare, in which
-   case, if XOR_CMP_OP is a zero constant, it will be overridden with *PEXP,
-   *XOR_P will be set to TRUE, *XOR_PAND_MASK will be copied from *PAND_MASK,
-   and the left-hand operand of the XOR will be decoded.  If *XOR_P is TRUE,
-   XOR_CMP_OP and XOR_PAND_MASK are supposed to be NULL, and then the
+   *PXORP is to be FALSE if EXP might be a XOR used in a compare, in which
+   case, if PXOR_CMP_OP is a zero constant, it will be overridden with *PEXP,
+   *PXORP will be set to TRUE, *PXOR_AND_MASK will be copied from *PAND_MASK,
+   and the left-hand operand of the XOR will be decoded.  If *PXORP is TRUE,
+   PXOR_CMP_OP and PXOR_AND_MASK are supposed to be NULL, and then the
right-hand operand of the XOR will be decoded.
 
*LOAD is set to the load stmt of the innermost reference, if any,
@@ -7538,8 +7537,8 @@ decode_field_reference (tree *pexp, HOST_WIDE_INT 
*pbitsize,
HOST_WIDE_INT *pbitpos,
bool *punsignedp, bool *preversep, bool *pvolatilep,
wide_int *pand_mask, bool *psignbit,
-   bool *xor_p, tree *xor_cmp_op, wide_int *xor_pand_mask,
-   gimple **load, location_t loc[4])
+   bool *pxorp, tree *pxor_cmp_op, wide_int *pxor_and_mask,
+   gimple **pload, location_t loc[4])
 {
   tree exp = *pexp;
   tree outer_type = 0;
@@ -7549,9 +7548,11 @@ decode_field_reference (tree *pexp, HOST_WIDE_INT 
*pbitsize,
   tree res_ops[2];
   machine_mode mode;
   bool convert_before_shift = false;
-
-  *load = NULL;
-  *psignbit = false;
+  bool signbit = false;
+  bool xorp = false;
+  tree xor_cmp_op;
+  wide_int xor_and_mask;
+  gimple *load = NULL;
 
   /* All the optimizations using this function assume integer fields.
  There are problems with FP fields since the type_for_size call
@@ -7576,7 +7577,7 @@ decode_field_reference (tree *pexp, HOST_WIDE_INT 
*pbitsize,
 
   /* Recognize and save a masking operation.  Combine it with an
  incoming mask.  */
-  if (pand_mask && gimple_binop_def_p (BIT_AND_EXPR, exp, res_ops)
+  if (gimple_binop_def_p (BIT_AND_EXPR, exp, res_ops)
   && TREE_CODE (res_ops[1]) == INTEGER_CST)
 {
   loc[1] = gimple_location (SSA_NAME_DEF_STMT (exp));
@@ -7596,29 +7597,29 @@ decode_field_reference (tree *pexp, HOST_WIDE_INT 
*pbitsize,
and_mask &= wide_int::from (*pand_mask, prec_op, UNSIGNED);
}
 }
-  else if (pand_mask)
+  else
 and_mask = *pand_mask;
 
   /* Turn (a ^ b) [!]= 0 into a [!]= b.  */
-  if (xor_p && gimple_binop_def_p (BIT_XOR_EXPR, exp, res_ops))
+  if (xorp && gimple_binop_def_p (BIT_XOR_EXPR, exp, res_ops))
 {
   /* No location recorded for this one, it's entirely subsumed by the
 compare.  */
-  if (*xor_p)
+  if (*pxorp)
{
  exp = res_ops[1];
- gcc_checking_assert (!xor_cmp_op && !xor_pand_mask);
+ gcc_checking_assert (!pxor_cmp_op && !pxor_and_mask);
}
-  else if (!xor_cmp_op)
+  else if (!*pxor_cmp_op)
/* Not much we can do when xor appears in the right-hand compare
  

[gcc(refs/users/aoliva/heads/testme)] [ifcombine] robustify decode_field_reference

2025-01-13 Thread Alexandre Oliva via Gcc-cvs
https://gcc.gnu.org/g:d543ef708e13b3925f1054203351e2f21350978c

commit d543ef708e13b3925f1054203351e2f21350978c
Author: Alexandre Oliva 
Date:   Mon Jan 13 22:15:17 2025 -0300

[ifcombine] robustify decode_field_reference

Arrange for decode_field_reference to use local variables throughout,
to modify the out parms only when we're about to return non-NULL, and
to drop the unused case of NULL pand_mask, that had a latent failure
to detect signbit masking.


for  gcc/ChangeLog

* gimple-fold.cc (decode_field_reference): Rebustify to set
out parms only when returning non-NULL.
(fold_truth_andor_for_ifcombine): Bail if
decode_field_reference returns NULL.  Add complementary assert
on r_const's not being set when l_const isn't.

Diff:
---
 gcc/gimple-fold.cc | 155 +++--
 1 file changed, 80 insertions(+), 75 deletions(-)

diff --git a/gcc/gimple-fold.cc b/gcc/gimple-fold.cc
index 5b1fbe6db1df..7c8c519b6f67 100644
--- a/gcc/gimple-fold.cc
+++ b/gcc/gimple-fold.cc
@@ -7510,18 +7510,17 @@ gimple_binop_def_p (enum tree_code code, tree t, tree 
op[2])
*PREVERSEP is set to the storage order of the field.
 
*PAND_MASK is set to the mask found in a BIT_AND_EXPR, if any.  If
-   PAND_MASK *is NULL, BIT_AND_EXPR is not recognized.  If *PAND_MASK
-   is initially set to a mask with nonzero precision, that mask is
+   *PAND_MASK is initially set to a mask with nonzero precision, that mask is
combined with the found mask, or adjusted in precision to match.
 
*PSIGNBIT is set to TRUE if, before clipping to *PBITSIZE, the mask
encompassed bits that corresponded to extensions of the sign bit.
 
-   *XOR_P is to be FALSE if EXP might be a XOR used in a compare, in which
-   case, if XOR_CMP_OP is a zero constant, it will be overridden with *PEXP,
-   *XOR_P will be set to TRUE, *XOR_PAND_MASK will be copied from *PAND_MASK,
-   and the left-hand operand of the XOR will be decoded.  If *XOR_P is TRUE,
-   XOR_CMP_OP and XOR_PAND_MASK are supposed to be NULL, and then the
+   *PXORP is to be FALSE if EXP might be a XOR used in a compare, in which
+   case, if PXOR_CMP_OP is a zero constant, it will be overridden with *PEXP,
+   *PXORP will be set to TRUE, *PXOR_AND_MASK will be copied from *PAND_MASK,
+   and the left-hand operand of the XOR will be decoded.  If *PXORP is TRUE,
+   PXOR_CMP_OP and PXOR_AND_MASK are supposed to be NULL, and then the
right-hand operand of the XOR will be decoded.
 
*LOAD is set to the load stmt of the innermost reference, if any,
@@ -7538,8 +7537,8 @@ decode_field_reference (tree *pexp, HOST_WIDE_INT 
*pbitsize,
HOST_WIDE_INT *pbitpos,
bool *punsignedp, bool *preversep, bool *pvolatilep,
wide_int *pand_mask, bool *psignbit,
-   bool *xor_p, tree *xor_cmp_op, wide_int *xor_pand_mask,
-   gimple **load, location_t loc[4])
+   bool *pxorp, tree *pxor_cmp_op, wide_int *pxor_and_mask,
+   gimple **pload, location_t loc[4])
 {
   tree exp = *pexp;
   tree outer_type = 0;
@@ -7549,9 +7548,11 @@ decode_field_reference (tree *pexp, HOST_WIDE_INT 
*pbitsize,
   tree res_ops[2];
   machine_mode mode;
   bool convert_before_shift = false;
-
-  *load = NULL;
-  *psignbit = false;
+  bool signbit = false;
+  bool xorp = false;
+  tree xor_cmp_op;
+  wide_int xor_and_mask;
+  gimple *load = NULL;
 
   /* All the optimizations using this function assume integer fields.
  There are problems with FP fields since the type_for_size call
@@ -7576,7 +7577,7 @@ decode_field_reference (tree *pexp, HOST_WIDE_INT 
*pbitsize,
 
   /* Recognize and save a masking operation.  Combine it with an
  incoming mask.  */
-  if (pand_mask && gimple_binop_def_p (BIT_AND_EXPR, exp, res_ops)
+  if (gimple_binop_def_p (BIT_AND_EXPR, exp, res_ops)
   && TREE_CODE (res_ops[1]) == INTEGER_CST)
 {
   loc[1] = gimple_location (SSA_NAME_DEF_STMT (exp));
@@ -7596,29 +7597,29 @@ decode_field_reference (tree *pexp, HOST_WIDE_INT 
*pbitsize,
and_mask &= wide_int::from (*pand_mask, prec_op, UNSIGNED);
}
 }
-  else if (pand_mask)
+  else
 and_mask = *pand_mask;
 
   /* Turn (a ^ b) [!]= 0 into a [!]= b.  */
-  if (xor_p && gimple_binop_def_p (BIT_XOR_EXPR, exp, res_ops))
+  if (xorp && gimple_binop_def_p (BIT_XOR_EXPR, exp, res_ops))
 {
   /* No location recorded for this one, it's entirely subsumed by the
 compare.  */
-  if (*xor_p)
+  if (*pxorp)
{
  exp = res_ops[1];
- gcc_checking_assert (!xor_cmp_op && !xor_pand_mask);
+ gcc_checking_assert (!pxor_cmp_op && !pxor_and_mask);
}
-  else if (!xor_cmp_op)
+  else if (!*pxor_cmp_op)
/* Not much we can do when xor appears in the right-hand compare
  

[gcc/aoliva/heads/testme] [ifcombine] robustify decode_field_reference

2025-01-13 Thread Alexandre Oliva via Gcc-cvs
The branch 'aoliva/heads/testme' was updated to point to:

 d543ef708e13... [ifcombine] robustify decode_field_reference

It previously pointed to:

 db645e2ec5b0... [ifcombine] robustify decode_field_reference

Diff:

!!! WARNING: THE FOLLOWING COMMITS ARE NO LONGER ACCESSIBLE (LOST):
---

  db645e2... [ifcombine] robustify decode_field_reference


Summary of changes (added commits):
---

  d543ef7... [ifcombine] robustify decode_field_reference


[gcc r15-6878] Fix typos in show_attr.

2025-01-13 Thread Thomas Kテカnig via Gcc-cvs
https://gcc.gnu.org/g:51f76cd947aeb5fe9889b6fde5830031e292b30a

commit r15-6878-g51f76cd947aeb5fe9889b6fde5830031e292b30a
Author: Thomas Koenig 
Date:   Mon Jan 13 22:38:20 2025 +0100

Fix typos in show_attr.

gcc/fortran/ChangeLog:

* dump-parse-tree.cc (show_attr): Fix typos for in_equivalence.

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

diff --git a/gcc/fortran/dump-parse-tree.cc b/gcc/fortran/dump-parse-tree.cc
index 97cab3f85f92..cf09e8d5b823 100644
--- a/gcc/fortran/dump-parse-tree.cc
+++ b/gcc/fortran/dump-parse-tree.cc
@@ -871,7 +871,7 @@ show_attr (symbol_attribute *attr, const char * module)
   if (attr->in_common)
 fputs (" IN-COMMON", dumpfile);
   if (attr->in_equivalence)
-fputs (" IN_EQUIVALENDE", dumpfile);
+fputs (" IN-EQUIVALENCE", dumpfile);
 
   if (attr->abstract)
 fputs (" ABSTRACT", dumpfile);


[gcc(refs/users/aoliva/heads/testme)] [ifcombine] set mask to clip sign-extended constant

2025-01-13 Thread Alexandre Oliva via Gcc-cvs
https://gcc.gnu.org/g:6c64cdc8a3ff6508f32c785eb070f08c596dc003

commit 6c64cdc8a3ff6508f32c785eb070f08c596dc003
Author: Alexandre Oliva 
Date:   Mon Jan 13 14:53:25 2025 -0300

[ifcombine] set mask to clip sign-extended constant

Diff:
---
 gcc/gimple-fold.cc| 152 +-
 gcc/testsuite/gcc.dg/field-merge-21.c |  52 
 gcc/testsuite/gcc.dg/field-merge-22.c |  30 +++
 3 files changed, 178 insertions(+), 56 deletions(-)

diff --git a/gcc/gimple-fold.cc b/gcc/gimple-fold.cc
index 93ed8b3abb05..f79faf21a5f7 100644
--- a/gcc/gimple-fold.cc
+++ b/gcc/gimple-fold.cc
@@ -7510,8 +7510,7 @@ gimple_binop_def_p (enum tree_code code, tree t, tree 
op[2])
*PREVERSEP is set to the storage order of the field.
 
*PAND_MASK is set to the mask found in a BIT_AND_EXPR, if any.  If
-   PAND_MASK *is NULL, BIT_AND_EXPR is not recognized.  If *PAND_MASK
-   is initially set to a mask with nonzero precision, that mask is
+   *PAND_MASK is initially set to a mask with nonzero precision, that mask is
combined with the found mask, or adjusted in precision to match.
 
*PSIGNBIT is set to TRUE if, before clipping to *PBITSIZE, the mask
@@ -7539,7 +7538,7 @@ decode_field_reference (tree *pexp, HOST_WIDE_INT 
*pbitsize,
bool *punsignedp, bool *preversep, bool *pvolatilep,
wide_int *pand_mask, bool *psignbit,
bool *xor_p, tree *xor_cmp_op, wide_int *xor_pand_mask,
-   gimple **load, location_t loc[4])
+   gimple **loadp, location_t loc[4])
 {
   tree exp = *pexp;
   tree outer_type = 0;
@@ -7549,9 +7548,11 @@ decode_field_reference (tree *pexp, HOST_WIDE_INT 
*pbitsize,
   tree res_ops[2];
   machine_mode mode;
   bool convert_before_shift = false;
-
-  *load = NULL;
-  *psignbit = false;
+  bool signbit = false;
+  bool xorp = false;
+  tree xor_op;
+  wide_int xor_mask;
+  gimple *load = NULL;
 
   /* All the optimizations using this function assume integer fields.
  There are problems with FP fields since the type_for_size call
@@ -7576,7 +7577,7 @@ decode_field_reference (tree *pexp, HOST_WIDE_INT 
*pbitsize,
 
   /* Recognize and save a masking operation.  Combine it with an
  incoming mask.  */
-  if (pand_mask && gimple_binop_def_p (BIT_AND_EXPR, exp, res_ops)
+  if (gimple_binop_def_p (BIT_AND_EXPR, exp, res_ops)
   && TREE_CODE (res_ops[1]) == INTEGER_CST)
 {
   loc[1] = gimple_location (SSA_NAME_DEF_STMT (exp));
@@ -7596,7 +7597,7 @@ decode_field_reference (tree *pexp, HOST_WIDE_INT 
*pbitsize,
and_mask &= wide_int::from (*pand_mask, prec_op, UNSIGNED);
}
 }
-  else if (pand_mask)
+  else
 and_mask = *pand_mask;
 
   /* Turn (a ^ b) [!]= 0 into a [!]= b.  */
@@ -7615,10 +7616,10 @@ decode_field_reference (tree *pexp, HOST_WIDE_INT 
*pbitsize,
return NULL_TREE;
   else if (integer_zerop (*xor_cmp_op))
{
- *xor_p = true;
+ xorp = true;
  exp = res_ops[0];
- *xor_cmp_op = *pexp;
- *xor_pand_mask = *pand_mask;
+ xor_op = *pexp;
+ xor_mask = *pand_mask;
}
 }
 
@@ -7646,12 +7647,12 @@ decode_field_reference (tree *pexp, HOST_WIDE_INT 
*pbitsize,
   /* Yet another chance to drop conversions.  This one is allowed to
  match a converting load, subsuming the load identification block
  below.  */
-  if (!outer_type && gimple_convert_def_p (exp, res_ops, load))
+  if (!outer_type && gimple_convert_def_p (exp, res_ops, &load))
 {
   outer_type = TREE_TYPE (exp);
   loc[0] = gimple_location (SSA_NAME_DEF_STMT (exp));
-  if (*load)
-   loc[3] = gimple_location (*load);
+  if (load)
+   loc[3] = gimple_location (load);
   exp = res_ops[0];
   /* This looks backwards, but we're going back the def chain, so if we
 find the conversion here, after finding a shift, that's because the
@@ -7662,14 +7663,13 @@ decode_field_reference (tree *pexp, HOST_WIDE_INT 
*pbitsize,
 }
 
   /* Identify the load, if there is one.  */
-  if (!(*load) && TREE_CODE (exp) == SSA_NAME
-  && !SSA_NAME_IS_DEFAULT_DEF (exp))
+  if (!load && TREE_CODE (exp) == SSA_NAME && !SSA_NAME_IS_DEFAULT_DEF (exp))
 {
   gimple *def = SSA_NAME_DEF_STMT (exp);
   if (gimple_assign_load_p (def))
{
  loc[3] = gimple_location (def);
- *load = def;
+ load = def;
  exp = gimple_assign_rhs1 (def);
}
 }
@@ -7694,63 +7694,75 @@ decode_field_reference (tree *pexp, HOST_WIDE_INT 
*pbitsize,
  && !type_has_mode_precision_p (TREE_TYPE (inner
 return NULL_TREE;
 
-  *pbitsize = bs;
-  *pbitpos = bp;
-  *punsignedp = unsignedp;
-  *preversep = reversep;
-  *pvolatilep = volatilep;
-
   /* Adjust shifts...  */
   if (convert_before_shift
-  && outer_type && *pbitsize > TYPE_PRECISION (outer_type))
+  && outer_type && bs > TYPE_PRE

[gcc/aoliva/heads/testme] (91 commits) [ifcombine] set mask to clip sign-extended constant

2025-01-13 Thread Alexandre Oliva via Gcc-cvs
The branch 'aoliva/heads/testme' was updated to point to:

 6c64cdc8a3ff... [ifcombine] set mask to clip sign-extended constant

It previously pointed to:

 7f21e6769701... [ifcombine] propagate signbit mask to XOR right-hand operan

Diff:

!!! WARNING: THE FOLLOWING COMMITS ARE NO LONGER ACCESSIBLE (LOST):
---

  7f21e67... [ifcombine] propagate signbit mask to XOR right-hand operan


Summary of changes (added commits):
---

  6c64cdc... [ifcombine] set mask to clip sign-extended constant
  52e4ede... [ifcombine] propagate signbit mask to XOR right-hand operan (*)
  41a5a97... expr: Fix up the divmod cost debugging note [PR115910] (*)
  539fc49... MAINTAINERS: Make contrib/check-MAINTAINERS.py happy (*)
  0cf06bf... ada: Update gnatdll documentation (-b option removed) (*)
  1a82657... ada: Cleanup preanalysis of static expressions (part 5) (*)
  2e0b086... ada: Fix relocatable DLL creation with gnatdll (*)
  492aae1... ada: Remove redundant parentheses inside unary operators (c (*)
  5fd925b... ada: Cleanup preanalysis of static expressions (part 4) (*)
  686bd4e... ada: Warn about redundant parentheses inside unary operator (*)
  34943af... ada: Remove redundant parentheses inside unary operators in (*)
  94a7543... ada: Remove redundant parentheses inside unary operators (*)
  ef4448e... ada: Fix spurious warning about redundant parentheses in ra (*)
  c6989fb... ada: Unbounded recursion on character aggregates with predi (*)
  f9d22b7... ada: Simplify expansion of negative membership operator (*)
  518fd9e... ada: Warn about redundant parentheses in upper range bounds (*)
  d2e3635... ada: Add more commentary to System.Val_Real.Large_Powfive (*)
  26b649b... ada: Fix parsing of raise expressions with no parens (*)
  d3904a3... tree-optimization/117119 - ICE with int128 IV in dataref an (*)
  c0c47fc... Un-XFAIL 'dg-note's in 'gfortran.dg/goacc/routine-external- (*)
  017c45f... Bump BASE-VER to 14.0.1 now that we are in stage4. (*)
  9100be5... lto: Pass cache checksum by reference [PR118181] (*)
  89ebb88... lto: Fix empty fnctl.h build error with MinGW. (*)
  0e05b79... Refactor ix86_expand_vecop_qihi2. (*)
  9c387a9... [PATCH] crc: Fix up some crc related wrong code issues [PR1 (*)
  422c588... Daily bump. (*)
  a2e540b... d: Merge dmd, druntime c7902293d7, phobos 03aeafd20 (*)
  f4fa0b7... Dump all symbol attributes in show_attr. (*)
  0dd21bc... d: Merge upstream dmd, druntime c57da0cf59, phobos ad8ee558 (*)
  a236f70... c: UX improvements to 'too {few,many} arguments' errors (v5 (*)
  f8eda60... Fortran: implement F2018 intrinsic OUT_OF_RANGE [PR115788] (*)
  ed8cd42... Alpha: Fix a block move pessimisation with zero-extension a (*)
  4e55721... Alpha: Optimize block moves coming from longword-aligned so (*)
  19fdb9f... Alpha: Always respect -mbwx, -mcix, -mfix, -mmax, and their (*)
  3cf0e6a... Alpha: Restore frame pointer last in `builtin_longjmp' [PR6 (*)
  4686116... Alpha: Add memory clobbers to `builtin_longjmp' expansion (*)
  40754a3... Fix union member access for EXEC_INQUIRE. (*)
  bedf26c... More memory leak fixes (*)
  4b29be7... testsuite: The expect framework might introduce CR in outpu (*)
  4b0ef49... testsuite: libstdc++: Use effective-target libatomic (*)
  851e188... c-pretty-print.cc (pp_c_tree_decl_identifier): Strip privat (*)
  c1729df... final: Fix get_attr_length for asm goto [PR118411] (*)
  550f1a4... Daily bump. (*)
  c9f7090... d: Merge upstream dmd, druntime 82a5d2a7c4, phobos dbc09d82 (*)
  292be68... libphobos: Merge upstream phobos 2a730adc0 (*)
  d6d7e02... c++/modules: Handle chaining already-imported local types [ (*)
  6528646... Fortran: Fix location_t in gfc_get_extern_function_decl; su (*)
  d64ca15... Fortran: Fix error recovery for bad component arrayspecs [P (*)
  664bd76... c++: modules and function attributes (*)
  fdabd93... c++: modules and class attributes (*)
  f30423e... LoongArch: Generate the final immediate for lu12i.w, lu32i. (*)
  dd3026f... d: Merge dmd, druntime 2b89c2909d, phobos bdedad3bf (*)
  b0eeb54... Use relations when simplifying MIN and MAX. (*)
  4951a90... Daily bump. (*)
  c82395e... d: Merge dmd, druntime 4ccb01fde5, phobos eab6595ad (*)
  a7ae0c3... d: Merge dmd, druntime 6884b433d2, phobos 48d581a1f (*)
  086031c... vect: Also cost gconds for scalar [PR118211] (*)
  f4e259b... vect: Ensure we add vector skip guard even when versioning  (*)
  f1c6789... vect: Fix dominators when adding a guard to skip the vector (*)
  0a46245... vect: Don't guard scalar epilogue for inverted loops [PR118 (*)
  68326d5... vect: Force alignment peeling to vectorize more early break (*)
  ddcfae1... AArch64: correct Cortex-X4 MIDR (*)
  89629b2... d: Merge dmd, druntime 34875cd6e1, phobos ebd24da8a (*)
  c9353e0... libstdc++: Fix unused parameter warnings in  [PR118387] (*)
  e86dadd... c++: modules and DECL_REPLACEABLE_P (*)
  9193641... Fix some me

[gcc/aoliva/heads/testbase] (90 commits) [ifcombine] propagate signbit mask to XOR right-hand operan

2025-01-13 Thread Alexandre Oliva via Gcc-cvs
The branch 'aoliva/heads/testbase' was updated to point to:

 52e4ede03097... [ifcombine] propagate signbit mask to XOR right-hand operan

It previously pointed to:

 47ac6ca9cb08... [ifcombine] drop other misuses of uniform_integer_cst_p

Diff:

Summary of changes (added commits):
---

  52e4ede... [ifcombine] propagate signbit mask to XOR right-hand operan (*)
  41a5a97... expr: Fix up the divmod cost debugging note [PR115910] (*)
  539fc49... MAINTAINERS: Make contrib/check-MAINTAINERS.py happy (*)
  0cf06bf... ada: Update gnatdll documentation (-b option removed) (*)
  1a82657... ada: Cleanup preanalysis of static expressions (part 5) (*)
  2e0b086... ada: Fix relocatable DLL creation with gnatdll (*)
  492aae1... ada: Remove redundant parentheses inside unary operators (c (*)
  5fd925b... ada: Cleanup preanalysis of static expressions (part 4) (*)
  686bd4e... ada: Warn about redundant parentheses inside unary operator (*)
  34943af... ada: Remove redundant parentheses inside unary operators in (*)
  94a7543... ada: Remove redundant parentheses inside unary operators (*)
  ef4448e... ada: Fix spurious warning about redundant parentheses in ra (*)
  c6989fb... ada: Unbounded recursion on character aggregates with predi (*)
  f9d22b7... ada: Simplify expansion of negative membership operator (*)
  518fd9e... ada: Warn about redundant parentheses in upper range bounds (*)
  d2e3635... ada: Add more commentary to System.Val_Real.Large_Powfive (*)
  26b649b... ada: Fix parsing of raise expressions with no parens (*)
  d3904a3... tree-optimization/117119 - ICE with int128 IV in dataref an (*)
  c0c47fc... Un-XFAIL 'dg-note's in 'gfortran.dg/goacc/routine-external- (*)
  017c45f... Bump BASE-VER to 14.0.1 now that we are in stage4. (*)
  9100be5... lto: Pass cache checksum by reference [PR118181] (*)
  89ebb88... lto: Fix empty fnctl.h build error with MinGW. (*)
  0e05b79... Refactor ix86_expand_vecop_qihi2. (*)
  9c387a9... [PATCH] crc: Fix up some crc related wrong code issues [PR1 (*)
  422c588... Daily bump. (*)
  a2e540b... d: Merge dmd, druntime c7902293d7, phobos 03aeafd20 (*)
  f4fa0b7... Dump all symbol attributes in show_attr. (*)
  0dd21bc... d: Merge upstream dmd, druntime c57da0cf59, phobos ad8ee558 (*)
  a236f70... c: UX improvements to 'too {few,many} arguments' errors (v5 (*)
  f8eda60... Fortran: implement F2018 intrinsic OUT_OF_RANGE [PR115788] (*)
  ed8cd42... Alpha: Fix a block move pessimisation with zero-extension a (*)
  4e55721... Alpha: Optimize block moves coming from longword-aligned so (*)
  19fdb9f... Alpha: Always respect -mbwx, -mcix, -mfix, -mmax, and their (*)
  3cf0e6a... Alpha: Restore frame pointer last in `builtin_longjmp' [PR6 (*)
  4686116... Alpha: Add memory clobbers to `builtin_longjmp' expansion (*)
  40754a3... Fix union member access for EXEC_INQUIRE. (*)
  bedf26c... More memory leak fixes (*)
  4b29be7... testsuite: The expect framework might introduce CR in outpu (*)
  4b0ef49... testsuite: libstdc++: Use effective-target libatomic (*)
  851e188... c-pretty-print.cc (pp_c_tree_decl_identifier): Strip privat (*)
  c1729df... final: Fix get_attr_length for asm goto [PR118411] (*)
  550f1a4... Daily bump. (*)
  c9f7090... d: Merge upstream dmd, druntime 82a5d2a7c4, phobos dbc09d82 (*)
  292be68... libphobos: Merge upstream phobos 2a730adc0 (*)
  d6d7e02... c++/modules: Handle chaining already-imported local types [ (*)
  6528646... Fortran: Fix location_t in gfc_get_extern_function_decl; su (*)
  d64ca15... Fortran: Fix error recovery for bad component arrayspecs [P (*)
  664bd76... c++: modules and function attributes (*)
  fdabd93... c++: modules and class attributes (*)
  f30423e... LoongArch: Generate the final immediate for lu12i.w, lu32i. (*)
  dd3026f... d: Merge dmd, druntime 2b89c2909d, phobos bdedad3bf (*)
  b0eeb54... Use relations when simplifying MIN and MAX. (*)
  4951a90... Daily bump. (*)
  c82395e... d: Merge dmd, druntime 4ccb01fde5, phobos eab6595ad (*)
  a7ae0c3... d: Merge dmd, druntime 6884b433d2, phobos 48d581a1f (*)
  086031c... vect: Also cost gconds for scalar [PR118211] (*)
  f4e259b... vect: Ensure we add vector skip guard even when versioning  (*)
  f1c6789... vect: Fix dominators when adding a guard to skip the vector (*)
  0a46245... vect: Don't guard scalar epilogue for inverted loops [PR118 (*)
  68326d5... vect: Force alignment peeling to vectorize more early break (*)
  ddcfae1... AArch64: correct Cortex-X4 MIDR (*)
  89629b2... d: Merge dmd, druntime 34875cd6e1, phobos ebd24da8a (*)
  c9353e0... libstdc++: Fix unused parameter warnings in  [PR118387] (*)
  e86dadd... c++: modules and DECL_REPLACEABLE_P (*)
  9193641... Fix some memory leaks (*)
  94d8de5... [PR118017][LRA]: Fix test for i686 (*)
  288ac09... arm: [MVE intrinsics] Fix tuples field name (PR 118332) (*)
  5534118... Fix bootstrap on !HARDREG_PRE_REGNOS targets (*)
  03faac5... rtl-optimization/117467 - limit ext-dce memory use (*)
 

[gcc/aoliva/heads/testme] [ifcombine] check and extend constants to compare with bitf

2025-01-13 Thread Alexandre Oliva via Gcc-cvs
The branch 'aoliva/heads/testme' was updated to point to:

 84acdb5125a6... [ifcombine] check and extend constants to compare with bitf

It previously pointed to:

 23364e8369a2... [ifcombine] check and extend constants to compare with bitf

Diff:

!!! WARNING: THE FOLLOWING COMMITS ARE NO LONGER ACCESSIBLE (LOST):
---

  23364e8... [ifcombine] check and extend constants to compare with bitf


Summary of changes (added commits):
---

  84acdb5... [ifcombine] check and extend constants to compare with bitf


[gcc(refs/users/aoliva/heads/testme)] [ifcombine] check and extend constants to compare with bitfields

2025-01-13 Thread Alexandre Oliva via Gcc-cvs
https://gcc.gnu.org/g:84acdb5125a64e6c031855f18c33d2046a7af87e

commit 84acdb5125a64e6c031855f18c33d2046a7af87e
Author: Alexandre Oliva 
Date:   Mon Jan 13 14:53:25 2025 -0300

[ifcombine] check and extend constants to compare with bitfields

Add logic to check and extend constants compared with bitfields, so
that fields are only compared with constants they could actually
equal.  This involves making sure the signedness doesn't change
between loads and conversions before shifts: we'd need to carry a lot
more data to deal with all the possibilities.

(IIRC we had logic that implicitly dealt with that when compare
constants were represented as typed trees, but after the rewrite to
represent them as wide_ints, the logic seemed superfluous.  It wasn't.)

While at that, I've robustified decode_field_reference to use local
variables throughout, to modify the out parms only when we're about to
return non-NULL, and to drop the unused case of NULL pand_mask, that
had a latent failure to detect signbit masking.


for  gcc/ChangeLog

PR tree-optimization/118456
* gimple-fold.cc (decode_field_reference): Punt if shifting
after changing signedness.  Rebustify to set out parms only
when returning non-NULL.
(fold_truth_andor_for_ifcombine): Check extension bits in
constants before clipping.  Add complementary assert on
r_const's not being set when l_const isn't.

for  gcc/testsuite/ChangeLog

PR tree-optimization/118456
* gcc.dg/field-merge-21.c: New.
* gcc.dg/field-merge-22.c: New.

Diff:
---
 gcc/gimple-fold.cc| 44 +++--
 gcc/testsuite/gcc.dg/field-merge-21.c | 53 +++
 gcc/testsuite/gcc.dg/field-merge-22.c | 31 
 3 files changed, 126 insertions(+), 2 deletions(-)

diff --git a/gcc/gimple-fold.cc b/gcc/gimple-fold.cc
index 93ed8b3abb05..c9cd842c9088 100644
--- a/gcc/gimple-fold.cc
+++ b/gcc/gimple-fold.cc
@@ -7712,6 +7712,18 @@ decode_field_reference (tree *pexp, HOST_WIDE_INT 
*pbitsize,
 
   if (shiftrt)
 {
+  /* Punt if we're shifting by more than the loaded bitfield (after
+adjustment), or if there's a shift after a change of signedness, punt.
+When comparing this field with a constant, we'll check that the
+constant is a proper sign- or zero-extension (depending on signedness)
+of a value that would fit in the selected portion of the bitfield.  A
+shift after a change of signedness would make the extension
+non-uniform, and we can't deal with that (yet ???).  See
+gcc.dg/field-merge-22.c for a test that would go wrong.  */
+  if (*pbitsize <= shiftrt
+ || (convert_before_shift
+ && outer_type && unsignedp != TYPE_UNSIGNED (outer_type)))
+   return NULL_TREE;
   if (!*preversep ? !BYTES_BIG_ENDIAN : BYTES_BIG_ENDIAN)
*pbitpos += shiftrt;
   *pbitsize -= shiftrt;
@@ -8512,13 +8524,25 @@ fold_truth_andor_for_ifcombine (enum tree_code code, 
tree truth_type,
  and bit position.  */
   if (l_const.get_precision ())
 {
+  /* Before clipping upper bits of the right-hand operand of the compare,
+check that they're sign or zero extensions, depending on how the
+left-hand operand would be extended.  */
+  bool l_non_ext_bits = false;
+  if (ll_bitsize < lr_bitsize)
+   {
+ wide_int zext = wi::zext (l_const, ll_bitsize);
+ if ((ll_unsignedp ? zext : wi::sext (l_const, ll_bitsize)) == l_const)
+   l_const = zext;
+ else
+   l_non_ext_bits = true;
+   }
   /* We're doing bitwise equality tests, so don't bother with sign
 extensions.  */
   l_const = wide_int::from (l_const, lnprec, UNSIGNED);
   if (ll_and_mask.get_precision ())
l_const &= wide_int::from (ll_and_mask, lnprec, UNSIGNED);
   l_const <<= xll_bitpos;
-  if ((l_const & ~ll_mask) != 0)
+  if (l_non_ext_bits || (l_const & ~ll_mask) != 0)
{
  warning_at (lloc, OPT_Wtautological_compare,
  "comparison is always %d", wanted_code == NE_EXPR);
@@ -8530,11 +8554,23 @@ fold_truth_andor_for_ifcombine (enum tree_code code, 
tree truth_type,
 again.  */
   gcc_checking_assert (r_const.get_precision ());
 
+  /* Before clipping upper bits of the right-hand operand of the compare,
+check that they're sign or zero extensions, depending on how the
+left-hand operand would be extended.  */
+  bool r_non_ext_bits = false;
+  if (rl_bitsize < rr_bitsize)
+   {
+ wide_int zext = wi::zext (r_const, rl_bitsize);
+ if ((rl_unsignedp ? zext : wi::sext (r_const, rl_bitsize)) == r_const)
+   r_const = zext;
+ else
+   r_non_ext_bits = true;
+ 

[gcc(refs/users/aoliva/heads/testme)] [ifcombine] robustify decode_field_reference

2025-01-13 Thread Alexandre Oliva via Gcc-cvs
https://gcc.gnu.org/g:df55a9a2e371d7b6291c8619ec013231f06841b6

commit df55a9a2e371d7b6291c8619ec013231f06841b6
Author: Alexandre Oliva 
Date:   Mon Jan 13 22:15:17 2025 -0300

[ifcombine] robustify decode_field_reference

Arrange for decode_field_reference to use local variables throughout,
to modify the out parms only when we're about to return non-NULL, and
to drop the unused case of NULL pand_mask, that had a latent failure
to detect signbit masking.


for  gcc/ChangeLog

* gimple-fold.cc (decode_field_reference): Rebustify to set
out parms only when returning non-NULL.
(fold_truth_andor_for_ifcombine): Add complementary assert on
r_const's not being set when l_const isn't.

Diff:
---
 gcc/gimple-fold.cc | 142 +++--
 1 file changed, 73 insertions(+), 69 deletions(-)

diff --git a/gcc/gimple-fold.cc b/gcc/gimple-fold.cc
index 5b1fbe6db1df..c53bbd028bf8 100644
--- a/gcc/gimple-fold.cc
+++ b/gcc/gimple-fold.cc
@@ -7510,18 +7510,17 @@ gimple_binop_def_p (enum tree_code code, tree t, tree 
op[2])
*PREVERSEP is set to the storage order of the field.
 
*PAND_MASK is set to the mask found in a BIT_AND_EXPR, if any.  If
-   PAND_MASK *is NULL, BIT_AND_EXPR is not recognized.  If *PAND_MASK
-   is initially set to a mask with nonzero precision, that mask is
+   *PAND_MASK is initially set to a mask with nonzero precision, that mask is
combined with the found mask, or adjusted in precision to match.
 
*PSIGNBIT is set to TRUE if, before clipping to *PBITSIZE, the mask
encompassed bits that corresponded to extensions of the sign bit.
 
-   *XOR_P is to be FALSE if EXP might be a XOR used in a compare, in which
-   case, if XOR_CMP_OP is a zero constant, it will be overridden with *PEXP,
-   *XOR_P will be set to TRUE, *XOR_PAND_MASK will be copied from *PAND_MASK,
-   and the left-hand operand of the XOR will be decoded.  If *XOR_P is TRUE,
-   XOR_CMP_OP and XOR_PAND_MASK are supposed to be NULL, and then the
+   *PXORP is to be FALSE if EXP might be a XOR used in a compare, in which
+   case, if PXOR_CMP_OP is a zero constant, it will be overridden with *PEXP,
+   *PXORP will be set to TRUE, *PXOR_AND_MASK will be copied from *PAND_MASK,
+   and the left-hand operand of the XOR will be decoded.  If *PXORP is TRUE,
+   PXOR_CMP_OP and PXOR_AND_MASK are supposed to be NULL, and then the
right-hand operand of the XOR will be decoded.
 
*LOAD is set to the load stmt of the innermost reference, if any,
@@ -7538,8 +7537,8 @@ decode_field_reference (tree *pexp, HOST_WIDE_INT 
*pbitsize,
HOST_WIDE_INT *pbitpos,
bool *punsignedp, bool *preversep, bool *pvolatilep,
wide_int *pand_mask, bool *psignbit,
-   bool *xor_p, tree *xor_cmp_op, wide_int *xor_pand_mask,
-   gimple **load, location_t loc[4])
+   bool *pxorp, tree *pxor_cmp_op, wide_int *pxor_and_mask,
+   gimple **pload, location_t loc[4])
 {
   tree exp = *pexp;
   tree outer_type = 0;
@@ -7549,9 +7548,11 @@ decode_field_reference (tree *pexp, HOST_WIDE_INT 
*pbitsize,
   tree res_ops[2];
   machine_mode mode;
   bool convert_before_shift = false;
-
-  *load = NULL;
-  *psignbit = false;
+  bool signbit = false;
+  bool xorp = false;
+  tree xor_cmp_op;
+  wide_int xor_and_mask;
+  gimple *load = NULL;
 
   /* All the optimizations using this function assume integer fields.
  There are problems with FP fields since the type_for_size call
@@ -7576,7 +7577,7 @@ decode_field_reference (tree *pexp, HOST_WIDE_INT 
*pbitsize,
 
   /* Recognize and save a masking operation.  Combine it with an
  incoming mask.  */
-  if (pand_mask && gimple_binop_def_p (BIT_AND_EXPR, exp, res_ops)
+  if (gimple_binop_def_p (BIT_AND_EXPR, exp, res_ops)
   && TREE_CODE (res_ops[1]) == INTEGER_CST)
 {
   loc[1] = gimple_location (SSA_NAME_DEF_STMT (exp));
@@ -7596,29 +7597,29 @@ decode_field_reference (tree *pexp, HOST_WIDE_INT 
*pbitsize,
and_mask &= wide_int::from (*pand_mask, prec_op, UNSIGNED);
}
 }
-  else if (pand_mask)
+  else
 and_mask = *pand_mask;
 
   /* Turn (a ^ b) [!]= 0 into a [!]= b.  */
-  if (xor_p && gimple_binop_def_p (BIT_XOR_EXPR, exp, res_ops))
+  if (xorp && gimple_binop_def_p (BIT_XOR_EXPR, exp, res_ops))
 {
   /* No location recorded for this one, it's entirely subsumed by the
 compare.  */
-  if (*xor_p)
+  if (*pxorp)
{
  exp = res_ops[1];
- gcc_checking_assert (!xor_cmp_op && !xor_pand_mask);
+ gcc_checking_assert (!pxor_cmp_op && !pxor_and_mask);
}
-  else if (!xor_cmp_op)
+  else if (!*pxor_cmp_op)
/* Not much we can do when xor appears in the right-hand compare
   operand.  */
return NULL_TREE;
-  else if

[gcc/aoliva/heads/testme] [ifcombine] robustify decode_field_reference

2025-01-13 Thread Alexandre Oliva via Gcc-cvs
The branch 'aoliva/heads/testme' was updated to point to:

 df55a9a2e371... [ifcombine] robustify decode_field_reference

It previously pointed to:

 995fc6e17270... [ifcombine] robustify decode_field_reference

Diff:

!!! WARNING: THE FOLLOWING COMMITS ARE NO LONGER ACCESSIBLE (LOST):
---

  995fc6e... [ifcombine] robustify decode_field_reference


Summary of changes (added commits):
---

  df55a9a... [ifcombine] robustify decode_field_reference


[gcc/aoliva/heads/testme] (2 commits) [ifcombine] robustify decode_field_reference

2025-01-13 Thread Alexandre Oliva via Gcc-cvs
The branch 'aoliva/heads/testme' was updated to point to:

 c8f631560b4d... [ifcombine] robustify decode_field_reference

It previously pointed to:

 84acdb5125a6... [ifcombine] check and extend constants to compare with bitf

Diff:

!!! WARNING: THE FOLLOWING COMMITS ARE NO LONGER ACCESSIBLE (LOST):
---

  84acdb5... [ifcombine] check and extend constants to compare with bitf


Summary of changes (added commits):
---

  c8f6315... [ifcombine] robustify decode_field_reference
  f87cc87... [ifcombine] check and extend constants to compare with bitf


[gcc(refs/users/aoliva/heads/testme)] [ifcombine] robustify decode_field_reference

2025-01-13 Thread Alexandre Oliva via Gcc-cvs
https://gcc.gnu.org/g:e4ccecb4a47a3ccd88d9d1dee5a5fba48072bedd

commit e4ccecb4a47a3ccd88d9d1dee5a5fba48072bedd
Author: Alexandre Oliva 
Date:   Mon Jan 13 22:15:17 2025 -0300

[ifcombine] robustify decode_field_reference

Arrange for decode_field_reference to use local variables throughout,
to modify the out parms only when we're about to return non-NULL, and
to drop the unused case of NULL pand_mask, that had a latent failure
to detect signbit masking.


for  gcc/ChangeLog

* gimple-fold.cc (decode_field_reference): Rebustify to set
out parms only when returning non-NULL.
(fold_truth_andor_for_ifcombine): Add complementary assert on
r_const's not being set when l_const isn't.

Diff:
---
 gcc/gimple-fold.cc | 136 -
 1 file changed, 71 insertions(+), 65 deletions(-)

diff --git a/gcc/gimple-fold.cc b/gcc/gimple-fold.cc
index 5b1fbe6db1df..daac58561e64 100644
--- a/gcc/gimple-fold.cc
+++ b/gcc/gimple-fold.cc
@@ -7510,18 +7510,17 @@ gimple_binop_def_p (enum tree_code code, tree t, tree 
op[2])
*PREVERSEP is set to the storage order of the field.
 
*PAND_MASK is set to the mask found in a BIT_AND_EXPR, if any.  If
-   PAND_MASK *is NULL, BIT_AND_EXPR is not recognized.  If *PAND_MASK
-   is initially set to a mask with nonzero precision, that mask is
+   *PAND_MASK is initially set to a mask with nonzero precision, that mask is
combined with the found mask, or adjusted in precision to match.
 
*PSIGNBIT is set to TRUE if, before clipping to *PBITSIZE, the mask
encompassed bits that corresponded to extensions of the sign bit.
 
-   *XOR_P is to be FALSE if EXP might be a XOR used in a compare, in which
-   case, if XOR_CMP_OP is a zero constant, it will be overridden with *PEXP,
-   *XOR_P will be set to TRUE, *XOR_PAND_MASK will be copied from *PAND_MASK,
-   and the left-hand operand of the XOR will be decoded.  If *XOR_P is TRUE,
-   XOR_CMP_OP and XOR_PAND_MASK are supposed to be NULL, and then the
+   *PXORP is to be FALSE if EXP might be a XOR used in a compare, in which
+   case, if PXOR_CMP_OP is a zero constant, it will be overridden with *PEXP,
+   *PXORP will be set to TRUE, *PXOR_AND_MASK will be copied from *PAND_MASK,
+   and the left-hand operand of the XOR will be decoded.  If *PXORP is TRUE,
+   PXOR_CMP_OP and PXOR_AND_MASK are supposed to be NULL, and then the
right-hand operand of the XOR will be decoded.
 
*LOAD is set to the load stmt of the innermost reference, if any,
@@ -7538,8 +7537,8 @@ decode_field_reference (tree *pexp, HOST_WIDE_INT 
*pbitsize,
HOST_WIDE_INT *pbitpos,
bool *punsignedp, bool *preversep, bool *pvolatilep,
wide_int *pand_mask, bool *psignbit,
-   bool *xor_p, tree *xor_cmp_op, wide_int *xor_pand_mask,
-   gimple **load, location_t loc[4])
+   bool *pxorp, tree *pxor_cmp_op, wide_int *pxor_and_mask,
+   gimple **pload, location_t loc[4])
 {
   tree exp = *pexp;
   tree outer_type = 0;
@@ -7549,9 +7548,11 @@ decode_field_reference (tree *pexp, HOST_WIDE_INT 
*pbitsize,
   tree res_ops[2];
   machine_mode mode;
   bool convert_before_shift = false;
-
-  *load = NULL;
-  *psignbit = false;
+  bool signbit = false;
+  bool xorp = false;
+  tree xor_cmp_op;
+  wide_int xor_and_mask;
+  gimple *load = NULL;
 
   /* All the optimizations using this function assume integer fields.
  There are problems with FP fields since the type_for_size call
@@ -7576,7 +7577,7 @@ decode_field_reference (tree *pexp, HOST_WIDE_INT 
*pbitsize,
 
   /* Recognize and save a masking operation.  Combine it with an
  incoming mask.  */
-  if (pand_mask && gimple_binop_def_p (BIT_AND_EXPR, exp, res_ops)
+  if (gimple_binop_def_p (BIT_AND_EXPR, exp, res_ops)
   && TREE_CODE (res_ops[1]) == INTEGER_CST)
 {
   loc[1] = gimple_location (SSA_NAME_DEF_STMT (exp));
@@ -7596,29 +7597,29 @@ decode_field_reference (tree *pexp, HOST_WIDE_INT 
*pbitsize,
and_mask &= wide_int::from (*pand_mask, prec_op, UNSIGNED);
}
 }
-  else if (pand_mask)
+  else
 and_mask = *pand_mask;
 
   /* Turn (a ^ b) [!]= 0 into a [!]= b.  */
-  if (xor_p && gimple_binop_def_p (BIT_XOR_EXPR, exp, res_ops))
+  if (xorp && gimple_binop_def_p (BIT_XOR_EXPR, exp, res_ops))
 {
   /* No location recorded for this one, it's entirely subsumed by the
 compare.  */
-  if (*xor_p)
+  if (*xorp)
{
  exp = res_ops[1];
  gcc_checking_assert (!xor_cmp_op && !xor_pand_mask);
}
-  else if (!xor_cmp_op)
+  else if (!*pxor_cmp_op)
/* Not much we can do when xor appears in the right-hand compare
   operand.  */
return NULL_TREE;
-  else if (integer_zerop (*xor_cmp_op))
+  else if (integer_zerop (*px

[gcc(refs/users/aoliva/heads/testme)] [ifcombine] robustify decode_field_reference

2025-01-13 Thread Alexandre Oliva via Gcc-cvs
https://gcc.gnu.org/g:7bbb55958cfb0b29301cc5209ef8e22f85729b94

commit 7bbb55958cfb0b29301cc5209ef8e22f85729b94
Author: Alexandre Oliva 
Date:   Mon Jan 13 22:15:17 2025 -0300

[ifcombine] robustify decode_field_reference

Arrange for decode_field_reference to use local variables throughout,
to modify the out parms only when we're about to return non-NULL, and
to drop the unused case of NULL pand_mask, that had a latent failure
to detect signbit masking.


for  gcc/ChangeLog

* gimple-fold.cc (decode_field_reference): Rebustify to set
out parms only when returning non-NULL.
(fold_truth_andor_for_ifcombine): Add complementary assert on
r_const's not being set when l_const isn't.

Diff:
---
 gcc/gimple-fold.cc | 138 -
 1 file changed, 72 insertions(+), 66 deletions(-)

diff --git a/gcc/gimple-fold.cc b/gcc/gimple-fold.cc
index 5b1fbe6db1df..221f1ff22e84 100644
--- a/gcc/gimple-fold.cc
+++ b/gcc/gimple-fold.cc
@@ -7510,18 +7510,17 @@ gimple_binop_def_p (enum tree_code code, tree t, tree 
op[2])
*PREVERSEP is set to the storage order of the field.
 
*PAND_MASK is set to the mask found in a BIT_AND_EXPR, if any.  If
-   PAND_MASK *is NULL, BIT_AND_EXPR is not recognized.  If *PAND_MASK
-   is initially set to a mask with nonzero precision, that mask is
+   *PAND_MASK is initially set to a mask with nonzero precision, that mask is
combined with the found mask, or adjusted in precision to match.
 
*PSIGNBIT is set to TRUE if, before clipping to *PBITSIZE, the mask
encompassed bits that corresponded to extensions of the sign bit.
 
-   *XOR_P is to be FALSE if EXP might be a XOR used in a compare, in which
-   case, if XOR_CMP_OP is a zero constant, it will be overridden with *PEXP,
-   *XOR_P will be set to TRUE, *XOR_PAND_MASK will be copied from *PAND_MASK,
-   and the left-hand operand of the XOR will be decoded.  If *XOR_P is TRUE,
-   XOR_CMP_OP and XOR_PAND_MASK are supposed to be NULL, and then the
+   *PXORP is to be FALSE if EXP might be a XOR used in a compare, in which
+   case, if PXOR_CMP_OP is a zero constant, it will be overridden with *PEXP,
+   *PXORP will be set to TRUE, *PXOR_AND_MASK will be copied from *PAND_MASK,
+   and the left-hand operand of the XOR will be decoded.  If *PXORP is TRUE,
+   PXOR_CMP_OP and PXOR_AND_MASK are supposed to be NULL, and then the
right-hand operand of the XOR will be decoded.
 
*LOAD is set to the load stmt of the innermost reference, if any,
@@ -7538,8 +7537,8 @@ decode_field_reference (tree *pexp, HOST_WIDE_INT 
*pbitsize,
HOST_WIDE_INT *pbitpos,
bool *punsignedp, bool *preversep, bool *pvolatilep,
wide_int *pand_mask, bool *psignbit,
-   bool *xor_p, tree *xor_cmp_op, wide_int *xor_pand_mask,
-   gimple **load, location_t loc[4])
+   bool *pxorp, tree *pxor_cmp_op, wide_int *pxor_and_mask,
+   gimple **pload, location_t loc[4])
 {
   tree exp = *pexp;
   tree outer_type = 0;
@@ -7549,9 +7548,11 @@ decode_field_reference (tree *pexp, HOST_WIDE_INT 
*pbitsize,
   tree res_ops[2];
   machine_mode mode;
   bool convert_before_shift = false;
-
-  *load = NULL;
-  *psignbit = false;
+  bool signbit = false;
+  bool xorp = false;
+  tree xor_cmp_op;
+  wide_int xor_and_mask;
+  gimple *load = NULL;
 
   /* All the optimizations using this function assume integer fields.
  There are problems with FP fields since the type_for_size call
@@ -7576,7 +7577,7 @@ decode_field_reference (tree *pexp, HOST_WIDE_INT 
*pbitsize,
 
   /* Recognize and save a masking operation.  Combine it with an
  incoming mask.  */
-  if (pand_mask && gimple_binop_def_p (BIT_AND_EXPR, exp, res_ops)
+  if (gimple_binop_def_p (BIT_AND_EXPR, exp, res_ops)
   && TREE_CODE (res_ops[1]) == INTEGER_CST)
 {
   loc[1] = gimple_location (SSA_NAME_DEF_STMT (exp));
@@ -7596,29 +7597,29 @@ decode_field_reference (tree *pexp, HOST_WIDE_INT 
*pbitsize,
and_mask &= wide_int::from (*pand_mask, prec_op, UNSIGNED);
}
 }
-  else if (pand_mask)
+  else
 and_mask = *pand_mask;
 
   /* Turn (a ^ b) [!]= 0 into a [!]= b.  */
-  if (xor_p && gimple_binop_def_p (BIT_XOR_EXPR, exp, res_ops))
+  if (xorp && gimple_binop_def_p (BIT_XOR_EXPR, exp, res_ops))
 {
   /* No location recorded for this one, it's entirely subsumed by the
 compare.  */
-  if (*xor_p)
+  if (*pxorp)
{
  exp = res_ops[1];
- gcc_checking_assert (!xor_cmp_op && !xor_pand_mask);
+ gcc_checking_assert (!xor_cmp_op && !xor_and_mask);
}
-  else if (!xor_cmp_op)
+  else if (!*pxor_cmp_op)
/* Not much we can do when xor appears in the right-hand compare
   operand.  */
return NULL_TREE;
-  else if (

[gcc/aoliva/heads/testme] [ifcombine] robustify decode_field_reference

2025-01-13 Thread Alexandre Oliva via Gcc-cvs
The branch 'aoliva/heads/testme' was updated to point to:

 e4ccecb4a47a... [ifcombine] robustify decode_field_reference

It previously pointed to:

 c8f631560b4d... [ifcombine] robustify decode_field_reference

Diff:

!!! WARNING: THE FOLLOWING COMMITS ARE NO LONGER ACCESSIBLE (LOST):
---

  c8f6315... [ifcombine] robustify decode_field_reference


Summary of changes (added commits):
---

  e4ccecb... [ifcombine] robustify decode_field_reference


[gcc(refs/users/aoliva/heads/testme)] [ifcombine] check and extend constants to compare with bitfields

2025-01-13 Thread Alexandre Oliva via Gcc-cvs
https://gcc.gnu.org/g:f87cc87007c827c9c16f2f6930703e70f409f93e

commit f87cc87007c827c9c16f2f6930703e70f409f93e
Author: Alexandre Oliva 
Date:   Mon Jan 13 14:53:25 2025 -0300

[ifcombine] check and extend constants to compare with bitfields

Add logic to check and extend constants compared with bitfields, so
that fields are only compared with constants they could actually
equal.  This involves making sure the signedness doesn't change
between loads and conversions before shifts: we'd need to carry a lot
more data to deal with all the possibilities.


for  gcc/ChangeLog

PR tree-optimization/118456
* gimple-fold.cc (decode_field_reference): Punt if shifting
after changing signedness.
(fold_truth_andor_for_ifcombine): Check extension bits in
constants before clipping.

for  gcc/testsuite/ChangeLog

PR tree-optimization/118456
* gcc.dg/field-merge-21.c: New.
* gcc.dg/field-merge-22.c: New.

Diff:
---
 gcc/gimple-fold.cc| 40 --
 gcc/testsuite/gcc.dg/field-merge-21.c | 53 +++
 gcc/testsuite/gcc.dg/field-merge-22.c | 31 
 3 files changed, 122 insertions(+), 2 deletions(-)

diff --git a/gcc/gimple-fold.cc b/gcc/gimple-fold.cc
index 93ed8b3abb05..5b1fbe6db1df 100644
--- a/gcc/gimple-fold.cc
+++ b/gcc/gimple-fold.cc
@@ -7712,6 +7712,18 @@ decode_field_reference (tree *pexp, HOST_WIDE_INT 
*pbitsize,
 
   if (shiftrt)
 {
+  /* Punt if we're shifting by more than the loaded bitfield (after
+adjustment), or if there's a shift after a change of signedness, punt.
+When comparing this field with a constant, we'll check that the
+constant is a proper sign- or zero-extension (depending on signedness)
+of a value that would fit in the selected portion of the bitfield.  A
+shift after a change of signedness would make the extension
+non-uniform, and we can't deal with that (yet ???).  See
+gcc.dg/field-merge-22.c for a test that would go wrong.  */
+  if (*pbitsize <= shiftrt
+ || (convert_before_shift
+ && outer_type && unsignedp != TYPE_UNSIGNED (outer_type)))
+   return NULL_TREE;
   if (!*preversep ? !BYTES_BIG_ENDIAN : BYTES_BIG_ENDIAN)
*pbitpos += shiftrt;
   *pbitsize -= shiftrt;
@@ -8512,13 +8524,25 @@ fold_truth_andor_for_ifcombine (enum tree_code code, 
tree truth_type,
  and bit position.  */
   if (l_const.get_precision ())
 {
+  /* Before clipping upper bits of the right-hand operand of the compare,
+check that they're sign or zero extensions, depending on how the
+left-hand operand would be extended.  */
+  bool l_non_ext_bits = false;
+  if (ll_bitsize < lr_bitsize)
+   {
+ wide_int zext = wi::zext (l_const, ll_bitsize);
+ if ((ll_unsignedp ? zext : wi::sext (l_const, ll_bitsize)) == l_const)
+   l_const = zext;
+ else
+   l_non_ext_bits = true;
+   }
   /* We're doing bitwise equality tests, so don't bother with sign
 extensions.  */
   l_const = wide_int::from (l_const, lnprec, UNSIGNED);
   if (ll_and_mask.get_precision ())
l_const &= wide_int::from (ll_and_mask, lnprec, UNSIGNED);
   l_const <<= xll_bitpos;
-  if ((l_const & ~ll_mask) != 0)
+  if (l_non_ext_bits || (l_const & ~ll_mask) != 0)
{
  warning_at (lloc, OPT_Wtautological_compare,
  "comparison is always %d", wanted_code == NE_EXPR);
@@ -8530,11 +8554,23 @@ fold_truth_andor_for_ifcombine (enum tree_code code, 
tree truth_type,
 again.  */
   gcc_checking_assert (r_const.get_precision ());
 
+  /* Before clipping upper bits of the right-hand operand of the compare,
+check that they're sign or zero extensions, depending on how the
+left-hand operand would be extended.  */
+  bool r_non_ext_bits = false;
+  if (rl_bitsize < rr_bitsize)
+   {
+ wide_int zext = wi::zext (r_const, rl_bitsize);
+ if ((rl_unsignedp ? zext : wi::sext (r_const, rl_bitsize)) == r_const)
+   r_const = zext;
+ else
+   r_non_ext_bits = true;
+   }
   r_const = wide_int::from (r_const, lnprec, UNSIGNED);
   if (rl_and_mask.get_precision ())
r_const &= wide_int::from (rl_and_mask, lnprec, UNSIGNED);
   r_const <<= xrl_bitpos;
-  if ((r_const & ~rl_mask) != 0)
+  if (r_non_ext_bits || (r_const & ~rl_mask) != 0)
{
  warning_at (rloc, OPT_Wtautological_compare,
  "comparison is always %d", wanted_code == NE_EXPR);
diff --git a/gcc/testsuite/gcc.dg/field-merge-21.c 
b/gcc/testsuite/gcc.dg/field-merge-21.c
new file mode 100644
index ..042b2123eb63
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/field-merge-21.c
@@ -0,0 +1,

[gcc/aoliva/heads/testme] [ifcombine] robustify decode_field_reference

2025-01-13 Thread Alexandre Oliva via Gcc-cvs
The branch 'aoliva/heads/testme' was updated to point to:

 7bbb55958cfb... [ifcombine] robustify decode_field_reference

It previously pointed to:

 e4ccecb4a47a... [ifcombine] robustify decode_field_reference

Diff:

!!! WARNING: THE FOLLOWING COMMITS ARE NO LONGER ACCESSIBLE (LOST):
---

  e4ccecb... [ifcombine] robustify decode_field_reference


Summary of changes (added commits):
---

  7bbb559... [ifcombine] robustify decode_field_reference


[gcc(refs/users/aoliva/heads/testme)] [ifcombine] robustify decode_field_reference

2025-01-13 Thread Alexandre Oliva via Gcc-cvs
https://gcc.gnu.org/g:995fc6e17270aa6c95700e001465ea35c3c5c1e8

commit 995fc6e17270aa6c95700e001465ea35c3c5c1e8
Author: Alexandre Oliva 
Date:   Mon Jan 13 22:15:17 2025 -0300

[ifcombine] robustify decode_field_reference

Arrange for decode_field_reference to use local variables throughout,
to modify the out parms only when we're about to return non-NULL, and
to drop the unused case of NULL pand_mask, that had a latent failure
to detect signbit masking.


for  gcc/ChangeLog

* gimple-fold.cc (decode_field_reference): Rebustify to set
out parms only when returning non-NULL.
(fold_truth_andor_for_ifcombine): Add complementary assert on
r_const's not being set when l_const isn't.

Diff:
---
 gcc/gimple-fold.cc | 138 -
 1 file changed, 72 insertions(+), 66 deletions(-)

diff --git a/gcc/gimple-fold.cc b/gcc/gimple-fold.cc
index 5b1fbe6db1df..bab4cf95a1b9 100644
--- a/gcc/gimple-fold.cc
+++ b/gcc/gimple-fold.cc
@@ -7510,18 +7510,17 @@ gimple_binop_def_p (enum tree_code code, tree t, tree 
op[2])
*PREVERSEP is set to the storage order of the field.
 
*PAND_MASK is set to the mask found in a BIT_AND_EXPR, if any.  If
-   PAND_MASK *is NULL, BIT_AND_EXPR is not recognized.  If *PAND_MASK
-   is initially set to a mask with nonzero precision, that mask is
+   *PAND_MASK is initially set to a mask with nonzero precision, that mask is
combined with the found mask, or adjusted in precision to match.
 
*PSIGNBIT is set to TRUE if, before clipping to *PBITSIZE, the mask
encompassed bits that corresponded to extensions of the sign bit.
 
-   *XOR_P is to be FALSE if EXP might be a XOR used in a compare, in which
-   case, if XOR_CMP_OP is a zero constant, it will be overridden with *PEXP,
-   *XOR_P will be set to TRUE, *XOR_PAND_MASK will be copied from *PAND_MASK,
-   and the left-hand operand of the XOR will be decoded.  If *XOR_P is TRUE,
-   XOR_CMP_OP and XOR_PAND_MASK are supposed to be NULL, and then the
+   *PXORP is to be FALSE if EXP might be a XOR used in a compare, in which
+   case, if PXOR_CMP_OP is a zero constant, it will be overridden with *PEXP,
+   *PXORP will be set to TRUE, *PXOR_AND_MASK will be copied from *PAND_MASK,
+   and the left-hand operand of the XOR will be decoded.  If *PXORP is TRUE,
+   PXOR_CMP_OP and PXOR_AND_MASK are supposed to be NULL, and then the
right-hand operand of the XOR will be decoded.
 
*LOAD is set to the load stmt of the innermost reference, if any,
@@ -7538,8 +7537,8 @@ decode_field_reference (tree *pexp, HOST_WIDE_INT 
*pbitsize,
HOST_WIDE_INT *pbitpos,
bool *punsignedp, bool *preversep, bool *pvolatilep,
wide_int *pand_mask, bool *psignbit,
-   bool *xor_p, tree *xor_cmp_op, wide_int *xor_pand_mask,
-   gimple **load, location_t loc[4])
+   bool *pxorp, tree *pxor_cmp_op, wide_int *pxor_and_mask,
+   gimple **pload, location_t loc[4])
 {
   tree exp = *pexp;
   tree outer_type = 0;
@@ -7549,9 +7548,11 @@ decode_field_reference (tree *pexp, HOST_WIDE_INT 
*pbitsize,
   tree res_ops[2];
   machine_mode mode;
   bool convert_before_shift = false;
-
-  *load = NULL;
-  *psignbit = false;
+  bool signbit = false;
+  bool xorp = false;
+  tree xor_cmp_op;
+  wide_int xor_and_mask;
+  gimple *load = NULL;
 
   /* All the optimizations using this function assume integer fields.
  There are problems with FP fields since the type_for_size call
@@ -7576,7 +7577,7 @@ decode_field_reference (tree *pexp, HOST_WIDE_INT 
*pbitsize,
 
   /* Recognize and save a masking operation.  Combine it with an
  incoming mask.  */
-  if (pand_mask && gimple_binop_def_p (BIT_AND_EXPR, exp, res_ops)
+  if (gimple_binop_def_p (BIT_AND_EXPR, exp, res_ops)
   && TREE_CODE (res_ops[1]) == INTEGER_CST)
 {
   loc[1] = gimple_location (SSA_NAME_DEF_STMT (exp));
@@ -7596,29 +7597,29 @@ decode_field_reference (tree *pexp, HOST_WIDE_INT 
*pbitsize,
and_mask &= wide_int::from (*pand_mask, prec_op, UNSIGNED);
}
 }
-  else if (pand_mask)
+  else
 and_mask = *pand_mask;
 
   /* Turn (a ^ b) [!]= 0 into a [!]= b.  */
-  if (xor_p && gimple_binop_def_p (BIT_XOR_EXPR, exp, res_ops))
+  if (xorp && gimple_binop_def_p (BIT_XOR_EXPR, exp, res_ops))
 {
   /* No location recorded for this one, it's entirely subsumed by the
 compare.  */
-  if (*xor_p)
+  if (*pxorp)
{
  exp = res_ops[1];
- gcc_checking_assert (!xor_cmp_op && !xor_pand_mask);
+ gcc_checking_assert (!pxor_cmp_op && !pxor_and_mask);
}
-  else if (!xor_cmp_op)
+  else if (!*pxor_cmp_op)
/* Not much we can do when xor appears in the right-hand compare
   operand.  */
return NULL_TREE;
-  else if

[gcc/aoliva/heads/testme] [ifcombine] robustify decode_field_reference

2025-01-13 Thread Alexandre Oliva via Gcc-cvs
The branch 'aoliva/heads/testme' was updated to point to:

 995fc6e17270... [ifcombine] robustify decode_field_reference

It previously pointed to:

 7bbb55958cfb... [ifcombine] robustify decode_field_reference

Diff:

!!! WARNING: THE FOLLOWING COMMITS ARE NO LONGER ACCESSIBLE (LOST):
---

  7bbb559... [ifcombine] robustify decode_field_reference


Summary of changes (added commits):
---

  995fc6e... [ifcombine] robustify decode_field_reference


[gcc r15-6887] Fortran: Add LOCALITY support for DO_CONCURRENT

2025-01-13 Thread Jerry DeLisle via Gcc-cvs
https://gcc.gnu.org/g:20b8500cfa522ebe0fcf756d5b32816da7f904dd

commit r15-6887-g20b8500cfa522ebe0fcf756d5b32816da7f904dd
Author: Anuj Mohite 
Date:   Mon Jan 13 16:28:57 2025 -0800

Fortran: Add LOCALITY support for DO_CONCURRENT

This patch provided by Anuj Mohite as part of the GSoC project.
It is modified slightly by Jerry DeLisle for minor formatting.
The patch provides front-end parsing of the LOCALITY specs in
DO_CONCURRENT and adds numerous test cases.

gcc/fortran/ChangeLog:

* dump-parse-tree.cc (show_code_node):  Updated to use
c->ext.concur.forall_iterator instead of c->ext.forall_iterator.
* frontend-passes.cc (index_interchange): Updated to
use c->ext.concur.forall_iterator instead of c->ext.forall_iterator.
(gfc_code_walker): Likewise.
* gfortran.h (enum locality_type): Added new enum for locality types
in DO CONCURRENT constructs.
* match.cc (match_simple_forall): Updated to use
new_st.ext.concur.forall_iterator instead of 
new_st.ext.forall_iterator.
(gfc_match_forall): Likewise.
(gfc_match_do):  Implemented support for matching DO CONCURRENT 
locality
specifiers (LOCAL, LOCAL_INIT, SHARED, DEFAULT(NONE), and REDUCE).
* parse.cc (parse_do_block): Updated to use
new_st.ext.concur.forall_iterator instead of 
new_st.ext.forall_iterator.
* resolve.cc (struct check_default_none_data): Added struct
check_default_none_data.
(do_concur_locality_specs_f2023): New function to check compliance
with F2023's C1133 constraint for DO CONCURRENT.
(check_default_none_expr): New function to check DEFAULT(NONE)
compliance.
(resolve_locality_spec): New function to resolve locality specs.
(gfc_count_forall_iterators): Updated to use
code->ext.concur.forall_iterator.
(gfc_resolve_forall): Updated to use 
code->ext.concur.forall_iterator.
* st.cc (gfc_free_statement): Updated to free locality 
specifications
and use p->ext.concur.forall_iterator.
* trans-stmt.cc (gfc_trans_forall_1): Updated to use
code->ext.concur.forall_iterator.

gcc/testsuite/ChangeLog:

* gfortran.dg/do_concurrent_10.f90: New test.
* gfortran.dg/do_concurrent_8_f2018.f90: New test.
* gfortran.dg/do_concurrent_8_f2023.f90: New test.
* gfortran.dg/do_concurrent_9.f90: New test.
* gfortran.dg/do_concurrent_all_clauses.f90: New test.
* gfortran.dg/do_concurrent_basic.f90: New test.
* gfortran.dg/do_concurrent_constraints.f90: New test.
* gfortran.dg/do_concurrent_local_init.f90: New test.
* gfortran.dg/do_concurrent_locality_specs.f90: New test.
* gfortran.dg/do_concurrent_multiple_reduce.f90: New test.
* gfortran.dg/do_concurrent_nested.f90: New test.
* gfortran.dg/do_concurrent_parser.f90: New test.
* gfortran.dg/do_concurrent_reduce_max.f90: New test.
* gfortran.dg/do_concurrent_reduce_sum.f90: New test.
* gfortran.dg/do_concurrent_shared.f90: New test.

Signed-off-by: Anuj 

Diff:
---
 gcc/fortran/dump-parse-tree.cc | 113 ++-
 gcc/fortran/frontend-passes.cc |   8 +-
 gcc/fortran/gfortran.h |  46 ++-
 gcc/fortran/match.cc   | 288 -
 gcc/fortran/parse.cc   |   2 +-
 gcc/fortran/resolve.cc | 354 -
 gcc/fortran/st.cc  |   5 +-
 gcc/fortran/trans-stmt.cc  |   6 +-
 gcc/testsuite/gfortran.dg/do_concurrent_10.f90 |  11 +
 .../gfortran.dg/do_concurrent_8_f2018.f90  |  19 ++
 .../gfortran.dg/do_concurrent_8_f2023.f90  |  23 ++
 gcc/testsuite/gfortran.dg/do_concurrent_9.f90  |  15 +
 .../gfortran.dg/do_concurrent_all_clauses.f90  |  26 ++
 gcc/testsuite/gfortran.dg/do_concurrent_basic.f90  |  11 +
 .../gfortran.dg/do_concurrent_constraints.f90  | 126 
 .../gfortran.dg/do_concurrent_local_init.f90   |  11 +
 .../gfortran.dg/do_concurrent_locality_specs.f90   |  14 +
 .../gfortran.dg/do_concurrent_multiple_reduce.f90  |  17 +
 gcc/testsuite/gfortran.dg/do_concurrent_nested.f90 |  26 ++
 gcc/testsuite/gfortran.dg/do_concurrent_parser.f90 |  20 ++
 .../gfortran.dg/do_concurrent_reduce_max.f90   |  14 +
 .../gfortran.dg/do_concurrent_reduce_sum.f90   |  14 +
 gcc/testsuite/gfortran.dg/do_concurrent_shared.f90 |  14 +
 23 files changed, 1147 insertions(+), 36 deletions(-)

diff --git a/gcc/fortran/dump-parse-tree.cc b/gcc/fortran/dump-parse-tree.cc
index cf09e8d5b823..0

[gcc/aoliva/heads/testme] [ifcombine] robustify decode_field_reference

2025-01-13 Thread Alexandre Oliva via Gcc-cvs
The branch 'aoliva/heads/testme' was updated to point to:

 0e2c9a1a29d4... [ifcombine] robustify decode_field_reference

It previously pointed to:

 d543ef708e13... [ifcombine] robustify decode_field_reference

Diff:

!!! WARNING: THE FOLLOWING COMMITS ARE NO LONGER ACCESSIBLE (LOST):
---

  d543ef7... [ifcombine] robustify decode_field_reference


Summary of changes (added commits):
---

  0e2c9a1... [ifcombine] robustify decode_field_reference


[gcc(refs/users/aoliva/heads/testme)] [ifcombine] robustify decode_field_reference

2025-01-13 Thread Alexandre Oliva via Gcc-cvs
https://gcc.gnu.org/g:0e2c9a1a29d4bcc9847b0e51482b2d357b864674

commit 0e2c9a1a29d4bcc9847b0e51482b2d357b864674
Author: Alexandre Oliva 
Date:   Mon Jan 13 22:15:17 2025 -0300

[ifcombine] robustify decode_field_reference

Arrange for decode_field_reference to use local variables throughout,
to modify the out parms only when we're about to return non-NULL, and
to drop the unused case of NULL pand_mask, that had a latent failure
to detect signbit masking.


for  gcc/ChangeLog

* gimple-fold.cc (decode_field_reference): Rebustify to set
out parms only when returning non-NULL.
(fold_truth_andor_for_ifcombine): Bail if
decode_field_reference returns NULL.  Add complementary assert
on r_const's not being set when l_const isn't.

Diff:
---
 gcc/gimple-fold.cc | 155 +++--
 1 file changed, 80 insertions(+), 75 deletions(-)

diff --git a/gcc/gimple-fold.cc b/gcc/gimple-fold.cc
index 5b1fbe6db1df..a1b4edb8107c 100644
--- a/gcc/gimple-fold.cc
+++ b/gcc/gimple-fold.cc
@@ -7510,18 +7510,17 @@ gimple_binop_def_p (enum tree_code code, tree t, tree 
op[2])
*PREVERSEP is set to the storage order of the field.
 
*PAND_MASK is set to the mask found in a BIT_AND_EXPR, if any.  If
-   PAND_MASK *is NULL, BIT_AND_EXPR is not recognized.  If *PAND_MASK
-   is initially set to a mask with nonzero precision, that mask is
+   *PAND_MASK is initially set to a mask with nonzero precision, that mask is
combined with the found mask, or adjusted in precision to match.
 
*PSIGNBIT is set to TRUE if, before clipping to *PBITSIZE, the mask
encompassed bits that corresponded to extensions of the sign bit.
 
-   *XOR_P is to be FALSE if EXP might be a XOR used in a compare, in which
-   case, if XOR_CMP_OP is a zero constant, it will be overridden with *PEXP,
-   *XOR_P will be set to TRUE, *XOR_PAND_MASK will be copied from *PAND_MASK,
-   and the left-hand operand of the XOR will be decoded.  If *XOR_P is TRUE,
-   XOR_CMP_OP and XOR_PAND_MASK are supposed to be NULL, and then the
+   *PXORP is to be FALSE if EXP might be a XOR used in a compare, in which
+   case, if PXOR_CMP_OP is a zero constant, it will be overridden with *PEXP,
+   *PXORP will be set to TRUE, *PXOR_AND_MASK will be copied from *PAND_MASK,
+   and the left-hand operand of the XOR will be decoded.  If *PXORP is TRUE,
+   PXOR_CMP_OP and PXOR_AND_MASK are supposed to be NULL, and then the
right-hand operand of the XOR will be decoded.
 
*LOAD is set to the load stmt of the innermost reference, if any,
@@ -7538,8 +7537,8 @@ decode_field_reference (tree *pexp, HOST_WIDE_INT 
*pbitsize,
HOST_WIDE_INT *pbitpos,
bool *punsignedp, bool *preversep, bool *pvolatilep,
wide_int *pand_mask, bool *psignbit,
-   bool *xor_p, tree *xor_cmp_op, wide_int *xor_pand_mask,
-   gimple **load, location_t loc[4])
+   bool *pxorp, tree *pxor_cmp_op, wide_int *pxor_and_mask,
+   gimple **pload, location_t loc[4])
 {
   tree exp = *pexp;
   tree outer_type = 0;
@@ -7549,9 +7548,11 @@ decode_field_reference (tree *pexp, HOST_WIDE_INT 
*pbitsize,
   tree res_ops[2];
   machine_mode mode;
   bool convert_before_shift = false;
-
-  *load = NULL;
-  *psignbit = false;
+  bool signbit = false;
+  bool xorp = false;
+  tree xor_cmp_op;
+  wide_int xor_and_mask;
+  gimple *load = NULL;
 
   /* All the optimizations using this function assume integer fields.
  There are problems with FP fields since the type_for_size call
@@ -7576,7 +7577,7 @@ decode_field_reference (tree *pexp, HOST_WIDE_INT 
*pbitsize,
 
   /* Recognize and save a masking operation.  Combine it with an
  incoming mask.  */
-  if (pand_mask && gimple_binop_def_p (BIT_AND_EXPR, exp, res_ops)
+  if (gimple_binop_def_p (BIT_AND_EXPR, exp, res_ops)
   && TREE_CODE (res_ops[1]) == INTEGER_CST)
 {
   loc[1] = gimple_location (SSA_NAME_DEF_STMT (exp));
@@ -7596,29 +7597,29 @@ decode_field_reference (tree *pexp, HOST_WIDE_INT 
*pbitsize,
and_mask &= wide_int::from (*pand_mask, prec_op, UNSIGNED);
}
 }
-  else if (pand_mask)
+  else
 and_mask = *pand_mask;
 
   /* Turn (a ^ b) [!]= 0 into a [!]= b.  */
-  if (xor_p && gimple_binop_def_p (BIT_XOR_EXPR, exp, res_ops))
+  if (pxorp && gimple_binop_def_p (BIT_XOR_EXPR, exp, res_ops))
 {
   /* No location recorded for this one, it's entirely subsumed by the
 compare.  */
-  if (*xor_p)
+  if (*pxorp)
{
  exp = res_ops[1];
- gcc_checking_assert (!xor_cmp_op && !xor_pand_mask);
+ gcc_checking_assert (!pxor_cmp_op && !pxor_and_mask);
}
-  else if (!xor_cmp_op)
+  else if (!*pxor_cmp_op)
/* Not much we can do when xor appears in the right-hand compare
 

[gcc(refs/users/aoliva/heads/testme)] [ifcombine] robustify decode_field_reference

2025-01-13 Thread Alexandre Oliva via Gcc-cvs
https://gcc.gnu.org/g:e5bef1e1c6f3eff196d218188180596108a8cbcd

commit e5bef1e1c6f3eff196d218188180596108a8cbcd
Author: Alexandre Oliva 
Date:   Mon Jan 13 22:15:17 2025 -0300

[ifcombine] robustify decode_field_reference

Arrange for decode_field_reference to use local variables throughout,
to modify the out parms only when we're about to return non-NULL, and
to drop the unused case of NULL pand_mask, that had a latent failure
to detect signbit masking.


for  gcc/ChangeLog

* gimple-fold.cc (decode_field_reference): Rebustify to set
out parms only when returning non-NULL.
(fold_truth_andor_for_ifcombine): Bail if
decode_field_reference returns NULL.  Add complementary assert
on r_const's not being set when l_const isn't.

Diff:
---
 gcc/gimple-fold.cc | 155 +++--
 1 file changed, 80 insertions(+), 75 deletions(-)

diff --git a/gcc/gimple-fold.cc b/gcc/gimple-fold.cc
index 5b1fbe6db1df..3c971a29ef04 100644
--- a/gcc/gimple-fold.cc
+++ b/gcc/gimple-fold.cc
@@ -7510,18 +7510,17 @@ gimple_binop_def_p (enum tree_code code, tree t, tree 
op[2])
*PREVERSEP is set to the storage order of the field.
 
*PAND_MASK is set to the mask found in a BIT_AND_EXPR, if any.  If
-   PAND_MASK *is NULL, BIT_AND_EXPR is not recognized.  If *PAND_MASK
-   is initially set to a mask with nonzero precision, that mask is
+   *PAND_MASK is initially set to a mask with nonzero precision, that mask is
combined with the found mask, or adjusted in precision to match.
 
*PSIGNBIT is set to TRUE if, before clipping to *PBITSIZE, the mask
encompassed bits that corresponded to extensions of the sign bit.
 
-   *XOR_P is to be FALSE if EXP might be a XOR used in a compare, in which
-   case, if XOR_CMP_OP is a zero constant, it will be overridden with *PEXP,
-   *XOR_P will be set to TRUE, *XOR_PAND_MASK will be copied from *PAND_MASK,
-   and the left-hand operand of the XOR will be decoded.  If *XOR_P is TRUE,
-   XOR_CMP_OP and XOR_PAND_MASK are supposed to be NULL, and then the
+   *PXORP is to be FALSE if EXP might be a XOR used in a compare, in which
+   case, if PXOR_CMP_OP is a zero constant, it will be overridden with *PEXP,
+   *PXORP will be set to TRUE, *PXOR_AND_MASK will be copied from *PAND_MASK,
+   and the left-hand operand of the XOR will be decoded.  If *PXORP is TRUE,
+   PXOR_CMP_OP and PXOR_AND_MASK are supposed to be NULL, and then the
right-hand operand of the XOR will be decoded.
 
*LOAD is set to the load stmt of the innermost reference, if any,
@@ -7538,8 +7537,8 @@ decode_field_reference (tree *pexp, HOST_WIDE_INT 
*pbitsize,
HOST_WIDE_INT *pbitpos,
bool *punsignedp, bool *preversep, bool *pvolatilep,
wide_int *pand_mask, bool *psignbit,
-   bool *xor_p, tree *xor_cmp_op, wide_int *xor_pand_mask,
-   gimple **load, location_t loc[4])
+   bool *pxorp, tree *pxor_cmp_op, wide_int *pxor_and_mask,
+   gimple **pload, location_t loc[4])
 {
   tree exp = *pexp;
   tree outer_type = 0;
@@ -7549,9 +7548,11 @@ decode_field_reference (tree *pexp, HOST_WIDE_INT 
*pbitsize,
   tree res_ops[2];
   machine_mode mode;
   bool convert_before_shift = false;
-
-  *load = NULL;
-  *psignbit = false;
+  bool signbit = false;
+  bool xorp = false;
+  tree xor_cmp_op;
+  wide_int xor_and_mask;
+  gimple *load = NULL;
 
   /* All the optimizations using this function assume integer fields.
  There are problems with FP fields since the type_for_size call
@@ -7576,7 +7577,7 @@ decode_field_reference (tree *pexp, HOST_WIDE_INT 
*pbitsize,
 
   /* Recognize and save a masking operation.  Combine it with an
  incoming mask.  */
-  if (pand_mask && gimple_binop_def_p (BIT_AND_EXPR, exp, res_ops)
+  if (gimple_binop_def_p (BIT_AND_EXPR, exp, res_ops)
   && TREE_CODE (res_ops[1]) == INTEGER_CST)
 {
   loc[1] = gimple_location (SSA_NAME_DEF_STMT (exp));
@@ -7596,29 +7597,29 @@ decode_field_reference (tree *pexp, HOST_WIDE_INT 
*pbitsize,
and_mask &= wide_int::from (*pand_mask, prec_op, UNSIGNED);
}
 }
-  else if (pand_mask)
+  else
 and_mask = *pand_mask;
 
   /* Turn (a ^ b) [!]= 0 into a [!]= b.  */
-  if (xor_p && gimple_binop_def_p (BIT_XOR_EXPR, exp, res_ops))
+  if (pxorp && gimple_binop_def_p (BIT_XOR_EXPR, exp, res_ops))
 {
   /* No location recorded for this one, it's entirely subsumed by the
 compare.  */
-  if (*xor_p)
+  if (*pxorp)
{
  exp = res_ops[1];
- gcc_checking_assert (!xor_cmp_op && !xor_pand_mask);
+ gcc_checking_assert (!pxor_cmp_op && !pxor_and_mask);
}
-  else if (!xor_cmp_op)
+  else if (!pxor_cmp_op)
/* Not much we can do when xor appears in the right-hand compare
  

[gcc/aoliva/heads/testme] [ifcombine] robustify decode_field_reference

2025-01-13 Thread Alexandre Oliva via Gcc-cvs
The branch 'aoliva/heads/testme' was updated to point to:

 e5bef1e1c6f3... [ifcombine] robustify decode_field_reference

It previously pointed to:

 0e2c9a1a29d4... [ifcombine] robustify decode_field_reference

Diff:

!!! WARNING: THE FOLLOWING COMMITS ARE NO LONGER ACCESSIBLE (LOST):
---

  0e2c9a1... [ifcombine] robustify decode_field_reference


Summary of changes (added commits):
---

  e5bef1e... [ifcombine] robustify decode_field_reference


[gcc r15-6847] Bump BASE-VER to 14.0.1 now that we are in stage4.

2025-01-13 Thread Richard Biener via Gcc-cvs
https://gcc.gnu.org/g:017c45fa2a4da40893f0aacd96164f04c78cb245

commit r15-6847-g017c45fa2a4da40893f0aacd96164f04c78cb245
Author: Richard Biener 
Date:   Mon Jan 13 09:04:55 2025 +0100

Bump BASE-VER to 14.0.1 now that we are in stage4.

* BASE-VER: Bump to 14.0.1.

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

diff --git a/gcc/BASE-VER b/gcc/BASE-VER
index 94188a74831e..2bbd2b4b42ff 100644
--- a/gcc/BASE-VER
+++ b/gcc/BASE-VER
@@ -1 +1 @@
-15.0.0
+15.0.1


[gcc r15-6848] Un-XFAIL 'dg-note's in 'gfortran.dg/goacc/routine-external-level-of-parallelism-2.f'

2025-01-13 Thread Thomas Schwinge via Gcc-cvs
https://gcc.gnu.org/g:c0c47fc89ddcc3b1fbb0e5f3040fc52d93ca0be0

commit r15-6848-gc0c47fc89ddcc3b1fbb0e5f3040fc52d93ca0be0
Author: Thomas Schwinge 
Date:   Mon Jan 13 09:11:19 2025 +0100

Un-XFAIL 'dg-note's in 
'gfortran.dg/goacc/routine-external-level-of-parallelism-2.f'

As of the recent commit 65286465b94cba6ee3d59edbc771bef0088ac46e
"Fortran: Fix location_t in gfc_get_extern_function_decl; [...]" change:

The declaration created by gfc_get_extern_function_decl used 
input_location
as DECL_SOURCE_LOCATION, which gave rather odd results with 'declared 
here'
diagnostic. - It is much more useful to use the gfc_symbol's 
declated_at,
which this commit now does.

..., we're no longer using the 'dg-bogus' location informations, as pointed 
out
for one class of additional notes of
'gfortran.dg/goacc/routine-external-level-of-parallelism-2.f', once added in
commit 03eb779141a29f96600cd46904b88a33c4b49a66 "Add 'dg-note', 
'dg-lto-note'".
Therefore, un-XFAILed 'dg-note's rather than XFAILed 'dg-bogus'es.

gcc/testsuite/
* gfortran.dg/goacc/routine-external-level-of-parallelism-2.f:
Un-XFAIL 'dg-note's.

Diff:
---
 .../routine-external-level-of-parallelism-2.f  | 26 --
 1 file changed, 14 insertions(+), 12 deletions(-)

diff --git 
a/gcc/testsuite/gfortran.dg/goacc/routine-external-level-of-parallelism-2.f 
b/gcc/testsuite/gfortran.dg/goacc/routine-external-level-of-parallelism-2.f
index 91898b11be54..35f67cbd0b87 100644
--- a/gcc/testsuite/gfortran.dg/goacc/routine-external-level-of-parallelism-2.f
+++ b/gcc/testsuite/gfortran.dg/goacc/routine-external-level-of-parallelism-2.f
@@ -7,12 +7,13 @@
   integer, parameter :: n = 100
   integer :: a(n), i, j
   external :: gangr, workerr, vectorr, seqr
-! { dg-bogus "note: routine 'gangr' declared here" "TODO1" { xfail { ! 
offloading_enabled } } .-1 }
-! { dg-bogus "note: routine 'gangr_' declared here" "TODO2" { xfail 
offloading_enabled } .-2 }
-! { dg-bogus "note: routine 'workerr' declared here" "TODO1" { xfail { ! 
offloading_enabled } } .-3 }
-! { dg-bogus "note: routine 'workerr_' declared here" "TODO2" { xfail 
offloading_enabled } .-4 }
-! { dg-bogus "note: routine 'vectorr' declared here" "TODO1" { xfail { ! 
offloading_enabled } } .-5 }
-! { dg-bogus "note: routine 'vectorr_' declared here" "TODO2" { xfail 
offloading_enabled } .-6 }
+! { dg-note "routine 'gangr' declared here" "" { target { ! offloading_enabled 
} } .-1 }
+! { dg-note "routine 'gangr_' declared here" "" { target offloading_enabled } 
.-2 }
+! { dg-note "routine 'workerr' declared here" "" { target { ! 
offloading_enabled } } .-3 }
+! { dg-note "routine 'workerr_' declared here" "" { target offloading_enabled 
} .-4 }
+! { dg-note "routine 'vectorr' declared here" "" { target { ! 
offloading_enabled } } .-5 }
+! { dg-note "routine 'vectorr_' declared here" "" { target offloading_enabled 
} .-6 }
+!TODO See PR101551 for 'offloading_enabled' differences.
 
 !$acc routine (gangr) gang
 !$acc routine (workerr) worker
@@ -200,12 +201,13 @@
   integer, parameter :: n = 100
   integer :: a(n), i, j
   integer, external :: gangf, workerf, vectorf, seqf
-! { dg-bogus "note: routine 'gangf' declared here" "TODO1" { xfail { ! 
offloading_enabled } } .-1 }
-! { dg-bogus "note: routine 'gangf_' declared here" "TODO2" { xfail 
offloading_enabled } .-2 }
-! { dg-bogus "note: routine 'workerf' declared here" "TODO1" { xfail { ! 
offloading_enabled } } .-3 }
-! { dg-bogus "note: routine 'workerf_' declared here" "TODO2" { xfail 
offloading_enabled } .-4 }
-! { dg-bogus "note: routine 'vectorf' declared here" "TODO1" { xfail { ! 
offloading_enabled } } .-5 }
-! { dg-bogus "note: routine 'vectorf_' declared here" "TODO2" { xfail 
offloading_enabled } .-6 }
+! { dg-note "routine 'gangf' declared here" "" { target { ! offloading_enabled 
} } .-1 }
+! { dg-note "routine 'gangf_' declared here" "" { target offloading_enabled } 
.-2 }
+! { dg-note "routine 'workerf' declared here" "" { target { ! 
offloading_enabled } } .-3 }
+! { dg-note "routine 'workerf_' declared here" "" { target offloading_enabled 
} .-4 }
+! { dg-note "routine 'vectorf' declared here" "" { target { ! 
offloading_enabled } } .-5 }
+! { dg-note "routine 'vectorf_' declared here" "" { target offloading_enabled 
} .-6 }
+!TODO See PR101551 for 'offloading_enabled' differences.
 
 !$acc routine (gangf) gang
 !$acc routine (workerf) worker


[gcc r15-6867] [PR rtl-optimization/107455] Eliminate unnecessary constant load

2025-01-13 Thread Jeff Law via Gcc-cvs
https://gcc.gnu.org/g:d23d338da4d2bd581b2d3fd97785dd2c26053a92

commit r15-6867-gd23d338da4d2bd581b2d3fd97785dd2c26053a92
Author: Jeff Law 
Date:   Mon Jan 13 07:29:39 2025 -0700

[PR rtl-optimization/107455] Eliminate unnecessary constant load

This resurrects a patch from a bit over 2 years ago that I never wrapped up.
IIRC, I ended up up catching covid, then in the hospital for an unrelated 
issue
and it just got dropped on the floor in the insanity.

The basic idea here is to help postreload-cse eliminate more const/copies by
recording a small set of conditional equivalences (as Richi said in 2022,
"Ick").

It was originally to help eliminate an unnecessary constant load I saw in
coremark, but as seen in BZ107455 the same issues show up in real code as 
well.

Bootstrapped and regression tested on x86-64, also been through multiple 
spins
in my tester.

Changes since v2:

  - Simplified logic for blocks to examine
  - Remove redundant tests when filtering blocks to examine
  - Remove bogus check which only allowed reg->reg copies

Changes since v1:

Richard B and Richard S both had good comments last time around and their
requests are reflected in this update:

  - Use rtx_equal_p rather than pointer equality
  - Restrict to register "destinations"
  - Restrict to integer modes
  - Adjust entry block handling

My own wider scale testing resulted in a few more changes.

  - Robustify extracting the (set (pc) ... ), which then required ...
  - Handle if src/dst are clobbered by the conditional branch
  - Fix logic error causing too many equivalences to be recorded

PR rtl-optimization/107455
gcc/
* postreload.cc (reload_cse_regs_1): Take advantage of conditional
equivalences.

gcc/testsuite
* gcc.target/riscv/pr107455-1.c: New test.
* gcc.target/riscv/pr107455-2.c: New test.

Diff:
---
 gcc/postreload.cc   | 107 ++--
 gcc/testsuite/gcc.target/riscv/pr107455-1.c |  46 
 gcc/testsuite/gcc.target/riscv/pr107455-2.c |  40 +++
 3 files changed, 187 insertions(+), 6 deletions(-)

diff --git a/gcc/postreload.cc b/gcc/postreload.cc
index 05c2e0e26445..487aa8aad054 100644
--- a/gcc/postreload.cc
+++ b/gcc/postreload.cc
@@ -33,6 +33,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "emit-rtl.h"
 #include "recog.h"
 
+#include "cfghooks.h"
 #include "cfgrtl.h"
 #include "cfgbuild.h"
 #include "cfgcleanup.h"
@@ -221,13 +222,107 @@ reload_cse_regs_1 (void)
   init_alias_analysis ();
 
   FOR_EACH_BB_FN (bb, cfun)
-FOR_BB_INSNS (bb, insn)
-  {
-   if (INSN_P (insn))
- cfg_changed |= reload_cse_simplify (insn, testreg);
+{
+  /* If BB has a small number of predecessors, see if each of the
+has the same implicit set.  If so, record that implicit set so
+that we can add it to the cselib tables.  */
+  rtx_insn *implicit_set;
 
-   cselib_process_insn (insn);
-  }
+  implicit_set = NULL;
+  if (EDGE_COUNT (bb->preds) <= 3)
+   {
+ edge e;
+ edge_iterator ei;
+ rtx src = NULL_RTX;
+ rtx dest = NULL_RTX;
+
+ /* Iterate over each incoming edge and see if they
+all have the same implicit set.  */
+ FOR_EACH_EDGE (e, ei, bb->preds)
+   {
+ /* Skip the entry/exit block.  */
+ if (e->src == ENTRY_BLOCK_PTR_FOR_FN (cfun))
+   break;
+
+ /* Verify this block ends with a suitable condjump  */
+ rtx_insn *condjump = BB_END (e->src);
+ if (!condjump || ! any_condjump_p (condjump))
+   break;
+
+ /* This predecessor ends with a possible equivalence
+producing conditional branch.  Extract the condition
+and try to use it to create an equivalence.  */
+ rtx pat = pc_set (condjump);
+ rtx i_t_e = SET_SRC (pat);
+ gcc_assert (GET_CODE (i_t_e) == IF_THEN_ELSE);
+ rtx cond = XEXP (i_t_e, 0);
+
+ if e->flags & EDGE_FALLTHRU) != 0)
+  == (XEXP (i_t_e, 1) == pc_rtx))
+ ? GET_CODE (cond) == EQ
+ : GET_CODE (cond) == NE)
+   {
+ /* If this is the first time through record
+the source and destination.  */
+ if (!dest)
+   {
+ dest = XEXP (cond, 0);
+ src = XEXP (cond, 1);
+   }
+ /* If this is not the first time through, then
+verify the source and destination match.  */
+ else if (rtx_equal_p (dest, XEXP (cond, 0))
+  && rtx_equal_p (src, XEXP (cond, 1)))
+  

[gcc r15-6868] PR modula2/118453: Subranges types do not use virtual tokens during construction

2025-01-13 Thread Gaius Mulley via Gcc-cvs
https://gcc.gnu.org/g:7cd4de65ffb3f34d6ba5af2f9570900fecd7bed0

commit r15-6868-g7cd4de65ffb3f34d6ba5af2f9570900fecd7bed0
Author: Gaius Mulley 
Date:   Mon Jan 13 14:40:43 2025 +

PR modula2/118453: Subranges types do not use virtual tokens during 
construction

P2SymBuild.mod.BuildSubrange does not use a virtual token and therefore
any error message containing a subrange type produces poor location carots.
This patch rewrites BuildSubrange and the buildError4 procedure in
M2Check.mod (which is only called when there is a formal/actual parameter
mismatch).  buildError4 now issues a sub error for the formal and actual
type declaration highlighing the type mismatch.

gcc/m2/ChangeLog:

PR modula2/118453
* gm2-compiler/M2Check.mod (buildError4): Call MetaError1
for the actual and formal parameter type.
* gm2-compiler/P2Build.bnf (SubrangeType): Construct a virtual
token containing the subrange type declaration.
(PrefixedSubrangeType): Ditto.
* gm2-compiler/P2SymBuild.def (BuildSubrange): Add tok parameter.
* gm2-compiler/P2SymBuild.mod (BuildSubrange): Use tok parameter,
rather than the token at the start of the subrange.

gcc/testsuite/ChangeLog:

PR modula2/118453
* gm2/pim/fail/badbecomes2.mod: New test.
* gm2/pim/fail/badparamset1.mod: New test.
* gm2/pim/fail/badparamset2.mod: New test.
* gm2/pim/fail/badsyntaxset1.mod: New test.

Signed-off-by: Gaius Mulley 

Diff:
---
 gcc/m2/gm2-compiler/M2Check.mod  |  8 +++-
 gcc/m2/gm2-compiler/P2Build.bnf  | 17 -
 gcc/m2/gm2-compiler/P2SymBuild.def   |  2 +-
 gcc/m2/gm2-compiler/P2SymBuild.mod   |  7 +++
 gcc/testsuite/gm2/pim/fail/badbecomes2.mod   |  9 +
 gcc/testsuite/gm2/pim/fail/badparamset1.mod  | 16 
 gcc/testsuite/gm2/pim/fail/badparamset2.mod  | 16 
 gcc/testsuite/gm2/pim/fail/badsyntaxset1.mod |  8 
 8 files changed, 68 insertions(+), 15 deletions(-)

diff --git a/gcc/m2/gm2-compiler/M2Check.mod b/gcc/m2/gm2-compiler/M2Check.mod
index 9e58ef05d36c..d2bb4ab7da35 100644
--- a/gcc/m2/gm2-compiler/M2Check.mod
+++ b/gcc/m2/gm2-compiler/M2Check.mod
@@ -36,7 +36,7 @@ FROM M2System IMPORT IsSystemType, IsGenericSystemType, 
IsSameSize, IsComplexN ;
 FROM M2Base IMPORT IsParameterCompatible, IsAssignmentCompatible, 
IsExpressionCompatible, IsComparisonCompatible, IsBaseType, IsMathType, ZType, 
CType, RType, IsComplexType, Char ;
 FROM Indexing IMPORT Index, InitIndex, GetIndice, PutIndice, KillIndex, 
HighIndice, LowIndice, IncludeIndiceIntoIndex, ForeachIndiceInIndexDo ;
 FROM M2Error IMPORT Error, InternalError, NewError, ErrorString, ChainError ;
-FROM M2MetaError IMPORT MetaErrorStringT2, MetaErrorStringT3, 
MetaErrorStringT4, MetaString2, MetaString3, MetaString4 ;
+FROM M2MetaError IMPORT MetaErrorStringT2, MetaErrorStringT3, 
MetaErrorStringT4, MetaString2, MetaString3, MetaString4, MetaError1 ;
 FROM StrLib IMPORT StrEqual ;
 FROM M2Debug IMPORT Assert ;
 
@@ -504,10 +504,8 @@ BEGIN
   (* and also generate a sub error containing detail.  *)
   IF (left # tinfo^.left) OR (right # tinfo^.right)
   THEN
- tinfo^.error := ChainError (tinfo^.token, tinfo^.error) ;
- s := MetaString2 (InitString ("{%1Ead} and {%2ad} are incompatible as 
formal and actual procedure parameters"),
-   left, right) ;
- ErrorString (tinfo^.error, s)
+ MetaError1 ('formal parameter {%1EDad}', right) ;
+ MetaError1 ('actual parameter {%1EDad}', left)
   END
END
 END buildError4 ;
diff --git a/gcc/m2/gm2-compiler/P2Build.bnf b/gcc/m2/gm2-compiler/P2Build.bnf
index f1eafc83da7c..b9a6daa70b2e 100644
--- a/gcc/m2/gm2-compiler/P2Build.bnf
+++ b/gcc/m2/gm2-compiler/P2Build.bnf
@@ -45,7 +45,9 @@ see .  *)
 
 IMPLEMENTATION MODULE P2Build ;
 
-FROM M2LexBuf IMPORT currentstring, currenttoken, GetToken, InsertToken, 
InsertTokenAndRewind, GetTokenNo ;
+FROM M2LexBuf IMPORT currentstring, currenttoken, GetToken, InsertToken,
+ InsertTokenAndRewind, GetTokenNo, MakeVirtual2Tok ;
+
 FROM M2MetaError IMPORT MetaErrorStringT0, MetaErrorT1 ;
 FROM NameKey IMPORT NulName, Name, makekey, MakeKey ;
 FROM M2Reserved IMPORT tokToTok, toktype, NulTok, ImportTok, ExportTok, 
QualifiedTok, UnQualifiedTok ;
@@ -765,12 +767,17 @@ IdentList := Ident
 % VAR
  
END %
  =:
 
-SubrangeType := "[" ConstExpression  ".." ConstExpression "]"  % 
BuildSubrange(NulSym) %
+SubrangeType :=% 
VAR start, combined: CARDINAL ; %
+ 

[gcc r15-6870] RISC-V: Fix program logic errors caused by data truncation on 32-bit host for zbs, such as i386

2025-01-13 Thread Jeff Law via Gcc-cvs
https://gcc.gnu.org/g:ecf688edc217472774817cc1284e75a9f72fe1b4

commit r15-6870-gecf688edc217472774817cc1284e75a9f72fe1b4
Author: Jin Ma 
Date:   Mon Jan 13 10:10:22 2025 -0700

RISC-V: Fix program logic errors caused by data truncation on 32-bit host 
for zbs, such as i386

Correct logic on 64-bit host:
...
bseti   a5,zero,38
bseti   a5,a5,63
addia5,a5,-1
and a4,a4,a5
...

Wrong logic on 32-bit host:
...
li  a5,64
bseti   a5,a5,31
addia5,a5,-1
and a4,a4,a5
...

gcc/ChangeLog:

* config/riscv/riscv.cc (riscv_build_integer_1): Change
1UL/1ULL to HOST_WIDE_INT_1U.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/zbs-bug.c: New test.

Diff:
---
 gcc/config/riscv/riscv.cc|  4 ++--
 gcc/testsuite/gcc.target/riscv/zbs-bug.c | 15 +++
 2 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc
index 65e09842fde8..3b5712429e46 100644
--- a/gcc/config/riscv/riscv.cc
+++ b/gcc/config/riscv/riscv.cc
@@ -1112,10 +1112,10 @@ riscv_build_integer_1 (struct riscv_integer_op 
codes[RISCV_MAX_INTEGER_OPS],
{
  HOST_WIDE_INT bit = ctz_hwi (value);
  alt_codes[i].code = (i == 0 ? UNKNOWN : IOR);
- alt_codes[i].value = 1UL << bit;
+ alt_codes[i].value = HOST_WIDE_INT_1U << bit;
  alt_codes[i].use_uw = false;
  alt_codes[i].save_temporary = false;
- value &= ~(1ULL << bit);
+ value &= ~(HOST_WIDE_INT_1U << bit);
  i++;
}
 
diff --git a/gcc/testsuite/gcc.target/riscv/zbs-bug.c 
b/gcc/testsuite/gcc.target/riscv/zbs-bug.c
new file mode 100644
index ..10dde5801334
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/zbs-bug.c
@@ -0,0 +1,15 @@
+/* { dg-do compile { target { rv64 } } } */
+/* { dg-skip-if "" { *-*-* } { "-O1" "-O2" "-O3" "-Og" "-Os" "-Oz" } } */
+/* { dg-options "-march=rv64gc_zbb_zbs -mabi=lp64d -O0" } */
+
+struct a {
+  unsigned : 29;
+  signed : 6;
+  signed b : 25;
+};
+
+void c() {
+  struct a d = {808};
+}
+
+/* { dg-final { scan-assembler-not "bseti.*31" } }*/


[gcc r15-6874] RISC-V: Improve bitwise and ashift reassociation for single-bit immediate without zbs [PR 115921]

2025-01-13 Thread Jeff Law via Gcc-cvs
https://gcc.gnu.org/g:107d5d682576e54963ddd36f3f21bc6b9506d278

commit r15-6874-g107d5d682576e54963ddd36f3f21bc6b9506d278
Author: Xi Ruoyao 
Date:   Mon Jan 13 11:28:05 2025 -0700

RISC-V: Improve bitwise and ashift reassociation for single-bit immediate 
without zbs [PR 115921]

When zbs is not available, there's nothing special with single-bit
immediates and we should perform reassociation as normal immediates.

gcc/ChangeLog:

PR target/115921
* config/riscv/riscv.md (_shift_reverse): Only check
popcount_hwi if !TARGET_ZBS.

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

diff --git a/gcc/config/riscv/riscv.md b/gcc/config/riscv/riscv.md
index 0922cab4402c..0a76ed63f0d1 100644
--- a/gcc/config/riscv/riscv.md
+++ b/gcc/config/riscv/riscv.md
@@ -2969,9 +2969,9 @@
 ;; for IOR/XOR.  It probably doesn't matter for AND.
 ;;
 ;; We also don't want to do this if the immediate already fits in a simm12
-;; field, or is a single bit operand, or when we might be able to generate
-;; a shift-add sequence via the splitter in bitmanip.md
-;; in bitmanip.md for masks that are a run of consecutive ones.
+;; field, or it is a single bit operand and zbs is available, or when we
+;; might be able to generate a shift-add sequence via the splitter in
+;; bitmanip.md for masks that are a run of consecutive ones.
 (define_insn_and_split "_shift_reverse"
   [(set (match_operand:X 0 "register_operand" "=r")
 (any_bitwise:X (ashift:X (match_operand:X 1 "register_operand" "r")
@@ -2979,7 +2979,7 @@
   (match_operand 3 "immediate_operand" "n")))]
   "(!SMALL_OPERAND (INTVAL (operands[3]))
 && SMALL_OPERAND (INTVAL (operands[3]) >> INTVAL (operands[2]))
-&& popcount_hwi (INTVAL (operands[3])) > 1
+&& (!TARGET_ZBS || popcount_hwi (INTVAL (operands[3])) > 1)
 && (!(TARGET_64BIT && TARGET_ZBA)
|| !consecutive_bits_operand (operands[3], VOIDmode)
|| !imm123_operand (operands[2], VOIDmode))


[gcc r15-6877] RISC-V: Remove zba check in bitwise and ashift reassociation [PR 115921]

2025-01-13 Thread Jeff Law via Gcc-cvs
https://gcc.gnu.org/g:a9ebf249063d2e8f6e8813fc954276766ad3a2fe

commit r15-6877-ga9ebf249063d2e8f6e8813fc954276766ad3a2fe
Author: Xi Ruoyao 
Date:   Mon Jan 13 13:11:38 2025 -0700

RISC-V: Remove zba check in bitwise and ashift reassociation [PR 115921]

The test case

long
test (long x, long y)
{
  return ((x | 0x1ff) << 3) + y;
}

is now compiled (-O2 -march=rv64g_zba) to

li  a4,4096
slliw   a5,a0,3
addia4,a4,-8
or  a5,a5,a4
addwa0,a5,a1
ret

Despite this check was originally intended to use zba better, now
removing it actually enables the use of zba for this test case (thanks
to late combine):

oria5,a0,511
sh3add  a0,a5,a1
ret

Obviously, bitmanip.md does not cover
(any_or (ashift (reg) (imm123)) imm) at all, and even for and it just
seems more natural splitting to (ashift (and (reg) (imm')) (imm123))
first, then let late combine to combine the outer ashift and the plus.

I've not found any test case regressed by the removal.
And "make check-gcc RUNTESTFLAGS=riscv.exp='zba-*.c'" also reports no
failure.

gcc/ChangeLog:

PR target/115921
* config/riscv/riscv.md (_shift_reverse): Remove
check for TARGET_ZBA.

gcc/testsuite/ChangeLog:

PR target/115921
* gcc.target/riscv/zba-shNadd-08.c: New test.

Diff:
---
 gcc/config/riscv/riscv.md  | 7 +--
 gcc/testsuite/gcc.target/riscv/zba-shNadd-08.c | 9 +
 2 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/gcc/config/riscv/riscv.md b/gcc/config/riscv/riscv.md
index 0a76ed63f0d1..fd98e0a481ee 100644
--- a/gcc/config/riscv/riscv.md
+++ b/gcc/config/riscv/riscv.md
@@ -2969,9 +2969,7 @@
 ;; for IOR/XOR.  It probably doesn't matter for AND.
 ;;
 ;; We also don't want to do this if the immediate already fits in a simm12
-;; field, or it is a single bit operand and zbs is available, or when we
-;; might be able to generate a shift-add sequence via the splitter in
-;; bitmanip.md for masks that are a run of consecutive ones.
+;; field, or it is a single bit operand and zbs is available.
 (define_insn_and_split "_shift_reverse"
   [(set (match_operand:X 0 "register_operand" "=r")
 (any_bitwise:X (ashift:X (match_operand:X 1 "register_operand" "r")
@@ -2980,9 +2978,6 @@
   "(!SMALL_OPERAND (INTVAL (operands[3]))
 && SMALL_OPERAND (INTVAL (operands[3]) >> INTVAL (operands[2]))
 && (!TARGET_ZBS || popcount_hwi (INTVAL (operands[3])) > 1)
-&& (!(TARGET_64BIT && TARGET_ZBA)
-   || !consecutive_bits_operand (operands[3], VOIDmode)
-   || !imm123_operand (operands[2], VOIDmode))
 && (INTVAL (operands[3]) & ((1ULL << INTVAL (operands[2])) - 1)) == 0)"
   "#"
   "&& 1"
diff --git a/gcc/testsuite/gcc.target/riscv/zba-shNadd-08.c 
b/gcc/testsuite/gcc.target/riscv/zba-shNadd-08.c
new file mode 100644
index ..50c9c4cf78bb
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/zba-shNadd-08.c
@@ -0,0 +1,9 @@
+/* { dg-do compile } */
+/* { dg-options "-march=rv64gc_zba -mabi=lp64 -O2" } */
+/* { dg-final { scan-assembler "sh3add" } } */
+
+long
+test (long x, long y)
+{
+  return ((x | 0x1ff) << 3) + y;
+}


[gcc r12-10899] Fortran: Cray pointer comparison wrongly optimized away [PR106692]

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

commit r12-10899-gb95b3406c1f7ea603495d71f62b21a9d2c8e15b9
Author: Harald Anlauf 
Date:   Thu Jan 2 20:22:23 2025 +0100

Fortran: Cray pointer comparison wrongly optimized away [PR106692]

PR fortran/106692

gcc/fortran/ChangeLog:

* trans-expr.cc (gfc_conv_expr_op): Inhibit excessive optimization
of Cray pointers by treating them as volatile in comparisons.

gcc/testsuite/ChangeLog:

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

(cherry picked from commit c7754a2fb2e60987524947fe189f3ffac035ea1d)

Diff:
---
 gcc/fortran/trans-expr.cc  | 13 +++
 gcc/testsuite/gfortran.dg/cray_pointers_13.f90 | 51 ++
 2 files changed, 64 insertions(+)

diff --git a/gcc/fortran/trans-expr.cc b/gcc/fortran/trans-expr.cc
index 54cf246fd0d7..7a7a7be17930 100644
--- a/gcc/fortran/trans-expr.cc
+++ b/gcc/fortran/trans-expr.cc
@@ -3923,6 +3923,19 @@ gfc_conv_expr_op (gfc_se * se, gfc_expr * expr)
 
   if (lop)
 {
+  // Inhibit overeager optimization of Cray pointer comparisons (PR106692).
+  if (expr->value.op.op1->expr_type == EXPR_VARIABLE
+ && expr->value.op.op1->ts.type == BT_INTEGER
+ && expr->value.op.op1->symtree
+ && expr->value.op.op1->symtree->n.sym->attr.cray_pointer)
+   TREE_THIS_VOLATILE (lse.expr) = 1;
+
+  if (expr->value.op.op2->expr_type == EXPR_VARIABLE
+ && expr->value.op.op2->ts.type == BT_INTEGER
+ && expr->value.op.op2->symtree
+ && expr->value.op.op2->symtree->n.sym->attr.cray_pointer)
+   TREE_THIS_VOLATILE (rse.expr) = 1;
+
   /* The result of logical ops is always logical_type_node.  */
   tmp = fold_build2_loc (input_location, code, logical_type_node,
 lse.expr, rse.expr);
diff --git a/gcc/testsuite/gfortran.dg/cray_pointers_13.f90 
b/gcc/testsuite/gfortran.dg/cray_pointers_13.f90
new file mode 100644
index ..766d24546ab2
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/cray_pointers_13.f90
@@ -0,0 +1,51 @@
+! { dg-do run }
+! { dg-additional-options "-fcray-pointer" }
+!
+! PR fortran/106692 - Cray pointer comparison wrongly optimized away
+!
+! Contributed by Marek Polacek
+
+program test
+  call test_cray()
+  call test_cray2()
+end
+
+subroutine test_cray()
+  pointer(ptrzz1 , zz1)
+  ptrzz1=0
+  if (ptrzz1 .ne. 0) then
+print *, "test_cray: ptrzz1=", ptrzz1
+stop 1
+  else
+call shape_cray(zz1)
+  end if
+end
+
+subroutine shape_cray(zz1)
+  pointer(ptrzz , zz)
+  ptrzz=loc(zz1)
+  if (ptrzz .ne. 0) then
+print *, "shape_cray: ptrzz=", ptrzz
+stop 3
+  end if
+end
+
+subroutine test_cray2()
+  pointer(ptrzz1 , zz1)
+  ptrzz1=0
+  if (0 == ptrzz1) then
+call shape_cray2(zz1)
+  else
+print *, "test_cray2: ptrzz1=", ptrzz1
+stop 2
+  end if
+end
+
+subroutine shape_cray2(zz1)
+  pointer(ptrzz , zz)
+  ptrzz=loc(zz1)
+  if (.not. (0 == ptrzz)) then
+print *, "shape_cray2: ptrzz=", ptrzz
+stop 4
+  end if
+end


[gcc/aoliva/heads/testme] [ifcombine] check and extend constants to compare with bitf

2025-01-13 Thread Alexandre Oliva via Gcc-cvs
The branch 'aoliva/heads/testme' was updated to point to:

 ca7f266795d8... [ifcombine] check and extend constants to compare with bitf

It previously pointed to:

 6c64cdc8a3ff... [ifcombine] set mask to clip sign-extended constant

Diff:

!!! WARNING: THE FOLLOWING COMMITS ARE NO LONGER ACCESSIBLE (LOST):
---

  6c64cdc... [ifcombine] set mask to clip sign-extended constant


Summary of changes (added commits):
---

  ca7f266... [ifcombine] check and extend constants to compare with bitf


[gcc(refs/users/aoliva/heads/testme)] [ifcombine] check and extend constants to compare with bitfields

2025-01-13 Thread Alexandre Oliva via Gcc-cvs
https://gcc.gnu.org/g:ca7f266795d806a7effbfd59036b126f1f1cc7ce

commit ca7f266795d806a7effbfd59036b126f1f1cc7ce
Author: Alexandre Oliva 
Date:   Mon Jan 13 14:53:25 2025 -0300

[ifcombine] check and extend constants to compare with bitfields

Add logic to check and extend constants compared with bitfields, so
that fields are only compared with constants they could actually
equal.  This involves making sure the signedness doesn't change
between loads and conversions before shifts: we'd need to carry a lot
more data to deal with all the possibilities.

(IIRC we had logic that implicitly dealt with that when compare
constants were represented as typed trees, but after the rewrite to
represent them as wide_ints, the logic seemed superfluous.  It wasn't.)

While at that, I've robustified decode_field_reference to use local
variables throughout, to modify the out parms only when we're about to
return non-NULL, and to drop the unused case of NULL pand_mask, that
had a latent failure to detect signbit masking.


for  gcc/ChangeLog

PR tree-optimization/118456
* gimple-fold.cc (decode_field_reference): Punt if shifting
after changing signedness.  Rebustify to set out parms only
when returning non-NULL.
(fold_truth_andor_for_ifcombine): Check extension bits in
constants before clipping.  Add complementary assert on
r_const's not being set when l_const isn't.

for  gcc/testsuite/ChangeLog

PR tree-optimization/118456
* gcc.dg/field-merge-21.c: New.
* gcc.dg/field-merge-22.c: New.

Diff:
---
 gcc/gimple-fold.cc| 152 +-
 gcc/testsuite/gcc.dg/field-merge-21.c |  52 
 gcc/testsuite/gcc.dg/field-merge-22.c |  30 +++
 3 files changed, 178 insertions(+), 56 deletions(-)

diff --git a/gcc/gimple-fold.cc b/gcc/gimple-fold.cc
index 93ed8b3abb05..fb5a20361950 100644
--- a/gcc/gimple-fold.cc
+++ b/gcc/gimple-fold.cc
@@ -7510,8 +7510,7 @@ gimple_binop_def_p (enum tree_code code, tree t, tree 
op[2])
*PREVERSEP is set to the storage order of the field.
 
*PAND_MASK is set to the mask found in a BIT_AND_EXPR, if any.  If
-   PAND_MASK *is NULL, BIT_AND_EXPR is not recognized.  If *PAND_MASK
-   is initially set to a mask with nonzero precision, that mask is
+   *PAND_MASK is initially set to a mask with nonzero precision, that mask is
combined with the found mask, or adjusted in precision to match.
 
*PSIGNBIT is set to TRUE if, before clipping to *PBITSIZE, the mask
@@ -7539,7 +7538,7 @@ decode_field_reference (tree *pexp, HOST_WIDE_INT 
*pbitsize,
bool *punsignedp, bool *preversep, bool *pvolatilep,
wide_int *pand_mask, bool *psignbit,
bool *xor_p, tree *xor_cmp_op, wide_int *xor_pand_mask,
-   gimple **load, location_t loc[4])
+   gimple **loadp, location_t loc[4])
 {
   tree exp = *pexp;
   tree outer_type = 0;
@@ -7549,9 +7548,11 @@ decode_field_reference (tree *pexp, HOST_WIDE_INT 
*pbitsize,
   tree res_ops[2];
   machine_mode mode;
   bool convert_before_shift = false;
-
-  *load = NULL;
-  *psignbit = false;
+  bool signbit = false;
+  bool xorp = false;
+  tree xor_op;
+  wide_int xor_mask;
+  gimple *load = NULL;
 
   /* All the optimizations using this function assume integer fields.
  There are problems with FP fields since the type_for_size call
@@ -7576,7 +7577,7 @@ decode_field_reference (tree *pexp, HOST_WIDE_INT 
*pbitsize,
 
   /* Recognize and save a masking operation.  Combine it with an
  incoming mask.  */
-  if (pand_mask && gimple_binop_def_p (BIT_AND_EXPR, exp, res_ops)
+  if (gimple_binop_def_p (BIT_AND_EXPR, exp, res_ops)
   && TREE_CODE (res_ops[1]) == INTEGER_CST)
 {
   loc[1] = gimple_location (SSA_NAME_DEF_STMT (exp));
@@ -7596,7 +7597,7 @@ decode_field_reference (tree *pexp, HOST_WIDE_INT 
*pbitsize,
and_mask &= wide_int::from (*pand_mask, prec_op, UNSIGNED);
}
 }
-  else if (pand_mask)
+  else
 and_mask = *pand_mask;
 
   /* Turn (a ^ b) [!]= 0 into a [!]= b.  */
@@ -7615,10 +7616,10 @@ decode_field_reference (tree *pexp, HOST_WIDE_INT 
*pbitsize,
return NULL_TREE;
   else if (integer_zerop (*xor_cmp_op))
{
- *xor_p = true;
+ xorp = true;
  exp = res_ops[0];
- *xor_cmp_op = *pexp;
- *xor_pand_mask = *pand_mask;
+ xor_op = *pexp;
+ xor_mask = *pand_mask;
}
 }
 
@@ -7646,12 +7647,12 @@ decode_field_reference (tree *pexp, HOST_WIDE_INT 
*pbitsize,
   /* Yet another chance to drop conversions.  This one is allowed to
  match a converting load, subsuming the load identification block
  below.  */
-  if (!outer_type && gimple_convert_def_p (exp, res_ops, load))
+

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

2025-01-13 Thread Jakub Jelinek via Libstdc++-cvs
https://gcc.gnu.org/g:074f598e85b434066965fa130b38f32abcbc4f5e

commit 074f598e85b434066965fa130b38f32abcbc4f5e
Merge: 20e73534b5a3 51f76cd947ae
Author: Jakub Jelinek 
Date:   Mon Jan 13 23:39:41 2025 +0100

Merge commit 'r15-6878-g51f76cd947aeb5fe9889b6fde5830031e292b30a' into 
redhat/gcc-15-branch

Diff:

 MAINTAINERS|2 +-
 gcc/BASE-VER   |2 +-
 gcc/ChangeLog  |   61 +
 gcc/DATESTAMP  |2 +-
 gcc/ada/checks.adb |6 +-
 .../doc/gnat_ugn/platform_specific_information.rst |   19 +-
 gcc/ada/exp_ch4.adb|9 +-
 gcc/ada/exp_dist.adb   |2 +-
 gcc/ada/exp_imgv.adb   |4 +-
 gcc/ada/exp_util.adb   |2 +-
 gcc/ada/gnat_ugn.texi  |   11 +-
 gcc/ada/gnatdll.adb|8 +-
 gcc/ada/libgnarl/a-reatim.adb  |2 +-
 gcc/ada/libgnat/a-coinve.adb   |6 +-
 gcc/ada/libgnat/a-nbnbre.adb   |4 +-
 gcc/ada/libgnat/a-ngcoty.adb   |   22 +-
 gcc/ada/libgnat/a-ngelfu.adb   |2 +-
 gcc/ada/libgnat/a-ngrear.adb   |2 +-
 gcc/ada/libgnat/a-strbou.ads   |   16 +-
 gcc/ada/libgnat/a-strfix.ads   |   16 +-
 gcc/ada/libgnat/a-strsea.adb   |   26 +-
 gcc/ada/libgnat/a-strsea.ads   |8 +-
 gcc/ada/libgnat/a-strsup.ads   |   16 +-
 gcc/ada/libgnat/a-strunb.ads   |   16 +-
 gcc/ada/libgnat/a-strunb__shared.ads   |   16 +-
 gcc/ada/libgnat/g-alleve.adb   |8 +-
 gcc/ada/libgnat/g-spitbo.adb   |4 +-
 gcc/ada/libgnat/s-aridou.adb   |   10 +-
 gcc/ada/libgnat/s-arit32.adb   |2 +-
 gcc/ada/libgnat/s-dourea.ads   |2 +-
 gcc/ada/libgnat/s-genbig.adb   |6 +-
 gcc/ada/libgnat/s-imager.adb   |2 +-
 gcc/ada/libgnat/s-statxd.adb   |6 +-
 gcc/ada/libgnat/s-valrea.adb   |5 +
 gcc/ada/libgnat/s-widthi.adb   |8 +-
 gcc/ada/mdll.adb   |   13 +-
 gcc/ada/par-ch3.adb|   18 +-
 gcc/ada/par-ch4.adb|   52 +-
 gcc/ada/sem_aggr.adb   |   11 +-
 gcc/ada/sem_attr.adb   |4 +-
 gcc/ada/sem_ch10.adb   |2 +-
 gcc/ada/sem_ch13.adb   |   28 +-
 gcc/ada/sem_ch3.adb|2 +-
 gcc/ada/sem_ch5.adb|   25 +-
 gcc/ada/sem_ch6.adb|4 +-
 gcc/ada/sem_ch7.adb|2 +-
 gcc/ada/sem_dim.adb|4 +-
 gcc/ada/sem_prag.adb   |2 +-
 gcc/ada/sem_res.adb|2 +-
 gcc/ada/sem_util.adb   |5 +-
 gcc/ada/uintp.adb  |   12 +-
 gcc/c-family/ChangeLog |8 +
 gcc/c-family/c-pretty-print.cc |   39 +-
 gcc/c/ChangeLog|   16 +
 gcc/c/c-typeck.cc  |   77 +-
 gcc/config/alpha/alpha.cc  |   67 +-
 gcc/config/alpha/alpha.md  |   18 +-
 gcc/config/i386/i386-expand.cc |   39 +-
 gcc/config/riscv/riscv-vsetvl.cc   |1 +
 gcc/config/riscv/riscv.cc  |7 +-
 gcc/config/riscv/riscv.md  |9 +-
 gcc/cp/ChangeLog   |   16 +
 gcc/cp/module.cc   |   14 +-
 gcc/d/ChangeLog|   43 +
 gcc/d/d-codegen.cc |   37 +-
 gcc/d/d-lang.cc|8 +-
 gcc/d/dmd/MERGE|2 +-
 gcc/d/dmd/README.md|2 +-
 gcc/d/dmd/VERSION  |2 +-
 gcc/d/dmd/astenums.d   |2 +-
 gcc/d/dmd/attrib.d |   30 -
 gcc/d/dmd/attrib.h |3 -
 gcc/d/dmd/canthrow.d   |2 +-
 gcc/d/dmd/clone.d  |   16 +-
 gcc/d/dmd/cond.d   |2 +-
 gcc/d/dmd/constfold.d   

[gcc/redhat/heads/gcc-15-branch] (59 commits) Merge commit 'r15-6878-g51f76cd947aeb5fe9889b6fde5830031e29

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

 074f598e85b4... Merge commit 'r15-6878-g51f76cd947aeb5fe9889b6fde5830031e29

It previously pointed to:

 20e73534b5a3... Merge commit 'r15-6820-gd64ca15351029164bac30b49fb3c4f9723e

Diff:

Summary of changes (added commits):
---

  074f598... Merge commit 'r15-6878-g51f76cd947aeb5fe9889b6fde5830031e29
  51f76cd... Fix typos in show_attr. (*)
  a9ebf24... RISC-V: Remove zba check in bitwise and ashift reassociatio (*)
  a52812a... libphobos: Bump soname to version 6 [PR117701] (*)
  a1a14ce... Fix build for STORE_FLAG_VALUE<0 targets [PR118418] (*)
  107d5d6... RISC-V: Improve bitwise and ashift reassociation for single (*)
  8d577a0... RISC-V: Fix the result error caused by not updating ratio w (*)
  7102620... RISC-V: fix thinko in riscv_register_move_cost () (*)
  2ea4801... Accept commas between clauses in OpenMP declare variant (*)
  ecf688e... RISC-V: Fix program logic errors caused by data truncation  (*)
  655a8a0... Add missing target directive in OpenMP dispatch Fortran run (*)
  7cd4de6... PR modula2/118453: Subranges types do not use virtual token (*)
  d23d338... [PR rtl-optimization/107455] Eliminate unnecessary constant (*)
  52e4ede... [ifcombine] propagate signbit mask to XOR right-hand operan (*)
  41a5a97... expr: Fix up the divmod cost debugging note [PR115910] (*)
  539fc49... MAINTAINERS: Make contrib/check-MAINTAINERS.py happy (*)
  0cf06bf... ada: Update gnatdll documentation (-b option removed) (*)
  1a82657... ada: Cleanup preanalysis of static expressions (part 5) (*)
  2e0b086... ada: Fix relocatable DLL creation with gnatdll (*)
  492aae1... ada: Remove redundant parentheses inside unary operators (c (*)
  5fd925b... ada: Cleanup preanalysis of static expressions (part 4) (*)
  686bd4e... ada: Warn about redundant parentheses inside unary operator (*)
  34943af... ada: Remove redundant parentheses inside unary operators in (*)
  94a7543... ada: Remove redundant parentheses inside unary operators (*)
  ef4448e... ada: Fix spurious warning about redundant parentheses in ra (*)
  c6989fb... ada: Unbounded recursion on character aggregates with predi (*)
  f9d22b7... ada: Simplify expansion of negative membership operator (*)
  518fd9e... ada: Warn about redundant parentheses in upper range bounds (*)
  d2e3635... ada: Add more commentary to System.Val_Real.Large_Powfive (*)
  26b649b... ada: Fix parsing of raise expressions with no parens (*)
  d3904a3... tree-optimization/117119 - ICE with int128 IV in dataref an (*)
  c0c47fc... Un-XFAIL 'dg-note's in 'gfortran.dg/goacc/routine-external- (*)
  017c45f... Bump BASE-VER to 14.0.1 now that we are in stage4. (*)
  9100be5... lto: Pass cache checksum by reference [PR118181] (*)
  89ebb88... lto: Fix empty fnctl.h build error with MinGW. (*)
  0e05b79... Refactor ix86_expand_vecop_qihi2. (*)
  9c387a9... [PATCH] crc: Fix up some crc related wrong code issues [PR1 (*)
  422c588... Daily bump. (*)
  a2e540b... d: Merge dmd, druntime c7902293d7, phobos 03aeafd20 (*)
  f4fa0b7... Dump all symbol attributes in show_attr. (*)
  0dd21bc... d: Merge upstream dmd, druntime c57da0cf59, phobos ad8ee558 (*)
  a236f70... c: UX improvements to 'too {few,many} arguments' errors (v5 (*)
  f8eda60... Fortran: implement F2018 intrinsic OUT_OF_RANGE [PR115788] (*)
  ed8cd42... Alpha: Fix a block move pessimisation with zero-extension a (*)
  4e55721... Alpha: Optimize block moves coming from longword-aligned so (*)
  19fdb9f... Alpha: Always respect -mbwx, -mcix, -mfix, -mmax, and their (*)
  3cf0e6a... Alpha: Restore frame pointer last in `builtin_longjmp' [PR6 (*)
  4686116... Alpha: Add memory clobbers to `builtin_longjmp' expansion (*)
  40754a3... Fix union member access for EXEC_INQUIRE. (*)
  bedf26c... More memory leak fixes (*)
  4b29be7... testsuite: The expect framework might introduce CR in outpu (*)
  4b0ef49... testsuite: libstdc++: Use effective-target libatomic (*)
  851e188... c-pretty-print.cc (pp_c_tree_decl_identifier): Strip privat (*)
  c1729df... final: Fix get_attr_length for asm goto [PR118411] (*)
  550f1a4... Daily bump. (*)
  c9f7090... d: Merge upstream dmd, druntime 82a5d2a7c4, phobos dbc09d82 (*)
  292be68... libphobos: Merge upstream phobos 2a730adc0 (*)
  d6d7e02... c++/modules: Handle chaining already-imported local types [ (*)
  6528646... Fortran: Fix location_t in gfc_get_extern_function_decl; su (*)

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


[gcc r15-6879] PR modula2/116557: Remove physical address from COPYING.FDL

2025-01-13 Thread Gaius Mulley via Gcc-cvs
https://gcc.gnu.org/g:9a4bb95a4e68b6f90a16f337b0b4cdb9af957ab1

commit r15-6879-g9a4bb95a4e68b6f90a16f337b0b4cdb9af957ab1
Author: Gaius Mulley 
Date:   Mon Jan 13 22:58:00 2025 +

PR modula2/116557: Remove physical address from COPYING.FDL

This patch removes the physical address from the COPYING.FDL and
replaces it with a URL.

gcc/m2/ChangeLog:

PR modula2/116557
* COPYING.FDL: Remove physical address and replace with a URL.

Signed-off-by: Gaius Mulley 

Diff:
---
 gcc/m2/COPYING.FDL | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/m2/COPYING.FDL b/gcc/m2/COPYING.FDL
index 99703c971a4f..60725095dd91 100644
--- a/gcc/m2/COPYING.FDL
+++ b/gcc/m2/COPYING.FDL
@@ -3,7 +3,7 @@
 
 
  Copyright (C) 2000-2025 Free Software Foundation, Inc.
- 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ .
  Everyone is permitted to copy and distribute verbatim copies
  of this license document, but changing it is not allowed.


[gcc(refs/users/aoliva/heads/testme)] [ifcombine] check and extend constants to compare with bitfields

2025-01-13 Thread Alexandre Oliva via Gcc-cvs
https://gcc.gnu.org/g:23364e8369a264e58a051ea74a9077eef3d27ae6

commit 23364e8369a264e58a051ea74a9077eef3d27ae6
Author: Alexandre Oliva 
Date:   Mon Jan 13 14:53:25 2025 -0300

[ifcombine] check and extend constants to compare with bitfields

Add logic to check and extend constants compared with bitfields, so
that fields are only compared with constants they could actually
equal.  This involves making sure the signedness doesn't change
between loads and conversions before shifts: we'd need to carry a lot
more data to deal with all the possibilities.

(IIRC we had logic that implicitly dealt with that when compare
constants were represented as typed trees, but after the rewrite to
represent them as wide_ints, the logic seemed superfluous.  It wasn't.)

While at that, I've robustified decode_field_reference to use local
variables throughout, to modify the out parms only when we're about to
return non-NULL, and to drop the unused case of NULL pand_mask, that
had a latent failure to detect signbit masking.


for  gcc/ChangeLog

PR tree-optimization/118456
* gimple-fold.cc (decode_field_reference): Punt if shifting
after changing signedness.  Rebustify to set out parms only
when returning non-NULL.
(fold_truth_andor_for_ifcombine): Check extension bits in
constants before clipping.  Add complementary assert on
r_const's not being set when l_const isn't.

for  gcc/testsuite/ChangeLog

PR tree-optimization/118456
* gcc.dg/field-merge-21.c: New.
* gcc.dg/field-merge-22.c: New.

Diff:
---
 gcc/gimple-fold.cc| 153 +-
 gcc/testsuite/gcc.dg/field-merge-21.c |  52 
 gcc/testsuite/gcc.dg/field-merge-22.c |  30 +++
 3 files changed, 179 insertions(+), 56 deletions(-)

diff --git a/gcc/gimple-fold.cc b/gcc/gimple-fold.cc
index 93ed8b3abb05..60d40b1b0d04 100644
--- a/gcc/gimple-fold.cc
+++ b/gcc/gimple-fold.cc
@@ -7510,8 +7510,7 @@ gimple_binop_def_p (enum tree_code code, tree t, tree 
op[2])
*PREVERSEP is set to the storage order of the field.
 
*PAND_MASK is set to the mask found in a BIT_AND_EXPR, if any.  If
-   PAND_MASK *is NULL, BIT_AND_EXPR is not recognized.  If *PAND_MASK
-   is initially set to a mask with nonzero precision, that mask is
+   *PAND_MASK is initially set to a mask with nonzero precision, that mask is
combined with the found mask, or adjusted in precision to match.
 
*PSIGNBIT is set to TRUE if, before clipping to *PBITSIZE, the mask
@@ -7539,7 +7538,7 @@ decode_field_reference (tree *pexp, HOST_WIDE_INT 
*pbitsize,
bool *punsignedp, bool *preversep, bool *pvolatilep,
wide_int *pand_mask, bool *psignbit,
bool *xor_p, tree *xor_cmp_op, wide_int *xor_pand_mask,
-   gimple **load, location_t loc[4])
+   gimple **loadp, location_t loc[4])
 {
   tree exp = *pexp;
   tree outer_type = 0;
@@ -7549,9 +7548,11 @@ decode_field_reference (tree *pexp, HOST_WIDE_INT 
*pbitsize,
   tree res_ops[2];
   machine_mode mode;
   bool convert_before_shift = false;
-
-  *load = NULL;
-  *psignbit = false;
+  bool signbit = false;
+  bool xorp = false;
+  tree xor_op;
+  wide_int xor_mask;
+  gimple *load = NULL;
 
   /* All the optimizations using this function assume integer fields.
  There are problems with FP fields since the type_for_size call
@@ -7576,7 +7577,7 @@ decode_field_reference (tree *pexp, HOST_WIDE_INT 
*pbitsize,
 
   /* Recognize and save a masking operation.  Combine it with an
  incoming mask.  */
-  if (pand_mask && gimple_binop_def_p (BIT_AND_EXPR, exp, res_ops)
+  if (gimple_binop_def_p (BIT_AND_EXPR, exp, res_ops)
   && TREE_CODE (res_ops[1]) == INTEGER_CST)
 {
   loc[1] = gimple_location (SSA_NAME_DEF_STMT (exp));
@@ -7596,7 +7597,7 @@ decode_field_reference (tree *pexp, HOST_WIDE_INT 
*pbitsize,
and_mask &= wide_int::from (*pand_mask, prec_op, UNSIGNED);
}
 }
-  else if (pand_mask)
+  else
 and_mask = *pand_mask;
 
   /* Turn (a ^ b) [!]= 0 into a [!]= b.  */
@@ -7615,10 +7616,10 @@ decode_field_reference (tree *pexp, HOST_WIDE_INT 
*pbitsize,
return NULL_TREE;
   else if (integer_zerop (*xor_cmp_op))
{
- *xor_p = true;
+ xorp = true;
  exp = res_ops[0];
- *xor_cmp_op = *pexp;
- *xor_pand_mask = *pand_mask;
+ xor_op = *pexp;
+ xor_mask = *pand_mask;
}
 }
 
@@ -7646,12 +7647,12 @@ decode_field_reference (tree *pexp, HOST_WIDE_INT 
*pbitsize,
   /* Yet another chance to drop conversions.  This one is allowed to
  match a converting load, subsuming the load identification block
  below.  */
-  if (!outer_type && gimple_convert_def_p (exp, res_ops, load))
+

[gcc/aoliva/heads/testme] [ifcombine] check and extend constants to compare with bitf

2025-01-13 Thread Alexandre Oliva via Gcc-cvs
The branch 'aoliva/heads/testme' was updated to point to:

 23364e8369a2... [ifcombine] check and extend constants to compare with bitf

It previously pointed to:

 ca7f266795d8... [ifcombine] check and extend constants to compare with bitf

Diff:

!!! WARNING: THE FOLLOWING COMMITS ARE NO LONGER ACCESSIBLE (LOST):
---

  ca7f266... [ifcombine] check and extend constants to compare with bitf


Summary of changes (added commits):
---

  23364e8... [ifcombine] check and extend constants to compare with bitf


[gcc r15-6880] RISC-V: testsuite: Skip test with -flto

2025-01-13 Thread Jeff Law via Gcc-cvs
https://gcc.gnu.org/g:1f6453684696b1c18899cbbecd4bd5ed4ae22476

commit r15-6880-g1f6453684696b1c18899cbbecd4bd5ed4ae22476
Author: Robin Dapp 
Date:   Mon Jan 13 16:26:24 2025 -0700

RISC-V: testsuite: Skip test with -flto

Hi,

the zbb-rol-ror and stack_save_restore tests use the -fno-lto option and
scan the final assembly.  For an invocation like -flto ... -fno-lto the
output file we scan is still something like
  zbb-rol-ror-09.ltrans0.ltrans.s.

Therefore skip the tests when "-flto" is present.  This gets rid
of a few UNRESOLVED tests.

Regtested on rv64gcv_zvl512b.  Going to push if the CI agrees.

Regards
 Robin

gcc/testsuite/ChangeLog:

* gcc.target/riscv/stack_save_restore_1.c: Skip for -flto.
* gcc.target/riscv/stack_save_restore_2.c: Ditto.
* gcc.target/riscv/zbb-rol-ror-04.c: Ditto.
* gcc.target/riscv/zbb-rol-ror-05.c: Ditto.
* gcc.target/riscv/zbb-rol-ror-06.c: Ditto.
* gcc.target/riscv/zbb-rol-ror-07.c: Ditto.
* gcc.target/riscv/zbb-rol-ror-08.c: Ditto.
* gcc.target/riscv/zbb-rol-ror-09.c: Ditto.

Diff:
---
 gcc/testsuite/gcc.target/riscv/stack_save_restore_1.c | 3 ++-
 gcc/testsuite/gcc.target/riscv/stack_save_restore_2.c | 3 ++-
 gcc/testsuite/gcc.target/riscv/zbb-rol-ror-04.c   | 4 ++--
 gcc/testsuite/gcc.target/riscv/zbb-rol-ror-05.c   | 4 ++--
 gcc/testsuite/gcc.target/riscv/zbb-rol-ror-06.c   | 4 ++--
 gcc/testsuite/gcc.target/riscv/zbb-rol-ror-07.c   | 4 ++--
 gcc/testsuite/gcc.target/riscv/zbb-rol-ror-08.c   | 4 ++--
 gcc/testsuite/gcc.target/riscv/zbb-rol-ror-09.c   | 4 ++--
 8 files changed, 16 insertions(+), 14 deletions(-)

diff --git a/gcc/testsuite/gcc.target/riscv/stack_save_restore_1.c 
b/gcc/testsuite/gcc.target/riscv/stack_save_restore_1.c
index d8b0668a820f..e0a7c68760a9 100644
--- a/gcc/testsuite/gcc.target/riscv/stack_save_restore_1.c
+++ b/gcc/testsuite/gcc.target/riscv/stack_save_restore_1.c
@@ -1,5 +1,6 @@
 /* { dg-do compile } */
-/* { dg-options "-march=rv64imafc -mabi=lp64f -msave-restore -O2 
-fno-schedule-insns -fno-schedule-insns2 -fno-unroll-loops -fno-peel-loops 
-fno-lto" } */
+/* { dg-options "-march=rv64imafc -mabi=lp64f -msave-restore -O2 
-fno-schedule-insns -fno-schedule-insns2 -fno-unroll-loops -fno-peel-loops" } */
+/* { dg-skip-if "" { *-*-* } { "-flto" } } */
 /* { dg-final { check-function-bodies "**" "" } } */
 
 char my_getchar();
diff --git a/gcc/testsuite/gcc.target/riscv/stack_save_restore_2.c 
b/gcc/testsuite/gcc.target/riscv/stack_save_restore_2.c
index 5f0389243b1f..aadeaa582305 100644
--- a/gcc/testsuite/gcc.target/riscv/stack_save_restore_2.c
+++ b/gcc/testsuite/gcc.target/riscv/stack_save_restore_2.c
@@ -1,5 +1,6 @@
 /* { dg-do compile } */
-/* { dg-options "-march=rv32imafc -mabi=ilp32f -msave-restore -O2 
-fno-schedule-insns -fno-schedule-insns2 -fno-unroll-loops -fno-peel-loops 
-fno-lto" } */
+/* { dg-options "-march=rv32imafc -mabi=ilp32f -msave-restore -O2 
-fno-schedule-insns -fno-schedule-insns2 -fno-unroll-loops -fno-peel-loops" } */
+/* { dg-skip-if "" { *-*-* } { "-flto" } } */
 /* { dg-final { check-function-bodies "**" "" } } */
 
 char my_getchar();
diff --git a/gcc/testsuite/gcc.target/riscv/zbb-rol-ror-04.c 
b/gcc/testsuite/gcc.target/riscv/zbb-rol-ror-04.c
index 28350e5e9371..b413b10ea931 100644
--- a/gcc/testsuite/gcc.target/riscv/zbb-rol-ror-04.c
+++ b/gcc/testsuite/gcc.target/riscv/zbb-rol-ror-04.c
@@ -1,6 +1,6 @@
 /* { dg-do compile } */
-/* { dg-options "-march=rv64gc_zbb -mabi=lp64d -fno-lto -O2" } */
-/* { dg-skip-if "" { *-*-* } { "-g" } } */
+/* { dg-options "-march=rv64gc_zbb -mabi=lp64d -O2" } */
+/* { dg-skip-if "" { *-*-* } { "-g" "-flto" } } */
 /* { dg-final { check-function-bodies "**" "" } } */
 /* { dg-final { scan-assembler-not {\mand} } } */
 
diff --git a/gcc/testsuite/gcc.target/riscv/zbb-rol-ror-05.c 
b/gcc/testsuite/gcc.target/riscv/zbb-rol-ror-05.c
index cc44653acfbd..179477ed93b8 100644
--- a/gcc/testsuite/gcc.target/riscv/zbb-rol-ror-05.c
+++ b/gcc/testsuite/gcc.target/riscv/zbb-rol-ror-05.c
@@ -1,6 +1,6 @@
 /* { dg-do compile } */
-/* { dg-options "-march=rv32gc_zbb -mabi=ilp32 -fno-lto -O2" } */
-/* { dg-skip-if "" { *-*-* } { "-g" } } */
+/* { dg-options "-march=rv32gc_zbb -mabi=ilp32 -O2" } */
+/* { dg-skip-if "" { *-*-* } { "-g" "-flto" } } */
 /* { dg-final { check-function-bodies "**" "" } } */
 /* { dg-final { scan-assembler-not {\mand} } } */
 
diff --git a/gcc/testsuite/gcc.target/riscv/zbb-rol-ror-06.c 
b/gcc/testsuite/gcc.target/riscv/zbb-rol-ror-06.c
index 7a98a5712bfe..b5f0b8b9027c 100644
--- a/gcc/testsuite/gcc.target/riscv/zbb-rol-ror-06.c
+++ b/gcc/testsuite/gcc.target/riscv/zbb-rol-ror-06.c
@@ -1,6 +1,6 @@
 /* { dg-do compile } */
-/* { dg-options "-march=rv64gc_zbb -mabi=lp64d -fno-lto -O2" } */
-/* { dg-skip-if "" { *-*-* } { "-g" } } */
+/* { dg-options "-march=rv64gc_zbb -mabi=lp64d 

[gcc r15-6872] RISC-V: fix thinko in riscv_register_move_cost ()

2025-01-13 Thread Vineet Gupta via Gcc-cvs
https://gcc.gnu.org/g:7102620067eebfbfb895dccd5ddd26870178c83f

commit r15-6872-g7102620067eebfbfb895dccd5ddd26870178c83f
Author: Vineet Gupta 
Date:   Sat Jan 11 11:13:19 2025 -0800

RISC-V: fix thinko in riscv_register_move_cost ()

This seeming benign mistake caused a massive SPEC2017 Cactu regression
(2.1 trillion insn to 2.5 trillion) wiping out all the gains from my
recent sched1 improvement. Thankfully the issue was trivial to fix even
if hard to isolate.

On BPI3:

Before bug
--
|  Performance counter stats for './cactusBSSN_r_base-1':
|
|   4,557,471.02 msec task-clock:u #1.000 CPUs 
utilized
|  1,245  context-switches:u   #0.273 /sec
|  1  cpu-migrations:u #0.000 /sec
|205,376  page-faults:u#   45.064 /sec
|  7,291,944,801,307  cycles:u #1.600 GHz
|  2,134,835,735,951  instructions:u   #0.29  insn 
per cycle
| 10,799,296,738  branches:u   #2.370 M/sec
| 15,308,966  branch-misses:u  #0.14% of 
all branches
|
| 4557.710508078 seconds time elapsed

Bug
---
|  Performance counter stats for './cactusBSSN_r_base-2':
|
|   4,801,813.79 msec task-clock:u #1.000 CPUs 
utilized
|  8,066  context-switches:u   #1.680 /sec
|  1  cpu-migrations:u #0.000 /sec
|203,836  page-faults:u#   42.450 /sec
|  7,682,826,638,790  cycles:u #1.600 GHz
|  2,503,133,291,344  instructions:u   #0.33  insn 
per cycle
   ^
| 10,799,287,796  branches:u   #2.249 M/sec
| 16,641,200  branch-misses:u  #0.15% of 
all branches
|
| 4802.616638386 seconds time elapsed
|

Fix
---
|  Performance counter stats for './cactusBSSN_r_base-3':
|
|   4,556,170.75 msec task-clock:u #1.000 CPUs 
utilized
|  1,739  context-switches:u   #0.382 /sec
|  0  cpu-migrations:u #0.000 /sec
|203,458  page-faults:u#   44.655 /sec
|  7,289,854,613,923  cycles:u #1.600 GHz
|  2,134,854,070,916  instructions:u   #0.29  insn 
per cycle
| 10,799,296,807  branches:u   #2.370 M/sec
| 15,403,357  branch-misses:u  #0.14% of 
all branches
|
| 4556.445490123 seconds time elapsed

Fixes: 46888571d242 ("RISC-V: Add cr and cf constraint")
Signed-off-by: Vineet Gupta 

gcc/ChangeLog:
* config/riscv/riscv.cc (riscv_register_move_cost): Remove buggy
check.

Diff:
---
 gcc/config/riscv/riscv.cc | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc
index 3b5712429e46..a03b35bb9cfd 100644
--- a/gcc/config/riscv/riscv.cc
+++ b/gcc/config/riscv/riscv.cc
@@ -9591,8 +9591,7 @@ riscv_register_move_cost (machine_mode mode,
   bool from_is_gpr = from == GR_REGS || from == RVC_GR_REGS;
   bool to_is_fpr = to == FP_REGS || to == RVC_FP_REGS;
   bool to_is_gpr = to == GR_REGS || to == RVC_GR_REGS;
-  if ((from_is_fpr && to == to_is_gpr) ||
-  (from_is_gpr && to_is_fpr))
+  if ((from_is_fpr && to_is_gpr) || (from_is_gpr && to_is_fpr))
 return tune_param->fmv_cost;
 
   if (from == V_REGS)


[gcc r15-6873] RISC-V: Fix the result error caused by not updating ratio when using "use_max_sew" to merge vsetvl

2025-01-13 Thread Jeff Law via Gcc-cvs
https://gcc.gnu.org/g:8d577a01cdbe02a23724b710b579b7811c983c33

commit r15-6873-g8d577a01cdbe02a23724b710b579b7811c983c33
Author: Jin Ma 
Date:   Mon Jan 13 11:15:55 2025 -0700

RISC-V: Fix the result error caused by not updating ratio when using 
"use_max_sew" to merge vsetvl

When the vsetvl instructions of the two RVV instructions are merged
using "use_max_sew", it is possible to update the sew of prev if
prev.sew < next.sew, but keep the original ratio, which is obviously
wrong. when the subsequent instructions are equal to the wrong ratio,
it is possible to generate the wrong "vsetvli zero,zero" instruction,
which will lead to unknown avl.

gcc/ChangeLog:

* config/riscv/riscv-vsetvl.cc (demand_system::use_max_sew): Also
set the ratio for PREV.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/base/bug-10.c: New test.

Diff:
---
 gcc/config/riscv/riscv-vsetvl.cc |  1 +
 gcc/testsuite/gcc.target/riscv/rvv/base/bug-10.c | 14 ++
 2 files changed, 15 insertions(+)

diff --git a/gcc/config/riscv/riscv-vsetvl.cc b/gcc/config/riscv/riscv-vsetvl.cc
index 851e52a20ba6..e9de21787dda 100644
--- a/gcc/config/riscv/riscv-vsetvl.cc
+++ b/gcc/config/riscv/riscv-vsetvl.cc
@@ -1722,6 +1722,7 @@ private:
   {
 int max_sew = MAX (prev.get_sew (), next.get_sew ());
 prev.set_sew (max_sew);
+prev.set_ratio (calculate_ratio (prev.get_sew (), prev.get_vlmul ()));
 use_min_of_max_sew (prev, next);
   }
   inline void use_next_sew_lmul (vsetvl_info &prev, const vsetvl_info &next)
diff --git a/gcc/testsuite/gcc.target/riscv/rvv/base/bug-10.c 
b/gcc/testsuite/gcc.target/riscv/rvv/base/bug-10.c
new file mode 100644
index ..af3a8610d63f
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/rvv/base/bug-10.c
@@ -0,0 +1,14 @@
+/* { dg-do compile { target { rv64 } } } */
+/* { dg-options " -march=rv64gcv_zvfh -mabi=lp64d -O2 
--param=vsetvl-strategy=optim -fno-schedule-insns  -fno-schedule-insns2 
-fno-schedule-fusion " } */
+
+#include 
+
+void
+foo (uint8_t *ptr, vfloat16m4_t *v1, vuint32m8_t *v2, vuint8m2_t *v3, size_t 
vl)
+{
+  *v1 = __riscv_vfmv_s_f_f16m4 (1, vl);
+  *v2 = __riscv_vmv_s_x_u32m8 (2963090659u, vl);
+  *v3 = __riscv_vsll_vx_u8m2 (__riscv_vid_v_u8m2 (vl), 2, vl);
+}
+
+/* { dg-final { scan-assembler-not {vsetvli.*zero,zero} } }*/


[gcc r15-6876] libphobos: Bump soname to version 6 [PR117701]

2025-01-13 Thread Iain Buclaw via Gcc-cvs
https://gcc.gnu.org/g:a52812a65cc10ef604100162c7c97ad7f4b37214

commit r15-6876-ga52812a65cc10ef604100162c7c97ad7f4b37214
Author: Iain Buclaw 
Date:   Mon Jan 13 20:52:49 2025 +0100

libphobos: Bump soname to version 6 [PR117701]

Each major release is not binary compatible with the previous.

PR d/117701

libphobos/ChangeLog:

* configure: Regenerate.
* configure.ac (libtool_VERSION): Update to 6:0:0.

Diff:
---
 libphobos/configure| 2 +-
 libphobos/configure.ac | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/libphobos/configure b/libphobos/configure
index 9b6a41879d36..b9fecbc0175e 100755
--- a/libphobos/configure
+++ b/libphobos/configure
@@ -15741,7 +15741,7 @@ SPEC_PHOBOS_DEPS="$LIBS"
 
 
 # Libdruntime / phobos soname version
-libtool_VERSION=5:0:0
+libtool_VERSION=6:0:0
 
 
 # Set default flags (after DRUNTIME_WERROR!)
diff --git a/libphobos/configure.ac b/libphobos/configure.ac
index 9fcd34504827..92449feb7e95 100644
--- a/libphobos/configure.ac
+++ b/libphobos/configure.ac
@@ -258,7 +258,7 @@ SPEC_PHOBOS_DEPS="$LIBS"
 AC_SUBST(SPEC_PHOBOS_DEPS)
 
 # Libdruntime / phobos soname version
-libtool_VERSION=5:0:0
+libtool_VERSION=6:0:0
 AC_SUBST(libtool_VERSION)
 
 # Set default flags (after DRUNTIME_WERROR!)


[gcc r15-6881] RISC-V: Disallow negative step for interleaving [PR117682]

2025-01-13 Thread Jeff Law via Gcc-cvs
https://gcc.gnu.org/g:7b815107f403c526b7e201ca00494f06d1c20768

commit r15-6881-g7b815107f403c526b7e201ca00494f06d1c20768
Author: Robin Dapp 
Date:   Mon Jan 13 17:09:35 2025 -0700

RISC-V: Disallow negative step for interleaving [PR117682]

Hi,

in PR117682 we build an interleaving pattern

  { 1, 201, 209, 25, 161, 105, 113, 185, 65, 9,
17, 89, 225, 169, 177, 249, 129, 73, 81, 153,
33, 233, 241, 57, 193, 137, 145, 217, 97, 41,
49, 121 };

with negative step expecting wraparound semantics due to -fwrapv.

For building interleaved patterns we have an optimization that
does e.g.
  {1, 209, ...} = { 1, 0, 209, 0, ...}
and
  {201, 25, ...} >> 8 = { 0, 201, 0, 25, ...}
and IORs those.

The optimization only works if the lowpart bits are zero.  When
overflowing e.g. with a negative step we cannot guarantee this.

This patch makes us fall back to the generic merge handling for negative
steps.

I'm not 100% certain we're good even for positive steps.  If the
step or the vector length is large enough we'd still overflow and
have non-zero lower bits.  I haven't seen this happen during my
testing, though and the patch doesn't make things worse, so...

Regtested on rv64gcv_zvl512b.  Let's see what the CI says.

Regards
 Robin

PR target/117682

gcc/ChangeLog:

* config/riscv/riscv-v.cc (expand_const_vector): Fall back to
merging if either step is negative.

gcc/testsuite/ChangeLog:

* gcc.target/riscv/rvv/autovec/pr117682.c: New test.

Diff:
---
 gcc/config/riscv/riscv-v.cc   | 11 +--
 gcc/testsuite/gcc.target/riscv/rvv/autovec/pr117682.c | 15 +++
 2 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/gcc/config/riscv/riscv-v.cc b/gcc/config/riscv/riscv-v.cc
index 7f4ce2b09300..9926a7b63bb5 100644
--- a/gcc/config/riscv/riscv-v.cc
+++ b/gcc/config/riscv/riscv-v.cc
@@ -1478,13 +1478,20 @@ expand_const_vector (rtx target, rtx src)
 
 can be interpreted into:
 
- EEW = 32, { 2, 4, ... }  */
+ EEW = 32, { 2, 4, ... }.
+
+This only works as long as the larger type does not overflow
+as we can't guarantee a zero value for each second element
+of the sequence with smaller EEW.
+??? For now we assume that no overflow happens with positive
+steps and forbid negative steps altogether.  */
  unsigned int new_smode_bitsize = builder.inner_bits_size () * 2;
  scalar_int_mode new_smode;
  machine_mode new_mode;
  poly_uint64 new_nunits
= exact_div (GET_MODE_NUNITS (builder.mode ()), 2);
- if (int_mode_for_size (new_smode_bitsize, 0).exists (&new_smode)
+ if (known_ge (step1, 0) && known_ge (step2, 0)
+ && int_mode_for_size (new_smode_bitsize, 0).exists (&new_smode)
  && get_vector_mode (new_smode, new_nunits).exists (&new_mode))
{
  rtx tmp1 = gen_reg_rtx (new_mode);
diff --git a/gcc/testsuite/gcc.target/riscv/rvv/autovec/pr117682.c 
b/gcc/testsuite/gcc.target/riscv/rvv/autovec/pr117682.c
new file mode 100644
index ..bbbcfcce6262
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/rvv/autovec/pr117682.c
@@ -0,0 +1,15 @@
+/* { dg-do run } */
+/* { dg-require-effective-target riscv_v } */
+/* { dg-require-effective-target rvv_zvl256b_ok } */
+/* { dg-options "-march=rv64gcv -mabi=lp64d -mrvv-vector-bits=zvl -fwrapv" } */
+
+signed char a = 9;
+int main() {
+  for (char e = 0; e < 20; e++)
+for (char f = 0; f < 7; f++)
+  a *= 57;
+
+  if (a != 41)
+__builtin_abort ();
+}
+


[gcc r15-6883] rs6000: Add clobber and guard for vsx_stxvd2x4_le_const [PR116030]

2025-01-13 Thread Peter Bergner via Gcc-cvs
https://gcc.gnu.org/g:f12bb6c26b86c616e4de8c542804cb5b5c9ebdc6

commit r15-6883-gf12bb6c26b86c616e4de8c542804cb5b5c9ebdc6
Author: Jiufu Guo 
Date:   Mon Jan 13 18:16:16 2025 -0600

rs6000: Add clobber and guard for vsx_stxvd2x4_le_const [PR116030]

Previously, vsx_stxvd2x4_le_const_ was introduced for 'split1' pass,
so it is guarded by "can_create_pseudo_p ()".  While it would be possible
to match the pattern of this insn during/after RA, this insn could be
updated to make it work for split pass after RA.

And this insn would not be the best choice if the address has alignment like
"&(-16)", so "!altivec_indexed_or_indirect_operand" is added to guard this 
insn.

2025-01-13  Jiufu Guo  

gcc/
PR target/116030
* config/rs6000/vsx.md (vsx_stxvd2x4_le_const_): Add clobber
and guard with !altivec_indexed_or_indirect_operand.

gcc/testsuite/
PR target/116030
* gcc.target/powerpc/pr116030.c: New test.

Diff:
---
 gcc/config/rs6000/vsx.md| 10 ++
 gcc/testsuite/gcc.target/powerpc/pr116030.c | 22 ++
 2 files changed, 28 insertions(+), 4 deletions(-)

diff --git a/gcc/config/rs6000/vsx.md b/gcc/config/rs6000/vsx.md
index d4e0190484a0..dd3573b80868 100644
--- a/gcc/config/rs6000/vsx.md
+++ b/gcc/config/rs6000/vsx.md
@@ -3453,12 +3453,13 @@
 
 (define_insn_and_split "vsx_stxvd2x4_le_const_"
   [(set (match_operand:VSX_W 0 "memory_operand" "=Z")
-   (match_operand:VSX_W 1 "immediate_operand" "W"))]
+   (match_operand:VSX_W 1 "immediate_operand" "W"))
+   (clobber (match_scratch:VSX_W 2 "=wa"))]
   "!BYTES_BIG_ENDIAN
&& VECTOR_MEM_VSX_P (mode)
&& !TARGET_P9_VECTOR
-   && const_vec_duplicate_p (operands[1])
-   && can_create_pseudo_p ()"
+   && !altivec_indexed_or_indirect_operand (operands[0], mode)
+   && const_vec_duplicate_p (operands[1])"
   "#"
   "&& 1"
   [(set (match_dup 2)
@@ -3471,7 +3472,8 @@
 {
   /* Here all the constants must be loaded without memory.  */
   gcc_assert (easy_altivec_constant (operands[1], mode));
-  operands[2] = gen_reg_rtx (mode);
+  if (GET_CODE (operands[2]) == SCRATCH)
+operands[2] = gen_reg_rtx (mode);
 }
   [(set_attr "type" "vecstore")
(set_attr "length" "8")])
diff --git a/gcc/testsuite/gcc.target/powerpc/pr116030.c 
b/gcc/testsuite/gcc.target/powerpc/pr116030.c
new file mode 100644
index ..da27106a5a75
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/pr116030.c
@@ -0,0 +1,22 @@
+/* { dg-do compile } */
+/* { dg-options "-mdejagnu-cpu=power8 -Os -fno-forward-propagate 
-ftrivial-auto-var-init=zero" } */
+/* { dg-require-effective-target dfp } */
+
+/* Verify we do not ICE on the tests below.  */
+
+/* { dg-final { scan-assembler-not "rldicr" { target { le } } } } */
+/* { dg-final { scan-assembler-not "stxvd2x" { target { le } } } } */
+
+union U128
+{
+  _Decimal128 d;
+  unsigned long long int u[2];
+};
+
+union U128
+foo ()
+{
+  volatile union U128 u128;
+  u128.d = 0.99e+39DL;
+  return u128;
+}


[gcc r15-6884] RISC-V: Expand shift count in Xmode in interleave pattern.

2025-01-13 Thread Jeff Law via Gcc-cvs
https://gcc.gnu.org/g:c864ffe615424de08abfe271fee7dc815c93bd21

commit r15-6884-gc864ffe615424de08abfe271fee7dc815c93bd21
Author: Robin Dapp 
Date:   Mon Jan 13 17:19:42 2025 -0700

RISC-V: Expand shift count in Xmode in interleave pattern.

Hi,

currently ssa-dse-1.C ICEs because expand_simple_binop returns NULL
when building the scalar that is used to IOR two interleaving
sequences.

That's because we try to emit a shift in HImode.  This patch shifts in
Xmode and then lowpart-subregs the result to HImode.

Regtested on rv64gcv_zvl512b.

Regards
 Robin

gcc/ChangeLog:

* config/riscv/riscv-v.cc (expand_const_vector): Shift in Xmode.

Diff:
---
 gcc/config/riscv/riscv-v.cc | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/gcc/config/riscv/riscv-v.cc b/gcc/config/riscv/riscv-v.cc
index 9926a7b63bb5..3735a5ba6594 100644
--- a/gcc/config/riscv/riscv-v.cc
+++ b/gcc/config/riscv/riscv-v.cc
@@ -1505,10 +1505,11 @@ expand_const_vector (rtx target, rtx src)
{
  /* { 1, 1, 2, 1, ... }.  */
  rtx scalar = expand_simple_binop (
-   new_smode, ASHIFT,
-   gen_int_mode (rtx_to_poly_int64 (base2), new_smode),
-   gen_int_mode (builder.inner_bits_size (), new_smode),
+   Xmode, ASHIFT,
+   gen_int_mode (rtx_to_poly_int64 (base2), Xmode),
+   gen_int_mode (builder.inner_bits_size (), Xmode),
NULL_RTX, false, OPTAB_DIRECT);
+ scalar = simplify_gen_subreg (new_smode, scalar, Xmode, 0);
  rtx tmp2 = gen_reg_rtx (new_mode);
  rtx ior_ops[] = {tmp2, tmp1, scalar};
  emit_vlmax_insn (code_for_pred_scalar (IOR, new_mode),


[gcc r15-6850] ada: Fix parsing of raise expressions with no parens

2025-01-13 Thread Marc Poulhi?s via Gcc-cvs
https://gcc.gnu.org/g:26b649b2d17dccf0f4c3c048f37c49660aad7f71

commit r15-6850-g26b649b2d17dccf0f4c3c048f37c49660aad7f71
Author: Piotr Trojanek 
Date:   Thu Jan 2 17:36:54 2025 +0100

ada: Fix parsing of raise expressions with no parens

According to Ada grammar, raise expression is an expression, but requires
parens to be a simple_expression. We wrongly classified raise expressions
as expressions, because we mishandled a global state variable in the parser.

This patch causes some illegal code to be rejected.

gcc/ada/ChangeLog:

* par-ch4.adb (P_Relation): Prevent Expr_Form to be overwritten when
parsing the raise expression itself.
(P_Simple_Expression): Fix manipulation of Expr_Form.

Diff:
---
 gcc/ada/par-ch4.adb | 10 --
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/gcc/ada/par-ch4.adb b/gcc/ada/par-ch4.adb
index 97f9b7ddeb28..3f8d1f1d2e34 100644
--- a/gcc/ada/par-ch4.adb
+++ b/gcc/ada/par-ch4.adb
@@ -2181,8 +2181,9 @@ package body Ch4 is
   --  First check for raise expression
 
   if Token = Tok_Raise then
+ Node1 := P_Raise_Expression;
  Expr_Form := EF_Non_Simple;
- return P_Raise_Expression;
+ return Node1;
   end if;
 
   --  All other cases
@@ -2415,6 +2416,8 @@ package body Ch4 is
 Node1 := P_Term;
  end if;
 
+ Expr_Form := EF_Simple;
+
  --  In the following, we special-case a sequence of concatenations of
  --  string literals, such as "aaa" & "bbb" & ... & "ccc", with nothing
  --  else mixed in. For such a sequence, we return a tree representing
@@ -2530,11 +2533,6 @@ package body Ch4 is
end;
 end if;
  end;
-
- --  All done, we clearly do not have name or numeric literal so this
- --  is a case of a simple expression which is some other possibility.
-
- Expr_Form := EF_Simple;
   end if;
 
   --  If all extensions are enabled and we have a deep delta aggregate


[gcc r15-6852] ada: Warn about redundant parentheses in upper range bounds

2025-01-13 Thread Marc Poulhi?s via Gcc-cvs
https://gcc.gnu.org/g:518fd9e9b18913997b9ed8120d2a85c7bd3528f9

commit r15-6852-g518fd9e9b18913997b9ed8120d2a85c7bd3528f9
Author: Piotr Trojanek 
Date:   Fri Jan 3 16:02:01 2025 +0100

ada: Warn about redundant parentheses in upper range bounds

Fix a glitch in condition that effectively caused detection of redundant
parentheses in upper range bounds to be dead code.

gcc/ada/ChangeLog:

* par-ch3.adb (P_Discrete_Range): Replace N_Subexpr, which was 
catching
all subexpressions, with kinds that catch nodes that require
parentheses to become "simple expressions".

Diff:
---
 gcc/ada/par-ch3.adb | 10 +++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/gcc/ada/par-ch3.adb b/gcc/ada/par-ch3.adb
index edea67855128..e58e2a2342b0 100644
--- a/gcc/ada/par-ch3.adb
+++ b/gcc/ada/par-ch3.adb
@@ -3070,11 +3070,15 @@ package body Ch3 is
  Check_Simple_Expression (Expr_Node);
  Set_High_Bound (Range_Node, Expr_Node);
 
- --  If Expr_Node (ignoring parentheses) is not a simple expression
- --  then emit a style check.
+ --  If the upper bound doesn't require parentheses, then emit a style
+ --  check. Parentheses that make "expression" syntax nodes a "simple
+ --  expression" are required; we filter those nodes both here and
+ --  inside Check_Xtra_Parens itself.
 
  if Style_Check
-   and then Nkind (Expr_Node) not in N_Op_Boolean | N_Subexpr
+   and then Nkind (Expr_Node) not in N_Membership_Test
+   | N_Op_Boolean
+   | N_Short_Circuit
  then
 Style.Check_Xtra_Parens (Expr_Node);
  end if;


[gcc r15-6853] ada: Simplify expansion of negative membership operator

2025-01-13 Thread Marc Poulhi?s via Gcc-cvs
https://gcc.gnu.org/g:f9d22b7ac734a917f3ee379336ad764ccd6f74ca

commit r15-6853-gf9d22b7ac734a917f3ee379336ad764ccd6f74ca
Author: Piotr Trojanek 
Date:   Mon Jan 6 12:06:59 2025 +0100

ada: Simplify expansion of negative membership operator

Code cleanup; semantics is unaffected.

gcc/ada/ChangeLog:

* exp_ch4.adb: (Expand_N_Not_In): Preserve Alternatives in expanded
membership operator just like preserving Right_Opnd (though only
one of these fields is present at a time).
* par-ch4.adb (P_Membership_Test): Remove redundant setting of 
fields
to their default values.

Diff:
---
 gcc/ada/exp_ch4.adb | 9 +++--
 gcc/ada/par-ch4.adb | 4 +---
 2 files changed, 4 insertions(+), 9 deletions(-)

diff --git a/gcc/ada/exp_ch4.adb b/gcc/ada/exp_ch4.adb
index a7f759fc8a57..82978c775cf2 100644
--- a/gcc/ada/exp_ch4.adb
+++ b/gcc/ada/exp_ch4.adb
@@ -7727,12 +7727,9 @@ package body Exp_Ch4 is
 Make_Op_Not (Loc,
   Right_Opnd =>
 Make_In (Loc,
-  Left_Opnd  => Left_Opnd (N),
-  Right_Opnd => Right_Opnd (N;
-
-  --  If this is a set membership, preserve list of alternatives
-
-  Set_Alternatives (Right_Opnd (N), Alternatives (Original_Node (N)));
+  Left_Opnd=> Left_Opnd (N),
+  Right_Opnd   => Right_Opnd (N),
+  Alternatives => Alternatives (N;
 
   --  We want this to appear as coming from source if original does (see
   --  transformations in Expand_N_In).
diff --git a/gcc/ada/par-ch4.adb b/gcc/ada/par-ch4.adb
index 3f8d1f1d2e34..648a4cf64641 100644
--- a/gcc/ada/par-ch4.adb
+++ b/gcc/ada/par-ch4.adb
@@ -3926,7 +3926,6 @@ package body Ch4 is
   if Token = Tok_Vertical_Bar then
  Error_Msg_Ada_2012_Feature ("set notation", Token_Ptr);
  Set_Alternatives (N, New_List (Alt));
- Set_Right_Opnd   (N, Empty);
 
  --  Loop to accumulate alternatives
 
@@ -3940,8 +3939,7 @@ package body Ch4 is
   --  Not set case
 
   else
- Set_Right_Opnd   (N, Alt);
- Set_Alternatives (N, No_List);
+ Set_Right_Opnd (N, Alt);
   end if;
end P_Membership_Test;


[gcc r15-6851] ada: Add more commentary to System.Val_Real.Large_Powfive

2025-01-13 Thread Marc Poulhi?s via Gcc-cvs
https://gcc.gnu.org/g:d2e3635aa1820346050b85009df82a60cdd8206f

commit r15-6851-gd2e3635aa1820346050b85009df82a60cdd8206f
Author: Eric Botcazou 
Date:   Mon Jan 6 09:09:49 2025 +0100

ada: Add more commentary to System.Val_Real.Large_Powfive

gcc/ada/ChangeLog:

* libgnat/s-valrea.adb (Large_Powfive) [2 parameters]: Add a couple
of additional comments.

Diff:
---
 gcc/ada/libgnat/s-valrea.adb | 5 +
 1 file changed, 5 insertions(+)

diff --git a/gcc/ada/libgnat/s-valrea.adb b/gcc/ada/libgnat/s-valrea.adb
index ed22366840f7..aff694dd7219 100644
--- a/gcc/ada/libgnat/s-valrea.adb
+++ b/gcc/ada/libgnat/s-valrea.adb
@@ -396,6 +396,9 @@ package body System.Val_Real is
begin
   pragma Assert (Exp > Maxexp);
 
+  --  This routine supports any type but it is not necessary to invoke it
+  --  for large types because the above one is sufficient for them.
+
   pragma Warnings (Off, "-gnatw.a");
   pragma Assert (not Is_Large_Type);
   pragma Warnings (On, "-gnatw.a");
@@ -407,6 +410,8 @@ package body System.Val_Real is
   --  its final value does not overflow but, if it's too large, then do not
   --  bother doing it since overflow is just fine. The scaling factor is -3
   --  for every power of 5 above the maximum, in other words division by 8.
+  --  Note that Maxpow is an upper bound of the span of exponents for which
+  --  scaling is needed, but it's OK to apply it even if it is not needed.
 
   if Exp - Maxexp <= Maxpow then
  S := 3 * (Exp - Maxexp);


[gcc r15-6855] ada: Fix spurious warning about redundant parentheses in range bound

2025-01-13 Thread Marc Poulhi?s via Gcc-cvs
https://gcc.gnu.org/g:ef4448e0a0508db63581c27238d39e634268b5a2

commit r15-6855-gef4448e0a0508db63581c27238d39e634268b5a2
Author: Piotr Trojanek 
Date:   Tue Jan 7 10:42:35 2025 +0100

ada: Fix spurious warning about redundant parentheses in range bound

Use the same logic for warning about redundant parentheses in lower and 
upper
bounds of a discrete range. This fixes a spurious warning that, if followed,
would render the code illegal.

gcc/ada/ChangeLog:

* par-ch3.adb (P_Discrete_Range): Detect redundant parentheses in 
the
lower bound like in the upper bound.

Diff:
---
 gcc/ada/par-ch3.adb | 16 +++-
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/gcc/ada/par-ch3.adb b/gcc/ada/par-ch3.adb
index e58e2a2342b0..fe727d7c0946 100644
--- a/gcc/ada/par-ch3.adb
+++ b/gcc/ada/par-ch3.adb
@@ -3061,7 +3061,16 @@ package body Ch3 is
  Range_Node := New_Node (N_Range, Token_Ptr);
  Set_Low_Bound (Range_Node, Expr_Node);
 
- if Style_Check then
+ --  If the bound doesn't require parentheses, then emit a style
+ --  check. Parentheses that change an "expression" syntax node into a
+ --  "simple expression" are required; we filter those nodes both here
+ --  and inside Check_Xtra_Parens itself.
+
+ if Style_Check
+   and then Nkind (Expr_Node) not in N_Membership_Test
+   | N_Op_Boolean
+   | N_Short_Circuit
+ then
 Style.Check_Xtra_Parens (Expr_Node);
  end if;
 
@@ -3070,10 +3079,7 @@ package body Ch3 is
  Check_Simple_Expression (Expr_Node);
  Set_High_Bound (Range_Node, Expr_Node);
 
- --  If the upper bound doesn't require parentheses, then emit a style
- --  check. Parentheses that make "expression" syntax nodes a "simple
- --  expression" are required; we filter those nodes both here and
- --  inside Check_Xtra_Parens itself.
+ --  Check for extra parentheses like for the lower bound
 
  if Style_Check
and then Nkind (Expr_Node) not in N_Membership_Test


[gcc r15-6854] ada: Unbounded recursion on character aggregates with predicated component subtype

2025-01-13 Thread Marc Poulhi?s via Gcc-cvs
https://gcc.gnu.org/g:c6989fbbf2f195e874245409635a856d74bf6945

commit r15-6854-gc6989fbbf2f195e874245409635a856d74bf6945
Author: Gary Dismukes 
Date:   Wed Jan 8 22:51:41 2025 +

ada: Unbounded recursion on character aggregates with predicated component 
subtype

The compiler was recursing endlessly when analyzing an aggregate of
an array type whose component subtype has a static predicate and the
component expressions are static, repeatedly transforming the aggregate
first into a string literal and then back into an aggregate. This is fixed
by suppressing the transformation to a string literal in the case where
the component subtype has predicates.

gcc/ada/ChangeLog:

* sem_aggr.adb (Resolve_Aggregate): Add another condition to 
prevent rewriting
an aggregate whose type is an array of characters, testing for the 
presence of
predicates on the component type.

Diff:
---
 gcc/ada/sem_aggr.adb | 11 ++-
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/gcc/ada/sem_aggr.adb b/gcc/ada/sem_aggr.adb
index 095093cc76bd..f6db5cb97a4a 100644
--- a/gcc/ada/sem_aggr.adb
+++ b/gcc/ada/sem_aggr.adb
@@ -1382,11 +1382,11 @@ package body Sem_Aggr is
 
  --  Do not perform this transformation if this was a string literal
  --  to start with, whose components needed constraint checks, or if
- --  the component type is non-static, because it will require those
- --  checks and be transformed back into an aggregate. If the index
- --  type is not Integer the aggregate may represent a user-defined
- --  string type but the context might need the original type so we
- --  do not perform the transformation at this point.
+ --  the component type is nonstatic or has predicates, because it will
+ --  require those checks and be transformed back into an aggregate.
+ --  If the index type is not Integer, then the aggregate may represent
+ --  a user-defined string type but the context might need the original
+ --  type, so we do not perform the transformation at this point.
 
  if Number_Dimensions (Typ) = 1
and then Is_Standard_Character_Type (Component_Type (Typ))
@@ -1396,6 +1396,7 @@ package body Sem_Aggr is
and then not Is_Bit_Packed_Array (Typ)
and then Nkind (Original_Node (Parent (N))) /= N_String_Literal
and then Is_OK_Static_Subtype (Component_Type (Typ))
+   and then not Has_Predicates (Component_Type (Typ))
and then Base_Type (Etype (First_Index (Typ))) =
   Base_Type (Standard_Integer)
and then not Has_Static_Empty_Array_Bounds (Typ)


[gcc r15-6857] ada: Remove redundant parentheses inside unary operators in comments

2025-01-13 Thread Marc Poulhi?s via Gcc-cvs
https://gcc.gnu.org/g:34943af17e3ed7963bb8b85757e24b300aa03cce

commit r15-6857-g34943af17e3ed7963bb8b85757e24b300aa03cce
Author: Piotr Trojanek 
Date:   Fri Jan 10 00:31:11 2025 +0100

ada: Remove redundant parentheses inside unary operators in comments

GNAT already emits a style warning when redundant parentheses appear inside
logical and short-circuit operators. A similar warning will be soon emitted 
for
unary operators as well. This patch removes the redundant parentheses to 
avoid
future build errors.

gcc/ada/ChangeLog:

* libgnat/s-genbig.adb: Remove redundant parentheses in comments.

Diff:
---
 gcc/ada/libgnat/s-genbig.adb | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/ada/libgnat/s-genbig.adb b/gcc/ada/libgnat/s-genbig.adb
index 82bf3f76fc2e..2780305e042b 100644
--- a/gcc/ada/libgnat/s-genbig.adb
+++ b/gcc/ada/libgnat/s-genbig.adb
@@ -91,7 +91,7 @@ package body System.Generic_Bignums is
   Remainder : out Big_Integer;
   Discard_Quotient  : Boolean := False;
   Discard_Remainder : Boolean := False);
-   --  Returns the Quotient and Remainder from dividing abs (X) by abs (Y). The
+   --  Returns the Quotient and Remainder from dividing abs X by abs Y. The
--  values of X and Y are not modified. If Discard_Quotient is True, then
--  Quotient is undefined on return, and if Discard_Remainder is True, then
--  Remainder is undefined on return. Service routine for Big_Div/Rem/Mod.


[gcc r15-6861] ada: Fix relocatable DLL creation with gnatdll

2025-01-13 Thread Marc Poulhi?s via Gcc-cvs
https://gcc.gnu.org/g:2e0b086f8403e00da964d44039c667d5b1806070

commit r15-6861-g2e0b086f8403e00da964d44039c667d5b1806070
Author: Pascal Obry 
Date:   Fri Jan 10 18:56:55 2025 +0100

ada: Fix relocatable DLL creation with gnatdll

gcc/ada/ChangeLog:

* mdll.adb: For the created DLL to be relocatable we do not want to 
use
the base file name when calling gnatdll.
* gnatdll.adb: Removes option -d which is not working anymore. And
when using a truly relocatable DLL the base-address has no real
meaning. Also reword the usage string for -d as we do not want to
specify relocatable as gnatdll can be used to create both
relocatable and non relocatable DLL.

Diff:
---
 gcc/ada/gnatdll.adb |  8 +---
 gcc/ada/mdll.adb| 13 +
 2 files changed, 6 insertions(+), 15 deletions(-)

diff --git a/gcc/ada/gnatdll.adb b/gcc/ada/gnatdll.adb
index 8881fc91ab4d..0faf79f361b4 100644
--- a/gcc/ada/gnatdll.adb
+++ b/gcc/ada/gnatdll.adb
@@ -134,10 +134,8 @@ procedure Gnatdll is
   P ("   -l file   File contains a list-of-files to be added to "
  & "the library");
   P ("   -e file   Definition file containing exports");
-  P ("   -d file   Put objects in the relocatable dynamic "
+  P ("   -d file   Put objects in the dynamic "
  & "library ");
-  P ("   -b addr   Set base address for the relocatable DLL");
-  P (" default address is " & Default_DLL_Address);
   P ("   -a[addr]  Build non-relocatable DLL at address ");
   P (" if  is not specified use "
  & Default_DLL_Address);
@@ -315,10 +313,6 @@ procedure Gnatdll is
 
Must_Build_Relocatable := False;
 
-when 'b' =>
-   DLL_Address := To_Unbounded_String (Parameter);
-   Must_Build_Relocatable := True;
-
 when 'e' =>
Def_Filename := To_Unbounded_String (Parameter);
 
diff --git a/gcc/ada/mdll.adb b/gcc/ada/mdll.adb
index 281f6a97e5ff..64350ff2ec3b 100644
--- a/gcc/ada/mdll.adb
+++ b/gcc/ada/mdll.adb
@@ -77,10 +77,7 @@ package body MDLL is
   Bas_Opt  : aliased String := "-Wl,--base-file," & Bas_File;
   Lib_Opt  : aliased String := "-mdll";
   Out_Opt  : aliased String := "-o";
-  Adr_Opt  : aliased String :=
-   (if Relocatable
-then ""
-else "-Wl,--image-base=" & Lib_Address);
+  Adr_Opt  : aliased String := "-Wl,--image-base=" & Lib_Address;
   Map_Opt  : aliased String := "-Wl,-Map," & Lib_Filename & ".map";
 
   L_Afiles : Argument_List := Afiles;
@@ -133,7 +130,7 @@ package body MDLL is
  --  2) Build exp from base file
 
  Utl.Dlltool (Def_File, Dll_File, Lib_File,
-  Base_File=> Bas_File,
+  Base_File=> (if Relocatable then "" else Bas_File),
   Exp_Table=> Exp_File,
   Build_Import => False);
 
@@ -148,7 +145,7 @@ package body MDLL is
  --  4) Build new exp from base file and the lib file (.a)
 
  Utl.Dlltool (Def_File, Dll_File, Lib_File,
-  Base_File=> Bas_File,
+  Base_File=> (if Relocatable then "" else Bas_File),
   Exp_Table=> Exp_File,
   Build_Import => Build_Import);
 
@@ -223,7 +220,7 @@ package body MDLL is
  --  2) Build exp from base file
 
  Utl.Dlltool (Def_File, Dll_File, Lib_File,
-  Base_File=> Bas_File,
+  Base_File=> (if Relocatable then "" else Bas_File),
   Exp_Table=> Exp_File,
   Build_Import => False);
 
@@ -247,7 +244,7 @@ package body MDLL is
  --  4) Build new exp from base file and the lib file (.a)
 
  Utl.Dlltool (Def_File, Dll_File, Lib_File,
-  Base_File=> Bas_File,
+  Base_File=> (if Relocatable then "" else Bas_File),
   Exp_Table=> Exp_File,
   Build_Import => Build_Import);


[gcc r15-6856] ada: Remove redundant parentheses inside unary operators

2025-01-13 Thread Marc Poulhi?s via Gcc-cvs
https://gcc.gnu.org/g:94a7543df92bc809c464f8312cab8d914fd3d8fe

commit r15-6856-g94a7543df92bc809c464f8312cab8d914fd3d8fe
Author: Piotr Trojanek 
Date:   Wed Jan 8 13:46:38 2025 +0100

ada: Remove redundant parentheses inside unary operators

GNAT already emits a style warning when redundant parentheses appear inside
logical and short-circuit operators. A similar warning will be soon emitted 
for
unary operators as well. This patch removes the redundant parentheses to 
avoid
future build errors.

gcc/ada/ChangeLog:

* checks.adb, exp_dist.adb, exp_imgv.adb, exp_util.adb,
libgnarl/a-reatim.adb, libgnat/a-coinve.adb, libgnat/a-nbnbre.adb,
libgnat/a-ngcoty.adb, libgnat/a-ngelfu.adb, libgnat/a-ngrear.adb,
libgnat/a-strbou.ads, libgnat/a-strfix.ads, libgnat/a-strsea.adb,
libgnat/a-strsea.ads, libgnat/a-strsup.ads,
libgnat/a-strunb__shared.ads, libgnat/g-alleve.adb,
libgnat/g-spitbo.adb, libgnat/s-aridou.adb, libgnat/s-arit32.adb,
libgnat/s-dourea.ads, libgnat/s-genbig.adb, libgnat/s-imager.adb,
libgnat/s-statxd.adb, libgnat/s-widthi.adb, sem_attr.adb, 
sem_ch10.adb,
sem_ch3.adb, sem_ch6.adb, sem_ch7.adb, sem_dim.adb, sem_prag.adb,
sem_res.adb, uintp.adb: Remove redundant parentheses inside NOT and 
ABS
operators.

Diff:
---
 gcc/ada/checks.adb   |  6 +++---
 gcc/ada/exp_dist.adb |  2 +-
 gcc/ada/exp_imgv.adb |  4 ++--
 gcc/ada/exp_util.adb |  2 +-
 gcc/ada/libgnarl/a-reatim.adb|  2 +-
 gcc/ada/libgnat/a-coinve.adb |  6 +++---
 gcc/ada/libgnat/a-nbnbre.adb |  4 ++--
 gcc/ada/libgnat/a-ngcoty.adb | 22 +++---
 gcc/ada/libgnat/a-ngelfu.adb |  2 +-
 gcc/ada/libgnat/a-ngrear.adb |  2 +-
 gcc/ada/libgnat/a-strbou.ads | 16 
 gcc/ada/libgnat/a-strfix.ads | 16 
 gcc/ada/libgnat/a-strsea.adb | 26 +-
 gcc/ada/libgnat/a-strsea.ads |  8 
 gcc/ada/libgnat/a-strsup.ads | 16 
 gcc/ada/libgnat/a-strunb__shared.ads | 16 
 gcc/ada/libgnat/g-alleve.adb |  8 
 gcc/ada/libgnat/g-spitbo.adb |  4 ++--
 gcc/ada/libgnat/s-aridou.adb | 10 +-
 gcc/ada/libgnat/s-arit32.adb |  2 +-
 gcc/ada/libgnat/s-dourea.ads |  2 +-
 gcc/ada/libgnat/s-genbig.adb |  4 ++--
 gcc/ada/libgnat/s-imager.adb |  2 +-
 gcc/ada/libgnat/s-statxd.adb |  6 +++---
 gcc/ada/libgnat/s-widthi.adb |  8 
 gcc/ada/sem_attr.adb |  4 ++--
 gcc/ada/sem_ch10.adb |  2 +-
 gcc/ada/sem_ch3.adb  |  2 +-
 gcc/ada/sem_ch6.adb  |  4 ++--
 gcc/ada/sem_ch7.adb  |  2 +-
 gcc/ada/sem_dim.adb  |  4 ++--
 gcc/ada/sem_prag.adb |  2 +-
 gcc/ada/sem_res.adb  |  2 +-
 gcc/ada/uintp.adb| 12 ++--
 34 files changed, 115 insertions(+), 115 deletions(-)

diff --git a/gcc/ada/checks.adb b/gcc/ada/checks.adb
index 7a5bc71f36b2..dcfcaa33bcc4 100644
--- a/gcc/ada/checks.adb
+++ b/gcc/ada/checks.adb
@@ -2076,7 +2076,7 @@ package body Checks is
  Lo := Succ (Expr_Type, UR_From_Uint (Ifirst - 1));
  Lo_OK := True;
 
-  elsif abs (Ifirst) < Max_Bound then
+  elsif abs Ifirst < Max_Bound then
  Lo := UR_From_Uint (Ifirst) - Ureal_Half;
  Lo_OK := (Ifirst > 0);
 
@@ -2120,7 +2120,7 @@ package body Checks is
  Hi := Pred (Expr_Type, UR_From_Uint (Ilast + 1));
  Hi_OK := True;
 
-  elsif abs (Ilast) < Max_Bound then
+  elsif abs Ilast < Max_Bound then
  Hi := UR_From_Uint (Ilast) + Ureal_Half;
  Hi_OK := (Ilast < 0);
   else
@@ -6243,7 +6243,7 @@ package body Checks is
   --  do the corresponding optimizations later on when applying the checks.
 
   if Mode in Minimized_Or_Eliminated then
- if not (Overflow_Checks_Suppressed (Etype (N)))
+ if not Overflow_Checks_Suppressed (Etype (N))
and then not (Is_Entity_Name (N)
   and then Overflow_Checks_Suppressed (Entity (N)))
  then
diff --git a/gcc/ada/exp_dist.adb b/gcc/ada/exp_dist.adb
index f3cc4b4f9afc..694fbe47daba 100644
--- a/gcc/ada/exp_dist.adb
+++ b/gcc/ada/exp_dist.adb
@@ -8626,7 +8626,7 @@ package body Exp_Dist is
 --  The RACW case is taken care of by Exp_Dist.Add_RACW_From_Any
 
 pragma Assert
-  (not (Is_Remote_Access_To_Class_Wide_Type (Typ)));
+  (not Is_Remote_Access_To_Class_Wide_Type (Typ));
 
 Use_Opaque_Representation := False;
 
diff --git a/gcc/ada/exp_imgv.adb b/gcc/ada/exp_imgv.adb
index a8c0fa0c1e68..c7cf06ba444f 100644
--- a/gcc/ada/exp_imgv.adb
+++ 

[gcc r15-6858] ada: Warn about redundant parentheses inside unary operators

2025-01-13 Thread Marc Poulhi?s via Gcc-cvs
https://gcc.gnu.org/g:686bd4e0bc484f9612038d51d07708ff8a4ff75b

commit r15-6858-g686bd4e0bc484f9612038d51d07708ff8a4ff75b
Author: Piotr Trojanek 
Date:   Wed Jan 8 14:00:50 2025 +0100

ada: Warn about redundant parentheses inside unary operators

GNAT already emits a style warning when redundant parentheses appear inside
logical and short-circuit operators. A similar warning is now emitted for
unary operators as well.

gcc/ada/ChangeLog:

* par-ch4.adb (P_Factor): Warn when the operand of a unary operator
doesn't require parentheses.

Diff:
---
 gcc/ada/par-ch4.adb | 38 ++
 1 file changed, 38 insertions(+)

diff --git a/gcc/ada/par-ch4.adb b/gcc/ada/par-ch4.adb
index 648a4cf64641..ca02f1baac18 100644
--- a/gcc/ada/par-ch4.adb
+++ b/gcc/ada/par-ch4.adb
@@ -2839,6 +2839,30 @@ package body Ch4 is
   Node1 : Node_Id;
   Node2 : Node_Id;
 
+  subtype N_Primary is Node_Kind with Static_Predicate =>
+N_Primary in N_Aggregate
+   | N_Allocator
+   | N_Attribute_Reference
+   | N_Case_Expression--  requires single parens
+   | N_Delta_Aggregate
+   | N_Direct_Name
+   | N_Explicit_Dereference
+   | N_Expression_With_Actions--  requires single parens
+   | N_Extension_Aggregate
+   | N_If_Expression  --  requires single parens
+   | N_Indexed_Component
+   | N_Null
+   | N_Numeric_Or_String_Literal
+   | N_Qualified_Expression
+   | N_Quantified_Expression  --  requires single parens
+   | N_Selected_Component
+   | N_Slice
+   | N_Subprogram_Call
+   | N_Target_Name
+   | N_Type_Conversion;
+  --  Node kinds that represents a "primary" subexpression, which does not
+  --  require parentheses when used as an operand of a unary operator.
+
begin
   if Token = Tok_Abs then
  Node1 := New_Op_Node (N_Op_Abs, Token_Ptr);
@@ -2849,6 +2873,13 @@ package body Ch4 is
 
  Scan; -- past ABS
  Set_Right_Opnd (Node1, P_Primary);
+
+ if Style_Check then
+if Nkind (Right_Opnd (Node1)) in N_Primary then
+   Style.Check_Xtra_Parens_Precedence (Right_Opnd (Node1));
+end if;
+ end if;
+
  return Node1;
 
   elsif Token = Tok_Not then
@@ -2860,6 +2891,13 @@ package body Ch4 is
 
  Scan; -- past NOT
  Set_Right_Opnd (Node1, P_Primary);
+
+ if Style_Check then
+if Nkind (Right_Opnd (Node1)) in N_Primary then
+   Style.Check_Xtra_Parens_Precedence (Right_Opnd (Node1));
+end if;
+ end if;
+
  return Node1;
 
   else


[gcc r15-6863] ada: Update gnatdll documentation (-b option removed)

2025-01-13 Thread Marc Poulhi?s via Gcc-cvs
https://gcc.gnu.org/g:0cf06bf0d7fd83549f0f410df57f8113fdc63da2

commit r15-6863-g0cf06bf0d7fd83549f0f410df57f8113fdc63da2
Author: Pascal Obry 
Date:   Sat Jan 11 14:19:39 2025 +0100

ada: Update gnatdll documentation (-b option removed)

gcc/ada/ChangeLog:
* doc/gnat_ugn/platform_specific_information.rst: Update.
* gnat_ugn.texi: Regenerate.

Diff:
---
 .../doc/gnat_ugn/platform_specific_information.rst| 19 ++-
 gcc/ada/gnat_ugn.texi | 11 ++-
 2 files changed, 8 insertions(+), 22 deletions(-)

diff --git a/gcc/ada/doc/gnat_ugn/platform_specific_information.rst 
b/gcc/ada/doc/gnat_ugn/platform_specific_information.rst
index aa63bb97e846..f2fc737f90d2 100644
--- a/gcc/ada/doc/gnat_ugn/platform_specific_information.rst
+++ b/gcc/ada/doc/gnat_ugn/platform_specific_information.rst
@@ -167,7 +167,7 @@ Alternatively, you can specify :file:`rts-sjlj/adainclude` 
in the file
 
 .. index:: --RTS switch
 
-You can select another run-time library temporarily 
+You can select another run-time library temporarily
 by using the :switch:`--RTS` switch, e.g., :switch:`--RTS=sjlj`
 
 
@@ -538,17 +538,17 @@ and::
 Choosing the Scheduling Policy with Windows
 ---
 
-Under Windows, the standard 31 priorities of the Ada model are mapped onto 
+Under Windows, the standard 31 priorities of the Ada model are mapped onto
 Window's seven standard priority levels by default: Idle, Lowest, Below Normal,
 Normal, Above Normal,
 
 When using the ``FIFO_Within_Priorities`` task dispatching policy, GNAT
-assigns the ``REALTIME_PRIORITY_CLASS`` priority class to the application 
-and maps the Ada priority range to the sixteen priorities made available under 
-``REALTIME_PRIORITY_CLASS``. 
+assigns the ``REALTIME_PRIORITY_CLASS`` priority class to the application
+and maps the Ada priority range to the sixteen priorities made available under
+``REALTIME_PRIORITY_CLASS``.
 
 For details on the values of the different priority mappings, see declarations
-in :file:`system.ads`. For more information about Windows priorities, please 
+in :file:`system.ads`. For more information about Windows priorities, please
 refer to Microsoft documentation.
 
 Windows Socket Timeouts
@@ -1548,13 +1548,6 @@ You may specify any of the following switches to 
``gnatdll``:
   relocatable DLL. We advise you to build relocatable DLL.
 
 
-  .. index:: -b (gnatdll)
-
-:switch:`-b {address}`
-  Set the relocatable DLL base address. By default the address is
-  ``0x1100``.
-
-
   .. index:: -bargs (gnatdll)
 
 :switch:`-bargs {opts}`
diff --git a/gcc/ada/gnat_ugn.texi b/gcc/ada/gnat_ugn.texi
index 0b62540a2fd9..2579b31a7fcc 100644
--- a/gcc/ada/gnat_ugn.texi
+++ b/gcc/ada/gnat_ugn.texi
@@ -19,7 +19,7 @@
 
 @copying
 @quotation
-GNAT User's Guide for Native Platforms , Jan 03, 2025
+GNAT User's Guide for Native Platforms , Jan 13, 2025
 
 AdaCore
 
@@ -24749,13 +24749,6 @@ Build a non-relocatable DLL at @code{address}. If you 
don’t specify
 default, when this switch is missing, @code{gnatdll} builds a
 relocatable DLL. We advise you to build relocatable DLL.
 
-@geindex -b (gnatdll)
-
-@item @code{-b `address'}
-
-Set the relocatable DLL base address. By default the address is
-@code{0x1100}.
-
 @geindex -bargs (gnatdll)
 
 @item @code{-bargs `opts'}
@@ -29839,8 +29832,8 @@ to permit their use in free software.
 
 @printindex ge
 
-@anchor{gnat_ugn/gnat_utility_programs switches-related-to-project-files}@w{   
   }
 @anchor{d2}@w{  }
+@anchor{gnat_ugn/gnat_utility_programs switches-related-to-project-files}@w{   
   }
 
 @c %**end of body
 @bye


[gcc r15-6859] ada: Cleanup preanalysis of static expressions (part 4)

2025-01-13 Thread Marc Poulhi?s via Gcc-cvs
https://gcc.gnu.org/g:5fd925bf732c889d020f2a575591648f990adb4f

commit r15-6859-g5fd925bf732c889d020f2a575591648f990adb4f
Author: Javier Miranda 
Date:   Fri Jan 10 19:08:39 2025 +

ada: Cleanup preanalysis of static expressions (part 4)

Fix regression in the SPARK 2014 testsuite.

gcc/ada/ChangeLog:

* sem_util.adb (Build_Actual_Subtype_Of_Component): No action
under preanalysis.
* sem_ch5.adb (Set_Assignment_Type): If the right-hand side contains
target names, expansion has been disabled to prevent expansion that
might move target names out of the context of the assignment 
statement.
Restore temporarily the current compilation mode so that the actual
subtype can be built.

Diff:
---
 gcc/ada/sem_ch5.adb  | 25 +
 gcc/ada/sem_util.adb |  5 ++---
 2 files changed, 23 insertions(+), 7 deletions(-)

diff --git a/gcc/ada/sem_ch5.adb b/gcc/ada/sem_ch5.adb
index 432debf3e25e..12d6426671e7 100644
--- a/gcc/ada/sem_ch5.adb
+++ b/gcc/ada/sem_ch5.adb
@@ -121,6 +121,9 @@ package body Sem_Ch5 is
   Lhs : constant Node_Id := Name (N);
   Rhs : constant Node_Id := Expression (N);
 
+  Save_Full_Analysis : Boolean := False;
+  --  Force initialization to facilitate static analysis
+
   procedure Diagnose_Non_Variable_Lhs (N : Node_Id);
   --  N is the node for the left hand side of an assignment, and it is not
   --  a variable. This routine issues an appropriate diagnostic.
@@ -318,7 +321,24 @@ package body Sem_Ch5 is
and then No (Actual_Designated_Subtype (Opnd
and then not Is_Unchecked_Union (Opnd_Type)
  then
-Decl := Build_Actual_Subtype_Of_Component (Opnd_Type, Opnd);
+--  If the right-hand side contains target names, expansion has
+--  been disabled to prevent expansion that might move target
+--  names out of the context of the assignment statement. Restore
+--  temporarily the current compilation mode so that the actual
+--  subtype can be built.
+
+if Nkind (N) = N_Assignment_Statement
+  and then Has_Target_Names (N)
+  and then Present (Current_Assignment)
+then
+   Expander_Mode_Restore;
+   Full_Analysis := Save_Full_Analysis;
+   Decl := Build_Actual_Subtype_Of_Component (Opnd_Type, Opnd);
+   Expander_Mode_Save_And_Set (False);
+   Full_Analysis := False;
+else
+   Decl := Build_Actual_Subtype_Of_Component (Opnd_Type, Opnd);
+end if;
 
 if Present (Decl) then
Insert_Action (N, Decl);
@@ -366,9 +386,6 @@ package body Sem_Ch5 is
   T1 : Entity_Id;
   T2 : Entity_Id;
 
-  Save_Full_Analysis : Boolean := False;
-  --  Force initialization to facilitate static analysis
-
--  Start of processing for Analyze_Assignment
 
begin
diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb
index 058c868aa07b..0e1505bbdbe6 100644
--- a/gcc/ada/sem_util.adb
+++ b/gcc/ada/sem_util.adb
@@ -1467,10 +1467,9 @@ package body Sem_Util is
--  Start of processing for Build_Actual_Subtype_Of_Component
 
begin
-  --  The subtype does not need to be created for a selected component
-  --  in a Spec_Expression.
+  --  The subtype does not need to be created during preanalysis
 
-  if In_Spec_Expression then
+  if Preanalysis_Active then
  return Empty;
 
   --  More comments for the rest of this body would be good ???


[gcc r15-6862] ada: Cleanup preanalysis of static expressions (part 5)

2025-01-13 Thread Marc Poulhi?s via Gcc-cvs
https://gcc.gnu.org/g:1a8265713021eea8d9d7a0f8c4f0ecec5eaa4f07

commit r15-6862-g1a8265713021eea8d9d7a0f8c4f0ecec5eaa4f07
Author: Javier Miranda 
Date:   Sat Jan 11 17:30:42 2025 +

ada: Cleanup preanalysis of static expressions (part 5)

Partially revert the fix for sem_ch13.adb as it does not comply
with RM 13.14(7.2/5).

gcc/ada/ChangeLog:

* sem_ch13.adb (Check_Aspect_At_End_Of_Declarations): Restore calls
to Preanalyze_Spec_Expression that were replaced by calls to
Preanalyze_And_Resolve. Add documentation.
(Check_Aspect_At_Freeze_Point): Ditto.

Diff:
---
 gcc/ada/sem_ch13.adb | 28 
 1 file changed, 20 insertions(+), 8 deletions(-)

diff --git a/gcc/ada/sem_ch13.adb b/gcc/ada/sem_ch13.adb
index 9bbec28ddb3d..072ec66a8f3d 100644
--- a/gcc/ada/sem_ch13.adb
+++ b/gcc/ada/sem_ch13.adb
@@ -10039,7 +10039,7 @@ package body Sem_Ch13 is
 
   --  If the predicate pragma comes from an aspect, replace the
   --  saved expression because we need the subtype references
-  --  replaced for the calls to Preanalyze_And_Resolve in
+  --  replaced for the calls to Preanalyze_Spec_Expression in
   --  Check_Aspect_At_xxx routines.
 
   if Present (Asp) then
@@ -10853,12 +10853,12 @@ package body Sem_Ch13 is
  | Aspect_Static_Predicate
 then
Push_Type (Ent);
-   Preanalyze_And_Resolve (Freeze_Expr, Standard_Boolean);
+   Preanalyze_Spec_Expression (Freeze_Expr, Standard_Boolean);
Pop_Type (Ent);
 
 elsif A_Id = Aspect_Priority then
Push_Type (Ent);
-   Preanalyze_And_Resolve (Freeze_Expr, Any_Integer);
+   Preanalyze_Spec_Expression (Freeze_Expr, Any_Integer);
Pop_Type (Ent);
 
 else
@@ -10894,6 +10894,12 @@ package body Sem_Ch13 is
 end if;
 return;
 
+ --  The expression must be analyzed in the special manner described in
+ --  "Handling of Default and Per-Object Expressions" in sem.ads, since
+ --  any static expressions within an aspect_specification also cause
+ --  freezing at the end of the immediately enclosing declaration list
+ --  (RM 13.14(7.2/5)).
+
  --  The default values attributes may be defined in the private part,
  --  and the analysis of the expression may take place when only the
  --  partial view is visible. The expression must be scalar, so use
@@ -10902,7 +10908,7 @@ package body Sem_Ch13 is
  elsif A_Id in Aspect_Default_Component_Value | Aspect_Default_Value
 and then Is_Private_Type (T)
  then
-Preanalyze_And_Resolve (End_Decl_Expr, Full_View (T));
+Preanalyze_Spec_Expression (End_Decl_Expr, Full_View (T));
 
  --  The following aspect expressions may contain references to
  --  components and discriminants of the type.
@@ -10916,14 +10922,14 @@ package body Sem_Ch13 is
  | Aspect_Static_Predicate
  then
 Push_Type (Ent);
-Preanalyze_And_Resolve (End_Decl_Expr, T);
+Preanalyze_Spec_Expression (End_Decl_Expr, T);
 Pop_Type (Ent);
 
  elsif A_Id = Aspect_Predicate_Failure then
-Preanalyze_And_Resolve (End_Decl_Expr, Standard_String);
+Preanalyze_Spec_Expression (End_Decl_Expr, Standard_String);
 
  elsif Present (End_Decl_Expr) then
-Preanalyze_And_Resolve (End_Decl_Expr, T);
+Preanalyze_Spec_Expression (End_Decl_Expr, T);
  end if;
 
  Err :=
@@ -11346,8 +11352,14 @@ package body Sem_Ch13 is
 
   --  Do the preanalyze call
 
+  --  The expression must be analyzed in the special manner described in
+  --  "Handling of Default and Per-Object Expressions" in sem.ads, since
+  --  at the freezing point of the entity associated with an aspect
+  --  specification, any static expressions expressions or names within
+  --  the aspect_specification cause freezing (RM 13.14(7.2/5)).
+
   if Present (Expression (ASN)) then
- Preanalyze_And_Resolve (Expression (ASN), T);
+ Preanalyze_Spec_Expression (Expression (ASN), T);
   end if;
end Check_Aspect_At_Freeze_Point;


[gcc r15-6860] ada: Remove redundant parentheses inside unary operators (cont.)

2025-01-13 Thread Marc Poulhi?s via Gcc-cvs
https://gcc.gnu.org/g:492aae16856e10cc44606953287192e345ec3294

commit r15-6860-g492aae16856e10cc44606953287192e345ec3294
Author: Piotr Trojanek 
Date:   Fri Jan 10 22:08:36 2025 +0100

ada: Remove redundant parentheses inside unary operators (cont.)

GNAT already emits a style warning when redundant parentheses appear inside
logical and short-circuit operators. A similar warning will be soon emitted 
for
unary operators as well. This patch removes the redundant parentheses to 
avoid
build errors.

gcc/ada/ChangeLog:

* libgnat/a-strunb.ads: Remove redundant parentheses inside NOT
operators.

Diff:
---
 gcc/ada/libgnat/a-strunb.ads | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/gcc/ada/libgnat/a-strunb.ads b/gcc/ada/libgnat/a-strunb.ads
index 5a1427c31a23..60d57954e5c9 100644
--- a/gcc/ada/libgnat/a-strunb.ads
+++ b/gcc/ada/libgnat/a-strunb.ads
@@ -432,8 +432,8 @@ is
   then J <= Index'Result - 1
   else J - 1 in Index'Result
 .. Length (Source) - Pattern'Length)
-  then not (Search.Match
-(To_String (Source), Pattern, Mapping, J,
+  then not Search.Match
+(To_String (Source), Pattern, Mapping, J))),
 
 --  Otherwise, 0 is returned
 
@@ -485,8 +485,8 @@ is
   then J <= Index'Result - 1
   else J - 1 in Index'Result
 .. Length (Source) - Pattern'Length)
-  then not (Search.Match
-(To_String (Source), Pattern, Mapping, J,
+  then not Search.Match
+(To_String (Source), Pattern, Mapping, J))),
 
 --  Otherwise, 0 is returned
 
@@ -591,8 +591,8 @@ is
   then J in From .. Index'Result - 1
   else J - 1 in Index'Result
 .. From - Pattern'Length)
-  then not (Search.Match
-(To_String (Source), Pattern, Mapping, J,
+  then not Search.Match
+(To_String (Source), Pattern, Mapping, J))),
 
 --  Otherwise, 0 is returned
 
@@ -655,8 +655,8 @@ is
   then J in From .. Index'Result - 1
   else J - 1 in Index'Result
 .. From - Pattern'Length)
-  then not (Search.Match
-(To_String (Source), Pattern, Mapping, J,
+  then not Search.Match
+(To_String (Source), Pattern, Mapping, J))),
 
 --  Otherwise, 0 is returned


[gcc r15-6866] [ifcombine] propagate signbit mask to XOR right-hand operand

2025-01-13 Thread Alexandre Oliva via Gcc-cvs
https://gcc.gnu.org/g:52e4ede030979d8aff2f88364e1d11c61fb212aa

commit r15-6866-g52e4ede030979d8aff2f88364e1d11c61fb212aa
Author: Alexandre Oliva 
Date:   Mon Jan 13 10:49:51 2025 -0300

[ifcombine] propagate signbit mask to XOR right-hand operand

If a single-bit bitfield takes up the sign bit of a storage unit,
comparing the corresponding bitfield between two objects loads the
storage units, XORs them, converts the result to signed char, and
compares it with zero: ((signed char)(a. ^ c.) >= 0).

fold_truth_andor_for_ifcombine recognizes the compare with zero as a
sign bit test, then it decomposes the XOR into an equality test.

The problem is that, after this decomposition, that figures out the
width of the accessed fields, we apply the sign bit mask to the
left-hand operand of the compare, but we failed to also apply it to
the right-hand operand when both were taken from the same XOR.

This patch fixes that.


for  gcc/ChangeLog

PR tree-optimization/118409
* gimple-fold.cc (fold_truth_andor_for_ifcombine): Apply the
signbit mask to the right-hand XOR operand too.

for  gcc/testsuite/ChangeLog

PR tree-optimization/118409
* gcc.dg/field-merge-20.c: New.

Diff:
---
 gcc/gimple-fold.cc| 20 +++
 gcc/testsuite/gcc.dg/field-merge-20.c | 64 +++
 2 files changed, 84 insertions(+)

diff --git a/gcc/gimple-fold.cc b/gcc/gimple-fold.cc
index a3987c4590ae..93ed8b3abb05 100644
--- a/gcc/gimple-fold.cc
+++ b/gcc/gimple-fold.cc
@@ -8270,6 +8270,16 @@ fold_truth_andor_for_ifcombine (enum tree_code code, 
tree truth_type,
ll_and_mask = sign;
   else
ll_and_mask &= sign;
+  if (l_xor)
+   {
+ if (!lr_and_mask.get_precision ())
+   lr_and_mask = sign;
+ else
+   lr_and_mask &= sign;
+ if (l_const.get_precision ())
+   l_const &= wide_int::from (lr_and_mask,
+  l_const.get_precision (), UNSIGNED);
+   }
 }
 
   if (rsignbit)
@@ -8279,6 +8289,16 @@ fold_truth_andor_for_ifcombine (enum tree_code code, 
tree truth_type,
rl_and_mask = sign;
   else
rl_and_mask &= sign;
+  if (r_xor)
+   {
+ if (!rr_and_mask.get_precision ())
+   rr_and_mask = sign;
+ else
+   rr_and_mask &= sign;
+ if (r_const.get_precision ())
+   r_const &= wide_int::from (rr_and_mask,
+  r_const.get_precision (), UNSIGNED);
+   }
 }
 
   /* If either comparison code is not correct for our logical operation,
diff --git a/gcc/testsuite/gcc.dg/field-merge-20.c 
b/gcc/testsuite/gcc.dg/field-merge-20.c
new file mode 100644
index ..44ac7fae50dc
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/field-merge-20.c
@@ -0,0 +1,64 @@
+/* { dg-do run } */
+/* { dg-options "-O1" } */
+
+/* tree-optimization/118409 */
+
+/* Check that tests involving a sign bit of a storage unit are handled
+   correctly.  The compares are turned into xor tests by earlier passes, and
+   ifcombine has to propagate the sign bit mask to the right hand of the
+   compare extracted from the xor, otherwise we'll retain unwanted bits for the
+   compare.  */
+
+typedef struct {
+int p : __CHAR_BIT__;
+int d : 1;
+int b : __CHAR_BIT__ - 2;
+int e : 1;
+} g;
+
+g a = {.d = 1, .e = 1}, c = {.b = 1, .d = 1, .e = 1};
+
+__attribute__((noipa))
+int f1 ()
+{
+  if (a.d == c.d
+  && a.e == c.e)
+return 0;
+  return -1;
+}
+
+__attribute__((noipa))
+int f2 ()
+{
+  if (a.d != c.d
+  || a.e != c.e)
+return -1;
+  return 0;
+}
+
+__attribute__((noipa))
+int f3 ()
+{
+  if (c.d == a.d
+  && c.e == a.e)
+return 0;
+  return -1;
+}
+
+__attribute__((noipa))
+int f4 ()
+{
+  if (c.d != a.d
+  || c.e != a.e)
+return -1;
+  return 0;
+}
+
+int main() {
+  if (f1 () < 0
+  || f2 () < 0
+  || f3 () < 0
+  || f4 () < 0)
+__builtin_abort();
+  return 0;
+}


[gcc r15-6849] tree-optimization/117119 - ICE with int128 IV in dataref analysis

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

commit r15-6849-gd3904a3ad9d7b4c8e5e536e5166b89548510fd48
Author: Richard Biener 
Date:   Mon Jan 13 09:12:23 2025 +0100

tree-optimization/117119 - ICE with int128 IV in dataref analysis

Here's another fix for a missing check that an IV value fits in a
HIW.  It's originally from Stefan.

PR tree-optimization/117119
* tree-data-ref.cc (initialize_matrix_A): Check whether
an INTEGER_CST fits in HWI, otherwise return chrec_dont_know.

* gcc.dg/torture/pr117119.c: New testcase.

Co-Authored-By: Stefan Schulze Frielinghaus 

Diff:
---
 gcc/testsuite/gcc.dg/torture/pr117119.c | 10 ++
 gcc/tree-data-ref.cc|  2 +-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/gcc/testsuite/gcc.dg/torture/pr117119.c 
b/gcc/testsuite/gcc.dg/torture/pr117119.c
new file mode 100644
index ..0ec4ac1b1802
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr117119.c
@@ -0,0 +1,10 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target int128 } */
+
+unsigned __int128 g_728;
+int func_1_l_5011[8];
+void func_1() {
+  for (;; g_728 += 1)
+func_1_l_5011[g_728] ^= func_1_l_5011[g_728 + 5];
+}
+void main() {}
diff --git a/gcc/tree-data-ref.cc b/gcc/tree-data-ref.cc
index 26ad0536c360..08c14fe29f22 100644
--- a/gcc/tree-data-ref.cc
+++ b/gcc/tree-data-ref.cc
@@ -4088,7 +4088,7 @@ initialize_matrix_A (lambda_matrix A, tree chrec, 
unsigned index, int mult)
   }
 
 case INTEGER_CST:
-  return chrec;
+  return cst_and_fits_in_hwi (chrec) ? chrec : chrec_dont_know;
 
 default:
   gcc_unreachable ();


[gcc r15-6888] tree-optimization/118405 - ICE with vector(1) T vs T load

2025-01-13 Thread Richard Biener via Gcc-cvs
https://gcc.gnu.org/g:31c3c1a83fd885b4687c9f6f7acd68af76d758d3

commit r15-6888-g31c3c1a83fd885b4687c9f6f7acd68af76d758d3
Author: Richard Biener 
Date:   Mon Jan 13 10:15:10 2025 +0100

tree-optimization/118405 - ICE with vector(1) T vs T load

When vectorizing a load we are now checking alignment before emitting
a vector(1) T load instead of blindly assuming it's OK when we had
a scalar T load.  For reasons we're not handling alignment computation
optimally here but we shouldn't ICE when we fall back to loads of T.

The following ensures the IL remains correct by emitting VIEW_CONVERT
from T to vector(1) T when needed.  It also removes an earlier fix
done in r9-382-gbb4e47476537f6 for the same issue with VMAT_ELEMENTWISE.

PR tree-optimization/118405
* tree-vect-stmts.cc (vectorizable_load): When we fall back
to scalar loads make sure we properly convert to vector(1) T
when there was only a single vector element.

Diff:
---
 gcc/tree-vect-stmts.cc | 18 --
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc
index f5b3608f6b13..0c0f999d3e3c 100644
--- a/gcc/tree-vect-stmts.cc
+++ b/gcc/tree-vect-stmts.cc
@@ -10731,9 +10731,6 @@ vectorizable_load (vec_info *vinfo,
  /* Else fall back to the default element-wise access.  */
  ltype = build_aligned_type (ltype, TYPE_ALIGN (TREE_TYPE (vectype)));
}
-  /* Load vector(1) scalar_type if it's 1 element-wise vectype.  */
-  else if (nloads == 1)
-   ltype = vectype;
 
   if (slp)
{
@@ -10782,11 +10779,11 @@ vectorizable_load (vec_info *vinfo,
 group_el * elsz + cst_offset);
  tree data_ref = build2 (MEM_REF, ltype, running_off, this_off);
  vect_copy_ref_info (data_ref, DR_REF (first_dr_info->dr));
- new_stmt = gimple_build_assign (make_ssa_name (ltype), data_ref);
+ new_temp = make_ssa_name (ltype);
+ new_stmt = gimple_build_assign (new_temp, data_ref);
  vect_finish_stmt_generation (vinfo, stmt_info, new_stmt, gsi);
  if (nloads > 1)
-   CONSTRUCTOR_APPEND_ELT (v, NULL_TREE,
-   gimple_assign_lhs (new_stmt));
+   CONSTRUCTOR_APPEND_ELT (v, NULL_TREE, new_temp);
 
  group_el += lnel;
  if (! slp
@@ -10833,6 +10830,15 @@ vectorizable_load (vec_info *vinfo,
}
}
}
+ else if (!costing_p && ltype != vectype)
+   {
+ new_stmt = gimple_build_assign (make_ssa_name (vectype),
+ VIEW_CONVERT_EXPR,
+ build1 (VIEW_CONVERT_EXPR,
+ vectype, new_temp));
+ vect_finish_stmt_generation (vinfo, stmt_info, new_stmt,
+  gsi);
+   }
 
  if (!costing_p)
{


[gcc r15-6871] Accept commas between clauses in OpenMP declare variant

2025-01-13 Thread Paul-Antoine Arras via Gcc-cvs
https://gcc.gnu.org/g:2ea4801cf7a4ebc0145b84f84ae7f4961e57b64f

commit r15-6871-g2ea4801cf7a4ebc0145b84f84ae7f4961e57b64f
Author: Paul-Antoine Arras 
Date:   Mon Jan 6 18:38:11 2025 +0100

Accept commas between clauses in OpenMP declare variant

Add support to the Fortran parser for the OpenMP syntax that allows a comma
after the directive name and between clauses of declare variant. The C and 
C++
parsers already support this syntax so only a new test is added.

gcc/fortran/ChangeLog:

* openmp.cc (gfc_match_omp_declare_variant): Match comma after 
directive
name and between clauses. Emit more useful diagnostics.

gcc/testsuite/ChangeLog:

* gfortran.dg/gomp/declare-variant-2.f90: Remove error test for a 
comma
after the directive name. Add tests for other invalid syntaxes 
(extra
comma and invalid clause).
* c-c++-common/gomp/adjust-args-5.c: New test.
* gfortran.dg/gomp/adjust-args-11.f90: New test.

Diff:
---
 gcc/fortran/openmp.cc  | 23 ++-
 gcc/testsuite/c-c++-common/gomp/adjust-args-5.c| 21 ++
 gcc/testsuite/gfortran.dg/gomp/adjust-args-11.f90  | 45 ++
 .../gfortran.dg/gomp/declare-variant-2.f90 | 10 -
 4 files changed, 87 insertions(+), 12 deletions(-)

diff --git a/gcc/fortran/openmp.cc b/gcc/fortran/openmp.cc
index e00044db7d08..0f1aaa021812 100644
--- a/gcc/fortran/openmp.cc
+++ b/gcc/fortran/openmp.cc
@@ -6559,7 +6559,6 @@ gfc_match_omp_context_selector_specification 
(gfc_omp_declare_variant *odv)
 match
 gfc_match_omp_declare_variant (void)
 {
-  bool first_p = true;
   char buf[GFC_MAX_SYMBOL_LEN + 1];
 
   if (gfc_match (" (") != MATCH_YES)
@@ -6617,11 +6616,15 @@ gfc_match_omp_declare_variant (void)
   return MATCH_ERROR;
 }
 
-  bool has_match = false, has_adjust_args = false;
+  bool has_match = false, has_adjust_args = false, error_p = false;
   locus adjust_args_loc;
 
   for (;;)
 {
+  gfc_gobble_whitespace ();
+  gfc_match_char (',');
+  gfc_gobble_whitespace ();
+
   enum clause
   {
match,
@@ -6637,13 +6640,9 @@ gfc_match_omp_declare_variant (void)
}
   else
{
- if (first_p)
-   {
- gfc_error ("expected % or % at %C");
- return MATCH_ERROR;
-   }
- else
-   break;
+ if (gfc_match_omp_eos () != MATCH_YES)
+   error_p = true;
+ break;
}
 
   if (gfc_match (" (") != MATCH_YES)
@@ -6689,8 +6688,12 @@ gfc_match_omp_declare_variant (void)
for (gfc_omp_namelist *n = *head; n != NULL; n = n->next)
  n->u.need_device_ptr = true;
}
+}
 
-  first_p = false;
+  if (error_p || (!has_match && !has_adjust_args))
+{
+  gfc_error ("expected % or % at %C");
+  return MATCH_ERROR;
 }
 
   if (has_adjust_args && !has_match)
diff --git a/gcc/testsuite/c-c++-common/gomp/adjust-args-5.c 
b/gcc/testsuite/c-c++-common/gomp/adjust-args-5.c
new file mode 100644
index ..8aff73cc6e55
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/gomp/adjust-args-5.c
@@ -0,0 +1,21 @@
+/* { dg-do compile } */
+
+/* Check that the OpenMP 5.1 syntax with commas after the directive name and
+   between clauses is supported. */
+
+int f (int a, void *b, float c[2]);
+
+#pragma omp declare variant (f), match (construct={dispatch}), adjust_args 
(nothing: a), adjust_args (need_device_ptr: b, c)
+int f0 (int a, void *b, float c[2]);
+
+int test () {
+  int a;
+  void *b;
+  float c[2];
+  struct {int a;} s;
+
+  #pragma omp dispatch, novariants(0), nocontext(1)
+  s.a = f0 (a, b, c);
+
+  return s.a;
+}
diff --git a/gcc/testsuite/gfortran.dg/gomp/adjust-args-11.f90 
b/gcc/testsuite/gfortran.dg/gomp/adjust-args-11.f90
new file mode 100644
index ..d2eb7c1d72cc
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/gomp/adjust-args-11.f90
@@ -0,0 +1,45 @@
+! { dg-do compile }
+
+! Check that the OpenMP syntax with commas between clauses is supported.
+! A comma after the directive name is introduced in 5.2, which currently is 
only
+! partially supported.
+
+module main
+  use iso_c_binding, only: c_ptr
+  implicit none
+
+  type :: struct
+integer :: a
+real :: b
+  end type
+
+  interface
+integer function f(a, b, c)
+  import c_ptr
+  integer, intent(in) :: a
+  type(c_ptr), intent(inout) :: b
+  type(c_ptr), intent(out) :: c(:)
+end function
+integer function f0(a, b, c)
+  import c_ptr
+  integer, intent(in) :: a
+  type(c_ptr), intent(inout) :: b
+  type(c_ptr), intent(out) :: c(:)
+  !$omp  declare variant (f), match (construct={dispatch}) , &
+  !$omp& adjust_args (nothing: a) ,adjust_args (need_device_ptr: 
b),adjust_args (need_device_ptr: c)
+end function
+  end interface
+
+contains
+subroutine test
+  integer :: a
+  type(c_

[gcc r15-6875] Fix build for STORE_FLAG_VALUE<0 targets [PR118418]

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

commit r15-6875-ga1a14ce3c39c25fecf052ffde063fc0ecfc2ffa3
Author: Richard Sandiford 
Date:   Mon Jan 13 19:37:12 2025 +

Fix build for STORE_FLAG_VALUE<0 targets [PR118418]

In g:06c4cf398947b53b4bfc65752f9f879bb2d07924 I mishandled signed
comparisons of comparison results on STORE_FLAG_VALUE < 0 targets
(despite specifically referencing STORE_FLAG_VALUE in the commit
message).  There, (lt TRUE FALSE) is true, although (ltu FALSE TRUE)
still holds.

Things get messy with vector modes, and since those weren't the focus
of the original commit, it seemed better to punt on them for now.
However, punting means that this optimisation no longer feels like
a natural tail-call operation.  The patch therefore converts
"return simplify..." to the usual call-and-conditional-return pattern.

gcc/
PR target/118418
* simplify-rtx.cc 
(simplify_context::simplify_relational_operation_1):
Take STORE_FLAG_VALUE into account when handling signed comparisons
of comparison results.

Diff:
---
 gcc/simplify-rtx.cc | 39 ---
 1 file changed, 24 insertions(+), 15 deletions(-)

diff --git a/gcc/simplify-rtx.cc b/gcc/simplify-rtx.cc
index 71c5d3c1b1b8..dda8fc689e79 100644
--- a/gcc/simplify-rtx.cc
+++ b/gcc/simplify-rtx.cc
@@ -6434,7 +6434,7 @@ simplify_context::simplify_relational_operation_1 
(rtx_code code,
return simplify_gen_binary (AND, mode, XEXP (tmp, 0), const1_rtx);
 }
 
-  /* For two booleans A and B:
+  /* For two unsigned booleans A and B:
 
  A >  B == ~B & A
  A >= B == ~B | A
@@ -6443,20 +6443,29 @@ simplify_context::simplify_relational_operation_1 
(rtx_code code,
  A == B == ~A ^ B (== ~B ^ A)
  A != B ==  A ^ B
 
- simplify_logical_relational_operation checks whether A and B
- are booleans.  */
-  if (code == GTU || code == GT)
-return simplify_logical_relational_operation (AND, mode, op1, op0, true);
-  if (code == GEU || code == GE)
-return simplify_logical_relational_operation (IOR, mode, op1, op0, true);
-  if (code == LTU || code == LT)
-return simplify_logical_relational_operation (AND, mode, op0, op1, true);
-  if (code == LEU || code == LE)
-return simplify_logical_relational_operation (IOR, mode, op0, op1, true);
-  if (code == EQ)
-return simplify_logical_relational_operation (XOR, mode, op0, op1, true);
-  if (code == NE)
-return simplify_logical_relational_operation (XOR, mode, op0, op1);
+ For signed comparisons, we have to take STORE_FLAG_VALUE into account,
+ with the rules above applying for positive STORE_FLAG_VALUE and with
+ the relations reversed for negative STORE_FLAG_VALUE.  */
+  if (is_a (cmp_mode)
+  && COMPARISON_P (op0)
+  && COMPARISON_P (op1))
+{
+  rtx t = NULL_RTX;
+  if (code == GTU || code == (STORE_FLAG_VALUE > 0 ? GT : LT))
+   t = simplify_logical_relational_operation (AND, mode, op1, op0, true);
+  else if (code == GEU || code == (STORE_FLAG_VALUE > 0 ? GE : LE))
+   t = simplify_logical_relational_operation (IOR, mode, op1, op0, true);
+  else if (code == LTU || code == (STORE_FLAG_VALUE > 0 ? LT : GT))
+   t = simplify_logical_relational_operation (AND, mode, op0, op1, true);
+  else if (code == LEU || code == (STORE_FLAG_VALUE > 0 ? LE : GE))
+   t = simplify_logical_relational_operation (IOR, mode, op0, op1, true);
+  else if (code == EQ)
+   t = simplify_logical_relational_operation (XOR, mode, op0, op1, true);
+  else if (code == NE)
+   t = simplify_logical_relational_operation (XOR, mode, op0, op1);
+  if (t)
+   return t;
+}
 
   return NULL_RTX;
 }