diff mbox

Fix segfault in vectorizer

Message ID 2255626.csdKOj6i2x@polaris
State New
Headers show

Commit Message

Eric Botcazou May 31, 2016, 5:46 p.m. UTC
> This code appears when we try to disable boolean patterns.  Boolean patterns
> replace booleans with integers of proper size which allow us to simply
> determine vectype using get_vectype_for_scalar_type.  With no such
> replacement we can't determine vectype just out of a scalar type (there are
> multiple possible options and get_vectype_for_scalar_type use would result
> in a lot of redundant conversions).  So we delay vectype computation for
> them and compute it basing on vectypes computed for their arguments.

OK, thanks for the explanation.  It would be nice to document that somewhere 
in the code if this isn't already done.

> Surely any missing vectype for a statement due to this delay is a bug.  I
> didn't notice STMT_VINFO_LIVE_P should be checked in addition to
> STMT_VINFO_RELEVANT_P.

That works indeed and generates no regression.  OK for mainline and 6 branch?


2016-05-31  Eric Botcazou  <ebotcazou@adacore.com>

	* tree-vect-loop.c (vect_determine_vectorization_factor): Also take
	into account live statements for mask producers.


2016-05-31  Eric Botcazou  <ebotcazou@adacore.com>

	* gnat.dg/opt56.ad[sb]: New test.

Comments

Richard Biener June 1, 2016, 9:44 a.m. UTC | #1
On Tue, May 31, 2016 at 7:46 PM, Eric Botcazou <ebotcazou@adacore.com> wrote:
>> This code appears when we try to disable boolean patterns.  Boolean patterns
>> replace booleans with integers of proper size which allow us to simply
>> determine vectype using get_vectype_for_scalar_type.  With no such
>> replacement we can't determine vectype just out of a scalar type (there are
>> multiple possible options and get_vectype_for_scalar_type use would result
>> in a lot of redundant conversions).  So we delay vectype computation for
>> them and compute it basing on vectypes computed for their arguments.
>
> OK, thanks for the explanation.  It would be nice to document that somewhere
> in the code if this isn't already done.
>
>> Surely any missing vectype for a statement due to this delay is a bug.  I
>> didn't notice STMT_VINFO_LIVE_P should be checked in addition to
>> STMT_VINFO_RELEVANT_P.
>
> That works indeed and generates no regression.  OK for mainline and 6 branch?

Yes.

Thanks,
Richard.

>
> 2016-05-31  Eric Botcazou  <ebotcazou@adacore.com>
>
>         * tree-vect-loop.c (vect_determine_vectorization_factor): Also take
>         into account live statements for mask producers.
>
>
> 2016-05-31  Eric Botcazou  <ebotcazou@adacore.com>
>
>         * gnat.dg/opt56.ad[sb]: New test.
>
> --
> Eric Botcazou
diff mbox

Patch

Index: tree-vect-loop.c
===================================================================
--- tree-vect-loop.c	(revision 236877)
+++ tree-vect-loop.c	(working copy)
@@ -441,7 +441,8 @@  vect_determine_vectorization_factor (loo
 		  && is_gimple_assign (stmt)
 		  && gimple_assign_rhs_code (stmt) != COND_EXPR)
 		{
-		  if (STMT_VINFO_RELEVANT_P (stmt_info))
+		  if (STMT_VINFO_RELEVANT_P (stmt_info)
+		      || STMT_VINFO_LIVE_P (stmt_info))
 		    mask_producers.safe_push (stmt_info);
 		  bool_result = true;