From 9ccaac1188959d2b35cfa820c46277ebef5f75e0 Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Tue, 28 Oct 2014 11:42:43 +0000 Subject: re PR tree-optimization/63665 (wrong code with signed overflow even with -fwrapv) 2014-10-28 Richard Biener PR middle-end/63665 * fold-const.c (fold_comparison): Properly guard simplifying against INT_MAX/INT_MIN with !TYPE_OVERFLOW_WRAPS. * gcc.dg/pr63665.c: New testcase. From-SVN: r216781 --- gcc/fold-const.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'gcc/fold-const.c') diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 8166070..218afa0 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -8749,7 +8749,8 @@ fold_comparison (location_t loc, enum tree_code code, tree type, /* If the constant operation overflowed this can be simplified as a comparison against INT_MAX/INT_MIN. */ - if (TREE_OVERFLOW (new_const)) + if (TREE_OVERFLOW (new_const) + && !TYPE_OVERFLOW_WRAPS (TREE_TYPE (arg0))) { int const1_sgn = tree_int_cst_sgn (const1); enum tree_code code2 = code; -- cgit v1.1