This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [mask-load, patch 1/2] Use boolean predicate for masked loads and store
- From: Ilya Enkovich <enkovich dot gnu at gmail dot com>
- To: Richard Biener <richard dot guenther at gmail dot com>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Fri, 23 Oct 2015 13:36:55 +0300
- Subject: Re: [mask-load, patch 1/2] Use boolean predicate for masked loads and store
- Authentication-results: sourceware.org; auth=none
- References: <20151008154029 dot GH63757 at msticlxl57 dot ims dot intel dot com> <CAFiYyc0ZsaGUhoqxjeFnDs7LOTn9-pVQve2HKP-BY9ygN71Zwg at mail dot gmail dot com> <CAMbmDYb1jvdHuR-qpc=DngjRJgPcKsWz99sgi9S_zRwG6fBPOA at mail dot gmail dot com> <CAFiYyc2rHBcdd9toVqoyDy6gL8RCkOQkLdeb-Jhqrhr0XGN=Rg at mail dot gmail dot com>
2015-10-23 13:32 GMT+03:00 Richard Biener <richard.guenther@gmail.com>:
> On Fri, Oct 23, 2015 at 12:23 PM, Ilya Enkovich <enkovich.gnu@gmail.com> wrote:
>> 2015-10-23 12:59 GMT+03:00 Richard Biener <richard.guenther@gmail.com>:
>>>
>>> ICK. So what does the above do? It basically preserves the boolean condition
>>> as "mask" unless ... we ought to swap it (formerly easy, just swap arguments
>>> of the cond_expr, now a bit harder, we need to invert the condition). But I
>>> don't understand the 'negate' dance. It looks like you want to have mask
>>> not be bool != 0 or bool == 1 but just bool in this case. I suggest you
>>> rework this to do sth like
>>
>> That's right, I want to avoid ==,!= comparisons with 0 and 1 by either
>> using compared SSA_NAME
>> or SSA_NAME != 0 (negate case).
>>
>>>
>>> gimple_seq stmts = NULL;
>>> gcc_assert (types_compatible_p (TREE_TYPE (cond), boolean_type_node));
>>
>> Is it really valid assert? Compiling fortran test with LTO I may have
>> logical(kind=4) [aka 32bit boolean]
>> type for cond and single bit _Bool for boolean_type_node.
>
> I put it there to make sure it is because otherwise the use of boolean_type_node
> below needs adjustment (boolean_true_node as well). TREE_TYPE (cond)
> would work and constant_boolean_node (true, TREE_TYPE (cond)) for
> boolean_type_node.
>
> Yes, you are right.
>
>>> if (TREE_CODE (cond) == SSA_NAME)
>>> ;
>>> else if (COMPARISON_CLASS_P (cond))
>>> mask = gimple_build (&stmts, TREE_CODE (cond), boolean_type_node,
>>> TREE_OPERAND (cond, 0), TREE_OPERAND (cond, 1));
>>> else
>>> gcc_unreachable ();
>>> if (swap)
>>> mask = gimple_build (&stmts, BIT_XOR_EXPR, boolean_type_node,
>>> mask, boolean_true_node);
>>> gsi_insert_seq_before (&gsi, stmts, GSI_SAME_STMT);
>>>
>>> which should do all of the above.
>>
>> Thus we would get smth like
>>
>> mask_1 = bool != 1
>> mask_2 = mask_1 XOR 1
>> _ifc_ = mask_2
>
> No, we'd get
>
> mask_1 = bool != 1;
>
> and the 'mask' variable should have been simplified to 'bool'
> (yes, we'd insert a dead stmt). gimple_build simplifies
> stmts via the match-and-simplify machinery and match.pd
> knows how to invert conditions.
>
Thanks! I'll try it.
Ilya