From bd170bbcd819a899eace0db56b353702b8d1ae2f Mon Sep 17 00:00:00 2001 From: Richard Guenther Date: Tue, 2 Dec 2008 14:49:00 +0000 Subject: [PATCH] re PR tree-optimization/38359 (ICE in set_lattice_value, at tree-ssa-ccp.c:466) 2008-12-02 Richard Guenther PR tree-optimization/38359 * fold-const.c (fold_binary): Fold -1 >> x to -1 only for non-negative x. * gcc.c-torture/compile/pr38359.c: New testcase. * gcc.c-torture/execute/shiftopt-1.c: Adjust. From-SVN: r142356 --- gcc/ChangeLog | 6 ++++++ gcc/fold-const.c | 3 ++- gcc/testsuite/ChangeLog | 6 ++++++ gcc/testsuite/gcc.c-torture/execute/shiftopt-1.c | 6 ------ 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 33b5cfd..843b221 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2008-12-02 Richard Guenther + + PR tree-optimization/38359 + * fold-const.c (fold_binary): Fold -1 >> x to -1 only for + non-negative x. + 2008-12-02 Martin Jambor PR middle-end/37861 diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 8dddca1..93415d8 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -11457,7 +11457,8 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) case RSHIFT_EXPR: /* Optimize -1 >> x for arithmetic right shifts. */ - if (integer_all_onesp (arg0) && !TYPE_UNSIGNED (type)) + if (integer_all_onesp (arg0) && !TYPE_UNSIGNED (type) + && tree_expr_nonnegative_p (arg1)) return omit_one_operand (type, arg0, arg1); /* ... fall through ... */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index f64db4d..33d0f86 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2008-12-02 Richard Guenther + + PR tree-optimization/38359 + * gcc.c-torture/compile/pr38359.c: New testcase. + * gcc.c-torture/execute/shiftopt-1.c: Adjust. + 2008-12-02 Janus Weil PR fortran/36704 diff --git a/gcc/testsuite/gcc.c-torture/execute/shiftopt-1.c b/gcc/testsuite/gcc.c-torture/execute/shiftopt-1.c index fa9517a..8c855b8 100644 --- a/gcc/testsuite/gcc.c-torture/execute/shiftopt-1.c +++ b/gcc/testsuite/gcc.c-torture/execute/shiftopt-1.c @@ -43,12 +43,6 @@ stest (int x) if (0 >> x != 0) link_error (); - - if (-1 >> x != -1) - link_error (); - - if (~0 >> x != ~0) - link_error (); } int -- 2.7.4