This is the mail archive of the gcc@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]

Re: Fast operations on floating point numbers?


Martin Reinecke wrote:

Hi,

I'm not completely sure whether this question belongs to a C/C++ newsgroup,
but it is probably compiler-specific, so I'm trying my luck here.


I'm developing a numerical simulation code which contains operations
like this one

double a;
int flipsign;

[...]

if (flipsign)
  a = -a;

in an inner loop which is executed billions of times.
I suspect that the conditional slows the execution down,
and the "a=-a" statement might not be optimal as well.

if you are on SSE2 platform (dunno if altivec...) and are using -mss2 -fmpmath=sse
double is mapped onto SSE2 regs. in that case I seem to remember that the NEG operation is optimized as a SSE XOR. the bit which I do not know is if it is even able to use the SSE insn to generate masks to avoid jumps... hope so...




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