On Mon, Jul 24, 2023 at 03:29:54PM -0400, Drew Ross via Gcc-patches wrote: > So would something like > > (simplify > (rshift (nop_convert? (lshift @0 INTEGER_CST@1)) @@1) > (with { tree stype = build_nonstandard_integer_type (1, 0); } > (if (INTEGRAL_TYPE_P (type) > && !TYPE_UNSIGNED (type) > && wi::eq_p (wi::to_wide (@1), element_precision (type) - 1)) > (convert (convert:stype @0))))) > > work?
Certainly swap the if and with and the (with then should be indented by 1 column to the right of (if and (convert one further (the reason for the swapping is not to call build_nonstandard_integer_type when it will not be needed, which will be probably far more often then an actual match). As discussed privately, the above isn't what we want for vectors and the 2 shifts are probably best on most arches because even when using -(x & 1) the { 1, 1, 1, ... } vector would often needed to be loaded from memory. Jakub