This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Fields, unions, and code quality
- From: Andrew Pinski <pinskia at physics dot uc dot edu>
- To: Andrew Haley <aph at redhat dot com>
- Cc: gcc at gcc dot gnu dot org
- Date: Tue, 20 Jun 2006 08:37:39 -0700
- Subject: Re: Fields, unions, and code quality
- References: <17560.1066.877603.629385@dell.pink>
On Jun 20, 2006, at 7:20 AM, Andrew Haley wrote:
Does using fields of auto variables of union type generate code that
is less efficient than it would be using scalars?
If it is only one used field at a time (and the address is not taken),
then FRE will resolve them.
Take:
int f(int t, int t1)
{
union f
{
int n;
float n1;
} f1, f2;
f1.n = t;
f2.n1 = t1;
int t2 = f1.n;
f1.n1 = t2;
return f1.n1 + f2.n1 * f1.n1;
}
in final_cleanup, we get:
D.1522 = (float) t;
return (int) (D.1522 + (float) t1 * D.1522);