This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

MIPS patch for nmadd/nmsub w/wo fast-math


While working on the vector float stuff, I noticed that we didn't
generate nmadd instructions when -ffast-math was used.  Then I noticed
that we didn't generate nmsub instructions unless -ffast-math was used.

This is an unfortunate side-effect of a change from Geoff Keating in Dec
2002.  Because some FP optimizations can only be performed when
-ffast-math is used, we end up with different canonical representations
for nmadd/nmsub depending on whether -ffast-math was used.  Thus we need
two patterns for them in the md file, one for the normal case and one
for the fast math case.  This is a bit annoying, but I don't see any way
around it.  We will lose some optimizations if we don't canonicalize
this way.

This patch adds the necessary patterns.  One tests HONOR_SIGNED_ZEROS
and one tests ! HONOR_SIGNED_ZEROS.  This is based on the equivalent
code Geoff added to the rs6000.md file.

You can see the effect with the attached testcase (you can ignore the
vector float stuff for now).  Without this patch, there is no nmadd
instruction when -ffast-math is used, and no nmsub instruction without
-ffast-math.  With this patch, we generate nmadd/nmsub both with and
without -ffast-math.

This was tested with an sb1-elf toolchain built from a combined tree,
with C and C++ built and tested.  There were no regressions.
-- 
Jim Wilson, GNU Tools Support, http://www.SpecifixInc.com

Attachment: patch.nmadd.fastmath
Description: Text document

typedef float psingle __attribute__ ((vector_size(8)));

psingle
sub1 (psingle f, psingle g, psingle h)
{
  return -((f * g) + h);
}

float
sub2 (float f, float g, float h)
{
  return -((f * g) + h);
}

double
sub3 (double f, double g, double h)
{
  return -((f * g) + h);
}

psingle
sub4 (psingle f, psingle g, psingle h)
{
  return -((f * g) - h);
}

float
sub5 (float f, float g, float h)
{
  return -((f * g) - h);
}

double
sub6 (double f, double g, double h)
{
  return -((f * g) - h);
}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]