On 7/12/23 23:50, Jeff Law wrote:


On 7/12/23 15:15, Aldy Hernandez via Gcc-patches wrote:
This patch teaches popcount about known set bits which are now
available in the irange.

    PR tree-optimization/107053

gcc/ChangeLog:

    * gimple-range-op.cc (cfn_popcount): Use known set bits.

gcc/testsuite/ChangeLog:

    * gcc.dg/tree-ssa/pr107053.c: New test.
You could probably play similar games with ctz/clz, though it's hard to know if it's worth the effort.

One way to find out might be to build jemalloc which uses those idioms heavily.  Similarly for deepsjeng from spec2017.

Jeff


See class cfn_clz and class cfn_ctz in gimple-range-op.cc. There's already code for both of these, although they're throwback from the VRP era, so there's definitely room for improvement. I think they came from vr-values.cc.

Aldy

Reply via email to