🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by Mario O. Bourgoin Wed, 11 Nov 1992 20:21
Extra instructions spuriously generated
#603
Author: Mario O. Bourgoin
Date: Wed, 11 Nov 1992 20:21
21 lines
1199 bytes
In trying to get to the bits of a floating point constant under GCC, I have
come up with casting it to the union of an unsigned and a float:

	((union {unsigned u; float f;}) (float) 3.1).u

This mercifully resolves to an immediate constant when compiled -O.
Unfortunately, the corresponding double cast:

	((union {unsigned u; double d;}) (double) 3.1).u

invariably results in the generation of four instructions to load both
parts of the double in a pair of registers, whether or not the second part
of the double is ever used.

In the best of all worlds, I would prefer that an immediate constant be
generated, but I would settle for just eliminating the useless load of the
second part of the double.  Could someone direct me on how to get GCC to do
this?

--Mario
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads