On Wed, Sep 7, 2011 at 3:15 PM, Artem Shinkarov
<artyom.shinkar...@gmail.com> wrote:
> On Tue, Sep 6, 2011 at 3:56 PM, Richard Guenther
> <richard.guent...@gmail.com> wrote:
>> On Tue, Sep 6, 2011 at 4:50 PM, Artem Shinkarov
>> <artyom.shinkar...@gmail.com> wrote:
>>> Here is a new version of the patch which considers the changes from
>>> 2011-09-02  Richard Guenther
>>>
>>>
>>> ChangeLog
>>>
>>> 20011-09-06 Artjoms Sinkarovs <artyom.shinkar...@gmail.com>
>>>
>>>       gcc/
>>>       * fold-const.c (constant_boolean_node): Adjust the meaning
>>>       of boolean for vector types: true = {-1,..}, false = {0,..}.
>>>       (fold_unary_loc): Avoid conversion of vector comparison to
>>>       boolean type.
>>
>> Both changes have already been done.
>
> I missed the way you applied constant_boolean node, sorry for that.
> But fold_unary_loc seems confusing to me. We have the following code:
>
>          else if (!INTEGRAL_TYPE_P (type))
>            return build3_loc (loc, COND_EXPR, type, op0,
>                               constant_boolean_node (true, type),
>                               constant_boolean_node (false, type));
>
> But this is wrong for the vector types, because it should construct
> VEC_COND_EXPR, not COND_EXPR. That is why I had a special case for
> vectors.

Ah, yeah.  I'll fix that.

The patch looks ok to me from a middle-end point of view.  Thus, if
Joseph is fine with it and Uros is, with the i386 piece the patch is ok.

Thanks,
Richard.

>>>       * expr.c (expand_expr_real_2): Expand vector comparison by
>>>       building an appropriate VEC_COND_EXPR.
>>
>> I prefer
>>
>> Index: gcc/expr.c
>> ===================================================================
>> *** gcc/expr.c.orig     2011-08-29 11:48:23.000000000 +0200
>> --- gcc/expr.c  2011-08-29 12:58:59.000000000 +0200
>> *************** do_store_flag (sepops ops, rtx target, e
>> *** 10309,10314 ****
>> --- 10309,10325 ----
>>    STRIP_NOPS (arg0);
>>    STRIP_NOPS (arg1);
>>
>> +   /* For vector typed comparisons emit code to generate the desired
>> +      all-ones or all-zeros mask.  Conveniently use the VEC_COND_EXPR
>> +      expander for this.  */
>> +   if (TREE_CODE (ops->type) == VECTOR_TYPE)
>> +     {
>> +       tree ifexp = build2 (ops->code, ops->type, arg0, arg1);
>> +       tree if_true = constant_boolean_node (true, ops->type);
>> +       tree if_false = constant_boolean_node (false, ops->type);
>> +       return expand_vec_cond_expr (ops->type, ifexp, if_true,
>> if_false, target);
>> +     }
>> +
>>    /* Get the rtx comparison code to use.  We know that EXP is a comparison
>>
>> as I said multiple times.
>>
>>>       * c-typeck.c (build_binary_op): Typecheck vector comparisons.
>>>       (c_objc_common_truthvalue_conversion): Adjust.
>>>       * tree-vect-generic.c (do_compare): Helper function.
>>>       (expand_vector_comparison): Check if hardware supports
>>>       vector comparison of the given type or expand vector
>>>       piecewise.
>>>       (expand_vector_operation): Treat comparison as binary
>>>       operation of vector type.
>>>       (expand_vector_operations_1): Adjust.
>>>       * tree-cfg.c (verify_gimple_comparison): Adjust.
>>
>> The tree-cfg.c change has already been done.
>>
>> Richard.
>>
>>>
>>>       gcc/config/i386
>>>       * i386.c (ix86_expand_sse_movcc): Consider a case when
>>>       vcond operators are {-1,..} and {0,..}.
>>>
>>>       gcc/doc
>>>       * extend.texi: Adjust.
>>>
>>>       gcc/testsuite
>>>       * gcc.c-torture/execute/vector-compare-1.c: New test.
>>>       * gcc.c-torture/execute/vector-compare-2.c: New test.
>>>       * gcc.dg/vector-compare-1.c: New test.
>>>       * gcc.dg/vector-compare-2.c: New test.
>>>
>>> bootstrapped and tested on x86_64-unknown-linux-gnu.
>>>
>>>
>>> Thanks,
>>> Artem.
>>>
>>
>
> All the rest is adjusted in the new version of the patch you can find
> in the attachment.
>
> ChangLog
>
>
> 20011-09-06 Artjoms Sinkarovs <artyom.shinkar...@gmail.com>
>
>      gcc/
>      * expr.c (do_store_flag): Expand vector comparison by
>      building an appropriate VEC_COND_EXPR.
>      * c-typeck.c (build_binary_op): Typecheck vector comparisons.
>      (c_objc_common_truthvalue_conversion): Adjust.
>      * tree-vect-generic.c (do_compare): Helper function.
>      (expand_vector_comparison): Check if hardware supports
>      vector comparison of the given type or expand vector
>      piecewise.
>      (expand_vector_operation): Treat comparison as binary
>      operation of vector type.
>      (expand_vector_operations_1): Adjust.
>
>      gcc/config/i386
>      * i386.c (ix86_expand_sse_movcc): Consider a case when
>      vcond operators are {-1,..} and {0,..}.
>
>      gcc/doc
>      * extend.texi: Adjust.
>
>      gcc/testsuite
>      * gcc.c-torture/execute/vector-compare-1.c: New test.
>      * gcc.c-torture/execute/vector-compare-2.c: New test.
>      * gcc.dg/vector-compare-1.c: New test.
>      * gcc.dg/vector-compare-2.c: New test.
>
> bootstrapped and tested on x86_64-unknown-linux-gnu.
>

Reply via email to