🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.help
Article #603

Extra instructions spuriously generated

#603
From: 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
Technical Details
Message-ID: <9211112021.AA14320@strident.think.com>
Path: arc1-ca.pugleaf.net!sparky!uunet!convex!darwin.sura.net!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!think.com!mob

Show Full Headers
Complete Article Headers
Newsgroups: gnu.gcc.help
Path: arc1-ca.pugleaf.net!sparky!uunet!convex!darwin.sura.net!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!think.com!mob
From: mob@think.com (Mario O. Bourgoin)
Subject: Extra instructions spuriously generated
Message-ID: <9211112021.AA14320@strident.think.com>
Sender: daemon@cis.ohio-state.edu
Organization: GNUs Not Usenet
Distribution: gnu
Date: Wed, 11 Nov 1992 20:21:50 GMT
Lines: 23