https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69526
--- Comment #13 from rdapp at linux dot vnet.ibm.com --- Created attachment 38535 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=38535&action=edit VRP/match.pd patch Found some time again and hacked together a fix for match.pd and VRP. The patch exports a VRP function no_range_overflow that is called from match.pd via tree.c. I realize that VRP didn't export any functions so far and if there's a better/idiomatic way to do it, please tell me. Further improvements or "code smell" hints very welcome. Currently this should fix cases like long foo(int i) { return (long) (i + 1) - 2; } Commutativity of a PLUS_EXPR is not yet being exploited and I'm relying on TYPE_OVERFLOW_UNDEFINED so far. The overflow checking could also be done more elegantly I suppose. This diff is extracted from the full patch which also includes the RTL level fix which I haven't included here since it has not changed. I hope the splitting didn't introduce new bugs but there are no regressions on s390x for the full patch.