Possible bug with ABS_EXPR and complex operands
Peter Gerwinski
peter@gerwinski.de
Thu Sep 30 18:34:00 GMT 1999
Hello,
in the big `switch' statement in expand_expr(), case ABS_EXPR,
the absolute value of a complex operand gets the mode of the
complex type. IMHO it should have the mode of the underlying
type - abs(complex)=real.
I am suggesting the change below.
Peter
Thu 30 Sep 1999 27:25 Peter Gerwinski <peter@gerwinski.de>
* expr.c (expand_expr): the absolute value of a complex
expression is of the underlying type.
--- expr.c.orig Thu Jul 1 00:59:55 1999
+++ expr.c Fri Oct 1 03:24:24 1999
@@ -7273,10 +7274,17 @@
case ABS_EXPR:
op0 = expand_expr (TREE_OPERAND (exp, 0), subtarget, VOIDmode, 0);
- /* Handle complex values specially. */
- if (GET_MODE_CLASS (mode) == MODE_COMPLEX_INT
- || GET_MODE_CLASS (mode) == MODE_COMPLEX_FLOAT)
- return expand_complex_abs (mode, op0, target, unsignedp);
+ /* Handle complex values specially.
+ It is the mode of the operand, not the mode of the return
+ value that is tested here. ABS(complex) does not return
+ complex type. */
+ {
+ enum machine_mode op0_mode =
+ TYPE_MODE (TREE_TYPE (TREE_OPERAND (exp, 0)));
+ if (GET_MODE_CLASS (op0_mode) == MODE_COMPLEX_INT
+ || GET_MODE_CLASS (op0_mode) == MODE_COMPLEX_FLOAT)
+ return expand_complex_abs (op0_mode, op0, target, unsignedp);
+ }
/* Unsigned abs is simply the operand. Testing here means we don't
risk generating incorrect code below. */
More information about the Gcc-bugs
mailing list