Hi Raghesh,
Apologies for the delay.
> +/* Return the narrower of two integral types for predicated-index legality.
> + When precision matches, prefer unsigned (defined wrap semantics). */
> +
> +static tree
> +vect_pred_idx_narrower_int_type (tree t1, tree t2)
> +{
> + if (TYPE_PRECISION (t1) < TYPE_PRECISION (t2))
> + return t1;
> + if (TYPE_PRECISION (t2) < TYPE_PRECISION (t1))
> + return t2;
> + /* Same width: prefer unsigned, where wrap is defined. */
> + if (TYPE_UNSIGNED (t1) || TYPE_UNSIGNED (t2))
> + return TYPE_UNSIGNED (t1) ? t1 : t2;
Does the last condition work? If we have an int in the chain somewhere,
I think we, conservatively, still need INT_MAX instead of UINT_MAX.
But that's too conservative for some cases as well. So, structurally, I
guess the idea is correct but we can only take the unsigned type for
cases like (unsigned)(int)a, i.e. if it is last?
But... I think I lead you the wrong way :/ What's still missing here is
need is just the precision of the chain and, after we detected the
"scatter", whether we have a sign extension or a zero extension
eventually. So I guess it's better to defer the max_stmt_execution etc.
of this patch to when we actually link the phi and the store. So patch
1 would stand on its own then, and we'd take care of proper semantics
when linking with the store.
Also, I now realize that my COND_ADD suggestion doesn't work (because we
don't transform this in ifcvt yet). The signed->unsigned transformation
during ifcvt makes things slightly more difficult for us here. Another
case for doing ifcvt on the fly :)
--
Regards
Robin