+ else
+ {
+ /* Keep this algorithm in sync with
+ tree-complex.c:expand_complex_div_wide().
+
+ Expand complex division to scalars, modified algorithm to minimize
+ overflow with wide input ranges. */
+ tree compare = fold_build2 (LT_EXPR, boolean_type_node,
+ fold_abs_const (r2, TREE_TYPE (type)),
+ fold_abs_const (i2, TREE_TYPE (type)));
+
+ if (integer_nonzerop (compare))
+ {
+ /* In the TRUE branch, we compute
+ ratio = br/bi;
+ div = (br * ratio) + bi;
+ tr = (ar * ratio) + ai;
+ ti = (ai * ratio) - ar;
+ tr = tr / div;
+ ti = ti / div; */
+ tree ratio = const_binop (code, r2, i2, notrunc);
+ tree div = const_binop (PLUS_EXPR, i2,
+ const_binop (MULT_EXPR, r2, ratio,
+ notrunc),
+ notrunc);
+ real = const_binop (MULT_EXPR, r1, ratio, notrunc);
+ real = const_binop (PLUS_EXPR, real, i1, notrunc);
+ real = const_binop (code, real, div, notrunc);
+
+ imag = const_binop (MULT_EXPR, i1, ratio, notrunc);
+ imag = const_binop (MINUS_EXPR, imag, r1, notrunc);
+ imag = const_binop (code, imag, div, notrunc);
+ }
+ else
+ {
+ /* In the FALSE branch, we compute
+ ratio = d/c;
+ divisor = (d * ratio) + c;
+ tr = (b * ratio) + a;
+ ti = b - (a * ratio);
+ tr = tr / div;
+ ti = ti / div; */
+ tree ratio = const_binop (code, i2, r2, notrunc);
+ tree div = const_binop (PLUS_EXPR, r2,
+ const_binop (MULT_EXPR, i2, ratio,
+ notrunc),
+ notrunc);
+
+ real = const_binop (MULT_EXPR, i1, ratio, notrunc);
+ real = const_binop (PLUS_EXPR, real, r1, notrunc);
+ real = const_binop (code, real, div, notrunc);
+
+ imag = const_binop (MULT_EXPR, r1, ratio, notrunc);
+ imag = const_binop (MINUS_EXPR, i1, imag, notrunc);
+ imag = const_binop (code, imag, div, notrunc);
+ }
+ }