This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix PR optimization/5999
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Richard Henderson <rth at redhat dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Tue, 19 Mar 2002 13:42:23 +0100
- Subject: [PATCH] Fix PR optimization/5999
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
Hi!
The following testcase ICEs because the a/b -> a * (1/b)
transformation did not take complex divisions into account.
I think the easiest is to just limit this to real divisions.
Ok to commit?
2002-03-19 Jakub Jelinek <jakub@redhat.com>
PR optimization/5999
* expr.c (expand_expr) [RDIV_EXPR]: Only convert real divisions into
multiplications by reciprocals.
* gcc.dg/20020319-1.c: New test.
--- gcc/testsuite/gcc.dg/20020319-1.c.jj Tue Mar 19 13:01:59 2002
+++ gcc/testsuite/gcc.dg/20020319-1.c Tue Mar 19 13:49:52 2002
@@ -0,0 +1,10 @@
+/* PR optimization/5999
+ This testcase ICEd because one a/b -> a * (1/b) optimization
+ did not handle complex divides. */
+/* { dg-do compile } */
+/* { dg-options "-O2 -ffast-math" } */
+
+__complex__ double foo (__complex__ double x, __complex__ double y)
+{
+ return x / y;
+}
--- gcc/expr.c.jj Mon Mar 18 15:58:29 2002
+++ gcc/expr.c Tue Mar 19 12:52:01 2002
@@ -7741,6 +7741,7 @@ expand_expr (exp, target, tmode, modifie
expensive divide. If not, combine will rebuild the original
computation. */
if (flag_unsafe_math_optimizations && optimize && !optimize_size
+ && TREE_CODE (type) == REAL_TYPE
&& !real_onep (TREE_OPERAND (exp, 0)))
return expand_expr (build (MULT_EXPR, type, TREE_OPERAND (exp, 0),
build (RDIV_EXPR, type,
Jakub