aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Guenther <rguenther@suse.de>2006-12-31 14:01:19 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2006-12-31 14:01:19 +0000
commit72ff1a96091ff6a1fb93e1c7087dc17f3c6c5d4b (patch)
tree0e17d9cce9536e7be84953e12a0a7bddb8f48b4c /gcc
parent20a037d5f58c824cb402275fa47f241377a5fde5 (diff)
downloadgcc-72ff1a96091ff6a1fb93e1c7087dc17f3c6c5d4b.zip
gcc-72ff1a96091ff6a1fb93e1c7087dc17f3c6c5d4b.tar.gz
gcc-72ff1a96091ff6a1fb93e1c7087dc17f3c6c5d4b.tar.bz2
re PR middle-end/30338 (infinite loop in maybe_canonicalize_comparison)
2006-12-31 Richard Guenther <rguenther@suse.de> 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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/fold-const.c2
-rw-r--r--gcc/testsuite/ChangeLog5
-rw-r--r--gcc/testsuite/gcc.c-torture/compile/pr30338.c14
4 files changed, 26 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index ff58d77..1e2601b 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2006-12-31 Richard Guenther <rguenther@suse.de>
+
+ PR middle-end/30338
+ * fold-const.c (fold_binary): Fix type-mismatch in folding
+ of -1 - A to ~A.
+
2006-12-30 Kazu Hirata <kazu@codesourcery.com>
* tree-inline.c: Fix a comment typo.
diff --git a/gcc/fold-const.c b/gcc/fold-const.c
index 1874609..dbdc9c2 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 564312d..a241389 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2006-12-31 Richard Guenther <rguenther@suse.de>
+
+ PR middle-end/30338
+ * gcc.c-torture/compile/pr30338.c: New testcase.
+
2006-12-31 Paul Thomas <pault@gcc.gnu.org>
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 0000000..2d6245d
--- /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;
+}
+