Richard Biener <richard.guent...@gmail.com> writes:
> On Wed, Jul 25, 2018 at 1:09 PM Richard Sandiford
> <richard.sandif...@arm.com> wrote:
>>
>> Richard Biener <richard.guent...@gmail.com> writes:
>> > On Tue, Jul 24, 2018 at 12:07 PM Richard Sandiford
>> > <richard.sandif...@arm.com> wrote:
>> >>
>> >> This patch adds a pattern_stmt_p field to stmt_vec_info, so that it's
>> >> possible to tell whether the statement is a pattern statement without
>> >> referring to other statements.  The new field goes in what was
>> >> previously a hole in the structure, so the size is the same as before.
>> >
>> > Not sure what the advantage is?  is_pattern_stmt_p () looks nicer
>> > than ->is_pattern_p
>>
>> I can keep the function wrapper if you prefer that.  But having a
>> statement "know" whether it's a pattern stmt makes things like
>> freeing stmt_vec_infos simpler (see later patches in the series).
>
> Ah, ok.
>
>> It should also be cheaper to test, but that's much more minor.
>
> So please keep the wrapper.

Like this?

> I guess at some point we should decide what to do with all
> the STMT_VINFO_ macros (and the others, {LOOP,BB}_ stuff
> is already used inconsistently).

Yeah...


2018-07-26  Richard Sandiford  <richard.sandif...@arm.com>

gcc/
        * tree-vectorizer.h (_stmt_vec_info::pattern_stmt_p): New field.
        (is_pattern_stmt_p): Use it.
        * tree-vect-patterns.c (vect_init_pattern_stmt): Set pattern_stmt_p
        on pattern statements.

Index: gcc/tree-vectorizer.h
===================================================================
--- gcc/tree-vectorizer.h       2018-07-26 11:28:18.000000000 +0100
+++ gcc/tree-vectorizer.h       2018-07-26 11:28:19.072951054 +0100
@@ -791,6 +791,12 @@ struct _stmt_vec_info {
   /* Stmt is part of some pattern (computation idiom)  */
   bool in_pattern_p;
 
+  /* True if the statement was created during pattern recognition as
+     part of the replacement for RELATED_STMT.  This implies that the
+     statement isn't part of any basic block, although for convenience
+     its gimple_bb is the same as for RELATED_STMT.  */
+  bool pattern_stmt_p;
+
   /* Is this statement vectorizable or should it be skipped in (partial)
      vectorization.  */
   bool vectorizable;
@@ -1157,8 +1163,7 @@ get_later_stmt (stmt_vec_info stmt1_info
 static inline bool
 is_pattern_stmt_p (stmt_vec_info stmt_info)
 {
-  stmt_vec_info related_stmt_info = STMT_VINFO_RELATED_STMT (stmt_info);
-  return related_stmt_info && STMT_VINFO_IN_PATTERN_P (related_stmt_info);
+  return stmt_info->pattern_stmt_p;
 }
 
 /* Return true if BB is a loop header.  */
Index: gcc/tree-vect-patterns.c
===================================================================
--- gcc/tree-vect-patterns.c    2018-07-26 11:28:18.000000000 +0100
+++ gcc/tree-vect-patterns.c    2018-07-26 11:28:19.068951168 +0100
@@ -108,6 +108,7 @@ vect_init_pattern_stmt (gimple *pattern_
     pattern_stmt_info = orig_stmt_info->vinfo->add_stmt (pattern_stmt);
   gimple_set_bb (pattern_stmt, gimple_bb (orig_stmt_info->stmt));
 
+  pattern_stmt_info->pattern_stmt_p = true;
   STMT_VINFO_RELATED_STMT (pattern_stmt_info) = orig_stmt_info;
   STMT_VINFO_DEF_TYPE (pattern_stmt_info)
     = STMT_VINFO_DEF_TYPE (orig_stmt_info);

Reply via email to