Use bit-CCP in range-ops.
authorAldy Hernandez <aldyh@redhat.com>
Sun, 6 Nov 2022 12:05:39 +0000 (13:05 +0100)
committerAldy Hernandez <aldyh@redhat.com>
Tue, 8 Nov 2022 14:17:14 +0000 (15:17 +0100)
commitb74dd1bbd2a02a0755bc882c6e64964b2a47ba5d
treee370ae531c043421fde6d528f95e6a99d3e0c5dd
parent7ca912b46e0eb45ebefeb0eda4c28afe1513d272
Use bit-CCP in range-ops.

After Jakub and Richi's suggestion of using the same representation
for tracking known bits as we do in CCP, I took a peek at the code and
realized there's a plethora of bit-tracking code there that we could
be sharing with range-ops.  For example, the multiplication
optimizations are way better than what I had cobbled together.  For
that matter, our maybe nonzero tracking as a whole has a lot of room
for improvement.  Being the lazy ass that I am, I think we should just
use one code base (CCP's).

This patch provides a thin wrapper for converting the irange maybe
nonzero bits to what CCP requires, and uses that to call into
bit_value_binop().  I have so far converted the MULT_EXPR range-op
entry to use it, as the DIV_EXPR entry we have gets a case CCP doesn't
get so I'd like to contribute the enhancement to CCP before converting
over.

I'd like to use this approach with the dozen or so tree_code's that
are handled in CCP, thus saving us from having to implement any of
them :).

Early next season I'd like to change irange's internal representation
to a pair of value / mask, and start tracking all known bits.  This
ties in nicely with our plan for tracking known set bits.

Perhaps if the stars align, we could merge the bit twiddling in CCP
into range-ops and have a central repository for it.  That is, once we
make the switch to wide-ints, and assuming there are no performance
issues.  Note that range-ops is our lowest level abstraction.
i.e. it's just the math, there's no GORI or ranger, or even the
concept of a symbolic or SSA.

gcc/ChangeLog:

* range-op.cc (irange_to_masked_value): New.
(update_known_bitmask): New.
(operator_mult::fold_range): Call update_known_bitmask.
gcc/range-op.cc