re PR middle-end/55832 (ICE in fold_convert_loc, at fold-const.c:1967)
authorJakub Jelinek <jakub@redhat.com>
Thu, 3 Jan 2013 09:02:41 +0000 (10:02 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Thu, 3 Jan 2013 09:02:41 +0000 (10:02 +0100)
PR tree-optimization/55832
* fold-const.c (fold_binary_loc): For ABS_EXPR<x> >= 0 and
ABS_EXPR<x> < 0 folding use constant_boolean_node instead of
integer_{one,zero}_node.

* gcc.c-torture/compile/pr55832.c: New test.

Co-Authored-By: Marc Glisse <marc.glisse@inria.fr>
From-SVN: r194836

gcc/ChangeLog
gcc/fold-const.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/compile/pr55832.c [new file with mode: 0644]

index 0c89cc4ec1b09975a49b7c17f26337c3f58ce499..346b366f04d91900e99ea2f48e19b251cb7805b4 100644 (file)
@@ -1,3 +1,11 @@
+2013-01-03  Jakub Jelinek  <jakub@redhat.com>
+           Marc Glisse  <marc.glisse@inria.fr>
+
+       PR tree-optimization/55832
+       * fold-const.c (fold_binary_loc): For ABS_EXPR<x> >= 0 and
+       ABS_EXPR<x> < 0 folding use constant_boolean_node instead of
+       integer_{one,zero}_node.
+
 2013-01-03  Jakub Jelinek  <jakub@redhat.com>
 
        PR debug/54402
index 0a8b90a5d09c48fa7415d06a023c43fcc73adee8..4f384a753444b811de58b36a3cbe518243721fd1 100644 (file)
@@ -1,7 +1,7 @@
 /* Fold a constant sub-tree into a single node for C-compiler
    Copyright (C) 1987, 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
    2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011,
-   2012 Free Software Foundation, Inc.
+   2012, 2013 Free Software Foundation, Inc.
 
 This file is part of GCC.
 
@@ -13519,7 +13519,9 @@ fold_binary_loc (location_t loc,
                                    "when simplifying comparison of "
                                    "absolute value and zero"),
                                   WARN_STRICT_OVERFLOW_CONDITIONAL);
-         return omit_one_operand_loc (loc, type, integer_one_node, arg0);
+         return omit_one_operand_loc (loc, type,
+                                      constant_boolean_node (true, type),
+                                      arg0);
        }
 
       /* Convert ABS_EXPR<x> < 0 to false.  */
@@ -13533,7 +13535,9 @@ fold_binary_loc (location_t loc,
                                    "when simplifying comparison of "
                                    "absolute value and zero"),
                                   WARN_STRICT_OVERFLOW_CONDITIONAL);
-         return omit_one_operand_loc (loc, type, integer_zero_node, arg0);
+         return omit_one_operand_loc (loc, type,
+                                      constant_boolean_node (false, type),
+                                      arg0);
        }
 
       /* If X is unsigned, convert X < (1 << Y) into X >> Y == 0
index b3418f11882d13ed179e487cbb496c8a8a76c26e..12f1688c447e35ee8177cc46ba5593cf6301ce07 100644 (file)
@@ -1,3 +1,8 @@
+2013-01-03  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/55832
+       * gcc.c-torture/compile/pr55832.c: New test.
+
 2013-01-02  John David Anglin  <dave.anglin@nrc-cnrc.gc.ca>
 
        * gcc.dg/pr55430.c: Define MAP_FAILED if not defined.
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr55832.c b/gcc/testsuite/gcc.c-torture/compile/pr55832.c
new file mode 100644 (file)
index 0000000..221c3c9
--- /dev/null
@@ -0,0 +1,23 @@
+/* PR tree-optimization/55832 */
+
+int g, b;
+
+void
+foo (void)
+{
+  union U { int i; unsigned short s; } a = { 0 };
+  unsigned char c;
+  unsigned short d = 0, *p = &a.s;
+
+  if (g)
+    a.i--;
+
+  if (b && a.i < (d = 1))
+    return;
+
+  for (; a.i < 15; a.i++)
+    b |= d <= c;
+
+  if (!*p)
+    g = 0;
+}