diff options
author | Jakub Jelinek <jakub@redhat.com> | 2020-10-21 10:51:33 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2020-10-21 10:54:47 +0200 |
commit | 5244b4af5e47bc98a2a9cf36f048981583a1b163 (patch) | |
tree | 6700b853da80be58b71937cb4a7bee63b0c9a660 /gcc/fortran/class.c | |
parent | 028a407463ce341487103abc877032384e6427bf (diff) | |
download | gcc-5244b4af5e47bc98a2a9cf36f048981583a1b163.zip gcc-5244b4af5e47bc98a2a9cf36f048981583a1b163.tar.gz gcc-5244b4af5e47bc98a2a9cf36f048981583a1b163.tar.bz2 |
phiopt: Optimize x ? __builtin_clz (x) : 32 in GIMPLE [PR97503]
While we have at the RTL level noce_try_ifelse_collapse combined with
simplify_cond_clz_ctz, that optimization doesn't always trigger because
e.g. on powerpc there is an define_insn to compare a reg against zero and
copy that register to another one and so we end up with a different pseudo
in the simplify_cond_clz_ctz test and punt.
For targets that define C?Z_DEFINED_VALUE_AT_ZERO to 2 for certain modes,
we can optimize it already in phiopt though, just need to ensure that
we transform the __builtin_c?z* calls into .C?Z ifns because my recent
VRP changes codified that the builtin calls are always undefined at zero,
while ifns honor C?Z_DEFINED_VALUE_AT_ZERO equal to 2.
And, in phiopt we already have popcount handling that does pretty much the
same thing, except for always using a zero value rather than the one set
by C?Z_DEFINED_VALUE_AT_ZERO.
So, this patch extends that function to handle not just popcount, but also
clz and ctz.
2020-10-21 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/97503
* tree-ssa-phiopt.c: Include internal-fn.h.
(cond_removal_in_popcount_pattern): Rename to ...
(cond_removal_in_popcount_clz_ctz_pattern): ... this. Handle not just
popcount, but also clz and ctz if it has C?Z_DEFINED_VALUE_AT_ZERO 2.
* gcc.dg/tree-ssa/pr97503.c: New test.
Diffstat (limited to 'gcc/fortran/class.c')
0 files changed, 0 insertions, 0 deletions