(const_binop, COMPLEX_TYPE, case RDIV_EXPR): If complex integer, use
authorRichard Kenner <kenner@gcc.gnu.org>
Wed, 2 Feb 1994 20:14:18 +0000 (15:14 -0500)
committerRichard Kenner <kenner@gcc.gnu.org>
Wed, 2 Feb 1994 20:14:18 +0000 (15:14 -0500)
TRUNC_DIV_EXPR for inner division.

From-SVN: r6468

gcc/fold-const.c

index 6f6027d67a0e1b7665143fe935d683a7fcf95d4a..600bbfa728ee85e6845b740ae491ddaee1a98ee3 100644 (file)
@@ -1433,18 +1433,26 @@ const_binop (code, arg1, arg2, notrunc)
                             const_binop (MULT_EXPR, r2, r2, notrunc),
                             const_binop (MULT_EXPR, i2, i2, notrunc),
                             notrunc);
-           t = build_complex (const_binop (RDIV_EXPR,
-                                           const_binop (PLUS_EXPR,
-                                                        const_binop (MULT_EXPR, r1, r2, notrunc),
-                                                        const_binop (MULT_EXPR, i1, i2, notrunc),
-                                                        notrunc),
-                                           magsquared, notrunc),
-                              const_binop (RDIV_EXPR,
-                                           const_binop (MINUS_EXPR,
-                                                        const_binop (MULT_EXPR, i1, r2, notrunc),
-                                                        const_binop (MULT_EXPR, r1, i2, notrunc),
-                                                        notrunc),
-                                           magsquared, notrunc));
+
+           t = build_complex
+             (const_binop (INTEGRAL_TYPE_P (TREE_TYPE (r1))
+                           ? TRUNC_DIV_EXPR : RDIV_EXPR,
+                           const_binop (PLUS_EXPR,
+                                        const_binop (MULT_EXPR, r1, r2,
+                                                     notrunc),
+                                        const_binop (MULT_EXPR, i1, i2,
+                                                     notrunc),
+                                        notrunc),
+                           magsquared, notrunc),
+              const_binop (INTEGRAL_TYPE_P (TREE_TYPE (r1))
+                           ? TRUNC_DIV_EXPR : RDIV_EXPR,
+                           const_binop (MINUS_EXPR,
+                                        const_binop (MULT_EXPR, i1, r2,
+                                                     notrunc),
+                                        const_binop (MULT_EXPR, r1, i2,
+                                                     notrunc),
+                                        notrunc),
+                           magsquared, notrunc));
          }
          break;