On Mon, 3 Aug 2020, Richard Biener wrote:
On Sat, Aug 1, 2020 at 9:29 AM Marc Glisse <marc.gli...@inria.fr> wrote:
Hello,
this transformation is quite straightforward, without overflow, 3*X==15 is
the same as X==5 and 3*X==5 cannot happen. Adding a single_use restriction
for the first case didn't seem necessary, although of course it can
slightly increase register pressure in some cases.
Bootstrap+regtest on x86_64-pc-linux-gnu.
OK with using constant_boolean_node (cmp == NE_EXPR, type).
ISTR we had the x * 0 == CST simplification somewhere
but maybe it was x * y == 0 ... ah, yes:
/* Transform comparisons of the form X * C1 CMP 0 to X CMP 0 in the
signed arithmetic case. That form is created by the compiler
often enough for folding it to be of value. One example is in
computing loop trip counts after Operator Strength Reduction. */
(for cmp (simple_comparison)
scmp (swapped_simple_comparison)
(simplify
(cmp (mult@3 @0 INTEGER_CST@1) integer_zerop@2)
As it is placed after your pattern it will be never matched I think
(but we don't warn because of INTEGER_CST vs. integer_zerop).
But I think your pattern subsumes it besides of the X * 0 == 0
compare - oh, and the other pattern also handles relational compares
(those will still trigger).
Maybe place the patterns next to each other? Also see whether
moving yours after the above will cease the testcases to be handled
because it's no longer matched - if not this might be the better
order.
I moved it after, it still works, so I pushed the patch. Note that the
other transformation has a single_use restriction, while this one doesn't,
that's not very consistent, but also hopefully not so important...
--
Marc Glisse