This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [mask-load, patch 1/2] Use boolean predicate for masked loads and store


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]