On Thu, Oct 29, 2015 at 2:42 PM, Ilya Enkovich <enkovich....@gmail.com> wrote:
> Hi,
>
> This patches powerpc fails for c-c++-common/torture/vector-compare-1.c test.  
> The problem is that vector comparison lowering produces vector of 0s and 1s 
> instead of 0s and -1s.  It doesn't matter if it usage is also lowered (like 
> happens on ARM and i386 with -mno-sse) byt on powerpc we may have comparison 
> of doubles be lowered but following VEC_COND_EXPR not lowered.  It causes 
> wrong VEC_COND_EXPR result.  i checked this patch fixes the test.  Full 
> regression testing on powerpc64le-unknown-linux-gnu is in progress.  OK if no 
> regression?
>
> Thanks,
> Ilya
> --
> gcc/
>
> 2015-10-29  Ilya Enkovich  <enkovich....@gmail.com>
>
>         * tree-vect-generic.c (do_compare): Use -1 for true
>         result instead of 1.
>
>
> diff --git a/gcc/tree-vect-generic.c b/gcc/tree-vect-generic.c
> index d0a4e0f..0b60b15 100644
> --- a/gcc/tree-vect-generic.c
> +++ b/gcc/tree-vect-generic.c
> @@ -161,10 +161,27 @@ static tree
>  do_compare (gimple_stmt_iterator *gsi, tree inner_type, tree a, tree b,
>             tree bitpos, tree bitsize, enum tree_code code, tree type)
>  {
> +  tree stype = TREE_TYPE (type);
> +
>    a = tree_vec_extract (gsi, inner_type, a, bitsize, bitpos);
>    b = tree_vec_extract (gsi, inner_type, b, bitsize, bitpos);
>
> -  return gimplify_build2 (gsi, code, TREE_TYPE (type), a, b);
> +  if (TYPE_PRECISION (stype) > 1)
> +    {
> +      tree cst_false = build_zero_cst (stype);
> +      tree cst_true;
> +      tree cmp;
> +
> +      if (TYPE_UNSIGNED (stype))
> +       cst_true = TYPE_MAXVAL (stype);
> +      else
> +       cst_true = build_minus_one_cst (stype);
> +
> +      cmp = build2 (code, boolean_type_node, a, b);
> +      return gimplify_build3 (gsi, COND_EXPR, stype, cmp, cst_true, 
> cst_false);
> +    }

I think this should unconditionally produce the COND_EXPR and
build cst_true using build_all_ones_cst (stype).

Ok with that change.

Thanks,
Richard.

> +
> +  return gimplify_build2 (gsi, code, stype, a, b);
>  }
>
>  /* Expand vector addition to scalars.  This does bit twiddling

Reply via email to