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 <andrew.pinski@oss.qualcomm.com>
3 files changed