From: Richard Guenther Date: Sun, 31 Dec 2006 14:01:19 +0000 (+0000) Subject: re PR middle-end/30338 (infinite loop in maybe_canonicalize_comparison) X-Git-Tag: releases/gcc-4.3.0~7783 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=72ff1a96091ff6a1fb93e1c7087dc17f3c6c5d4b;p=thirdparty%2Fgcc.git re PR middle-end/30338 (infinite loop in maybe_canonicalize_comparison) 2006-12-31 Richard Guenther PR middle-end/30338 * fold-const.c (fold_binary): Fix type-mismatch in folding of -1 - A to ~A. * gcc.c-torture/compile/pr30338.c: New testcase. From-SVN: r120297 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index ff58d77ab54b..1e2601bac491 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2006-12-31 Richard Guenther + + PR middle-end/30338 + * fold-const.c (fold_binary): Fix type-mismatch in folding + of -1 - A to ~A. + 2006-12-30 Kazu Hirata * tree-inline.c: Fix a comment typo. diff --git a/gcc/fold-const.c b/gcc/fold-const.c index 18746096b5a3..dbdc9c26367e 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -9009,7 +9009,7 @@ fold_binary (enum tree_code code, tree type, tree op0, tree op1) /* Convert -1 - A to ~A. */ if (INTEGRAL_TYPE_P (type) && integer_all_onesp (arg0)) - return fold_build1 (BIT_NOT_EXPR, type, arg1); + return fold_build1 (BIT_NOT_EXPR, type, op1); if (! FLOAT_TYPE_P (type)) { diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 564312da9348..a24138920b20 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2006-12-31 Richard Guenther + + PR middle-end/30338 + * gcc.c-torture/compile/pr30338.c: New testcase. + 2006-12-31 Paul Thomas PR fortran/27900 diff --git a/gcc/testsuite/gcc.c-torture/compile/pr30338.c b/gcc/testsuite/gcc.c-torture/compile/pr30338.c new file mode 100644 index 000000000000..2d6245d014d9 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr30338.c @@ -0,0 +1,14 @@ +/* We used to do folding with mismatched types which caused us to + infinitely loop in comparison foldings. */ + +extern char *grub_scratch_mem; +int testload_func (char *arg, int flags) +{ + int i; + for (i = 0; i < 0x10ac0; i++) + if (*((unsigned char *) ((0x200000 + i + (int) grub_scratch_mem))) + != *((unsigned char *) ((0x300000 + i + (int) grub_scratch_mem)))) + return 0; + return 1; +} +