[Bug tree-optimization/107765] missing (int)-(unsigned)int_val to just -int_val if int_val is known not to contain INT_MIN
"cvs-commit at gcc dot gnu.org via Gcc-bugs" <[email protected]>
| Newsgroups | gmane.comp.gcc.bugs |
|---|---|
| Message-ID | <[email protected]/bugzilla/> |
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107765 --- Comment #9 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The trunk branch has been updated by Andrea Pinski <[email protected]>: https://gcc.gnu.org/g:8d004ef91c4f7c315519975ffaec78d28d4a21ff commit r17-3279-g8d004ef91c4f7c315519975ffaec78d28d4a21ff Author: Andrea Pinski <[email protected]> Date: Mon Jul 27 23:02:07 2026 -0700 match: Try to remove casts for `(int)-(unsigned)a`[PR107765] This adds some extra checks to see if we can remove the casts for signed integer overflow reasons while doing a negative. This is needed more due to the recent patch which adds them in some cases. This also changes TYPE_UNSIGNED to be TYPE_OVERFLOW_WRAPS to allow this to happen with -fwrapv too. Changes since v1: * Use expr_not_equal_to and simplify the if stmt. Also use TYPE_OVERFLOW_WRAPS instead of TYPE_UNSIGNED. Bootstrapped and tested on x86_64-linux-gnu. PR tree-optimization/107765 gcc/ChangeLog: * match.pd (`(cast)-(cast)a`): Expand to use expr_not_equal_to of INT_MIN. gcc/testsuite/ChangeLog: * gcc.dg/tree-ssa/neg-cast-1.c: New test. * gcc.dg/tree-ssa/neg-cast-4.c: New test. Signed-off-by: Andrea Pinski <[email protected]>