summaryrefslogtreecommitdiff
path: root/gcc/optabs.c
diff options
context:
space:
mode:
authorToon Moene <toon@moene.indiv.nluug.nl>2002-05-18 21:45:18 +0200
committerToon Moene <toon@gcc.gnu.org>2002-05-18 19:45:18 +0000
commit6835a09cfcbfe46a57fa503ca07d5b9f43551a0e (patch)
treeedc2de3e7cd3282bb8bbeb327203167572367109 /gcc/optabs.c
parentd48bc59acf17cb6141afdba04724b31cbb8f36fd (diff)
downloadgcc-6835a09cfcbfe46a57fa503ca07d5b9f43551a0e.tar.gz
optabs.c (complex_part_zero_p): New.
2002-05-18 Toon Moene <toon@moene.indiv.nluug.nl> * optabs.c (complex_part_zero_p): New. * (expand_cmplxdiv_straight): Use it. * (expand_cmplxdiv_wide): Ditto. * (expand_binop): Ditto. From-SVN: r53594
Diffstat (limited to 'gcc/optabs.c')
-rw-r--r--gcc/optabs.c24
1 files changed, 21 insertions, 3 deletions
diff --git a/gcc/optabs.c b/gcc/optabs.c
index 4d1ebda77f6..d1610978a57 100644
--- a/gcc/optabs.c
+++ b/gcc/optabs.c
@@ -108,6 +108,8 @@ static rtx ftruncify PARAMS ((rtx));
static optab new_optab PARAMS ((void));
static inline optab init_optab PARAMS ((enum rtx_code));
static inline optab init_optabv PARAMS ((enum rtx_code));
+static inline int complex_part_zero_p PARAMS ((rtx, enum mode_class,
+ enum machine_mode));
static void init_libfuncs PARAMS ((optab, int, int, const char *, int));
static void init_integral_libfuncs PARAMS ((optab, const char *, int));
static void init_floating_libfuncs PARAMS ((optab, const char *, int));
@@ -212,6 +214,22 @@ widen_operand (op, mode, oldmode, unsignedp, no_extend)
return result;
}
+/* Test whether either the real or imaginary part of a complex floating
+ point number is 0.0, so that it can be ignored (when compiling
+ with -funsafe-math-optimizations). */
+
+static inline int
+complex_part_zero_p (part, class, submode)
+ rtx part;
+ enum mode_class class;
+ enum machine_mode submode;
+{
+ return part == 0 ||
+ (flag_unsafe_math_optimizations
+ && class == MODE_COMPLEX_FLOAT
+ && part == CONST0_RTX (submode));
+}
+
/* Generate code to perform a straightforward complex divide. */
static int
@@ -265,7 +283,7 @@ expand_cmplxdiv_straight (real0, real1, imag0, imag1, realr, imagr, submode,
if (divisor == 0)
return 0;
- if (imag0 == 0)
+ if (complex_part_zero_p (imag0, class, submode))
{
/* Mathematically, ((a)(c-id))/divisor. */
/* Computationally, (a+i0) / (c+id) = (ac/(cc+dd)) + i(-ad/(cc+dd)). */
@@ -431,7 +449,7 @@ expand_cmplxdiv_wide (real0, real1, imag0, imag1, realr, imagr, submode,
/* Calculate dividend. */
- if (imag0 == 0)
+ if (complex_part_zero_p (imag0, class, submode))
{
real_t = real0;
@@ -1657,7 +1675,7 @@ expand_binop (mode, binoptab, op0, op1, target, unsignedp, methods)
case DIV:
/* (a+ib) / (c+id) = ((ac+bd)/(cc+dd)) + i((bc-ad)/(cc+dd)) */
- if (imag1 == 0)
+ if (complex_part_zero_p (imag1, class, submode))
{
/* (a+ib) / (c+i0) = (a/c) + i(b/c) */