Fix tree-optimization/103220: Another missing folding of (type) X op CST where type...
authorAndrew Pinski <apinski@marvell.com>
Sat, 20 Nov 2021 01:37:54 +0000 (01:37 +0000)
committerAndrew Pinski <apinski@marvell.com>
Sat, 20 Nov 2021 08:06:18 +0000 (08:06 +0000)
commit74faa9834a9ad208e34f67b08c854c20b0fcfe92
treeadac44730f5fd3e571332b64031b94f110168b8c
parent38e4a361e79a459947540920db645f3d7fa7221a
Fix tree-optimization/103220: Another missing folding of (type) X op CST where type is a nop convert

The problem here is that int_fits_type_p will return false if we just
change the sign of things like -2 (or 254) so we should accept the case
where we just change the sign (and not the precision) of the type.

OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions.

PR tree-optimization/103220

gcc/ChangeLog:

* match.pd ((type) X bitop CST): Don't check if CST
fits into the type if only the sign changes.

gcc/testsuite/ChangeLog:

* gcc.dg/tree-ssa/pr103220-1.c: New test.
* gcc.dg/tree-ssa/pr103220-2.c: New test.
* gcc.dg/pr25530.c: Update test to check for
4294967294 in the case -2 is not matched.
gcc/match.pd
gcc/testsuite/gcc.dg/pr25530.c
gcc/testsuite/gcc.dg/tree-ssa/pr103220-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/tree-ssa/pr103220-2.c [new file with mode: 0644]