In the pattern X - (X / Y) * Y to X % Y, this patch guards the
simplification for vector types by a check for:
1) Support of the mod optab for vectors OR
2) Application during early gimple passes (using PROP_gimple_any).
This is to prevent reverting vectorization of modulo to div/mult/sub
if the target does not support vector mod optab, while still allowing
the simplification during early gimple passes (as tested, for example,
in gcc.dg/fold-minus-1.c).

The patch was bootstrapped and regtested on aarch64-linux-gnu, no regression.
OK for mainline?

Signed-off-by: Jennifer Schmitz <jschm...@nvidia.com>

gcc/
        PR tree-optimization/116569
        * generic-match-head.cc (optimize_early_gimple_p): Add inline
        function with mask for early gimple passes.
        * gimple-match-head.cc (optimize_early_gimple_p): Likewise.
        * match.pd: Guard simplification to trunc_mod with check for
        mod optab support.

gcc/testsuite/
        PR tree-optimization/116569
        * gcc.dg/torture/pr116569.c: New test.

Attachment: 0001-PR116569-match.pd-Check-trunc_mod-vector-obtap-befor.patch
Description: Binary data

Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to