]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[PATCH] Add POLY_INT_CST support to fold_ctor_reference in gimple-fold.cc
authorRichard Ball <richard.ball@arm.com>
Tue, 1 Aug 2023 15:57:02 +0000 (16:57 +0100)
committerRichard Ball <richard.ball@arm.com>
Tue, 1 Aug 2023 16:00:09 +0000 (17:00 +0100)
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.

gcc/gimple-fold.cc

index 86b83472a61616f0cdd6ce44db1f8b0f2c8bdc68..fd01810581ad48687b5e778a4ca758f1d492560b 100644 (file)
@@ -8159,8 +8159,8 @@ fold_ctor_reference (tree type, tree ctor, const poly_uint64 &poly_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)