[PATCH 2/2] Remove dead vect_recog_mixed_size_cond_pattern

2024-10-26 Thread Richard Biener
vect_recog_mixed_size_cond_pattern only applies to COMPARISON_CLASS_P
rhs1 COND_EXPRs which no longer appear - the following removes it.
Its testcases still pass, I believe the situation is mitigated by
bool pattern handling of the compare use in COND_EXPRs.

Boostrap and regtest running on x86_64-unknown-linux-gnu.

* tree-vect-patterns.cc (type_conversion_p): Remove.
(vect_recog_mixed_size_cond_pattern): Likewise.
(vect_vect_recog_func_ptrs): Remove vect_recog_mixed_size_cond_pattern
entry.
---
 gcc/tree-vect-patterns.cc | 198 --
 1 file changed, 198 deletions(-)

diff --git a/gcc/tree-vect-patterns.cc b/gcc/tree-vect-patterns.cc
index 46f439fb8a3..302101fa6a0 100644
--- a/gcc/tree-vect-patterns.cc
+++ b/gcc/tree-vect-patterns.cc
@@ -313,55 +313,6 @@ vect_get_internal_def (vec_info *vinfo, tree op)
   return NULL;
 }
 
-/* Check whether NAME, an ssa-name used in STMT_VINFO,
-   is a result of a type promotion, such that:
- DEF_STMT: NAME = NOP (name0)
-   If CHECK_SIGN is TRUE, check that either both types are signed or both are
-   unsigned.  */
-
-static bool
-type_conversion_p (vec_info *vinfo, tree name, bool check_sign,
-  tree *orig_type, gimple **def_stmt, bool *promotion)
-{
-  tree type = TREE_TYPE (name);
-  tree oprnd0;
-  enum vect_def_type dt;
-
-  stmt_vec_info def_stmt_info;
-  if (!vect_is_simple_use (name, vinfo, &dt, &def_stmt_info, def_stmt))
-return false;
-
-  if (dt != vect_internal_def
-  && dt != vect_external_def && dt != vect_constant_def)
-return false;
-
-  if (!*def_stmt)
-return false;
-
-  if (!is_gimple_assign (*def_stmt))
-return false;
-
-  if (!CONVERT_EXPR_CODE_P (gimple_assign_rhs_code (*def_stmt)))
-return false;
-
-  oprnd0 = gimple_assign_rhs1 (*def_stmt);
-
-  *orig_type = TREE_TYPE (oprnd0);
-  if (!INTEGRAL_TYPE_P (type) || !INTEGRAL_TYPE_P (*orig_type)
-  || ((TYPE_UNSIGNED (type) != TYPE_UNSIGNED (*orig_type)) && check_sign))
-return false;
-
-  if (TYPE_PRECISION (type) >= (TYPE_PRECISION (*orig_type) * 2))
-*promotion = true;
-  else
-*promotion = false;
-
-  if (!vect_is_simple_use (oprnd0, vinfo, &dt))
-return false;
-
-  return true;
-}
-
 /* Holds information about an input operand after some sign changes
and type promotions have been peeled away.  */
 class vect_unpromoted_value {
@@ -5408,154 +5359,6 @@ vect_recog_mod_var_pattern (vec_info *vinfo,
   return pattern_stmt;
 }
 
-/* Function vect_recog_mixed_size_cond_pattern
-
-   Try to find the following pattern:
-
- type x_t, y_t;
- TYPE a_T, b_T, c_T;
-   loop:
- S1  a_T = x_t CMP y_t ? b_T : c_T;
-
-   where type 'TYPE' is an integral type which has different size
-   from 'type'.  b_T and c_T are either constants (and if 'TYPE' is wider
-   than 'type', the constants need to fit into an integer type
-   with the same width as 'type') or results of conversion from 'type'.
-
-   Input:
-
-   * STMT_VINFO: The stmt from which the pattern search begins.
-
-   Output:
-
-   * TYPE_OUT: The type of the output of this pattern.
-
-   * Return value: A new stmt that will be used to replace the pattern.
-   Additionally a def_stmt is added.
-
-   a_it = x_t CMP y_t ? b_it : c_it;
-   a_T = (TYPE) a_it;  */
-
-static gimple *
-vect_recog_mixed_size_cond_pattern (vec_info *vinfo,
-   stmt_vec_info stmt_vinfo, tree *type_out)
-{
-  gimple *last_stmt = stmt_vinfo->stmt;
-  tree cond_expr, then_clause, else_clause;
-  tree type, vectype, comp_vectype, itype = NULL_TREE, vecitype;
-  gimple *pattern_stmt, *def_stmt;
-  tree orig_type0 = NULL_TREE, orig_type1 = NULL_TREE;
-  gimple *def_stmt0 = NULL, *def_stmt1 = NULL;
-  bool promotion;
-  tree comp_scalar_type;
-
-  if (!is_gimple_assign (last_stmt)
-  || gimple_assign_rhs_code (last_stmt) != COND_EXPR
-  || STMT_VINFO_DEF_TYPE (stmt_vinfo) != vect_internal_def)
-return NULL;
-
-  cond_expr = gimple_assign_rhs1 (last_stmt);
-  then_clause = gimple_assign_rhs2 (last_stmt);
-  else_clause = gimple_assign_rhs3 (last_stmt);
-
-  if (!COMPARISON_CLASS_P (cond_expr))
-return NULL;
-
-  comp_scalar_type = TREE_TYPE (TREE_OPERAND (cond_expr, 0));
-  comp_vectype = get_vectype_for_scalar_type (vinfo, comp_scalar_type);
-  if (comp_vectype == NULL_TREE)
-return NULL;
-
-  type = TREE_TYPE (gimple_assign_lhs (last_stmt));
-  if (types_compatible_p (type, comp_scalar_type)
-  || ((TREE_CODE (then_clause) != INTEGER_CST
-  || TREE_CODE (else_clause) != INTEGER_CST)
- && !INTEGRAL_TYPE_P (comp_scalar_type))
-  || !INTEGRAL_TYPE_P (type))
-return NULL;
-
-  if ((TREE_CODE (then_clause) != INTEGER_CST
-   && !type_conversion_p (vinfo, then_clause, false,
- &orig_type0, &def_stmt0, &promotion))
-  || (TREE_CODE (else_clause) != INTEGER_CST
- && !type_conversion_p (vinfo, else_clause, false,
- 

[PATCH] Testing: remove dead code in adjust_bool_pattern

2024-10-26 Thread Richard Biener
I believe the comparison handling in adjust_bool_pattern is dead
after no longer queueing them but there's a do_compare goto that's
not obviously dead.  So I'm looking for testcases - the code path
would build a COND_EXPR with a comparison embedded.

Bootstrap and regtest running on x86_64-unknown-linux-gnu.

* tree-vect-patterns.cc (adjust_bool_pattern): Assert
we do not reach the do_compare case.
---
 gcc/tree-vect-patterns.cc | 1 +
 1 file changed, 1 insertion(+)

diff --git a/gcc/tree-vect-patterns.cc b/gcc/tree-vect-patterns.cc
index 302101fa6a0..48550bb2672 100644
--- a/gcc/tree-vect-patterns.cc
+++ b/gcc/tree-vect-patterns.cc
@@ -5585,6 +5585,7 @@ adjust_bool_pattern (vec_info *vinfo, tree var, tree 
out_type,
 
 default:
 do_compare:
+  gcc_unreachable ();
   gcc_assert (TREE_CODE_CLASS (rhs_code) == tcc_comparison);
   if (TREE_CODE (TREE_TYPE (rhs1)) != INTEGER_TYPE
  || !TYPE_UNSIGNED (TREE_TYPE (rhs1))
-- 
2.43.0


[PATCH 1/2] Remove dead code in vectorizer pattern recog

2024-10-26 Thread Richard Biener
The following removes the code path in vect_recog_mask_conversion_pattern
dealing with comparisons in COND_EXPRs.  That can no longer happen.

Bootstrap and regtest running on x86_64-unknown-linux-gnu.

* tree-vect-patterns.cc (vect_recog_mask_conversion_pattern):
Remove COMPARISON_CLASS_P rhs1 of COND_EXPR case and assert
it doesn't happen.
---
 gcc/tree-vect-patterns.cc | 99 +--
 1 file changed, 2 insertions(+), 97 deletions(-)

diff --git a/gcc/tree-vect-patterns.cc b/gcc/tree-vect-patterns.cc
index a6d246f570c..46f439fb8a3 100644
--- a/gcc/tree-vect-patterns.cc
+++ b/gcc/tree-vect-patterns.cc
@@ -6240,8 +6240,6 @@ vect_recog_mask_conversion_pattern (vec_info *vinfo,
   tree lhs = NULL_TREE, rhs1, rhs2, tmp, rhs1_type, rhs2_type;
   tree vectype1, vectype2;
   stmt_vec_info pattern_stmt_info;
-  tree rhs1_op0 = NULL_TREE, rhs1_op1 = NULL_TREE;
-  tree rhs1_op0_type = NULL_TREE, rhs1_op1_type = NULL_TREE;
 
   /* Check for MASK_LOAD and MASK_STORE as well as COND_OP calls requiring mask
  conversion.  */
@@ -6331,60 +6329,13 @@ vect_recog_mask_conversion_pattern (vec_info *vinfo,
 {
   vectype1 = get_vectype_for_scalar_type (vinfo, TREE_TYPE (lhs));
 
+  gcc_assert (! COMPARISON_CLASS_P (rhs1));
   if (TREE_CODE (rhs1) == SSA_NAME)
{
  rhs1_type = integer_type_for_mask (rhs1, vinfo);
  if (!rhs1_type)
return NULL;
}
-  else if (COMPARISON_CLASS_P (rhs1))
-   {
- /* Check whether we're comparing scalar booleans and (if so)
-whether a better mask type exists than the mask associated
-with boolean-sized elements.  This avoids unnecessary packs
-and unpacks if the booleans are set from comparisons of
-wider types.  E.g. in:
-
-  int x1, x2, x3, x4, y1, y1;
-  ...
-  bool b1 = (x1 == x2);
-  bool b2 = (x3 == x4);
-  ... = b1 == b2 ? y1 : y2;
-
-it is better for b1 and b2 to use the mask type associated
-with int elements rather bool (byte) elements.  */
- rhs1_op0 = TREE_OPERAND (rhs1, 0);
- rhs1_op1 = TREE_OPERAND (rhs1, 1);
- if (!rhs1_op0 || !rhs1_op1)
-   return NULL;
- rhs1_op0_type = integer_type_for_mask (rhs1_op0, vinfo);
- rhs1_op1_type = integer_type_for_mask (rhs1_op1, vinfo);
-
- if (!rhs1_op0_type)
-   rhs1_type = TREE_TYPE (rhs1_op0);
- else if (!rhs1_op1_type)
-   rhs1_type = TREE_TYPE (rhs1_op1);
- else if (TYPE_PRECISION (rhs1_op0_type)
-  != TYPE_PRECISION (rhs1_op1_type))
-   {
- int tmp0 = (int) TYPE_PRECISION (rhs1_op0_type)
-- (int) TYPE_PRECISION (TREE_TYPE (lhs));
- int tmp1 = (int) TYPE_PRECISION (rhs1_op1_type)
-- (int) TYPE_PRECISION (TREE_TYPE (lhs));
- if ((tmp0 > 0 && tmp1 > 0) || (tmp0 < 0 && tmp1 < 0))
-   {
- if (abs (tmp0) > abs (tmp1))
-   rhs1_type = rhs1_op1_type;
- else
-   rhs1_type = rhs1_op0_type;
-   }
- else
-   rhs1_type = build_nonstandard_integer_type
- (TYPE_PRECISION (TREE_TYPE (lhs)), 1);
-   }
- else
-   rhs1_type = rhs1_op0_type;
-   }
   else
return NULL;
 
@@ -6400,55 +6351,9 @@ vect_recog_mask_conversion_pattern (vec_info *vinfo,
 its vector type) and behave as though the comparison was an SSA
 name from the outset.  */
   if (known_eq (TYPE_VECTOR_SUBPARTS (vectype1),
-   TYPE_VECTOR_SUBPARTS (vectype2))
- && !rhs1_op0_type
- && !rhs1_op1_type)
+   TYPE_VECTOR_SUBPARTS (vectype2)))
return NULL;
 
-  /* If rhs1 is invariant and we can promote it leave the COND_EXPR
- in place, we can handle it in vectorizable_condition.  This avoids
-unnecessary promotion stmts and increased vectorization factor.  */
-  if (COMPARISON_CLASS_P (rhs1)
- && INTEGRAL_TYPE_P (rhs1_type)
- && known_le (TYPE_VECTOR_SUBPARTS (vectype1),
-  TYPE_VECTOR_SUBPARTS (vectype2)))
-   {
- enum vect_def_type dt;
- if (vect_is_simple_use (TREE_OPERAND (rhs1, 0), vinfo, &dt)
- && dt == vect_external_def
- && vect_is_simple_use (TREE_OPERAND (rhs1, 1), vinfo, &dt)
- && (dt == vect_external_def
- || dt == vect_constant_def))
-   {
- tree wide_scalar_type = build_nonstandard_integer_type
-   (vector_element_bits (vectype1), TYPE_UNSIGNED (rhs1_type));
- tree vectype3 = get_vectype_for_scalar_type (vinfo,
-  wide_scalar_type);
- if (expand_vec_cond_expr_p (v

[PATCH] Remove code in vectorizer pattern recog relying on vec_cond{u,eq,}

2024-10-26 Thread Richard Biener
With the intent to rely on vec_cond_mask and vec_cmp patterns
comparisons do not need rewriting into COND_EXPRs that eventually
combine to vec_cond{u,eq,}.

Bootstrap and regtest running on x86_64-unknown-linux-gnu.

* tree-vect-patterns.cc (check_bool_pattern): For comparisons
we do nothing if we can expand them or we can't replace them
with a ? -1 : 0 condition - but the latter would require
expanding the comparison which we proved we can't.  So do
nothing, aka not think vec_cond{u,eq,} will save us.
---
 gcc/tree-vect-patterns.cc | 37 +
 1 file changed, 1 insertion(+), 36 deletions(-)

diff --git a/gcc/tree-vect-patterns.cc b/gcc/tree-vect-patterns.cc
index 46aa3129bb3..a6d246f570c 100644
--- a/gcc/tree-vect-patterns.cc
+++ b/gcc/tree-vect-patterns.cc
@@ -5610,42 +5610,7 @@ check_bool_pattern (tree var, vec_info *vinfo, 
hash_set &stmts)
   break;
 
 default:
-  if (TREE_CODE_CLASS (rhs_code) == tcc_comparison)
-   {
- tree vecitype, comp_vectype;
-
- /* If the comparison can throw, then is_gimple_condexpr will be
-false and we can't make a COND_EXPR/VEC_COND_EXPR out of it.  */
- if (stmt_could_throw_p (cfun, def_stmt))
-   return false;
-
- comp_vectype = get_vectype_for_scalar_type (vinfo, TREE_TYPE (rhs1));
- if (comp_vectype == NULL_TREE)
-   return false;
-
- tree mask_type = get_mask_type_for_scalar_type (vinfo,
- TREE_TYPE (rhs1));
- if (mask_type
- && expand_vec_cmp_expr_p (comp_vectype, mask_type, rhs_code))
-   return false;
-
- if (TREE_CODE (TREE_TYPE (rhs1)) != INTEGER_TYPE)
-   {
- scalar_mode mode = SCALAR_TYPE_MODE (TREE_TYPE (rhs1));
- tree itype
-   = build_nonstandard_integer_type (GET_MODE_BITSIZE (mode), 1);
- vecitype = get_vectype_for_scalar_type (vinfo, itype);
- if (vecitype == NULL_TREE)
-   return false;
-   }
- else
-   vecitype = comp_vectype;
- if (! expand_vec_cond_expr_p (vecitype, comp_vectype, rhs_code))
-   return false;
-   }
-  else
-   return false;
-  break;
+  return false;
 }
 
   bool res = stmts.add (def_stmt);
-- 
2.43.0


[Ada] Fix PR ada/62122

2024-10-26 Thread Eric Botcazou
This is an old glitch in the GNAT RM.

Tested on x86-64/Linux, applied on the mainline.


2024-10-26  Eric Botcazou  

PR ada/62122
* doc/gnat_rm/implementation_defined_attributes.rst
(Unrestricted_Access): Remove null exclusion.
* gnat_rm.texi: Regenerate.

-- 
Eric Botcazoudiff --git a/gcc/ada/doc/gnat_rm/implementation_defined_attributes.rst b/gcc/ada/doc/gnat_rm/implementation_defined_attributes.rst
index 2db245a0b88..f0518106853 100644
--- a/gcc/ada/doc/gnat_rm/implementation_defined_attributes.rst
+++ b/gcc/ada/doc/gnat_rm/implementation_defined_attributes.rst
@@ -1382,7 +1382,7 @@ has returned, such calls are erroneous. For example:
 
   package body P is
 
- type Less_Nested is not null access procedure;
+ type Less_Nested is access procedure;
  Global : Less_Nested;
 
  procedure P1 is
diff --git a/gcc/ada/gnat_rm.texi b/gcc/ada/gnat_rm.texi
index 4bcdcf6781d..647207f89e9 100644
--- a/gcc/ada/gnat_rm.texi
+++ b/gcc/ada/gnat_rm.texi
@@ -12066,7 +12066,7 @@ has returned, such calls are erroneous. For example:
 @example
 package body P is
 
-   type Less_Nested is not null access procedure;
+   type Less_Nested is access procedure;
Global : Less_Nested;
 
procedure P1 is


Re: [PATCH] doc/cpp: Document __has_include_next

2024-10-26 Thread Arsen Arsenović
Hi!

Arsen Arsenović  writes:

> OK for trunk?  Seems to build and render fine with makeinfo --info and
> --html.  Typesetting it, I see overfull and underfull hboxes, but I
> suspect these were here for a while..

Gentle ping on this patch.

TIA, have a lovely day.
-- 
Arsen Arsenović


signature.asc
Description: PGP signature


[PATCH 0/2] RISC-V:Add Cache Management Operation ISA Extensions Intrinsics

2024-10-26 Thread shiyulong
From: yulong 

This patchset adds intrinsic support for CMOs extensions.But it not include 
prefetchi.

cf. ;

Patch 1: Add Zicbom/z/p intrinsic support
Patch 2: Add test cases.

yulong (2):
  Add intrinsic support for the CMOs extensions
  Add intrinsic cases for the CMOs extensions

 gcc/config.gcc  |  2 +-
 gcc/config/riscv/riscv_cmo.h| 84 +
 gcc/testsuite/gcc.target/riscv/cmo-32.c | 52 +++
 gcc/testsuite/gcc.target/riscv/cmo-64.c | 52 +++
 4 files changed, 189 insertions(+), 1 deletion(-)
 create mode 100644 gcc/config/riscv/riscv_cmo.h
 create mode 100644 gcc/testsuite/gcc.target/riscv/cmo-32.c
 create mode 100644 gcc/testsuite/gcc.target/riscv/cmo-64.c

-- 
2.34.1



[PATCH 2/2] Add intrinsic cases for the CMOs extensions

2024-10-26 Thread shiyulong
From: yulong 

gcc/testsuite/ChangeLog:

* gcc.target/riscv/cmo-32.c: New test.
* gcc.target/riscv/cmo-64.c: New test.

---
 gcc/testsuite/gcc.target/riscv/cmo-32.c | 52 +
 gcc/testsuite/gcc.target/riscv/cmo-64.c | 52 +
 2 files changed, 104 insertions(+)
 create mode 100644 gcc/testsuite/gcc.target/riscv/cmo-32.c
 create mode 100644 gcc/testsuite/gcc.target/riscv/cmo-64.c

diff --git a/gcc/testsuite/gcc.target/riscv/cmo-32.c 
b/gcc/testsuite/gcc.target/riscv/cmo-32.c
new file mode 100644
index 000..1e06ce184ac
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/cmo-32.c
@@ -0,0 +1,52 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target rv32} */
+/* { dg-options "-march=rv32gc_zicbom_zicbop_zicboz -mabi=ilp32" } */
+
+#include "riscv_cmo.h"
+
+void foo1 (void *addr)
+{
+__riscv_cmo_clean(0);
+__riscv_cmo_clean(addr);
+__riscv_cmo_clean((void*)0x111);
+}
+
+void foo2 (void *addr)
+{
+__riscv_cmo_flush(0);
+__riscv_cmo_flush(addr);
+__riscv_cmo_flush((void*)0x111);
+}
+
+void foo3 (void *addr)
+{
+__riscv_cmo_inval(0);
+__riscv_cmo_inval(addr);
+__riscv_cmo_inval((void*)0x111);
+}
+
+void foo4 (void *addr)
+{
+__riscv_cmo_prefetch(addr,0,0);
+__riscv_cmo_prefetch(addr,0,1);
+__riscv_cmo_prefetch(addr,0,2);
+__riscv_cmo_prefetch(addr,0,3);
+__riscv_cmo_prefetch(addr,1,0);
+__riscv_cmo_prefetch(addr,1,1);
+__riscv_cmo_prefetch(addr,1,2);
+__riscv_cmo_prefetch(addr,1,3);
+}
+
+void foo5 (void *addr)
+{
+__riscv_cmo_zero(0);
+__riscv_cmo_zero(addr);
+__riscv_cmo_zero((void*)0x121);
+}
+
+/* { dg-final { scan-assembler-times "cbo.clean\t" 3 } } */
+/* { dg-final { scan-assembler-times "cbo.flush\t" 3 } } */
+/* { dg-final { scan-assembler-times "cbo.inval\t" 3 } } */
+/* { dg-final { scan-assembler-times "prefetch.r\t" 4 } } */
+/* { dg-final { scan-assembler-times "prefetch.w\t" 4 } } */
+/* { dg-final { scan-assembler-times "cbo.zero\t" 3 } } */
diff --git a/gcc/testsuite/gcc.target/riscv/cmo-64.c 
b/gcc/testsuite/gcc.target/riscv/cmo-64.c
new file mode 100644
index 000..6865c224095
--- /dev/null
+++ b/gcc/testsuite/gcc.target/riscv/cmo-64.c
@@ -0,0 +1,52 @@
+/* { dg-do compile } */
+/* { dg-require-effective-target rv64 } */
+/* { dg-options "-march=rv64gc_zicbom_zicbop_zicboz -mabi=lp64d" } */
+
+#include "riscv_cmo.h"
+
+void foo1 (void *addr)
+{
+__riscv_cmo_clean(0);
+__riscv_cmo_clean(addr);
+__riscv_cmo_clean((void*)0x111);
+}
+
+void foo2 (void *addr)
+{
+__riscv_cmo_flush(0);
+__riscv_cmo_flush(addr);
+__riscv_cmo_flush((void*)0x111);
+}
+
+void foo3 (void *addr)
+{
+__riscv_cmo_inval(0);
+__riscv_cmo_inval(addr);
+__riscv_cmo_inval((void*)0x111);
+}
+
+void foo4 (void *addr)
+{
+__riscv_cmo_prefetch(addr,0,0);
+__riscv_cmo_prefetch(addr,0,1);
+__riscv_cmo_prefetch(addr,0,2);
+__riscv_cmo_prefetch(addr,0,3);
+__riscv_cmo_prefetch(addr,1,0);
+__riscv_cmo_prefetch(addr,1,1);
+__riscv_cmo_prefetch(addr,1,2);
+__riscv_cmo_prefetch(addr,1,3);
+}
+
+void foo5 (void *addr)
+{
+__riscv_cmo_zero(0);
+__riscv_cmo_zero(addr);
+__riscv_cmo_zero((void*)0x121);
+}
+
+/* { dg-final { scan-assembler-times "cbo.clean\t" 3 } } */
+/* { dg-final { scan-assembler-times "cbo.flush\t" 3 } } */
+/* { dg-final { scan-assembler-times "cbo.inval\t" 3 } } */
+/* { dg-final { scan-assembler-times "prefetch.r\t" 4 } } */
+/* { dg-final { scan-assembler-times "prefetch.w\t" 4 } } */
+/* { dg-final { scan-assembler-times "cbo.zero\t" 3 } } */
-- 
2.34.1



[PATCH 1/2] Add intrinsic support for the CMOs extensions

2024-10-26 Thread shiyulong
From: yulong 

gcc/ChangeLog:

* config.gcc: Add riscv_cmo.h.
* config/riscv/riscv_cmo.h: New file.

---
 gcc/config.gcc   |  2 +-
 gcc/config/riscv/riscv_cmo.h | 84 
 2 files changed, 85 insertions(+), 1 deletion(-)
 create mode 100644 gcc/config/riscv/riscv_cmo.h

diff --git a/gcc/config.gcc b/gcc/config.gcc
index fd848228722..e2ed3b309cc 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -558,7 +558,7 @@ riscv*)
extra_objs="${extra_objs} riscv-vector-builtins.o 
riscv-vector-builtins-shapes.o riscv-vector-builtins-bases.o"
extra_objs="${extra_objs} thead.o riscv-target-attr.o"
d_target_objs="riscv-d.o"
-   extra_headers="riscv_vector.h riscv_crypto.h riscv_bitmanip.h 
riscv_th_vector.h"
+   extra_headers="riscv_vector.h riscv_crypto.h riscv_bitmanip.h 
riscv_th_vector.h riscv_cmo.h"
target_gtfiles="$target_gtfiles 
\$(srcdir)/config/riscv/riscv-vector-builtins.cc"
target_gtfiles="$target_gtfiles 
\$(srcdir)/config/riscv/riscv-vector-builtins.h"
;;
diff --git a/gcc/config/riscv/riscv_cmo.h b/gcc/config/riscv/riscv_cmo.h
new file mode 100644
index 000..aa2103ed0ef
--- /dev/null
+++ b/gcc/config/riscv/riscv_cmo.h
@@ -0,0 +1,84 @@
+/* RISC-V CMO Extension intrinsics include file.
+   Copyright (C) 2024 Free Software Foundation, Inc.
+
+   This file is part of GCC.
+
+   GCC is free software; you can redistribute it and/or modify it
+   under the terms of the GNU General Public License as published
+   by the Free Software Foundation; either version 3, or (at your
+   option) any later version.
+
+   GCC is distributed in the hope that it will be useful, but WITHOUT
+   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+   or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
+   License for more details.
+
+   Under Section 7 of GPL version 3, you are granted additional
+   permissions described in the GCC Runtime Library Exception, version
+   3.1, as published by the Free Software Foundation.
+
+   You should have received a copy of the GNU General Public License and
+   a copy of the GCC Runtime Library Exception along with this program;
+   see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
+   .  */
+
+#ifndef __RISCV_CMO_H
+#define __RISCV_CMO_H
+
+#include 
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#if defined (__riscv_zicbom)
+
+extern __inline void
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+__riscv_cmo_clean (void *addr)
+{
+__builtin_riscv_zicbom_cbo_clean(addr);
+}
+
+extern __inline void
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+__riscv_cmo_flush (void *addr)
+{
+__builtin_riscv_zicbom_cbo_flush(addr);
+}
+
+extern __inline void
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+__riscv_cmo_inval (void *addr)
+{
+__builtin_riscv_zicbom_cbo_inval(addr);
+}
+
+#endif // __riscv_zicbom
+
+#if defined (__riscv_zicbop)
+
+extern __inline void
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+__riscv_cmo_prefetch (void *addr, const int vs1, const int vs2)
+{
+__builtin_prefetch(addr,vs1,vs2);
+}
+
+#endif // __riscv_zicbop
+
+#if defined (__riscv_zicboz)
+
+extern __inline void
+__attribute__ ((__gnu_inline__, __always_inline__, __artificial__))
+__riscv_cmo_zero (void *addr)
+{
+__builtin_riscv_zicboz_cbo_zero(addr);
+}
+
+#endif // __riscv_zicboz
+
+#if defined (__cplusplus)
+}
+#endif // __cplusplus
+#endif // __RISCV_CMO_H
\ No newline at end of file
-- 
2.34.1



Re: [patch, Fortran, doc] Update descriptions for UNSIGNED

2024-10-26 Thread Iain Sandoe



> On 26 Oct 2024, at 22:41, Thomas Koenig  wrote:
> 
> Am 26.10.24 um 22:10 schrieb Iain Sandoe:
>>> Pushed (4727bfb37701f3fef98a5f8b60dcd2daa82e8143).
>> This seems to have broken —enable-languages=all bootstrap with
>>  /src-local/gcc-master/gcc/fortran/intrinsic.texi:39: node `Intrinsic 
>> Procedures' lacks menu item for `UINT' despite being its Up target
>> /src-local/gcc-master/gcc/fortran/intrinsic.texi:14934: warning: node prev 
>> `UMASK' in menu `UCOBOUND' and in sectioning `UINT’ differ
> 
> That is weird - if this is not picked up with "make info", "make html"
> and "make pdf", what command is needed to trigger it?  Or is it
> --enable-languages=all vs. --enable-languages=c,c++,fortran which I use?

make info was enough to trigger it in my testing.

It might depend on the version of makeinfo [6.7 on both the platforms I saw 
fail].

Iain

> 
>> I think the following patch (which will no doubt be whitespace-mangled my 
>> mailer) is needed - under test
> 
> If you're already testing it, please commit if it passes (approved if
> any approval is needed).

OK - thanks - will post the final patch here.
Iain

> 
> Thanks for the help!
> 
> Best regards
> 
>   Thomas
> 
> 
>> diff --git a/gcc/fortran/intrinsic.texi b/gcc/fortran/intrinsic.texi
>> index 0354704e4d0..f47fa3bbd5e 100644
>> --- a/gcc/fortran/intrinsic.texi
>> +++ b/gcc/fortran/intrinsic.texi
>> @@ -321,6 +321,7 @@ Some basic guidelines for editing this document:
>>  * @code{TTYNAM}:TTYNAM,Get the name of a terminal device
>>  * @code{UBOUND}:UBOUND,Upper dimension bounds of an array
>>  * @code{UCOBOUND}:  UCOBOUND,  Upper codimension bounds of an array
>> +* @code{UINT}:  UINT,  Convert to an unsigned integer type
>>  * @code{UMASK}: UMASK, Set the file creation mask
>>  * @code{UNLINK}:UNLINK,Remove a file from the file system
>>  * @code{UNPACK}:UNPACK,Unpack an array of rank one into an array
> 
> 
> 



[PATCH] guality tests: Silence gdb debuginfod warning

2024-10-26 Thread H.J. Lu
When gdb defaults to use debuginfod, gdb warns guality tests:

Spawning: gdb -nx -nw -quiet -batch -x pr36728-2.gdb ./pr36728-2.exe
spawn gdb -nx -nw -quiet -batch -x pr36728-2.gdb ./pr36728-2.exe
Breakpoint 1 at 0x4004ba: file /export/gnu/import/git/gitlab/x86-gcc/gcc/testsui
te/gcc.dg/guality/pr36728-2.c, line 18.

This GDB supports auto-downloading debuginfo from the following URLs:
  
Enable debuginfod for this session? (y or [n]) [answered N; input not from termi
nal]
Debuginfod has been disabled.
To make this setting permanent, add 'set debuginfod enabled off' to .gdbinit.

After 'set debuginfod enabled off' is added to ~/.gdbinit, gdb warning
doesn't go away since -nx option ignores ~/.gdbinit.  Silence gdb warning
by setting DEBUGINFOD_URLS to "" and restore if it exists.

PR testsuite/117300
* g++.dg/guality/guality.exp: Set DEBUGINFOD_URLS to "" and
restore it if it exists.
* gcc.dg/guality/guality.exp: Likewise.
* gfortran.dg/guality/guality.exp: Likewise.

Co-authored-by: Andrew Pinski 
Signed-off-by: H.J. Lu 

-- 
H.J.
From 9cdffb8a969ed6a3c2fd2273b05abdbdc424af41 Mon Sep 17 00:00:00 2001
From: "H.J. Lu" 
Date: Sun, 27 Oct 2024 05:51:18 +0800
Subject: [PATCH] guality tests: Silence gdb debuginfod warning

When gdb defaults to use debuginfod, gdb warns guality tests:

Spawning: gdb -nx -nw -quiet -batch -x pr36728-2.gdb ./pr36728-2.exe
spawn gdb -nx -nw -quiet -batch -x pr36728-2.gdb ./pr36728-2.exe
Breakpoint 1 at 0x4004ba: file /export/gnu/import/git/gitlab/x86-gcc/gcc/testsuite/gcc.dg/guality/pr36728-2.c, line 18.

This GDB supports auto-downloading debuginfo from the following URLs:
  
Enable debuginfod for this session? (y or [n]) [answered N; input not from terminal]
Debuginfod has been disabled.
To make this setting permanent, add 'set debuginfod enabled off' to .gdbinit.

After 'set debuginfod enabled off' is added to ~/.gdbinit, gdb warning
doesn't go away since -nx option ignores ~/.gdbinit.  Silence gdb warning
by setting DEBUGINFOD_URLS to "" and restore if it exists.

	PR testsuite/117300
	* g++.dg/guality/guality.exp: Set DEBUGINFOD_URLS to "" and
	restore it if it exists.
	* gcc.dg/guality/guality.exp: Likewise.
	* gfortran.dg/guality/guality.exp: Likewise.

Co-authored-by: Andrew Pinski 
Signed-off-by: H.J. Lu 
---
 gcc/testsuite/g++.dg/guality/guality.exp  | 10 ++
 gcc/testsuite/gcc.dg/guality/guality.exp  | 10 ++
 gcc/testsuite/gfortran.dg/guality/guality.exp | 10 ++
 3 files changed, 30 insertions(+)

diff --git a/gcc/testsuite/g++.dg/guality/guality.exp b/gcc/testsuite/g++.dg/guality/guality.exp
index cd56b06f2f0..6de5e8091a5 100644
--- a/gcc/testsuite/g++.dg/guality/guality.exp
+++ b/gcc/testsuite/g++.dg/guality/guality.exp
@@ -51,6 +51,12 @@ if ![info exists ::env(GUALITY_GDB_NAME)] {
 }
 setenv GUALITY_GDB_NAME "$guality_gdb_name"
 }
+
+if [info exists ::env(DEBUGINFOD_URLS)] {
+  set orig_debuginfod_urls "$::env(DEBUGINFOD_URLS)"
+  setenv DEBUGINFOD_URLS ""
+}
+
 report_gdb $::env(GUALITY_GDB_NAME) [info script]
 
 global DG_TORTURE_OPTIONS LTO_TORTURE_OPTIONS
@@ -91,5 +97,9 @@ if [info exists guality_gdb_name] {
 unsetenv GUALITY_GDB_NAME
 }
 
+if [info exists ::env(DEBUGINFOD_URLS)] {
+  setenv DEBUGINFOD_URLS "$orig_debuginfod_urls"
+}
+
 torture-finish
 dg-finish
diff --git a/gcc/testsuite/gcc.dg/guality/guality.exp b/gcc/testsuite/gcc.dg/guality/guality.exp
index a8f2921d888..0dc8f10762d 100644
--- a/gcc/testsuite/gcc.dg/guality/guality.exp
+++ b/gcc/testsuite/gcc.dg/guality/guality.exp
@@ -51,6 +51,12 @@ if ![info exists ::env(GUALITY_GDB_NAME)] {
 }
 setenv GUALITY_GDB_NAME "$guality_gdb_name"
 }
+
+if [info exists ::env(DEBUGINFOD_URLS)] {
+  set orig_debuginfod_urls "$::env(DEBUGINFOD_URLS)"
+  setenv DEBUGINFOD_URLS ""
+}
+
 report_gdb $::env(GUALITY_GDB_NAME) [info script]
 
 proc guality_transform_options { args } {
@@ -106,5 +112,9 @@ if [info exists guality_gdb_name] {
 unsetenv GUALITY_GDB_NAME
 }
 
+if [info exists ::env(DEBUGINFOD_URLS)] {
+  setenv DEBUGINFOD_URLS "$orig_debuginfod_urls"
+}
+
 torture-finish
 dg-finish
diff --git a/gcc/testsuite/gfortran.dg/guality/guality.exp b/gcc/testsuite/gfortran.dg/guality/guality.exp
index 610449523f0..105e08a70d8 100644
--- a/gcc/testsuite/gfortran.dg/guality/guality.exp
+++ b/gcc/testsuite/gfortran.dg/guality/guality.exp
@@ -32,6 +32,12 @@ if ![info exists ::env(GUALITY_GDB_NAME)] {
 }
 setenv GUALITY_GDB_NAME "$guality_gdb_name"
 }
+
+if [info exists ::env(DEBUGINFOD_URLS)] {
+  set orig_debuginfod_urls "$::env(DEBUGINFOD_URLS)"
+  setenv DEBUGINFOD_URLS ""
+}
+
 report_gdb $::env(GUALITY_GDB_NAME) [info script]
 
 global DG_TORTURE_OPTIONS
@@ -45,5 +51,9 @@ if [info exists guality_gdb_name] {
 unsetenv GUALITY_GDB_NAME
 }
 
+if [info exists ::env(DEBUGINFOD_URLS)] {
+  setenv DEBUGINFOD_URLS "$orig_debuginfod_urls"
+}
+
 torture-finish
 dg-finish
-- 
2.47.0



Re: [patch, Fortran, doc] Update descriptions for UNSIGNED

2024-10-26 Thread Thomas Koenig

Am 26.10.24 um 22:10 schrieb Iain Sandoe:

Pushed (4727bfb37701f3fef98a5f8b60dcd2daa82e8143).

This seems to have broken —enable-languages=all bootstrap with

  /src-local/gcc-master/gcc/fortran/intrinsic.texi:39: node `Intrinsic 
Procedures' lacks menu item for `UINT' despite being its Up target
/src-local/gcc-master/gcc/fortran/intrinsic.texi:14934: warning: node prev 
`UMASK' in menu `UCOBOUND' and in sectioning `UINT’ differ


That is weird - if this is not picked up with "make info", "make html"
and "make pdf", what command is needed to trigger it?  Or is it
--enable-languages=all vs. --enable-languages=c,c++,fortran which I use?


I think the following patch (which will no doubt be whitespace-mangled my 
mailer) is needed - under test


If you're already testing it, please commit if it passes (approved if
any approval is needed).

Thanks for the help!

Best regards

Thomas




diff --git a/gcc/fortran/intrinsic.texi b/gcc/fortran/intrinsic.texi
index 0354704e4d0..f47fa3bbd5e 100644
--- a/gcc/fortran/intrinsic.texi
+++ b/gcc/fortran/intrinsic.texi
@@ -321,6 +321,7 @@ Some basic guidelines for editing this document:
  * @code{TTYNAM}:TTYNAM,Get the name of a terminal device
  * @code{UBOUND}:UBOUND,Upper dimension bounds of an array
  * @code{UCOBOUND}:  UCOBOUND,  Upper codimension bounds of an array
+* @code{UINT}:  UINT,  Convert to an unsigned integer type
  * @code{UMASK}: UMASK, Set the file creation mask
  * @code{UNLINK}:UNLINK,Remove a file from the file system
  * @code{UNPACK}:UNPACK,Unpack an array of rank one into an array






[pushed] doc, fortran: Add a missing menu item.

2024-10-26 Thread Iain Sandoe
Tested on x86_64-darwin21 and linux, with makeinfo 6.7 pushed to trunk,
thanks
Iain

--- 8< ---

The changes in r15-4697-g4727bfb37701 omit a menu entry which causes a
bootstrap fail when Fortran is included for at least makeinfo 6.7.
Fixed thus.

gcc/fortran/ChangeLog:

* intrinsic.texi: Add menu item for UINT.

Signed-off-by: Iain Sandoe 
---
 gcc/fortran/intrinsic.texi | 1 +
 1 file changed, 1 insertion(+)

diff --git a/gcc/fortran/intrinsic.texi b/gcc/fortran/intrinsic.texi
index 0354704e4d0..f47fa3bbd5e 100644
--- a/gcc/fortran/intrinsic.texi
+++ b/gcc/fortran/intrinsic.texi
@@ -321,6 +321,7 @@ Some basic guidelines for editing this document:
 * @code{TTYNAM}:TTYNAM,Get the name of a terminal device
 * @code{UBOUND}:UBOUND,Upper dimension bounds of an array
 * @code{UCOBOUND}:  UCOBOUND,  Upper codimension bounds of an array
+* @code{UINT}:  UINT,  Convert to an unsigned integer type
 * @code{UMASK}: UMASK, Set the file creation mask
 * @code{UNLINK}:UNLINK,Remove a file from the file system
 * @code{UNPACK}:UNPACK,Unpack an array of rank one into an array
-- 
2.39.2 (Apple Git-143)



Re: [patch, Fortran, doc] Update descriptions for UNSIGNED

2024-10-26 Thread Steve Kargl
On Sat, Oct 26, 2024 at 05:16:54PM +0200, Thomas Koenig wrote:
> 
> OK for trunk?
> 

OK, but see below.

> +@item @code{SUM}, @pxref{SUM}
> +@item @code{TRANSPOSE}, @pxref{TRANSPOSE}
> +@item @code{TRANSFER}, @pxref{TRANSFER}
>  @end itemize
> +
> +The following intrincis are enabled with @option{-funsigned}:

s/intrincis/intrinsics


> +@item @var{I} @tab Shall be of @code{INTEGER} or @code{UNSIGNED} type.
> +@item @var{J} @tab Shall be of of the same type and kind as @var{I}.
>  @end multitable

"of of" need to delete one.
 

> +@item @var{I} @tab Shall be of @code{INTEGER} or @code{UNSIGNED} type.
> +@item @var{J} @tab Shall be of of the same type and kind as @var{I}.

"of of" 

> +@item @var{I} @tab Shall be of @code{INTEGER} or @code{UNSIGNED} type.
> +@item @var{J} @tab Shall be of of the same type and kind as @var{I}.

"of of"

-- 
Steve


[patch, Fortran, doc] Update descriptions for UNSIGNED

2024-10-26 Thread Thomas Koenig

Hello world,

the attached patch adds documentation for the long list of intrinsics
which take UNSIGNED arguments. Checked with "make html", "make pdf" and
"make info".

gcc/fortran/ChangeLog:

* gfortran.texi: Correct reference to make clear that UNSIGNED
will not be part of F202Y.
Other clarifications.
Extend table of intrinsics, add links.
* intrinsic.texi: Add descriptions for UNSIGNED arguments.
* invoke.texi: Add anchor for -funsigned.

OK for trunk?

Best regards

Thomasdiff --git a/gcc/fortran/gfortran.texi b/gcc/fortran/gfortran.texi
index 76326e625f8..a20053ed611 100644
--- a/gcc/fortran/gfortran.texi
+++ b/gcc/fortran/gfortran.texi
@@ -1192,7 +1192,7 @@ extensions.
 @menu
 * Extensions implemented in GNU Fortran::
 * Extensions not implemented in GNU Fortran::
-* Experimental features for Fortran 202Y::
+* Experimental features for future Fortran versions::
 @end menu
 
 
@@ -2702,19 +2702,19 @@ descriptor occurred, use @code{INQUIRE} to get the file position,
 count the characters up to the next @code{NEW_LINE} and then start
 reading from the position marked previously.
 
-@node Experimental features for Fortran 202Y
-@section Experimental features for Fortran 202Y
-@cindex Fortran 202Y
+@node Experimental features for future Fortran versions
+@section Experimental features future Fortran versions
+@cindex Future Fortran versions
 
 GNU Fortran supports some experimental features which have been
 proposed and accepted by the J3 standards committee.  These
 exist to give users a chance to try them out, and to provide
 a reference implementation.
 
-As these features have not been finalized, there is a chance that the
-version in the upcoming standard will differ from what GNU Fortran
-currently implements.  Stability of these implementations is therefore
-not guaranteed.
+As these features have not been included in the worklist for Fortran
+202Y by WG5, there is a chance that a version in any upcoming standard
+will differ from what GNU Fortran currently implements.  These
+features are therefore currently classified as an extension.
 
 @menu
 * Unsigned integers::
@@ -2723,11 +2723,12 @@ not guaranteed.
 @node Unsigned integers
 @subsection Unsigned integers
 @cindex Unsigned integers
-GNU Fortran supports unsigned integers according to
+If the @option{-funsigned} option is given, GNU Fortran supports
+unsigned integers according to
 @uref{https://j3-fortran.org/doc/year/24/24-116.txt, J3/24-116}.  The
-data type is called @code{UNSIGNED}.  For an unsigned type with $n$ bits,
-it implements integer arithmetic modulo @code{2**n}, comparable to the
-@code{unsigned} data type in C.
+data type is called @code{UNSIGNED}.  For an unsigned type with @code{n}
+bits, it implements integer arithmetic modulo @code{2**n}, comparable
+to the @code{unsigned} data type in C.
 
 The data type has @code{KIND} numbers comparable to other Fortran data
 types, which can be selected via the @code{SELECTED_UNSIGNED_KIND}
@@ -2771,31 +2772,75 @@ formatted and unformatted I/O.  For formatted I/O, the @code{B},
 values and values which would overflow are rejected with
 @code{-pedantic}.
 
-As of now, the following intrinsics take unsigned arguments:
+The following intrinsics take unsigned arguments:
 @itemize @bullet
-@item @code{BLT}, @code{BLE}, @code{BGE} and @code{BGT}. These intrinsics
-  are actually redundant because comparison operators could be used
-  directly.
-@item @code{IAND}, @code{IOR}, @code{IEOR} and @code{NOT}
-@item @code{BIT_SIZE}, @code{DIGITS} and @code{HUGE}
-@item @code{DSHIFTL} and @code{DSHIFTR}
-@item @code{IBCLR}, @code{IBITS} and @code{IBSET}
-@item @code{MIN} and @code{MAX}
-@item @code{ISHFT}, @code{ISHFTC}, @code{SHIFTL}, @code{SHIFTR} and
-  @code{SHIFTA}.
-@item @code{MERGE_BITS}
-@item @code{MOD} and @code{MODULO}
-@item @code{MVBITS}
-@item @code{RANGE}
-@item @code{TRANSFER}
-@item @code{SUM}, @code{PRODUCT}, @code{MATMUL} and @code{DOT_PRODUCT}
-@item @code{IANY}, @code{IALL} and @code{IPARITY}
-@item @code{RANDOM_NUMBER}
-@item @code{CSHIFT} and @code{EOSHIFT}
-@item @code{FINDLOC}
-@item @code{MAXVAL} and @code{MINVAL}
-@item @code{MAXLOC} and @code{MINLOC}.
+@item @code{BGE}, @pxref{BGE}
+@item @code{BGT}, @pxref{BGT}
+@item @code{BIT_SIZE}, @pxref{BIT_SIZE}
+@item @code{BLE}, @pxref{BLE}
+@item @code{BLT}, @pxref{BLT}
+@item @code{CSHIFT}, @pxref{CSHIFT}
+@item @code{DIGITS}, @pxref{DIGITS}
+@item @code{DOT_PRODUCT}, @pxref{DOT_PRODUCT}
+@item @code{DSHIFTL}, @pxref{DSHIFTL}
+@item @code{DSHIFTR}, @pxref{DSHIFTR}
+@item @code{EOSHIFT}, @pxref{EOSHIFT}
+@item @code{FINDLOC}, @pxref{FINDLOC}
+@item @code{HUGE}, @pxref{HUGE}
+@item @code{IALL}, @pxref{IALL}
+@item @code{IAND}, @pxref{IAND}
+@item @code{IANY}, @pxref{IANY}
+@item @code{IBCLR}, @pxref{IBCLR}
+@item @code{IBITS}, @pxref{IBITS}
+@item @code{IBSET}, @pxref{IBSET}
+@item @code{IEOR}, @pxref{IEOR}
+@item @code{IOR}, @pxref{IOR}
+@item @code{IPARITY}, 

RE: [PATCH] i386: Add _MM_FROUND_TO_NEAREST_TIES_EVEN to smmintrin.h

2024-10-26 Thread Paul Caprioli
This patch adds the standard macro definition _MM_FROUND_TO_NEAREST_TIES_EVEN 
for specifying the IEEE rounding to nearest attribute `roundTiesToEven` for 
AVX512 floating-point intrinsics.

More information can be found in the original email to this list
 https://gcc.gnu.org/pipermail/gcc-patches/2024-July/657957.html
and in the discussion
 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117163

Regards,
Paul
From d01a657a6bc138cfbf1953bbbf2976a0eed4c5c7 Mon Sep 17 00:00:00 2001
From: Paul Caprioli 
Date: Sat, 20 Jul 2024 11:31:06 -0700
Subject: [PATCH] Add _MM_FROUND_TO_NEAREST_TIES_EVEN to smmintrin.h

---
 gcc/config/i386/smmintrin.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/gcc/config/i386/smmintrin.h b/gcc/config/i386/smmintrin.h
index c2d82773247..1b732433453 100644
--- a/gcc/config/i386/smmintrin.h
+++ b/gcc/config/i386/smmintrin.h
@@ -39,6 +39,7 @@
 
 /* Rounding mode macros. */
 #define _MM_FROUND_TO_NEAREST_INT	0x00
+#define _MM_FROUND_TO_NEAREST_TIES_EVEN	0x00
 #define _MM_FROUND_TO_NEG_INF		0x01
 #define _MM_FROUND_TO_POS_INF		0x02
 #define _MM_FROUND_TO_ZERO		0x03
-- 
2.39.5



Re: [patch, Fortran, doc] Update descriptions for UNSIGNED

2024-10-26 Thread Iain Sandoe
Hi Thomas

> On 26 Oct 2024, at 18:28, Thomas Koenig  wrote:
> 
> Hi Steve,
> 
>>> OK for trunk?
>>> 
>> OK, but see below.
> 
> Pushed (4727bfb37701f3fef98a5f8b60dcd2daa82e8143). 

This seems to have broken —enable-languages=all bootstrap with

 /src-local/gcc-master/gcc/fortran/intrinsic.texi:39: node `Intrinsic 
Procedures' lacks menu item for `UINT' despite being its Up target
/src-local/gcc-master/gcc/fortran/intrinsic.texi:14934: warning: node prev 
`UMASK' in menu `UCOBOUND' and in sectioning `UINT’ differ

I think the following patch (which will no doubt be whitespace-mangled my 
mailer) is needed - under test
thanks
Iain

diff --git a/gcc/fortran/intrinsic.texi b/gcc/fortran/intrinsic.texi
index 0354704e4d0..f47fa3bbd5e 100644
--- a/gcc/fortran/intrinsic.texi
+++ b/gcc/fortran/intrinsic.texi
@@ -321,6 +321,7 @@ Some basic guidelines for editing this document:
 * @code{TTYNAM}:TTYNAM,Get the name of a terminal device
 * @code{UBOUND}:UBOUND,Upper dimension bounds of an array
 * @code{UCOBOUND}:  UCOBOUND,  Upper codimension bounds of an array
+* @code{UINT}:  UINT,  Convert to an unsigned integer type
 * @code{UMASK}: UMASK, Set the file creation mask
 * @code{UNLINK}:UNLINK,Remove a file from the file system
 * @code{UNPACK}:UNPACK,Unpack an array of rank one into an array




Re: [PATCH] Add 'cobol' to Makefile.def, take 2

2024-10-26 Thread James K. Lowden
On Sat, 26 Oct 2024 11:22:20 +0800
Xi Ruoyao  wrote:

> The changelog is not formatted correctly.  gcc/ has its own
> changelog. And gcc/cobol should have its own changelog too, like all
> other frontends.

Thank you for pointing that out.  I now have

[snip]
Subject: [PATCH]  Add 'cobol' to 10 files

ChangeLog
* Makefile.def: Add libgcobol module and cobol language.
* configure: Regenerated
* configure.ac: Add libgcobol module and cobol language.

gcc/ChangeLog
* gcc/common.opt: Add libgcobol module and cobol language.

gcc/cobol/ChangeLog
* gcc/cobol/ChangeLog: Add gcc/cobol/ChangeLog
* gcc/cobol/LICENSE: Add gcc/cobol/LICENSE
* gcc/cobol/Make-lang.in: Add gcc/cobol/Make-lang.in
* gcc/cobol/config-lang.in: Add gcc/cobol/config-lang.in
* gcc/cobol/lang.opt: Add gcc/cobol/lang.opt
* gcc/cobol/lang.opt.urls: Add gcc/cobol/lang.opt.urls
[pins]

> Please also use "git gcc-verify".  

Where is this documented?  I found 

https://gcc.gnu.org/pipermail/gcc-cvs/2020-May/288244.html

and

contrib/gcc-git-customization.sh

There's quite a bit of stuff in there.  I genenerally don't use anyone else's 
handy-dandy configuration, especially for git, which is baroque enough as it 
is.  But I can run one command, 

$ grep gcc-verify gcc-git-customization.sh 
git config alias.gcc-verify '!f() { "`git rev-parse 
--show-toplevel`/contrib/gcc-changelog/git_check_commit.py" $@; } ; f'

if that's what we need. 

--jkl


[PATCH] c: detect variably-modified types [PR117145,PR117245,PR100420]

2024-10-26 Thread Martin Uecker


Here is a patch that hopefully fixes the last cases where we do not
tag variably-modified types correctly.  It is probably best to look
at the c-typeck.cc changes first.

Martin


c: detect variably-modified types [PR117145,PR117245,PR100420]

This fixes two cases where variably-modified types were not recognized as
such.  The first is when building composite types and the other when a type
is reconstructed for the 'vector' attribute.  Construction of types in
the C FE is reorganized to use c_build_* functions which are responsible for
setting C_TYPE_VARIABLE_SIZE, C_TYPE_VARIABLY_MODIFIED and 
TYPE_TYPELESS_STORAGE
based on the properties of the type itself and these replace all other logic
elsewhere (e.g. in grokdeclarator).  A new 'c_reconstruct_complex_type' 
based
on these functions is introduced which is called via a language hook when 
the
'vector' attribute is processed (as for C++).

One problem is are arrays of unspecified size 'T[*]' which were represented
identically to zero-sized arrays but with C_TYPE_VARIABLE_SIZE set.  To 
avoid
having to create distinct type copies for this, the representation was 
changed
to make it a natural VLA by giving it an upper bound of '(0, 0)'.  This also
then allows fixing of PR100420 where such arrays were printed as 'T[0]'.

Finally, a new function 'c_verify_type' checks consistency of properties
specific to C FE and is called when checking is on.

PR c/117145
PR c/117245
PR c/100420

gcc/c/ChangeLog:
* c-decl.cc (c_build_pointer_type): Move to c-typeck.cc
(grokdeclarator): Simplify logic.
(match_builtin_function_types): Adapt.
(push_decl): Adapt.
(implicitly_declare): Adapt.
(c_update_type_canonical): Adapt.
(c_make_fname_decl): Adapt.
(start_function): Adapt.
* c-obj-common.h: Add LANG_HOOKS_RECONSTRUCT_COMPLEX_TYPE.
* c-tree.h: Add prototypes.
* c-typeck.cc (c_verify_type): New function.
(c_set_type_bits). New function.
(c_build_pointer_type): Moved from c-decl.cc.
(c_build_pointer_type_for_mode): New function.
(c_build_function_type): New function.
(c_build_array_type): New function.
(c_build_type_attribute_variant): New function.
(c_reconstruct_complex_type): New function.
(c_build_functype_attribute_variant): Renamed.
(array_to_pointer_conversion): Simplify logic.
(composite_type_internal): Simplify logic..
(build_unary_op): Simplify logic..
(comptypes_verify): Add checking assertions.
(c_build_qualified_type): Add checking assertions.
(c_build_function_call_vec): Adapt.
(qualify_type): Adapt.
(build_functype_attribute_variant): Adapt.
(common_pointer_type): Adapt.
(c_common_type): Adapt.
(convert_for_assignment): Adapt.
(type_or_builtin_type): Adapt.
(build_access_with_size_for_counted_by): Adapt.
(build_conditional_expr): Adapt.
(build_modify_expr): Adapt.
(build_binary_op): Adapt.
(build_omp_array_section): Adapt.
(handle_omp_array_sections): Adapt.
(c_finish_omp_clauses): Adapt.
* c-parser.cc (c_parser_typeof_specifier): Adapt.
(c_parser_generic_selection): Adapt.

gcc/c-family/ChangeLog:
* c-pretty-print.cc (c_pretty_printer::direct_abstract_declarator):
Detect arrays of unspecified size.

gcc/testsuite/ChangeLog:
* gcc.dg/c23-tag-composite-11.c: New test.
* gcc.dg/Warray-parameter-4.c: Resolve xfails.
* gcc.dg/Wvla-parameter-2.c: Resolve xfails.
* gcc.dg/Wvla-parameter-3.c: Resolve xfails.
* gcc.dg/pr117145-1.c: New test.
* gcc.dg/pr117145-2.c: New test.
* gcc.dg/pr117245.c: New test.

diff --git a/gcc/c-family/c-pretty-print.cc b/gcc/c-family/c-pretty-print.cc
index 13806714446..f843b33eb79 100644
--- a/gcc/c-family/c-pretty-print.cc
+++ b/gcc/c-family/c-pretty-print.cc
@@ -688,7 +688,11 @@ c_pretty_printer::direct_abstract_declarator (tree t)
maxval = TREE_OPERAND (maxval, 0);
}
 
- expression (maxval);
+ /* This covers unspecified bounds.  */
+ if (TREE_CODE (maxval) == COMPOUND_EXPR)
+   pp_string (this, "*");
+ else
+   expression (maxval);
}
}
  else if (TYPE_SIZE (t))
diff --git a/gcc/c/c-decl.cc b/gcc/c/c-decl.cc
index 1827bbf0646..e66a6e6b131 100644
--- a/gcc/c/c-decl.cc
+++ b/gcc/c/c-decl.cc
@@ -714,22 +714,9 @@ add_stmt (tree t)
 
   return t;
 

Re: [PATCH] tree: Mark PAREN_EXPR and VEC_DUPLICATE_EXPR as non-trapping [PR117234]

2024-10-26 Thread Richard Biener



> Am 26.10.2024 um 19:06 schrieb Andrew Pinski :
> 
> While looking to fix a possible trapping issue in PHI-OPT's factor,
> I noticed that some tree codes could be marked as trapping even
> though they don't have a possibility to trap. In the case of PAREN_EXPR,
> it is basically a nop except when it comes to association across it so
> it can't trap.
> In the case of VEC_DUPLICATE_EXPR, it is similar to a CONSTRUCTOR, so it
> can't trap.
> 
> This fixes those 2 issues and adds 4 testcases, 2 which are specific to 
> aarch64
> since the only way to get a VEC_DUPLICATE_EXPR is to use intrinsics currently.
> 
> Build and tested for aarch64-linux-gnu.

Ok

Richard 

>PR tree-optimization/117234
> 
> gcc/ChangeLog:
> 
>* tree-eh.cc (operation_could_trap_helper_p): Treat
>PAREN_EXPR and VEC_DUPLICATE_EXPR like constructing
>expressions.
> 
> gcc/testsuite/ChangeLog:
> 
>* g++.dg/eh/noncall-fp-1.C: New test.
>* g++.target/aarch64/sve/noncall-eh-fp-1.C: New test.
>* gcc.dg/tree-ssa/trapping-1.c: New test.
>* gcc.target/aarch64/sve/trapping-1.c: New test.
> 
> Signed-off-by: Andrew Pinski 
> ---
> gcc/testsuite/g++.dg/eh/noncall-fp-1.C| 15 +
> .../g++.target/aarch64/sve/noncall-eh-fp-1.C  | 16 ++
> gcc/testsuite/gcc.dg/tree-ssa/trapping-1.c| 21 +++
> .../gcc.target/aarch64/sve/trapping-1.c   | 21 +++
> gcc/tree-eh.cc|  2 ++
> 5 files changed, 75 insertions(+)
> create mode 100644 gcc/testsuite/g++.dg/eh/noncall-fp-1.C
> create mode 100644 gcc/testsuite/g++.target/aarch64/sve/noncall-eh-fp-1.C
> create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/trapping-1.c
> create mode 100644 gcc/testsuite/gcc.target/aarch64/sve/trapping-1.c
> 
> diff --git a/gcc/testsuite/g++.dg/eh/noncall-fp-1.C 
> b/gcc/testsuite/g++.dg/eh/noncall-fp-1.C
> new file mode 100644
> index 000..bb6f8afb58a
> --- /dev/null
> +++ b/gcc/testsuite/g++.dg/eh/noncall-fp-1.C
> @@ -0,0 +1,15 @@
> +/* { dg-do compile } */
> +/* { dg-options "-O2 -fnon-call-exceptions -fdump-tree-optimized" } */
> +
> +/* PR tree-optimization/117234  */
> +/* PAREN_EXPR should not be declared as trapping.  */
> +
> +float f1(float a)
> +{
> +  try {
> +return __builtin_assoc_barrier (a);
> +  }  catch(...)
> +  { __builtin_trap (); }
> +}
> +
> +/* { dg-final { scan-tree-dump-not "__builtin_trap" "optimized" } } */
> diff --git a/gcc/testsuite/g++.target/aarch64/sve/noncall-eh-fp-1.C 
> b/gcc/testsuite/g++.target/aarch64/sve/noncall-eh-fp-1.C
> new file mode 100644
> index 000..778b63d82d5
> --- /dev/null
> +++ b/gcc/testsuite/g++.target/aarch64/sve/noncall-eh-fp-1.C
> @@ -0,0 +1,16 @@
> +/* { dg-do compile } */
> +/* { dg-options "-O2 -fnon-call-exceptions -fdump-tree-optimized" } */
> +
> +/* PR tree-optimization/117234  */
> +/* VEC_DUPLICATE_EXPR should not be declared as trapping.  */
> +#include 
> +
> +svfloat32_t f(float a)
> +{
> +  try {
> +return svdup_f32(a);
> +  }  catch(...)
> +  { __builtin_trap (); }
> +}
> +
> +/* { dg-final { scan-tree-dump-not "__builtin_trap" "optimized" } } */
> diff --git a/gcc/testsuite/gcc.dg/tree-ssa/trapping-1.c 
> b/gcc/testsuite/gcc.dg/tree-ssa/trapping-1.c
> new file mode 100644
> index 000..ea07562e47e
> --- /dev/null
> +++ b/gcc/testsuite/gcc.dg/tree-ssa/trapping-1.c
> @@ -0,0 +1,21 @@
> +/* { dg-do compile } */
> +/* { dg-options "-O2 -fdump-tree-lim-details" } */
> +
> +/* PR tree-optimization/117234  */
> +/* PAREN_EXPR should not be declared as
> +   a trapping.  */
> +
> +float f1(float a, int t, _Bool *b, float c)
> +{
> +  float tt = 0;
> +  for (int i = 0; i < t; i++)
> +  {
> +if (b[i])
> +  tt *= -__builtin_assoc_barrier (-a);
> +  }
> +  return tt;
> +}
> +
> +/* There should be 3 `invariant up to level`, two for each `-` and one
> +   for the PAREN_EXPR. */
> +/* { dg-final { scan-tree-dump-times "invariant up to level" 3 "lim2" } } */
> diff --git a/gcc/testsuite/gcc.target/aarch64/sve/trapping-1.c 
> b/gcc/testsuite/gcc.target/aarch64/sve/trapping-1.c
> new file mode 100644
> index 000..1ac7ac708d2
> --- /dev/null
> +++ b/gcc/testsuite/gcc.target/aarch64/sve/trapping-1.c
> @@ -0,0 +1,21 @@
> +/* { dg-do compile } */
> +/* { dg-options "-O2 -fdump-tree-lim-details" } */
> +
> +/* PR tree-optimization/117234  */
> +/* VEC_DUPLICATE_EXPR should not be declared as
> +   a trapping.  */
> +#include 
> +
> +svfloat32_t f(float a, int t, _Bool *b)
> +{
> +  svfloat32_t tt = svdup_f32(0.0);
> +  for (int i =0 ;i < t; i++)
> +  {
> +if (b[i])
> +  tt = svadd_f32_z(svptrue_b32(),tt,svdup_f32(a));
> +  }
> +  return tt;
> +}
> +
> +/* There should be 1 `invariant up to level`, one for the 
> VEC_DUPLICATE_EXPR. */
> +/* { dg-final { scan-tree-dump-times "invariant up to level" 1 "lim2" } } */
> diff --git a/gcc/tree-eh.cc b/gcc/tree-eh.cc
> index ae0a4e3864c..769785fad2b 100644
> --- a/gcc/tree-eh.cc
> +++ b/gcc/tree-eh.cc
> @@ -2532

Re: [patch, Fortran, doc] Update descriptions for UNSIGNED

2024-10-26 Thread Thomas Koenig

Hi Steve,


OK for trunk?



OK, but see below.


Pushed (4727bfb37701f3fef98a5f8b60dcd2daa82e8143). Thanks for
the proof-reading!

Best regards

Thomas




[PATCH] [aarch64] Fix function multiversioning dispatcher link error with LTO

2024-10-26 Thread Yangyu Chen
We forgot to apply DECL_EXTERNAL to __init_cpu_features_resolver decl. When
building with LTO, the linker cannot find the
__init_cpu_features_resolver.lto_priv* symbol, causing the link error.

This patch get this fixed by adding DECL_EXTERNAL to the decl.

Minimal steps to reproduce the bug:

echo '__attribute__((target_clones("default", "aes"))) void func1() { }' > 1.c
echo '__attribute__((target_clones("default", "aes"))) void func2() { }' > 2.c
echo 'void func1();void func2();int main(){func1();func2();return 0;}' > main.c
gcc -flto -c 1.c 2.c
gcc -flto main.c 1.o 2.o

Fixes: 0cfde688e213 ("[aarch64] Add function multiversioning support")

gcc/ChangeLog:

* config/aarch64/aarch64.cc (dispatch_function_versions): Adding
DECL_EXTERNAL to __init_cpu_features_resolver decl.
---
 gcc/config/aarch64/aarch64.cc | 1 +
 1 file changed, 1 insertion(+)

diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc
index 5770491b30c..2baa8c5d5c0 100644
--- a/gcc/config/aarch64/aarch64.cc
+++ b/gcc/config/aarch64/aarch64.cc
@@ -20437,6 +20437,7 @@ dispatch_function_versions (tree dispatch_decl,
   tree init_fn_id = get_identifier ("__init_cpu_features_resolver");
   tree init_fn_decl = build_decl (UNKNOWN_LOCATION, FUNCTION_DECL,
  init_fn_id, init_fn_type);
+  DECL_EXTERNAL (init_fn_decl) = 1;
   tree arg1 = DECL_ARGUMENTS (dispatch_decl);
   tree arg2 = TREE_CHAIN (arg1);
   ifunc_cpu_init_stmt = gimple_build_call (init_fn_decl, 2, arg1, arg2);
-- 
2.47.0



Re: [PATCH v3 10/11] RISC-V: Implement TARGET_GENERATE_VERSION_DISPATCHER_BODY and TARGET_GET_FUNCTION_VERSIONS_DISPATCHER

2024-10-26 Thread Yangyu Chen




On 2024/10/24 15:13, Yangyu Chen wrote:

This patch implements the TARGET_GENERATE_VERSION_DISPATCHER_BODY and
TARGET_GET_FUNCTION_VERSIONS_DISPATCHER for RISC-V. This is used to
generate the dispatcher function and get the dispatcher function for
function multiversioning.

This patch copies many codes from commit 0cfde688e213 ("[aarch64]
Add function multiversioning support") and modifies them to fit the
RISC-V port. A key difference is the data structure of feature bits in
RISC-V C-API is a array of unsigned long long, while in AArch64 is not
a array. So we need to generate the array reference for each feature
bits element in the dispatcher function.

gcc/ChangeLog:

* config/riscv/riscv.cc (add_condition_to_bb): New function.
(dispatch_function_versions): New function.
(get_suffixed_assembler_name): New function.
(make_resolver_func): New function.
(riscv_generate_version_dispatcher_body): New function.
(riscv_get_function_versions_dispatcher): New function.
(TARGET_GENERATE_VERSION_DISPATCHER_BODY): Implement it.
(TARGET_GET_FUNCTION_VERSIONS_DISPATCHER): Implement it.
---
  gcc/config/riscv/riscv.cc | 582 ++
  1 file changed, 582 insertions(+)

diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc
index 46961360096..c8dbe5333ec 100644
--- a/gcc/config/riscv/riscv.cc
+++ b/gcc/config/riscv/riscv.cc
+static int
+dispatch_function_versions (tree dispatch_decl,
+   void *fndecls_p,
+   basic_block *empty_bb)
+{
+  gimple *ifunc_cpu_init_stmt;
+  gimple_seq gseq;
+  vec *fndecls;
+
+  gcc_assert (dispatch_decl != NULL
+ && fndecls_p != NULL
+ && empty_bb != NULL);
+
+  push_cfun (DECL_STRUCT_FUNCTION (dispatch_decl));
+
+  gseq = bb_seq (*empty_bb);
+  /* Function version dispatch is via IFUNC.  IFUNC resolvers fire before
+ constructors, so explicity call __init_riscv_feature_bits here.  */
+  tree init_fn_type = build_function_type_list (void_type_node,
+   long_unsigned_type_node,
+   ptr_type_node,
+   NULL);
+  tree init_fn_id = get_identifier ("__init_riscv_feature_bits");
+  tree init_fn_decl = build_decl (UNKNOWN_LOCATION, FUNCTION_DECL,
+ init_fn_id, init_fn_type);


Here should add `DECL_EXTERNAL (init_fn_decl) = 1;` to avoid link error 
with LTO.


Similar patch on aarch64 by me:

https://patchwork.sourceware.org/project/gcc/patch/tencent_d088823cda488e50b88a31b5212c8d4d7...@qq.com/

I'm waiting for other reviews before submitting the next revision.


+  ifunc_cpu_init_stmt = gimple_build_call (init_fn_decl, 0);




Re: [PATCH v7] Target-independent store forwarding avoidance.

2024-10-26 Thread Jeff Law




On 10/23/24 8:27 AM, Konstantinos Eleftheriou wrote:

From: kelefth 

This pass detects cases of expensive store forwarding and tries to avoid them
by reordering the stores and using suitable bit insertion sequences.
For example it can transform this:

  strbw2, [x1, 1]
  ldr x0, [x1]  # Expensive store forwarding to larger load.

To:

  ldr x0, [x1]
  strbw2, [x1]
  bfi x0, x2, 0, 8

Assembly like this can appear with bitfields or type punning / unions.
On stress-ng when running the cpu-union microbenchmark the following speedups
have been observed.

   Neoverse-N1:  +29.4%
   Intel Coffeelake: +13.1%
   AMD 5950X:+17.5%

[ ... ]
Seems to still have some correctness issues.  H8 reports this when the 
pass is enabled by default:



Tests that now fail, but worked before (8 tests):

h8300-sim/-mh/-mint32: gcc: gcc.c-torture/execute/pr63843.c   -O2  execution 
test

[ ... ]

It looks like we miss setting the high half of the register.  The good 
sequence looks like:



!   mov.b   @er2,r3l
!   mov.b   r3l,@(2,er7)
mov.b   @(1,er2),r2l
mov.b   r2l,@(3,er7)
!   mov.w   @(2,er7),r0


Note the word (16 bit) move at the end of the sequence that sets both 
halves of the r0 register.


The broken sequence looks like this:


!   mov.b   @er2,r0l
mov.b   @(1,er2),r2l
+   mov.b   r0l,@(2,er7)
mov.b   r2l,@(3,er7)
!   mov.b   r2l,r0l


Note how all the assignments are byte sized and that nothing sets r0h. 
We get whatever value happened to be lying around in the high half of 
the register.


You should be able to see this with an H8 cross compiler and shouldn't 
need a full toolchain to test.  Compile with -O2 -mh -mint32.  There is 
only one opportunity for SFB avoidance in pr63843.


There's also a failure for bfin-elf, but I suspect it's ultimately the 
same underlying issue.  Obviously I'll retest once there's a fix.


jeff




[PATCH] tree: Mark PAREN_EXPR and VEC_DUPLICATE_EXPR as non-trapping [PR117234]

2024-10-26 Thread Andrew Pinski
While looking to fix a possible trapping issue in PHI-OPT's factor,
I noticed that some tree codes could be marked as trapping even
though they don't have a possibility to trap. In the case of PAREN_EXPR,
it is basically a nop except when it comes to association across it so
it can't trap.
In the case of VEC_DUPLICATE_EXPR, it is similar to a CONSTRUCTOR, so it
can't trap.

This fixes those 2 issues and adds 4 testcases, 2 which are specific to aarch64
since the only way to get a VEC_DUPLICATE_EXPR is to use intrinsics currently.

Build and tested for aarch64-linux-gnu.

PR tree-optimization/117234

gcc/ChangeLog:

* tree-eh.cc (operation_could_trap_helper_p): Treat
PAREN_EXPR and VEC_DUPLICATE_EXPR like constructing
expressions.

gcc/testsuite/ChangeLog:

* g++.dg/eh/noncall-fp-1.C: New test.
* g++.target/aarch64/sve/noncall-eh-fp-1.C: New test.
* gcc.dg/tree-ssa/trapping-1.c: New test.
* gcc.target/aarch64/sve/trapping-1.c: New test.

Signed-off-by: Andrew Pinski 
---
 gcc/testsuite/g++.dg/eh/noncall-fp-1.C| 15 +
 .../g++.target/aarch64/sve/noncall-eh-fp-1.C  | 16 ++
 gcc/testsuite/gcc.dg/tree-ssa/trapping-1.c| 21 +++
 .../gcc.target/aarch64/sve/trapping-1.c   | 21 +++
 gcc/tree-eh.cc|  2 ++
 5 files changed, 75 insertions(+)
 create mode 100644 gcc/testsuite/g++.dg/eh/noncall-fp-1.C
 create mode 100644 gcc/testsuite/g++.target/aarch64/sve/noncall-eh-fp-1.C
 create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/trapping-1.c
 create mode 100644 gcc/testsuite/gcc.target/aarch64/sve/trapping-1.c

diff --git a/gcc/testsuite/g++.dg/eh/noncall-fp-1.C 
b/gcc/testsuite/g++.dg/eh/noncall-fp-1.C
new file mode 100644
index 000..bb6f8afb58a
--- /dev/null
+++ b/gcc/testsuite/g++.dg/eh/noncall-fp-1.C
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fnon-call-exceptions -fdump-tree-optimized" } */
+
+/* PR tree-optimization/117234  */
+/* PAREN_EXPR should not be declared as trapping.  */
+
+float f1(float a)
+{
+  try {
+return __builtin_assoc_barrier (a);
+  }  catch(...)
+  { __builtin_trap (); }
+}
+
+/* { dg-final { scan-tree-dump-not "__builtin_trap" "optimized" } } */
diff --git a/gcc/testsuite/g++.target/aarch64/sve/noncall-eh-fp-1.C 
b/gcc/testsuite/g++.target/aarch64/sve/noncall-eh-fp-1.C
new file mode 100644
index 000..778b63d82d5
--- /dev/null
+++ b/gcc/testsuite/g++.target/aarch64/sve/noncall-eh-fp-1.C
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fnon-call-exceptions -fdump-tree-optimized" } */
+
+/* PR tree-optimization/117234  */
+/* VEC_DUPLICATE_EXPR should not be declared as trapping.  */
+#include 
+
+svfloat32_t f(float a)
+{
+  try {
+return svdup_f32(a);
+  }  catch(...)
+  { __builtin_trap (); }
+}
+
+/* { dg-final { scan-tree-dump-not "__builtin_trap" "optimized" } } */
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/trapping-1.c 
b/gcc/testsuite/gcc.dg/tree-ssa/trapping-1.c
new file mode 100644
index 000..ea07562e47e
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/tree-ssa/trapping-1.c
@@ -0,0 +1,21 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-lim-details" } */
+
+/* PR tree-optimization/117234  */
+/* PAREN_EXPR should not be declared as
+   a trapping.  */
+
+float f1(float a, int t, _Bool *b, float c)
+{
+  float tt = 0;
+  for (int i = 0; i < t; i++)
+  {
+if (b[i])
+  tt *= -__builtin_assoc_barrier (-a);
+  }
+  return tt;
+}
+
+/* There should be 3 `invariant up to level`, two for each `-` and one
+   for the PAREN_EXPR. */
+/* { dg-final { scan-tree-dump-times "invariant up to level" 3 "lim2" } } */
diff --git a/gcc/testsuite/gcc.target/aarch64/sve/trapping-1.c 
b/gcc/testsuite/gcc.target/aarch64/sve/trapping-1.c
new file mode 100644
index 000..1ac7ac708d2
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/sve/trapping-1.c
@@ -0,0 +1,21 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-lim-details" } */
+
+/* PR tree-optimization/117234  */
+/* VEC_DUPLICATE_EXPR should not be declared as
+   a trapping.  */
+#include 
+
+svfloat32_t f(float a, int t, _Bool *b)
+{
+  svfloat32_t tt = svdup_f32(0.0);
+  for (int i =0 ;i < t; i++)
+  {
+if (b[i])
+  tt = svadd_f32_z(svptrue_b32(),tt,svdup_f32(a));
+  }
+  return tt;
+}
+
+/* There should be 1 `invariant up to level`, one for the VEC_DUPLICATE_EXPR. 
*/
+/* { dg-final { scan-tree-dump-times "invariant up to level" 1 "lim2" } } */
diff --git a/gcc/tree-eh.cc b/gcc/tree-eh.cc
index ae0a4e3864c..769785fad2b 100644
--- a/gcc/tree-eh.cc
+++ b/gcc/tree-eh.cc
@@ -2532,6 +2532,8 @@ operation_could_trap_helper_p (enum tree_code op,
 
 case COMPLEX_EXPR:
 case CONSTRUCTOR:
+case VEC_DUPLICATE_EXPR:
+case PAREN_EXPR:
   /* Constructing an object cannot trap.  */
   return false;
 
-- 
2.43.0



Re: [COMMITTED 4/4] - Implement pointer_or_operator.

2024-10-26 Thread Mikael Morin

Hello,

Le 24/10/2024 à 14:53, Andrew MacLeod a écrit :

diff --git a/gcc/range-op-ptr.cc b/gcc/range-op-ptr.cc
index dd312a80366..ef2b2cce516 100644
--- a/gcc/range-op-ptr.cc
+++ b/gcc/range-op-ptr.cc

(...)

-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);


this doesn't feel right.  It checks that the operand range is anything 
but singleton [0], instead of checking that it does not contain 0.



-  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);


And it makes this else branch dead.


+
+  update_known_bitmask (r, BIT_IOR_EXPR, op1, op2);
+  return true;
 }
 


For example, the change makes VARYING | 0 fold to non-zero (instead of 
VARYING).