This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH]: Fix ICE in PRE
- From: Daniel Berlin <dberlin at dberlin dot org>
- To: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Tue, 17 May 2005 21:50:23 -0400
- Subject: [PATCH]: Fix ICE in PRE
Falk Hueffner pointed this out to me on IRC (so there is no bug report
for it).
Because PRE now can optimize pure and const calls, when you use -O2
-ffast-math, it is going to remove the cos call along the d = 0 path.
double f(double d, double i, int j) { if (j == 1) d = 0; return d *
cos(i); }
In doing so, it needs to regenerate the d * cos expression in the other
branch, and find_or_generate_expression was ICE'ing because it hadn't
been updated to know that it can generate CALL_EXPR :).
Fixed thusly.
Bootstrapped and currently being regtested on i686-pc-linux-gnu (except
java, which fails to build for me both with and without the patch).
I'll commit this to mainline once it finishes regtesting.
--Dan
2005-05-17 Daniel Berlin <dberlin@dberlin.org>
* tree-ssa-pre.c (find_or_generate_expression): CALL_EXPR
is okay too.
Index: tree-ssa-pre.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-ssa-pre.c,v
retrieving revision 2.89
diff -u -p -r2.89 tree-ssa-pre.c
--- tree-ssa-pre.c 16 May 2005 23:14:02 -0000 2.89
+++ tree-ssa-pre.c 18 May 2005 01:40:43 -0000
@@ -1467,7 +1465,8 @@ find_or_generate_expression (basic_block
gcc_assert (UNARY_CLASS_P (genop)
|| BINARY_CLASS_P (genop)
|| COMPARISON_CLASS_P (genop)
- || REFERENCE_CLASS_P (genop));
+ || REFERENCE_CLASS_P (genop)
+ || TREE_CODE (genop) == CALL_EXPR);
genop = create_expression_by_pieces (block, genop, stmts);
}
return genop;
Index: testsuite/gcc.dg/20050517-1.c
===================================================================
RCS file: testsuite/gcc.dg/20050517-1.c
diff -N testsuite/gcc.dg/20050517-1.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ testsuite/gcc.dg/20050517-1.c 18 May 2005 01:40:43 -0000
@@ -0,0 +1,7 @@
+/* Tree PRE is going to transform this so that it doesn't call cos on the
+ d = 0 path, and in doing so, it needs to regenerate the cos call.
+ This was ICE'ing due to an overly strict check on what it knew how
+ to regenerate. */
+/* { dg-do compile } */
+/* { dg-options "-O2 -ffast-math" } */
+double f(double d, double i, int j) { if (j == 1) d = 0; return d * cos(i); }