Re: [PATCH] Add POLY_INT_CST support to fold_ctor_reference in gimple-fold.cc

2023-08-01 Thread Richard Ball via Gcc-patches

Thanks Richard,

I've gone through the write access process and committed this.

On 7/31/2023 10:56 AM, Richard Sandiford wrote:

Richard Ball  writes:

Add POLY_INT_CST support to code within
fold_ctor_reference. This code previously
only supported INTEGER_CST which caused a
bug when using VEC_PERM_EXPR with SVE vectors.


Just to add for others: this is a prerequisite for a follow-on patch,
so the change will be tested there.


gcc/ChangeLog:

  * gimple-fold.cc (fold_ctor_reference):
  Add support for Poly_int.


Nit: s/Poly_int/poly_int/

OK with that change, thanks.  Please follow https://gcc.gnu.org/gitwrite.html
to get write access (I'll sponsor).

Richard


#

diff --git a/gcc/gimple-fold.cc b/gcc/gimple-fold.cc
index
4027ff71e10337fe49c600fcd5a80026b260d54d..91e80b9aaa3b4797ce3a94129ca42c98d974cbd9
100644
--- a/gcc/gimple-fold.cc
+++ b/gcc/gimple-fold.cc
@@ -8162,8 +8162,8 @@ fold_ctor_reference (tree type, tree ctor, const
poly_uint64 _offset,
result.  */
 if (!AGGREGATE_TYPE_P (TREE_TYPE (ctor)) && !offset
 /* VIEW_CONVERT_EXPR is defined only for matching sizes.  */
-  && !compare_tree_int (TYPE_SIZE (type), size)
-  && !compare_tree_int (TYPE_SIZE (TREE_TYPE (ctor)), size))
+  && known_eq (wi::to_poly_widest (TYPE_SIZE (type)), size)
+  && known_eq (wi::to_poly_widest (TYPE_SIZE (TREE_TYPE (ctor))),
size))
   {
 ret = canonicalize_constructor_val (unshare_expr (ctor), from_decl);
 if (ret)


Re: [PATCH] Add POLY_INT_CST support to fold_ctor_reference in gimple-fold.cc

2023-07-31 Thread Richard Sandiford via Gcc-patches
Richard Ball  writes:
> Add POLY_INT_CST support to code within
> fold_ctor_reference. This code previously
> only supported INTEGER_CST which caused a
> bug when using VEC_PERM_EXPR with SVE vectors.

Just to add for others: this is a prerequisite for a follow-on patch,
so the change will be tested there.

> gcc/ChangeLog:
>
>  * gimple-fold.cc (fold_ctor_reference):
>  Add support for Poly_int.

Nit: s/Poly_int/poly_int/

OK with that change, thanks.  Please follow https://gcc.gnu.org/gitwrite.html
to get write access (I'll sponsor).

Richard

> #
>
> diff --git a/gcc/gimple-fold.cc b/gcc/gimple-fold.cc
> index 
> 4027ff71e10337fe49c600fcd5a80026b260d54d..91e80b9aaa3b4797ce3a94129ca42c98d974cbd9
>  
> 100644
> --- a/gcc/gimple-fold.cc
> +++ b/gcc/gimple-fold.cc
> @@ -8162,8 +8162,8 @@ fold_ctor_reference (tree type, tree ctor, const 
> poly_uint64 _offset,
>result.  */
> if (!AGGREGATE_TYPE_P (TREE_TYPE (ctor)) && !offset
> /* VIEW_CONVERT_EXPR is defined only for matching sizes.  */
> -  && !compare_tree_int (TYPE_SIZE (type), size)
> -  && !compare_tree_int (TYPE_SIZE (TREE_TYPE (ctor)), size))
> +  && known_eq (wi::to_poly_widest (TYPE_SIZE (type)), size)
> +  && known_eq (wi::to_poly_widest (TYPE_SIZE (TREE_TYPE (ctor))), 
> size))
>   {
> ret = canonicalize_constructor_val (unshare_expr (ctor), from_decl);
> if (ret)


[PATCH] Add POLY_INT_CST support to fold_ctor_reference in gimple-fold.cc

2023-07-31 Thread Richard Ball via Gcc-patches

Add POLY_INT_CST support to code within
fold_ctor_reference. This code previously
only supported INTEGER_CST which caused a
bug when using VEC_PERM_EXPR with SVE vectors.

gcc/ChangeLog:

* gimple-fold.cc (fold_ctor_reference):
Add support for Poly_int.


#

diff --git a/gcc/gimple-fold.cc b/gcc/gimple-fold.cc
index 
4027ff71e10337fe49c600fcd5a80026b260d54d..91e80b9aaa3b4797ce3a94129ca42c98d974cbd9 
100644

--- a/gcc/gimple-fold.cc
+++ b/gcc/gimple-fold.cc
@@ -8162,8 +8162,8 @@ fold_ctor_reference (tree type, tree ctor, const 
poly_uint64 _offset,

  result.  */
   if (!AGGREGATE_TYPE_P (TREE_TYPE (ctor)) && !offset
   /* VIEW_CONVERT_EXPR is defined only for matching sizes.  */
-  && !compare_tree_int (TYPE_SIZE (type), size)
-  && !compare_tree_int (TYPE_SIZE (TREE_TYPE (ctor)), size))
+  && known_eq (wi::to_poly_widest (TYPE_SIZE (type)), size)
+  && known_eq (wi::to_poly_widest (TYPE_SIZE (TREE_TYPE (ctor))), 
size))

 {
   ret = canonicalize_constructor_val (unshare_expr (ctor), from_decl);
   if (ret)