C undefined overflow explicitly encoded in the IL
The no-undefined-overflow branch introduces non-overflowing expression tree codes for +, - and *.
- PRE/POSTIN/DECREMENT_EXPR frontend codes need NV variants and be gimplified properly
VRP should change regular codes to nv variants when it can prove the operation does not overflow. roughly implemented
- SCCVN should value-number regular variants to nv variants when they are available, CSEing c = a +/nv b; d = a + b; to d = c; (but not c = d;)
- Implement -ftrapv support in the frontends (or the gimplifier) by inserting explicit overflow checks
like s = x + y; if (((s x) & (s y)) < 0) builtin_trap (); and recognize the tree pattern during ifcombine changing it to builtin_addv (x, y) to benefit from addv expanders.
- operand_equal_p should consider a +/nv b equal to a + b(?)
- somehow make it possible to generate unsigned a +/nv b from fold for easier testcases.
Functions definitely needing audit
- tree-chrec.c:convert_affine_scev, all the logic about language semantics needs to be dropped and replaced with proper NV_EXPR support.
- tree-ssa-loop-niter.c:nowrap_type_p is at least wrong for pointer types now, its users need to be audited
- tree-ssa-loop-niter.c:scev_probably_wraps_p should not be called with true use_overflow_semantics flag
Several transformations that fold does can be audited to preserve NV in some circumstances. For now only obvious places do so. It may also be profitable to not perform some folding retaining NV information.
Testcases that need fixing
- g++.dg/tree-ssa/tmmti-2.C needs -fstrict-overflow