[gcc(refs/users/meissner/heads/work182-sha)] Update ChangeLog.*

2024-10-25 Thread Michael Meissner via Gcc-cvs
https://gcc.gnu.org/g:87891a90941adc1873dad4e22c656f293e37e8d1

commit 87891a90941adc1873dad4e22c656f293e37e8d1
Author: Michael Meissner 
Date:   Thu Oct 24 12:30:57 2024 -0400

Update ChangeLog.*

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

diff --git a/gcc/ChangeLog.sha b/gcc/ChangeLog.sha
index c6151fce09a4..80f083698d2a 100644
--- a/gcc/ChangeLog.sha
+++ b/gcc/ChangeLog.sha
@@ -116,7 +116,7 @@ XXEVAL   6300   0   
0  0 0
 Load vector rotate constants  96   96  96  96 9696
 
 
-These patches to add XXEVAL support add the following fusion patterns:
+These add the following fusion patterns:
 
xxland  => xxland   xxlandc => xxland   xxlxor  => xxland
xxlor   => xxland   xxlnor  => xxland   xxleqv  => xxland


[gcc r15-4602] Simplify (X /[ex] C1) * (C1 * C2) -> X * C2

2024-10-25 Thread Richard Sandiford via Gcc-cvs
https://gcc.gnu.org/g:b381e84c4ecd72029effe1f8919d3aaea0fbd86b

commit r15-4602-gb381e84c4ecd72029effe1f8919d3aaea0fbd86b
Author: Richard Sandiford 
Date:   Thu Oct 24 14:22:31 2024 +0100

Simplify (X /[ex] C1) * (C1 * C2) -> X * C2

gcc/
* match.pd: Simplify (X /[ex] C1) * (C1 * C2) -> X * C2.

gcc/testsuite/
* gcc.dg/tree-ssa/mulexactdiv-1.c: New test.
* gcc.dg/tree-ssa/mulexactdiv-2.c: Likewise.
* gcc.dg/tree-ssa/mulexactdiv-3.c: Likewise.
* gcc.dg/tree-ssa/mulexactdiv-4.c: Likewise.
* gcc.target/aarch64/sve/cnt_fold_1.c: Likewise.
* gcc.target/aarch64/sve/cnt_fold_2.c: Likewise.

Diff:
---
 gcc/match.pd  |   8 ++
 gcc/testsuite/gcc.dg/tree-ssa/mulexactdiv-1.c |  23 +
 gcc/testsuite/gcc.dg/tree-ssa/mulexactdiv-2.c |  19 
 gcc/testsuite/gcc.dg/tree-ssa/mulexactdiv-3.c |  21 +
 gcc/testsuite/gcc.dg/tree-ssa/mulexactdiv-4.c |  14 +++
 gcc/testsuite/gcc.target/aarch64/sve/cnt_fold_1.c | 110 ++
 gcc/testsuite/gcc.target/aarch64/sve/cnt_fold_2.c |  55 +++
 7 files changed, 250 insertions(+)

diff --git a/gcc/match.pd b/gcc/match.pd
index 2e7f06ecbe45..e3dabdc15d5f 100644
--- a/gcc/match.pd
+++ b/gcc/match.pd
@@ -31,6 +31,7 @@ along with GCC; see the file COPYING3.  If not see
zerop
initializer_each_zero_or_onep
CONSTANT_CLASS_P
+   poly_int_tree_p
tree_expr_nonnegative_p
tree_expr_nonzero_p
integer_valued_real_p
@@ -5471,6 +5472,13 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
   (mult (convert1? (exact_div @0 @@1)) (convert2? @1))
   (convert @0))
 
+/* (X /[ex] C1) * (C1 * C2) -> X * C2.  */
+(simplify
+ (mult (convert? (exact_div @0 INTEGER_CST@1)) poly_int_tree_p@2)
+ (with { poly_widest_int factor; }
+  (if (multiple_p (wi::to_poly_widest (@2), wi::to_widest (@1), &factor))
+   (mult (convert @0) { wide_int_to_tree (type, factor); }
+
 /* Simplify (A / B) * B + (A % B) -> A.  */
 (for div (trunc_div ceil_div floor_div round_div)
  mod (trunc_mod ceil_mod floor_mod round_mod)
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/mulexactdiv-1.c 
b/gcc/testsuite/gcc.dg/tree-ssa/mulexactdiv-1.c
new file mode 100644
index ..fa853eb7dffc
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/mulexactdiv-1.c
@@ -0,0 +1,23 @@
+/* { dg-options "-O2 -fdump-tree-optimized-raw" } */
+
+#define TEST_CMP(FN, DIV, MUL) \
+  int  \
+  FN (int x)   \
+  {\
+if (x & 7) \
+  __builtin_unreachable ();\
+x /= DIV;  \
+return x * MUL;\
+  }
+
+TEST_CMP (f1, 2, 6)
+TEST_CMP (f2, 2, 10)
+TEST_CMP (f3, 4, 80)
+TEST_CMP (f4, 8, 200)
+
+/* { dg-final { scan-tree-dump-not {<[a-z]*_div_expr, } "optimized" } } */
+/* { dg-final { scan-tree-dump-not {> 1) & -2)
+TEST_CMP (f2, int, 4, unsigned long, -8)
+TEST_CMP (f3, int, 8, unsigned int, -24)
+TEST_CMP (f4, long, 2, int, (~0U >> 1) & -2)
+TEST_CMP (f5, long, 4, unsigned int, 100)
+TEST_CMP (f6, long, 8, unsigned long, 200)
+
+/* { dg-final { scan-tree-dump-not {<[a-z]*_div_expr, } "optimized" } } */
+/* { dg-final { scan-tree-dump-not {
+
+/*
+** f1:
+** cntdx([0-9]+)
+** mul w0, (w0, w\1|w\1, w0)
+** ret
+*/
+int
+f1 (int x)
+{
+  if (x & 1)
+__builtin_unreachable ();
+  x /= 2;
+  return x * svcntw();
+}
+
+/*
+** f2:
+** cntdx([0-9]+)
+** mul w0, (w0, w\1|w\1, w0)
+** ret
+*/
+int
+f2 (int x)
+{
+  if (x & 3)
+__builtin_unreachable ();
+  x /= 4;
+  return x * svcnth();
+}
+
+/*
+** f3:
+** cntdx([0-9]+)
+** mul w0, (w0, w\1|w\1, w0)
+** ret
+*/
+int
+f3 (int x)
+{
+  if (x & 7)
+__builtin_unreachable ();
+  x /= 8;
+  return x * svcntb();
+}
+
+/*
+** f4:
+** cntwx([0-9]+)
+** mul w0, (w0, w\1|w\1, w0)
+** ret
+*/
+int
+f4 (int x)
+{
+  if (x & 1)
+__builtin_unreachable ();
+  x /= 2;
+  return x * svcnth();
+}
+
+/*
+** f5:
+** cntwx([0-9]+)
+** mul w0, (w0, w\1|w\1, w0)
+** ret
+*/
+int
+f5 (int x)
+{
+  if (x & 3)
+__builtin_unreachable ();
+  x /= 4;
+  return x * svcntb();
+}
+
+/*
+** f6:
+** cnthx([0-9]+)
+** mul w0, (w0, w\1|w\1, w0)
+** ret
+*/
+int
+f6 (int x)
+{
+  if (x & 1)
+__builtin_unreachable ();
+  x /= 2;
+  return x * svcntb();
+}
+
+/*
+** f7:
+** cntbx([0-9]+)
+** mul w0, (w0, w\1|w\1, w0)
+** ret
+*/
+int
+f7 (int x)
+{
+  if (x & 15)
+__builtin_unreachable ();
+  x /= 16;
+  return x * svcntb() * 16;
+}
diff --git a/gcc/testsuite/gcc.target/aarch64/sve/cnt_fold_2.c 
b/gcc/testsuite/gcc.target/aarch64/sve/cnt_fold_2.c
new file mode 100644
index ..7412b7b964eb
--- /dev/null
+++ b/gcc/testsuite/gcc.ta

[gcc r15-4598] Remove pointer_and_operator.

2024-10-25 Thread Andrew Macleod via Gcc-cvs
https://gcc.gnu.org/g:f9d94c1d5cf051350a39a9816f35cf94d351f6da

commit r15-4598-gf9d94c1d5cf051350a39a9816f35cf94d351f6da
Author: Andrew MacLeod 
Date:   Mon Oct 21 18:20:10 2024 -0400

Remove pointer_and_operator.

This operator class predates the dispatch system, and is no longer used.
The functionality of wi_fold has been replaced by
operator_bitwise_and::fold_range with prange operaands.

* range-op-ptr.cc (class pointer_and_operator): Remove.
(pointer_and_operator::wi_fold): Remove.

Diff:
---
 gcc/range-op-ptr.cc | 23 ---
 1 file changed, 23 deletions(-)

diff --git a/gcc/range-op-ptr.cc b/gcc/range-op-ptr.cc
index f8ce62d5719d..dd312a803660 100644
--- a/gcc/range-op-ptr.cc
+++ b/gcc/range-op-ptr.cc
@@ -379,29 +379,6 @@ pointer_plus_operator::op2_range (irange &r, tree type,
   return true;
 }
 
-class pointer_and_operator : public range_operator
-{
-public:
-  virtual void wi_fold (irange &r, tree type,
-   const wide_int &lh_lb, const wide_int &lh_ub,
-   const wide_int &rh_lb, const wide_int &rh_ub) const;
-} op_pointer_and;
-
-void
-pointer_and_operator::wi_fold (irange &r, tree type,
-  const wide_int &lh_lb,
-  const wide_int &lh_ub,
-  const wide_int &rh_lb ATTRIBUTE_UNUSED,
-  const wide_int &rh_ub ATTRIBUTE_UNUSED) const
-{
-  // For pointer types, we are really only interested in asserting
-  // whether the expression evaluates to non-NULL.
-  if (wi_zero_p (type, lh_lb, lh_ub) || wi_zero_p (type, lh_lb, lh_ub))
-r.set_zero (type);
-  else
-r.set_varying (type);
-}
-
 
 class pointer_or_operator : public range_operator
 {


[gcc(refs/users/aoliva/heads/testme)] handle TRUTH_ANDIF cond exprs in ifcombine_replace_cond

2024-10-25 Thread Alexandre Oliva via Gcc-cvs
https://gcc.gnu.org/g:374dec3079e90b26e18ea03a3e81a3dc6491e3a8

commit 374dec3079e90b26e18ea03a3e81a3dc6491e3a8
Author: Alexandre Oliva 
Date:   Thu Oct 24 15:35:40 2024 -0300

handle TRUTH_ANDIF cond exprs in ifcombine_replace_cond

The upcoming move of fold_truth_andor to ifcombine brings with it the
possibility of TRUTH_ANDIF cond exprs.  Handle them by splitting the
cond so as to best use both BB insertion points, but only if they're
contiguous.


for  gcc/ChangeLog

* tree-ssa-ifcombine.c (ifcombine_replace_cond): Support
TRUTH_ANDIF cond exprs.

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

diff --git a/gcc/tree-ssa-ifcombine.cc b/gcc/tree-ssa-ifcombine.cc
index 817c95b20252..6194e92bd381 100644
--- a/gcc/tree-ssa-ifcombine.cc
+++ b/gcc/tree-ssa-ifcombine.cc
@@ -518,6 +518,17 @@ ifcombine_replace_cond (gcond *inner_cond, bool inner_inv,
gcond *outer_cond, bool outer_inv,
tree cond, bool must_canon, tree cond2)
 {
+  /* Split cond into cond2 if they're contiguous.  ??? We might be able to
+ handle ORIF as well, inverting both conditions, but it's not clear that
+ this would be enough, and it never comes up.  */
+  if (!cond2
+  && TREE_CODE (cond) == TRUTH_ANDIF_EXPR
+  && single_pred (gimple_bb (inner_cond)) == gimple_bb (outer_cond))
+{
+  cond2 = TREE_OPERAND (cond, 1);
+  cond = TREE_OPERAND (cond, 0);
+}
+
   bool outer_p = cond2 || (single_pred (gimple_bb (inner_cond))
   != gimple_bb (outer_cond));
   bool result_inv = outer_p ? outer_inv : inner_inv;


[gcc/aoliva/heads/testme] (711 commits) ifcombine across noncontiguous blocks

2024-10-25 Thread Alexandre Oliva via Gcc-cvs
The branch 'aoliva/heads/testme' was updated to point to:

 c0ef27f42446... ifcombine across noncontiguous blocks

It previously pointed to:

 dea162ded074... fold fold_truth_andor into ifcombine

Diff:

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

  dea162d... fold fold_truth_andor into ifcombine


Summary of changes (added commits):
---

  c0ef27f... ifcombine across noncontiguous blocks
  11bf09a... introduce ifcombine_replace_cond
  d586ea3... adjust update_profile_after_ifcombine for noncontiguous ifc
  3e47b27... introduce ifcombine_replace_cond
  ebc7c0f... drop redundant ifcombine_ifandif parm
  6c0e7c5... allow vuses in ifcombine blocks
  fc40202... SVE intrinsics: Fold division and multiplication by -1 to n (*)
  90e38c4... SVE intrinsics: Add constant folding for svindex. (*)
  078f7c4... [PATCH] RISC-V: override alignment of function/jump/loop (*)
  a616b7e... libffi: LoongArch: Fix soft-float builds of libffi (*)
  8df549f... testsuite: Fix up pr116488.c and pr117226.c tests [PR116488 (*)
  03b469e... RISC-V: Add testcases for form 4 of signed vector SAT_ADD (*)
  fa546b6... Daily bump. (*)
  820464e... aarch64: Fix warning in aarch64_ptrue_reg (*)
  36e3e68... match: Reject non-const internal functions [PR117260] (*)
  5467f5b... ginclude: stdalign.h should define __xxx_is_defined macros  (*)
  f342d66... top-level: Add pull request template for Forgejo (*)
  779c039... jit: reset state in varasm.cc [PR117275] (*)
  9ffcf1f... aarch64: Improve scalar mode popcount expansion by using SV (*)
  774ad67... Implement operator_pointer_diff::fold_range (*)
  4b0f238... libstdc++: Add -D_GLIBCXX_ASSERTIONS default for -O0 to API (*)
  5a661ec... libstdc++: Add GLIBCXX_TESTSUITE_STDS example to docs (*)
  f565063... diagnostics: implement buffering for non-textual formats [P (*)
  de2dc62... libstdc++: Replace std::__to_address in C++20 branch in  array_type_nelts_minus_one (*)
  f8687bc... libbacktrace: don't get confused by overlapping address ran (*)
  aaa855f... hppa: Fix up pa.opt.urls (*)
  1f07dea... Handle GFC_STD_UNSIGNED like a standard in error messages. (*)
  44a81aa... hppa: Add LRA support (*)
  b039d06... [PATCH 3/7] RISC-V: Fix vector memcpy smaller LMUL generati (*)
  212d868... [PATCH 2/7] RISC-V: Fix uninitialized reg in memcpy (*)
  f244492... [PATCH 1/7] RISC-V: Fix indentation in riscv_vector::expand (*)
  3a12ac4... i386: Fix the order of operands in andn3 [PR (*)
  d0a9ae1... libstdc++: Reuse std::__assign_one in  ( (*)
  4d8373f... RISC-V: Add testcases for form 4 of vector signed SAT_SUB (*)
  b976292... RISC-V: Add testcases for form 3 of vector signed SAT_SUB (*)
  5920bc8... Match: Support form 3 for vector signed integer SAT_SUB (*)
  72d24d2... RISC-V: Add testcases for form 2 of vector signed SAT_SUB (*)
  5667400... tree-optimization/116290 - fix compare-debug issue in ldist (*)
  b717c46... SH: Fix cost estimation of mem load/store (*)
  7ec8b4b... SH: Add -fno-math-errno to fsca,fsrra tests. (*)
  c21402e... Daily bump. (*)
  90a4851... libstdc++: testsuite: adjust name_fortify test for pre-defi (*)
  27f6b37... libstdc++: Fix ranges::copy_backward for a single memcpyabl (*)
  2ef62aa... MAINTAINERS: Add myself to write after approval (*)
  a4eec6c... Revert "c++: Fix overeager Woverloaded-virtual with convers (*)
  f0f1155... m68k: replace reload_in_progress by reload_in_progress || l (*)
  1506027... tree-optimization/116481 - avoid building function_type[] (*)
  3269a72... Fortran: Use OpenACC's acc_on_device builtin, fix OpenMP' _ (*)
  c38385d... [RISC-V] Avoid unnecessary extensions when value is already (*)
  f08af08... Daily bump. (*)
  d09131e... Unsigned constants for ISO_FORTRAN_ENV and ISO_C_BINDING. (*)
  a9173a5... vect: Fix inconsistency in fully-masked lane-reducing op ge (*)
  f54d42e... tree-optimization/117104 - add missed guards to max(a,b) != (*)
  ba773a8... RISC-V] Slightly improve broadcasting small constants into  (*)
  34b77d1... Fortran/OpenMP: Warn when mapping polymorphic variables (*)
  5cf85a2... bootstrap: Fix genmatch build where system gcc defaults to  (*)
  c1034d7... gcc.target/i386/pr55583.c: Use long long for 64-bit integer (*)
  80d0e10... gcc.target/i386/pr115749.c: Use word_mode integer (*)
  a4ce868... gcc.target/i386/invariant-ternlog-1.c: Also scan (%edx) (*)
  c397a8c... libcpp, genmatch: Use gcc_diag instead of printf for libcpp (*)
  c20c9d8... Fortran: Unify gfc_get_location handling; fix expr->ts bug (*)
  a564261... testsuite/i386: Add vector sat_sub testcases [PR112600] (*)
  2a865ad... MAINTAINERS: Add myself to write after approval (*)
  60163c8... c++: Fix overeager Woverloaded-virtual with conversion oper (*)
  c4af4fe... RISC-V: Add testcases for form 1 of vector signed SAT_SUB (*)
  2a7f490... RISC-V: Implement vector SAT_SUB for signed integer (*)
  d339dbe... Vect: Try the pattern of vec

[gcc(refs/users/aoliva/heads/testme)] preserve TRUTH_ANDIF handling in ifcombine_replace_cond

2024-10-25 Thread Alexandre Oliva via Gcc-cvs
https://gcc.gnu.org/g:88b60656bc326fc024633217ddf343283fc52f38

commit 88b60656bc326fc024633217ddf343283fc52f38
Author: Alexandre Oliva 
Date:   Thu Oct 24 15:35:40 2024 -0300

preserve TRUTH_ANDIF handling in ifcombine_replace_cond

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

diff --git a/gcc/tree-ssa-ifcombine.cc b/gcc/tree-ssa-ifcombine.cc
index 817c95b20252..a21cc22cf589 100644
--- a/gcc/tree-ssa-ifcombine.cc
+++ b/gcc/tree-ssa-ifcombine.cc
@@ -518,6 +518,19 @@ ifcombine_replace_cond (gcond *inner_cond, bool inner_inv,
gcond *outer_cond, bool outer_inv,
tree cond, bool must_canon, tree cond2)
 {
+  /* Split cond into cond2 if they're contiguous.  ??? We might be able to
+ handle ORIF as well, inverting both conditions, but it's not clear that
+ this would be enough, and it never comes up.  */
+  if (!cond2
+  && TREE_CODE (cond) == TRUTH_ANDIF_EXPR
+  && single_pred (gimple_bb (inner_cond)) == gimple_bb (outer_cond))
+{
+  /* ??? Does this ever hit?  */
+  gcc_unreachable ();
+  cond2 = TREE_OPERAND (cond, 1);
+  cond = TREE_OPERAND (cond, 0);
+}
+
   bool outer_p = cond2 || (single_pred (gimple_bb (inner_cond))
   != gimple_bb (outer_cond));
   bool result_inv = outer_p ? outer_inv : inner_inv;


[gcc(refs/users/meissner/heads/work182-sha)] Revert changes

2024-10-25 Thread Michael Meissner via Gcc-cvs
https://gcc.gnu.org/g:8b06419de49a2a2041a0b1a58c0348e0e71f176d

commit 8b06419de49a2a2041a0b1a58c0348e0e71f176d
Author: Michael Meissner 
Date:   Thu Oct 24 12:15:20 2024 -0400

Revert changes

Diff:
---
 gcc/config/rs6000/fusion.md| 660 +
 gcc/config/rs6000/genfusion.pl | 102 +---
 gcc/config/rs6000/predicates.md|  14 +-
 gcc/config/rs6000/rs6000.cc|   3 -
 gcc/config/rs6000/rs6000.md|   7 +-
 gcc/config/rs6000/rs6000.opt   |   4 -
 .../gcc.target/powerpc/p10-vector-fused-1.c|   0
 .../gcc.target/powerpc/p10-vector-fused-2.c|   0
 8 files changed, 270 insertions(+), 520 deletions(-)

diff --git a/gcc/config/rs6000/fusion.md b/gcc/config/rs6000/fusion.md
index 215a3aae074f..4ed9ae1d69f4 100644
--- a/gcc/config/rs6000/fusion.md
+++ b/gcc/config/rs6000/fusion.md
@@ -1871,170 +1871,146 @@
 ;; logical-logical fusion pattern generated by gen_logical_addsubf
 ;; vector vand -> vand
 (define_insn "*fuse_vand_vand"
-  [(set (match_operand:VM 3 "vector_fusion_operand" "=&0,&1,&v,wa,v")
-(and:VM (and:VM (match_operand:VM 0 "vector_fusion_operand" 
"v,v,v,wa,v")
-  (match_operand:VM 1 "vector_fusion_operand" 
"%v,v,v,wa,v"))
- (match_operand:VM 2 "vector_fusion_operand" "v,v,v,wa,v")))
-   (clobber (match_scratch:VM 4 "=X,X,X,X,&v"))]
+  [(set (match_operand:VM 3 "altivec_register_operand" "=&0,&1,&v,v")
+(and:VM (and:VM (match_operand:VM 0 "altivec_register_operand" 
"v,v,v,v")
+  (match_operand:VM 1 "altivec_register_operand" 
"%v,v,v,v"))
+ (match_operand:VM 2 "altivec_register_operand" "v,v,v,v")))
+   (clobber (match_scratch:VM 4 "=X,X,X,&v"))]
   "(TARGET_P10_FUSION)"
   "@
vand %3,%1,%0\;vand %3,%3,%2
vand %3,%1,%0\;vand %3,%3,%2
vand %3,%1,%0\;vand %3,%3,%2
-   xxeval %x3,%x2,%x1,%x0,1
vand %4,%1,%0\;vand %3,%4,%2"
   [(set_attr "type" "fused_vector")
(set_attr "cost" "6")
-   (set_attr "length" "8")
-   (set_attr "prefixed" "*,*,*,yes,*")
-   (set_attr "isa" "*,*,*,xxeval,*")])
+   (set_attr "length" "8")])
 
 ;; logical-logical fusion pattern generated by gen_logical_addsubf
 ;; vector vandc -> vand
 (define_insn "*fuse_vandc_vand"
-  [(set (match_operand:VM 3 "vector_fusion_operand" "=&0,&1,&v,wa,v")
-(and:VM (and:VM (not:VM (match_operand:VM 0 "vector_fusion_operand" 
"v,v,v,wa,v"))
-  (match_operand:VM 1 "vector_fusion_operand" 
"v,v,v,wa,v"))
- (match_operand:VM 2 "vector_fusion_operand" "v,v,v,wa,v")))
-   (clobber (match_scratch:VM 4 "=X,X,X,X,&v"))]
+  [(set (match_operand:VM 3 "altivec_register_operand" "=&0,&1,&v,v")
+(and:VM (and:VM (not:VM (match_operand:VM 0 "altivec_register_operand" 
"v,v,v,v"))
+  (match_operand:VM 1 "altivec_register_operand" 
"v,v,v,v"))
+ (match_operand:VM 2 "altivec_register_operand" "v,v,v,v")))
+   (clobber (match_scratch:VM 4 "=X,X,X,&v"))]
   "(TARGET_P10_FUSION)"
   "@
vandc %3,%1,%0\;vand %3,%3,%2
vandc %3,%1,%0\;vand %3,%3,%2
vandc %3,%1,%0\;vand %3,%3,%2
-   xxeval %x3,%x2,%x1,%x0,2
vandc %4,%1,%0\;vand %3,%4,%2"
   [(set_attr "type" "fused_vector")
(set_attr "cost" "6")
-   (set_attr "length" "8")
-   (set_attr "prefixed" "*,*,*,yes,*")
-   (set_attr "isa" "*,*,*,xxeval,*")])
+   (set_attr "length" "8")])
 
 ;; logical-logical fusion pattern generated by gen_logical_addsubf
 ;; vector veqv -> vand
 (define_insn "*fuse_veqv_vand"
-  [(set (match_operand:VM 3 "vector_fusion_operand" "=&0,&1,&v,wa,v")
-(and:VM (not:VM (xor:VM (match_operand:VM 0 "vector_fusion_operand" 
"v,v,v,wa,v")
-  (match_operand:VM 1 "vector_fusion_operand" 
"v,v,v,wa,v")))
- (match_operand:VM 2 "vector_fusion_operand" "v,v,v,wa,v")))
-   (clobber (match_scratch:VM 4 "=X,X,X,X,&v"))]
+  [(set (match_operand:VM 3 "altivec_register_operand" "=&0,&1,&v,v")
+(and:VM (not:VM (xor:VM (match_operand:VM 0 "altivec_register_operand" 
"v,v,v,v")
+  (match_operand:VM 1 "altivec_register_operand" 
"v,v,v,v")))
+ (match_operand:VM 2 "altivec_register_operand" "v,v,v,v")))
+   (clobber (match_scratch:VM 4 "=X,X,X,&v"))]
   "(TARGET_P10_FUSION)"
   "@
veqv %3,%1,%0\;vand %3,%3,%2
veqv %3,%1,%0\;vand %3,%3,%2
veqv %3,%1,%0\;vand %3,%3,%2
-   xxeval %x3,%x2,%x1,%x0,9
veqv %4,%1,%0\;vand %3,%4,%2"
   [(set_attr "type" "fused_vector")
(set_attr "cost" "6")
-   (set_attr "length" "8")
-   (set_attr "prefixed" "*,*,*,yes,*")
-   (set_attr "isa" "*,*,*,xxeval,*")])
+   (set_attr "length" "8")])
 
 ;; logical-logical fusion pattern generated by gen_logical_addsubf
 ;; vector vnand -> vand
 (define_insn "*fuse_vnand_vand"
-  [(set (match_operand:VM 3 "vector_fusion_operand" "=&0,&1,&v,wa,v")
-(and:V

[gcc r15-4609] Add comment about pp_format to diagnostic_context::report_diagnostic

2024-10-25 Thread David Malcolm via Gcc-cvs
https://gcc.gnu.org/g:fc1a001921c9c37b4d4dcaf180998aefb4037b8e

commit r15-4609-gfc1a001921c9c37b4d4dcaf180998aefb4037b8e
Author: David Malcolm 
Date:   Thu Oct 24 11:47:30 2024 -0400

Add comment about pp_format to diagnostic_context::report_diagnostic

No functional change intended.

gcc/ChangeLog:
* diagnostic.cc (diagnostic_context::report_diagnostic): Add
comment about interaction of this code with pretty-print
formatting phaes.

Signed-off-by: David Malcolm 

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

diff --git a/gcc/diagnostic.cc b/gcc/diagnostic.cc
index f1cfb3a16867..712300896573 100644
--- a/gcc/diagnostic.cc
+++ b/gcc/diagnostic.cc
@@ -1341,7 +1341,14 @@ diagnostic_context::report_diagnostic (diagnostic_info 
*diagnostic)
 m_output_format->on_begin_group ();
   m_diagnostic_groups.m_emission_count++;
 
+  /* Run phases 1 and 2 of formatting the message.
+ In particular, some format codes may have side-effects here which need to
+ happen before sending the diagnostic to the output format.
+
+ For example, Fortran's %C and %L formatting codes populate the
+ rich_location.  */
   pp_format (m_printer, &diagnostic->message);
+
   /* Call vfunc in the output format.  This is responsible for
  phase 3 of formatting, and for printing the result.  */
   m_output_format->on_report_diagnostic (*diagnostic, orig_diag_kind);


[gcc r15-4599] Implement pointer_or_operator.

2024-10-25 Thread Andrew Macleod via Gcc-cvs
https://gcc.gnu.org/g:f24e10876689dcd92b05756bd3ec833ddf1e6b7e

commit r15-4599-gf24e10876689dcd92b05756bd3ec833ddf1e6b7e
Author: Andrew MacLeod 
Date:   Wed Oct 23 10:59:13 2024 -0400

Implement pointer_or_operator.

The class pointer_or is no longer used, and can be removed.  Its
functionality was never moved to the new dispatch system.
This implements operator_bitwise_or::fold_range() for prange operands.

* range-op-mixed.h (operator_bitwise_or::fold_range): Add prange
variant.
* range-op-ptr.cc (class pointer_or_operator): Remove.
(pointer_or_operator::op1_range): Remove.
(pointer_or_operator::op2_range): Remove.
(pointer_or_operator::wi_fold): Remove.
(operator_bitwise_or::fold_range): New prange variant.

Diff:
---
 gcc/range-op-mixed.h |  6 +
 gcc/range-op-ptr.cc  | 63 +---
 2 files changed, 16 insertions(+), 53 deletions(-)

diff --git a/gcc/range-op-mixed.h b/gcc/range-op-mixed.h
index cc1db2f67758..f7c447d935e3 100644
--- a/gcc/range-op-mixed.h
+++ b/gcc/range-op-mixed.h
@@ -809,9 +809,15 @@ protected:
 class operator_bitwise_or : public range_operator
 {
 public:
+  using range_operator::fold_range;
   using range_operator::op1_range;
   using range_operator::op2_range;
   using range_operator::update_bitmask;
+
+  bool fold_range (prange &r, tree type,
+  const prange &op1,
+  const prange &op2,
+  relation_trio) const final override;
   bool op1_range (irange &r, tree type,
  const irange &lhs, const irange &op2,
  relation_trio rel = TRIO_VARYING) const override;
diff --git a/gcc/range-op-ptr.cc b/gcc/range-op-ptr.cc
index dd312a803660..ef2b2cce5167 100644
--- a/gcc/range-op-ptr.cc
+++ b/gcc/range-op-ptr.cc
@@ -379,69 +379,26 @@ pointer_plus_operator::op2_range (irange &r, tree type,
   return true;
 }
 
-
-class pointer_or_operator : public range_operator
-{
-public:
-  using range_operator::op1_range;
-  using range_operator::op2_range;
-  virtual bool op1_range (irange &r, tree type,
- const irange &lhs,
- const irange &op2,
- relation_trio rel = TRIO_VARYING) const;
-  virtual bool op2_range (irange &r, tree type,
- const irange &lhs,
- const irange &op1,
- relation_trio rel = TRIO_VARYING) const;
-  virtual void wi_fold (irange &r, tree type,
-   const wide_int &lh_lb, const wide_int &lh_ub,
-   const wide_int &rh_lb, const wide_int &rh_ub) const;
-} op_pointer_or;
-
-bool
-pointer_or_operator::op1_range (irange &r, tree type,
-   const irange &lhs,
-   const irange &op2 ATTRIBUTE_UNUSED,
-   relation_trio) const
-{
-  if (lhs.undefined_p ())
-return false;
-  if (lhs.zero_p ())
-{
-  r.set_zero (type);
-  return true;
-}
-  r.set_varying (type);
-  return true;
-}
-
 bool
-pointer_or_operator::op2_range (irange &r, tree type,
-   const irange &lhs,
-   const irange &op1,
-   relation_trio) const
-{
-  return pointer_or_operator::op1_range (r, type, lhs, op1);
-}
-
-void
-pointer_or_operator::wi_fold (irange &r, tree type,
- const wide_int &lh_lb,
- const wide_int &lh_ub,
- const wide_int &rh_lb,
- const wide_int &rh_ub) const
+operator_bitwise_or::fold_range (prange &r, tree type,
+const prange &op1,
+const prange &op2,
+relation_trio) const
 {
   // For pointer types, we are really only interested in asserting
   // whether the expression evaluates to non-NULL.
-  if (!wi_includes_zero_p (type, lh_lb, lh_ub)
-  && !wi_includes_zero_p (type, rh_lb, rh_ub))
+  if (!op1.zero_p () || !op2.zero_p ())
 r.set_nonzero (type);
-  else if (wi_zero_p (type, lh_lb, lh_ub) && wi_zero_p (type, rh_lb, rh_ub))
+  else if (op1.zero_p () && op2.zero_p ())
 r.set_zero (type);
   else
 r.set_varying (type);
+
+  update_known_bitmask (r, BIT_IOR_EXPR, op1, op2);
+  return true;
 }
 
+
 class operator_pointer_diff : public range_operator
 {
   using range_operator::fold_range;


[gcc r15-4592] SVE intrinsics: Fold constant operands for svlsl.

2024-10-25 Thread Kyrylo Tkachov via Gcc-cvs
https://gcc.gnu.org/g:3e7549ece7c6b90b9e961778361ee2b65bf104a9

commit r15-4592-g3e7549ece7c6b90b9e961778361ee2b65bf104a9
Author: Soumya AR 
Date:   Thu Oct 17 09:30:35 2024 +0530

SVE intrinsics: Fold constant operands for svlsl.

This patch implements constant folding for svlsl. Test cases have been 
added to
check for the following cases:

Zero, merge, and don't care predication.
Shift by 0.
Shift by register width.
Overflow shift on signed and unsigned integers.
Shift on a negative integer.
Maximum possible shift, eg. shift by 7 on an 8-bit integer.

The patch was bootstrapped and regtested on aarch64-linux-gnu, no 
regression.
OK for mainline?

Signed-off-by: Soumya AR 

gcc/ChangeLog:

* config/aarch64/aarch64-sve-builtins-base.cc (svlsl_impl::fold):
Try constant folding.
* config/aarch64/aarch64-sve-builtins.cc (aarch64_const_binop):
Return 0 if shift is out of range.

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/sve/const_fold_lsl_1.c: New test.

Diff:
---
 gcc/config/aarch64/aarch64-sve-builtins-base.cc|  15 ++-
 gcc/config/aarch64/aarch64-sve-builtins.cc |   5 +-
 .../gcc.target/aarch64/sve/const_fold_lsl_1.c  | 142 +
 3 files changed, 160 insertions(+), 2 deletions(-)

diff --git a/gcc/config/aarch64/aarch64-sve-builtins-base.cc 
b/gcc/config/aarch64/aarch64-sve-builtins-base.cc
index 327688756d1b..fe16d93adcd1 100644
--- a/gcc/config/aarch64/aarch64-sve-builtins-base.cc
+++ b/gcc/config/aarch64/aarch64-sve-builtins-base.cc
@@ -1926,6 +1926,19 @@ public:
   }
 };
 
+class svlsl_impl : public rtx_code_function
+{
+public:
+  CONSTEXPR svlsl_impl ()
+: rtx_code_function (ASHIFT, ASHIFT) {}
+
+  gimple *
+  fold (gimple_folder &f) const override
+  {
+return f.fold_const_binary (LSHIFT_EXPR);
+  }
+};
+
 class svmad_impl : public function_base
 {
 public:
@@ -3304,7 +3317,7 @@ FUNCTION (svldnf1uh, svldxf1_extend_impl, 
(TYPE_SUFFIX_u16, UNSPEC_LDNF1))
 FUNCTION (svldnf1uw, svldxf1_extend_impl, (TYPE_SUFFIX_u32, UNSPEC_LDNF1))
 FUNCTION (svldnt1, svldnt1_impl,)
 FUNCTION (svlen, svlen_impl,)
-FUNCTION (svlsl, rtx_code_function, (ASHIFT, ASHIFT))
+FUNCTION (svlsl, svlsl_impl,)
 FUNCTION (svlsl_wide, shift_wide, (ASHIFT, UNSPEC_ASHIFT_WIDE))
 FUNCTION (svlsr, rtx_code_function, (LSHIFTRT, LSHIFTRT))
 FUNCTION (svlsr_wide, shift_wide, (LSHIFTRT, UNSPEC_LSHIFTRT_WIDE))
diff --git a/gcc/config/aarch64/aarch64-sve-builtins.cc 
b/gcc/config/aarch64/aarch64-sve-builtins.cc
index 41673745cfea..af6469fff716 100644
--- a/gcc/config/aarch64/aarch64-sve-builtins.cc
+++ b/gcc/config/aarch64/aarch64-sve-builtins.cc
@@ -1147,7 +1147,10 @@ aarch64_const_binop (enum tree_code code, tree arg1, 
tree arg2)
   /* Return 0 for division by 0, like SDIV and UDIV do.  */
   if (code == TRUNC_DIV_EXPR && integer_zerop (arg2))
return arg2;
-
+  /* Return 0 if shift amount is out of range. */
+  if (code == LSHIFT_EXPR
+ && wi::geu_p (wi::to_wide (arg2), TYPE_PRECISION (type)))
+   return build_int_cst (type, 0);
   if (!poly_int_binop (poly_res, code, arg1, arg2, sign, &overflow))
return NULL_TREE;
   return force_fit_type (type, poly_res, false,
diff --git a/gcc/testsuite/gcc.target/aarch64/sve/const_fold_lsl_1.c 
b/gcc/testsuite/gcc.target/aarch64/sve/const_fold_lsl_1.c
new file mode 100644
index ..6109558001a0
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/sve/const_fold_lsl_1.c
@@ -0,0 +1,142 @@
+/* { dg-final { check-function-bodies "**" "" } } */
+/* { dg-options "-O2" } */
+
+#include "arm_sve.h"
+
+/*
+** s64_x:
+** mov z[0-9]+\.d, #20
+** ret
+*/
+svint64_t s64_x (svbool_t pg) {
+return svlsl_n_s64_x (pg, svdup_s64 (5), 2);  
+}
+
+/*
+** s64_x_vect:
+** mov z[0-9]+\.d, #20
+** ret
+*/
+svint64_t s64_x_vect (svbool_t pg) {
+return svlsl_s64_x (pg, svdup_s64 (5), svdup_u64 (2));  
+}
+
+/*
+** s64_z:
+** mov z[0-9]+\.d, p[0-7]/z, #20
+** ret
+*/
+svint64_t s64_z (svbool_t pg) {
+return svlsl_n_s64_z (pg, svdup_s64 (5), 2);  
+}
+
+/*
+** s64_z_vect:
+** mov z[0-9]+\.d, p[0-7]/z, #20
+** ret
+*/
+svint64_t s64_z_vect (svbool_t pg) {
+return svlsl_s64_z (pg, svdup_s64 (5), svdup_u64 (2));  
+}
+
+/*
+** s64_m_ptrue:
+** mov z[0-9]+\.d, #20
+** ret
+*/
+svint64_t s64_m_ptrue () {
+return svlsl_n_s64_m (svptrue_b64 (), svdup_s64 (5), 2);  
+}
+
+/*
+** s64_m_ptrue_vect:
+** mov z[0-9]+\.d, #20
+** ret
+*/
+svint64_t s64_m_ptrue_vect () {
+return svlsl_s64_m (svptrue_b64 (), svdup_s64 (5), svdup_u64 (2));  
+}
+
+/*
+** s64_m_pg:
+** mov z[0-9]+\.d, #5
+** lsl z[0-9]+\.d, p[0-7]/m, z[0-9]+\.d, #2
+** ret
+*/
+svint64_t s64_m_pg (svbool_t pg) {
+return svlsl_n_s64_m (pg, svdup_s64 (5), 2);
+} 
+
+/*
+** s64_m_pg_vect:
+** mov z[0-9]+\.d, #

[gcc r15-4648] ada: Small adjustments to commentary after latest change

2024-10-25 Thread Marc Poulhi?s via Gcc-cvs
https://gcc.gnu.org/g:0b972c87ac2a90292f48a389e77d8f1368c77d3b

commit r15-4648-g0b972c87ac2a90292f48a389e77d8f1368c77d3b
Author: Eric Botcazou 
Date:   Tue Oct 1 09:19:36 2024 +0200

ada: Small adjustments to commentary after latest change

This removes the enumeration of the various cases in the comment associated
with the declaration of In_Expanded_Body to prevent synchronization issues.

gcc/ada/ChangeLog:

* freeze.adb (Freeze_Expression.In_Expanded_Body): Tweak comments.

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

diff --git a/gcc/ada/freeze.adb b/gcc/ada/freeze.adb
index 101cf4740e34..9c14e1f1a700 100644
--- a/gcc/ada/freeze.adb
+++ b/gcc/ada/freeze.adb
@@ -8341,10 +8341,9 @@ package body Freeze is
 
   function In_Expanded_Body (N : Node_Id) return Boolean;
   --  Given an N_Handled_Sequence_Of_Statements node, determines whether it
-  --  is the statement sequence of an expander-generated subprogram: body
-  --  created for an expression function, for a predicate function, an init
-  --  proc, a stream subprogram, or a renaming as body. If so, this is not
-  --  a freezing context and the entity will be frozen at a later point.
+  --  is the statement sequence of an expander-generated subprogram body or
+  --  of a renaming_as_body. If so, this is not a freezing context and the
+  --  entity will be frozen at a later point.
 
   function Has_Decl_In_List
 (E : Entity_Id;
@@ -8464,8 +8463,8 @@ package body Freeze is
  else
 Id := Defining_Unit_Name (Specification (P));
 
---  The following are expander-created bodies, or bodies that
---  are not freeze points.
+--  This is the body of a Type-Specific Support routine or the one
+--  generated for a renaming_as_body.
 
 if Nkind (Id) = N_Defining_Identifier
   and then (Is_Init_Proc (Id)


[gcc r15-4657] ada: Mark XUA types as artificial

2024-10-25 Thread Marc Poulhi?s via Gcc-cvs
https://gcc.gnu.org/g:125a6e41176b7584caf4cf01c5b2ce77c9f195d2

commit r15-4657-g125a6e41176b7584caf4cf01c5b2ce77c9f195d2
Author: Tom Tromey 
Date:   Wed Jul 10 11:52:17 2024 -0600

ada: Mark XUA types as artificial

gdb does not need the name of XUA types.  This patch changes the
compiler to unconditionally mark these as artificial; a subsequent
patch will arrange for the name to be omitted.

gcc/ada/ChangeLog:

* gcc-interface/decl.cc (gnat_to_gnu_entity): Pass 'true' to
create_type_decl when creating XUA type.

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

diff --git a/gcc/ada/gcc-interface/decl.cc b/gcc/ada/gcc-interface/decl.cc
index 256541df4113..ba75fa330934 100644
--- a/gcc/ada/gcc-interface/decl.cc
+++ b/gcc/ada/gcc-interface/decl.cc
@@ -2483,7 +2483,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, 
bool definition)
/* See the above description for the rationale.  */
tree gnu_tmp_decl
  = create_type_decl (create_concat_name (gnat_entity, "XUA"), tem,
- artificial_p, debug_info_p, gnat_entity);
+ true, debug_info_p, gnat_entity);
TYPE_CONTEXT (tem) = gnu_fat_type;
TYPE_CONTEXT (TYPE_POINTER_TO (tem)) = gnu_fat_type;


[gcc r15-4638] ada: Update simpler accessibility model doc

2024-10-25 Thread Marc Poulhi?s via Gcc-cvs
https://gcc.gnu.org/g:2e81389c3aea7d5a1d1f5b1716b7fab1114d0a91

commit r15-4638-g2e81389c3aea7d5a1d1f5b1716b7fab1114d0a91
Author: Tonu Naks 
Date:   Fri Sep 13 14:59:55 2024 +

ada: Update simpler accessibility model doc

gcc/ada/ChangeLog:

* doc/gnat_rm/gnat_language_extensions.rst: update
simpler accessibility model
* gnat_rm.texi: Regenerate.
* gnat_ugn.texi: Regenerate.

Diff:
---
 gcc/ada/doc/gnat_rm/gnat_language_extensions.rst | 210 ++---
 gcc/ada/gnat_rm.texi | 359 ++-
 gcc/ada/gnat_ugn.texi|   2 +-
 3 files changed, 271 insertions(+), 300 deletions(-)

diff --git a/gcc/ada/doc/gnat_rm/gnat_language_extensions.rst 
b/gcc/ada/doc/gnat_rm/gnat_language_extensions.rst
index 0e9bb7fc54eb..4cb1560ae9c8 100644
--- a/gcc/ada/doc/gnat_rm/gnat_language_extensions.rst
+++ b/gcc/ada/doc/gnat_rm/gnat_language_extensions.rst
@@ -789,29 +789,31 @@ It cannot be applied to objects of types without any 
ancestors.
 --  executed.
   end;
 
-Simpler accessibility model
+Simpler Accessibility Model
 ---
 
 The goal of this feature is to simplify the accessibility rules by removing
 dynamic accessibility checks that are often difficult to understand and debug.
-The new rules are effective at preventing errors, at the expense of loosing
-some flexibility in the use of anonymous access types.
+The new rules eliminate the need for runtime accessibility checks by imposing
+more conservative legality rules when enabled via a new restriction (see RM 
13.12),
+No_Dynamic_Accessibility_Checks, which prevents dangling reference problems
+at compile time.
 
-The feature can be activated with pragma "No_Dynamic_Accessibility_Checks".
-As a result, a set of restrictions apply that can be categorized into three
-use-case of anonymous access types:
+This restriction has no effect on the user-visible behavior of a program when 
executed;
+the only effect of this restriction is to enable additional compile-time checks
+(described below) which ensure statically that Ada's dynamic accessibility 
checks
+will not fail.
 
-* standalone objects,
-* subprogam parameters and
-* function results.
+The feature can be activated with ``pragma Restrictions 
(No_Dynamic_Accessibility_Checks);``.
+As a result, additional compile-time checks are performed; these checks 
pertain to
+stand-alone objects, subprogram parameters, and function results as described 
below.
 
-Each of those use-cases is explained separately below. All of the refined 
rules are
-compatible with the [use of anonymous access types in SPARK]
+All of the refined rules are compatible with the [use of anonymous access 
types in SPARK]
 
(http://docs.adacore.com/spark2014-docs/html/lrm/declarations-and-types.html#access-types).
 
 
-Standalone objects
-^^
+Stand-alone objects
+
 
 .. code-block:: ada
 
@@ -820,32 +822,41 @@ Standalone objects
Cst: constant access T := ...
Cst_To_Cst : constant access constant T := ...
 
-The accessibility levels of standalone objects of anonymous access type (both
-constants or variables) is derived of the level of their object declaration.
+In this section, we will refer to a stand-alone object of an anonymous access
+type as an SO.
+
+When the restriction is in effect, the "statically deeper" relationship
+(see RM 3.10.2(4)) does apply to the type of a SO (contrary to RM 3.10.2(19.2))
+and, for the purposes of compile-time checks, the accessibility level of the
+type of a SO is the accessibility level of that SO.
 This supports many common use-cases without the employment of 
``Unchecked_Access``
 while still removing the need for dynamic checks.
 
-The most major benefit of this change is the compatibility with standard Ada 
rules.
-
-For example, the following assignment is legal without ``Unchecked_Access`` 
that
-would be required without using the No_Dynamic_Accessibility_Checks pragma:
+This statically disallows cases that would otherwise require a dynamic 
accessibility
+check, such as
 
 .. code-block:: ada
 
-   pragma Restrictions (No_Dynamic_Accessibility_Checks);
-
-   procedure Accessibility is
-
-  type T is null record;
-  type T_Ptr is access all T;
-
-  T_Inst : aliased T;
-  Anon  : access T := T_Inst'Access;
-  Named : T_Ptr := Anon;
+   type Ref is access all Integer;
+   Ptr : Ref;
+   Good : aliased Integer;
 
+   procedure Proc is
+  Bad : aliased Integer;
+  Stand_Alone : access Integer;
begin
-  null;
-   end;
+  if  then
+ Stand_Alone := Good'Access;
+  else
+ Stand_Alone := Bad'Access;
+  end if;
+  Ptr := Ref (Stand_Alone);
+   end Proc;
+
+If a No_Dynamic_Accessibility_Checks restriction is in effect, then the 
otherwise-legal
+type conversion (the right-hand side of the assignment to Ptr) becomes a 
violation

[gcc r15-4660] ada: Change scope of XUB type

2024-10-25 Thread Marc Poulhi?s via Gcc-cvs
https://gcc.gnu.org/g:7124671cadc5a9f21bb9332b5fd68d29fdcdef52

commit r15-4660-g7124671cadc5a9f21bb9332b5fd68d29fdcdef52
Author: Tom Tromey 
Date:   Wed Jul 31 09:01:45 2024 -0600

ada: Change scope of XUB type

An earlier patch in the "nameless" series caused a regression with
-fgnat-encodings=all.  Previously, all artificial types were emitted
in the CU scope in the DWARF, but with the patch, an "XUB" type is
emitted in the function scope.  This causes gdb lookups to erroneously
find the XUB type rather than the type that gdb expects to find.

Note that I don't know why the earlier code worked, because decl.cc
clearly sets the XUB type's context to be the current function.

This patch changes the type's context so that it is nested in a type
that is conveniently available.

gcc/ada/ChangeLog:

* gcc-interface/decl.cc (gnat_to_gnu_entity): Use gnu_fat_type as 
the type
context for a XUB type.

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

diff --git a/gcc/ada/gcc-interface/decl.cc b/gcc/ada/gcc-interface/decl.cc
index 372d72a18b60..3404b747ddf8 100644
--- a/gcc/ada/gcc-interface/decl.cc
+++ b/gcc/ada/gcc-interface/decl.cc
@@ -2401,7 +2401,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, 
bool definition)
= chainon (gnu_template_fields, gnu_temp_fields[index]);
finish_record_type (gnu_template_type, gnu_template_fields, 0,
debug_info_p);
-   TYPE_CONTEXT (gnu_template_type) = current_function_decl;
+   TYPE_CONTEXT (gnu_template_type) = gnu_fat_type;
 
/* If Component_Size is not already specified, annotate it with the
   size of the component.  */


[gcc r15-4639] ada: Add Type_Size_For function to Uintp package

2024-10-25 Thread Marc Poulhi?s via Gcc-cvs
https://gcc.gnu.org/g:77f6918222a3a9ff8bc3f6ea59656105c883f8df

commit r15-4639-g77f6918222a3a9ff8bc3f6ea59656105c883f8df
Author: Eric Botcazou 
Date:   Fri Sep 13 11:53:00 2024 +0200

ada: Add Type_Size_For function to Uintp package

It computes the size of an integer type that can accommodate the input.

gcc/ada/ChangeLog:

* uintp.ads (Type_Size_For): New function declaration.
* uintp.adb (Type_Size_For): New function body.
* exp_imgv.adb (Rewrite_Object_Image): Call Type_Size_For to get
the size of a narrower integer type.

Diff:
---
 gcc/ada/exp_imgv.adb |  9 -
 gcc/ada/uintp.adb| 13 +
 gcc/ada/uintp.ads|  3 +++
 3 files changed, 20 insertions(+), 5 deletions(-)

diff --git a/gcc/ada/exp_imgv.adb b/gcc/ada/exp_imgv.adb
index 20afebc061c0..c95c46adbc02 100644
--- a/gcc/ada/exp_imgv.adb
+++ b/gcc/ada/exp_imgv.adb
@@ -2539,13 +2539,12 @@ package body Exp_Imgv is
 
  elsif Nkind (P) = N_Integer_Literal then
 declare
-   Val  : constant Uint:= Intval (P);
-   Neg  : constant Boolean := Val < Uint_0;
-   Bits : constant Nat := Num_Bits (Val) + Boolean'Pos (Neg);
+   Val  : constant Uint := Intval (P);
+   Siz  : constant Nat  := Type_Size_For (Val);
 
 begin
-   if Bits <= System_Max_Integer_Size then
-  Ptyp := Integer_Type_For (UI_From_Int (Bits), not Neg);
+   if Siz <= System_Max_Integer_Size then
+  Ptyp := Integer_Type_For (UI_From_Int (Siz), Val >= Uint_0);
end if;
 end;
  end if;
diff --git a/gcc/ada/uintp.adb b/gcc/ada/uintp.adb
index 1957928f7f6f..fc548e02d570 100644
--- a/gcc/ada/uintp.adb
+++ b/gcc/ada/uintp.adb
@@ -758,6 +758,19 @@ package body Uintp is
   end if;
end Release_And_Save;
 
+   
+   --  Type_Size_For --
+   
+
+   function Type_Size_For (Input : Valid_Uint) return Nat is
+  Neg  : constant Boolean := Input < Uint_0;
+
+   begin
+  --  Num_Bits is correct only for nonnegative values
+
+  return Num_Bits (Input) + Boolean'Pos (Neg);
+   end Type_Size_For;
+
-
-- UI_Abs --
-
diff --git a/gcc/ada/uintp.ads b/gcc/ada/uintp.ads
index c80b49471854..2676ff51d30d 100644
--- a/gcc/ada/uintp.ads
+++ b/gcc/ada/uintp.ads
@@ -264,6 +264,9 @@ package Uintp is
--  function is used for capacity checks, and it can be one bit off
--  without affecting its usage.
 
+   function Type_Size_For (Input : Valid_Uint) return Nat;
+   --  Returns the size of an integer type that can accommodate Input
+
-
-- Output Routines --
-


[gcc r15-4655] ada: Add 'artificial_p' parameter to build_unc_object_type

2024-10-25 Thread Marc Poulhi?s via Gcc-cvs
https://gcc.gnu.org/g:b857742bc8b675073b5c2ab7687ce09a42789ead

commit r15-4655-gb857742bc8b675073b5c2ab7687ce09a42789ead
Author: Tom Tromey 
Date:   Wed Jul 10 11:46:57 2024 -0600

ada: Add 'artificial_p' parameter to build_unc_object_type

This adds an 'artificial_p' parameter to build_unc_object_type, so
that the artificiality of the type can be propagated to
create_type_decl.  This will affect the namelessness of the type in a
subsequent patch.

gcc/ada/ChangeLog:

* gcc-interface/decl.cc (gnat_to_gnu_entity): Pass artificial_p to
build_unc_object_type.
* gcc-interface/gigi.h (build_unc_object_type): Update.
* gcc-interface/utils.cc (build_unc_object_type) Add artificial_p
parameter.
(build_unc_object_type_from_ptr): Update.

Diff:
---
 gcc/ada/gcc-interface/decl.cc  |  2 +-
 gcc/ada/gcc-interface/gigi.h   |  9 ++---
 gcc/ada/gcc-interface/utils.cc | 13 -
 3 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/gcc/ada/gcc-interface/decl.cc b/gcc/ada/gcc-interface/decl.cc
index aa22c495a169..14b39b336bd8 100644
--- a/gcc/ada/gcc-interface/decl.cc
+++ b/gcc/ada/gcc-interface/decl.cc
@@ -2496,7 +2496,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, 
bool definition)
? create_concat_name (gnat_name, "XUT")
: gnu_entity_name;
obj = build_unc_object_type (gnu_template_type, tem, xut_name,
-debug_info_p);
+artificial_p, debug_info_p);
 
SET_TYPE_UNCONSTRAINED_ARRAY (obj, gnu_type);
TYPE_OBJECT_RECORD_TYPE (gnu_type) = obj;
diff --git a/gcc/ada/gcc-interface/gigi.h b/gcc/ada/gcc-interface/gigi.h
index f4b302be3e0b..00f00d967c73 100644
--- a/gcc/ada/gcc-interface/gigi.h
+++ b/gcc/ada/gcc-interface/gigi.h
@@ -742,10 +742,13 @@ extern tree build_template (tree template_type, tree 
array_type, tree expr);
is an unconstrained array.  This consists of a RECORD_TYPE containing a
field of TEMPLATE_TYPE and a field of OBJECT_TYPE, which is an ARRAY_TYPE.
If ARRAY_TYPE is that of an unconstrained array, this is used to represent
-   an arbitrary unconstrained object.  Use NAME as the name of the record.
-   DEBUG_INFO_P is true if we need to write debug information for the type.  */
+   an arbitrary unconstrained object.  Use NAME as the name of the
+   record.  ARTIFICIAL_P is true if the type was generated by the
+   compiler, or false if the type came from source.  DEBUG_INFO_P is
+   true if we need to write debug information for the type.  */
 extern tree build_unc_object_type (tree template_type, tree object_type,
-  tree name, bool debug_info_p);
+  tree name, bool artificial_p,
+  bool debug_info_p);
 
 /* Same as build_unc_object_type, but taking a thin or fat pointer type
instead of the template type.  */
diff --git a/gcc/ada/gcc-interface/utils.cc b/gcc/ada/gcc-interface/utils.cc
index 951d3848d09b..9e2715a8d81f 100644
--- a/gcc/ada/gcc-interface/utils.cc
+++ b/gcc/ada/gcc-interface/utils.cc
@@ -4465,12 +4465,14 @@ build_vector_type_for_array (tree array_type, tree 
attribute)
is an unconstrained array.  This consists of a RECORD_TYPE containing a
field of TEMPLATE_TYPE and a field of OBJECT_TYPE, which is an ARRAY_TYPE.
If ARRAY_TYPE is that of an unconstrained array, this is used to represent
-   an arbitrary unconstrained object.  Use NAME as the name of the record.
-   DEBUG_INFO_P is true if we need to write debug information for the type.  */
+   an arbitrary unconstrained object.  Use NAME as the name of the
+   record.  ARTIFICIAL_P is true if the type was generated by the
+   compiler, or false if the type came from source.  DEBUG_INFO_P is
+   true if we need to write debug information for the type.  */
 
 tree
 build_unc_object_type (tree template_type, tree object_type, tree name,
-  bool debug_info_p)
+  bool artificial_p, bool debug_info_p)
 {
   tree type = make_node (RECORD_TYPE);
   tree template_field
@@ -4487,7 +4489,7 @@ build_unc_object_type (tree template_type, tree 
object_type, tree name,
 
   /* Declare it now since it will never be declared otherwise.  This is
  necessary to ensure that its subtrees are properly marked.  */
-  create_type_decl (name, type, true, debug_info_p, Empty);
+  create_type_decl (name, type, artificial_p, debug_info_p, Empty);
 
   return type;
 }
@@ -4508,7 +4510,8 @@ build_unc_object_type_from_ptr (tree thin_fat_ptr_type, 
tree object_type,
: TREE_TYPE (TYPE_FIELDS (TREE_TYPE (thin_fat_ptr_type;
 
   return
-build_unc_object_type (template_type, object_type, name, debug_info_p);
+build_unc_object_type (template_type, object_type, name, true,
+  debug_info_p);
 }
 
 /* Update anything pre

[gcc r15-4636] ada: Increase stack size for Windows tasking programs

2024-10-25 Thread Marc Poulhi?s via Gcc-cvs
https://gcc.gnu.org/g:c3b0c0b0dc464537924d8641cb33ffa30698e0ee

commit r15-4636-gc3b0c0b0dc464537924d8641cb33ffa30698e0ee
Author: squirek 
Date:   Thu Sep 12 14:37:49 2024 +

ada: Increase stack size for Windows tasking programs

This patch increases the default tasking stack size for Windows tasking
program to 8 mb to avoid use of pragma Linker_Options in the general case.

gcc/ada/ChangeLog:

* libgnarl/s-taprop__mingw.adb: Modify stack size and update
documentation.

Diff:
---
 gcc/ada/libgnarl/s-taprop__mingw.adb | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/gcc/ada/libgnarl/s-taprop__mingw.adb 
b/gcc/ada/libgnarl/s-taprop__mingw.adb
index 8c7f59f1c5d2..3c4e4b91a7e6 100644
--- a/gcc/ada/libgnarl/s-taprop__mingw.adb
+++ b/gcc/ada/libgnarl/s-taprop__mingw.adb
@@ -68,11 +68,11 @@ package body System.Task_Primitives.Operations is
use System.Win32;
use System.Win32.Ext;
 
-   pragma Link_With ("-Xlinker --stack=0x20,0x1000");
-   --  Change the default stack size (2 MB) for tasking programs on Windows.
-   --  This allows about 1000 tasks running at the same time. Note that
-   --  we set the stack size for non tasking programs on System unit.
-   --  Also note that under Windows XP, we use a Windows XP extension to
+   pragma Link_With ("-Xlinker --stack=0x80,0x1000");
+   --  Change the default stack size (8 MB) for tasking programs on Windows.
+   --  This allows at least 1000 tasks running at the same time. Note that
+   --  we set the stack size for non tasking programs in the System unit.
+   --  Also note that under Windows, we use a Windows extension to
--  specify the stack size on a per task basis, as done under other OSes.
 



[gcc r15-4641] ada: Adjust documentation of External_Initialization

2024-10-25 Thread Marc Poulhi?s via Gcc-cvs
https://gcc.gnu.org/g:f4e8bdb86b7953ea7931b8e01725464b2c1be6ad

commit r15-4641-gf4e8bdb86b7953ea7931b8e01725464b2c1be6ad
Author: Ronan Desplanques 
Date:   Mon Sep 23 10:36:29 2024 +0200

ada: Adjust documentation of External_Initialization

The parameters Maximum_Size and If_Empty were mentioned during the
request for comments phase but are not implemented, at least for now.
This patch changes the GNAT reference manual accordingly. It also makes
a minor punctuation change.

gcc/ada/ChangeLog:

* doc/gnat_rm/gnat_language_extensions.rst: Adjust documentation.
* gnat_rm.texi: Regenerate.
* gnat_ugn.texi: Regenerate.

Diff:
---
 gcc/ada/doc/gnat_rm/gnat_language_extensions.rst |  6 +-
 gcc/ada/gnat_rm.texi | 10 +-
 gcc/ada/gnat_ugn.texi|  2 +-
 3 files changed, 3 insertions(+), 15 deletions(-)

diff --git a/gcc/ada/doc/gnat_rm/gnat_language_extensions.rst 
b/gcc/ada/doc/gnat_rm/gnat_language_extensions.rst
index 4cb1560ae9c8..088d289f35fe 100644
--- a/gcc/ada/doc/gnat_rm/gnat_language_extensions.rst
+++ b/gcc/ada/doc/gnat_rm/gnat_language_extensions.rst
@@ -1570,11 +1570,7 @@ Example:
 
 ``External_Initialization`` aspect accepts the following parameters:
 
-- mandatory ``Path``: the path the compiler uses to access the binary resource;
-- optional ``Maximum_Size``: the maximum number of bytes the compiler reads 
from
-  the resource;
-- optional ``If_Empty``: an expression used in place of read data in case
-  the resource is empty;
+- mandatory ``Path``: the path the compiler uses to access the binary resource.
 
 ``Path`` is resolved according to the same rules the compiler uses for loading 
the source files.
 
diff --git a/gcc/ada/gnat_rm.texi b/gcc/ada/gnat_rm.texi
index 96b13e51c078..4bcdcf6781d4 100644
--- a/gcc/ada/gnat_rm.texi
+++ b/gcc/ada/gnat_rm.texi
@@ -30786,15 +30786,7 @@ end P;
 @itemize -
 
 @item 
-mandatory @code{Path}: the path the compiler uses to access the binary 
resource;
-
-@item 
-optional @code{Maximum_Size}: the maximum number of bytes the compiler reads 
from
-the resource;
-
-@item 
-optional @code{If_Empty}: an expression used in place of read data in case
-the resource is empty;
+mandatory @code{Path}: the path the compiler uses to access the binary 
resource.
 @end itemize
 
 @code{Path} is resolved according to the same rules the compiler uses for 
loading the source files.
diff --git a/gcc/ada/gnat_ugn.texi b/gcc/ada/gnat_ugn.texi
index be1958da076f..6e8e0b5dc364 100644
--- a/gcc/ada/gnat_ugn.texi
+++ b/gcc/ada/gnat_ugn.texi
@@ -29695,8 +29695,8 @@ to permit their use in free software.
 
 @printindex ge
 
-@anchor{d1}@w{  }
 @anchor{gnat_ugn/gnat_utility_programs switches-related-to-project-files}@w{   
   }
+@anchor{d1}@w{  }
 
 @c %**end of body
 @bye


[gcc r15-4656] ada: Mark XUB types as nameless

2024-10-25 Thread Marc Poulhi?s via Gcc-cvs
https://gcc.gnu.org/g:0eb688077f50d24e2fe21e7c9385b74b81e0a925

commit r15-4656-g0eb688077f50d24e2fe21e7c9385b74b81e0a925
Author: Tom Tromey 
Date:   Wed Jul 10 11:38:55 2024 -0600

ada: Mark XUB types as nameless

gdb does not need the name of XUB types.  This patch changes the
compiler to omit these names from the DWARF when minimal encodings are
in use.

gcc/ada/ChangeLog:

* gcc-interface/decl.cc (gnat_to_gnu_entity): Set TYPE_NAMELESS on
XUB types.

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

diff --git a/gcc/ada/gcc-interface/decl.cc b/gcc/ada/gcc-interface/decl.cc
index 14b39b336bd8..256541df4113 100644
--- a/gcc/ada/gcc-interface/decl.cc
+++ b/gcc/ada/gcc-interface/decl.cc
@@ -2393,6 +2393,8 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, 
bool definition)
/* Install all the fields into the template.  */
TYPE_NAME (gnu_template_type)
  = create_concat_name (gnat_entity, "XUB");
+   TYPE_NAMELESS (gnu_template_type)
+ = gnat_encodings != DWARF_GNAT_ENCODINGS_ALL;
gnu_template_fields = NULL_TREE;
for (index = 0; index < ndim; index++)
  gnu_template_fields


[gcc r15-4654] ada: Standard types are not artificial

2024-10-25 Thread Marc Poulhi?s via Gcc-cvs
https://gcc.gnu.org/g:c895db1080349d230a2c23f544905b4c703a5ee4

commit r15-4654-gc895db1080349d230a2c23f544905b4c703a5ee4
Author: Tom Tromey 
Date:   Wed Jul 10 11:29:11 2024 -0600

ada: Standard types are not artificial

This changes gigi so that standard types are no longer marked
artificial.  This change is needed to prevent subsequent patches from
causing standard types to have their names elided.  Also, although
DWARF says that DW_AT_artificial is used for "the declaration of an
object or type artificially generated by a compiler and not explicitly
declared by the source program", it seems to me that types provided by
the language should not be marked as such; and this is what the C and
C++ compilers do.

gcc/ada/ChangeLog:

* gcc-interface/decl.cc (is_artificial): New function.
(gnat_to_gnu_entity): Use it.

Diff:
---
 gcc/ada/gcc-interface/decl.cc | 16 ++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/gcc/ada/gcc-interface/decl.cc b/gcc/ada/gcc-interface/decl.cc
index f22dea0d2cfe..aa22c495a169 100644
--- a/gcc/ada/gcc-interface/decl.cc
+++ b/gcc/ada/gcc-interface/decl.cc
@@ -259,6 +259,18 @@ typedef struct {
 
 static bool intrin_profiles_compatible_p (const intrin_binding_t *);
 
+/* Return true if GNAT_ENTITY is artificial, false otherwise.  */
+
+static bool
+is_artificial (Entity_Id gnat_entity)
+{
+  if (Comes_From_Source (gnat_entity))
+return false;
+  if (Sloc (gnat_entity) == Standard_Location)
+return false;
+  return true;
+}
+
 /* Given GNAT_ENTITY, a GNAT defining identifier node, which denotes some Ada
entity, return the equivalent GCC tree for that entity (a ..._DECL node)
and associate the ..._DECL node with the input GNAT defining identifier.
@@ -284,7 +296,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, 
bool definition)
   /* True if this is a type.  */
   const bool is_type = IN (kind, Type_Kind);
   /* True if this is an artificial entity.  */
-  const bool artificial_p = !Comes_From_Source (gnat_entity);
+  const bool artificial_p = is_artificial (gnat_entity);
   /* True if debug info is requested for this entity.  */
   const bool debug_info_p = Needs_Debug_Info (gnat_entity);
   /* True if this entity is to be considered as imported.  */
@@ -3006,7 +3018,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, 
bool definition)
 in order to decode the packed array type.  */
  tree gnu_tmp_decl
= create_type_decl (gnu_entity_name, gnu_type,
-   !Comes_From_Source (Etype (gnat_entity))
+   is_artificial (Etype (gnat_entity))
&& artificial_p, debug_info_p,
gnat_entity);
  /* Save it as our equivalent in case the call below elaborates


[gcc r15-4651] ada: Back out part of previous change -- disable warning

2024-10-25 Thread Marc Poulhi?s via Gcc-cvs
https://gcc.gnu.org/g:12d625e3f01cfe375320aef4ff8095c50b91d709

commit r15-4651-g12d625e3f01cfe375320aef4ff8095c50b91d709
Author: Bob Duff 
Date:   Tue Oct 1 16:31:10 2024 -0400

ada: Back out part of previous change -- disable warning

Temporarily disable the warning, because it breaks
SPARK continuous builder

gcc/ada/ChangeLog:

* sem_ch10.adb (Analyze_With_Clause): Temporarily disable warning.

Diff:
---
 gcc/ada/sem_ch10.adb | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/gcc/ada/sem_ch10.adb b/gcc/ada/sem_ch10.adb
index 6e4280b8f10b..202a44eb87c1 100644
--- a/gcc/ada/sem_ch10.adb
+++ b/gcc/ada/sem_ch10.adb
@@ -3039,7 +3039,8 @@ package body Sem_Ch10 is
 
  --  Self-referential withs are always useless, so warn
 
- if Warn_On_Redundant_Constructs then
+ if Warn_On_Redundant_Constructs and then False then -- ???
+--  Disable for now, because it breaks SPARK builds
 Error_Msg_N ("unnecessary with of self?r?", N);
  end if;


[gcc r15-4642] ada: Spurious error when compiling in Syntax and Semantics Only mode

2024-10-25 Thread Marc Poulhi?s via Gcc-cvs
https://gcc.gnu.org/g:d0a072e1f8b46eccf8fcc014e25cd47f17b86496

commit r15-4642-gd0a072e1f8b46eccf8fcc014e25cd47f17b86496
Author: Javier Miranda 
Date:   Thu Sep 26 09:18:48 2024 +

ada: Spurious error when compiling in Syntax and Semantics Only mode

Compiling under switch -gnatc, the frontend reports spurious errors
accessing components of class-wide tagged types.

gcc/ada/ChangeLog:

* sem_ch3.adb (Record_Type_Definition): For tagged types, add
the missing decoration to the First_Entity in the corresponding
class-wide type entity.

Diff:
---
 gcc/ada/sem_ch3.adb | 17 +
 1 file changed, 17 insertions(+)

diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb
index ea0a97bd39fc..00d5fe256d97 100644
--- a/gcc/ada/sem_ch3.adb
+++ b/gcc/ada/sem_ch3.adb
@@ -23074,6 +23074,23 @@ package body Sem_Ch3 is
  if Present (Variant_Part (Component_List (Def))) then
 Analyze (Variant_Part (Component_List (Def)));
  end if;
+
+ --  For tagged types, when compiling in Generate_Code mode, the _Tag
+ --  component is added before the creation of the class-wide entity
+ --  and it is shared by that entity once it is built.
+
+ --  However, when compiling in Check_Syntax or Check_Semantics modes,
+ --  since the _Tag component is not added to the tagged type entity,
+ --  the First_Entity of its class-wide type remains empty, and must
+ --  be explicitly set to prevent spurious errors from being reported.
+
+ if Operating_Mode <= Check_Semantics
+   and then Is_Tagged_Type (T)
+   and then Present (First_Entity (T))
+   and then No (First_Entity (Class_Wide_Type (T)))
+ then
+Set_First_Entity (Class_Wide_Type (T), First_Entity (T));
+ end if;
   end if;
 
   --  After completing the semantic analysis of the record definition,


[gcc r15-4649] ada: Emit DWARF for Ada 'with' and 'use' clauses

2024-10-25 Thread Marc Poulhi?s via Gcc-cvs
https://gcc.gnu.org/g:5f583c94e505fee54ecbe4b87ea081f6fd3c3874

commit r15-4649-g5f583c94e505fee54ecbe4b87ea081f6fd3c3874
Author: Tom Tromey 
Date:   Wed Apr 24 13:13:08 2024 -0600

ada: Emit DWARF for Ada 'with' and 'use' clauses

This changes the Ada compiler to emit DWARF information for Ada 'with'
and 'use' clauses.  In particular, code like:

with Pck; use Pck;

will be emitted as:

 <1><146a>: Abbrev Number: 23 (DW_TAG_module)
<146b>   DW_AT_name: pck
<146f>   DW_AT_decl_file   : 1
<1470>   DW_AT_decl_line   : 16
<1471>   DW_AT_decl_column : 6
 <1><1472>: Abbrev Number: 24 (DW_TAG_imported_module)
<1473>   DW_AT_decl_file   : 1
<1474>   DW_AT_decl_line   : 16
<1475>   DW_AT_decl_column : 11
<1476>   DW_AT_import  : <0x146a>

That is, DW_TAG_module is used to represent a 'with' clause, and
DW_TAG_imported_module is used to represent 'use'.

gcc/ada/ChangeLog:

* gcc-interface/trans.cc (namespace_map): New global.
(Compilation_Unit_to_gnu): Also handle N_With_Clause and
N_Use_Package_Clause.
(get_or_create_namespace, get_namespace): New functions.
(gnat_to_gnu) : Call
get_namespace.
: Likewise.

Diff:
---
 gcc/ada/gcc-interface/trans.cc | 141 +++--
 1 file changed, 136 insertions(+), 5 deletions(-)

diff --git a/gcc/ada/gcc-interface/trans.cc b/gcc/ada/gcc-interface/trans.cc
index 5f5cbe5b4774..d23133d5cb6f 100644
--- a/gcc/ada/gcc-interface/trans.cc
+++ b/gcc/ada/gcc-interface/trans.cc
@@ -237,6 +237,9 @@ static vec gnu_program_error_label_stack;
 /* Map GNAT tree codes to GCC tree codes for simple expressions.  */
 static enum tree_code gnu_codes[Number_Node_Kinds];
 
+/* Map from identifier nodes to namespace decls.  */
+static GTY(()) hash_map *namespace_map;
+
 static void init_code_table (void);
 static tree get_elaboration_procedure (void);
 static void Compilation_Unit_to_gnu (Node_Id);
@@ -5929,7 +5932,9 @@ Compilation_Unit_to_gnu (Node_Id gnat_node)
   for (gnat_pragma = First (Context_Items (gnat_node));
Present (gnat_pragma);
gnat_pragma = Next (gnat_pragma))
-if (Nkind (gnat_pragma) == N_Pragma)
+if (Nkind (gnat_pragma) == N_Pragma
+   || Nkind (gnat_pragma) == N_With_Clause
+   || Nkind (gnat_pragma) == N_Use_Package_Clause)
   add_stmt (gnat_to_gnu (gnat_pragma));
   process_decls (Declarations (Aux_Decls_Node (gnat_node)), Empty,
 true, true);
@@ -6324,6 +6329,104 @@ statement_node_p (Node_Id gnat_node)
   return false;
 }
 
+/* Get or create the namespace NAME.  FULL_NAME is the full name of
+   the namespace, for instance "outer__inner" -- this is needed
+   because there's only a single level hash table storing all
+   namespaces.  GNAT_NODE is used for context and passed to
+   gnat_pushdecl.  GNU_CONTEXT is the outer namespace, or NULL_TREE if
+   there is not one.  */
+
+static tree
+get_or_create_namespace (const char *name, const char *full_name,
+Node_Id gnat_node, tree gnu_context)
+{
+  if (namespace_map == nullptr)
+namespace_map = hash_map::create_ggc ();
+  tree full_id = get_identifier (full_name);
+  tree *value = namespace_map->get (full_id);
+  if (value != nullptr)
+return *value;
+
+  tree id = get_identifier (name);
+  tree result = build_decl (input_location, NAMESPACE_DECL, id,
+   void_type_node);
+  namespace_map->put (full_id, result);
+  gnat_pushdecl (result, gnat_node);
+  DECL_CONTEXT (result) = gnu_context;
+  return result;
+}
+
+/* Create namespace decls from GNAT_NAME.  GNAT_NODE is used for
+   context and passed to gnat_pushdecl, if a new namespace decl is
+   created.  GNAT_NAME can be a fully-qualified series of namespaces
+   (e.g., "outer__inner"); the innermost decl is returned.
+
+   If GNU_ORIG is non-NULL, then the new namespace will be a renaming
+   of GNU_ORIG.  That is, the final "namespace" created will actually
+   be an IMPORTED_DECL rather than a NAMESPACE_DECL.  */
+
+static tree
+get_namespace (Node_Id gnat_name, Node_Id gnat_node, tree gnu_orig = NULL_TREE)
+{
+  if (Is_Entity_Name (gnat_name))
+gnat_name = Entity (gnat_name);
+
+  gcc_assert (Nkind (gnat_name) == N_Defining_Identifier);
+
+  if (Ekind (gnat_name) == E_Void)
+return NULL_TREE;
+
+  /* This loop takes an encoded name and then successively handles
+ prefixes, making a namespace decl for each one.  E.g., for
+ "outer__middle__inner", it will first handle "outer", then
+ "outer__middle" (creating the namespace "middle" with a
+ DECL_CONTEXT of "outer"), and then finally
+ "outer__middle__inner".  FULL_STR always points to the start of
+ the name, while STR points to just the final component.  */
+  char *str = Get_Name_String (Chars (gnat_name));
+  const char *full_str

[gcc r15-4659] ada: Set DECL_NAMELESS in create_type_decl

2024-10-25 Thread Marc Poulhi?s via Gcc-cvs
https://gcc.gnu.org/g:a60e7289350d7b04d4c81187070d705f441e9c70

commit r15-4659-ga60e7289350d7b04d4c81187070d705f441e9c70
Author: Tom Tromey 
Date:   Tue Jul 9 09:36:26 2024 -0600

ada: Set DECL_NAMELESS in create_type_decl

When using minimal encodings, most artificial types do not need to
have their names emitted in the DWARF.  This patch changes the
compiler to generally omit these names.

However, a subset of names are needed: when the compiler creates an
artificial type for certain kinds of arrays, the name is needed by
gdb.  So, a new parameter is added to create_type_decl to allow this
omission to be disabled.

Note that simply passing 'false' as the artificial_p argument to
create_type_decl doesn't work properly -- other parts of the compiler
seem to rely on this flag being set, and so making this change causes
ICEs.

gcc/ada/ChangeLog:

* gcc-interface/decl.cc (gnat_to_gnu_entity): Update some calls to
create_type_decl.
* gcc-interface/gigi.h (create_type_decl): Add can_be_nameless 
parameter.
* gcc-interface/utils.cc (create_type_decl): Add can_be_nameless
parameter.  Set DECL_NAMELESS on type decl.

Diff:
---
 gcc/ada/gcc-interface/decl.cc  | 6 +++---
 gcc/ada/gcc-interface/gigi.h   | 7 +--
 gcc/ada/gcc-interface/utils.cc | 9 +++--
 3 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/gcc/ada/gcc-interface/decl.cc b/gcc/ada/gcc-interface/decl.cc
index ba75fa330934..372d72a18b60 100644
--- a/gcc/ada/gcc-interface/decl.cc
+++ b/gcc/ada/gcc-interface/decl.cc
@@ -2003,7 +2003,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, 
bool definition)
 
  /* Create a stripped-down declaration, mainly for debugging.  */
  t = create_type_decl (gnu_entity_name, gnu_type, true, debug_info_p,
-   gnat_entity);
+   gnat_entity, false);
 
  /* Now save it and build the enclosing record type.  */
  gnu_field_type = gnu_type;
@@ -2276,7 +2276,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, 
bool definition)
? create_concat_name (gnat_name, "XUP")
: gnu_entity_name;
create_type_decl (xup_name, gnu_fat_type, true, debug_info_p,
- gnat_entity);
+ gnat_entity, false);
 
/* Build a reference to the template from a PLACEHOLDER_EXPR that
   is the fat pointer.  This will be used to access the individual
@@ -3022,7 +3022,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, 
bool definition)
= create_type_decl (gnu_entity_name, gnu_type,
is_artificial (Etype (gnat_entity))
&& artificial_p, debug_info_p,
-   gnat_entity);
+   gnat_entity, false);
  /* Save it as our equivalent in case the call below elaborates
 this type again.  */
  save_gnu_tree (gnat_entity, gnu_tmp_decl, false);
diff --git a/gcc/ada/gcc-interface/gigi.h b/gcc/ada/gcc-interface/gigi.h
index 00f00d967c73..875a3d6b87f0 100644
--- a/gcc/ada/gcc-interface/gigi.h
+++ b/gcc/ada/gcc-interface/gigi.h
@@ -625,9 +625,12 @@ extern tree create_type_stub_decl (tree name, tree type);
used in the declaration.  ARTIFICIAL_P is true if the declaration was
generated by the compiler.  DEBUG_INFO_P is true if we need to write
debug information about this type.  GNAT_NODE is used for the position
-   of the decl.  */
+   of the decl.  Normally, an artificial type might be marked as
+   nameless.  However, if CAN_BE_NAMELESS is false, this marking is
+   disabled and the name will always be attached for the type.  */
 extern tree create_type_decl (tree name, tree type, bool artificial_p,
- bool debug_info_p, Node_Id gnat_node);
+ bool debug_info_p, Node_Id gnat_node,
+ bool can_be_nameless = true);
 
 /* Return a VAR_DECL or CONST_DECL node.
 
diff --git a/gcc/ada/gcc-interface/utils.cc b/gcc/ada/gcc-interface/utils.cc
index a06366bf40e4..3a571e0077bd 100644
--- a/gcc/ada/gcc-interface/utils.cc
+++ b/gcc/ada/gcc-interface/utils.cc
@@ -2846,11 +2846,13 @@ create_type_stub_decl (tree name, tree type)
used in the declaration.  ARTIFICIAL_P is true if the declaration was
generated by the compiler.  DEBUG_INFO_P is true if we need to write
debug information about this type.  GNAT_NODE is used for the position
-   of the decl.  */
+   of the decl.  Normally, an artificial type might be marked as
+   nameless.  However, if CAN_BE_NAMELESS is false, this marking is
+   disabled and the name will always be attached for the type.  */
 
 tree
 create_type_decl (tree name, tree type, bool artificial_p, bool debug_info_p,
-   

[gcc r15-4674] aarch64: Add support for mfloat8x{8|16}_t types

2024-10-25 Thread Andrew Carlotti via Gcc-cvs
https://gcc.gnu.org/g:d74b0c698c8feb63589af4085760f6349a7386a6

commit r15-4674-gd74b0c698c8feb63589af4085760f6349a7386a6
Author: Andrew Carlotti 
Date:   Mon Oct 21 16:22:09 2024 +0100

aarch64: Add support for mfloat8x{8|16}_t types

gcc/ChangeLog:

* config/aarch64/aarch64-builtins.cc
(aarch64_init_simd_builtin_types): Initialise FP8 simd types.
* config/aarch64/aarch64-builtins.h
(enum aarch64_type_qualifiers): Add qualifier_modal_float bit.
* config/aarch64/aarch64-simd-builtin-types.def:
Add Mfloat8x{8|16}_t types.
* config/aarch64/arm_neon.h: Add mfloat8x{8|16}_t typedefs.

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/movv16qi_2.c: Test mfloat as well.
* gcc.target/aarch64/movv16qi_3.c: Ditto.
* gcc.target/aarch64/movv2x16qi_1.c: Ditto.
* gcc.target/aarch64/movv3x16qi_1.c: Ditto.
* gcc.target/aarch64/movv4x16qi_1.c: Ditto.
* gcc.target/aarch64/movv8qi_2.c: Ditto.
* gcc.target/aarch64/movv8qi_3.c: Ditto.
* gcc.target/aarch64/mfloat-init-1.c: New test.

Diff:
---
 gcc/config/aarch64/aarch64-builtins.cc| 4 
 gcc/config/aarch64/aarch64-builtins.h | 2 ++
 gcc/config/aarch64/aarch64-simd-builtin-types.def | 2 ++
 gcc/config/aarch64/arm_neon.h | 3 +++
 gcc/testsuite/gcc.target/aarch64/mfloat-init-1.c  | 5 +
 gcc/testsuite/gcc.target/aarch64/movv16qi_2.c | 1 +
 gcc/testsuite/gcc.target/aarch64/movv16qi_3.c | 1 +
 gcc/testsuite/gcc.target/aarch64/movv2x16qi_1.c   | 1 +
 gcc/testsuite/gcc.target/aarch64/movv3x16qi_1.c   | 1 +
 gcc/testsuite/gcc.target/aarch64/movv4x16qi_1.c   | 1 +
 gcc/testsuite/gcc.target/aarch64/movv8qi_2.c  | 1 +
 gcc/testsuite/gcc.target/aarch64/movv8qi_3.c  | 1 +
 12 files changed, 23 insertions(+)

diff --git a/gcc/config/aarch64/aarch64-builtins.cc 
b/gcc/config/aarch64/aarch64-builtins.cc
index c4885630b90a..a41e37a7ea73 100644
--- a/gcc/config/aarch64/aarch64-builtins.cc
+++ b/gcc/config/aarch64/aarch64-builtins.cc
@@ -1220,6 +1220,10 @@ aarch64_init_simd_builtin_types (void)
   aarch64_simd_types[Bfloat16x4_t].eltype = bfloat16_type_node;
   aarch64_simd_types[Bfloat16x8_t].eltype = bfloat16_type_node;
 
+  /* Init FP8 element types.  */
+  aarch64_simd_types[Mfloat8x8_t].eltype = aarch64_mfp8_type_node;
+  aarch64_simd_types[Mfloat8x16_t].eltype = aarch64_mfp8_type_node;
+
   for (i = 0; i < nelts; i++)
 {
   tree eltype = aarch64_simd_types[i].eltype;
diff --git a/gcc/config/aarch64/aarch64-builtins.h 
b/gcc/config/aarch64/aarch64-builtins.h
index e326fe666769..00db7a74885d 100644
--- a/gcc/config/aarch64/aarch64-builtins.h
+++ b/gcc/config/aarch64/aarch64-builtins.h
@@ -54,6 +54,8 @@ enum aarch64_type_qualifiers
   /* Lane indices selected in quadtuplets. - must be in range, and flipped for
  bigendian.  */
   qualifier_lane_quadtup_index = 0x1000,
+  /* Modal FP types.  */
+  qualifier_modal_float = 0x2000,
 };
 
 #define ENTRY(E, M, Q, G) E,
diff --git a/gcc/config/aarch64/aarch64-simd-builtin-types.def 
b/gcc/config/aarch64/aarch64-simd-builtin-types.def
index 6111cd0d4fe1..83b2da2e7dc0 100644
--- a/gcc/config/aarch64/aarch64-simd-builtin-types.def
+++ b/gcc/config/aarch64/aarch64-simd-builtin-types.def
@@ -52,3 +52,5 @@
   ENTRY (Float64x2_t, V2DF, none, 13)
   ENTRY (Bfloat16x4_t, V4BF, none, 14)
   ENTRY (Bfloat16x8_t, V8BF, none, 14)
+  ENTRY (Mfloat8x8_t, V8QI, modal_float, 13)
+  ENTRY (Mfloat8x16_t, V16QI, modal_float, 14)
diff --git a/gcc/config/aarch64/arm_neon.h b/gcc/config/aarch64/arm_neon.h
index e376685489da..730d9d3fa815 100644
--- a/gcc/config/aarch64/arm_neon.h
+++ b/gcc/config/aarch64/arm_neon.h
@@ -72,6 +72,9 @@ typedef __Poly16_t poly16_t;
 typedef __Poly64_t poly64_t;
 typedef __Poly128_t poly128_t;
 
+typedef __Mfloat8x8_t mfloat8x8_t;
+typedef __Mfloat8x16_t mfloat8x16_t;
+
 typedef __fp16 float16_t;
 typedef float float32_t;
 typedef double float64_t;
diff --git a/gcc/testsuite/gcc.target/aarch64/mfloat-init-1.c 
b/gcc/testsuite/gcc.target/aarch64/mfloat-init-1.c
new file mode 100644
index ..15a6b331fd39
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/mfloat-init-1.c
@@ -0,0 +1,5 @@
+/* { dg-do assemble } */
+/* { dg-options "-O --save-temps" } */
+
+/* { dg-error "invalid conversion to type 'mfloat8_t" "" {target *-*-*} 0 } */
+__Mfloat8x8_t const_mf8x8 () { return (__Mfloat8x8_t) { 1, 1, 1, 1, 1, 1, 1, 1 
}; }
diff --git a/gcc/testsuite/gcc.target/aarch64/movv16qi_2.c 
b/gcc/testsuite/gcc.target/aarch64/movv16qi_2.c
index 08a0a19b5151..39a06db07075 100644
--- a/gcc/testsuite/gcc.target/aarch64/movv16qi_2.c
+++ b/gcc/testsuite/gcc.target/aarch64/movv16qi_2.c
@@ -17,6 +17,7 @@ TEST_GENERAL (__Bfloat16x8_t)
 TEST_GENERAL (__Float16x8_t)
 TEST_GENERAL (__Float32x4_t)
 TEST_GENERAL (__Float64x2_t)
+TEST_GENERAL (__Mfloat8x16_t)
 
 __Int8x16_t const_s8x8 

[gcc r15-4675] aarch64: Add mfloat vreinterpret intrinsics

2024-10-25 Thread Andrew Carlotti via Gcc-cvs
https://gcc.gnu.org/g:17d7a4b01a54b1af90c8c87bde59f067ed630cd1

commit r15-4675-g17d7a4b01a54b1af90c8c87bde59f067ed630cd1
Author: Andrew Carlotti 
Date:   Mon Oct 21 16:22:43 2024 +0100

aarch64: Add mfloat vreinterpret intrinsics

gcc/ChangeLog:

* config/aarch64/aarch64-builtins.cc (MODE_d_mf8): New.
(MODE_q_mf8): New.
(QUAL_mf8): New.
(VREINTERPRET_BUILTINS1): Add mf8 entry.
(VREINTERPRET_BUILTINS): Ditto.
(VREINTERPRETQ_BUILTINS1): Ditto.
(VREINTERPRETQ_BUILTINS): Ditto.
(aarch64_lookup_simd_type_in_table): Match modal_float bit

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/advsimd-intrinsics/mf8-reinterpret.c: New test.

Diff:
---
 gcc/config/aarch64/aarch64-builtins.cc | 12 +-
 .../aarch64/advsimd-intrinsics/mf8-reinterpret.c   | 46 ++
 2 files changed, 57 insertions(+), 1 deletion(-)

diff --git a/gcc/config/aarch64/aarch64-builtins.cc 
b/gcc/config/aarch64/aarch64-builtins.cc
index a41e37a7ea73..86d96e47f01c 100644
--- a/gcc/config/aarch64/aarch64-builtins.cc
+++ b/gcc/config/aarch64/aarch64-builtins.cc
@@ -133,6 +133,7 @@
 #define MODE_d_f16 E_V4HFmode
 #define MODE_d_f32 E_V2SFmode
 #define MODE_d_f64 E_V1DFmode
+#define MODE_d_mf8 E_V8QImode
 #define MODE_d_s8 E_V8QImode
 #define MODE_d_s16 E_V4HImode
 #define MODE_d_s32 E_V2SImode
@@ -148,6 +149,7 @@
 #define MODE_q_f16 E_V8HFmode
 #define MODE_q_f32 E_V4SFmode
 #define MODE_q_f64 E_V2DFmode
+#define MODE_q_mf8 E_V16QImode
 #define MODE_q_s8 E_V16QImode
 #define MODE_q_s16 E_V8HImode
 #define MODE_q_s32 E_V4SImode
@@ -177,6 +179,7 @@
 #define QUAL_p16 qualifier_poly
 #define QUAL_p64 qualifier_poly
 #define QUAL_p128 qualifier_poly
+#define QUAL_mf8 qualifier_modal_float
 
 #define LENGTH_d ""
 #define LENGTH_q "q"
@@ -598,6 +601,7 @@ static aarch64_simd_builtin_datum 
aarch64_simd_builtin_data[] = {
 /* vreinterpret intrinsics are defined for any pair of element types.
{ _bf16   }   { _bf16   }
{  _f16 _f32 _f64 }   {  _f16 _f32 _f64 }
+   { _mf8}   { _mf8}
{ _s8  _s16 _s32 _s64 } x { _s8  _s16 _s32 _s64 }
{ _u8  _u16 _u32 _u64 }   { _u8  _u16 _u32 _u64 }
{ _p8  _p16  _p64 }   { _p8  _p16  _p64 }.  */
@@ -609,6 +613,7 @@ static aarch64_simd_builtin_datum 
aarch64_simd_builtin_data[] = {
   VREINTERPRET_BUILTIN2 (A, f16) \
   VREINTERPRET_BUILTIN2 (A, f32) \
   VREINTERPRET_BUILTIN2 (A, f64) \
+  VREINTERPRET_BUILTIN2 (A, mf8) \
   VREINTERPRET_BUILTIN2 (A, s8) \
   VREINTERPRET_BUILTIN2 (A, s16) \
   VREINTERPRET_BUILTIN2 (A, s32) \
@@ -626,6 +631,7 @@ static aarch64_simd_builtin_datum 
aarch64_simd_builtin_data[] = {
   VREINTERPRET_BUILTINS1 (f16) \
   VREINTERPRET_BUILTINS1 (f32) \
   VREINTERPRET_BUILTINS1 (f64) \
+  VREINTERPRET_BUILTINS1 (mf8) \
   VREINTERPRET_BUILTINS1 (s8) \
   VREINTERPRET_BUILTINS1 (s16) \
   VREINTERPRET_BUILTINS1 (s32) \
@@ -641,6 +647,7 @@ static aarch64_simd_builtin_datum 
aarch64_simd_builtin_data[] = {
 /* vreinterpretq intrinsics are additionally defined for p128.
{ _bf16 }   { _bf16 }
{  _f16 _f32 _f64   }   {  _f16 _f32 _f64   }
+   { _mf8  }   { _mf8  }
{ _s8  _s16 _s32 _s64   } x { _s8  _s16 _s32 _s64   }
{ _u8  _u16 _u32 _u64   }   { _u8  _u16 _u32 _u64   }
{ _p8  _p16  _p64 _p128 }   { _p8  _p16  _p64 _p128 }.  */
@@ -652,6 +659,7 @@ static aarch64_simd_builtin_datum 
aarch64_simd_builtin_data[] = {
   VREINTERPRETQ_BUILTIN2 (A, f16) \
   VREINTERPRETQ_BUILTIN2 (A, f32) \
   VREINTERPRETQ_BUILTIN2 (A, f64) \
+  VREINTERPRETQ_BUILTIN2 (A, mf8) \
   VREINTERPRETQ_BUILTIN2 (A, s8) \
   VREINTERPRETQ_BUILTIN2 (A, s16) \
   VREINTERPRETQ_BUILTIN2 (A, s32) \
@@ -670,6 +678,7 @@ static aarch64_simd_builtin_datum 
aarch64_simd_builtin_data[] = {
   VREINTERPRETQ_BUILTINS1 (f16) \
   VREINTERPRETQ_BUILTINS1 (f32) \
   VREINTERPRETQ_BUILTINS1 (f64) \
+  VREINTERPRETQ_BUILTINS1 (mf8) \
   VREINTERPRETQ_BUILTINS1 (s8) \
   VREINTERPRETQ_BUILTINS1 (s16) \
   VREINTERPRETQ_BUILTINS1 (s32) \
@@ -1117,7 +1126,8 @@ aarch64_lookup_simd_type_in_table (machine_mode mode,
 {
   int i;
   int nelts = ARRAY_SIZE (aarch64_simd_types);
-  int q = qualifiers & (qualifier_poly | qualifier_unsigned);
+  int q = qualifiers
+& (qualifier_poly | qualifier_unsigned | qualifier_modal_float);
 
   for (i = 0; i < nelts; i++)
 {
diff --git 
a/gcc/testsuite/gcc.target/aarch64/advsimd-intrinsics/mf8-reinterpret.c 
b/gcc/testsuite/gcc.target/aarch64/advsimd-intrinsics/mf8-reinterpret.c
new file mode 100644
index ..5e5921746036
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/advsimd-intrinsics/mf8-reinterpret.c
@@ -0,0 +1,46 @@
+/* { dg-do compile { target { aarch64*-*-* } } } */
+
+#include 
+
+#define TEST_128(T, S) 

[gcc r15-4596] Cleanup pointer_plus_operator.

2024-10-25 Thread Andrew Macleod via Gcc-cvs
https://gcc.gnu.org/g:20d80c84ee4d19950c7d39f5c8be52836e90cad9

commit r15-4596-g20d80c84ee4d19950c7d39f5c8be52836e90cad9
Author: Andrew MacLeod 
Date:   Mon Oct 21 16:47:32 2024 -0400

Cleanup pointer_plus_operator.

The POINTER_PLUS operator still carries some remnamts of the old
irange interface, which is now dead code with prange.

* range-op-ptr.cc (pointer_plus_operator::wi_fold): Remove.
(pointer_plus_operator::op2_range): Remove irange variant.
(pointer_plus_operator::update_bitmask): Likewise.

Diff:
---
 gcc/range-op-ptr.cc | 74 +
 1 file changed, 1 insertion(+), 73 deletions(-)

diff --git a/gcc/range-op-ptr.cc b/gcc/range-op-ptr.cc
index 07a551618f98..4f4b2cf6bab9 100644
--- a/gcc/range-op-ptr.cc
+++ b/gcc/range-op-ptr.cc
@@ -302,16 +302,7 @@ public:
  const prange &lhs,
  const prange &op1,
  relation_trio = TRIO_VARYING) const final override;
-  virtual void wi_fold (irange &r, tree type,
-   const wide_int &lh_lb,
-   const wide_int &lh_ub,
-   const wide_int &rh_lb,
-   const wide_int &rh_ub) const;
-  virtual bool op2_range (irange &r, tree type,
- const irange &lhs,
- const irange &op1,
- relation_trio = TRIO_VARYING) const;
-  void update_bitmask (irange &r, const irange &lh, const irange &rh) const
+  void update_bitmask (prange &r, const prange &lh, const irange &rh) const
 { update_known_bitmask (r, POINTER_PLUS_EXPR, lh, rh); }
 } op_pointer_plus;
 
@@ -388,69 +379,6 @@ pointer_plus_operator::op2_range (irange &r, tree type,
   return true;
 }
 
-void
-pointer_plus_operator::wi_fold (irange &r, tree type,
-   const wide_int &lh_lb,
-   const wide_int &lh_ub,
-   const wide_int &rh_lb,
-   const wide_int &rh_ub) const
-{
-  // Check for [0,0] + const, and simply return the const.
-  if (lh_lb == 0 && lh_ub == 0 && rh_lb == rh_ub)
-{
-  r.set (type, rh_lb, rh_lb);
-  return;
-}
-
-  // For pointer types, we are really only interested in asserting
-  // whether the expression evaluates to non-NULL.
-  //
-  // With -fno-delete-null-pointer-checks we need to be more
-  // conservative.  As some object might reside at address 0,
-  // then some offset could be added to it and the same offset
-  // subtracted again and the result would be NULL.
-  // E.g.
-  // static int a[12]; where &a[0] is NULL and
-  // ptr = &a[6];
-  // ptr -= 6;
-  // ptr will be NULL here, even when there is POINTER_PLUS_EXPR
-  // where the first range doesn't include zero and the second one
-  // doesn't either.  As the second operand is sizetype (unsigned),
-  // consider all ranges where the MSB could be set as possible
-  // subtractions where the result might be NULL.
-  if ((!wi_includes_zero_p (type, lh_lb, lh_ub)
-   || !wi_includes_zero_p (type, rh_lb, rh_ub))
-  && !TYPE_OVERFLOW_WRAPS (type)
-  && (flag_delete_null_pointer_checks
- || !wi::sign_mask (rh_ub)))
-r.set_nonzero (type);
-  else if (lh_lb == lh_ub && lh_lb == 0
-  && rh_lb == rh_ub && rh_lb == 0)
-r.set_zero (type);
-  else
-   r.set_varying (type);
-}
-
-bool
-pointer_plus_operator::op2_range (irange &r, tree type,
- const irange &lhs ATTRIBUTE_UNUSED,
- const irange &op1 ATTRIBUTE_UNUSED,
- relation_trio trio) const
-{
-  relation_kind rel = trio.lhs_op1 ();
-  r.set_varying (type);
-
-  // If the LHS and OP1 are equal, the op2 must be zero.
-  if (rel == VREL_EQ)
-r.set_zero (type);
-  // If the LHS and OP1 are not equal, the offset must be non-zero.
-  else if (rel == VREL_NE)
-r.set_nonzero (type);
-  else
-return false;
-  return true;
-}
-
 class pointer_min_max_operator : public range_operator
 {
 public:


[gcc r15-4662] tree-optimization/116575 - SLP masked load-lanes discovery

2024-10-25 Thread Richard Biener via Gcc-cvs
https://gcc.gnu.org/g:7b2fb7ddc7a713c057d033a48c9482d5383ba54c

commit r15-4662-g7b2fb7ddc7a713c057d033a48c9482d5383ba54c
Author: Richard Biener 
Date:   Wed Oct 23 13:56:55 2024 +0200

tree-optimization/116575 - SLP masked load-lanes discovery

The following implements masked load-lane discovery for SLP.  The
challenge here is that a masked load has a full-width mask with
group-size number of elements when this becomes a masked load-lanes
instruction one mask element gates all group members.  We already
have some discovery hints in place, namely STMT_VINFO_SLP_VECT_ONLY
to guard non-uniform masks, but we need to choose a way for SLP
discovery to handle possible masked load-lanes SLP trees.

I have this time chosen to handle load-lanes discovery where we
have performed permute optimization already and conveniently got
the graph with predecessor edges built.  This is because unlike
non-masked loads masked loads with a load_permutation are never
produced by SLP discovery (because load permutation handling doesn't
handle un-permuting the mask) and thus the load-permutation lowering
which handles non-masked load-lanes discovery doesn't trigger.

With this SLP discovery for a possible masked load-lanes, thus
a masked load with uniform mask, produces a splat of a single-lane
sub-graph as the mask SLP operand.  This is a representation that
shouldn't pessimize the mask load case and allows the masked load-lanes
transform to simply elide this splat.

This fixes the aarch64-sve.exp mask_struct_load*.c testcases with
--param vect-force-slp=1

PR tree-optimization/116575
* tree-vect-slp.cc (vect_get_and_check_slp_defs): Handle
gaps, aka NULL scalar stmt.
(vect_build_slp_tree_2): Allow gaps in the middle of a
grouped mask load.  When the mask of a grouped mask load
is uniform do single-lane discovery for the mask and
insert a splat VEC_PERM_EXPR node.
(vect_optimize_slp_pass::decide_masked_load_lanes): New
function.
(vect_optimize_slp_pass::run): Call it.

Diff:
---
 gcc/tree-vect-slp.cc | 141 +--
 1 file changed, 138 insertions(+), 3 deletions(-)

diff --git a/gcc/tree-vect-slp.cc b/gcc/tree-vect-slp.cc
index 53f5400a961d..b192328e3eb7 100644
--- a/gcc/tree-vect-slp.cc
+++ b/gcc/tree-vect-slp.cc
@@ -641,6 +641,16 @@ vect_get_and_check_slp_defs (vec_info *vinfo, unsigned 
char swap,
   unsigned int commutative_op = -1U;
   bool first = stmt_num == 0;
 
+  if (!stmt_info)
+{
+  for (auto oi : *oprnds_info)
+   {
+ oi->def_stmts.quick_push (NULL);
+ oi->ops.quick_push (NULL_TREE);
+   }
+  return 0;
+}
+
   if (!is_a (stmt_info->stmt)
   && !is_a (stmt_info->stmt)
   && !is_a (stmt_info->stmt))
@@ -2029,9 +2039,11 @@ vect_build_slp_tree_2 (vec_info *vinfo, slp_tree node,
has_gaps = true;
  /* We cannot handle permuted masked loads directly, see
 PR114375.  We cannot handle strided masked loads or masked
-loads with gaps.  */
+loads with gaps unless the mask is uniform.  */
  if ((STMT_VINFO_GROUPED_ACCESS (stmt_info)
-  && (DR_GROUP_GAP (first_stmt_info) != 0 || has_gaps))
+  && (DR_GROUP_GAP (first_stmt_info) != 0
+  || (has_gaps
+  && STMT_VINFO_SLP_VECT_ONLY (first_stmt_info
  || STMT_VINFO_STRIDED_P (stmt_info))
{
  load_permutation.release ();
@@ -2054,7 +2066,12 @@ vect_build_slp_tree_2 (vec_info *vinfo, slp_tree node,
  unsigned i = 0;
  for (stmt_vec_info si = first_stmt_info;
   si; si = DR_GROUP_NEXT_ELEMENT (si))
-   stmts2[i++] = si;
+   {
+ if (si != first_stmt_info)
+   for (unsigned k = 1; k < DR_GROUP_GAP (si); ++k)
+ stmts2[i++] = NULL;
+ stmts2[i++] = si;
+   }
  bool *matches2 = XALLOCAVEC (bool, dr_group_size);
  slp_tree unperm_load
= vect_build_slp_tree (vinfo, stmts2, dr_group_size,
@@ -2683,6 +2700,46 @@ out:
  continue;
}
 
+  /* When we have a masked load with uniform mask discover this
+as a single-lane mask with a splat permute.  This way we can
+recognize this as a masked load-lane by stripping the splat.  */
+  if (is_a  (STMT_VINFO_STMT (stmt_info))
+ && gimple_call_internal_p (STMT_VINFO_STMT (stmt_info),
+IFN_MASK_LOAD)
+ && STMT_VINFO_GROUPED_ACCESS (stmt_info)
+ && ! STMT_VINFO_SLP_VECT_ONLY (DR_GROUP_FIRST_ELEMENT (stmt_i

[gcc r15-4663] tree-optimization/117277 - remove CLOBBERs before SLP code generation

2024-10-25 Thread Richard Biener via Gcc-cvs
https://gcc.gnu.org/g:482d5a7b1a4abdd95f42033ad3b8d1276b8fb20a

commit r15-4663-g482d5a7b1a4abdd95f42033ad3b8d1276b8fb20a
Author: Richard Biener 
Date:   Thu Oct 24 16:15:43 2024 +0200

tree-optimization/117277 - remove CLOBBERs before SLP code generation

We have to remove CLOBBERs before SLP is code generated since for
store-lanes we are inserting our own CLOBBERs that we want to survive.
So the following refactors vect_transform_loop to remove unwanted
stmts first.

This resolves the gcc.target/aarch64/sve/store_lane_spill_1.c FAIL.

PR tree-optimization/117277
* tree-vect-loop.cc (vect_transform_loop): Remove CLOBBERs
and prefetches before doing any code generation.

Diff:
---
 gcc/tree-vect-loop.cc | 110 +++---
 1 file changed, 59 insertions(+), 51 deletions(-)

diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc
index 698b240012d1..414f8360e518 100644
--- a/gcc/tree-vect-loop.cc
+++ b/gcc/tree-vect-loop.cc
@@ -12515,6 +12515,25 @@ vect_transform_loop (loop_vec_info loop_vinfo, gimple 
*loop_vectorized_call)
   if (LOOP_VINFO_EARLY_BREAKS (loop_vinfo))
 move_early_exit_stmts (loop_vinfo);
 
+  /* Remove existing clobber stmts and prefetches.  */
+  for (i = 0; i < nbbs; i++)
+{
+  basic_block bb = bbs[i];
+  for (gimple_stmt_iterator si = gsi_start_bb (bb); !gsi_end_p (si);)
+   {
+ stmt = gsi_stmt (si);
+ if (gimple_clobber_p (stmt)
+ || gimple_call_builtin_p (stmt, BUILT_IN_PREFETCH))
+   {
+ unlink_stmt_vdef (stmt);
+ gsi_remove (&si, true);
+ release_defs (stmt);
+   }
+ else
+   gsi_next (&si);
+   }
+}
+
   /* Schedule the SLP instances first, then handle loop vectorization
  below.  */
   if (!loop_vinfo->slp_instances.is_empty ())
@@ -12609,66 +12628,55 @@ vect_transform_loop (loop_vec_info loop_vinfo, gimple 
*loop_vectorized_call)
   !gsi_end_p (si);)
{
  stmt = gsi_stmt (si);
- /* During vectorization remove existing clobber stmts and
-prefetches.  */
- if (gimple_clobber_p (stmt)
- || gimple_call_builtin_p (stmt, BUILT_IN_PREFETCH))
-   {
- unlink_stmt_vdef (stmt);
- gsi_remove (&si, true);
- release_defs (stmt);
-   }
- else
+
+ /* Ignore vector stmts created in the outer loop.  */
+ stmt_info = loop_vinfo->lookup_stmt (stmt);
+
+ /* vector stmts created in the outer-loop during vectorization of
+stmts in an inner-loop may not have a stmt_info, and do not
+need to be vectorized.  */
+ stmt_vec_info seen_store = NULL;
+ if (stmt_info)
{
- /* Ignore vector stmts created in the outer loop.  */
- stmt_info = loop_vinfo->lookup_stmt (stmt);
-
- /* vector stmts created in the outer-loop during vectorization of
-stmts in an inner-loop may not have a stmt_info, and do not
-need to be vectorized.  */
- stmt_vec_info seen_store = NULL;
- if (stmt_info)
+ if (STMT_VINFO_IN_PATTERN_P (stmt_info))
{
- if (STMT_VINFO_IN_PATTERN_P (stmt_info))
+ gimple *def_seq = STMT_VINFO_PATTERN_DEF_SEQ (stmt_info);
+ for (gimple_stmt_iterator subsi = gsi_start (def_seq);
+  !gsi_end_p (subsi); gsi_next (&subsi))
{
- gimple *def_seq = STMT_VINFO_PATTERN_DEF_SEQ (stmt_info);
- for (gimple_stmt_iterator subsi = gsi_start (def_seq);
-  !gsi_end_p (subsi); gsi_next (&subsi))
-   {
- stmt_vec_info pat_stmt_info
-   = loop_vinfo->lookup_stmt (gsi_stmt (subsi));
- vect_transform_loop_stmt (loop_vinfo, pat_stmt_info,
-   &si, &seen_store);
-   }
  stmt_vec_info pat_stmt_info
-   = STMT_VINFO_RELATED_STMT (stmt_info);
- if (vect_transform_loop_stmt (loop_vinfo, pat_stmt_info,
-   &si, &seen_store))
-   maybe_set_vectorized_backedge_value (loop_vinfo,
-pat_stmt_info);
-   }
- else
-   {
- if (vect_transform_loop_stmt (loop_vinfo, stmt_info, &si,
-   &seen_store))
-   maybe_set_vectorized_backedge_value (loop_vinfo,
-stmt_info);
+   = loop_vinfo->lookup_stmt (gsi_st

[gcc r15-4661] Relax vect_check_scalar_mask check

2024-10-25 Thread Richard Biener via Gcc-cvs
https://gcc.gnu.org/g:07c357eae8df759705057b5d3fefdc52556fc23d

commit r15-4661-g07c357eae8df759705057b5d3fefdc52556fc23d
Author: Richard Biener 
Date:   Wed Oct 23 11:55:31 2024 +0200

Relax vect_check_scalar_mask check

When the mask is not a constant or external def there's no need to
check the scalar type, in particular with SLP and the mask being
a VEC_PERM_EXPR there isn't a scalar operand ready to check
(not one vect_is_simple_use will get you).  We later check the
vector type and reject non-mask types there.

* tree-vect-stmts.cc (vect_check_scalar_mask): Only check
the scalar type for constant or extern defs.

Diff:
---
 gcc/tree-vect-stmts.cc | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc
index ce5289ec60ee..9f1449dfc259 100644
--- a/gcc/tree-vect-stmts.cc
+++ b/gcc/tree-vect-stmts.cc
@@ -2520,7 +2520,8 @@ vect_check_scalar_mask (vec_info *vinfo, stmt_vec_info 
stmt_info,
   return false;
 }
 
-  if (!VECT_SCALAR_BOOLEAN_TYPE_P (TREE_TYPE (*mask)))
+  if ((mask_dt == vect_constant_def || mask_dt == vect_external_def)
+  && !VECT_SCALAR_BOOLEAN_TYPE_P (TREE_TYPE (*mask)))
 {
   if (dump_enabled_p ())
dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,


[gcc r15-4652] ada: Fix internal error on bit-packed array type with Volatile_Full_Access

2024-10-25 Thread Marc Poulhi?s via Gcc-cvs
https://gcc.gnu.org/g:de8d6829371821775183fbf5633cc1e654d96b78

commit r15-4652-gde8d6829371821775183fbf5633cc1e654d96b78
Author: Eric Botcazou 
Date:   Wed Sep 11 19:53:12 2024 +0200

ada: Fix internal error on bit-packed array type with Volatile_Full_Access

The problem occurs when the component type is a record type with default
values for the initialization procedure of the (base) array type, because
the compiler is trying to generate a full access for a parameter of the
base array type, which does not make sense.

gcc/ada/ChangeLog:

PR ada/116551
* gcc-interface/trans.cc (node_is_atomic) : Return
false if the type of the entity is an unconstrained array type.
(node_is_volatile_full_access) : Likewise.

Diff:
---
 gcc/ada/gcc-interface/trans.cc | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/gcc/ada/gcc-interface/trans.cc b/gcc/ada/gcc-interface/trans.cc
index 7728e60ccb6b..93f67404ddb4 100644
--- a/gcc/ada/gcc-interface/trans.cc
+++ b/gcc/ada/gcc-interface/trans.cc
@@ -4263,7 +4263,10 @@ node_is_atomic (Node_Id gnat_node)
   if (!Is_Object (gnat_entity))
break;
   return Is_Atomic (gnat_entity)
+/* Disregard the flag on unconstrained arrays or simple constants
+   since we cannot or need not generate an atomic access.  */
 || (Is_Atomic (Etype (gnat_entity))
+&& Ekind (Etype (gnat_entity)) != E_Array_Type
 && !simple_constant_p (gnat_entity));
 
 case N_Selected_Component:
@@ -4303,7 +4306,10 @@ node_is_volatile_full_access (Node_Id gnat_node)
   if (!Is_Object (gnat_entity))
break;
   return Is_Volatile_Full_Access (gnat_entity)
+/* Disregard the flag on unconstrained arrays or simple constants
+   since we cannot or need not generate a full access.  */
 || (Is_Volatile_Full_Access (Etype (gnat_entity))
+&& Ekind (Etype (gnat_entity)) != E_Array_Type
 && !simple_constant_p (gnat_entity));
 
 case N_Selected_Component:


[gcc r15-4653] ada: Fix fallout of change in parameter passing out of aliasing considerations

2024-10-25 Thread Marc Poulhi?s via Gcc-cvs
https://gcc.gnu.org/g:11e06dd243ac578f81d435ca0aea2ce3340a0650

commit r15-4653-g11e06dd243ac578f81d435ca0aea2ce3340a0650
Author: Eric Botcazou 
Date:   Wed Sep 18 08:24:32 2024 +0200

ada: Fix fallout of change in parameter passing out of aliasing 
considerations

If an actual parameter that is a type conversion is passed by reference but
not addressable, the temporary that is created and whose address is passed
instead may need to be in the target type of the conversion to fulfill the
requirements of strict aliasing.

gcc/ada/ChangeLog:

* gcc-interface/trans.cc (Call_to_gnu): If the formal is passed by
reference and the actual is a type conversion but not addressable,
create the temporary in the target type of the conversion if this
is needed to enforce strict aliasing.

Diff:
---
 gcc/ada/gcc-interface/trans.cc | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/gcc/ada/gcc-interface/trans.cc b/gcc/ada/gcc-interface/trans.cc
index 93f67404ddb4..5f8a18eebb72 100644
--- a/gcc/ada/gcc-interface/trans.cc
+++ b/gcc/ada/gcc-interface/trans.cc
@@ -5010,9 +5010,12 @@ Call_to_gnu (Node_Id gnat_node, tree *gnu_result_type_p, 
tree gnu_target,
   TREE_TYPE (gnu_name
gnu_name = convert (gnu_name_type, gnu_name);
 
- /* If the temporary is created  because of aliasing considerations,
+ /* If the temporary is created because of aliasing considerations,
+or would have been so created if the actual was addressable,
 it must be in the target type of the (unchecked) conversion.  */
- if (aliasing)
+ if (aliasing
+ || (node_is_type_conversion (gnat_actual)
+ && !aliasable_p (gnu_name, gnu_actual_type)))
{
  if (Nkind (gnat_actual) == N_Unchecked_Type_Conversion)
gnu_name = unchecked_convert (gnu_actual_type, gnu_name,


[gcc r15-4658] ada: Mark some type decls as nameless

2024-10-25 Thread Marc Poulhi?s via Gcc-cvs
https://gcc.gnu.org/g:88715b94809895343caa405accb8f3c42c791853

commit r15-4658-g88715b94809895343caa405accb8f3c42c791853
Author: Tom Tromey 
Date:   Wed Jul 10 11:54:25 2024 -0600

ada: Mark some type decls as nameless

The types created by record_builtin_type and create_type_stub_decl can
be marked as nameless when using minimal encodings.  In this
situation, gdb does not need these type names.

gcc/ada/ChangeLog:

* gcc-interface/utils.cc (record_builtin_type, 
create_type_stub_decl):
Set DECL_NAMELESS on type decls.

Diff:
---
 gcc/ada/gcc-interface/utils.cc | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/gcc/ada/gcc-interface/utils.cc b/gcc/ada/gcc-interface/utils.cc
index 9e2715a8d81f..a06366bf40e4 100644
--- a/gcc/ada/gcc-interface/utils.cc
+++ b/gcc/ada/gcc-interface/utils.cc
@@ -2019,6 +2019,8 @@ record_builtin_type (const char *name, tree type, bool 
artificial_p)
   tree type_decl = build_decl (input_location,
   TYPE_DECL, get_identifier (name), type);
   DECL_ARTIFICIAL (type_decl) = artificial_p;
+  DECL_NAMELESS (type_decl) = (artificial_p
+  && gnat_encodings != DWARF_GNAT_ENCODINGS_ALL);
   TYPE_ARTIFICIAL (type) = artificial_p;
   gnat_pushdecl (type_decl, Empty);
 
@@ -2835,6 +2837,7 @@ create_type_stub_decl (tree name, tree type)
 {
   tree type_decl = build_decl (input_location, TYPE_DECL, name, type);
   DECL_ARTIFICIAL (type_decl) = 1;
+  DECL_NAMELESS (type_decl) = gnat_encodings != DWARF_GNAT_ENCODINGS_ALL;
   TYPE_ARTIFICIAL (type) = 1;
   return type_decl;
 }


[gcc r15-4635] ada: Constraint error not raised in ACATS test c413007

2024-10-25 Thread Marc Poulhi?s via Gcc-cvs
https://gcc.gnu.org/g:2325d653e3790f3ffda9aebf7f7a94f7aacd0bc0

commit r15-4635-g2325d653e3790f3ffda9aebf7f7a94f7aacd0bc0
Author: Javier Miranda 
Date:   Tue Sep 17 11:53:06 2024 +

ada: Constraint error not raised in ACATS test c413007

The Constraint_Error exception is not raised when a subprogram
is called using prefix notation, and the prefix of the call is
an access-to-subprogram type with a null value. This new check
is enabled by switch -gnatd_P

gcc/ada/ChangeLog:

* gen_il-fields.ads: New node field (Is_Expanded_Prefixed_Call).
* gen_il-gen-gen_nodes.adb: New semantic field for N_Function_Call
and N_Procedure_Call_Statement nodes.
* sem_ch4.adb (Complete_Object_Operation): Mark the rewritten node
with the Is_Expanded_Prefixed_Call flag.
* sem_res.adb (Check_Prefixed_Call): Code cleanup and addition of
documentation.
(Resolve_Actuals): Add a null-exclusion check on the
prefix of the call when it is an access-type.
* sinfo.ads: Adding new semantic flag (Is_Expanded_Prefixed_Call)
to N_Function_Call and N_Procedure_Call_Statement nodes.
* debug.adb: Adding documentation for switch d_P.

Diff:
---
 gcc/ada/debug.adb| 10 -
 gcc/ada/gen_il-fields.ads|  1 +
 gcc/ada/gen_il-gen-gen_nodes.adb |  6 ++-
 gcc/ada/sem_ch4.adb  |  4 +-
 gcc/ada/sem_res.adb  | 93 
 gcc/ada/sinfo.ads|  6 +++
 6 files changed, 79 insertions(+), 41 deletions(-)

diff --git a/gcc/ada/debug.adb b/gcc/ada/debug.adb
index 3dbf3a7b3976..9daa0110233b 100644
--- a/gcc/ada/debug.adb
+++ b/gcc/ada/debug.adb
@@ -180,7 +180,7 @@ package body Debug is
--  d_M  Ignore Source_File_Name and Source_File_Name_Project pragmas
--  d_N
--  d_O
-   --  d_P
+   --  d_P  Enable runtime check for null prefix of prefixed subprogram call
--  d_Q
--  d_R  For LLVM, dump the representation of records
--  d_S
@@ -1040,6 +1040,14 @@ package body Debug is
--   it is checked, and the progress of the recursive trace through
--   elaboration calls at compile time.
 
+   --  d_P  For prefixed subprogram calls with an access-type prefix, generate
+   --   a null-excluding runtime check on the prefix, even when the called
+   --   subprogram has a first access parameter that does not exclude null
+   --   (that is the case only for class-wide parameter, as controlling
+   --   parameters are automatically null-excluding). In such a case,
+   --   P.Proc is equivalent to Proc(P.all'Access); see RM 6.4(9.1/5).
+   --   This includes a dereference, and thus a null check.
+
--  d_R  In the LLVM backend, output the internal representation of
--   each record
 
diff --git a/gcc/ada/gen_il-fields.ads b/gcc/ada/gen_il-fields.ads
index dcebab67d0c9..5563a9d385cd 100644
--- a/gcc/ada/gen_il-fields.ads
+++ b/gcc/ada/gen_il-fields.ads
@@ -255,6 +255,7 @@ package Gen_IL.Fields is
   Is_Elsif,
   Is_Entry_Barrier_Function,
   Is_Expanded_Build_In_Place_Call,
+  Is_Expanded_Prefixed_Call,
   Is_Folded_In_Parser,
   Is_Generic_Contract_Pragma,
   Is_Homogeneous_Aggregate,
diff --git a/gcc/ada/gen_il-gen-gen_nodes.adb b/gcc/ada/gen_il-gen-gen_nodes.adb
index d211343a6077..55d54358e460 100644
--- a/gcc/ada/gen_il-gen-gen_nodes.adb
+++ b/gcc/ada/gen_il-gen-gen_nodes.adb
@@ -408,11 +408,13 @@ begin -- Gen_IL.Gen.Gen_Nodes
Cc (N_Function_Call, N_Subprogram_Call,
(Sy (Name, Node_Id, Default_Empty),
 Sy (Parameter_Associations, List_Id, Default_No_List),
-Sm (Is_Expanded_Build_In_Place_Call, Flag)));
+Sm (Is_Expanded_Build_In_Place_Call, Flag),
+Sm (Is_Expanded_Prefixed_Call, Flag)));
 
Cc (N_Procedure_Call_Statement, N_Subprogram_Call,
(Sy (Name, Node_Id, Default_Empty),
-Sy (Parameter_Associations, List_Id, Default_No_List)));
+Sy (Parameter_Associations, List_Id, Default_No_List),
+Sm (Is_Expanded_Prefixed_Call, Flag)));
 
Ab (N_Raise_xxx_Error, N_Subexpr);
 
diff --git a/gcc/ada/sem_ch4.adb b/gcc/ada/sem_ch4.adb
index bf0d7cfd1af9..c1f6622db1e4 100644
--- a/gcc/ada/sem_ch4.adb
+++ b/gcc/ada/sem_ch4.adb
@@ -9510,7 +9510,6 @@ package body Sem_Ch4 is
Error_Msg_NE
  ("expect variable in call to&", Prefix (N), Entity (Subprog));
 end if;
-
  --  Conversely, if the formal is an access parameter and the object is
  --  not an access type or a reference type (i.e. a type with the
  --  Implicit_Dereference aspect specified), replace the actual with a
@@ -9581,6 +9580,8 @@ package body Sem_Ch4 is
 
  Rewrite (Node_To_Replace, Call_Node);
 
+ Set_Is_Expanded_Prefixed_Call (Node_To_Replace);
+
  --  Propagate the interpretations collect

[gcc r15-4640] ada: Update Compiler_Error documentation

2024-10-25 Thread Marc Poulhi?s via Gcc-cvs
https://gcc.gnu.org/g:cb0f66e02559fd57fb31f7befbaf5967792722e8

commit r15-4640-gcb0f66e02559fd57fb31f7befbaf5967792722e8
Author: Richard Kenner 
Date:   Mon May 27 11:52:16 2024 -0400

ada: Update Compiler_Error documentation

Since we usually build without assertions, we force a bugbox by
raising Program_Error, not an always-false assertion.

gcc/ada/ChangeLog:

* comperr.ads (Compiler_Error): Update documentation.

Diff:
---
 gcc/ada/comperr.ads | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/ada/comperr.ads b/gcc/ada/comperr.ads
index eb8ae4ca6c61..e60a1fd9c8e6 100644
--- a/gcc/ada/comperr.ads
+++ b/gcc/ada/comperr.ads
@@ -46,7 +46,7 @@ package Comperr is
--  Note that this is only used at the outer level (to handle constraint
--  errors or assert errors etc.) In the normal logic of the compiler we
--  always use pragma Assert to check for errors, and if necessary an
-   --  explicit abort is achieved by pragma Assert (False). From_GCC is true
+   --  explicit abort is achieved by raise Program_Error. From_GCC is true
--  for a GCC abort and false for a front end exception (with a possible
--  message stored in TSD.Current_Excep).


[gcc r15-4664] Restrict :c to commutative ops as intended

2024-10-25 Thread Richard Biener via Gcc-cvs
https://gcc.gnu.org/g:967939055cee4a34729f795042977d99535e061a

commit r15-4664-g967939055cee4a34729f795042977d99535e061a
Author: Richard Biener 
Date:   Thu Oct 24 17:06:29 2024 +0200

Restrict :c to commutative ops as intended

genmatch was supposed to restrict :c to verifiable commutative
operations while leaving :C to the "I know what I'm doing" case.
The following enforces this, cleaning up parsing and amending
the commutative_op helper.  There's one pattern that needs adjustment,
the pattern optimizing fmax (x, NaN) or fmax (NaN, x) to x since
fmax isn't commutative.

* genmatch.cc (commutative_op): Add paramter to indicate whether
all compares should be considered commutative.  Handle
hypot, add_overflow and mul_overflow.
(parser::parse_expr): Simplify 'c' handling by using
commutative_op and error out when the operation is not.
* match.pd ((minmax:c @0 NaN@1) -> @0): Use :C, we know
what we are doing.

Diff:
---
 gcc/genmatch.cc | 40 +++-
 gcc/match.pd|  2 +-
 2 files changed, 16 insertions(+), 26 deletions(-)

diff --git a/gcc/genmatch.cc b/gcc/genmatch.cc
index 1682206efee0..1acd9216b3b0 100644
--- a/gcc/genmatch.cc
+++ b/gcc/genmatch.cc
@@ -1107,12 +1107,13 @@ is_a_helper ::test (id_base *id)
index of the first, otherwise return -1.  */
 
 static int
-commutative_op (id_base *id)
+commutative_op (id_base *id, bool compares_are_commutative = false)
 {
   if (operator_id *code = dyn_cast  (id))
 {
   if (commutative_tree_code (code->code)
- || commutative_ternary_tree_code (code->code))
+ || commutative_ternary_tree_code (code->code)
+ || (compares_are_commutative && comparison_code_p (code->code)))
return 0;
   return -1;
 }
@@ -1120,9 +1121,12 @@ commutative_op (id_base *id)
 switch (fn->fn)
   {
   CASE_CFN_FMA:
+  CASE_CFN_HYPOT:
   case CFN_FMS:
   case CFN_FNMA:
   case CFN_FNMS:
+  case CFN_ADD_OVERFLOW:
+  case CFN_MUL_OVERFLOW:
return 0;
 
   case CFN_COND_ADD:
@@ -1158,11 +1162,13 @@ commutative_op (id_base *id)
   }
   if (user_id *uid = dyn_cast (id))
 {
-  int res = commutative_op (uid->substitutes[0]);
+  int res = commutative_op (uid->substitutes[0],
+   compares_are_commutative);
   if (res < 0)
return -1;
   for (unsigned i = 1; i < uid->substitutes.length (); ++i)
-   if (res != commutative_op (uid->substitutes[i]))
+   if (res != commutative_op (uid->substitutes[i],
+  compares_are_commutative))
  return -1;
   return res;
 }
@@ -5214,27 +5220,11 @@ parser::parse_expr ()
{
  if (*sp == 'c')
{
- if (operator_id *o
-   = dyn_cast (e->operation))
-   {
- if (!commutative_tree_code (o->code)
- && !comparison_code_p (o->code))
-   fatal_at (token, "operation is not commutative");
-   }
- else if (user_id *p = dyn_cast (e->operation))
-   for (unsigned i = 0;
-i < p->substitutes.length (); ++i)
- {
-   if (operator_id *q
- = dyn_cast (p->substitutes[i]))
- {
-   if (!commutative_tree_code (q->code)
-   && !comparison_code_p (q->code))
- fatal_at (token, "operation %s is not "
-   "commutative", q->id);
- }
- }
- is_commutative = true;
+ if (commutative_op (e->operation, true) != -1)
+   is_commutative = true;
+ else
+   fatal_at (token, "operation %s is not known "
+ "commutative", e->operation->id);
}
  else if (*sp == 'C')
is_commutative = true;
diff --git a/gcc/match.pd b/gcc/match.pd
index 148d0bc65d03..93536a39348d 100644
--- a/gcc/match.pd
+++ b/gcc/match.pd
@@ -4672,7 +4672,7 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
  /* If either argument is NaN and other one is not sNaN, return the other
 one.  Avoid the transformation if we get (and honor) a signalling NaN.  */
  (simplify
-  (minmax:c @0 REAL_CST@1)
+  (minmax:C @0 REAL_CST@1)
(if (real_isnan (TREE_REAL_CST_PTR (@1))
&& (!HONOR_SNANS (@1) || !TREE_REAL_CST (@1).signalling)
&& !tree_expr_maybe_signaling_nan_p (@0))


[gcc r14-10839] c++: Further fix for get_member_function_from_ptrfunc [PR117259]

2024-10-25 Thread Jakub Jelinek via Gcc-cvs
https://gcc.gnu.org/g:8bd4f104ff9cd4d47b301698ae29010924a0fe9d

commit r14-10839-g8bd4f104ff9cd4d47b301698ae29010924a0fe9d
Author: Jakub Jelinek 
Date:   Thu Oct 24 12:56:19 2024 +0200

c++: Further fix for get_member_function_from_ptrfunc [PR117259]

The following testcase shows that the previous 
get_member_function_from_ptrfunc
changes weren't sufficient and we still have cases where
-fsanitize=undefined with pointers to member functions can cause wrong code
being generated and related false positive warnings.

The problem is that save_expr doesn't always create SAVE_EXPR, it can skip
some invariant arithmetics and in the end it could be really large
expressions which would be evaluated several times (and what is worse, with
-fsanitize=undefined those expressions then can have SAVE_EXPRs added to
their subparts for -fsanitize=bounds or -fsanitize=null or
-fsanitize=alignment instrumentation).  Tried to just build1 a SAVE_EXPR
+ add TREE_SIDE_EFFECTS instead of save_expr, but that doesn't work either,
because cp_fold happily optimizes those SAVE_EXPRs away when it sees
SAVE_EXPR operand is tree_invariant_p.

So, the following patch instead of using save_expr or building SAVE_EXPR
manually builds a TARGET_EXPR.  Both types are pointers, so it doesn't need
to be destroyed in any way, but TARGET_EXPR is what doesn't get optimized
away immediately.

2024-10-24  Jakub Jelinek  

PR c++/117259
* typeck.cc (get_member_function_from_ptrfunc): Use 
force_target_expr
rather than save_expr for instance_ptr and function.  Don't call it
for TREE_CONSTANT.

* g++.dg/ubsan/pr117259.C: New test.

(cherry picked from commit b25d3201b6338d9f71c64f524ca2974d9a1f38e8)

Diff:
---
 gcc/cp/typeck.cc  | 31 +--
 gcc/testsuite/g++.dg/ubsan/pr117259.C | 13 +
 2 files changed, 30 insertions(+), 14 deletions(-)

diff --git a/gcc/cp/typeck.cc b/gcc/cp/typeck.cc
index 3d62943f8647..a72599bc1536 100644
--- a/gcc/cp/typeck.cc
+++ b/gcc/cp/typeck.cc
@@ -4175,24 +4175,27 @@ get_member_function_from_ptrfunc (tree 
*instance_ptrptr, tree function,
   if (!nonvirtual && is_dummy_object (instance_ptr))
nonvirtual = true;
 
-  /* Use save_expr even when instance_ptr doesn't have side-effects,
-unless it is a simple decl (save_expr won't do anything on
-constants), so that we don't ubsan instrument the expression
-multiple times.  See PR116449.  */
+  /* Use force_target_expr even when instance_ptr doesn't have
+side-effects, unless it is a simple decl or constant, so
+that we don't ubsan instrument the expression multiple times.
+Don't use save_expr, as save_expr can avoid building a SAVE_EXPR
+and building a SAVE_EXPR manually can be optimized away during
+cp_fold.  See PR116449 and PR117259.  */
   if (TREE_SIDE_EFFECTS (instance_ptr)
- || (!nonvirtual && !DECL_P (instance_ptr)))
-   {
- instance_save_expr = save_expr (instance_ptr);
- if (instance_save_expr == instance_ptr)
-   instance_save_expr = NULL_TREE;
- else
-   instance_ptr = instance_save_expr;
-   }
+ || (!nonvirtual
+ && !DECL_P (instance_ptr)
+ && !TREE_CONSTANT (instance_ptr)))
+   instance_ptr = instance_save_expr
+ = force_target_expr (TREE_TYPE (instance_ptr), instance_ptr,
+  complain);
 
   /* See above comment.  */
   if (TREE_SIDE_EFFECTS (function)
- || (!nonvirtual && !DECL_P (function)))
-   function = save_expr (function);
+ || (!nonvirtual
+ && !DECL_P (function)
+ && !TREE_CONSTANT (function)))
+   function
+ = force_target_expr (TREE_TYPE (function), function, complain);
 
   /* Start by extracting all the information from the PMF itself.  */
   e3 = pfn_from_ptrmemfunc (function);
diff --git a/gcc/testsuite/g++.dg/ubsan/pr117259.C 
b/gcc/testsuite/g++.dg/ubsan/pr117259.C
new file mode 100644
index ..2b7ba56c2a36
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ubsan/pr117259.C
@@ -0,0 +1,13 @@
+// PR c++/117259
+// { dg-do compile }
+// { dg-options "-Wuninitialized -fsanitize=undefined" }
+
+struct A { void foo () {} };
+struct B { void (A::*b) (); B (void (A::*x) ()) : b(x) {}; };
+const B c[1] = { &A::foo };
+
+void
+foo (A *x, int y)
+{
+  (x->*c[y].b) ();
+}


[gcc/redhat/heads/gcc-14-branch] (174 commits) Merge commit 'r14-10840-g7965062f9e9ba634247b1dab22e1d83f44

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

 3f6cf880bdad... Merge commit 'r14-10840-g7965062f9e9ba634247b1dab22e1d83f44

It previously pointed to:

 c7a1c1a4bf73... Merge commit 'r14-10667-g5609246b561ab929b24eeb32965911884b

Diff:

Summary of changes (added commits):
---

  3f6cf88... Merge commit 'r14-10840-g7965062f9e9ba634247b1dab22e1d83f44
  7965062... Assorted --disable-checking fixes [PR117249] (*)
  8bd4f10... c++: Further fix for get_member_function_from_ptrfunc [PR11 (*)
  85221c9... asan: Fix up build_check_stmt gsi handling [PR117209] (*)
  11b5128... Add regression test (*)
  d587da2... ada: Fix internal error on bit-packed array type with Volat (*)
  ddba843... AVR: target/116953 - Restore recog_data after calling jump_ (*)
  944d585... Fortran: Simplify len_trim with array ref and fix mapping b (*)
  2d47645... c++: remove dg-warning [PR117274] (*)
  9eb9686... Daily bump. (*)
  b718f6e... Fix ICE due to isa mismatch for the builtins. (*)
  20c180c... c-family: Fix up -Wsizeof-pointer-memaccess ICEs [PR117230] (*)
  6603ec4... match.pd: Further fma negation fixes [PR116891] (*)
  ffce44e... middle-end/116891 - fix (negate (IFN_FNMS@3 @0 @1 @2)) -> ( (*)
  608486e... Daily bump. (*)
  7de78f7... c++: non-dep structured binding decltype again [PR117107] (*)
  01d3a97... c++/modules: Fix treatment of unnamed types [PR116929] (*)
  8b1146f... testsuite: arm: Use check-function-bodies in fp16-aapcs-* t (*)
  cc1e605... testsuite: arm: Relax expected asm in bitfield* and union-2 (*)
  47c66c5... testsuite: arm: Use check-function-bodies in cmse-5 tests (*)
  1ab9081... testsuite: Skip pr112305.c for -O[01] on simulators (*)
  f381a21... libstdc++: Implement LWG 3664 changes to ranges::distance (*)
  07ee687... libstdc++/ranges: Implement various small LWG issues (*)
  be56fee... libstdc++: Add some missing ranges feature-test macro tests (*)
  0b2f2a7... libstdc++: Implement P2997R1 changes to the indirect invoca (*)
  3795ac8... libstdc++: Implement P2609R3 changes to the indirect invoca (*)
  04c9cbe... Daily bump. (*)
  44c3eba... tree-optimization/117104 - add missed guards to max(a,b) != (*)
  1d11536... tree-optimization/116982 - analyze scalar loop exit early (*)
  a474455... tree-optimization/116907 - stale BLOCK reference from DECL_ (*)
  8d8b8ed... tree-optimization/116481 - avoid building function_type[] (*)
  69934cb... tree-optimization/116290 - fix compare-debug issue in ldist (*)
  2ac6159... middle-end/115110 - Fix view_converted_memref_p (*)
  17f1277... rs6000: Correct the function code for _AMO_LD_DEC_BOUNDED (*)
  79e7e02... Refine splitters related to "combine vpcmpuw + zero_extend  (*)
  809a582... Daily bump. (*)
  2eb6818... Daily bump. (*)
  e2df2ca... Daily bump. (*)
  f057e95... ipa: Treat static constructors and destructors as non-local (*)
  ab465ce... RISC-V:Bugfix for C++ code compilation failure with rv32ima (*)
  c468a00... c++: checking ICE w/ constexpr if and lambda as def targ [P (*)
  36de56d... c++: ICE with -Wtautological-compare in template [PR116534] (*)
  0784e89... c++: wrong error due to std::initializer_list opt [PR116476 (*)
  420e17e... c++: ICE with ()-init and TARGET_EXPR eliding [PR116424] (*)
  8be94d5... i386: Fix expand_vector_set for VEC_MERGE/VEC_DUPLICATE RTX (*)
  ed664f8... Daily bump. (*)
  23480ef... libstdc++: Fix Python deprecation warning in printers.py (*)
  f1cee9d... libstdc++: Increase timeouts for PSTL tests in debug mode [ (*)
  4d8a55a... libstdc++: Implement LWG 3564 for ranges::transform_view (*)
  f1436fd... libstdc++: Fix localized %c formatting for  [PR1170 (*)
  7836113... libstdc++: Tweak %c formatting for chrono types (*)
  8f181a2... libstdc++: Populate generic std::time_get's wide %c format  (*)
  cbb1814... libstdc++: Use std::move for iterator in ranges::fill [PR11 (*)
  abbfe1e... middle-end: Fix ifcvt predicate generation for masked funct (*)
  f0629e3... Fix handling of ICF_NOVOPS in ipa-modref (*)
  a9ab9b6... aarch64: Fix caller saves of VNx2QI [PR116238] (*)
  b62c956... Add regression test (*)
  aff061f... ada: Type conversion in instance incorrectly rejected. (*)
  9b7d5ec... Add a new tune avx256_avoid_vec_perm for SRF. (*)
  fe0692f... Add new microarchitecture tune for SRF/GRR/CWF. (*)
  20131c1... Daily bump. (*)
  d8ac855... testsuite: fix PR111613 test (*)
  81fd5bf... tree-optimization/117041 - fix load classification of forme (*)
  6638d6e... middle-end/117086 - fixup vec_cond simplifications (*)
  50d0fda... tree-optimization/116990 - missed control flow check in vec (*)
  ae4b9dc... tree-optimization/116879 - failure to recognize non-empty l (*)
  32bc20d... tree-optimization/116850 - corrupt post-dom info (*)
  18bc415... tree-optimization/116768 - wrong dependence analysis (*)
  987a7b5... tree-optimization/116166 - forward jump-threading going wil (*)
  68316af... i386: Fix up ix86_expand_int_compare with TImode comparison (*)
  80f1343... ra

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

2024-10-25 Thread Jakub Jelinek via Gcc-cvs
https://gcc.gnu.org/g:3f6cf880bdadb4404d5540bad605ceec58261359

commit 3f6cf880bdadb4404d5540bad605ceec58261359
Merge: c7a1c1a4bf73 7965062f9e9b
Author: Jakub Jelinek 
Date:   Fri Oct 25 17:31:50 2024 +0200

Merge commit 'r14-10840-g7965062f9e9ba634247b1dab22e1d83f446337ab' into 
redhat/gcc-14-branch

Diff:

 gcc/ChangeLog  | 629 +
 gcc/DATESTAMP  |   2 +-
 gcc/ada/ChangeLog  |  40 ++
 gcc/ada/exp_aggr.adb   |  22 +-
 gcc/ada/exp_aggr.ads   |   4 +
 gcc/ada/exp_ch3.adb|  15 +-
 gcc/ada/exp_ch7.adb|   6 +
 gcc/ada/exp_put_image.adb  |   3 +-
 gcc/ada/exp_util.adb   |   1 +
 gcc/ada/gcc-interface/trans.cc |   6 +
 gcc/ada/sem_ch12.adb   |   6 +-
 gcc/ada/sem_res.adb|   2 +-
 gcc/asan.cc|  14 +-
 gcc/c-family/ChangeLog |  15 +
 gcc/c-family/c-cppbuiltin.cc   |   6 +-
 gcc/c-family/c-warn.cc |  20 +-
 gcc/c/ChangeLog|   9 +
 gcc/c/c-typeck.cc  |   5 +-
 gcc/cgraph.cc  |   7 +-
 gcc/common/config/i386/i386-common.cc  |  46 +-
 gcc/config/aarch64/aarch64.cc  |   7 +-
 gcc/config/avr/avr.cc  |   4 +
 gcc/config/darwin.h|   4 +
 gcc/config/darwin.opt  |   4 +
 gcc/config/i386/i386-builtin.def   |  16 +-
 gcc/config/i386/i386-expand.cc |  28 +-
 gcc/config/i386/i386.cc|  66 ++-
 gcc/config/i386/i386.h |  38 +-
 gcc/config/i386/sse.md | 247 
 gcc/config/i386/subst.md   |   3 +
 gcc/config/i386/x86-tune-costs.h   |  23 +-
 gcc/config/i386/x86-tune-sched.cc  |  67 ++-
 gcc/config/i386/x86-tune.def   |  47 +-
 gcc/config/nvptx/nvptx.cc  |   2 +-
 gcc/config/pa/pa.h |   3 +
 gcc/config/pa/pa.md| 102 +++-
 gcc/config/riscv/riscv-c.cc|   7 +-
 gcc/config/rs6000/amo.h|   2 +-
 gcc/config/s390/s390-protos.h  |   1 -
 gcc/config/s390/s390.cc|  64 +--
 gcc/config/s390/s390.md|  15 +-
 gcc/config/s390/vector.md  |  75 +--
 gcc/cp/ChangeLog   | 120 
 gcc/cp/call.cc |  30 +-
 gcc/cp/constexpr.cc|   1 +
 gcc/cp/decl.cc |   5 +-
 gcc/cp/optimize.cc |   6 +
 gcc/cp/pt.cc   |   9 +-
 gcc/cp/tree.cc |  15 +-
 gcc/cp/typeck.cc   |  31 +-
 gcc/cp/typeck2.cc  |  14 +-
 gcc/cselib.cc  |   5 +
 gcc/doc/invoke.texi| 260 -
 gcc/except.cc  |   6 +-
 gcc/fold-const.cc  |  47 +-
 gcc/fortran/ChangeLog  |  10 +
 gcc/fortran/simplify.cc|  75 +++
 gcc/fortran/trans-decl.cc  |   3 +-
 gcc/fortran/trans-expr.cc  |  18 +-
 gcc/genautomata.cc |   3 +-
 gcc/gimple-range-cache.cc  |  21 +-
 gcc/gimple-ssa-isolate-paths.cc|  23 +-
 gcc/gimple-ssa-strength-reduction.cc   |   6 +-
 gcc/gimplify.cc|   8 +
 gcc/ipa-modref.cc  |  39 +-
 gcc/ipa-visibility.cc  |   5 +-
 gcc/lto-cgraph.cc  |   3 +-
 gcc/match.pd   |  59 +-
 gcc/opts-common.cc |   6 +-
 gcc/po/ChangeLog   |   4 +
 gcc/po/zh_CN.po| 461 ++-
 gcc/pointer-query.cc   |  11 +
 gcc/testsuite/ChangeLog| 552 ++
 .../c-c++-common/Wsizeof-pointer-memaccess5.c  |  29 +
 gcc/testsuite/g++.dg/cpp0x/initlist-opt2.C |  21 +
 gcc/testsuite/g++.dg/cpp1z/constexpr-116676.C  |  57 ++

[gcc r14-10838] asan: Fix up build_check_stmt gsi handling [PR117209]

2024-10-25 Thread Jakub Jelinek via Gcc-cvs
https://gcc.gnu.org/g:85221c95e3458de903ca9eeef76345e8326d3ec2

commit r14-10838-g85221c95e3458de903ca9eeef76345e8326d3ec2
Author: Jakub Jelinek 
Date:   Thu Oct 24 12:45:34 2024 +0200

asan: Fix up build_check_stmt gsi handling [PR117209]

gsi_safe_insert_before properly updates gsi_bb in gimple_stmt_iterator
in case it splits objects, but unfortunately build_check_stmt was in
some places (but not others) using a copy of the iterator rather than
the iterator passed from callers and so didn't propagate that to callers.
I guess it didn't matter much before when it was just using
gsi_insert_before as that really didn't change the iterator.
The !before_p case is apparently dead code, nothing is calling it with
before_p=false since around 4.9.

2024-10-24  Jakub Jelinek  

PR sanitizer/117209
* asan.cc (maybe_cast_to_ptrmode): Formatting fix.
(build_check_stmt): Don't copy *iter into gsi, perform all
the updates on iter directly.

* gcc.dg/asan/pr117209.c: New test.

(cherry picked from commit 885143fa77599c44bfdd4e8e6b6987b7824db6ba)

Diff:
---
 gcc/asan.cc  | 14 +-
 gcc/testsuite/gcc.dg/asan/pr117209.c | 15 +++
 2 files changed, 20 insertions(+), 9 deletions(-)

diff --git a/gcc/asan.cc b/gcc/asan.cc
index 9e0f51b1477c..386aeec81557 100644
--- a/gcc/asan.cc
+++ b/gcc/asan.cc
@@ -2610,7 +2610,7 @@ maybe_cast_to_ptrmode (location_t loc, tree len, 
gimple_stmt_iterator *iter,
   if (ptrofftype_p (len))
 return len;
   gimple *g = gimple_build_assign (make_ssa_name (pointer_sized_int_node),
- NOP_EXPR, len);
+  NOP_EXPR, len);
   gimple_set_location (g, loc);
   if (before_p)
 gsi_safe_insert_before (iter, g);
@@ -2644,16 +2644,13 @@ build_check_stmt (location_t loc, tree base, tree len,
  bool is_non_zero_len, bool before_p, bool is_store,
  bool is_scalar_access, unsigned int align = 0)
 {
-  gimple_stmt_iterator gsi = *iter;
   gimple *g;
 
   gcc_assert (!(size_in_bytes > 0 && !is_non_zero_len));
   gcc_assert (size_in_bytes == -1 || size_in_bytes >= 1);
 
-  gsi = *iter;
-
   base = unshare_expr (base);
-  base = maybe_create_ssa_name (loc, base, &gsi, before_p);
+  base = maybe_create_ssa_name (loc, base, iter, before_p);
 
   if (len)
 {
@@ -2704,12 +2701,11 @@ build_check_stmt (location_t loc, tree base, tree len,
 align / BITS_PER_UNIT));
   gimple_set_location (g, loc);
   if (before_p)
-gsi_safe_insert_before (&gsi, g);
+gsi_safe_insert_before (iter, g);
   else
 {
-  gsi_insert_after (&gsi, g, GSI_NEW_STMT);
-  gsi_next (&gsi);
-  *iter = gsi;
+  gsi_insert_after (iter, g, GSI_NEW_STMT);
+  gsi_next (iter);
 }
 }
 
diff --git a/gcc/testsuite/gcc.dg/asan/pr117209.c 
b/gcc/testsuite/gcc.dg/asan/pr117209.c
new file mode 100644
index ..34c71ba260b3
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/asan/pr117209.c
@@ -0,0 +1,15 @@
+/* PR sanitizer/117209 */
+/* { dg-do compile } */
+/* { dg-options "-fsanitize=address" } */
+
+struct A { char a; };
+void foo (void);
+__attribute__((returns_twice, const)) int bar (struct A);
+
+void
+baz (struct A *x, int *y, int z)
+{
+  if (z)
+foo (); 
+  *y = bar (*x);
+}


[gcc r15-4676] testsuite: add testcase for fixed PR115933

2024-10-25 Thread Sam James via Gcc-cvs
https://gcc.gnu.org/g:68e7ced1c7a9b205d3de5937d36ceab94fb44144

commit r15-4676-g68e7ced1c7a9b205d3de5937d36ceab94fb44144
Author: Sam James 
Date:   Sun Oct 20 08:28:59 2024 +0100

testsuite: add testcase for fixed PR115933

gcc/testsuite/ChangeLog:
PR rtl-optimization/115933

* gcc.dg/pr115933.c: New test.

Diff:
---
 gcc/testsuite/gcc.dg/pr115933.c | 19 +++
 1 file changed, 19 insertions(+)

diff --git a/gcc/testsuite/gcc.dg/pr115933.c b/gcc/testsuite/gcc.dg/pr115933.c
new file mode 100644
index ..041597ae3309
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr115933.c
@@ -0,0 +1,19 @@
+/* PR rtl-optimization/115933 */
+/* { dg-do run } */
+/* { dg-options "-O1 -fno-tree-loop-optimize -ftree-vrp -fno-tree-ch -fgcse" } 
*/
+
+int a, b;
+unsigned c() {
+  int d, e = d = 2;
+  if (a < 0)
+for (e = 0; e < 1; e++)
+  d = 0;
+  b = e;
+  return d;
+}
+int main() {
+  c();
+  if (b != 2)
+__builtin_abort();
+  return 0;
+}


[gcc r15-4677] Fortran: Fix ICE with structure constructor in data statement [PR79685]

2024-10-25 Thread Paul Thomas via Gcc-cvs
https://gcc.gnu.org/g:6cb1da72cac166bd3b005c0430557b68b9761da5

commit r15-4677-g6cb1da72cac166bd3b005c0430557b68b9761da5
Author: Paul Thomas 
Date:   Fri Oct 25 17:59:03 2024 +0100

Fortran: Fix ICE with structure constructor in data statement [PR79685]

2024-10-25  Paul Thomas  

gcc/fortran
PR fortran/79685
* decl.cc (match_data_constant): Find the symtree instead of
the symbol so the use renamed symbols are found. Pass this and
the derived type to gfc_match_structure_constructor.
* match.h: Update prototype of gfc_match_structure_contructor.
* primary.cc (gfc_match_structure_constructor): Remove call to
gfc_get_ha_sym_tree and use caller supplied symtree instead.

gcc/testsuite/
PR fortran/79685
* gfortran.dg/use_rename_13.f90: New test.

Diff:
---
 gcc/fortran/decl.cc |  7 --
 gcc/fortran/match.h |  2 +-
 gcc/fortran/primary.cc  |  8 +++
 gcc/testsuite/gfortran.dg/use_rename_13.f90 | 37 +
 4 files changed, 46 insertions(+), 8 deletions(-)

diff --git a/gcc/fortran/decl.cc b/gcc/fortran/decl.cc
index 499a8462629e..000c8dcf34ed 100644
--- a/gcc/fortran/decl.cc
+++ b/gcc/fortran/decl.cc
@@ -377,6 +377,7 @@ match_data_constant (gfc_expr **result)
   gfc_expr *expr;
   match m;
   locus old_loc;
+  gfc_symtree *symtree;
 
   m = gfc_match_literal_constant (&expr, 1);
   if (m == MATCH_YES)
@@ -437,9 +438,11 @@ match_data_constant (gfc_expr **result)
   if (m != MATCH_YES)
 return m;
 
-  if (gfc_find_symbol (name, NULL, 1, &sym))
+  if (gfc_find_sym_tree (name, NULL, 1, &symtree))
 return MATCH_ERROR;
 
+  sym = symtree->n.sym;
+
   if (sym && sym->attr.generic)
 dt_sym = gfc_find_dt_in_generic (sym);
 
@@ -453,7 +456,7 @@ match_data_constant (gfc_expr **result)
   return MATCH_ERROR;
 }
   else if (dt_sym && gfc_fl_struct (dt_sym->attr.flavor))
-return gfc_match_structure_constructor (dt_sym, result);
+return gfc_match_structure_constructor (dt_sym, symtree, result);
 
   /* Check to see if the value is an initialization array expression.  */
   if (sym->value->expr_type == EXPR_ARRAY)
diff --git a/gcc/fortran/match.h b/gcc/fortran/match.h
index b2158e12a92f..13972bfe3e10 100644
--- a/gcc/fortran/match.h
+++ b/gcc/fortran/match.h
@@ -303,7 +303,7 @@ match gfc_match_bind_c_stmt (void);
 match gfc_match_bind_c (gfc_symbol *, bool);
 
 /* primary.cc.  */
-match gfc_match_structure_constructor (gfc_symbol *, gfc_expr **);
+match gfc_match_structure_constructor (gfc_symbol *, gfc_symtree *, gfc_expr 
**);
 match gfc_match_variable (gfc_expr **, int);
 match gfc_match_equiv_variable (gfc_expr **);
 match gfc_match_actual_arglist (int, gfc_actual_arglist **, bool = false);
diff --git a/gcc/fortran/primary.cc b/gcc/fortran/primary.cc
index f3f659cf8dfe..0f258edd1294 100644
--- a/gcc/fortran/primary.cc
+++ b/gcc/fortran/primary.cc
@@ -3648,18 +3648,16 @@ gfc_convert_to_structure_constructor (gfc_expr *e, 
gfc_symbol *sym, gfc_expr **c
 
 
 match
-gfc_match_structure_constructor (gfc_symbol *sym, gfc_expr **result)
+gfc_match_structure_constructor (gfc_symbol *sym, gfc_symtree *symtree,
+gfc_expr **result)
 {
   match m;
   gfc_expr *e;
-  gfc_symtree *symtree;
   bool t = true;
 
-  gfc_get_ha_sym_tree (sym->name, &symtree);
-
   e = gfc_get_expr ();
-  e->symtree = symtree;
   e->expr_type = EXPR_FUNCTION;
+  e->symtree = symtree;
   e->where = gfc_current_locus;
 
   gcc_assert (gfc_fl_struct (sym->attr.flavor)
diff --git a/gcc/testsuite/gfortran.dg/use_rename_13.f90 
b/gcc/testsuite/gfortran.dg/use_rename_13.f90
new file mode 100644
index ..97f26f42f762
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/use_rename_13.f90
@@ -0,0 +1,37 @@
+! { dg-do compile }
+!
+! Test the fix for pr79685, which failed as in the comments below.
+!
+! Contributed by Juergen Reuter  
+!
+module omega_color
+  implicit none
+
+  type omega_color_factor
+ integer :: i
+  end type
+
+  type(omega_color_factor), parameter :: op = omega_color_factor (199)
+
+end module
+
+module foo
+  use omega_color, ocf => omega_color_factor, ocfp => op
+  implicit none
+
+  type(ocf) :: table_color_factors1 = ocf(42)
+  type(ocf) :: table_color_factors2
+  type(ocf) :: table_color_factors3 (2)
+  type(ocf) :: table_color_factors4
+  data table_color_factors2 / ocf(99) /! This failed in 
gfc_match_structure_constructor.
+  data table_color_factors3 / ocf(1), ocf(2) / ! ditto.
+  data table_color_factors4 / ocfp /
+end module
+
+  use foo
+  if (table_color_factors1%i .ne. 42) stop 1
+  if (table_color_factors2%i .ne. 99) stop 2
+  if (any (table_color_factors3%i .ne. [1,2])) stop 3
+  if (table_color_factors4%i .ne. 199) stop 4
+end
+


[gcc r15-4683] testsuite: lto: rename pr47333 test

2024-10-25 Thread Sam James via Gcc-cvs
https://gcc.gnu.org/g:04e0fbbc34e1015f081676c6fc7c674cf0eeb1d5

commit r15-4683-g04e0fbbc34e1015f081676c6fc7c674cf0eeb1d5
Author: Sam James 
Date:   Fri Oct 25 16:31:01 2024 +0100

testsuite: lto: rename pr47333 test

This was being ignored previously. Rename it per README.

gcc/testsuite/ChangeLog:
PR target/47333

* g++.dg/lto/pr47333.C: Move to...
* g++.dg/lto/pr47333_0.C: ...here.

Diff:
---
 gcc/testsuite/g++.dg/lto/{pr47333.C => pr47333_0.C} | 0
 1 file changed, 0 insertions(+), 0 deletions(-)

diff --git a/gcc/testsuite/g++.dg/lto/pr47333.C 
b/gcc/testsuite/g++.dg/lto/pr47333_0.C
similarity index 100%
rename from gcc/testsuite/g++.dg/lto/pr47333.C
rename to gcc/testsuite/g++.dg/lto/pr47333_0.C


[gcc r15-4692] testsuite: fixup tbaa test again

2024-10-25 Thread Sam James via Gcc-cvs
https://gcc.gnu.org/g:40fedaf35fa99a9728d5b84d47035f4c92e1ba90

commit r15-4692-g40fedaf35fa99a9728d5b84d47035f4c92e1ba90
Author: Sam James 
Date:   Sat Oct 26 02:03:43 2024 +0100

testsuite: fixup tbaa test again

Test was broken until r15-4684-g2d1d6be00257c5 which made it actually
run and r15-4685-g091e45b4e97d1e which applied fixes other than the
trivial rename.

But more is needed: this gets the test working properly in terms of scanning
the dump and handling the interaction w/ LTO with not producing an 
executable
(did try ltrans scan but that didn't work either).

Unfortunately, the test seems to fail for me on godbolt even going back to
GCC 7.1 or thereabouts, hence XFAIL. However, if I revert 
r9-3870-g2a98b4bfc3d952,
I do get an ICE in fld_incomplete_type_of -- because we do far more checking
with LTO now on (in)complete types. And reverting it on releases/gcc-9 
actually
makes it give 0.

In summary: fix the test fully so it really does run and we get a check
for ICEing at least, and mark the dg-final scan as XFAIL so Honza can
comment on that.

gcc/testsuite/ChangeLog:
PR testsuite/117299

* gcc.dg/lto/tbaa_0.c: Move to...
* gcc.dg/tbaa.c: ...here.

Diff:
---
 gcc/testsuite/gcc.dg/{lto/tbaa_0.c => tbaa.c} | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/gcc/testsuite/gcc.dg/lto/tbaa_0.c b/gcc/testsuite/gcc.dg/tbaa.c
similarity index 77%
rename from gcc/testsuite/gcc.dg/lto/tbaa_0.c
rename to gcc/testsuite/gcc.dg/tbaa.c
index eb14ea62b896..b336622afd1a 100644
--- a/gcc/testsuite/gcc.dg/lto/tbaa_0.c
+++ b/gcc/testsuite/gcc.dg/tbaa.c
@@ -1,6 +1,6 @@
-/* { dg-lto-do link } */
-/* We need -flto=partition=none to get the dump file for scan-tree-dump-times. 
*/
-/* { dg-lto-options {{ -O2 -flto -flto-partition=none -fdump-tree-evrp 
-std=gnu89 }} } */
+/* { dg-do assemble } */
+/* { dg-options "-O2 -flto -flto-partition=one -fdump-tree-evrp -std=gnu89" } 
*/
+/* { dg-require-effective-target lto } */
 
 typedef struct rtx_def *rtx;
 typedef struct cselib_val_struct
@@ -40,4 +40,4 @@ discard_useless_locs (x, info)
   n_useless_values++;
 }
 }
-/* { dg-final { scan-tree-dump-times "n_useless_values" 2 "evrp" } } */
+/* { dg-final { scan-tree-dump-times "n_useless_values" 2 "evrp" { xfail *-*-* 
} } } */


[gcc r15-4597] Remove pointer_min_max_operator.

2024-10-25 Thread Andrew Macleod via Gcc-cvs
https://gcc.gnu.org/g:7173e2ff30c1e42168db4ac1dedc12ae1518faab

commit r15-4597-g7173e2ff30c1e42168db4ac1dedc12ae1518faab
Author: Andrew MacLeod 
Date:   Mon Oct 21 18:11:43 2024 -0400

Remove pointer_min_max_operator.

The pointer_min_max_operator class was used before the current dispatch
system was created.  These operations have been transferred to
operator_min::fold_range () and operator_max::fold_range () with prange
operands.

This class is no longer used for anything, delete it.

* range-op-ptr.cc (class pointer_min_max_operator): Remove.
(pointer_min_max_operator::wi_fold): Remove.

Diff:
---
 gcc/range-op-ptr.cc | 28 
 1 file changed, 28 deletions(-)

diff --git a/gcc/range-op-ptr.cc b/gcc/range-op-ptr.cc
index 4f4b2cf6bab9..f8ce62d5719d 100644
--- a/gcc/range-op-ptr.cc
+++ b/gcc/range-op-ptr.cc
@@ -379,34 +379,6 @@ pointer_plus_operator::op2_range (irange &r, tree type,
   return true;
 }
 
-class pointer_min_max_operator : public range_operator
-{
-public:
-  virtual void wi_fold (irange & r, tree type,
-   const wide_int &lh_lb, const wide_int &lh_ub,
-   const wide_int &rh_lb, const wide_int &rh_ub) const;
-} op_ptr_min_max;
-
-void
-pointer_min_max_operator::wi_fold (irange &r, tree type,
-  const wide_int &lh_lb,
-  const wide_int &lh_ub,
-  const wide_int &rh_lb,
-  const wide_int &rh_ub) const
-{
-  // For MIN/MAX expressions with pointers, we only care about
-  // nullness.  If both are non null, then the result is nonnull.
-  // If both are null, then the result is null.  Otherwise they
-  // are varying.
-  if (!wi_includes_zero_p (type, lh_lb, lh_ub)
-  && !wi_includes_zero_p (type, rh_lb, rh_ub))
-r.set_nonzero (type);
-  else if (wi_zero_p (type, lh_lb, lh_ub) && wi_zero_p (type, rh_lb, rh_ub))
-r.set_zero (type);
-  else
-r.set_varying (type);
-}
-
 class pointer_and_operator : public range_operator
 {
 public:


[gcc(refs/users/aoliva/heads/testme)] fold fold_truth_andor field merging into ifcombine

2024-10-25 Thread Alexandre Oliva via Gcc-cvs
https://gcc.gnu.org/g:5a9cf11ec7d136b1b46132ef1ef2f095febc7b3e

commit 5a9cf11ec7d136b1b46132ef1ef2f095febc7b3e
Author: Alexandre Oliva 
Date:   Sun Oct 20 21:02:05 2024 -0300

fold fold_truth_andor field merging into ifcombine

This patch introduces various improvements to the logic that merges
field compares, moving it into ifcombine.

Before the patch, we could merge:

  (a.x1 EQNE b.x1)  ANDOR  (a.y1 EQNE b.y1)

into something like:

  (((type *)&a)[Na] & MASK) EQNE (((type *)&b)[Nb] & MASK)

if both of A's fields live within the same alignment boundaries, and
so do B's, at the same relative positions.  Constants may be used
instead of the object B.

The initial goal of this patch was to enable such combinations when a
field crossed alignment boundaries, e.g. for packed types.  We can't
generally access such fields with a single memory access, so when we
come across such a compare, we will attempt to combine each access
separately.

Some merging opportunities were missed because of right-shifts,
compares expressed as e.g. ((a.x1 ^ b.x1) & MASK) EQNE 0, and
narrowing conversions, especially after earlier merges.  This patch
introduces handlers for several cases involving these.

The merging of multiple field accesses into wider bitfield-like
accesses is undesirable to do too early in compilation, so we move it
from folding to ifcombine, and extend ifcombine to merge noncontiguous
compares, absent intervening side effects.  VUSEs used to prevent
ifcombine; that seemed excessively conservative, since relevant side
effects were already tested, including the possibility of trapping
loads, so that's removed.

Unlike earlier ifcombine, when merging noncontiguous compares the
merged compare must replace the earliest compare, which may require
moving up the DEFs that contributed to the latter compare.

When it is the second of a noncontiguous pair of compares that first
accesses a word, we may merge the first compare with part of the
second compare that refers to the same word, keeping the compare of
the remaining bits at the spot where the second compare used to be.

Handling compares with non-constant fields was somewhat generalized
from what fold used to do, now handling non-adjacent fields, even if a
field of one object crosses an alignment boundary but the other
doesn't.


The -Wno-error for toplev.o on rs6000 is because of toplev.c's:

  if ((flag_sanitize & SANITIZE_ADDRESS)
  && !FRAME_GROWS_DOWNWARD)

and rs6000.h's:

#define FRAME_GROWS_DOWNWARD (flag_stack_protect != 0   \
  || (flag_sanitize & SANITIZE_ADDRESS) != 0)

The mutually exclusive conditions involving flag_sanitize are now
noticed and reported by ifcombine's warning on mutually exclusive
compares.  i386's needs -Wno-error for insn-attrtab.o for similar
reasons.


for  gcc/ChangeLog

* fold-const.cc (make_bit_field): Export.
(all_ones_mask_p): Drop.
(unextend, decode_field_reference, fold_truth_andor_1): Move
field compare merging logic...
* gimple-fold.cc: ... here.
(ssa_is_substitutable_p, is_cast_p, is_binop_p): New.
(prepare_xor, follow_load): New.
(compute_split_boundary_from_align): New.
(make_bit_field_load, build_split_load): New.
(reuse_split_load, mergeable_loads_p): New.
(fold_truth_andor_maybe_separate): New.
* tree-ssa-ifcombine.cc: Include bitmap.h.
(constant_condition_p): New.
(recognize_if_then_else_nc, recognize_if_succs): New.
(bb_no_side_effects_p): Don't reject VUSEs.
(update_profile_after_ifcombine): Adjust for noncontiguous
merges.
(ifcombine_mark_ssa_name): New.
(struct ifcombine_mark_ssa_name_t): New.
(ifcombine_mark_ssa_name_walk): New.
(ifcombine_replace_cond): Extended for noncontiguous merges
after factoring out of...
(ifcombine_ifandif): ... this.  Drop result_inv arg.  Try
fold_truth_andor_maybe_separate.
(tree_ssa_ifcombine_bb_1): Add outer_succ_bb arg.  Call
recognize_if_then_else_nc.  Adjust ifcombine_ifandif calls.
(tree_ssa_ifcombine_bb): Return the earliest affected block.
Call recognize_if_then_else_nc.  Try noncontiguous blocks.
(pass_tree_ifcombine::execute): Retry affected blocks.
* config/i386/t-i386 (insn-attrtab.o-warn): Disable errors.
* config/rs6000/t-rs6000 (toplev.o-warn): Likewise.

for  gcc/testsuite/ChangeLog

* gcc.dg/field-merge-1.c: New.
* gcc.dg/field-merge-2.c: New.
 

[gcc r15-4665] libstdc++: implement concatenation of strings and string_views

2024-10-25 Thread Jonathan Wakely via Libstdc++-cvs
https://gcc.gnu.org/g:813afa280cc130d6d01a4b8294db19965956a3f9

commit r15-4665-g813afa280cc130d6d01a4b8294db19965956a3f9
Author: Giuseppe D'Angelo 
Date:   Tue Jul 30 20:09:12 2024 +0200

libstdc++: implement concatenation of strings and string_views

This adds support for P2591R5, merged for C++26.

libstdc++-v3/ChangeLog:

* include/bits/basic_string.h: Implement the four operator+
overloads between basic_string and (types convertible to)
basic_string_view.
* include/bits/version.def: Bump the feature-testing macro.
* include/bits/version.h: Regenerate.
* 
testsuite/21_strings/basic_string/operators/char/op_plus_fspath_neg.cc: New 
test.
* 
testsuite/21_strings/basic_string/operators/char/op_plus_string_view.cc: New 
test.
* 
testsuite/21_strings/basic_string/operators/char/op_plus_string_view_compat.cc:
New test.

Signed-off-by: Giuseppe D'Angelo 

Diff:
---
 libstdc++-v3/include/bits/basic_string.h   |  48 ++
 libstdc++-v3/include/bits/version.def  |   5 +
 libstdc++-v3/include/bits/version.h|   7 +-
 .../operators/char/op_plus_fspath_neg.cc   |  13 ++
 .../operators/char/op_plus_string_view.cc  | 169 +
 .../operators/char/op_plus_string_view_compat.cc   |  63 
 6 files changed, 304 insertions(+), 1 deletion(-)

diff --git a/libstdc++-v3/include/bits/basic_string.h 
b/libstdc++-v3/include/bits/basic_string.h
index e2ae62665f65..f5b320099b17 100644
--- a/libstdc++-v3/include/bits/basic_string.h
+++ b/libstdc++-v3/include/bits/basic_string.h
@@ -3754,6 +3754,54 @@ _GLIBCXX_END_NAMESPACE_CXX11
 { return std::move(__lhs.append(1, __rhs)); }
 #endif
 
+#if __glibcxx_string_view >= 202403L
+  // const string & + string_view
+  template
+[[nodiscard]]
+constexpr basic_string<_CharT, _Traits, _Alloc>
+operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
+  type_identity_t> __rhs)
+{
+  using _Str = basic_string<_CharT, _Traits, _Alloc>;
+  return std::__str_concat<_Str>(__lhs.data(), __lhs.size(),
+ __rhs.data(), __rhs.size(),
+ __lhs.get_allocator());
+}
+
+  // string && + string_view
+  template
+[[nodiscard]]
+constexpr basic_string<_CharT, _Traits, _Alloc>
+operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs,
+  type_identity_t> __rhs)
+{
+  return std::move(__lhs.append(__rhs));
+}
+
+  // string_view + const string &
+  template
+[[nodiscard]]
+constexpr basic_string<_CharT, _Traits, _Alloc>
+operator+(type_identity_t> __lhs,
+  const basic_string<_CharT, _Traits, _Alloc>& __rhs)
+{
+  using _Str = basic_string<_CharT, _Traits, _Alloc>;
+  return std::__str_concat<_Str>(__lhs.data(), __lhs.size(),
+ __rhs.data(), __rhs.size(),
+ __rhs.get_allocator());
+}
+
+  // string_view + string &&
+  template
+[[nodiscard]]
+constexpr basic_string<_CharT, _Traits, _Alloc>
+operator+(type_identity_t> __lhs,
+  basic_string<_CharT, _Traits, _Alloc>&& __rhs)
+{
+  return std::move(__rhs.insert(0, __lhs));
+}
+#endif
+
   // operator ==
   /**
*  @brief  Test equivalence of two strings.
diff --git a/libstdc++-v3/include/bits/version.def 
b/libstdc++-v3/include/bits/version.def
index 4fa820a5a4ab..364bafc9bba5 100644
--- a/libstdc++-v3/include/bits/version.def
+++ b/libstdc++-v3/include/bits/version.def
@@ -698,6 +698,11 @@ ftms = {
 
 ftms = {
   name = string_view;
+  values = {
+v = 202403;
+cxxmin = 26;
+hosted = yes;
+  };
   values = {
 v = 201803;
 cxxmin = 17;
diff --git a/libstdc++-v3/include/bits/version.h 
b/libstdc++-v3/include/bits/version.h
index fdbee8161d9e..a0e3b36864b7 100644
--- a/libstdc++-v3/include/bits/version.h
+++ b/libstdc++-v3/include/bits/version.h
@@ -776,7 +776,12 @@
 #undef __glibcxx_want_shared_ptr_weak_type
 
 #if !defined(__cpp_lib_string_view)
-# if (__cplusplus >= 201703L) && _GLIBCXX_HOSTED
+# if (__cplusplus >  202302L) && _GLIBCXX_HOSTED
+#  define __glibcxx_string_view 202403L
+#  if defined(__glibcxx_want_all) || defined(__glibcxx_want_string_view)
+#   define __cpp_lib_string_view 202403L
+#  endif
+# elif (__cplusplus >= 201703L) && _GLIBCXX_HOSTED
 #  define __glibcxx_string_view 201803L
 #  if defined(__glibcxx_want_all) || defined(__glibcxx_want_string_view)
 #   define __cpp_lib_string_view 201803L
diff --git 
a/libstdc++-v3/testsuite/21_strings/basic_string/operators/char/op_plus_fspath_neg.cc
 
b/libstdc++-v3/testsuite/21_strings/basic_string/operators/char/op_plus_fspath_neg.cc
new file mode 100644
index ..bf1e09ada1e9
--- /dev/null
+++ 
b/libstdc++-v3/testsuite/21_strings/basic_string/operators/char/op_plu

[gcc r15-4666] libstdc++: Disable parts of new test that depend on constexpr std::string

2024-10-25 Thread Jonathan Wakely via Gcc-cvs
https://gcc.gnu.org/g:a4931587cbccdb6aff352f9df728ab468c5260b9

commit r15-4666-ga4931587cbccdb6aff352f9df728ab468c5260b9
Author: Jonathan Wakely 
Date:   Thu Oct 24 20:12:08 2024 +0100

libstdc++: Disable parts of new test that depend on constexpr std::string

The compile-time assertions don't work with -D_GLIBCXX_USE_CXX11_ABI=0.

libstdc++-v3/ChangeLog:

* 
testsuite/21_strings/basic_string/operators/char/op_plus_string_view.cc:
Check __cpp_lib_constexpr_string.

Diff:
---
 .../21_strings/basic_string/operators/char/op_plus_string_view.cc   | 2 ++
 1 file changed, 2 insertions(+)

diff --git 
a/libstdc++-v3/testsuite/21_strings/basic_string/operators/char/op_plus_string_view.cc
 
b/libstdc++-v3/testsuite/21_strings/basic_string/operators/char/op_plus_string_view.cc
index 364d5bd5abab..2d474519f60a 100644
--- 
a/libstdc++-v3/testsuite/21_strings/basic_string/operators/char/op_plus_string_view.cc
+++ 
b/libstdc++-v3/testsuite/21_strings/basic_string/operators/char/op_plus_string_view.cc
@@ -44,6 +44,7 @@ struct convertible_to_lots
   constexpr operator std::string() const { return "convertible_to_lots3"; }
 };
 
+#if __cpp_lib_constexpr_string >= 201907 // constexpr std::string
 using namespace std::literals;
 static_assert( "costa "s + "marbella"sv == "costa marbella"s );
 static_assert( "costa "sv + "marbella"s == "costa marbella"s );
@@ -52,6 +53,7 @@ static_assert( "costa "s + convertible_to_string_view2{} == 
"costa convertible_t
 static_assert( "costa "s + convertible_to_string_view3{} == "costa 
convertible_to_sv3 non_const"s );
 static_assert( "costa "s + convertible_to_string_view_and_char_star{} == 
"costa convertible_to_sv_and_charstar1"s );
 static_assert( "costa "s + convertible_to_lots{} == "costa 
convertible_to_lots1"s );
+#endif // __cpp_lib_constexpr_string
 
 void
 test01()


[gcc r14-10835] AVR: target/116953 - Restore recog_data after calling jump_over_one_insn_p.

2024-10-25 Thread Georg-Johann Lay via Gcc-cvs
https://gcc.gnu.org/g:ddba8434cbf0ddf07a48a8b68942b4c78b5567c7

commit r14-10835-gddba8434cbf0ddf07a48a8b68942b4c78b5567c7
Author: Georg-Johann Lay 
Date:   Tue Oct 22 11:51:44 2024 +0200

AVR: target/116953 - Restore recog_data after calling jump_over_one_insn_p.

The previous fix for PR116953 is incomplete because references to
recog_data are escaping avr_out_sbxx_branch() in the form of %-operands
in the returned asm code template.  This patch reverts the previous fix,
and re-extracts the operands by means of extract_constrain_insn_cached()
after the call of jump_over_one_insn_p().

PR target/116953
gcc/
* config/avr/avr.cc (avr_out_sbxx_branch): Revert previous fix
for PR116953 (r15-4078).  Run extract_constrain_insn_cached
on the current insn after calling jump_over_one_insn_p.

(cherry picked from commit ca0ab7a0ac18911181e9161cfb8b87fb90039612)

Diff:
---
 gcc/config/avr/avr.cc | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/gcc/config/avr/avr.cc b/gcc/config/avr/avr.cc
index 5891465cd277..ab1163af9849 100644
--- a/gcc/config/avr/avr.cc
+++ b/gcc/config/avr/avr.cc
@@ -14409,16 +14409,16 @@ avr_hard_regno_rename_ok (unsigned int old_reg, 
unsigned int new_reg)
Operand 3: label to jump to if the test is true.  */
 
 const char *
-avr_out_sbxx_branch (rtx_insn *insn, rtx xop[])
+avr_out_sbxx_branch (rtx_insn *insn, rtx operands[])
 {
-  // jump_over_one_insn_p may call extract on the next insn, clobbering
-  // recog_data.operand.  Hence make a copy of the operands (PR116953).
-  rtx operands[] = { xop[0], xop[1], xop[2], xop[3] };
-
   enum rtx_code comp = GET_CODE (operands[0]);
   bool long_jump = get_attr_length (insn) >= 4;
   bool reverse = long_jump || jump_over_one_insn_p (insn, operands[3]);
 
+  // PR116953: jump_over_one_insn_p may call extract on the next insn,
+  // clobbering recog_data.operand.  Thus, restore recog_data.
+  extract_constrain_insn_cached (insn);
+
   if (comp == GE)
 comp = EQ;
   else if (comp == LT)


[gcc r14-10840] Assorted --disable-checking fixes [PR117249]

2024-10-25 Thread Jakub Jelinek via Gcc-cvs
https://gcc.gnu.org/g:7965062f9e9ba634247b1dab22e1d83f446337ab

commit r14-10840-g7965062f9e9ba634247b1dab22e1d83f446337ab
Author: Jakub Jelinek 
Date:   Fri Oct 25 14:09:42 2024 +0200

Assorted --disable-checking fixes [PR117249]

We have currently 3 different definitions of gcc_assert macro, one used most
of the time (unless --disable-checking) which evaluates the condition at
runtime and also checks it at runtime, then one for --disable-checking GCC 
4.5+
which looks like
((void)(UNLIKELY (!(EXPR)) ? __builtin_unreachable (), 0 : 0))
and a fallback one
((void)(0 && (EXPR)))
Now, the last one actually doesn't evaluate any of the side-effects in the
argument, just quiets up unused var/parameter warnings.
I've tried to replace the middle definition with
({ [[assume (EXPR)]]; (void) 0; })
for compilers which support assume attribute and statement expressions
(surprisingly quite a few spots use gcc_assert inside of comma expressions),
but ran into PR117287, so for now such a change isn't being proposed.

The following patch attempts to move important side-effects from gcc_assert
arguments.

Bootstrapped/regtested on x86_64-linux and i686-linux with normal
--enable-checking=yes,rtl,extra, plus additionally I've attempted to do
x86_64-linux bootstrap with --disable-checking and gcc_assert changed to the
((void)(0 && (EXPR)))
version when --disable-checking.  That version ran into spurious middle-end
warnings
../../gcc/../include/libiberty.h:733:36: error: argument to ‘alloca’ is too 
large [-Werror=alloca-larger-than=]
../../gcc/tree-ssa-reassoc.cc:5659:20: note: in expansion of macro 
‘XALLOCAVEC’
  int op_num = ops.length ();
  int op_normal_num = op_num;
  gcc_assert (op_num > 0);
  int stmt_num = op_num - 1;
  gimple **stmts = XALLOCAVEC (gimple *, stmt_num);
where we have gcc_assert exactly to work-around middle-end warnings.
Guess I'd need to also disable -Werror for this experiment, which actually
isn't a problem with unmodified system.h, because even for
--disable-checking we use the __builtin_unreachable at least in
stage2/stage3 and so the warnings aren't emitted, and even if it used
[[assume ()]]; it would work too because in stage2/stage3 we could again
rely on assume and statement expression support.

2024-10-25  Jakub Jelinek  

PR middle-end/117249
* tree-ssa-structalias.cc (insert_vi_for_tree): Move put calls out 
of
gcc_assert.
* lto-cgraph.cc (lto_symtab_encoder_delete_node): Likewise.
* gimple-ssa-strength-reduction.cc (get_alternative_base,
add_cand_for_stmt): Likewise.
* tree-eh.cc (add_stmt_to_eh_lp_fn): Likewise.
* except.cc (duplicate_eh_regions_1): Likewise.
* tree-ssa-reassoc.cc (insert_operand_rank): Likewise.
* config/nvptx/nvptx.cc (nvptx_expand_call): Use == rather than = in
gcc_assert.
* opts-common.cc (jobserver_info::disconnect): Call close outside of
gcc_assert and only check result in it.
(jobserver_info::return_token): Call write outside of gcc_assert and
only check result in it.
* genautomata.cc (output_default_latencies): Move j++ side-effect
outside of gcc_assert.
* tree-ssa-loop-ivopts.cc (get_alias_ptr_type_for_ptr_address): Use
== rather than = in gcc_assert.
* cgraph.cc (symbol_table::create_edge): Move ++edges_max_uid
side-effect outside of gcc_assert.

(cherry picked from commit e2a8772c9328960c625f5b95091d4312efa0e284)

Diff:
---
 gcc/cgraph.cc| 3 ++-
 gcc/config/nvptx/nvptx.cc| 2 +-
 gcc/except.cc| 6 --
 gcc/genautomata.cc   | 3 ++-
 gcc/gimple-ssa-strength-reduction.cc | 6 --
 gcc/lto-cgraph.cc| 3 ++-
 gcc/opts-common.cc   | 6 --
 gcc/tree-eh.cc   | 3 ++-
 gcc/tree-ssa-loop-ivopts.cc  | 2 +-
 gcc/tree-ssa-reassoc.cc  | 3 ++-
 gcc/tree-ssa-structalias.cc  | 3 ++-
 11 files changed, 26 insertions(+), 14 deletions(-)

diff --git a/gcc/cgraph.cc b/gcc/cgraph.cc
index 39a3adbc7c35..8226c7d96e05 100644
--- a/gcc/cgraph.cc
+++ b/gcc/cgraph.cc
@@ -894,7 +894,8 @@ symbol_table::create_edge (cgraph_node *caller, cgraph_node 
*callee,
   edge->m_summary_id = -1;
   edges_count++;
 
-  gcc_assert (++edges_max_uid != 0);
+  ++edges_max_uid;
+  gcc_assert (edges_max_uid != 0);
   edge->m_uid = edges_max_uid;
   edge->aux = NULL;
   edge->caller = caller;
diff --git a/gcc/config/nvptx/nvptx.cc b/gcc/config/nvptx/nvptx.cc
index 2a8f713c6806..f88d7965bd37 100644
--- a/gcc/config/nvptx/nvptx.cc
+++ b/gcc/config/nvptx/nvptx.cc
@@ -1900,7 +1900,7 @@ nvptx_expand_call (rtx retval, rtx addres

[gcc r15-4670] lto: Handle RAW_DATA_CST in compare_tree_sccs_1 [PR117201]

2024-10-25 Thread Jakub Jelinek via Gcc-cvs
https://gcc.gnu.org/g:432044b24a0460b31e332cf6ff92dc97ad1e8508

commit r15-4670-g432044b24a0460b31e332cf6ff92dc97ad1e8508
Author: Jakub Jelinek 
Date:   Fri Oct 25 14:05:37 2024 +0200

lto: Handle RAW_DATA_CST in compare_tree_sccs_1 [PR117201]

I've missed I need to add RAW_DATA_CST support in compare_tree_sccs_1,
because without that it considers all RAW_DATA_CSTs to be equivalent,
regardless of their length or content.

2024-10-24  Jakub Jelinek  

PR lto/117201
PR lto/117288
* lto-common.cc (compare_tree_sccs_1): Handle RAW_DATA_CST.

* gcc.dg/lto/pr117201_0.c: New test.
* gcc.dg/lto/pr117288_0.c: New test.

Diff:
---
 gcc/lto/lto-common.cc |  6 +++
 gcc/testsuite/gcc.dg/lto/pr117201_0.c | 26 
 gcc/testsuite/gcc.dg/lto/pr117288_0.c | 76 +++
 3 files changed, 108 insertions(+)

diff --git a/gcc/lto/lto-common.cc b/gcc/lto/lto-common.cc
index 77607751db52..cc14cd7100f1 100644
--- a/gcc/lto/lto-common.cc
+++ b/gcc/lto/lto-common.cc
@@ -1336,6 +1336,12 @@ compare_tree_sccs_1 (tree t1, tree t2, tree **map)
   TREE_STRING_LENGTH (t1)) != 0)
   return false;
 
+  if (code == RAW_DATA_CST)
+if (RAW_DATA_LENGTH (t1) != RAW_DATA_LENGTH (t2)
+   || memcmp (RAW_DATA_POINTER (t1), RAW_DATA_POINTER (t2),
+  RAW_DATA_LENGTH (t1)) != 0)
+  return false;
+
   if (code == OMP_CLAUSE)
 {
   compare_values (OMP_CLAUSE_CODE);
diff --git a/gcc/testsuite/gcc.dg/lto/pr117201_0.c 
b/gcc/testsuite/gcc.dg/lto/pr117201_0.c
new file mode 100644
index ..e4bfce67b016
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/pr117201_0.c
@@ -0,0 +1,26 @@
+/* PR lto/117201 */
+/* { dg-lto-do run } */
+/* { dg-lto-options { "-O0 -flto" } } */
+
+unsigned char a = 193;
+unsigned char *b = &a;
+
+void
+foo (void)
+{
+  unsigned char c[] = { 0, 2, 1, 1, 2, 1, 2, 2, 6, 2, 1, 1, 1, 1, 2, 2, 0,
+   2, 1, 1, 2, 1, 2, 2, 1, 2, 1, 1, 2, 1, 2, 2, 1, 2,
+   1, 1, 2, 1, 2, 2, 1, 1, 2, 4, 8, 8, 3, 3, 1, 1, 5,
+   4, 1, 1, 1, 0, 5, 5, 9, 4, 8, 8, 7, 0, 1, 1 };
+}
+
+int
+main ()
+{
+  unsigned char c[] = { 193, 0, 0, 0, 1, 0, 1, 1, 1, 0, 1, 0, 5, 2, 3, 1, 0,
+   1, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 4,
+   2, 2, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1,
+   1, 1, 0, 5, 3, 3, 1, 0, 1, 0, 0, 1, 0, 1, 0 };
+  if (b[0] != c[0])
+__builtin_abort ();
+}
diff --git a/gcc/testsuite/gcc.dg/lto/pr117288_0.c 
b/gcc/testsuite/gcc.dg/lto/pr117288_0.c
new file mode 100644
index ..05179aa29cd9
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/lto/pr117288_0.c
@@ -0,0 +1,76 @@
+/* PR lto/117288 */
+/* { dg-lto-do link } */
+/* { dg-lto-options { "-O0 -flto" } } */
+
+__attribute__((noipa)) static void
+foo (const void *x)
+{
+  (void) x;
+}
+
+static void
+bar (void)
+{
+  unsigned char a[81] = {
+0x16, 0xfe, 0xfd, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x01, 0xfa, 0x01, 0x00, 0x01,
+0xee, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,
+0xee, 0xfe, 0xfd, 0xc0, 0xca, 0xb5, 0x6f, 0x3d,
+0x23, 0xcc, 0x53, 0x9a, 0x67, 0x17, 0x70, 0xd3,
+0xfb, 0x23, 0x16, 0x9e, 0x4e, 0xd6, 0x7e, 0x29,
+0xab, 0xfa, 0x4c, 0xa5, 0x84, 0x95, 0xc3, 0xdb,
+0x21, 0x9a, 0x52, 0x00, 0x00, 0x00, 0x36, 0x13,
+0x01, 0x13, 0x02, 0x13, 0x03, 0xc0, 0x2c, 0xc0,
+0x2b, 0xc0, 0x30, 0xc0, 0x2f, 0x00, 0x9f, 0x00,
+0x9e,
+  };
+  foo (&a);
+}
+
+static void
+baz (void)
+{
+  const struct S
+  {
+unsigned char a[32];
+int b;
+unsigned char c[32];
+int d;
+unsigned char e[32];
+int f;
+unsigned char g[80];
+int h;
+unsigned char i[80];
+int j;
+  } s = {
+{ 0x00, }, 16,
+{ 0x4f, }, 16,
+{ 0x00 }, 0,
+{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+  0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11,
+  0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11,
+  0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22,
+  0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22,
+  0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33,
+  0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33,
+  0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44,
+  0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44, 0x44 }, 80,
+{ 0xe9, }, 80,
+  };
+
+  foo (s.g);
+}
+
+__attribute__((noipa)) static void
+qux (const void (*x) (void))
+{
+  (void) x;
+}
+
+int
+main ()
+{
+  qux (&baz);
+  qux (&bar);
+}


[gcc r15-4672] Match: Simplify branch form 3 of unsigned SAT_ADD into branchless

2024-10-25 Thread Pan Li via Gcc-cvs
https://gcc.gnu.org/g:df4af89bc3eabbeaccb16539aa1082cb9863e187

commit r15-4672-gdf4af89bc3eabbeaccb16539aa1082cb9863e187
Author: Pan Li 
Date:   Thu Oct 24 21:57:04 2024 +0800

Match: Simplify branch form 3 of unsigned SAT_ADD into branchless

There are sorts of forms for the unsigned SAT_ADD.  Some of them are
complicated while others are cheap.  This patch would like to simplify
the complicated form into the cheap ones.  For example as below:

From the form 3 (branch):
  SAT_U_ADD = (X + Y) >= x ? (X + Y) : -1.

To (branchless):
  SAT_U_ADD = (X + Y) | - ((X + Y) < X).

  #define T uint8_t

  T sat_add_u_1 (T x, T y)
  {
return (T)(x + y) >= x ? (x + y) : -1;
  }

Before this patch:
   1   │ uint8_t sat_add_u_1 (uint8_t x, uint8_t y)
   2   │ {
   3   │   uint8_t D.2809;
   4   │
   5   │   _1 = x + y;
   6   │   if (x <= _1) goto ; else goto ;
   7   │   :
   8   │   D.2809 = x + y;
   9   │   goto ;
  10   │   :
  11   │   D.2809 = 255;
  12   │   :
  13   │   return D.2809;
  14   │ }

After this patch:
   1   │ uint8_t sat_add_u_1 (uint8_t x, uint8_t y)
   2   │ {
   3   │   uint8_t D.2809;
   4   │
   5   │   _1 = x + y;
   6   │   _2 = x + y;
   7   │   _3 = x > _2;
   8   │   _4 = (unsigned char) _3;
   9   │   _5 = -_4;
  10   │   D.2809 = _1 | _5;
  11   │   return D.2809;
  12   │ }

The simplify doesn't need to check if target support the SAT_ADD, it
is somehow the optimization in gimple level.

The below test suites are passed for this patch.
* The rv64gcv fully regression test.
* The x86 bootstrap test.
* The x86 fully regression test.

gcc/ChangeLog:

* match.pd: Remove unsigned branch form 3 for SAT_ADD, and
add simplify to branchless instead.

gcc/testsuite/ChangeLog:

* gcc.dg/tree-ssa/sat_u_add-simplify-1-u16.c: New test.
* gcc.dg/tree-ssa/sat_u_add-simplify-1-u32.c: New test.
* gcc.dg/tree-ssa/sat_u_add-simplify-1-u64.c: New test.
* gcc.dg/tree-ssa/sat_u_add-simplify-1-u8.c: New test.

Signed-off-by: Pan Li 

Diff:
---
 gcc/match.pd | 11 +++
 gcc/testsuite/gcc.dg/tree-ssa/sat_u_add-simplify-1-u16.c | 15 +++
 gcc/testsuite/gcc.dg/tree-ssa/sat_u_add-simplify-1-u32.c | 15 +++
 gcc/testsuite/gcc.dg/tree-ssa/sat_u_add-simplify-1-u64.c | 15 +++
 gcc/testsuite/gcc.dg/tree-ssa/sat_u_add-simplify-1-u8.c  | 15 +++
 5 files changed, 67 insertions(+), 4 deletions(-)

diff --git a/gcc/match.pd b/gcc/match.pd
index e622ccbd67c0..f16b733b8914 100644
--- a/gcc/match.pd
+++ b/gcc/match.pd
@@ -3146,10 +3146,13 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
 (match (unsigned_integer_sat_add @0 @1)
  (bit_ior:c (usadd_left_part_2 @0 @1) (usadd_right_part_2 @0 @1)))
 
-/* Unsigned saturation add, case 3 (branch with ge):
-   SAT_U_ADD = (X + Y) >= x ? (X + Y) : -1.  */
-(match (unsigned_integer_sat_add @0 @1)
- (cond^ (ge (usadd_left_part_1@2 @0 @1) @0) @2 integer_minus_onep))
+/* Simplify SAT_U_ADD to the cheap form
+   From: SAT_U_ADD = (X + Y) >= x ? (X + Y) : -1.
+   To:   SAT_U_ADD = (X + Y) | - ((X + Y) < X).  */
+(simplify (cond (ge (plus:c@2 @0 @1) @0) @2 integer_minus_onep)
+ (if (INTEGRAL_TYPE_P (type) && TYPE_UNSIGNED (type)
+  && types_match (type, @0, @1))
+  (bit_ior @2 (negate (convert (lt @2 @0))
 
 /* Unsigned saturation add, case 4 (branch with lt):
SAT_U_ADD = (X + Y) < x ? -1 : (X + Y).  */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/sat_u_add-simplify-1-u16.c 
b/gcc/testsuite/gcc.dg/tree-ssa/sat_u_add-simplify-1-u16.c
new file mode 100644
index ..7617fbaca454
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/sat_u_add-simplify-1-u16.c
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-gimple-details" } */
+
+#include 
+
+#define T uint16_t
+
+T sat_add_u_1 (T x, T y)
+{
+  return (T)(x + y) >= x ? (x + y) : -1;
+}
+
+/* { dg-final { scan-tree-dump-not " if " "gimple" } } */
+/* { dg-final { scan-tree-dump-not " else " "gimple" } } */
+/* { dg-final { scan-tree-dump-not " goto " "gimple" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/sat_u_add-simplify-1-u32.c 
b/gcc/testsuite/gcc.dg/tree-ssa/sat_u_add-simplify-1-u32.c
new file mode 100644
index ..efea85bfbb7e
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/sat_u_add-simplify-1-u32.c
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-gimple-details" } */
+
+#include 
+
+#define T uint32_t
+
+T sat_add_u_1 (T x, T y)
+{
+  return (T)(x + y) >= x ? (x + y) : -1;
+}
+
+/* { dg-final { scan-tree-dump-not " if " "gimple" } } */
+/* { dg-final { scan-tree-dump-not " else " "gimple" } } */
+/* { dg-final { scan-tree-dump-not " goto " "gi

[gcc r15-4673] match.pd: Add std::pow folding optimizations.

2024-10-25 Thread Jennifer Schmitz via Gcc-cvs
https://gcc.gnu.org/g:07a8538d90763f0ae640dea822bdeb63ea17ec44

commit r15-4673-g07a8538d90763f0ae640dea822bdeb63ea17ec44
Author: Jennifer Schmitz 
Date:   Thu Oct 17 08:40:34 2024 -0700

match.pd: Add std::pow folding optimizations.

This patch adds the following two simplifications in match.pd for
POW_ALL and POWI:
- pow (1.0/x, y) to pow (x, -y), avoiding the division
- pow (0.0, x) to 0.0, avoiding the call to pow.
The patterns are guarded by flag_unsafe_math_optimizations,
!flag_trapping_math, and !HONOR_INFINITIES.
The POW_ALL patterns are also gated under !flag_errno_math.
The second pattern is also guarded by !HONOR_NANS and
!HONOR_SIGNED_ZEROS.

Tests were added to confirm the application of the transform for
builtins pow, powf, powl, powi, powif, powil, and powf16.

The patch was bootstrapped and regtested on aarch64-linux-gnu and
x86_64-linux-gnu, no regression.
OK for mainline?

Signed-off-by: Jennifer Schmitz 

gcc/
* match.pd: Fold pow (1.0/x, y) -> pow (x, -y) and
pow (0.0, x) -> 0.0.

gcc/testsuite/
* gcc.dg/tree-ssa/pow_fold_1.c: New test.

Diff:
---
 gcc/match.pd   | 28 
 gcc/testsuite/gcc.dg/tree-ssa/pow_fold_1.c | 42 ++
 2 files changed, 70 insertions(+)

diff --git a/gcc/match.pd b/gcc/match.pd
index f16b733b8914..809c717bc862 100644
--- a/gcc/match.pd
+++ b/gcc/match.pd
@@ -8285,6 +8285,21 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
(rdiv @0 (exps:s @1))
 (mult @0 (exps (negate @1)
 
+ (for pow (POW_ALL)
+  (if (! HONOR_INFINITIES (type)
+   && ! flag_trapping_math
+   && ! flag_errno_math)
+   /* Simplify pow(1.0/x, y) into pow(x, -y).  */
+   (simplify
+(pow (rdiv:s real_onep@0 @1) @2)
+ (pow @1 (negate @2)))
+
+   /* Simplify pow(0.0, x) into 0.0.  */
+   (if (! HONOR_NANS (type) && ! HONOR_SIGNED_ZEROS (type))
+(simplify
+ (pow real_zerop@0 @1)
+  @0
+
  (if (! HONOR_SIGN_DEPENDENT_ROUNDING (type)
   && ! HONOR_NANS (type) && ! HONOR_INFINITIES (type)
   && ! flag_trapping_math
@@ -8643,6 +8658,19 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
   (mult (POW:s @0 @1) (POW:s @2 @1))
(POW (mult @0 @2) @1))
 
+ (if (! HONOR_INFINITIES (type) && ! flag_trapping_math)
+  /* Simplify powi(1.0/x, y) into powi(x, -y).  */
+  (simplify
+   (POWI (rdiv@3 real_onep@0 @1) @2)
+   (if (single_use (@3))
+(POWI @1 (negate @2
+
+  /* Simplify powi(0.0, x) into 0.0.  */
+  (if (! HONOR_NANS (type) && ! HONOR_SIGNED_ZEROS (type))
+   (simplify
+(POWI real_zerop@0 @1)
+ @0)))
+
  /* Simplify powi(x,y) * powi(z,y) -> powi(x*z,y). */
  (simplify
   (mult (POWI:s @0 @1) (POWI:s @2 @1))
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pow_fold_1.c 
b/gcc/testsuite/gcc.dg/tree-ssa/pow_fold_1.c
new file mode 100644
index ..d98bcb0827e4
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/pow_fold_1.c
@@ -0,0 +1,42 @@
+/* { dg-do compile } */
+/* { dg-options "-Ofast -fdump-tree-optimized -fexcess-precision=16" } */
+/* { dg-add-options float16 } */
+/* { dg-require-effective-target float16_runtime } */
+/* { dg-require-effective-target c99_runtime } */
+
+extern void link_error (void);
+
+#define POW1OVER(TYPE1, TYPE2, CTY, TY)\
+  void \
+  pow1over_##TY (TYPE1 x, TYPE2 y) \
+  {\
+TYPE1 t1 = 1.0##CTY / x;   \
+TYPE1 t2 = __builtin_pow##TY (t1, y);  \
+TYPE2 t3 = -y; \
+TYPE1 t4 = __builtin_pow##TY (x, t3);  \
+if (t2 != t4)  \
+  link_error ();   \
+  }\
+
+#define POW0(TYPE1, TYPE2, CTY, TY)\
+  void \
+  pow0_##TY (TYPE2 x)  \
+  {\
+TYPE1 t1 = __builtin_pow##TY (0.0##CTY, x);\
+if (t1 != 0.0##CTY)\
+  link_error ();   \
+  }\
+
+#define TEST_ALL(TYPE1, TYPE2, CTY, TY)\
+  POW1OVER (TYPE1, TYPE2, CTY, TY) \
+  POW0 (TYPE1, TYPE2, CTY, TY)
+
+TEST_ALL (double, double, , )
+TEST_ALL (float, float, f, f)
+TEST_ALL (_Float16, _Float16, f16, f16)
+TEST_ALL (long double, long double, L, l)
+TEST_ALL (double, int, , i)
+TEST_ALL (float, int, f, if)
+TEST_ALL (long double, int, L, il)
+
+/* { dg-final { scan-tree-dump-not "link_error" "optimized" } } */


[gcc r15-4647] ada: Pragma Pre_Class and Post_Class have no effect at runtime

2024-10-25 Thread Marc Poulhi?s via Gcc-cvs
https://gcc.gnu.org/g:13a4eb2548a9907fd5c57c1e4b51b22411066cf0

commit r15-4647-g13a4eb2548a9907fd5c57c1e4b51b22411066cf0
Author: Javier Miranda 
Date:   Mon Sep 30 09:08:04 2024 +

ada: Pragma Pre_Class and Post_Class have no effect at runtime

The pragmas Pre_Class and Post_Class are accepted by the compiler
but have no effect at runtime.

gcc/ada/ChangeLog:

* freeze.adb (Freeze_Entity): If the entity is an 
access-to-subprogram
type declaration that pre/postcondition contracts, build the
wrapper
(if not previously done as part of processing aspects).
* sem_ch3.adb (Build_Access_Subprogram_Wrapper): Add missing support
for building the wrapper when the access type has pragmas
Pre_Class/Post_Class.
(Build_Access_Subprogram_Wrapper_Declaration): New subprogram.
* sem_ch3.ads (Build_Access_Subprogram_Wrapper): Spec moved to the
public part of the package.
* sem_prag.adb (Analyze_Pre_Post_Condition): Store in the tree copy 
of
class-wide pre/postcondition expression; required to merge it with
inherited conditions.
(Is_Valid_Assertion_Kind): Added Pre_Class and Post_Class.

Diff:
---
 gcc/ada/freeze.adb   |  15 +++
 gcc/ada/sem_ch3.adb  | 260 +++
 gcc/ada/sem_ch3.ads  |   5 +
 gcc/ada/sem_prag.adb |  46 -
 4 files changed, 240 insertions(+), 86 deletions(-)

diff --git a/gcc/ada/freeze.adb b/gcc/ada/freeze.adb
index 326b39b05458..101cf4740e34 100644
--- a/gcc/ada/freeze.adb
+++ b/gcc/ada/freeze.adb
@@ -6938,6 +6938,21 @@ package body Freeze is
 end if;
  end;
 
+ --  If the entity is a declaration of an access-to-subprogram type
+ --  with pre/postcondition contracts, build the wrapper (if it hasn't
+ --  already been done during aspect processing), and propagate the
+ --  pre/postcondition pragmas to the wrapper.
+
+ if Ada_Version >= Ada_2022
+   and then Expander_Active
+   and then Ekind (E) = E_Access_Subprogram_Type
+   and then Nkind (Parent (E)) = N_Full_Type_Declaration
+   and then Present (Contract (Designated_Type (E)))
+   and then not Is_Derived_Type (E)
+ then
+Build_Access_Subprogram_Wrapper (Parent (E));
+ end if;
+
  --  Deal with special cases of freezing for subtype
 
  if E /= Base_Type (E) then
diff --git a/gcc/ada/sem_ch3.adb b/gcc/ada/sem_ch3.adb
index 00d5fe256d97..b684f69eb8f6 100644
--- a/gcc/ada/sem_ch3.adb
+++ b/gcc/ada/sem_ch3.adb
@@ -105,11 +105,6 @@ package body Sem_Ch3 is
--  abstract interface types implemented by a record type or a derived
--  record type.
 
-   procedure Build_Access_Subprogram_Wrapper (Decl : Node_Id);
-   --  When an access-to-subprogram type has pre/postconditions, we build a
-   --  subprogram that includes these contracts and is invoked by an indirect
-   --  call through the corresponding access type.
-
procedure Build_Derived_Type
  (N : Node_Id;
   Parent_Type   : Entity_Id;
@@ -6997,19 +6992,78 @@ package body Sem_Ch3 is
-
 
procedure Build_Access_Subprogram_Wrapper (Decl : Node_Id) is
-  Loc  : constant Source_Ptr := Sloc (Decl);
   Id   : constant Entity_Id  := Defining_Identifier (Decl);
+  Loc  : constant Source_Ptr := Sloc (Decl);
+  Subp : constant Entity_Id  := Make_Temporary (Loc, 'A');
   Type_Def : constant Node_Id:= Type_Definition (Decl);
-  Specs   :  constant List_Id:=
-  Parameter_Specifications (Type_Def);
-  Profile : constant List_Id := New_List;
-  Subp: constant Entity_Id   := Make_Temporary (Loc, 'A');
+  Specs: constant List_Id:= Parameter_Specifications (Type_Def);
+
+  function Build_Access_Subprogram_Wrapper_Declaration return Node_Id;
+  --  Build the declaration and the specification of the wrapper
+
+  -
+  -- Build_Access_Subprogram_Wrapper_Declaration --
+  -
+
+  function Build_Access_Subprogram_Wrapper_Declaration return Node_Id is
+ Form_P   : Node_Id;
+ New_Decl : Node_Id;
+ New_P: Node_Id;
+ Profile  : constant List_Id := New_List;
+ Spec : Node_Id;
+
+  begin
+ Form_P := First (Specs);
+
+ while Present (Form_P) loop
+New_P := New_Copy_Tree (Form_P);
+Set_Defining_Identifier (New_P,
+  Make_Defining_Identifier
+   (Loc, Chars (Defining_Identifier (Form_P;
+Append (New_P, Profile);
+Next (Form_P);
+ end loop;
+
+ --  Add to parameter specifications the access parameter 

[gcc r15-4668] testsuite: Generalise tree-ssa/shifts-3.c regexp

2024-10-25 Thread Richard Sandiford via Gcc-cvs
https://gcc.gnu.org/g:a0e37a6bf6e13968ddad3560213eece4baa34bee

commit r15-4668-ga0e37a6bf6e13968ddad3560213eece4baa34bee
Author: Richard Sandiford 
Date:   Fri Oct 25 12:25:42 2024 +0100

testsuite: Generalise tree-ssa/shifts-3.c regexp

My recent gcc.dg/tree-ssa/shifts-3.c test failed on arm-linux-gnu
because it used widen_mult_expr to do a multiplication on chars.
This patch generalises the regexp in the same way as for f3.

gcc/testsuite/
* gcc.dg/tree-ssa/shifts-3.c: Accept widen_mult for f2 too.

Diff:
---
 gcc/testsuite/gcc.dg/tree-ssa/shifts-3.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/testsuite/gcc.dg/tree-ssa/shifts-3.c 
b/gcc/testsuite/gcc.dg/tree-ssa/shifts-3.c
index dcff518e630d..2b1cf703b4ac 100644
--- a/gcc/testsuite/gcc.dg/tree-ssa/shifts-3.c
+++ b/gcc/testsuite/gcc.dg/tree-ssa/shifts-3.c
@@ -58,7 +58,7 @@ f6 (unsigned int x)
 /* { dg-final { scan-tree-dump-not {<[a-z]*_div_expr,} "optimized" } } */
 /* { dg-final { scan-tree-dump-not {

[gcc r13-9149] Add regression test

2024-10-25 Thread Eric Botcazou via Gcc-cvs
https://gcc.gnu.org/g:18af118e17bd0787638967725047f7241e43b2b2

commit r13-9149-g18af118e17bd0787638967725047f7241e43b2b2
Author: Eric Botcazou 
Date:   Fri Oct 25 13:14:22 2024 +0200

Add regression test

gcc/testsuite
PR ada/116551
* gnat.dg/specs/vfa3.ads: New test.

Diff:
---
 gcc/testsuite/gnat.dg/specs/vfa3.ads | 25 +
 1 file changed, 25 insertions(+)

diff --git a/gcc/testsuite/gnat.dg/specs/vfa3.ads 
b/gcc/testsuite/gnat.dg/specs/vfa3.ads
new file mode 100644
index ..200e294e140f
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/specs/vfa3.ads
@@ -0,0 +1,25 @@
+-- { dg-do compile }
+
+package VFA3 is
+
+   type Bit is mod 2**1
+ with Size => 1;
+
+   type Intr_Level_Field is record
+  Level_Low  : Bit := 0;
+  Level_High : Bit := 0;
+  Edge_Low   : Bit := 0;
+  Edge_High  : Bit := 0;
+   end record with Pack, Size => 4;
+   for Intr_Level_Field use record
+  Level_Low  at 0 range 0 .. 0;
+  Level_High at 0 range 1 .. 1;
+  Edge_Low   at 0 range 2 .. 2;
+  Edge_High  at 0 range 3 .. 3;
+   end record;
+
+   type Intr_Level_Cluster is array (0 .. 7) of Intr_Level_Field
+ with Volatile_Full_Access, Pack, Object_Size => 32;
+   --  There are 8 Fields in a 32-bit word.
+
+end VFA3;


[gcc r14-10837] Add regression test

2024-10-25 Thread Eric Botcazou via Gcc-cvs
https://gcc.gnu.org/g:11b51284290b2e369fcab8d74735bf3cc017894f

commit r14-10837-g11b51284290b2e369fcab8d74735bf3cc017894f
Author: Eric Botcazou 
Date:   Fri Oct 25 13:14:22 2024 +0200

Add regression test

gcc/testsuite
PR ada/116551
* gnat.dg/specs/vfa3.ads: New test.

Diff:
---
 gcc/testsuite/gnat.dg/specs/vfa3.ads | 25 +
 1 file changed, 25 insertions(+)

diff --git a/gcc/testsuite/gnat.dg/specs/vfa3.ads 
b/gcc/testsuite/gnat.dg/specs/vfa3.ads
new file mode 100644
index ..200e294e140f
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/specs/vfa3.ads
@@ -0,0 +1,25 @@
+-- { dg-do compile }
+
+package VFA3 is
+
+   type Bit is mod 2**1
+ with Size => 1;
+
+   type Intr_Level_Field is record
+  Level_Low  : Bit := 0;
+  Level_High : Bit := 0;
+  Edge_Low   : Bit := 0;
+  Edge_High  : Bit := 0;
+   end record with Pack, Size => 4;
+   for Intr_Level_Field use record
+  Level_Low  at 0 range 0 .. 0;
+  Level_High at 0 range 1 .. 1;
+  Edge_Low   at 0 range 2 .. 2;
+  Edge_High  at 0 range 3 .. 3;
+   end record;
+
+   type Intr_Level_Cluster is array (0 .. 7) of Intr_Level_Field
+ with Volatile_Full_Access, Pack, Object_Size => 32;
+   --  There are 8 Fields in a 32-bit word.
+
+end VFA3;


[gcc r13-9148] ada: Fix internal error on bit-packed array type with Volatile_Full_Access

2024-10-25 Thread Eric Botcazou via Gcc-cvs
https://gcc.gnu.org/g:fbad5c84458324c82f848d35fffa02cb5a412270

commit r13-9148-gfbad5c84458324c82f848d35fffa02cb5a412270
Author: Eric Botcazou 
Date:   Wed Sep 11 19:53:12 2024 +0200

ada: Fix internal error on bit-packed array type with Volatile_Full_Access

The problem occurs when the component type is a record type with default
values for the initialization procedure of the (base) array type, because
the compiler is trying to generate a full access for a parameter of the
base array type, which does not make sense.

gcc/ada/ChangeLog:

PR ada/116551
* gcc-interface/trans.cc (node_is_atomic) : Return
false if the type of the entity is an unconstrained array type.
(node_is_volatile_full_access) : Likewise.

Diff:
---
 gcc/ada/gcc-interface/trans.cc | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/gcc/ada/gcc-interface/trans.cc b/gcc/ada/gcc-interface/trans.cc
index 0c7fde754ea6..d54e7118593f 100644
--- a/gcc/ada/gcc-interface/trans.cc
+++ b/gcc/ada/gcc-interface/trans.cc
@@ -4193,7 +4193,10 @@ node_is_atomic (Node_Id gnat_node)
   if (!Is_Object (gnat_entity))
break;
   return Is_Atomic (gnat_entity)
+/* Disregard the flag on unconstrained arrays or simple constants
+   since we cannot or need not generate an atomic access.  */
 || (Is_Atomic (Etype (gnat_entity))
+&& Ekind (Etype (gnat_entity)) != E_Array_Type
 && !simple_constant_p (gnat_entity));
 
 case N_Selected_Component:
@@ -4233,7 +4236,10 @@ node_is_volatile_full_access (Node_Id gnat_node)
   if (!Is_Object (gnat_entity))
break;
   return Is_Volatile_Full_Access (gnat_entity)
+/* Disregard the flag on unconstrained arrays or simple constants
+   since we cannot or need not generate a full access.  */
 || (Is_Volatile_Full_Access (Etype (gnat_entity))
+&& Ekind (Etype (gnat_entity)) != E_Array_Type
 && !simple_constant_p (gnat_entity));
 
 case N_Selected_Component:


[gcc r15-4679] aarch64: Support multiple variants including up to 3

2024-10-25 Thread Andrew Pinski via Gcc-cvs
https://gcc.gnu.org/g:c8138acb99003860e1e845499b5b2a4e328a969a

commit r15-4679-gc8138acb99003860e1e845499b5b2a4e328a969a
Author: Andrew Pinski 
Date:   Sat May 4 02:03:16 2024 -0700

aarch64: Support multiple variants including up to 3

On some of the Qualcomm's SoC that includes oryon-1 core, the variant
will be different on the cores due to big.little config. Though
the difference between big and little is not significant enough
to have seperate cost/scheduling models for them and the feature set
is the same across all variants.

Also on some SoCs, there are 3 variants of the core, big.middle.little
so this increases the support there for up to 3 cores and 3 variants
in the original parsing loop but it does not change the support for max
of 2 different cores.

After this patch and the patch that adds oryon-1, -mcpu=native works
on the SoCs I am working with.

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

gcc/ChangeLog:

* config/aarch64/driver-aarch64.cc (host_detect_local_cpu): Support
3 cores and 3 variants. If there is one core but multiple variant,
then treat the variant as being all.

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/cpunative/info_25: New file.
* gcc.target/aarch64/cpunative/info_26: New file.
* gcc.target/aarch64/cpunative/native_cpu_25.c: New test.
* gcc.target/aarch64/cpunative/native_cpu_26.c: New test.

Signed-off-by: Andrew Pinski 

Diff:
---
 gcc/config/aarch64/driver-aarch64.cc   | 14 +++-
 gcc/testsuite/gcc.target/aarch64/cpunative/info_25 | 17 ++
 gcc/testsuite/gcc.target/aarch64/cpunative/info_26 | 26 ++
 .../gcc.target/aarch64/cpunative/native_cpu_25.c   | 11 +
 .../gcc.target/aarch64/cpunative/native_cpu_26.c   | 11 +
 5 files changed, 74 insertions(+), 5 deletions(-)

diff --git a/gcc/config/aarch64/driver-aarch64.cc 
b/gcc/config/aarch64/driver-aarch64.cc
index b620351e5720..abe6e7df7dc6 100644
--- a/gcc/config/aarch64/driver-aarch64.cc
+++ b/gcc/config/aarch64/driver-aarch64.cc
@@ -256,9 +256,9 @@ host_detect_local_cpu (int argc, const char **argv)
   bool cpu = false;
   unsigned int i = 0;
   unsigned char imp = INVALID_IMP;
-  unsigned int cores[2] = { INVALID_CORE, INVALID_CORE };
+  unsigned int cores[3] = { INVALID_CORE, INVALID_CORE, INVALID_CORE };
   unsigned int n_cores = 0;
-  unsigned int variants[2] = { ALL_VARIANTS, ALL_VARIANTS };
+  unsigned int variants[3] = { ALL_VARIANTS, ALL_VARIANTS, ALL_VARIANTS };
   unsigned int n_variants = 0;
   bool processed_exts = false;
   aarch64_feature_flags extension_flags = 0;
@@ -314,7 +314,7 @@ host_detect_local_cpu (int argc, const char **argv)
  unsigned cvariant = parse_field (buf);
  if (!contains_core_p (variants, cvariant))
{
-  if (n_variants == 2)
+ if (n_variants == 3)
 goto not_found;
 
   variants[n_variants++] = cvariant;
@@ -326,7 +326,7 @@ host_detect_local_cpu (int argc, const char **argv)
  unsigned ccore = parse_field (buf);
  if (!contains_core_p (cores, ccore))
{
- if (n_cores == 2)
+ if (n_cores == 3)
goto not_found;
 
  cores[n_cores++] = ccore;
@@ -383,11 +383,15 @@ host_detect_local_cpu (int argc, const char **argv)
   /* Weird cpuinfo format that we don't know how to handle.  */
   if (n_cores == 0
   || n_cores > 2
-  || (n_cores == 1 && n_variants != 1)
   || imp == INVALID_IMP
   || !processed_exts)
 goto not_found;
 
+  /* If we have one core type but multiple variants, consider
+ that as one variant with ALL_VARIANTS instead.  */
+  if (n_cores == 1 && n_variants != 1)
+variants[0] = ALL_VARIANTS;
+
   /* Simple case, one core type or just looking for the arch. */
   if (n_cores == 1 || arch)
 {
diff --git a/gcc/testsuite/gcc.target/aarch64/cpunative/info_25 
b/gcc/testsuite/gcc.target/aarch64/cpunative/info_25
new file mode 100644
index ..d6e83ccab097
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/cpunative/info_25
@@ -0,0 +1,17 @@
+processor  : 0
+BogoMIPS   : 38.40
+Features   : fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp 
asimdhp cpuid asimdrdm jscvt fcma lrcpc dcpop sha3 sm3 sm4 asimddp sha512 
asimdfhm dit uscat ilrcpc flagm ssbs sb paca pacg dcpodp flagm2 frint i8mm bf16 
rng bti ecv afp rpres
+CPU implementer: 0x51
+CPU architecture: 8
+CPU variant: 0x2
+CPU part   : 0x001
+CPU revision   : 1
+
+processor  : 1
+BogoMIPS   : 38.40
+Features   : fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp 
asimdhp cpuid asimdrdm jscvt fcma lrcpc dcpop sha3 sm3 sm4 asimddp sha512 
asimdfhm dit uscat ilrcpc flagm ssbs sb paca pacg dcpodp flagm2 frint i8mm bf16 
r

[gcc r15-4685] testsuite: lto: fix tbaa_0 test

2024-10-25 Thread Sam James via Gcc-cvs
https://gcc.gnu.org/g:091e45b4e97d1ecf765bf3afb58cecda23fee23c

commit r15-4685-g091e45b4e97d1ecf765bf3afb58cecda23fee23c
Author: Sam James 
Date:   Fri Oct 25 17:59:31 2024 +0100

testsuite: lto: fix tbaa_0 test

These failures were hidden until we started to run the test by fixing
the filename earlier: use dg-lto directives, pass -std=gnu89 for
implicit-int, and use -flto-partition=none like 
c-c++-common/hwasan/builtin-special-handling.c.

gcc/testsuite/ChangeLog:

* gcc.dg/lto/tbaa_0.c: Use dg-lto directives, pass -std=gnu89, and
use -flto-partition=none.

Diff:
---
 gcc/testsuite/gcc.dg/lto/tbaa_0.c | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/gcc/testsuite/gcc.dg/lto/tbaa_0.c 
b/gcc/testsuite/gcc.dg/lto/tbaa_0.c
index 74c049671133..eb14ea62b896 100644
--- a/gcc/testsuite/gcc.dg/lto/tbaa_0.c
+++ b/gcc/testsuite/gcc.dg/lto/tbaa_0.c
@@ -1,5 +1,7 @@
-/* { dg-do compile } */
-/* { dg-options "-O2 -flto -fdump-tree-evrp" } */
+/* { dg-lto-do link } */
+/* We need -flto=partition=none to get the dump file for scan-tree-dump-times. 
*/
+/* { dg-lto-options {{ -O2 -flto -flto-partition=none -fdump-tree-evrp 
-std=gnu89 }} } */
+
 typedef struct rtx_def *rtx;
 typedef struct cselib_val_struct
 {
@@ -38,4 +40,4 @@ discard_useless_locs (x, info)
   n_useless_values++;
 }
 }
-/* { dg-final { scan-tree-dump-times "n_useless_values" 2 "evrp" } } */
 
+/* { dg-final { scan-tree-dump-times "n_useless_values" 2 "evrp" } } */


[gcc r15-4687] testsuite: lto: fix pr62026 test

2024-10-25 Thread Sam James via Gcc-cvs
https://gcc.gnu.org/g:908b306909f10d7592a0ef611cc77b5720f07fa7

commit r15-4687-g908b306909f10d7592a0ef611cc77b5720f07fa7
Author: Sam James 
Date:   Fri Oct 25 20:55:39 2024 +0100

testsuite: lto: fix pr62026 test

This failure was hidden until we started to run the test by fixing
the filename earlier: pass -Wno-return-type.

gcc/testsuite/ChangeLog:
PR lto/62026

* g++.dg/lto/pr62026_0.C: Pass -Wno-return-type.

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

diff --git a/gcc/testsuite/g++.dg/lto/pr62026_0.C 
b/gcc/testsuite/g++.dg/lto/pr62026_0.C
index 0432e907f56f..d6445ee9b4d8 100644
--- a/gcc/testsuite/g++.dg/lto/pr62026_0.C
+++ b/gcc/testsuite/g++.dg/lto/pr62026_0.C
@@ -1,5 +1,5 @@
 // { dg-lto-do link }
-// { dg-lto-options {{-flto -O3 -r}} }
+// { dg-lto-options {{-flto -O3 -r -Wno-return-type}} }
 class C;
 class F {
   virtual C m_fn1();


[gcc r15-4688] testsuite: lto: fix pr47333 test

2024-10-25 Thread Sam James via Gcc-cvs
https://gcc.gnu.org/g:2266e38cfd8071262004f164ebe37f60e2d4615d

commit r15-4688-g2266e38cfd8071262004f164ebe37f60e2d4615d
Author: Sam James 
Date:   Fri Oct 25 21:12:21 2024 +0100

testsuite: lto: fix pr47333 test

This failure was hidden until we started to run the test by fixing
the filename earlier: ignore -Wtemplate-body using a pragma like
e.g. g++.dg/lto/20101010-1_0.C does because lto.exp doesn't support
dg-additional-options.

gcc/testsuite/ChangeLog:
PR lto/47333

* g++.dg/lto/pr47333_0.C: Ignore -Wtemplate-body.

Diff:
---
 gcc/testsuite/g++.dg/lto/pr47333_0.C | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/gcc/testsuite/g++.dg/lto/pr47333_0.C 
b/gcc/testsuite/g++.dg/lto/pr47333_0.C
index 60873ca07c7a..b171c8cb9604 100644
--- a/gcc/testsuite/g++.dg/lto/pr47333_0.C
+++ b/gcc/testsuite/g++.dg/lto/pr47333_0.C
@@ -1,3 +1,6 @@
+/* "WARNING: lto.exp does not support dg-additional-options" */
+#pragma GCC diagnostic ignored "-Wtemplate-body"
+
 namespace std
 {
   typedef unsigned int size_t;


[gcc r15-4684] testsuite: lto: rename tbaa-1 test

2024-10-25 Thread Sam James via Gcc-cvs
https://gcc.gnu.org/g:2d1d6be00257c5ad9031986ac2f6f3d0a96d935a

commit r15-4684-g2d1d6be00257c5ad9031986ac2f6f3d0a96d935a
Author: Sam James 
Date:   Fri Oct 25 16:31:32 2024 +0100

testsuite: lto: rename tbaa-1 test

This was being ignored previously. Rename it per README.

gcc/testsuite/ChangeLog:

* gcc.dg/lto/tbaa-1.c: Move to...
* gcc.dg/lto/tbaa_0.c: ...here.

Diff:
---
 gcc/testsuite/gcc.dg/lto/{tbaa-1.c => tbaa_0.c} | 0
 1 file changed, 0 insertions(+), 0 deletions(-)

diff --git a/gcc/testsuite/gcc.dg/lto/tbaa-1.c 
b/gcc/testsuite/gcc.dg/lto/tbaa_0.c
similarity index 100%
rename from gcc/testsuite/gcc.dg/lto/tbaa-1.c
rename to gcc/testsuite/gcc.dg/lto/tbaa_0.c


[gcc r15-4682] testsuite: lto: rename pr62026 test

2024-10-25 Thread Sam James via Gcc-cvs
https://gcc.gnu.org/g:03ff420aa0a916ab835129d9575c7029116ec4f9

commit r15-4682-g03ff420aa0a916ab835129d9575c7029116ec4f9
Author: Sam James 
Date:   Fri Oct 25 16:30:49 2024 +0100

testsuite: lto: rename pr62026 test

This was being ignored previously. Rename it per README.

gcc/testsuite/ChangeLog:
PR lto/62026

* g++.dg/lto/pr62026.C: Move to...
* g++.dg/lto/pr62026_0.C: ...here.

Diff:
---
 gcc/testsuite/g++.dg/lto/{pr62026.C => pr62026_0.C} | 0
 1 file changed, 0 insertions(+), 0 deletions(-)

diff --git a/gcc/testsuite/g++.dg/lto/pr62026.C 
b/gcc/testsuite/g++.dg/lto/pr62026_0.C
similarity index 100%
rename from gcc/testsuite/g++.dg/lto/pr62026.C
rename to gcc/testsuite/g++.dg/lto/pr62026_0.C


[gcc r15-4686] testsuite: lto: fix pr95677 test

2024-10-25 Thread Sam James via Gcc-cvs
https://gcc.gnu.org/g:e87c1af38d551cb7f81e10f57bf245a2b8f039be

commit r15-4686-ge87c1af38d551cb7f81e10f57bf245a2b8f039be
Author: Sam James 
Date:   Fri Oct 25 18:02:06 2024 +0100

testsuite: lto: fix pr95677 test

These failures were hidden until we started to run the test by fixing
the filename earlier: use dg-lto directives.

gcc/testsuite/ChangeLog:
PR c++/95677

* g++.dg/lto/pr95677_0.C: Use dg-lto-*.

Diff:
---
 gcc/testsuite/g++.dg/lto/pr95677_0.C | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/gcc/testsuite/g++.dg/lto/pr95677_0.C 
b/gcc/testsuite/g++.dg/lto/pr95677_0.C
index 520ef04e61c8..d24279de0252 100644
--- a/gcc/testsuite/g++.dg/lto/pr95677_0.C
+++ b/gcc/testsuite/g++.dg/lto/pr95677_0.C
@@ -1,8 +1,7 @@
 // PR c++/95677
 
-// { dg-do link }
-// { dg-require-effective-target lto }
-// { dg-options "-flto" }
+// { dg-lto-do link }
+// { dg-lto-options { -flto } }


[gcc r15-4681] testsuite: lto: rename pr95677 test

2024-10-25 Thread Sam James via Gcc-cvs
https://gcc.gnu.org/g:96110c14cf61a1f8ecae04b8d947a60758363701

commit r15-4681-g96110c14cf61a1f8ecae04b8d947a60758363701
Author: Sam James 
Date:   Mon Oct 21 12:13:34 2024 +0100

testsuite: lto: rename pr95677 test

This was being ignored previously. Rename it per README.

gcc/testsuite/ChangeLog:
PR c++/95677

* g++.dg/lto/pr95677.C: Move to...
* g++.dg/lto/pr95677_0.C: ...here.

Diff:
---
 gcc/testsuite/g++.dg/lto/{pr95677.C => pr95677_0.C} | 0
 1 file changed, 0 insertions(+), 0 deletions(-)

diff --git a/gcc/testsuite/g++.dg/lto/pr95677.C 
b/gcc/testsuite/g++.dg/lto/pr95677_0.C
similarity index 100%
rename from gcc/testsuite/g++.dg/lto/pr95677.C
rename to gcc/testsuite/g++.dg/lto/pr95677_0.C


[gcc r12-10785] Fortran: Simplify len_trim with array ref and fix mapping bug[PR84868].

2024-10-25 Thread Paul Thomas via Gcc-cvs
https://gcc.gnu.org/g:b5211c13cf2ca3576ae287b204640516de20ecff

commit r12-10785-gb5211c13cf2ca3576ae287b204640516de20ecff
Author: Paul Thomas 
Date:   Tue Jul 16 15:56:44 2024 +0100

Fortran: Simplify len_trim with array ref and fix mapping bug[PR84868].

2024-07-16  Paul Thomas  

gcc/fortran
PR fortran/84868
* simplify.cc (gfc_simplify_len_trim): If the argument is an
element of a parameter array, simplify all the elements and
build a new parameter array to hold the result, after checking
that it doesn't already exist.
* trans-expr.cc (gfc_get_interface_mapping_array) if a string
length is available, use it for the typespec.
(gfc_add_interface_mapping): Supply the se string length.

gcc/testsuite/
PR fortran/84868
* gfortran.dg/pr84868.f90: New test.

(cherry picked from commit 9f966b6a8ff0244dd6f8bf36d876799d5f9bbaee)

Diff:
---
 gcc/fortran/simplify.cc   | 75 +++
 gcc/fortran/trans-expr.cc | 18 +---
 gcc/testsuite/gfortran.dg/pr84868.f90 | 84 +++
 3 files changed, 171 insertions(+), 6 deletions(-)

diff --git a/gcc/fortran/simplify.cc b/gcc/fortran/simplify.cc
index a10f79c4a932..b8935eb0118b 100644
--- a/gcc/fortran/simplify.cc
+++ b/gcc/fortran/simplify.cc
@@ -4582,6 +4582,81 @@ gfc_simplify_len_trim (gfc_expr *e, gfc_expr *kind)
   if (k == -1)
 return &gfc_bad_expr;
 
+  /* If the expression is either an array element or section, an array
+ parameter must be built so that the reference can be applied. Constant
+ references should have already been simplified away. All other cases
+ can proceed to translation, where kind conversion will occur silently.  */
+  if (e->expr_type == EXPR_VARIABLE
+  && e->ts.type == BT_CHARACTER
+  && e->symtree->n.sym->attr.flavor == FL_PARAMETER
+  && e->ref && e->ref->type == REF_ARRAY
+  && e->ref->u.ar.type != AR_FULL
+  && e->symtree->n.sym->value)
+{
+  char name[2*GFC_MAX_SYMBOL_LEN + 12];
+  gfc_namespace *ns = e->symtree->n.sym->ns;
+  gfc_symtree *st;
+  gfc_expr *expr;
+  gfc_expr *p;
+  gfc_constructor *c;
+  int cnt = 0;
+
+  sprintf (name, "_len_trim_%s_%s", e->symtree->n.sym->name,
+  ns->proc_name->name);
+  st = gfc_find_symtree (ns->sym_root, name);
+  if (st)
+   goto already_built;
+
+  /* Recursively call this fcn to simplify the constructor elements.  */
+  expr = gfc_copy_expr (e->symtree->n.sym->value);
+  expr->ts.type = BT_INTEGER;
+  expr->ts.kind = k;
+  expr->ts.u.cl = NULL;
+  c = gfc_constructor_first (expr->value.constructor);
+  for (; c; c = gfc_constructor_next (c))
+   {
+ if (c->iterator)
+   continue;
+
+ if (c->expr && c->expr->ts.type == BT_CHARACTER)
+   {
+ p = gfc_simplify_len_trim (c->expr, kind);
+ if (p == NULL)
+   goto clean_up;
+ gfc_replace_expr (c->expr, p);
+ cnt++;
+   }
+   }
+
+  if (cnt)
+   {
+ /* Build a new parameter to take the result.  */
+ st = gfc_new_symtree (&ns->sym_root, name);
+ st->n.sym = gfc_new_symbol (st->name, ns);
+ st->n.sym->value = expr;
+ st->n.sym->ts = expr->ts;
+ st->n.sym->attr.dimension = 1;
+ st->n.sym->attr.save = SAVE_IMPLICIT;
+ st->n.sym->attr.flavor = FL_PARAMETER;
+ st->n.sym->as = gfc_copy_array_spec (e->symtree->n.sym->as);
+ gfc_set_sym_referenced (st->n.sym);
+ st->n.sym->refs++;
+ gfc_commit_symbol (st->n.sym);
+
+already_built:
+ /* Build a return expression.  */
+ expr = gfc_copy_expr (e);
+ expr->ts = st->n.sym->ts;
+ expr->symtree = st;
+ gfc_expression_rank (expr);
+ return expr;
+   }
+
+clean_up:
+  gfc_free_expr (expr);
+  return NULL;
+}
+
   if (e->expr_type != EXPR_CONSTANT)
 return NULL;
 
diff --git a/gcc/fortran/trans-expr.cc b/gcc/fortran/trans-expr.cc
index e78a01003c9c..54cf246fd0d7 100644
--- a/gcc/fortran/trans-expr.cc
+++ b/gcc/fortran/trans-expr.cc
@@ -4326,12 +4326,15 @@ gfc_get_interface_mapping_charlen 
(gfc_interface_mapping * mapping,
 
 static tree
 gfc_get_interface_mapping_array (stmtblock_t * block, gfc_symbol * sym,
-gfc_packed packed, tree data)
+gfc_packed packed, tree data, tree len)
 {
   tree type;
   tree var;
 
-  type = gfc_typenode_for_spec (&sym->ts);
+  if (len != NULL_TREE && (TREE_CONSTANT (len) || VAR_P (len)))
+type = gfc_get_character_type_len (sym->ts.kind, len);
+  else
+type = gfc_typenode_for_spec (&sym->ts);
   type = gfc_get_nodesc_array_type (type, sym->as, packed,
!sym->attr.tar

[gcc r14-10834] Fortran: Simplify len_trim with array ref and fix mapping bug[PR84868].

2024-10-25 Thread Paul Thomas via Gcc-cvs
https://gcc.gnu.org/g:944d585d8a566e50a287eb64caf9af0e90daf5dd

commit r14-10834-g944d585d8a566e50a287eb64caf9af0e90daf5dd
Author: Paul Thomas 
Date:   Tue Jul 16 15:56:44 2024 +0100

Fortran: Simplify len_trim with array ref and fix mapping bug[PR84868].

2024-07-16  Paul Thomas  

gcc/fortran
PR fortran/84868
* simplify.cc (gfc_simplify_len_trim): If the argument is an
element of a parameter array, simplify all the elements and
build a new parameter array to hold the result, after checking
that it doesn't already exist.
* trans-expr.cc (gfc_get_interface_mapping_array) if a string
length is available, use it for the typespec.
(gfc_add_interface_mapping): Supply the se string length.

gcc/testsuite/
PR fortran/84868
* gfortran.dg/pr84868.f90: New test.

(cherry picked from commit 9f966b6a8ff0244dd6f8bf36d876799d5f9bbaee)

Diff:
---
 gcc/fortran/simplify.cc   | 75 +++
 gcc/fortran/trans-expr.cc | 18 +---
 gcc/testsuite/gfortran.dg/pr84868.f90 | 84 +++
 3 files changed, 171 insertions(+), 6 deletions(-)

diff --git a/gcc/fortran/simplify.cc b/gcc/fortran/simplify.cc
index 3043483daa90..cc2ccfe13afe 100644
--- a/gcc/fortran/simplify.cc
+++ b/gcc/fortran/simplify.cc
@@ -4637,6 +4637,81 @@ gfc_simplify_len_trim (gfc_expr *e, gfc_expr *kind)
   if (k == -1)
 return &gfc_bad_expr;
 
+  /* If the expression is either an array element or section, an array
+ parameter must be built so that the reference can be applied. Constant
+ references should have already been simplified away. All other cases
+ can proceed to translation, where kind conversion will occur silently.  */
+  if (e->expr_type == EXPR_VARIABLE
+  && e->ts.type == BT_CHARACTER
+  && e->symtree->n.sym->attr.flavor == FL_PARAMETER
+  && e->ref && e->ref->type == REF_ARRAY
+  && e->ref->u.ar.type != AR_FULL
+  && e->symtree->n.sym->value)
+{
+  char name[2*GFC_MAX_SYMBOL_LEN + 12];
+  gfc_namespace *ns = e->symtree->n.sym->ns;
+  gfc_symtree *st;
+  gfc_expr *expr;
+  gfc_expr *p;
+  gfc_constructor *c;
+  int cnt = 0;
+
+  sprintf (name, "_len_trim_%s_%s", e->symtree->n.sym->name,
+  ns->proc_name->name);
+  st = gfc_find_symtree (ns->sym_root, name);
+  if (st)
+   goto already_built;
+
+  /* Recursively call this fcn to simplify the constructor elements.  */
+  expr = gfc_copy_expr (e->symtree->n.sym->value);
+  expr->ts.type = BT_INTEGER;
+  expr->ts.kind = k;
+  expr->ts.u.cl = NULL;
+  c = gfc_constructor_first (expr->value.constructor);
+  for (; c; c = gfc_constructor_next (c))
+   {
+ if (c->iterator)
+   continue;
+
+ if (c->expr && c->expr->ts.type == BT_CHARACTER)
+   {
+ p = gfc_simplify_len_trim (c->expr, kind);
+ if (p == NULL)
+   goto clean_up;
+ gfc_replace_expr (c->expr, p);
+ cnt++;
+   }
+   }
+
+  if (cnt)
+   {
+ /* Build a new parameter to take the result.  */
+ st = gfc_new_symtree (&ns->sym_root, name);
+ st->n.sym = gfc_new_symbol (st->name, ns);
+ st->n.sym->value = expr;
+ st->n.sym->ts = expr->ts;
+ st->n.sym->attr.dimension = 1;
+ st->n.sym->attr.save = SAVE_IMPLICIT;
+ st->n.sym->attr.flavor = FL_PARAMETER;
+ st->n.sym->as = gfc_copy_array_spec (e->symtree->n.sym->as);
+ gfc_set_sym_referenced (st->n.sym);
+ st->n.sym->refs++;
+ gfc_commit_symbol (st->n.sym);
+
+already_built:
+ /* Build a return expression.  */
+ expr = gfc_copy_expr (e);
+ expr->ts = st->n.sym->ts;
+ expr->symtree = st;
+ gfc_expression_rank (expr);
+ return expr;
+   }
+
+clean_up:
+  gfc_free_expr (expr);
+  return NULL;
+}
+
   if (e->expr_type != EXPR_CONSTANT)
 return NULL;
 
diff --git a/gcc/fortran/trans-expr.cc b/gcc/fortran/trans-expr.cc
index dfc5b8e9b4a5..3a5a41401858 100644
--- a/gcc/fortran/trans-expr.cc
+++ b/gcc/fortran/trans-expr.cc
@@ -4424,12 +4424,15 @@ gfc_get_interface_mapping_charlen 
(gfc_interface_mapping * mapping,
 
 static tree
 gfc_get_interface_mapping_array (stmtblock_t * block, gfc_symbol * sym,
-gfc_packed packed, tree data)
+gfc_packed packed, tree data, tree len)
 {
   tree type;
   tree var;
 
-  type = gfc_typenode_for_spec (&sym->ts);
+  if (len != NULL_TREE && (TREE_CONSTANT (len) || VAR_P (len)))
+type = gfc_get_character_type_len (sym->ts.kind, len);
+  else
+type = gfc_typenode_for_spec (&sym->ts);
   type = gfc_get_nodesc_array_type (type, sym->as, packed,
!sym->attr.tar

[gcc r13-9147] Fortran: Simplify len_trim with array ref and fix mapping bug[PR84868].

2024-10-25 Thread Paul Thomas via Gcc-cvs
https://gcc.gnu.org/g:457a3bb146eb83ffc229d0658cb21317187c38ab

commit r13-9147-g457a3bb146eb83ffc229d0658cb21317187c38ab
Author: Paul Thomas 
Date:   Tue Jul 16 15:56:44 2024 +0100

Fortran: Simplify len_trim with array ref and fix mapping bug[PR84868].

2024-07-16  Paul Thomas  

gcc/fortran
PR fortran/84868
* simplify.cc (gfc_simplify_len_trim): If the argument is an
element of a parameter array, simplify all the elements and
build a new parameter array to hold the result, after checking
that it doesn't already exist.
* trans-expr.cc (gfc_get_interface_mapping_array) if a string
length is available, use it for the typespec.
(gfc_add_interface_mapping): Supply the se string length.

gcc/testsuite/
PR fortran/84868
* gfortran.dg/pr84868.f90: New test.

(cherry picked from commit 9f966b6a8ff0244dd6f8bf36d876799d5f9bbaee)

Diff:
---
 gcc/fortran/simplify.cc   | 75 +++
 gcc/fortran/trans-expr.cc | 18 +---
 gcc/testsuite/gfortran.dg/pr84868.f90 | 84 +++
 3 files changed, 171 insertions(+), 6 deletions(-)

diff --git a/gcc/fortran/simplify.cc b/gcc/fortran/simplify.cc
index fe700097b7b0..1d0af095de51 100644
--- a/gcc/fortran/simplify.cc
+++ b/gcc/fortran/simplify.cc
@@ -4623,6 +4623,81 @@ gfc_simplify_len_trim (gfc_expr *e, gfc_expr *kind)
   if (k == -1)
 return &gfc_bad_expr;
 
+  /* If the expression is either an array element or section, an array
+ parameter must be built so that the reference can be applied. Constant
+ references should have already been simplified away. All other cases
+ can proceed to translation, where kind conversion will occur silently.  */
+  if (e->expr_type == EXPR_VARIABLE
+  && e->ts.type == BT_CHARACTER
+  && e->symtree->n.sym->attr.flavor == FL_PARAMETER
+  && e->ref && e->ref->type == REF_ARRAY
+  && e->ref->u.ar.type != AR_FULL
+  && e->symtree->n.sym->value)
+{
+  char name[2*GFC_MAX_SYMBOL_LEN + 12];
+  gfc_namespace *ns = e->symtree->n.sym->ns;
+  gfc_symtree *st;
+  gfc_expr *expr;
+  gfc_expr *p;
+  gfc_constructor *c;
+  int cnt = 0;
+
+  sprintf (name, "_len_trim_%s_%s", e->symtree->n.sym->name,
+  ns->proc_name->name);
+  st = gfc_find_symtree (ns->sym_root, name);
+  if (st)
+   goto already_built;
+
+  /* Recursively call this fcn to simplify the constructor elements.  */
+  expr = gfc_copy_expr (e->symtree->n.sym->value);
+  expr->ts.type = BT_INTEGER;
+  expr->ts.kind = k;
+  expr->ts.u.cl = NULL;
+  c = gfc_constructor_first (expr->value.constructor);
+  for (; c; c = gfc_constructor_next (c))
+   {
+ if (c->iterator)
+   continue;
+
+ if (c->expr && c->expr->ts.type == BT_CHARACTER)
+   {
+ p = gfc_simplify_len_trim (c->expr, kind);
+ if (p == NULL)
+   goto clean_up;
+ gfc_replace_expr (c->expr, p);
+ cnt++;
+   }
+   }
+
+  if (cnt)
+   {
+ /* Build a new parameter to take the result.  */
+ st = gfc_new_symtree (&ns->sym_root, name);
+ st->n.sym = gfc_new_symbol (st->name, ns);
+ st->n.sym->value = expr;
+ st->n.sym->ts = expr->ts;
+ st->n.sym->attr.dimension = 1;
+ st->n.sym->attr.save = SAVE_IMPLICIT;
+ st->n.sym->attr.flavor = FL_PARAMETER;
+ st->n.sym->as = gfc_copy_array_spec (e->symtree->n.sym->as);
+ gfc_set_sym_referenced (st->n.sym);
+ st->n.sym->refs++;
+ gfc_commit_symbol (st->n.sym);
+
+already_built:
+ /* Build a return expression.  */
+ expr = gfc_copy_expr (e);
+ expr->ts = st->n.sym->ts;
+ expr->symtree = st;
+ gfc_expression_rank (expr);
+ return expr;
+   }
+
+clean_up:
+  gfc_free_expr (expr);
+  return NULL;
+}
+
   if (e->expr_type != EXPR_CONSTANT)
 return NULL;
 
diff --git a/gcc/fortran/trans-expr.cc b/gcc/fortran/trans-expr.cc
index 657f1cb649b4..7e3c38e5f92d 100644
--- a/gcc/fortran/trans-expr.cc
+++ b/gcc/fortran/trans-expr.cc
@@ -4366,12 +4366,15 @@ gfc_get_interface_mapping_charlen 
(gfc_interface_mapping * mapping,
 
 static tree
 gfc_get_interface_mapping_array (stmtblock_t * block, gfc_symbol * sym,
-gfc_packed packed, tree data)
+gfc_packed packed, tree data, tree len)
 {
   tree type;
   tree var;
 
-  type = gfc_typenode_for_spec (&sym->ts);
+  if (len != NULL_TREE && (TREE_CONSTANT (len) || VAR_P (len)))
+type = gfc_get_character_type_len (sym->ts.kind, len);
+  else
+type = gfc_typenode_for_spec (&sym->ts);
   type = gfc_get_nodesc_array_type (type, sym->as, packed,
!sym->attr.targ

[gcc r15-4632] ada: Spurious error compiling CC51011

2024-10-25 Thread Marc Poulhi?s via Gcc-cvs
https://gcc.gnu.org/g:d6f9774b780150c1cbb58d43a0f1f36c2da0e2c7

commit r15-4632-gd6f9774b780150c1cbb58d43a0f1f36c2da0e2c7
Author: Javier Miranda 
Date:   Mon Sep 16 11:40:06 2024 +

ada: Spurious error compiling CC51011

Adjust the check of 13.14(10.2/3) to avoid reporting an error
on unfrozen incomplete types, as they are never frozen
(AI12-0155-1).

gcc/ada/ChangeLog:

* sem_ch8.adb (Freeze_Actual_Profile): Do not report error
on incomplete types, since they do not cause freezing.

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

diff --git a/gcc/ada/sem_ch8.adb b/gcc/ada/sem_ch8.adb
index 13c44c5e302c..760d4bebc78e 100644
--- a/gcc/ada/sem_ch8.adb
+++ b/gcc/ada/sem_ch8.adb
@@ -2343,6 +2343,11 @@ package body Sem_Ch8 is
  elsif From_Limited_With (Etype (F)) then
 null;
 
+ --  Incomplete types are never frozen (AI12-0155-1)
+
+ elsif Is_Incomplete_Type (Etype (F)) then
+null;
+
  else
 Error_Msg_NE
   ("type& must be frozen before this point",


[gcc r15-4637] ada: Misc improvements to gnat RM

2024-10-25 Thread Marc Poulhi?s via Gcc-cvs
https://gcc.gnu.org/g:f2434f2a965e51a2537240d85fcedab8d4be81b9

commit r15-4637-gf2434f2a965e51a2537240d85fcedab8d4be81b9
Author: Bob Duff 
Date:   Wed Sep 18 16:28:34 2024 -0400

ada: Misc improvements to gnat RM

...in the "GNAT language extensions" section.

gcc/ada/ChangeLog:

* doc/gnat_rm/gnat_language_extensions.rst:
Minor wording improvments.
* gnat_rm.texi: Regenerate.
* gnat_ugn.texi: Regenerate.

Diff:
---
 gcc/ada/doc/gnat_rm/gnat_language_extensions.rst | 81 -
 gcc/ada/gnat_rm.texi | 89 ++--
 gcc/ada/gnat_ugn.texi|  4 +-
 3 files changed, 101 insertions(+), 73 deletions(-)

diff --git a/gcc/ada/doc/gnat_rm/gnat_language_extensions.rst 
b/gcc/ada/doc/gnat_rm/gnat_language_extensions.rst
index cccf60217d0f..0e9bb7fc54eb 100644
--- a/gcc/ada/doc/gnat_rm/gnat_language_extensions.rst
+++ b/gcc/ada/doc/gnat_rm/gnat_language_extensions.rst
@@ -14,8 +14,9 @@ There are two sets of language extensions:
   available to users early on.
 
 * The second is the experimental set. It includes the first, but also
-  experimental features, that are here because they're still in an early
-  prototyping phase.
+  experimental features, which are considered experimental because
+  they're still in an early prototyping phase.
+  These features might be removed or heavily modified at any time.
 
 How to activate the extended GNAT Ada superset
 ==
@@ -32,12 +33,12 @@ There are two ways to activate the extended GNAT Ada 
superset:
 As a configuration pragma, you can either put it at the beginning of a source
 file, or in a ``.adc`` file corresponding to your project.
 
-* The ``-gnatX`` option, that you can pass to the compiler directly, will
+* The ``-gnatX`` command-line option will
   activate the curated subset of extensions.
 
 .. attention:: You can activate the experimental set of extensions
in addition by using either
-   the ``-gnatX0`` command line flag, or the pragma ``Extensions_Allowed`` with
+   the ``-gnatX0`` command-line option, or the pragma ``Extensions_Allowed`` 
with
``All_Extensions`` as an argument. However, it is not recommended you use
this subset for serious projects; it is only meant as a technology preview
for use in playground experiments.
@@ -56,8 +57,8 @@ Local Declarations Without Block
 A ``basic_declarative_item`` may appear at the place of any statement. This
 avoids the heavy syntax of block_statements just to declare something locally.
 
-The only valid kind of declarations for now are ``object_declaration``,
-``object_renaming_declaration``, ``use_package_clause`` and
+The only valid kinds of declarations for now are ``object_declaration``,
+``object_renaming_declaration``, ``use_package_clause``, and
 ``use_type_clause``.
 
 For example:
@@ -75,10 +76,11 @@ For example:
 It is generally a good practice to declare local variables (or constants) with 
as
 short a lifetime as possible. However, introducing a declare block to 
accomplish
 this is a relatively heavy syntactic load along with a traditional extra level
-of indentation. The alternative syntax supported here allows declaring symbols
-in any statement sequence. Lifetime of such local declarations is until the 
end of
+of indentation. The alternative syntax supported here allows declarations
+in any statement sequence.
+The lifetime of such local declarations is until the end of
 the enclosing construct. The same enclosing construct cannot contain several
-declarations of the same symbol; however, overriding symbols from higher-level
+declarations of the same defining name; however, overriding symbols from 
higher-level
 scopes works similarly to the explicit ``declare`` block.
 
 If the enclosing construct allows an exception handler (such as an accept
@@ -188,8 +190,8 @@ appear within parentheses after the name of the primitive 
operation.
 
 This same notation is already available for tagged types. This extension allows
 for untagged types. It is allowed for all primitive operations of the type
-independent of whether they were originally declared in a package spec or its
-private part, or were inherited and/or overridden as part of a derived type
+independent of whether they were originally declared in a package spec,
+or were inherited and/or overridden as part of a derived type
 declaration occurring anywhere, so long as the first parameter is of the type,
 or an access parameter designating the type.
 
@@ -248,18 +250,17 @@ Here is an example of this feature:
-- ...
 end Stacks;
 
-.. todo::
-
-   I do not understand this feature enough to decide if the description above
-   is sufficient for documentation.
-
-Link to the original RFC:
-https://github.com/AdaCore/ada-spark-rfcs/blob/master/prototyped/rfc-expression-functions-as-default-for-generic-formal-function-parameters.rst
+If 

[gcc r15-4630] ada: Fix fallout of change to 'Wide_Wide_Value for enumeration types

2024-10-25 Thread Marc Poulhi?s via Gcc-cvs
https://gcc.gnu.org/g:18232cbcfd2c4f95bf51b4fa9fb65f545c2a0569

commit r15-4630-g18232cbcfd2c4f95bf51b4fa9fb65f545c2a0569
Author: Eric Botcazou 
Date:   Fri Sep 13 21:09:31 2024 +0200

ada: Fix fallout of change to 'Wide_Wide_Value for enumeration types

The literals of enumeration types are always normalized, even though they
contain wide characters (but the normalization leaves these unchanged),
so a normalization routine that is aware of wide characters must be run
on the input string for 'Wide_Wide_Value.

gcc/ada/ChangeLog:

PR ada/115507
* rtsfind.ads (RE_Id): Add RE_Enum_[Wide_]Wide_String_To_String.
(RE_Unit_Table): Add entries for the new values.
* exp_attr.adb (Is_User_Defined_Enumeration_Type): New predicate.
(Expand_N_Attribute_Reference) : Build a call
to RE_Enum_Wide_String_To_String for user-defined enumeration types.
: Likewise with
RE_Enum_Wide_Wide_String_To_String.
* exp_imgv.adb (Expand_Value_Attribute): Adjust to above.
* libgnat/s-wchwts.ads (Enum_Wide_String_To_String): New function.
(Enum_Wide_Wide_String_To_String): Likewise.
* libgnat/s-wchwts.adb: Add clauses for System.Case_Util.
(Normalize_String): New local procedure.
(Enum_Wide_String_To_String): New function body.
(Enum_Wide_Wide_String_To_String): Likewise.

Diff:
---
 gcc/ada/exp_attr.adb |  29 -
 gcc/ada/exp_imgv.adb |   4 +-
 gcc/ada/libgnat/s-wchwts.adb | 150 ++-
 gcc/ada/libgnat/s-wchwts.ads |  12 
 gcc/ada/rtsfind.ads  |   4 ++
 5 files changed, 193 insertions(+), 6 deletions(-)

diff --git a/gcc/ada/exp_attr.adb b/gcc/ada/exp_attr.adb
index 702c4bb120a3..cb068c102a2c 100644
--- a/gcc/ada/exp_attr.adb
+++ b/gcc/ada/exp_attr.adb
@@ -273,6 +273,10 @@ package body Exp_Attr is
--  expansion. Typically used for rounding and truncation attributes that
--  appear directly inside a conversion to integer.
 
+   function Is_User_Defined_Enumeration_Type (Typ : Entity_Id) return Boolean;
+   --  Returns True if Typ is a user-defined enumeration type, in the sense
+   --  that its literals are declared in the source.
+
function Interunit_Ref_OK
  (Subp_Unit, Attr_Ref_Unit : Node_Id) return Boolean is
(In_Same_Extended_Unit (Subp_Unit, Attr_Ref_Unit)
@@ -8107,7 +8111,10 @@ package body Exp_Attr is
  Expressions=> New_List (
Make_Function_Call (Loc,
  Name =>
-   New_Occurrence_Of (RTE (RE_Wide_String_To_String), Loc),
+   New_Occurrence_Of
+ (RTE (if Is_User_Defined_Enumeration_Type (Typ)
+   then RE_Enum_Wide_String_To_String
+   else RE_Wide_String_To_String), Loc),
 
  Parameter_Associations => New_List (
Relocate_Node (First (Exprs)),
@@ -8139,7 +8146,9 @@ package body Exp_Attr is
Make_Function_Call (Loc,
  Name   =>
New_Occurrence_Of
- (RTE (RE_Wide_Wide_String_To_String), Loc),
+ (RTE (if Is_User_Defined_Enumeration_Type (Typ)
+   then RE_Enum_Wide_Wide_String_To_String
+   else RE_Wide_Wide_String_To_String), Loc),
 
  Parameter_Associations => New_List (
Relocate_Node (First (Exprs)),
@@ -9458,4 +9467,20 @@ package body Exp_Attr is
   or else Id = Attribute_Truncation;
end Is_Inline_Floating_Point_Attribute;
 
+   --
+   -- Is_User_Defined_Enumeration_Type --
+   --
+
+   function Is_User_Defined_Enumeration_Type (Typ : Entity_Id) return Boolean
+   is
+  Rtyp : constant Entity_Id := Root_Type (Base_Type (Typ));
+
+   begin
+  return Is_Enumeration_Type (Rtyp)
+and then Rtyp not in Standard_Boolean
+   | Standard_Character
+   | Standard_Wide_Character
+   | Standard_Wide_Wide_Character;
+   end Is_User_Defined_Enumeration_Type;
+
 end Exp_Attr;
diff --git a/gcc/ada/exp_imgv.adb b/gcc/ada/exp_imgv.adb
index ef2a3a3250fc..20afebc061c0 100644
--- a/gcc/ada/exp_imgv.adb
+++ b/gcc/ada/exp_imgv.adb
@@ -1744,9 +1744,9 @@ package body Exp_Imgv is
   E : constant Entity_Id := Entity (Name (First (Args)));
 
begin
-  Is_Wide := Is_RTE (E, RE_Wide_String_To_String)
+  Is_Wide := Is_RTE (E, RE_Enum_Wide_String_To_String)
or else
- Is_RTE (E, RE_Wide_Wide_String_To_String);
+ Is_RTE (E, RE_Enum_Wide_Wide_String_To_String);
   

[gcc r15-4627] ada: Inspect deferred constant completions in missing contexts

2024-10-25 Thread Marc Poulhi?s via Gcc-cvs
https://gcc.gnu.org/g:a8bfc4dede003c76123f44eaafb374cb6dbcc1ec

commit r15-4627-ga8bfc4dede003c76123f44eaafb374cb6dbcc1ec
Author: Raphaël AMIARD 
Date:   Wed Sep 4 08:24:26 2024 +

ada: Inspect deferred constant completions in missing contexts

Namely declare expressions and statement lists, which can have object
declarations in -gnatX mode.

gcc/ada/ChangeLog:

* sem_util.ads: Introduce Inspect_Deferred_Constant_Completion
on a single object declaration, to better factorize the code
* sem_util.adb: Introduce aforementioned overload
* sem_ch4.adb (Analyze_Expression_With_Actions): Check deferred
constant completions
* sem_ch5.adb (Analyze_Statements): Check deferred constant
completions

Diff:
---
 gcc/ada/sem_ch4.adb  |  2 ++
 gcc/ada/sem_ch5.adb  |  2 ++
 gcc/ada/sem_util.adb | 16 ++--
 gcc/ada/sem_util.ads |  5 +
 4 files changed, 19 insertions(+), 6 deletions(-)

diff --git a/gcc/ada/sem_ch4.adb b/gcc/ada/sem_ch4.adb
index 9afaa896e20b..2d912109 100644
--- a/gcc/ada/sem_ch4.adb
+++ b/gcc/ada/sem_ch4.adb
@@ -2414,6 +2414,8 @@ package body Sem_Ch4 is
 
  case Nkind (A) is
 when N_Object_Declaration =>
+   Inspect_Deferred_Constant_Completion (A);
+
if Nkind (Object_Definition (A)) = N_Access_Definition then
   Error_Msg_N
 ("anonymous access type not allowed in declare_expression",
diff --git a/gcc/ada/sem_ch5.adb b/gcc/ada/sem_ch5.adb
index 30fee6e65001..131195a78c7c 100644
--- a/gcc/ada/sem_ch5.adb
+++ b/gcc/ada/sem_ch5.adb
@@ -4255,6 +4255,8 @@ package body Sem_Ch5 is
  ("implicit label declaration for & is hidden#",
   Identifier (S));
 end if;
+ else
+Inspect_Deferred_Constant_Completion (S);
  end if;
 
  Next (S);
diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb
index ac64b1ca5496..12437cc5a4c8 100644
--- a/gcc/ada/sem_util.adb
+++ b/gcc/ada/sem_util.adb
@@ -14811,13 +14811,8 @@ package body Sem_Util is
-- Inspect_Deferred_Constant_Completion --
--
 
-   procedure Inspect_Deferred_Constant_Completion (Decls : List_Id) is
-  Decl : Node_Id;
-
+   procedure Inspect_Deferred_Constant_Completion (Decl : Node_Id) is
begin
-  Decl := First (Decls);
-  while Present (Decl) loop
-
  --  Deferred constant signature
 
  if Nkind (Decl) = N_Object_Declaration
@@ -14838,6 +14833,15 @@ package body Sem_Util is
   Defining_Identifier (Decl));
  end if;
 
+   end Inspect_Deferred_Constant_Completion;
+
+   procedure Inspect_Deferred_Constant_Completion (Decls : List_Id) is
+  Decl : Node_Id;
+
+   begin
+  Decl := First (Decls);
+  while Present (Decl) loop
+ Inspect_Deferred_Constant_Completion (Decl);
  Next (Decl);
   end loop;
end Inspect_Deferred_Constant_Completion;
diff --git a/gcc/ada/sem_util.ads b/gcc/ada/sem_util.ads
index eccbd4351d01..22ee23aa4ab0 100644
--- a/gcc/ada/sem_util.ads
+++ b/gcc/ada/sem_util.ads
@@ -1718,6 +1718,11 @@ package Sem_Util is
--  prefix is an access type, rewrite the access type node N (which is the
--  prefix, e.g. of an indexed component) as an explicit dereference.
 
+   procedure Inspect_Deferred_Constant_Completion (Decl : Node_Id);
+   --  If Decl is a constant object declaration without a default value, check
+   --  whether it has been completed by a full constant declaration or an
+   --  Import pragma. Emit an error message if that is not the case.
+
procedure Inspect_Deferred_Constant_Completion (Decls : List_Id);
--  Examine all deferred constants in the declaration list Decls and check
--  whether they have been completed by a full constant declaration or an


[gcc r15-4629] ada: Untagged incomplete view not detected in ACATS test b3a1a060

2024-10-25 Thread Marc Poulhi?s via Gcc-cvs
https://gcc.gnu.org/g:20441f8a30189040df995b1f4800ceed75a8c23c

commit r15-4629-g20441f8a30189040df995b1f4800ceed75a8c23c
Author: Javier Miranda 
Date:   Fri Sep 13 07:02:02 2024 +

ada: Untagged incomplete view not detected in ACATS test b3a1a060

Adding checks for RM 3.10.1(10): An actual parameter cannot be
of an untagged incomplete view; the result object of a function
call cannot be of an incomplete view.

gcc/ada/ChangeLog:

* sem_res.adb (Resolve_Actuals): Add checks for incomplete
type actuals.

Diff:
---
 gcc/ada/sem_res.adb | 52 +++-
 1 file changed, 47 insertions(+), 5 deletions(-)

diff --git a/gcc/ada/sem_res.adb b/gcc/ada/sem_res.adb
index 6b673a9c1987..5f77ddabd09e 100644
--- a/gcc/ada/sem_res.adb
+++ b/gcc/ada/sem_res.adb
@@ -4667,14 +4667,56 @@ package body Sem_Res is
F_Typ := Full_View (F_Typ);
 end if;
 
---  An actual cannot be an untagged formal incomplete type
+--  An actual cannot be of an untagged incomplete view; the result
+--  object of a function call cannot be of an incomplete view
+--  (RM 3.10.1(10)).
 
 if Ekind (A_Typ) = E_Incomplete_Type
-  and then not Is_Tagged_Type (A_Typ)
-  and then Is_Generic_Type (A_Typ)
+  and then (Nkind (A) = N_Function_Call
+  or else not Is_Tagged_Type (A_Typ))
 then
-   Error_Msg_N
- ("invalid use of untagged formal incomplete type", A);
+   --  No error if the call is placed in the initializing
+   --  expression of a component of the full-view of the
+   --  incomplete type. For example:
+
+   --type T;
+   --function F (Obj : T) return Integer;
+
+   --type T is record
+   --   Data : Integer := F (T);
+   --end record;
+
+   if Present (Full_View (A_Typ))
+ and then Full_View (A_Typ) = Current_Scope
+ and then In_Spec_Expression
+ and then In_Default_Expr
+   then
+  null;
+
+   --  No error if the call is performed in pre/postconditions, and
+   --  it is an incomplete type of a limited-with clause.
+
+   elsif From_Limited_With (A_Typ)
+ and then Present (Non_Limited_View (A_Typ))
+ and then Is_Subprogram (Current_Scope)
+ and then
+   (In_Spec_Expression
+  or else
+Present (Class_Preconditions_Subprogram (Current_Scope)))
+   then
+  null;
+
+   elsif Is_Generic_Type (A_Typ) then
+  if Is_Tagged_Type (A_Typ) then
+ Error_Msg_N
+   ("invalid use of tagged formal incomplete type", A);
+  else
+ Error_Msg_N
+   ("invalid use of untagged formal incomplete type", A);
+  end if;
+   else
+  Check_Fully_Declared (A_Typ, A);
+   end if;
 end if;
 
 --  For mode IN, if actual is an entity, and the type of the formal


[gcc r15-4633] ada: Fix internal error on ambiguous operands of comparison operator

2024-10-25 Thread Marc Poulhi?s via Gcc-cvs
https://gcc.gnu.org/g:104f8ad0ad4e0adb542bcf062c6a1009661fb4c1

commit r15-4633-g104f8ad0ad4e0adb542bcf062c6a1009661fb4c1
Author: Eric Botcazou 
Date:   Mon Sep 16 08:31:57 2024 +0200

ada: Fix internal error on ambiguous operands of comparison operator

This is a regression introduced when the diagnosis of ambiguous operands
for comparison and equality operators was moved from the analysis to the
resolution phase in order to avoid spurious ambiguities in specific cases.

When an ambiguity is detected for the operands of predefined comparison
and equality operators during analysis, it needs to be recorded so that
later calls to the disambiguation routine know about this ambiguity for
the case where the context has been resolved to boolean.

gcc/ada/ChangeLog:

* sem_type.ads (Interp ): Add Opnd_Typ component and remove default
value for Abstract_Op component.
(Add_One_Interp): Rename Opnd_Type parameter to Opnd_Typ.
* sem_type.adb (Add_One_Interp): Likewise.
(Add_One_Interp.Add_Entry): Record the operand type as well.
(Collect_Interp): Record Empty for the operand type.
(Disambiguate.Is_Ambiguous_Boolean_Operator): New predicate.
(Disambiguate): Use it to detect recorded ambiguity cases.
* sem_ch4.adb (Find_Comparison_Equality_Types): Add commentary.

Diff:
---
 gcc/ada/sem_ch4.adb  |  8 
 gcc/ada/sem_type.adb | 45 +
 gcc/ada/sem_type.ads | 25 +
 3 files changed, 58 insertions(+), 20 deletions(-)

diff --git a/gcc/ada/sem_ch4.adb b/gcc/ada/sem_ch4.adb
index 2d912109..bf0d7cfd1af9 100644
--- a/gcc/ada/sem_ch4.adb
+++ b/gcc/ada/sem_ch4.adb
@@ -7455,6 +7455,8 @@ package body Sem_Ch4 is
then
   It := Disambiguate (L, Valid_I, I, Any_Type);
 
+  --  Note the ambiguity for later, see below
+
   if It = No_Interp then
  L_Typ := Any_Type;
  R_Typ := T;
@@ -7472,6 +7474,12 @@ package body Sem_Ch4 is
 Get_Next_Interp (I, It);
  end loop;
 
+ --  Record the operator as an interpretation of the operation if we
+ --  have found a valid pair of types for the two operands. If we have
+ --  found more than one such pair and did not manage to disambiguate
+ --  them, record an "ambiguous" operator as the interpretation, that
+ --  Disambiguate in Sem_Type will specifically recognize.
+
  if Present (L_Typ) then
 Set_Etype (L, L_Typ);
 Set_Etype (R, R_Typ);
diff --git a/gcc/ada/sem_type.adb b/gcc/ada/sem_type.adb
index 75e7dafbc604..c775849684a2 100644
--- a/gcc/ada/sem_type.adb
+++ b/gcc/ada/sem_type.adb
@@ -197,10 +197,10 @@ package body Sem_Type is

 
procedure Add_One_Interp
- (N : Node_Id;
-  E : Entity_Id;
-  T : Entity_Id;
-  Opnd_Type : Entity_Id := Empty)
+ (N: Node_Id;
+  E: Entity_Id;
+  T: Entity_Id;
+  Opnd_Typ : Entity_Id := Empty)
is
   Vis_Type : Entity_Id;
 
@@ -308,7 +308,7 @@ package body Sem_Type is
 end if;
  end loop;
 
- All_Interp.Table (All_Interp.Last) := (Name, Typ, Abstr_Op);
+ All_Interp.Table (All_Interp.Last) := (Name, Typ, Opnd_Typ, Abstr_Op);
  All_Interp.Append (No_Interp);
   end Add_Entry;
 
@@ -369,8 +369,8 @@ package body Sem_Type is
   --  it is the type of the operand that is relevant here.
 
   if Ekind (E) = E_Operator then
- if Present (Opnd_Type) then
-Vis_Type := Opnd_Type;
+ if Present (Opnd_Typ) then
+Vis_Type := Opnd_Typ;
  else
 Vis_Type := Base_Type (T);
  end if;
@@ -663,7 +663,7 @@ package body Sem_Type is
and then not Is_Inherited_Operation (H)
  then
 All_Interp.Table (All_Interp.Last) :=
-  (H, Etype (H), Empty);
+  (H, Etype (H), Empty, Empty);
 All_Interp.Append (No_Interp);
 goto Next_Homograph;
 
@@ -1317,6 +1317,12 @@ package body Sem_Type is
   --  the generic. Within the instance the actual is represented by a
   --  constructed subprogram renaming.
 
+  function Is_Ambiguous_Boolean_Operator (I : Interp) return Boolean;
+  --  Determine whether I corresponds to an "ambiguous" boolean operator.
+  --  Such an interpretation is used to record the ambiguity of operands
+  --  diagnosed during the analysis of comparison and equality operations.
+  --  See Find_Comparison_Equality_Types in Sem_Ch4 for the rationale.
+
   function Matches (Op : Node_Id; Func_Id : Entity_Id) return Boolean;
   --  Determine w

[gcc r15-4631] ada: Fix wrong handling of wide wide characters in Append_Decoded_With_Brackets

2024-10-25 Thread Marc Poulhi?s via Gcc-cvs
https://gcc.gnu.org/g:a71c37a7241d8a73fe51712e5b4c7222afbaee8b

commit r15-4631-ga71c37a7241d8a73fe51712e5b4c7222afbaee8b
Author: Eric Botcazou 
Date:   Sat Sep 14 14:48:24 2024 +0200

ada: Fix wrong handling of wide wide characters in 
Append_Decoded_With_Brackets

This only shows up at link time when the name of a compilation unit contains
a wide wide character.

gcc/ada/ChangeLog:

* namet.adb (Append_Decoded_With_Brackets): Fix condition for the
cheap test at the beginning of the loop.

Diff:
---
 gcc/ada/namet.adb | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/gcc/ada/namet.adb b/gcc/ada/namet.adb
index 72f6c2088db0..2e3b9c014fc4 100644
--- a/gcc/ada/namet.adb
+++ b/gcc/ada/namet.adb
@@ -474,7 +474,11 @@ package body Namet is
 
 P := 1;
 while P < Temp.Length loop
-   if Temp.Chars (P + 1) in 'A' .. 'Z' then
+   --  Cheap test for the common case of no encoding
+
+   if Temp.Chars (P + 1) in 'A' .. 'Z'
+ and then Temp.Chars (P + 1) /= 'W'
+   then
   P := P + 1;
 
--  Uhh encoding


[gcc r15-4626] ada: Pass parameters of full access unconstrained array types by copy in calls

2024-10-25 Thread Marc Poulhi?s via Gcc-cvs
https://gcc.gnu.org/g:1c298fc41512a1062f348eb54d54d01697a66ffc

commit r15-4626-g1c298fc41512a1062f348eb54d54d01697a66ffc
Author: Eric Botcazou 
Date:   Thu Sep 12 16:11:47 2024 +0200

ada: Pass parameters of full access unconstrained array types by copy in 
calls

When a full access array type is declared, either Volatile_Full_Access in
Ada 2012 or Atomic in Ada 2022, an implicit base array type is built by the
compiler with the Full_Access flag set, although full accesses cannot be
generated for objects of this type because the size is not known statically.

If the component type is a record with default values, an initialization
procedure taking a parameter of the base array type is built. Given that
full accesses cannot be generated for the parameter inside the procedure,
we need to pass the actual parameter by copy to the procedure in order to
implement the full access semantics.

gcc/ada/ChangeLog:

* exp_ch6.adb (Expand_Actuals.Is_Legal_Copy): Return True for an
initialization procedure with a full access formal parameter.
(Expand_Actuals.Requires_Atomic_Or_Volatile_Copy): Return True if
the formal parameter is of a full access unconstrained array type.

Diff:
---
 gcc/ada/exp_ch6.adb | 27 ++-
 1 file changed, 22 insertions(+), 5 deletions(-)

diff --git a/gcc/ada/exp_ch6.adb b/gcc/ada/exp_ch6.adb
index c868234655ea..c550b1c8c1f0 100644
--- a/gcc/ada/exp_ch6.adb
+++ b/gcc/ada/exp_ch6.adb
@@ -1613,7 +1613,8 @@ package body Exp_Ch6 is
 
   function Requires_Atomic_Or_Volatile_Copy return Boolean;
   --  Returns whether a copy is required as per RM C.6(19) and gives a
-  --  warning in this case.
+  --  warning in this case. This also handles the special case of a base
+  --  array type with full access semantics.
 
   ---
   -- Add_Call_By_Copy_Code --
@@ -2269,15 +2270,22 @@ package body Exp_Ch6 is
 
   function Is_Legal_Copy return Boolean is
   begin
- --  An attempt to copy a value of such a type can only occur if
- --  representation clauses give the actual a misaligned address.
+ --  Calls to the initialization procedure of full access types may
+ --  require a copy in order to implement the full access semantics.
 
- if Is_By_Reference_Type (Etype (Formal))
+ if Is_Init_Proc (Subp) and then Is_Full_Access (Etype (Formal)) then
+return True;
+
+ --  In the other cases, a copy is not allowed for by-reference types
+ --  or if the parameter is aliased or explicitly passed by reference.
+
+ elsif Is_By_Reference_Type (Etype (Formal))
or else Is_Aliased (Formal)
or else (Mechanism (Formal) = By_Reference
  and then not Has_Foreign_Convention (Subp))
  then
-
+--  An attempt to copy a value of such types can only occur if
+--  representation clauses give the actual a misaligned address.
 --  The actual may in fact be properly aligned but there is not
 --  enough front-end information to determine this. In that case
 --  gigi will emit an error or a warning if a copy is not legal,
@@ -2386,6 +2394,15 @@ package body Exp_Ch6 is
 return True;
  end if;
 
+ --  Special case for the base type of a full access array type: full
+ --  access semantics cannot be enforced for the base type inside the
+ --  called subprogram so we do it at the call site by means of a copy.
+
+ if Ekind (E_Formal) = E_Array_Type and then Is_Full_Access (E_Formal)
+ then
+return True;
+ end if;
+
  return False;
   end Requires_Atomic_Or_Volatile_Copy;


[gcc r15-4628] ada: Forbid repr clauses for decls in handled_stmts

2024-10-25 Thread Marc Poulhi?s via Gcc-cvs
https://gcc.gnu.org/g:d1cb12a5b870daccfaf2b4d9c91646a00eb01aee

commit r15-4628-gd1cb12a5b870daccfaf2b4d9c91646a00eb01aee
Author: Raphaël AMIARD 
Date:   Tue Sep 10 11:10:21 2024 +0200

ada: Forbid repr clauses for decls in handled_stmts

gcc/ada/ChangeLog:

* par-ch5.adb (P_Sequence_Of_Statements): Forbid repr clauses in
handled_statements.

Diff:
---
 gcc/ada/par-ch5.adb | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/gcc/ada/par-ch5.adb b/gcc/ada/par-ch5.adb
index 557aaf1ff680..34c845f838cc 100644
--- a/gcc/ada/par-ch5.adb
+++ b/gcc/ada/par-ch5.adb
@@ -257,8 +257,7 @@ package body Ch5 is
   while Present (Decl) loop
  if not (Nkind (Decl) in
 N_Object_Declaration | N_Object_Renaming_Declaration |
-N_Use_Type_Clause | N_Use_Package_Clause |
-N_Representation_Clause)
+N_Use_Type_Clause | N_Use_Package_Clause)
  then
 Error_Msg
   ("Declaration kind not allowed in statements lists",


[gcc r15-4643] ada: Pragmas Pre_Class/Post_Class rejected for abstract subprograms

2024-10-25 Thread Marc Poulhi?s via Gcc-cvs
https://gcc.gnu.org/g:c2d4ca9c1de23ca08fb4b1e1fb5e266c6483090e

commit r15-4643-gc2d4ca9c1de23ca08fb4b1e1fb5e266c6483090e
Author: Javier Miranda 
Date:   Thu Sep 26 10:14:10 2024 +

ada: Pragmas Pre_Class/Post_Class rejected for abstract subprograms

The Pre_Class/Post_Class pragmas are rejected at compile time
for abstract subprograms.

gcc/ada/ChangeLog:

* sem_prag.adb (Analyze_Pre_Post_Condition): Allow the use of
pragma Pre_Class/Post_Class with abstract subprograms.

Diff:
---
 gcc/ada/sem_prag.adb | 18 +-
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/gcc/ada/sem_prag.adb b/gcc/ada/sem_prag.adb
index 90f9c72e7260..2165a1cbccc9 100644
--- a/gcc/ada/sem_prag.adb
+++ b/gcc/ada/sem_prag.adb
@@ -5228,17 +5228,17 @@ package body Sem_Prag is
Find_Related_Declaration_Or_Body
  (N, Do_Checks => not Duplicates_OK);
 
- --  When a pre/postcondition pragma applies to an abstract subprogram,
- --  its original form must be an aspect with 'Class.
+ --  Abstract subprogram
 
  if Nkind (Subp_Decl) = N_Abstract_Subprogram_Declaration then
-if not From_Aspect_Specification (N) then
-   Error_Pragma
- ("pragma % cannot be applied to abstract subprogram");
-
-elsif not Class_Present (N) then
-   Error_Pragma
- ("aspect % requires ''Class for abstract subprogram");
+if not Class_Present (N) then
+   if From_Aspect_Specification (N) then
+  Error_Pragma
+("aspect % requires ''Class for abstract subprogram");
+   else
+  Error_Pragma
+("pragma % cannot be applied to abstract subprogram");
+   end if;
 end if;
 
  --  Entry declaration


[gcc r15-4634] ada: Put Finalizable aspect in -gnatX

2024-10-25 Thread Marc Poulhi?s via Gcc-cvs
https://gcc.gnu.org/g:c2673f56cc13208ee401a4feda690a0e377d55c7

commit r15-4634-gc2673f56cc13208ee401a4feda690a0e377d55c7
Author: Raphaël AMIARD 
Date:   Fri Sep 13 15:30:03 2024 +0200

ada: Put Finalizable aspect in -gnatX

gcc/ada/ChangeLog:

* sem_ch13.adb (Analyze_One_Aspect): change the call to
`Error_Msg_GNAT_Extension` to allow this aspect in core
extensions. Put the code path in core extensions.
* exp_util.adb (Name_Of_Controlled_Prim_Op): Put the code path
in core extensions

Diff:
---
 gcc/ada/exp_util.adb | 2 +-
 gcc/ada/sem_ch13.adb | 5 +++--
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/gcc/ada/exp_util.adb b/gcc/ada/exp_util.adb
index 8b9ce9a2acc5..400d5d86fbaf 100644
--- a/gcc/ada/exp_util.adb
+++ b/gcc/ada/exp_util.adb
@@ -11574,7 +11574,7 @@ package body Exp_Util is
   --  The aspect Finalizable may change the name of the primitives when
   --  present, but it's a GNAT extension.
 
-  if All_Extensions_Allowed then
+  if Core_Extensions_Allowed then
  declare
 Rep : constant Node_Id :=
   Get_Rep_Item (Typ, Name_Finalizable, Check_Parents => True);
diff --git a/gcc/ada/sem_ch13.adb b/gcc/ada/sem_ch13.adb
index 953da67c9d37..11545771030e 100644
--- a/gcc/ada/sem_ch13.adb
+++ b/gcc/ada/sem_ch13.adb
@@ -4073,9 +4073,10 @@ package body Sem_Ch13 is
   end if;
 
when Aspect_Finalizable =>
-  if not All_Extensions_Allowed then
+  if not Core_Extensions_Allowed then
  Error_Msg_Name_1 := Nam;
- Error_Msg_GNAT_Extension ("aspect %", Loc);
+ Error_Msg_GNAT_Extension
+   ("aspect %", Loc, Is_Core_Extension => True);
  goto Continue;
 
   elsif not Is_Type (E) then


[gcc(refs/users/aoliva/heads/testme)] adjust update_profile_after_ifcombine for noncontiguous ifcombine

2024-10-25 Thread Alexandre Oliva via Gcc-cvs
https://gcc.gnu.org/g:b7de5a6fdd765f027cdbb727c7a1424013febffe

commit b7de5a6fdd765f027cdbb727c7a1424013febffe
Author: Alexandre Oliva 
Date:   Thu Oct 24 05:25:28 2024 -0300

adjust update_profile_after_ifcombine for noncontiguous ifcombine

Prepare for ifcombining noncontiguous blocks, adding (still unused)
logic to the ifcombine profile updater to handle such cases.


for  gcc/ChangeLog

* tree-ssa-ifcombine.cc (known_succ_p): New.
(update_profile_after_ifcombine): Handle noncontiguous blocks.

Diff:
---
 gcc/tree-ssa-ifcombine.cc | 109 --
 1 file changed, 85 insertions(+), 24 deletions(-)

diff --git a/gcc/tree-ssa-ifcombine.cc b/gcc/tree-ssa-ifcombine.cc
index 6dcf5e6efe1d..b5b72be29bbf 100644
--- a/gcc/tree-ssa-ifcombine.cc
+++ b/gcc/tree-ssa-ifcombine.cc
@@ -49,6 +49,21 @@ along with GCC; see the file COPYING3.  If not see
 false) >= 2)
 #endif
 
+/* Return FALSE iff the COND_BB ends with a conditional whose result is not a
+   known constant.  */
+
+static bool
+known_succ_p (basic_block cond_bb)
+{
+  gcond *cond = safe_dyn_cast  (*gsi_last_bb (cond_bb));
+
+  if (!cond)
+return true;
+
+  return (CONSTANT_CLASS_P (gimple_cond_lhs (cond))
+ && CONSTANT_CLASS_P (gimple_cond_rhs (cond)));
+}
+
 /* This pass combines COND_EXPRs to simplify control flow.  It
currently recognizes bit tests and comparisons in chains that
represent logical and or logical or of two COND_EXPRs.
@@ -356,14 +371,28 @@ recognize_bits_test (gcond *cond, tree *name, tree *bits, 
bool inv)
 }
 
 
-/* Update profile after code in outer_cond_bb was adjusted so
-   outer_cond_bb has no condition.  */
+/* Update profile after code in either outer_cond_bb or inner_cond_bb was
+   adjusted so that it has no condition.  */
 
 static void
 update_profile_after_ifcombine (basic_block inner_cond_bb,
basic_block outer_cond_bb)
 {
-  edge outer_to_inner = find_edge (outer_cond_bb, inner_cond_bb);
+  /* In the following we assume that inner_cond_bb has single predecessor.  */
+  gcc_assert (single_pred_p (inner_cond_bb));
+
+  basic_block outer_to_inner_bb = inner_cond_bb;
+  profile_probability prob = profile_probability::always ();
+  for (;;)
+{
+  basic_block parent = single_pred (outer_to_inner_bb);
+  prob *= find_edge (parent, outer_to_inner_bb)->probability;
+  if (parent == outer_cond_bb)
+   break;
+  outer_to_inner_bb = parent;
+}
+
+  edge outer_to_inner = find_edge (outer_cond_bb, outer_to_inner_bb);
   edge outer2 = (EDGE_SUCC (outer_cond_bb, 0) == outer_to_inner
 ? EDGE_SUCC (outer_cond_bb, 1)
 : EDGE_SUCC (outer_cond_bb, 0));
@@ -374,29 +403,61 @@ update_profile_after_ifcombine (basic_block inner_cond_bb,
 std::swap (inner_taken, inner_not_taken);
   gcc_assert (inner_taken->dest == outer2->dest);
 
-  /* In the following we assume that inner_cond_bb has single predecessor.  */
-  gcc_assert (single_pred_p (inner_cond_bb));
-
-  /* Path outer_cond_bb->(outer2) needs to be merged into path
- outer_cond_bb->(outer_to_inner)->inner_cond_bb->(inner_taken)
- and probability of inner_not_taken updated.  */
-
-  inner_cond_bb->count = outer_cond_bb->count;
+  if (outer_to_inner_bb == inner_cond_bb
+  && known_succ_p (outer_cond_bb))
+{
+  /* Path outer_cond_bb->(outer2) needs to be merged into path
+outer_cond_bb->(outer_to_inner)->inner_cond_bb->(inner_taken)
+and probability of inner_not_taken updated.  */
+
+  inner_cond_bb->count = outer_cond_bb->count;
+
+  /* Handle special case where inner_taken probability is always. In this
+case we know that the overall outcome will be always as well, but
+combining probabilities will be conservative because it does not know
+that outer2->probability is inverse of
+outer_to_inner->probability.  */
+  if (inner_taken->probability == profile_probability::always ())
+   ;
+  else
+   inner_taken->probability = outer2->probability
+ + outer_to_inner->probability * inner_taken->probability;
+  inner_not_taken->probability = profile_probability::always ()
+   - inner_taken->probability;
 
-  /* Handle special case where inner_taken probability is always. In this case
- we know that the overall outcome will be always as well, but combining
- probabilities will be conservative because it does not know that
- outer2->probability is inverse of outer_to_inner->probability.  */
-  if (inner_taken->probability == profile_probability::always ())
-;
+  outer_to_inner->probability = profile_probability::always ();
+  outer2->probability = profile_probability::never ();
+}
+  else if (known_succ_p (inner_cond_bb))
+{
+  /* Path inner_cond_bb->(inner_taken) needs to be merged into path
+outer_cond_bb->(outer2).  We've accumulated

[gcc r15-4645] ada: Fix ATC with timed delay from Ada.Real_Time

2024-10-25 Thread Marc Poulhi?s via Gcc-cvs
https://gcc.gnu.org/g:8af9169fcf792531ca7bbaac80d15123c7970f06

commit r15-4645-g8af9169fcf792531ca7bbaac80d15123c7970f06
Author: Eric Botcazou 
Date:   Fri Sep 27 09:36:17 2024 +0200

ada: Fix ATC with timed delay from Ada.Real_Time

An Asynchronous Transfer of Control blocks with a timed delay that is
computed by means of the Ada.Real_Time unit (instead of the default
Ada.Calendar unit) because of a missing abort deferral in the unit.

gcc/ada/ChangeLog:

PR ada/43485
* libgnarl/a-retide.adb: Add with clause for System.Soft_Links.
(Delay_Until): Defer and undefer abort around the call to the
Timed_Delay routine of System.Task_Primitives.Operations.

Diff:
---
 gcc/ada/libgnarl/a-retide.adb | 4 
 1 file changed, 4 insertions(+)

diff --git a/gcc/ada/libgnarl/a-retide.adb b/gcc/ada/libgnarl/a-retide.adb
index 80e3d31ed17d..d7cac0f2124f 100644
--- a/gcc/ada/libgnarl/a-retide.adb
+++ b/gcc/ada/libgnarl/a-retide.adb
@@ -31,11 +31,13 @@
 
 with Ada.Exceptions;
 
+with System.Soft_Links;
 with System.Tasking;
 with System.Task_Primitives.Operations;
 
 package body Ada.Real_Time.Delays is
 
+   package SSL  renames System.Soft_Links;
package STPO renames System.Task_Primitives.Operations;
 

@@ -62,7 +64,9 @@ package body Ada.Real_Time.Delays is
  Ada.Exceptions.Raise_Exception
(Program_Error'Identity, "potentially blocking operation");
   else
+ SSL.Abort_Defer.all;
  STPO.Timed_Delay (Self_Id, To_Duration (T), Absolute_RT);
+ SSL.Abort_Undefer.all;
   end if;
end Delay_Until;


[gcc r15-4644] ada: Fix internal error on function call in class-wide precondition

2024-10-25 Thread Marc Poulhi?s via Gcc-cvs
https://gcc.gnu.org/g:2e3d527fe37e2bf8cba74a42d78f2d99f3e7094a

commit r15-4644-g2e3d527fe37e2bf8cba74a42d78f2d99f3e7094a
Author: Eric Botcazou 
Date:   Fri Sep 27 12:19:14 2024 +0200

ada: Fix internal error on function call in class-wide precondition

This occurs when the call is to a function that is declared in a package
that is nested in the scope where the type declaration is located.

gcc/ada/ChangeLog:

* freeze.adb (Freeze_Expression.In_Expanded_Body): Also return True
for the body of a helper/wrapper built for class-wide preconditions.

Diff:
---
 gcc/ada/freeze.adb | 8 
 1 file changed, 8 insertions(+)

diff --git a/gcc/ada/freeze.adb b/gcc/ada/freeze.adb
index 882c026455ec..326b39b05458 100644
--- a/gcc/ada/freeze.adb
+++ b/gcc/ada/freeze.adb
@@ -8438,6 +8438,14 @@ package body Freeze is
  then
 return True;
 
+ --  This is the body of a helper/wrapper built for CW preconditions
+
+ elsif Present (Corresponding_Spec (P))
+   and then
+ Present (Class_Preconditions_Subprogram (Corresponding_Spec (P)))
+ then
+return True;
+
  else
 Id := Defining_Unit_Name (Specification (P));


[gcc r15-4669] Default expand_vec_cond_expr_p code to ERROR_MARK

2024-10-25 Thread Richard Biener via Gcc-cvs
https://gcc.gnu.org/g:35c3aac80e7a18c32436259143cba0f47bd0cb5a

commit r15-4669-g35c3aac80e7a18c32436259143cba0f47bd0cb5a
Author: Richard Biener 
Date:   Fri Oct 25 12:38:24 2024 +0200

Default expand_vec_cond_expr_p code to ERROR_MARK

As we want to transition to only vcond_mask expanders the following
makes it possible to easier distinguish queries that rely on
vcond queries for expand_vec_cond_expr_p from those of vcond_mask
by for the latter having the comparison code defaulted to ERROR_MARK.

* optabs-tree.h (expand_vec_cond_expr_p): Default the
comparison code to ERROR_MARK.
* match.pd: Remove unneded expand_vec_cond_expr_p args.
* tree-vect-generic.cc (expand_vector_condition): Likewise.
* tree-vect-loop.cc (vect_reduction_update_partial_vector_usage):
Likewise.
* tree-vect-stmts.cc (vectorizable_simd_clone_call): Likewise.
(scan_store_can_perm_p): Likewise.
(vectorizable_condition): Likewise.

Diff:
---
 gcc/match.pd | 17 +++--
 gcc/optabs-tree.h|  2 +-
 gcc/tree-vect-generic.cc |  2 +-
 gcc/tree-vect-loop.cc|  3 +--
 gcc/tree-vect-stmts.cc   |  7 +++
 5 files changed, 13 insertions(+), 18 deletions(-)

diff --git a/gcc/match.pd b/gcc/match.pd
index 93536a39348d..e622ccbd67c0 100644
--- a/gcc/match.pd
+++ b/gcc/match.pd
@@ -411,7 +411,7 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
tree ones = build_all_ones_cst (vec_cmp_type);
   }
   (if (expand_vec_cmp_expr_p (vec_cmp_type, vec_truth_type, LT_EXPR)
-  && expand_vec_cond_expr_p (vec_cmp_type, vec_truth_type, LT_EXPR))
+  && expand_vec_cond_expr_p (vec_cmp_type, vec_truth_type))
(view_convert:type (vec_cond (lt:vec_truth_type
 (view_convert:vec_cmp_type @0)
 { zeros; })
@@ -5805,13 +5805,12 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
   (if (VECTOR_TYPE_P (type)
&& (TREE_CODE_CLASS (op) != tcc_comparison
   || types_match (type, TREE_TYPE (@1))
-  || expand_vec_cond_expr_p (type, TREE_TYPE (@0), ERROR_MARK)
+  || expand_vec_cond_expr_p (type, TREE_TYPE (@0))
   || (optimize_vectors_before_lowering_p ()
   /* The following is optimistic on the side of non-support, we are
  missing the legacy vcond{,u,eq} cases.  Do this only when
  lowering will be able to fixup..  */
-  && !expand_vec_cond_expr_p (TREE_TYPE (@1),
-  TREE_TYPE (@0), ERROR_MARK
+  && !expand_vec_cond_expr_p (TREE_TYPE (@1), TREE_TYPE (@0)
(vec_cond @0 (op! @1 @3) (op! @2 @4
 
 /* (c ? a : b) op d  -->  c ? (a op d) : (b op d) */
@@ -5820,20 +5819,18 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
   (if (VECTOR_TYPE_P (type)
&& (TREE_CODE_CLASS (op) != tcc_comparison
   || types_match (type, TREE_TYPE (@1))
-  || expand_vec_cond_expr_p (type, TREE_TYPE (@0), ERROR_MARK)
+  || expand_vec_cond_expr_p (type, TREE_TYPE (@0))
   || (optimize_vectors_before_lowering_p ()
-  && !expand_vec_cond_expr_p (TREE_TYPE (@1),
-  TREE_TYPE (@0), ERROR_MARK
+  && !expand_vec_cond_expr_p (TREE_TYPE (@1), TREE_TYPE (@0)
(vec_cond @0 (op! @1 @3) (op! @2 @3
  (simplify
   (op @3 (vec_cond:s @0 @1 @2))
   (if (VECTOR_TYPE_P (type)
&& (TREE_CODE_CLASS (op) != tcc_comparison
   || types_match (type, TREE_TYPE (@1))
-  || expand_vec_cond_expr_p (type, TREE_TYPE (@0), ERROR_MARK)
+  || expand_vec_cond_expr_p (type, TREE_TYPE (@0))
   || (optimize_vectors_before_lowering_p ()
-  && !expand_vec_cond_expr_p (TREE_TYPE (@1),
-  TREE_TYPE (@0), ERROR_MARK
+  && !expand_vec_cond_expr_p (TREE_TYPE (@1), TREE_TYPE (@0)
(vec_cond @0 (op! @3 @1) (op! @3 @2)
 
 #if GIMPLE
diff --git a/gcc/optabs-tree.h b/gcc/optabs-tree.h
index f2b49991462d..85805fd8296a 100644
--- a/gcc/optabs-tree.h
+++ b/gcc/optabs-tree.h
@@ -43,7 +43,7 @@ supportable_half_widening_operation (enum tree_code, tree, 
tree,
 bool supportable_convert_operation (enum tree_code, tree, tree,
enum tree_code *);
 bool expand_vec_cmp_expr_p (tree, tree, enum tree_code);
-bool expand_vec_cond_expr_p (tree, tree, enum tree_code);
+bool expand_vec_cond_expr_p (tree, tree, enum tree_code = ERROR_MARK);
 void init_tree_optimization_optabs (tree);
 bool target_supports_op_p (tree, enum tree_code,
   enum optab_subtype = optab_default);
diff --git a/gcc/tree-vect-generic.cc b/gcc/tree-vect-generic.cc
index f6f52569f433..ef7d2dd259da 100644
--- a/gcc/tree-vect-generic.cc
+++ b/gcc/tree-vect-generic.cc
@@ -1051,7 +1051,7 @@ expand_vector_condition 

[gcc r15-4650] ada: Disable self-referential with_clauses

2024-10-25 Thread Marc Poulhi?s via Gcc-cvs
https://gcc.gnu.org/g:58e34ecbe57586ebc3111e938ebcaa35b188f939

commit r15-4650-g58e34ecbe57586ebc3111e938ebcaa35b188f939
Author: Bob Duff 
Date:   Tue Oct 1 11:29:34 2024 -0400

ada: Disable self-referential with_clauses

Self-referential with_clauses (as in package body X says "with X;")
cause trouble, such as duplicate nested instantiations when using
container packages. This patch disables most of the processing by
setting the Is_Implicit_With flag. It's not really implicit, but the
subsequent processing behaves as if it is, and coming up with a more
accurate (and much longer) name for the flag doesn't seem beneficial for
such an obscure case. Note that the spec of X will be processed later,
rather than upon seeing "with X;".

Other cleanups, such as renaming Implicit_With to be Is_Implicit_With.

gcc/ada/ChangeLog:

* sem_ch10.adb: (Analyze_With_Clause): Check for self-referential
with clause. Give a warning, and set Is_Implicit_With, which we
are reusing in this obscure case even though it's not really
implicit.
(Analyze_Context): Remove check for self-referential with clause.
It wasn't correct -- it only triggered for Acts_As_Spec
subprograms. Corrected check is now in Analyze_With_Clause.
(Implicit_With): Rename to be Is_Implicit_With. Misc cleanup,
comment fixes.
(Process_Spec_Clauses): Remove default for Exit_On_Self parameter.
Use "exit when" instead of if statement.
* sinfo.ads (Implicit_With): Rename to be Is_Implicit_With.
Document new use for self-referential withs.
* ali.adb (Scan_ALI): Use an aggregate to initialize Withs entry.
* exp_put_image.adb (Preload_Root_Buffer_Type): Make this a
once-only procedure.
* sem_util.ads (Is_Ancestor_Package): Fix comment -- a libraryunit
is an ancestor of itself, but this doesn't return True in that
case.
* sem_util.adb (Is_Ancestor_Package): Better to initialize things
on their declaration.
* lib-load.adb: Minor comment fix.
* sem_prag.adb: Implicit_With --> Is_Implicit_With. Minor comment
fix.
* gen_il-fields.ads: Implicit_With --> Is_Implicit_With.
* gen_il-gen-gen_nodes.adb: Likewise
* lib.adb: Likewise
* lib-writ.adb: Likewise
* rtsfind.adb: Likewise
* sem_cat.adb: Likewise
* sem_ch12.adb: Likewise
* sem_ch8.adb: Likewise
* sem_elab.adb: Likewise
* sem_warn.adb: Likewise
* gcc-interface/trans.cc: (Implicit_With): Rename to be
Is_Implicit_With.

Diff:
---
 gcc/ada/ali.adb  |  32 +-
 gcc/ada/exp_put_image.adb|  36 +---
 gcc/ada/gcc-interface/trans.cc   |   4 +-
 gcc/ada/gen_il-fields.ads|   2 +-
 gcc/ada/gen_il-gen-gen_nodes.adb |   2 +-
 gcc/ada/lib-load.adb |   2 +-
 gcc/ada/lib-writ.adb |   2 +-
 gcc/ada/lib.adb  |   2 +-
 gcc/ada/rtsfind.adb  |  10 ++--
 gcc/ada/sem_cat.adb  |   2 +-
 gcc/ada/sem_ch10.adb | 124 ---
 gcc/ada/sem_ch12.adb |   2 +-
 gcc/ada/sem_ch8.adb  |   2 +-
 gcc/ada/sem_elab.adb |   8 +--
 gcc/ada/sem_prag.adb |   6 +-
 gcc/ada/sem_util.adb |   4 +-
 gcc/ada/sem_util.ads |   2 +-
 gcc/ada/sem_warn.adb |   2 +-
 gcc/ada/sinfo.ads|  40 +++--
 19 files changed, 152 insertions(+), 132 deletions(-)

diff --git a/gcc/ada/ali.adb b/gcc/ada/ali.adb
index bde73b9810b2..376c710fc50c 100644
--- a/gcc/ada/ali.adb
+++ b/gcc/ada/ali.adb
@@ -2942,24 +2942,22 @@ package body ALI is
Checkc (' ');
Skip_Space;
Withs.Increment_Last;
-   Withs.Table (Withs.Last).Uname  := Get_Unit_Name;
-   Withs.Table (Withs.Last).Elaborate  := False;
-   Withs.Table (Withs.Last).Elaborate_All  := False;
-   Withs.Table (Withs.Last).Elab_Desirable := False;
-   Withs.Table (Withs.Last).Elab_All_Desirable := False;
-   Withs.Table (Withs.Last).SAL_Interface  := False;
-   Withs.Table (Withs.Last).Limited_With   := (C = 'Y');
-   Withs.Table (Withs.Last).Implicit_With  := (C = 'Z');
+   Withs.Table (Withs.Last) :=
+ (Uname  => Get_Unit_Name,
+  Sfile  => No_File,
+  Afile  => No_File,
+  Elaborate  => False,
+  Elaborate_All  => False,
+  Elab_Desirable => False,
+  E

[gcc r15-4667] Add regression test

2024-10-25 Thread Eric Botcazou via Gcc-cvs
https://gcc.gnu.org/g:4d72cfaadf3946b46b7472066f3c2f937d0f52f3

commit r15-4667-g4d72cfaadf3946b46b7472066f3c2f937d0f52f3
Author: Eric Botcazou 
Date:   Fri Oct 25 13:14:22 2024 +0200

Add regression test

gcc/testsuite
PR ada/116551
* gnat.dg/specs/vfa3.ads: New test.

Diff:
---
 gcc/testsuite/gnat.dg/specs/vfa3.ads | 25 +
 1 file changed, 25 insertions(+)

diff --git a/gcc/testsuite/gnat.dg/specs/vfa3.ads 
b/gcc/testsuite/gnat.dg/specs/vfa3.ads
new file mode 100644
index ..200e294e140f
--- /dev/null
+++ b/gcc/testsuite/gnat.dg/specs/vfa3.ads
@@ -0,0 +1,25 @@
+-- { dg-do compile }
+
+package VFA3 is
+
+   type Bit is mod 2**1
+ with Size => 1;
+
+   type Intr_Level_Field is record
+  Level_Low  : Bit := 0;
+  Level_High : Bit := 0;
+  Edge_Low   : Bit := 0;
+  Edge_High  : Bit := 0;
+   end record with Pack, Size => 4;
+   for Intr_Level_Field use record
+  Level_Low  at 0 range 0 .. 0;
+  Level_High at 0 range 1 .. 1;
+  Edge_Low   at 0 range 2 .. 2;
+  Edge_High  at 0 range 3 .. 3;
+   end record;
+
+   type Intr_Level_Cluster is array (0 .. 7) of Intr_Level_Field
+ with Volatile_Full_Access, Pack, Object_Size => 32;
+   --  There are 8 Fields in a 32-bit word.
+
+end VFA3;


[gcc r14-10836] ada: Fix internal error on bit-packed array type with Volatile_Full_Access

2024-10-25 Thread Eric Botcazou via Gcc-cvs
https://gcc.gnu.org/g:d587da263188eb81741e432de70bccf8c53c3d97

commit r14-10836-gd587da263188eb81741e432de70bccf8c53c3d97
Author: Eric Botcazou 
Date:   Wed Sep 11 19:53:12 2024 +0200

ada: Fix internal error on bit-packed array type with Volatile_Full_Access

The problem occurs when the component type is a record type with default
values for the initialization procedure of the (base) array type, because
the compiler is trying to generate a full access for a parameter of the
base array type, which does not make sense.

gcc/ada/ChangeLog:

PR ada/116551
* gcc-interface/trans.cc (node_is_atomic) : Return
false if the type of the entity is an unconstrained array type.
(node_is_volatile_full_access) : Likewise.

Diff:
---
 gcc/ada/gcc-interface/trans.cc | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/gcc/ada/gcc-interface/trans.cc b/gcc/ada/gcc-interface/trans.cc
index 8c7ffbf56877..86183e2ba3dd 100644
--- a/gcc/ada/gcc-interface/trans.cc
+++ b/gcc/ada/gcc-interface/trans.cc
@@ -4230,7 +4230,10 @@ node_is_atomic (Node_Id gnat_node)
   if (!Is_Object (gnat_entity))
break;
   return Is_Atomic (gnat_entity)
+/* Disregard the flag on unconstrained arrays or simple constants
+   since we cannot or need not generate an atomic access.  */
 || (Is_Atomic (Etype (gnat_entity))
+&& Ekind (Etype (gnat_entity)) != E_Array_Type
 && !simple_constant_p (gnat_entity));
 
 case N_Selected_Component:
@@ -4270,7 +4273,10 @@ node_is_volatile_full_access (Node_Id gnat_node)
   if (!Is_Object (gnat_entity))
break;
   return Is_Volatile_Full_Access (gnat_entity)
+/* Disregard the flag on unconstrained arrays or simple constants
+   since we cannot or need not generate a full access.  */
 || (Is_Volatile_Full_Access (Etype (gnat_entity))
+&& Ekind (Etype (gnat_entity)) != E_Array_Type
 && !simple_constant_p (gnat_entity));
 
 case N_Selected_Component:


[gcc r15-4671] Assorted --disable-checking fixes [PR117249]

2024-10-25 Thread Jakub Jelinek via Gcc-cvs
https://gcc.gnu.org/g:e2a8772c9328960c625f5b95091d4312efa0e284

commit r15-4671-ge2a8772c9328960c625f5b95091d4312efa0e284
Author: Jakub Jelinek 
Date:   Fri Oct 25 14:09:42 2024 +0200

Assorted --disable-checking fixes [PR117249]

We have currently 3 different definitions of gcc_assert macro, one used most
of the time (unless --disable-checking) which evaluates the condition at
runtime and also checks it at runtime, then one for --disable-checking GCC 
4.5+
which looks like
((void)(UNLIKELY (!(EXPR)) ? __builtin_unreachable (), 0 : 0))
and a fallback one
((void)(0 && (EXPR)))
Now, the last one actually doesn't evaluate any of the side-effects in the
argument, just quiets up unused var/parameter warnings.
I've tried to replace the middle definition with
({ [[assume (EXPR)]]; (void) 0; })
for compilers which support assume attribute and statement expressions
(surprisingly quite a few spots use gcc_assert inside of comma expressions),
but ran into PR117287, so for now such a change isn't being proposed.

The following patch attempts to move important side-effects from gcc_assert
arguments.

Bootstrapped/regtested on x86_64-linux and i686-linux with normal
--enable-checking=yes,rtl,extra, plus additionally I've attempted to do
x86_64-linux bootstrap with --disable-checking and gcc_assert changed to the
((void)(0 && (EXPR)))
version when --disable-checking.  That version ran into spurious middle-end
warnings
../../gcc/../include/libiberty.h:733:36: error: argument to ‘alloca’ is too 
large [-Werror=alloca-larger-than=]
../../gcc/tree-ssa-reassoc.cc:5659:20: note: in expansion of macro 
‘XALLOCAVEC’
  int op_num = ops.length ();
  int op_normal_num = op_num;
  gcc_assert (op_num > 0);
  int stmt_num = op_num - 1;
  gimple **stmts = XALLOCAVEC (gimple *, stmt_num);
where we have gcc_assert exactly to work-around middle-end warnings.
Guess I'd need to also disable -Werror for this experiment, which actually
isn't a problem with unmodified system.h, because even for
--disable-checking we use the __builtin_unreachable at least in
stage2/stage3 and so the warnings aren't emitted, and even if it used
[[assume ()]]; it would work too because in stage2/stage3 we could again
rely on assume and statement expression support.

2024-10-25  Jakub Jelinek  

PR middle-end/117249
* tree-ssa-structalias.cc (insert_vi_for_tree): Move put calls out 
of
gcc_assert.
* lto-cgraph.cc (lto_symtab_encoder_delete_node): Likewise.
* gimple-ssa-strength-reduction.cc (get_alternative_base,
add_cand_for_stmt): Likewise.
* tree-eh.cc (add_stmt_to_eh_lp_fn): Likewise.
* except.cc (duplicate_eh_regions_1): Likewise.
* tree-ssa-reassoc.cc (insert_operand_rank): Likewise.
* config/nvptx/nvptx.cc (nvptx_expand_call): Use == rather than = in
gcc_assert.
* opts-common.cc (jobserver_info::disconnect): Call close outside of
gcc_assert and only check result in it.
(jobserver_info::return_token): Call write outside of gcc_assert and
only check result in it.
* genautomata.cc (output_default_latencies): Move j++ side-effect
outside of gcc_assert.
* tree-ssa-loop-ivopts.cc (get_alias_ptr_type_for_ptr_address): Use
== rather than = in gcc_assert.
* cgraph.cc (symbol_table::create_edge): Move ++edges_max_uid
side-effect outside of gcc_assert.

Diff:
---
 gcc/cgraph.cc| 3 ++-
 gcc/config/nvptx/nvptx.cc| 2 +-
 gcc/except.cc| 6 --
 gcc/genautomata.cc   | 3 ++-
 gcc/gimple-ssa-strength-reduction.cc | 6 --
 gcc/lto-cgraph.cc| 3 ++-
 gcc/opts-common.cc   | 6 --
 gcc/tree-eh.cc   | 3 ++-
 gcc/tree-ssa-loop-ivopts.cc  | 2 +-
 gcc/tree-ssa-reassoc.cc  | 3 ++-
 gcc/tree-ssa-structalias.cc  | 3 ++-
 11 files changed, 26 insertions(+), 14 deletions(-)

diff --git a/gcc/cgraph.cc b/gcc/cgraph.cc
index 93628ef7f264..d4c35341ab58 100644
--- a/gcc/cgraph.cc
+++ b/gcc/cgraph.cc
@@ -895,7 +895,8 @@ symbol_table::create_edge (cgraph_node *caller, cgraph_node 
*callee,
   edge->m_summary_id = -1;
   edges_count++;
 
-  gcc_assert (++edges_max_uid != 0);
+  ++edges_max_uid;
+  gcc_assert (edges_max_uid != 0);
   edge->m_uid = edges_max_uid;
   edge->aux = NULL;
   edge->caller = caller;
diff --git a/gcc/config/nvptx/nvptx.cc b/gcc/config/nvptx/nvptx.cc
index 883bab67fff1..3072d3729a89 100644
--- a/gcc/config/nvptx/nvptx.cc
+++ b/gcc/config/nvptx/nvptx.cc
@@ -1902,7 +1902,7 @@ nvptx_expand_call (rtx retval, rtx address)
   if (varargs)
 XVECEXP (pat, 0, vec_pos++) = gen_rtx_USE (VOIDmode, va

[gcc r15-4678] AArch64: Add more accurate constraint [PR117292]

2024-10-25 Thread Wilco Dijkstra via Gcc-cvs
https://gcc.gnu.org/g:7c17058eac3834fb03ec9e518235e4192557b97d

commit r15-4678-g7c17058eac3834fb03ec9e518235e4192557b97d
Author: Wilco Dijkstra 
Date:   Fri Oct 25 14:53:58 2024 +

AArch64: Add more accurate constraint [PR117292]

As shown in the PR, reload may only check the constraint in some cases and
and not check the predicate is still valid for the resulting instruction.
To fix the issue, add a new constraint which matches the predicate exactly.

gcc/ChangeLog:
PR target/117292
* config/aarch64/aarch64-simd.md (xor3): Use
'De' constraint.
* config/aarch64/constraints.md (De): Add new constraint.

gcc/testsuite/ChangeLog:
PR target/117292
* gcc.target/aarch64/sve/single_5.c: Remove xfails.
* gcc.target/aarch64/pr117292.c: New test.

Diff:
---
 gcc/config/aarch64/aarch64-simd.md  |  2 +-
 gcc/config/aarch64/constraints.md   |  6 
 gcc/testsuite/gcc.target/aarch64/pr117292.c | 41 +
 gcc/testsuite/gcc.target/aarch64/sve/single_5.c |  4 +--
 4 files changed, 50 insertions(+), 3 deletions(-)

diff --git a/gcc/config/aarch64/aarch64-simd.md 
b/gcc/config/aarch64/aarch64-simd.md
index 68839246fd8a..e456f693d2f3 100644
--- a/gcc/config/aarch64/aarch64-simd.md
+++ b/gcc/config/aarch64/aarch64-simd.md
@@ -1151,7 +1151,7 @@
   "TARGET_SIMD"
   {@ [ cons: =0 , 1 , 2  ]
  [ w, w , w  ] eor\t%0., %1., %2.
- [ w, 0 , Do ] << aarch64_output_simd_xor_imm (operands[2], 
);
+ [ w, 0 , De ] << aarch64_output_simd_xor_imm (operands[2], 
);
   }
   [(set_attr "type" "neon_logic")]
 )
diff --git a/gcc/config/aarch64/constraints.md 
b/gcc/config/aarch64/constraints.md
index 3f9fd92a1911..647941c3c5a3 100644
--- a/gcc/config/aarch64/constraints.md
+++ b/gcc/config/aarch64/constraints.md
@@ -472,6 +472,12 @@
  (and (match_code "const_vector")
   (match_test "aarch64_simd_valid_and_imm (op)")))
 
+(define_constraint "De"
+  "@internal
+   A constraint that matches vector of immediates for xor."
+ (and (match_code "const_vector")
+  (match_test "aarch64_simd_valid_xor_imm (op)")))
+
 (define_constraint "Dn"
   "@internal
  A constraint that matches vector of immediates."
diff --git a/gcc/testsuite/gcc.target/aarch64/pr117292.c 
b/gcc/testsuite/gcc.target/aarch64/pr117292.c
new file mode 100644
index ..86816266c681
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/pr117292.c
@@ -0,0 +1,41 @@
+/* { dg-do compile } */
+/* { dg-options "-Os" } */
+
+#pragma GCC target "+nosve"
+
+typedef char v8u8;
+typedef __attribute__((__vector_size__ (2))) char v16u8;
+typedef __attribute__((__vector_size__ (4))) char v32u8;
+typedef __attribute__((__vector_size__ (8))) char v64u8;
+typedef short v128u8;
+typedef __attribute__((__vector_size__ (32))) char v256u8;
+typedef __attribute__((__vector_size__ (64))) char v512u8;
+v16u8 foo0_v16s16_0;
+__attribute__((__vector_size__ (16))) int foo0_v512u32_0;
+v8u8 foo0_ret;
+
+static __attribute__((__noinline__)) __attribute__((__noclone__)) void
+foo0 (signed char s8_0, v512u8 v512u16_0, v512u8 v512s16_0,
+v512u8 v512s32_0, v512u8 v512u64_0, v512u8 v512s64_0,
+v512u8 v512u128_0, v512u8 v512s128_0)
+{
+  char v8s8_0;
+  v8s8_0 ^= s8_0;
+  foo0_v512u32_0 /= foo0_v512u32_0 ^ s8_0;
+  v512u8 v512u8_r = v512u16_0 + v512s16_0 + v512s32_0 +
+v512u64_0 + v512s64_0 + v512u128_0 + v512s128_0;
+  v16u8 v16u8_r = ((union { v64u8 a; v16u8 b;})
+ ((union { v128u8 a; v64u8 b;})
+ ((union { v256u8 a; v128u8 b;})
+ ((union { v512u8 a; v256u8 b;})  v512u8_r).b).b).b).b +
+foo0_v16s16_0;
+  v8u8 v8u8_r = ((union { v16u8 a; v8u8 b;}) v16u8_r).b + v8s8_0;
+  foo0_ret = v8u8_r;
+}
+
+void
+main ()
+{
+  foo0 (3, (v512u8){}, (v512u8){}, (v512u8){}, (v512u8){},
+(v512u8){}, (v512u8){}, (v512u8){});
+}
diff --git a/gcc/testsuite/gcc.target/aarch64/sve/single_5.c 
b/gcc/testsuite/gcc.target/aarch64/sve/single_5.c
index 233118bbb383..ac81194733f0 100644
--- a/gcc/testsuite/gcc.target/aarch64/sve/single_5.c
+++ b/gcc/testsuite/gcc.target/aarch64/sve/single_5.c
@@ -11,8 +11,8 @@
 /* { dg-final { scan-assembler-times {\tmovi\tv[0-9]+\.8h, 0x4\n} 1 } } */
 /* { dg-final { scan-assembler-times {\tmovi\tv[0-9]+\.4s, 0x5\n} 1 } } */
 /* { dg-final { scan-assembler-times {\tmovi\tv[0-9]+\.4s, 0x6\n} 1 } } */
-/* { dg-final { scan-assembler-times {\tmov\tz[0-9]+\.d, #7\n} 1 { xfail *-*-* 
} } } */
-/* { dg-final { scan-assembler-times {\tmov\tz[0-9]+\.d, #8\n} 1 { xfail *-*-* 
} } } */
+/* { dg-final { scan-assembler-times {\tmov\tz[0-9]+\.d, #7\n} 1 } } */
+/* { dg-final { scan-assembler-times {\tmov\tz[0-9]+\.d, #8\n} 1 } } */
 /* { dg-final { scan-assembler-times {\tfmov\tv[0-9]+\.8h, 1\.0e\+0\n} 1 } } */
 /* { dg-final { scan-assembler-times {\tfmov\tv[0-9]+\.4s, 2\.0e\+0\n} 1 } } */
 /* { dg-final { scan-assem

[gcc r15-4680] toplevel: Error out if using --disable-libstdcxx with bootstrap [PR105474]

2024-10-25 Thread Andrew Pinski via Gcc-cvs
https://gcc.gnu.org/g:48b22a3f05df203c40a6f953aaa0acf828aad9a9

commit r15-4680-g48b22a3f05df203c40a6f953aaa0acf828aad9a9
Author: Andrew Pinski 
Date:   Thu Aug 22 14:34:03 2024 -0700

toplevel: Error out if using --disable-libstdcxx with bootstrap [PR105474]

Bootstrapping and using --disable-libstdcxx will cause a build failure deep 
in compiling
stage2 so instead error out early in the toplevel configure so it is more 
user friendly.

Bootstrapped and tested on x86_64-linux-gnu.
Also made sure --disable-libstdcxx without --disable-bootstrap failed.

PR bootstrap/105474

ChangeLog:

* configure: Regenerate.
* configure.ac: Error out if libstdc++ is not enabled
with bootstrapping.

Signed-off-by: Andrew Pinski 

Diff:
---
 configure| 9 +
 configure.ac | 9 +
 2 files changed, 18 insertions(+)

diff --git a/configure b/configure
index 6a77d454fd53..41bc0d356341 100755
--- a/configure
+++ b/configure
@@ -10236,6 +10236,15 @@ case "$enable_bootstrap:$ENABLE_GOLD: $configdirs 
:,$stage1_languages," in
 ;;
 esac
 
+# Bootstrapping GCC requires libstdc++-v3 so error out if libstdc++ is 
disabled with bootstrapping
+# Note C++ is always enabled for stage1 now.
+case "$enable_bootstrap:${noconfigdirs}" in
+  yes:*target-libstdc++-v3*)
+as_fn_error $? "bootstrapping with --disable-libstdcxx is not supported" 
"$LINENO" 5
+;;
+esac
+
+
 extrasub_build=
 for module in ${build_configdirs} ; do
   if test -z "${no_recursion}" \
diff --git a/configure.ac b/configure.ac
index 2567757e74df..1cab846ab1f5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3192,6 +3192,15 @@ case "$enable_bootstrap:$ENABLE_GOLD: $configdirs 
:,$stage1_languages," in
 ;;
 esac
 
+# Bootstrapping GCC requires libstdc++-v3 so error out if libstdc++ is 
disabled with bootstrapping
+# Note C++ is always enabled for stage1 now.
+case "$enable_bootstrap:${noconfigdirs}" in
+  yes:*target-libstdc++-v3*)
+AC_MSG_ERROR([bootstrapping with --disable-libstdcxx is not supported])
+;;
+esac
+
+
 extrasub_build=
 for module in ${build_configdirs} ; do
   if test -z "${no_recursion}" \


[gcc r15-4689] simplify-rtx: Handle `a != 0 ? -a : 0` [PR58195]

2024-10-25 Thread Andrew Pinski via Gcc-cvs
https://gcc.gnu.org/g:35bf490452e06b3e3567933342fb15ef5d11f503

commit r15-4689-g35bf490452e06b3e3567933342fb15ef5d11f503
Author: Andrew Pinski 
Date:   Sun Oct 20 10:44:14 2024 -0700

simplify-rtx: Handle `a != 0 ? -a : 0` [PR58195]

The gimple (and generic) levels have this optmization since 
r12-2041-g7d6979197274a662da7bdc5.
It seems like a good idea to add a similar one to rtl just in case it is 
not caught at the
gimple level.

Note the loop case in csel-neg-1.c is not handled at the gimple level (even 
with phiopt turned back on),
this is because of casts to avoid signed integer overflow; a patch to fix 
this at the gimple level will be
submitted seperately.

Changes since v1:
* v2: Use `CONST0_RTX (mode)` instead of const0_rtx. Add csel-neg-2.c for 
float testcase which now passes.

Build and tested for aarch64-linux-gnu.

PR rtl-optimization/58195

gcc/ChangeLog:

* simplify-rtx.cc (simplify_context::simplify_ternary_operation): 
Handle
`a != 0 ? -a : 0` and `a == 0 ? 0 : -a`.

gcc/testsuite/ChangeLog:

* gcc.target/aarch64/csel-neg-1.c: New test.
* gcc.target/aarch64/csel-neg-2.c: New test.

Signed-off-by: Andrew Pinski 

Diff:
---
 gcc/simplify-rtx.cc   | 22 +++
 gcc/testsuite/gcc.target/aarch64/csel-neg-1.c | 31 +++
 gcc/testsuite/gcc.target/aarch64/csel-neg-2.c | 19 
 3 files changed, 72 insertions(+)

diff --git a/gcc/simplify-rtx.cc b/gcc/simplify-rtx.cc
index e9591680f7c9..2c04ce960ee4 100644
--- a/gcc/simplify-rtx.cc
+++ b/gcc/simplify-rtx.cc
@@ -6909,6 +6909,28 @@ simplify_context::simplify_ternary_operation (rtx_code 
code, machine_mode mode,
  && rtx_equal_p (XEXP (op0, 1), op1
return op2;
 
+  /* Convert a != 0 ? -a : 0 into "-a".  */
+  if (GET_CODE (op0) == NE
+ && ! side_effects_p (op0)
+ && ! HONOR_NANS (mode)
+ && ! HONOR_SIGNED_ZEROS (mode)
+ && XEXP (op0, 1) == CONST0_RTX (mode)
+ && op2 == CONST0_RTX (mode)
+ && GET_CODE (op1) == NEG
+ && rtx_equal_p (XEXP (op0, 0), XEXP (op1, 0)))
+   return op1;
+
+  /* Convert a == 0 ? 0 : -a into "-a".  */
+  if (GET_CODE (op0) == EQ
+ && ! side_effects_p (op0)
+ && ! HONOR_NANS (mode)
+ && ! HONOR_SIGNED_ZEROS (mode)
+ && op1 == CONST0_RTX (mode)
+ && XEXP (op0, 1) == CONST0_RTX (mode)
+ && GET_CODE (op2) == NEG
+ && rtx_equal_p (XEXP (op0, 0), XEXP (op2, 0)))
+   return op2;
+
   /* Convert (!c) != {0,...,0} ? a : b into
  c != {0,...,0} ? b : a for vector modes.  */
   if (VECTOR_MODE_P (GET_MODE (op1))
diff --git a/gcc/testsuite/gcc.target/aarch64/csel-neg-1.c 
b/gcc/testsuite/gcc.target/aarch64/csel-neg-1.c
new file mode 100644
index ..7551965bccab
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/csel-neg-1.c
@@ -0,0 +1,31 @@
+/* { dg-do compile } */
+/* Disable phiopt as that will optimize away the `?:`,
+   want to test simplify-rtx */
+/* { dg-options "-O2 -fno-ssa-phiopt" } */
+
+/* PR rtl-optimization/58195 */
+
+int a2(int input)
+{
+  if (input == 0)
+return 0;
+  return -input;
+}
+int a1(int input)
+{
+int t = -input;
+return input == 0 ? 0 : t;
+}
+
+int a(int input)
+{
+int value = 0;
+for(int n = input; n != 0; ++n)
+++value;
+return value;
+}
+
+/* There should be no comparison against 0 here,  */
+/* { dg-final { scan-assembler-not "cmp\t" } } */
+/* { dg-final { scan-assembler "\tneg\t" } } */
+
diff --git a/gcc/testsuite/gcc.target/aarch64/csel-neg-2.c 
b/gcc/testsuite/gcc.target/aarch64/csel-neg-2.c
new file mode 100644
index ..72fe9b7d03f0
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/csel-neg-2.c
@@ -0,0 +1,19 @@
+/* { dg-do compile } */
+/* Disable phiopt as that will optimize away the `?:`,
+   want to test simplify-rtx */
+/* { dg-options "-O2 -ffast-math -fno-ssa-phiopt" } */
+
+/* PR rtl-optimization/58195 */
+
+float a2(float input)
+{
+  if (input == 0)
+return 0;
+  return -input;
+}
+
+/* There should be no comparison against 0 here,  */
+/* { dg-final { scan-assembler-not "\tfcmp\t" } } */
+/* { dg-final { scan-assembler-not "\tfcsel\t" } } */
+/* { dg-final { scan-assembler "\tfneg\t" } } */
+


[gcc r15-4690] libbacktrace: recognize new Mach-O DWARF sections

2024-10-25 Thread Ian Lance Taylor via Gcc-cvs
https://gcc.gnu.org/g:bab7a64c1ab95db3d651025ddb84f74c2b973bab

commit r15-4690-gbab7a64c1ab95db3d651025ddb84f74c2b973bab
Author: Ian Lance Taylor 
Date:   Fri Oct 25 15:17:15 2024 -0700

libbacktrace: recognize new Mach-O DWARF sections

Patch from Pavel Safonov.

These sections are used on macOS Sequoia.

Fixes https://github.com/ianlancetaylor/libbacktrace/issues/136

* macho.c (dwarf_section_names): Add __debug_addr and
__debug_line_str.

Diff:
---
 libbacktrace/macho.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libbacktrace/macho.c b/libbacktrace/macho.c
index fc4c9591dfa3..9f8738dd7844 100644
--- a/libbacktrace/macho.c
+++ b/libbacktrace/macho.c
@@ -306,9 +306,9 @@ static const char * const dwarf_section_names[DEBUG_MAX] =
   "__debug_abbrev",
   "__debug_ranges",
   "__debug_str",
-  "", /* DEBUG_ADDR */
+  "__debug_addr",
   "__debug_str_offs",
-  "", /* DEBUG_LINE_STR */
+  "__debug_line_str",
   "__debug_rnglists"
 };