OSDN Git Service

PR middle-end/11984
authorsayle <sayle@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 20 Aug 2003 21:55:01 +0000 (21:55 +0000)
committersayle <sayle@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 20 Aug 2003 21:55:01 +0000 (21:55 +0000)
* fold-const.c (fold <PLUS_EXPR>): Check for integer constant
operands before calling tree_int_cst_lt when performing associative
transformations.

* gcc.dg/20030820-1.c: New test case.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@70618 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/fold-const.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/20030820-1.c [new file with mode: 0644]

index 2ff2414..cf5369d 100644 (file)
@@ -1,3 +1,10 @@
+2003-08-20  Roger Sayle  <roger@eyesopen.com>
+
+       PR middle-end/11984
+       * fold-const.c (fold <PLUS_EXPR>): Check for integer constant
+       operands before calling tree_int_cst_lt when performing associative
+       transformations.
+
 2003-08-20  Jason Merrill  <jason@redhat.com>
 
        * tree.h (IS_EXPR_CODE_CLASS): Also include 'r' and 's'.
index ef7c086..bf6b1f8 100644 (file)
@@ -5884,7 +5884,9 @@ fold (tree expr)
                 example: ((X*2 + 4) - 8U)/2.  */
              if (minus_lit0 && lit0)
                {
-                 if (tree_int_cst_lt (lit0, minus_lit0))
+                 if (TREE_CODE (lit0) == INTEGER_CST
+                     && TREE_CODE (minus_lit0) == INTEGER_CST
+                     && tree_int_cst_lt (lit0, minus_lit0))
                    {
                      minus_lit0 = associate_trees (minus_lit0, lit0,
                                                    MINUS_EXPR, type);
index bbbf552..869e26e 100644 (file)
@@ -1,3 +1,8 @@
+2003-08-20  Roger Sayle  <roger@eyesopen.com>
+
+       PR middle-end/11984
+       * gcc.dg/20030820-1.c: New test case.
+
 2003-08-20  Nathan Sidwell  <nathan@codesourcery.com>
 
        PR c++/11945
diff --git a/gcc/testsuite/gcc.dg/20030820-1.c b/gcc/testsuite/gcc.dg/20030820-1.c
new file mode 100644 (file)
index 0000000..f86fb39
--- /dev/null
@@ -0,0 +1,13 @@
+/* PR middle-end/11984 */
+/* The following program used to ICE in fold because we didn't check
+   whether the constants we were reassociating were integer constants
+   before calling tree_int_cst_lt.  */
+
+/* { dg-do compile } */
+/* { dg-options "-O2 -ffast-math" } */
+
+double f(double x)
+{
+  return 1.0 - x - 0.1;
+}
+