--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-O1 -fdump-tree-cplxlower1-raw" } */
+
+_Complex double f(double a, double c)
+{
+ _Complex double d = __builtin_complex (a, a);
+ d+=__builtin_complex(c, c);
+ return d;
+}
+
+/* There should only be one plus as (a+c) is still (a+c) */
+/* { dg-final { scan-tree-dump-times "plus_expr, " 1 "cplxlower1" } } */
case PAIR (VARYING, VARYING):
general:
rr = gimple_build (&stmts, loc, code, inner_type, ar, br);
- ri = gimple_build (&stmts, loc, code, inner_type, ai, bi);
+ /* (a+ai) + (b+bi) -> (a+b)+(a+b)i
+ small optimization to remove one new statement. */
+ if (operand_equal_p (ar, ai) && operand_equal_p (br, bi))
+ ri = rr;
+ else
+ ri = gimple_build (&stmts, loc, code, inner_type, ai, bi);
break;
default: