------- Comment #8 from rguenth at gcc dot gnu dot org 2010-06-13 12:25 -------
(In reply to comment #7)
> (In reply to comment #6)
> > (In reply to comment #5)
> > > The bug is in creation of a neutral value for BIT_AND_EXPR. What is the
> > > correct
> > > way to create it for all types? I found
> > > double-int.h:#define ALL_ONES (~((unsigned HOST_WIDE_INT) 0))
> > > but it won't work for signed.
> >
> > build_int_cst (type, -1)
>
> OK, thanks.
>
> >
> > At least in tree-vect-slp.c:1669 this seems to be buggy. The
> > case for BIT_AND_EXPR should be separated from that of MULT_EXPR.
>
> Right, this is buggy too, but the failure here is in reduction
> (get_initial_def_for_reduction), not in SLP.
>
> Is it safe to assume that operands of BIT_AND_EXPR are of integral type?
Yes, I think so (vector types are ok as well, but we don't vectorize with
vector types around, maybe fixed-point types are ok as well, but we
have no vector modes for them)
> If so,
> I'll test the following patch:
>
> Index: tree-vect-loop.c
> ===================================================================
> --- tree-vect-loop.c (revision 160524)
> +++ tree-vect-loop.c (working copy)
> @@ -2871,12 +2871,15 @@ get_initial_def_for_reduction (gimple st
> *adjustment_def = init_val;
> }
>
> - if (code == MULT_EXPR || code == BIT_AND_EXPR)
> + if (code == MULT_EXPR)
> {
> real_init_val = dconst1;
> int_init_val = 1;
> }
>
> + if (code == BIT_AND_EXPR)
> + int_init_val = -1;
> +
> if (SCALAR_FLOAT_TYPE_P (scalar_type))
> def_for_init = build_real (scalar_type, real_init_val);
> else
> Index: tree-vect-slp.c
> ===================================================================
> --- tree-vect-slp.c (revision 160524)
> +++ tree-vect-slp.c (working copy)
> @@ -1662,7 +1662,6 @@ vect_get_constant_vectors (slp_tree slp_
> break;
>
> case MULT_EXPR:
> - case BIT_AND_EXPR:
> if (SCALAR_FLOAT_TYPE_P (TREE_TYPE (op)))
> neutral_op = build_real (TREE_TYPE (op), dconst1);
> else
> @@ -1670,6 +1669,10 @@ vect_get_constant_vectors (slp_tree slp_
>
> break;
>
> + case BIT_AND_EXPR:
> + neutral_op = build_int_cst (TREE_TYPE (op), -1);
> + break;
> +
> default:
> neutral_op = NULL;
> }
Looks good.
Thanks,
Richard.
> Thanks,
> Ira
>
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44507