public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r13-108] Fold more vector constants early
@ 2022-05-04 11:58 Richard Biener
  0 siblings, 0 replies; only message in thread
From: Richard Biener @ 2022-05-04 11:58 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:3ae5cbff1ad958ddefc12010bf7e32a47741d331

commit r13-108-g3ae5cbff1ad958ddefc12010bf7e32a47741d331
Author: Richard Biener <rguenther@suse.de>
Date:   Fri Mar 25 08:43:45 2022 +0100

    Fold more vector constants early
    
    In PR105049 we had
    
      return VIEW_CONVERT_EXPR<U>( VEC_PERM_EXPR < {<<< Unknown tree: compound_literal_expr
            V D.1984 = { 0 }; >>>, { 0 }} , {<<< Unknown tree: compound_literal_expr
            V D.1985 = { 0 }; >>>, { 0 }} , { 0, 0 } >  & {(short int) SAVE_EXPR <c>, (short int) SAVE_EXPR <c>});
    
    where we gimplify the init CTORs to
    
      _1 = {{ 0 }, { 0 }};
      _2 = {{ 0 }, { 0 }};
    
    instead of to vector constants.  The following makes sure to simplify the
    CTORs to VECTOR_CSTs during gimplification by re-ordering the simplification
    to after CTOR flag recomputation and gimplification of the elements.
    
    2022-03-25  Richard Biener  <rguenther@suse.de>
    
            * gimplify.cc (gimplify_init_constructor): First gimplify,
            then simplify the result to a VECTOR_CST.

Diff:
---
 gcc/gimplify.cc | 33 ++++++++++++++++-----------------
 1 file changed, 16 insertions(+), 17 deletions(-)

diff --git a/gcc/gimplify.cc b/gcc/gimplify.cc
index 2588824dce2..f052d9f970c 100644
--- a/gcc/gimplify.cc
+++ b/gcc/gimplify.cc
@@ -5432,6 +5432,22 @@ gimplify_init_constructor (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p,
 	if (notify_temp_creation)
 	  return GS_OK;
 
+	/* Vector types use CONSTRUCTOR all the way through gimple
+	   compilation as a general initializer.  */
+	FOR_EACH_VEC_SAFE_ELT (elts, ix, ce)
+	  {
+	    enum gimplify_status tret;
+	    tret = gimplify_expr (&ce->value, pre_p, post_p, is_gimple_val,
+				  fb_rvalue);
+	    if (tret == GS_ERROR)
+	      ret = GS_ERROR;
+	    else if (TREE_STATIC (ctor)
+		     && !initializer_constant_valid_p (ce->value,
+						       TREE_TYPE (ce->value)))
+	      TREE_STATIC (ctor) = 0;
+	  }
+	recompute_constructor_flags (ctor);
+
 	/* Go ahead and simplify constant constructors to VECTOR_CST.  */
 	if (TREE_CONSTANT (ctor))
 	  {
@@ -5454,25 +5470,8 @@ gimplify_init_constructor (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p,
 		TREE_OPERAND (*expr_p, 1) = build_vector_from_ctor (type, elts);
 		break;
 	      }
-
-	    TREE_CONSTANT (ctor) = 0;
 	  }
 
-	/* Vector types use CONSTRUCTOR all the way through gimple
-	   compilation as a general initializer.  */
-	FOR_EACH_VEC_SAFE_ELT (elts, ix, ce)
-	  {
-	    enum gimplify_status tret;
-	    tret = gimplify_expr (&ce->value, pre_p, post_p, is_gimple_val,
-				  fb_rvalue);
-	    if (tret == GS_ERROR)
-	      ret = GS_ERROR;
-	    else if (TREE_STATIC (ctor)
-		     && !initializer_constant_valid_p (ce->value,
-						       TREE_TYPE (ce->value)))
-	      TREE_STATIC (ctor) = 0;
-	  }
-	recompute_constructor_flags (ctor);
 	if (!is_gimple_reg (TREE_OPERAND (*expr_p, 0)))
 	  TREE_OPERAND (*expr_p, 1) = get_formal_tmp_var (ctor, pre_p);
       }


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-05-04 11:58 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-04 11:58 [gcc r13-108] Fold more vector constants early Richard Biener

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).