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] | |
This patch implements a fast copysign for PPC but only for -flag_unsafe_math_optimizations as it does not handle signed zeros correctly. This uses the optable which RTH added a couple of days ago to do this expansion.
With this patch copysign is expanded to:
fabs f0,f1
fnabs f1,f1
fsel f1,f2,f0,f1Which is faster and smaller than storing and doing bitfield operations on the sign bit.
Thanks, Andrew Pinski
ChangeLog: * config/rs6000/rs6000.md (copysignsf3): New expand. (copysigndf3): Likewise.
Attachment:
fastcopysign.diff.txt
Description: Text document
Testcase: /* { dg-do run } */ /* { dg-options "-O2 -ffast-math" } */
float copysignf(float,float); double copysign(double, double);
float fs(float a,float b) { return copysignf(a,b); }
double f(double a,double b)
{
return copysign(a,b);
}
float a = __builtin_inf();
float b = 1.0;
void abort(void);int main(void)
{
if (fs (a,a)!=__builtin_fabs(a))
abort();
if (fs (a,-a)!=-__builtin_fabs(a))
abort();
if (fs (-a,a)!=__builtin_fabs(a))
abort();
if (fs (-a,-a)!=-__builtin_fabs(a))
abort();if (f (a,a)!=__builtin_fabs(a)) abort(); if (f (a,-a)!=-__builtin_fabs(a)) abort(); if (f (-a,a)!=__builtin_fabs(a)) abort(); if (f (-a,-a)!=-__builtin_fabs(a)) abort();
if (fs (b,b)!=__builtin_fabs(b)) abort(); if (fs (b,-b)!=-__builtin_fabs(b)) abort(); if (fs (-b,b)!=__builtin_fabs(b)) abort(); if (fs (-b,-b)!=-__builtin_fabs(b)) abort();
if (f (b,b)!=__builtin_fabs(b)) abort(); if (f (b,-b)!=-__builtin_fabs(b)) abort(); if (f (-b,b)!=__builtin_fabs(b)) abort(); if (f (-b,-b)!=-__builtin_fabs(b)) abort(); }
| Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
|---|---|---|
| Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |