On 9/26/22 11:24, Aldy Hernandez via Gcc-patches wrote:
For [0 = x & MASK], we can determine that x is ~MASK.  This is
something we're picking up in DOM thanks to maybe_set_nonzero_bits,
but is something we should handle natively.

This is a good example of how much easier to maintain the range-ops
entries are versus the ad-hoc pattern matching stuff we had to do
before.  For the curious, compare the changes to range-op here,
versus maybe_set_nonzero_bits.

I'm leaving the call to maybe_set_nonzero_bits until I can properly
audit it to make sure we're catching it all in range-ops.  It won't
hurt, since both set_range_info() and set_nonzero_bits() are
intersect operations, so we'll never lose information if we do both.

Tested on x86-64 Linux.

        PR tree-optimization/107009

gcc/ChangeLog:

        * range-op.cc (operator_bitwise_and::op1_range): Optimize 0 = x & MASK.
        (range_op_bitwise_and_tests): New test.

Umm,


0 = x & MASK;


Just means that X has no bits set in MASK.   So you can use it to set nonzero-bits to ~MASK like your patch does and you can use that to refine a result.  So it's really the comment that is misleading/wrong.


jeff

Reply via email to