[PATCH] Fix PR optimization/5999

Jakub Jelinek jakub@redhat.com
Tue Mar 19 04:42:00 GMT 2002


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



More information about the Gcc-patches mailing list