The following patch removes (well, the patch only disables) strict-overflow handling (and thus emitting -Wstrict-overflo diagnostics) from VRP.
I XFAILed three testcases (well, all three are really the same testcase), removed on XFAIL and added a testcase for the missed VRP caused by those INF(OVF) being "sticky". I'm now re-bootstrapping and testing this on trunk (after I've committed the -f[no-]strict-overflow removal). The patch bootstrapped and tested ok a week ago. I'm not sure if I will commit the patch as-is or if I actually remove (some) of the strict-overflow machinery itself in the initial patch. Comments still appreciated. And yes, it should be easily possible to preserve the warning on the testcase -- even from within the FE itself I guess but also from VRP (the IV is not SCEV analyzable otherwise -Waggressive-loop-optimizations would warn). Richard. 2017-05-02 Richard Biener <rguent...@suse.de> PR tree-optimization/31130 * tree-vrp.c (needs_overflow_infinity): Return always false. (set_value_range_to_nonnegative): Properly guard supports_overflow_infinity. * gcc.dg/Wstrict-overflow-12.c: XFAIL. * gcc.dg/Wstrict-overflow-13.c: Likewise. * gcc.dg/Wstrict-overflow-21.c: Likewise. * gcc.dg/pr52904.c: Remove XFAIL. * gcc.dg/tree-ssa/vrp113.c: New testcase. Index: gcc/tree-vrp.c =================================================================== *** gcc/tree-vrp.c.orig 2017-04-28 11:24:38.953886334 +0200 --- gcc/tree-vrp.c 2017-05-02 15:14:48.438675683 +0200 *************** vrp_val_is_min (const_tree val) *** 220,228 **** TYPE_{MIN,MAX}_VALUE. */ static inline bool ! needs_overflow_infinity (const_tree type) { ! return INTEGRAL_TYPE_P (type) && !TYPE_OVERFLOW_WRAPS (type); } /* Return whether TYPE can support our overflow infinity --- 220,228 ---- TYPE_{MIN,MAX}_VALUE. */ static inline bool ! needs_overflow_infinity (const_tree) { ! return false; } /* Return whether TYPE can support our overflow infinity *************** set_value_range_to_nonnegative (value_ra *** 558,564 **** { tree zero; ! if (overflow_infinity && !supports_overflow_infinity (type)) { set_value_range_to_varying (vr); return; --- 558,566 ---- { tree zero; ! if (overflow_infinity ! && (needs_overflow_infinity (type) ! && !supports_overflow_infinity (type))) { set_value_range_to_varying (vr); return; *************** set_value_range_to_nonnegative (value_ra *** 566,572 **** zero = build_int_cst (type, 0); set_value_range (vr, VR_RANGE, zero, ! (overflow_infinity ? positive_overflow_infinity (type) : TYPE_MAX_VALUE (type)), vr->equiv); --- 568,574 ---- zero = build_int_cst (type, 0); set_value_range (vr, VR_RANGE, zero, ! (overflow_infinity && needs_overflow_infinity (type) ? positive_overflow_infinity (type) : TYPE_MAX_VALUE (type)), vr->equiv); Index: gcc/testsuite/gcc.dg/Wstrict-overflow-12.c =================================================================== *** gcc/testsuite/gcc.dg/Wstrict-overflow-12.c.orig 2007-11-30 13:59:34.000000000 +0100 --- gcc/testsuite/gcc.dg/Wstrict-overflow-12.c 2017-05-02 15:19:32.259012861 +0200 *************** int *** 10,16 **** foo () { int i, bits; ! for (i = 1, bits = 1; i > 0; i += i) /* { dg-warning "assuming signed overflow does not occur" "correct warning" } */ ++bits; return bits; } --- 10,16 ---- foo () { int i, bits; ! for (i = 1, bits = 1; i > 0; i += i) /* { dg-warning "assuming signed overflow does not occur" "correct warning" { xfail *-*-* } } */ ++bits; return bits; } Index: gcc/testsuite/gcc.dg/Wstrict-overflow-13.c =================================================================== *** gcc/testsuite/gcc.dg/Wstrict-overflow-13.c.orig 2007-11-30 13:59:35.000000000 +0100 --- gcc/testsuite/gcc.dg/Wstrict-overflow-13.c 2017-05-02 15:20:03.927497363 +0200 *************** int *** 11,17 **** foo () { int j; ! for (j = 1; 0 < j; j *= 2) /* { dg-warning "assuming signed overflow does not occur" "correct warning" } */ if (! bigtime_test (j)) return 1; return 0; --- 11,17 ---- foo () { int j; ! for (j = 1; 0 < j; j *= 2) /* { dg-warning "assuming signed overflow does not occur" "correct warning" { xfail *-*-* } } */ if (! bigtime_test (j)) return 1; return 0; Index: gcc/testsuite/gcc.dg/Wstrict-overflow-21.c =================================================================== *** gcc/testsuite/gcc.dg/Wstrict-overflow-21.c.orig 2008-01-22 15:53:57.000000000 +0100 --- gcc/testsuite/gcc.dg/Wstrict-overflow-21.c 2017-05-02 15:20:18.087714039 +0200 *************** int *** 5,11 **** foo () { int i, bits; ! for (i = 1, bits = 1; i > 0; i += i) /* { dg-warning "assuming signed overflow does not occur" "correct warning" } */ ++bits; return bits; } --- 5,11 ---- foo () { int i, bits; ! for (i = 1, bits = 1; i > 0; i += i) /* { dg-warning "assuming signed overflow does not occur" "correct warning" { xfail *-*-* } } */ ++bits; return bits; } Index: gcc/testsuite/gcc.dg/pr52904.c =================================================================== *** gcc/testsuite/gcc.dg/pr52904.c.orig 2016-08-17 13:59:02.625248245 +0200 --- gcc/testsuite/gcc.dg/pr52904.c 2017-05-02 15:21:42.157000890 +0200 *************** wait_reading_process_output (void) *** 14,20 **** nfds++; } ! if (nfds < 0) /* { dg-bogus "assuming signed overflow does not occur" "" { xfail *-*-* } } */ return 1; return 0; } --- 14,20 ---- nfds++; } ! if (nfds < 0) /* { dg-bogus "assuming signed overflow does not occur" "" } */ return 1; return 0; } Index: gcc/testsuite/gcc.dg/tree-ssa/vrp113.c =================================================================== *** /dev/null 1970-01-01 00:00:00.000000000 +0000 --- gcc/testsuite/gcc.dg/tree-ssa/vrp113.c 2017-05-02 15:32:03.314531397 +0200 *************** *** 0 **** --- 1,24 ---- + /* { dg-do link } */ + /* { dg-options "-O2 -fdump-tree-fre1 -fdump-tree-evrp" } */ + + extern void link_error (); + void foo (int a) + { + if (a < 0) + { + int y; + a = -a; + y = a / 7; + y = y * 2; + if (y > 1 << 30) + link_error (); + } + } + + int main() + { + return 0; + } + + /* { dg-final { scan-tree-dump-times "link_error" 1 "fre1" } } */ + /* { dg-final { scan-tree-dump-times "link_error" 0 "evrp" } } */