]> git.ipfire.org Git - thirdparty/gcc.git/commit
CCP: handle division by a power of 2 as a right shift.
authorAldy Hernandez <aldyh@redhat.com>
Sun, 6 Nov 2022 19:38:42 +0000 (20:38 +0100)
committerAldy Hernandez <aldyh@redhat.com>
Tue, 8 Nov 2022 15:10:10 +0000 (16:10 +0100)
commit215355d302d8602c7eeefb9c927a3dbb221714c8
tree6e26101f73122dba6f403975dbe65e5db6533fe1
parentcb0a2b1f28cf0c231bf38fcd02c40689739df7bb
CCP: handle division by a power of 2 as a right shift.

We have some code in range-ops that sets better maybe nonzero bits for
TRUNC_DIV_EXPR by a power of 2 than CCP does, by just shifting the
mask.  I'd like to offload this functionality into the CCP mask
tracking code, which already does the right thing for right shifts.

The testcase for this change is gcc.dg/tree-ssa/vrp123.c and
gcc.dg/tree-ssa/pr107541.c.

gcc/ChangeLog:

* range-op.cc (operator_div::fold_range): Call
update_known_bitmask.
* tree-ssa-ccp.cc (bit_value_binop): Handle divisions by powers of
2 as a right shift.
gcc/range-op.cc
gcc/tree-ssa-ccp.cc