On Sat, Aug 27, 2011 at 3:39 AM, Artem Shinkarov <[email protected]> wrote: > Hi > > Here is a patch with vector comparison only. > Comparison is expanded using VEC_COND_EXPR, conversions between the > different types inside the VEC_COND_EXPR are happening in optabs.c.
I have split out the middle-end infrastructure parts to support vector
comparisons apart from the expansion piece and am testing this
(see attached, I adjusted some minor bits). I will commit this if
testing goes ok.
Looking over the rest I wonder why you need to avoid legitimizing stuff
in vector_compare_rtx? I can't produce any error with x86_64 or i586,
but on i586 gcc.c-torture/execute/vector-compare-1.c does not build
because
/space/rguenther/src/svn/trunk/gcc/testsuite/gcc.c-torture/execute/vector-compare-1.c:118:5:
error: incompatible types when assigning to type '__vector(2) long
int' from type '__vector(2) long long int'^M
so the testcases need double-checking for this kind of errors. You
can run tests for both -m32 and -m64 with a command-line like
make check-gcc RUNTESTFLAGS="--target_board=unix/\{,-m32\}
dg.exp=vector-compare*.c"
I'd like to further split the optabs.c and expr.c change which look
independent.
I have the attached incremental patch ontop of yours, I will test the
expr.c and optabs.c parts separately and plan to commit them as well
if that succeeds.
Richard.
> The comparison generally works, however, the x86 backend does not
> recognize vectors of all 1s of type float and double, which is very
> bad, but I hope it could be fixed easily. Here is my humble attempt:
>
> Index: gcc/config/i386/predicates.md
> ===================================================================
> --- gcc/config/i386/predicates.md (revision 177665)
> +++ gcc/config/i386/predicates.md (working copy)
> @@ -763,7 +763,19 @@ (define_predicate "vector_all_ones_opera
> for (i = 0; i < nunits; ++i)
> {
> rtx x = CONST_VECTOR_ELT (op, i);
> - if (x != constm1_rtx)
> + rtx y;
> +
> + if (GET_MODE_CLASS (GET_MODE (x)) == MODE_FLOAT)
> + {
> + REAL_VALUE_TYPE r;
> + REAL_VALUE_FROM_INT (r, -1, -1, GET_MODE (x));
> + y = CONST_DOUBLE_FROM_REAL_VALUE (r, GET_MODE (x));
> + }
> + else
> + y = constm1_rtx;
> +
> + /* if (x != constm1_rtx) */
> + if (!rtx_equal_p (x, y))
> return false;
> }
> return true;
>
> But the problem I have here is that -1 actually converts to -1.0,
> where I need to treat -0x1 as float. Something like:
>
> int p = -1;
> void *x = &p;
> float r = *((float *)x);
>
> Is there any way to do that in this context? Or may be there is
> another way to support real-typed vectors of -1 as constants?
>
>
> ChangeLog
>
> 20011-08-27 Artjoms Sinkarovs <[email protected]>
>
> gcc/
> * optabs.c (vector_compare_rtx): Allow comparison operands
> and vcond operands have different type.
> (expand_vec_cond_expr): Convert operands in case they do
> not match.
> * 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.
> * expr.c (expand_expr_real_2): 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.
> * gimplify.c (gimplify_expr): Support vector comparison
> in gimple.
> * tree.def: Adjust comment.
> * 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.
>
> 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.
>
>
> Artem.
>
vec-compare.v7.diff.r
Description: Binary data
p
Description: Binary data
