There are a couple of things wrong with this pattern which
I missed during the review. First each nop_convert should
be nop_convert1 or nop_convert2.
Second is we need to the minus in the same type as the minus
was originally so we don't introduce extra undefined behavior
(signed integer overflow). And we need a convert into the new
type too.
pr117363-1.c tests not introducing extra undefined behavior.
pr117363-2.c tests the casting to the correct final type, ldist
introduces the cond_expr here.
Bootstraped and tested on x86_64-linux-gnu.
PR tree-optimization/117363
gcc/ChangeLog:
* match.pd (`a != 0 ? a - 1 : 0`): Fix type handling
and nop_convert handling.
gcc/testsuite/ChangeLog:
* gcc.dg/torture/pr117363-1.c: New test.
* gcc.dg/torture/pr117363-2.c: New test.
Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>