public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] Avoid false vector mask conversion
@ 2015-11-12 16:09 Ilya Enkovich
  2015-11-13 10:04 ` Richard Biener
  2015-12-02 14:52 ` Richard Biener
  0 siblings, 2 replies; 10+ messages in thread
From: Ilya Enkovich @ 2015-11-12 16:09 UTC (permalink / raw)
  To: gcc-patches

Hi,

When we use LTO for fortran we may have a mix 32bit and 1bit scalar booleans. It means we may have conversion of one scalar type to another which confuses vectorizer because values with different scalar boolean type may get the same vectype.  This patch transforms such conversions into comparison.

I managed to make a small fortran test which gets vectorized with this patch but I didn't find how I can run fortran test with LTO and then scan tree dump to check it is vectorized.  BTW here is a loop from the test:

      real*8 a(18)
      logical b(18)
      integer i

      do i=1,18
         if(a(i).gt.0.d0) then
            b(i)=.true.
         else
            b(i)=.false.
         endif
      enddo

Bootstrapped and tested on x86_64-unknown-linux-gnu.  OK for trunk?

Thanks,
Ilya
--
gcc/

2015-11-12  Ilya Enkovich  <enkovich.gnu@gmail.com>

	* tree-vect-patterns.c (vect_recog_mask_conversion_pattern):
	Transform useless boolean conversion into assignment.


diff --git a/gcc/tree-vect-patterns.c b/gcc/tree-vect-patterns.c
index b9d900c..62070da 100644
--- a/gcc/tree-vect-patterns.c
+++ b/gcc/tree-vect-patterns.c
@@ -3674,6 +3674,38 @@ vect_recog_mask_conversion_pattern (vec<gimple *> *stmts, tree *type_in,
   if (TREE_CODE (TREE_TYPE (lhs)) != BOOLEAN_TYPE)
     return NULL;
 
+  /* Check conversion between boolean types of different sizes.
+     If no vectype is specified, then we have a regular mask
+     assignment with no actual conversion.  */
+  if (rhs_code == CONVERT_EXPR
+      && !STMT_VINFO_DATA_REF (stmt_vinfo)
+      && !STMT_VINFO_VECTYPE (stmt_vinfo))
+    {
+      if (TREE_CODE (rhs1) != SSA_NAME)
+	return NULL;
+
+      rhs1_type = search_type_for_mask (rhs1, vinfo);
+      if (!rhs1_type)
+	return NULL;
+
+      vectype1 = get_mask_type_for_scalar_type (rhs1_type);
+
+      if (!vectype1)
+	return NULL;
+
+      lhs = vect_recog_temp_ssa_var (TREE_TYPE (lhs), NULL);
+      pattern_stmt = gimple_build_assign (lhs, rhs1);
+
+      *type_out = vectype1;
+      *type_in = vectype1;
+      stmts->safe_push (last_stmt);
+      if (dump_enabled_p ())
+	dump_printf_loc (MSG_NOTE, vect_location,
+                         "vect_recog_mask_conversion_pattern: detected:\n");
+
+      return pattern_stmt;
+    }
+
   if (rhs_code != BIT_IOR_EXPR
       && rhs_code != BIT_XOR_EXPR
       && rhs_code != BIT_AND_EXPR)

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] Avoid false vector mask conversion
  2015-11-12 16:09 [PATCH] Avoid false vector mask conversion Ilya Enkovich
@ 2015-11-13 10:04 ` Richard Biener
  2015-11-13 13:17   ` Ilya Enkovich
  2015-12-02 14:52 ` Richard Biener
  1 sibling, 1 reply; 10+ messages in thread
From: Richard Biener @ 2015-11-13 10:04 UTC (permalink / raw)
  To: Ilya Enkovich; +Cc: GCC Patches

On Thu, Nov 12, 2015 at 5:08 PM, Ilya Enkovich <enkovich.gnu@gmail.com> wrote:
> Hi,
>
> When we use LTO for fortran we may have a mix 32bit and 1bit scalar booleans. It means we may have conversion of one scalar type to another which confuses vectorizer because values with different scalar boolean type may get the same vectype.

Confuses aka fails to vectorize?

>  This patch transforms such conversions into comparison.
>
> I managed to make a small fortran test which gets vectorized with this patch but I didn't find how I can run fortran test with LTO and then scan tree dump to check it is vectorized.  BTW here is a loop from the test:
>
>       real*8 a(18)
>       logical b(18)
>       integer i
>
>       do i=1,18
>          if(a(i).gt.0.d0) then
>             b(i)=.true.
>          else
>             b(i)=.false.
>          endif
>       enddo

This looks the the "error" comes from if-conversion - can't we do
better there then?

Richard.

> Bootstrapped and tested on x86_64-unknown-linux-gnu.  OK for trunk?
>
> Thanks,
> Ilya
> --
> gcc/
>
> 2015-11-12  Ilya Enkovich  <enkovich.gnu@gmail.com>
>
>         * tree-vect-patterns.c (vect_recog_mask_conversion_pattern):
>         Transform useless boolean conversion into assignment.
>
>
> diff --git a/gcc/tree-vect-patterns.c b/gcc/tree-vect-patterns.c
> index b9d900c..62070da 100644
> --- a/gcc/tree-vect-patterns.c
> +++ b/gcc/tree-vect-patterns.c
> @@ -3674,6 +3674,38 @@ vect_recog_mask_conversion_pattern (vec<gimple *> *stmts, tree *type_in,
>    if (TREE_CODE (TREE_TYPE (lhs)) != BOOLEAN_TYPE)
>      return NULL;
>
> +  /* Check conversion between boolean types of different sizes.
> +     If no vectype is specified, then we have a regular mask
> +     assignment with no actual conversion.  */
> +  if (rhs_code == CONVERT_EXPR
> +      && !STMT_VINFO_DATA_REF (stmt_vinfo)
> +      && !STMT_VINFO_VECTYPE (stmt_vinfo))
> +    {
> +      if (TREE_CODE (rhs1) != SSA_NAME)
> +       return NULL;
> +
> +      rhs1_type = search_type_for_mask (rhs1, vinfo);
> +      if (!rhs1_type)
> +       return NULL;
> +
> +      vectype1 = get_mask_type_for_scalar_type (rhs1_type);
> +
> +      if (!vectype1)
> +       return NULL;
> +
> +      lhs = vect_recog_temp_ssa_var (TREE_TYPE (lhs), NULL);
> +      pattern_stmt = gimple_build_assign (lhs, rhs1);
> +
> +      *type_out = vectype1;
> +      *type_in = vectype1;
> +      stmts->safe_push (last_stmt);
> +      if (dump_enabled_p ())
> +       dump_printf_loc (MSG_NOTE, vect_location,
> +                         "vect_recog_mask_conversion_pattern: detected:\n");
> +
> +      return pattern_stmt;
> +    }
> +
>    if (rhs_code != BIT_IOR_EXPR
>        && rhs_code != BIT_XOR_EXPR
>        && rhs_code != BIT_AND_EXPR)

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] Avoid false vector mask conversion
  2015-11-13 10:04 ` Richard Biener
@ 2015-11-13 13:17   ` Ilya Enkovich
  2015-11-23 13:15     ` Ilya Enkovich
  0 siblings, 1 reply; 10+ messages in thread
From: Ilya Enkovich @ 2015-11-13 13:17 UTC (permalink / raw)
  To: Richard Biener; +Cc: GCC Patches

2015-11-13 13:03 GMT+03:00 Richard Biener <richard.guenther@gmail.com>:
> On Thu, Nov 12, 2015 at 5:08 PM, Ilya Enkovich <enkovich.gnu@gmail.com> wrote:
>> Hi,
>>
>> When we use LTO for fortran we may have a mix 32bit and 1bit scalar booleans. It means we may have conversion of one scalar type to another which confuses vectorizer because values with different scalar boolean type may get the same vectype.
>
> Confuses aka fails to vectorize?

Right.

>
>>  This patch transforms such conversions into comparison.
>>
>> I managed to make a small fortran test which gets vectorized with this patch but I didn't find how I can run fortran test with LTO and then scan tree dump to check it is vectorized.  BTW here is a loop from the test:
>>
>>       real*8 a(18)
>>       logical b(18)
>>       integer i
>>
>>       do i=1,18
>>          if(a(i).gt.0.d0) then
>>             b(i)=.true.
>>          else
>>             b(i)=.false.
>>          endif
>>       enddo
>
> This looks the the "error" comes from if-conversion - can't we do
> better there then?

No, this loop is transformed into a single BB before if-conversion by
cselim + phiopt.

Ilya

>
> Richard.
>
>> Bootstrapped and tested on x86_64-unknown-linux-gnu.  OK for trunk?
>>
>> Thanks,
>> Ilya

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] Avoid false vector mask conversion
  2015-11-13 13:17   ` Ilya Enkovich
@ 2015-11-23 13:15     ` Ilya Enkovich
  2015-12-02 10:39       ` Ilya Enkovich
  0 siblings, 1 reply; 10+ messages in thread
From: Ilya Enkovich @ 2015-11-23 13:15 UTC (permalink / raw)
  To: Richard Biener; +Cc: GCC Patches

Ping

2015-11-13 16:17 GMT+03:00 Ilya Enkovich <enkovich.gnu@gmail.com>:
> 2015-11-13 13:03 GMT+03:00 Richard Biener <richard.guenther@gmail.com>:
>> On Thu, Nov 12, 2015 at 5:08 PM, Ilya Enkovich <enkovich.gnu@gmail.com> wrote:
>>> Hi,
>>>
>>> When we use LTO for fortran we may have a mix 32bit and 1bit scalar booleans. It means we may have conversion of one scalar type to another which confuses vectorizer because values with different scalar boolean type may get the same vectype.
>>
>> Confuses aka fails to vectorize?
>
> Right.
>
>>
>>>  This patch transforms such conversions into comparison.
>>>
>>> I managed to make a small fortran test which gets vectorized with this patch but I didn't find how I can run fortran test with LTO and then scan tree dump to check it is vectorized.  BTW here is a loop from the test:
>>>
>>>       real*8 a(18)
>>>       logical b(18)
>>>       integer i
>>>
>>>       do i=1,18
>>>          if(a(i).gt.0.d0) then
>>>             b(i)=.true.
>>>          else
>>>             b(i)=.false.
>>>          endif
>>>       enddo
>>
>> This looks the the "error" comes from if-conversion - can't we do
>> better there then?
>
> No, this loop is transformed into a single BB before if-conversion by
> cselim + phiopt.
>
> Ilya
>
>>
>> Richard.
>>
>>> Bootstrapped and tested on x86_64-unknown-linux-gnu.  OK for trunk?
>>>
>>> Thanks,
>>> Ilya

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] Avoid false vector mask conversion
  2015-11-23 13:15     ` Ilya Enkovich
@ 2015-12-02 10:39       ` Ilya Enkovich
  0 siblings, 0 replies; 10+ messages in thread
From: Ilya Enkovich @ 2015-12-02 10:39 UTC (permalink / raw)
  To: Richard Biener; +Cc: GCC Patches

Ping

2015-11-23 16:05 GMT+03:00 Ilya Enkovich <enkovich.gnu@gmail.com>:
> Ping
>
> 2015-11-13 16:17 GMT+03:00 Ilya Enkovich <enkovich.gnu@gmail.com>:
>> 2015-11-13 13:03 GMT+03:00 Richard Biener <richard.guenther@gmail.com>:
>>> On Thu, Nov 12, 2015 at 5:08 PM, Ilya Enkovich <enkovich.gnu@gmail.com> wrote:
>>>> Hi,
>>>>
>>>> When we use LTO for fortran we may have a mix 32bit and 1bit scalar booleans. It means we may have conversion of one scalar type to another which confuses vectorizer because values with different scalar boolean type may get the same vectype.
>>>
>>> Confuses aka fails to vectorize?
>>
>> Right.
>>
>>>
>>>>  This patch transforms such conversions into comparison.
>>>>
>>>> I managed to make a small fortran test which gets vectorized with this patch but I didn't find how I can run fortran test with LTO and then scan tree dump to check it is vectorized.  BTW here is a loop from the test:
>>>>
>>>>       real*8 a(18)
>>>>       logical b(18)
>>>>       integer i
>>>>
>>>>       do i=1,18
>>>>          if(a(i).gt.0.d0) then
>>>>             b(i)=.true.
>>>>          else
>>>>             b(i)=.false.
>>>>          endif
>>>>       enddo
>>>
>>> This looks the the "error" comes from if-conversion - can't we do
>>> better there then?
>>
>> No, this loop is transformed into a single BB before if-conversion by
>> cselim + phiopt.
>>
>> Ilya
>>
>>>
>>> Richard.
>>>
>>>> Bootstrapped and tested on x86_64-unknown-linux-gnu.  OK for trunk?
>>>>
>>>> Thanks,
>>>> Ilya

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] Avoid false vector mask conversion
  2015-11-12 16:09 [PATCH] Avoid false vector mask conversion Ilya Enkovich
  2015-11-13 10:04 ` Richard Biener
@ 2015-12-02 14:52 ` Richard Biener
  2015-12-02 15:25   ` Ilya Enkovich
  1 sibling, 1 reply; 10+ messages in thread
From: Richard Biener @ 2015-12-02 14:52 UTC (permalink / raw)
  To: Ilya Enkovich; +Cc: GCC Patches

On Thu, Nov 12, 2015 at 5:08 PM, Ilya Enkovich <enkovich.gnu@gmail.com> wrote:
> Hi,
>
> When we use LTO for fortran we may have a mix 32bit and 1bit scalar booleans. It means we may have conversion of one scalar type to another which confuses vectorizer because values with different scalar boolean type may get the same vectype.  This patch transforms such conversions into comparison.
>
> I managed to make a small fortran test which gets vectorized with this patch but I didn't find how I can run fortran test with LTO and then scan tree dump to check it is vectorized.  BTW here is a loop from the test:
>
>       real*8 a(18)
>       logical b(18)
>       integer i
>
>       do i=1,18
>          if(a(i).gt.0.d0) then
>             b(i)=.true.
>          else
>             b(i)=.false.
>          endif
>       enddo
>
> Bootstrapped and tested on x86_64-unknown-linux-gnu.  OK for trunk?
>
> Thanks,
> Ilya
> --
> gcc/
>
> 2015-11-12  Ilya Enkovich  <enkovich.gnu@gmail.com>
>
>         * tree-vect-patterns.c (vect_recog_mask_conversion_pattern):
>         Transform useless boolean conversion into assignment.
>
>
> diff --git a/gcc/tree-vect-patterns.c b/gcc/tree-vect-patterns.c
> index b9d900c..62070da 100644
> --- a/gcc/tree-vect-patterns.c
> +++ b/gcc/tree-vect-patterns.c
> @@ -3674,6 +3674,38 @@ vect_recog_mask_conversion_pattern (vec<gimple *> *stmts, tree *type_in,
>    if (TREE_CODE (TREE_TYPE (lhs)) != BOOLEAN_TYPE)
>      return NULL;
>
> +  /* Check conversion between boolean types of different sizes.
> +     If no vectype is specified, then we have a regular mask
> +     assignment with no actual conversion.  */
> +  if (rhs_code == CONVERT_EXPR

CONVERT_EXPR_CODE_P (rhs_code)

> +      && !STMT_VINFO_DATA_REF (stmt_vinfo)
> +      && !STMT_VINFO_VECTYPE (stmt_vinfo))
> +    {
> +      if (TREE_CODE (rhs1) != SSA_NAME)
> +       return NULL;
> +
> +      rhs1_type = search_type_for_mask (rhs1, vinfo);
> +      if (!rhs1_type)
> +       return NULL;
> +
> +      vectype1 = get_mask_type_for_scalar_type (rhs1_type);
> +
> +      if (!vectype1)
> +       return NULL;
> +
> +      lhs = vect_recog_temp_ssa_var (TREE_TYPE (lhs), NULL);
> +      pattern_stmt = gimple_build_assign (lhs, rhs1);

So what's the actual issue here?  That the conversion is spurious?
Why can't you accept this simply in vectorizable_assignment then?

Richard.

> +      *type_out = vectype1;
> +      *type_in = vectype1;
> +      stmts->safe_push (last_stmt);
> +      if (dump_enabled_p ())
> +       dump_printf_loc (MSG_NOTE, vect_location,
> +                         "vect_recog_mask_conversion_pattern: detected:\n");
> +
> +      return pattern_stmt;
> +    }
> +
>    if (rhs_code != BIT_IOR_EXPR
>        && rhs_code != BIT_XOR_EXPR
>        && rhs_code != BIT_AND_EXPR)

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] Avoid false vector mask conversion
  2015-12-02 14:52 ` Richard Biener
@ 2015-12-02 15:25   ` Ilya Enkovich
  2015-12-02 15:27     ` Richard Biener
  0 siblings, 1 reply; 10+ messages in thread
From: Ilya Enkovich @ 2015-12-02 15:25 UTC (permalink / raw)
  To: Richard Biener; +Cc: GCC Patches

2015-12-02 17:52 GMT+03:00 Richard Biener <richard.guenther@gmail.com>:
> On Thu, Nov 12, 2015 at 5:08 PM, Ilya Enkovich <enkovich.gnu@gmail.com> wrote:
>> Hi,
>>
>> When we use LTO for fortran we may have a mix 32bit and 1bit scalar booleans. It means we may have conversion of one scalar type to another which confuses vectorizer because values with different scalar boolean type may get the same vectype.  This patch transforms such conversions into comparison.
>>
>> I managed to make a small fortran test which gets vectorized with this patch but I didn't find how I can run fortran test with LTO and then scan tree dump to check it is vectorized.  BTW here is a loop from the test:
>>
>>       real*8 a(18)
>>       logical b(18)
>>       integer i
>>
>>       do i=1,18
>>          if(a(i).gt.0.d0) then
>>             b(i)=.true.
>>          else
>>             b(i)=.false.
>>          endif
>>       enddo
>>
>> Bootstrapped and tested on x86_64-unknown-linux-gnu.  OK for trunk?
>>
>> Thanks,
>> Ilya
>> --
>> gcc/
>>
>> 2015-11-12  Ilya Enkovich  <enkovich.gnu@gmail.com>
>>
>>         * tree-vect-patterns.c (vect_recog_mask_conversion_pattern):
>>         Transform useless boolean conversion into assignment.
>>
>>
>> diff --git a/gcc/tree-vect-patterns.c b/gcc/tree-vect-patterns.c
>> index b9d900c..62070da 100644
>> --- a/gcc/tree-vect-patterns.c
>> +++ b/gcc/tree-vect-patterns.c
>> @@ -3674,6 +3674,38 @@ vect_recog_mask_conversion_pattern (vec<gimple *> *stmts, tree *type_in,
>>    if (TREE_CODE (TREE_TYPE (lhs)) != BOOLEAN_TYPE)
>>      return NULL;
>>
>> +  /* Check conversion between boolean types of different sizes.
>> +     If no vectype is specified, then we have a regular mask
>> +     assignment with no actual conversion.  */
>> +  if (rhs_code == CONVERT_EXPR
>
> CONVERT_EXPR_CODE_P (rhs_code)
>
>> +      && !STMT_VINFO_DATA_REF (stmt_vinfo)
>> +      && !STMT_VINFO_VECTYPE (stmt_vinfo))
>> +    {
>> +      if (TREE_CODE (rhs1) != SSA_NAME)
>> +       return NULL;
>> +
>> +      rhs1_type = search_type_for_mask (rhs1, vinfo);
>> +      if (!rhs1_type)
>> +       return NULL;
>> +
>> +      vectype1 = get_mask_type_for_scalar_type (rhs1_type);
>> +
>> +      if (!vectype1)
>> +       return NULL;
>> +
>> +      lhs = vect_recog_temp_ssa_var (TREE_TYPE (lhs), NULL);
>> +      pattern_stmt = gimple_build_assign (lhs, rhs1);
>
> So what's the actual issue here?  That the conversion is spurious?
> Why can't you accept this simply in vectorizable_assignment then?

The problem is that conversion is supposed to be handled by
vectorizable_conversion,
but it fails to because it is not actually a conversion. I suppose it
may be handled
in vectorizable_assignment but I chose this pattern because it's meant
to handle mask
conversion issues.

Thanks,
Ilya

>
> Richard.
>
>> +      *type_out = vectype1;
>> +      *type_in = vectype1;
>> +      stmts->safe_push (last_stmt);
>> +      if (dump_enabled_p ())
>> +       dump_printf_loc (MSG_NOTE, vect_location,
>> +                         "vect_recog_mask_conversion_pattern: detected:\n");
>> +
>> +      return pattern_stmt;
>> +    }
>> +
>>    if (rhs_code != BIT_IOR_EXPR
>>        && rhs_code != BIT_XOR_EXPR
>>        && rhs_code != BIT_AND_EXPR)

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] Avoid false vector mask conversion
  2015-12-02 15:25   ` Ilya Enkovich
@ 2015-12-02 15:27     ` Richard Biener
  2015-12-04 15:01       ` Ilya Enkovich
  0 siblings, 1 reply; 10+ messages in thread
From: Richard Biener @ 2015-12-02 15:27 UTC (permalink / raw)
  To: Ilya Enkovich; +Cc: GCC Patches

On Wed, Dec 2, 2015 at 4:24 PM, Ilya Enkovich <enkovich.gnu@gmail.com> wrote:
> 2015-12-02 17:52 GMT+03:00 Richard Biener <richard.guenther@gmail.com>:
>> On Thu, Nov 12, 2015 at 5:08 PM, Ilya Enkovich <enkovich.gnu@gmail.com> wrote:
>>> Hi,
>>>
>>> When we use LTO for fortran we may have a mix 32bit and 1bit scalar booleans. It means we may have conversion of one scalar type to another which confuses vectorizer because values with different scalar boolean type may get the same vectype.  This patch transforms such conversions into comparison.
>>>
>>> I managed to make a small fortran test which gets vectorized with this patch but I didn't find how I can run fortran test with LTO and then scan tree dump to check it is vectorized.  BTW here is a loop from the test:
>>>
>>>       real*8 a(18)
>>>       logical b(18)
>>>       integer i
>>>
>>>       do i=1,18
>>>          if(a(i).gt.0.d0) then
>>>             b(i)=.true.
>>>          else
>>>             b(i)=.false.
>>>          endif
>>>       enddo
>>>
>>> Bootstrapped and tested on x86_64-unknown-linux-gnu.  OK for trunk?
>>>
>>> Thanks,
>>> Ilya
>>> --
>>> gcc/
>>>
>>> 2015-11-12  Ilya Enkovich  <enkovich.gnu@gmail.com>
>>>
>>>         * tree-vect-patterns.c (vect_recog_mask_conversion_pattern):
>>>         Transform useless boolean conversion into assignment.
>>>
>>>
>>> diff --git a/gcc/tree-vect-patterns.c b/gcc/tree-vect-patterns.c
>>> index b9d900c..62070da 100644
>>> --- a/gcc/tree-vect-patterns.c
>>> +++ b/gcc/tree-vect-patterns.c
>>> @@ -3674,6 +3674,38 @@ vect_recog_mask_conversion_pattern (vec<gimple *> *stmts, tree *type_in,
>>>    if (TREE_CODE (TREE_TYPE (lhs)) != BOOLEAN_TYPE)
>>>      return NULL;
>>>
>>> +  /* Check conversion between boolean types of different sizes.
>>> +     If no vectype is specified, then we have a regular mask
>>> +     assignment with no actual conversion.  */
>>> +  if (rhs_code == CONVERT_EXPR
>>
>> CONVERT_EXPR_CODE_P (rhs_code)
>>
>>> +      && !STMT_VINFO_DATA_REF (stmt_vinfo)
>>> +      && !STMT_VINFO_VECTYPE (stmt_vinfo))
>>> +    {
>>> +      if (TREE_CODE (rhs1) != SSA_NAME)
>>> +       return NULL;
>>> +
>>> +      rhs1_type = search_type_for_mask (rhs1, vinfo);
>>> +      if (!rhs1_type)
>>> +       return NULL;
>>> +
>>> +      vectype1 = get_mask_type_for_scalar_type (rhs1_type);
>>> +
>>> +      if (!vectype1)
>>> +       return NULL;
>>> +
>>> +      lhs = vect_recog_temp_ssa_var (TREE_TYPE (lhs), NULL);
>>> +      pattern_stmt = gimple_build_assign (lhs, rhs1);
>>
>> So what's the actual issue here?  That the conversion is spurious?
>> Why can't you accept this simply in vectorizable_assignment then?
>
> The problem is that conversion is supposed to be handled by
> vectorizable_conversion,
> but it fails to because it is not actually a conversion. I suppose it
> may be handled
> in vectorizable_assignment but I chose this pattern because it's meant
> to handle mask
> conversion issues.

I think it's always better to avoid patterns if you can.

Richard.

> Thanks,
> Ilya
>
>>
>> Richard.
>>
>>> +      *type_out = vectype1;
>>> +      *type_in = vectype1;
>>> +      stmts->safe_push (last_stmt);
>>> +      if (dump_enabled_p ())
>>> +       dump_printf_loc (MSG_NOTE, vect_location,
>>> +                         "vect_recog_mask_conversion_pattern: detected:\n");
>>> +
>>> +      return pattern_stmt;
>>> +    }
>>> +
>>>    if (rhs_code != BIT_IOR_EXPR
>>>        && rhs_code != BIT_XOR_EXPR
>>>        && rhs_code != BIT_AND_EXPR)

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] Avoid false vector mask conversion
  2015-12-02 15:27     ` Richard Biener
@ 2015-12-04 15:01       ` Ilya Enkovich
  2015-12-10 11:18         ` Richard Biener
  0 siblings, 1 reply; 10+ messages in thread
From: Ilya Enkovich @ 2015-12-04 15:01 UTC (permalink / raw)
  To: Richard Biener; +Cc: GCC Patches

On 02 Dec 16:27, Richard Biener wrote:
> On Wed, Dec 2, 2015 at 4:24 PM, Ilya Enkovich <enkovich.gnu@gmail.com> wrote:
> >
> > The problem is that conversion is supposed to be handled by
> > vectorizable_conversion,
> > but it fails to because it is not actually a conversion. I suppose it
> > may be handled
> > in vectorizable_assignment but I chose this pattern because it's meant
> > to handle mask
> > conversion issues.
> 
> I think it's always better to avoid patterns if you can.
> 
> Richard.
> 

Here is a variant with vectorizable_assignment change.  Bootstrapped and regtested on x86_64-unknown-linux-gnu.  Does it look better?

Thanks,
Ilya
--
gcc/

2015-12-04  Ilya Enkovich  <enkovich.gnu@gmail.com>

	* tree-vect-stmts.c (vectorizable_assignment): Support
	useless boolean conversion.


diff --git a/gcc/tree-vect-stmts.c b/gcc/tree-vect-stmts.c
index 3b078da..2cdbb04 100644
--- a/gcc/tree-vect-stmts.c
+++ b/gcc/tree-vect-stmts.c
@@ -4229,7 +4229,12 @@ vectorizable_assignment (gimple *stmt, gimple_stmt_iterator *gsi,
       /* But a conversion that does not change the bit-pattern is ok.  */
       && !((TYPE_PRECISION (TREE_TYPE (scalar_dest))
 	    > TYPE_PRECISION (TREE_TYPE (op)))
-	   && TYPE_UNSIGNED (TREE_TYPE (op))))
+	   && TYPE_UNSIGNED (TREE_TYPE (op)))
+      /* Conversion between boolean types of different sizes is
+	 a simple assignment in case their vectypes are same
+	 boolean vectors.  */
+      && (!VECTOR_BOOLEAN_TYPE_P (vectype)
+	  || !VECTOR_BOOLEAN_TYPE_P (vectype_in)))
     {
       if (dump_enabled_p ())
         dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] Avoid false vector mask conversion
  2015-12-04 15:01       ` Ilya Enkovich
@ 2015-12-10 11:18         ` Richard Biener
  0 siblings, 0 replies; 10+ messages in thread
From: Richard Biener @ 2015-12-10 11:18 UTC (permalink / raw)
  To: Ilya Enkovich; +Cc: GCC Patches

On Fri, Dec 4, 2015 at 4:00 PM, Ilya Enkovich <enkovich.gnu@gmail.com> wrote:
> On 02 Dec 16:27, Richard Biener wrote:
>> On Wed, Dec 2, 2015 at 4:24 PM, Ilya Enkovich <enkovich.gnu@gmail.com> wrote:
>> >
>> > The problem is that conversion is supposed to be handled by
>> > vectorizable_conversion,
>> > but it fails to because it is not actually a conversion. I suppose it
>> > may be handled
>> > in vectorizable_assignment but I chose this pattern because it's meant
>> > to handle mask
>> > conversion issues.
>>
>> I think it's always better to avoid patterns if you can.
>>
>> Richard.
>>
>
> Here is a variant with vectorizable_assignment change.  Bootstrapped and regtested on x86_64-unknown-linux-gnu.  Does it look better?

Yes.

Thanks,
Richard.

> Thanks,
> Ilya
> --
> gcc/
>
> 2015-12-04  Ilya Enkovich  <enkovich.gnu@gmail.com>
>
>         * tree-vect-stmts.c (vectorizable_assignment): Support
>         useless boolean conversion.
>
>
> diff --git a/gcc/tree-vect-stmts.c b/gcc/tree-vect-stmts.c
> index 3b078da..2cdbb04 100644
> --- a/gcc/tree-vect-stmts.c
> +++ b/gcc/tree-vect-stmts.c
> @@ -4229,7 +4229,12 @@ vectorizable_assignment (gimple *stmt, gimple_stmt_iterator *gsi,
>        /* But a conversion that does not change the bit-pattern is ok.  */
>        && !((TYPE_PRECISION (TREE_TYPE (scalar_dest))
>             > TYPE_PRECISION (TREE_TYPE (op)))
> -          && TYPE_UNSIGNED (TREE_TYPE (op))))
> +          && TYPE_UNSIGNED (TREE_TYPE (op)))
> +      /* Conversion between boolean types of different sizes is
> +        a simple assignment in case their vectypes are same
> +        boolean vectors.  */
> +      && (!VECTOR_BOOLEAN_TYPE_P (vectype)
> +         || !VECTOR_BOOLEAN_TYPE_P (vectype_in)))
>      {
>        if (dump_enabled_p ())
>          dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2015-12-10 11:18 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-12 16:09 [PATCH] Avoid false vector mask conversion Ilya Enkovich
2015-11-13 10:04 ` Richard Biener
2015-11-13 13:17   ` Ilya Enkovich
2015-11-23 13:15     ` Ilya Enkovich
2015-12-02 10:39       ` Ilya Enkovich
2015-12-02 14:52 ` Richard Biener
2015-12-02 15:25   ` Ilya Enkovich
2015-12-02 15:27     ` Richard Biener
2015-12-04 15:01       ` Ilya Enkovich
2015-12-10 11:18         ` 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).