tree-optimization/116514 - handle pointer difference in bit-CCP
commite7d5b9aa021f6fc32810670b18ffabe543262775
authorRichard Biener <rguenther@suse.de>
Wed, 28 Aug 2024 12:06:48 +0000 (28 14:06 +0200)
committerRichard Biener <rguenth@gcc.gnu.org>
Mon, 9 Sep 2024 13:02:26 +0000 (9 15:02 +0200)
treef3340ad130b425003e3cc5f5d4f67c724c3eeafe
parent898e3e95a6acf542baf03be95ce5bf7b3ad04276
tree-optimization/116514 - handle pointer difference in bit-CCP

When evaluating the difference of two aligned pointers in CCP we
fail to handle the EXACT_DIV_EXPR by the element size that occurs.
The testcase then also exercises modulo to test alignment but
modulo by a power-of-two isn't handled either.

PR tree-optimization/116514
* tree-ssa-ccp.cc (bit_value_binop): Handle EXACT_DIV_EXPR
like TRUNC_DIV_EXPR.  Handle exact division of a signed value
by a power-of-two like a shift.  Handle unsigned division by
a power-of-two like a shift.
Handle unsigned TRUNC_MOD_EXPR by power-of-two, handle signed
TRUNC_MOD_EXPR by power-of-two if the result is zero.

* gcc.dg/tree-ssa/ssa-ccp-44.c: New testcase.
gcc/testsuite/gcc.dg/tree-ssa/ssa-ccp-44.c [new file with mode: 0644]
gcc/tree-ssa-ccp.cc