Commit 214d5b84 by Richard Kenner

(const_binop): Add new arg, TYPE, to call to build_complex.

(fold, case CONJ_EXPR, COMPLEX_EXPR): Likewise.

From-SVN: r12865
parent 77912476
...@@ -1228,6 +1228,7 @@ const_binop (code, arg1, arg2, notrunc) ...@@ -1228,6 +1228,7 @@ const_binop (code, arg1, arg2, notrunc)
#endif /* not REAL_IS_NOT_DOUBLE, or REAL_ARITHMETIC */ #endif /* not REAL_IS_NOT_DOUBLE, or REAL_ARITHMETIC */
if (TREE_CODE (arg1) == COMPLEX_CST) if (TREE_CODE (arg1) == COMPLEX_CST)
{ {
register tree type = TREE_TYPE (arg1);
register tree r1 = TREE_REALPART (arg1); register tree r1 = TREE_REALPART (arg1);
register tree i1 = TREE_IMAGPART (arg1); register tree i1 = TREE_IMAGPART (arg1);
register tree r2 = TREE_REALPART (arg2); register tree r2 = TREE_REALPART (arg2);
...@@ -1237,17 +1238,20 @@ const_binop (code, arg1, arg2, notrunc) ...@@ -1237,17 +1238,20 @@ const_binop (code, arg1, arg2, notrunc)
switch (code) switch (code)
{ {
case PLUS_EXPR: case PLUS_EXPR:
t = build_complex (const_binop (PLUS_EXPR, r1, r2, notrunc), t = build_complex (type,
const_binop (PLUS_EXPR, r1, r2, notrunc),
const_binop (PLUS_EXPR, i1, i2, notrunc)); const_binop (PLUS_EXPR, i1, i2, notrunc));
break; break;
case MINUS_EXPR: case MINUS_EXPR:
t = build_complex (const_binop (MINUS_EXPR, r1, r2, notrunc), t = build_complex (type,
const_binop (MINUS_EXPR, r1, r2, notrunc),
const_binop (MINUS_EXPR, i1, i2, notrunc)); const_binop (MINUS_EXPR, i1, i2, notrunc));
break; break;
case MULT_EXPR: case MULT_EXPR:
t = build_complex (const_binop (MINUS_EXPR, t = build_complex (type,
const_binop (MINUS_EXPR,
const_binop (MULT_EXPR, const_binop (MULT_EXPR,
r1, r2, notrunc), r1, r2, notrunc),
const_binop (MULT_EXPR, const_binop (MULT_EXPR,
...@@ -1269,32 +1273,33 @@ const_binop (code, arg1, arg2, notrunc) ...@@ -1269,32 +1273,33 @@ const_binop (code, arg1, arg2, notrunc)
const_binop (MULT_EXPR, i2, i2, notrunc), const_binop (MULT_EXPR, i2, i2, notrunc),
notrunc); notrunc);
t = build_complex t = build_complex (type,
(const_binop (INTEGRAL_TYPE_P (TREE_TYPE (r1)) const_binop
? TRUNC_DIV_EXPR : RDIV_EXPR, (INTEGRAL_TYPE_P (TREE_TYPE (r1))
const_binop (PLUS_EXPR, ? TRUNC_DIV_EXPR : RDIV_EXPR,
const_binop (MULT_EXPR, r1, r2, const_binop (PLUS_EXPR,
notrunc), const_binop (MULT_EXPR, r1, r2,
const_binop (MULT_EXPR, i1, i2, notrunc),
notrunc), const_binop (MULT_EXPR, i1, i2,
notrunc), notrunc),
magsquared, notrunc), notrunc),
const_binop (INTEGRAL_TYPE_P (TREE_TYPE (r1)) magsquared, notrunc),
? TRUNC_DIV_EXPR : RDIV_EXPR, const_binop
const_binop (MINUS_EXPR, (INTEGRAL_TYPE_P (TREE_TYPE (r1))
const_binop (MULT_EXPR, i1, r2, ? TRUNC_DIV_EXPR : RDIV_EXPR,
notrunc), const_binop (MINUS_EXPR,
const_binop (MULT_EXPR, r1, i2, const_binop (MULT_EXPR, i1, r2,
notrunc), notrunc),
notrunc), const_binop (MULT_EXPR, r1, i2,
magsquared, notrunc)); notrunc),
notrunc),
magsquared, notrunc));
} }
break; break;
default: default:
abort (); abort ();
} }
TREE_TYPE (t) = TREE_TYPE (arg1);
return t; return t;
} }
return 0; return 0;
...@@ -3621,7 +3626,7 @@ fold (expr) ...@@ -3621,7 +3626,7 @@ fold (expr)
TREE_TYPE (TREE_TYPE (arg0)), TREE_TYPE (TREE_TYPE (arg0)),
TREE_OPERAND (arg0, 1)))); TREE_OPERAND (arg0, 1))));
else if (TREE_CODE (arg0) == COMPLEX_CST) else if (TREE_CODE (arg0) == COMPLEX_CST)
return build_complex (TREE_OPERAND (arg0, 0), return build_complex (type, TREE_OPERAND (arg0, 0),
fold (build1 (NEGATE_EXPR, fold (build1 (NEGATE_EXPR,
TREE_TYPE (TREE_TYPE (arg0)), TREE_TYPE (TREE_TYPE (arg0)),
TREE_OPERAND (arg0, 1)))); TREE_OPERAND (arg0, 1))));
...@@ -5123,7 +5128,7 @@ fold (expr) ...@@ -5123,7 +5128,7 @@ fold (expr)
case COMPLEX_EXPR: case COMPLEX_EXPR:
if (wins) if (wins)
return build_complex (arg0, arg1); return build_complex (type, arg0, arg1);
return t; return t;
case REALPART_EXPR: case REALPART_EXPR:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment