> > + if (TYPE_PRECISION (unprom_diff.type) != TYPE_PRECISION (abs_type) > > + && TYPE_UNSIGNED (unprom_diff.type) > > + && TYPE_UNSIGNED (abs_type)) > > The last line is now redundant, since TYPE_UNSIGNED was checked above.
Done. > > + // Failed to find a widen operation so we check for a regular MINUS_EXPR > > Nit: please use /* ... */ for files that currently use that style. Done. > > + if (diff_oprnds && diff > > + && gimple_assign_rhs_code (diff) == MINUS_EXPR) > > We also need to check TYPE_OVERFLOW_UNDEFINED (TREE_TYPE (abs_oprnd)), > since this case exploits undefined behaviour for signed subtraction. Done. > > + UABD expressions are used when the input types are > > + narrower than the output types or the output type is narrower > > + than 32 bits > > Isn't it only the first (input types narrower than the output types)? > I guess the second part is referring to the fact that, in C, an operation > on sub-32-bit values will happen in int and then be narrowed back down. > But in gimple that's all explicit, and it's the widening to int that > allows UABD to be used. (And UABD can then be used regardless of whether > the result is narrowed back down.) Dropped this block as it is no longer applicable. Must've been from a much earlier version of this patch. > Might as well drop signed_out_vectype and use vectype directly. Done. > > + if (!SAME_TYPE (TREE_TYPE (diff_oprnds[0]), TREE_TYPE > > (abd_oprnds[0]))) > > + return NULL; > > This shouldn't be necesary. The transformation would be correct > even if the subtraction is widened before the ABS, since we already > checked for signed promotion, and since we're only trying SABD. Done. Patch is in the next response.