Article View: gnu.gcc.bug
Article #897Re: Performance anomoly using constructor expressions
From: Ron Guilmette
Date: Sat, 20 Jan 1990 04:36
Date: Sat, 20 Jan 1990 04:36
28 lines
1589 bytes
1589 bytes
In article <9001121726.AA22371@dopey.cs.unc.edu> alexande@cs.unc.edu (Geoffrey D. Alexander) writes: >I have encountered a strange peformance anomoly using contstructor expressions. ... > >Now, modify the this program so that the value of MULT_COMPLEX(x,x) is saved in >a temporary variable. ... > >Now, compile the programs as follows: > > gcc test4a.c -O -o test4a > gcc test4b.c -O -o test4b > >Running on a Sun3-60M (w/o floating point chip) under SunOS Release 4.0.3, >test4a takes 4.1 seconds, while test4b takes only 2.3 seconds. Anyone care >to explain why? I believe that it is because of the fact that constructor expressions are treated as "executable" by the compiler (regardless of whether or not their "components" are compile-time constants). Thus, each time you "execute" the constructor expression, code must be executed to (again) copy each of the components into some (often temporary) area. If you "construct" only once and copy the value into your own "temporary" structure and then use that from then on, then you only pay for the actual "construction" operation once. // rfg
Technical Details
Message-ID:
<25B7EACF.23324@paris.ics.uci.edu>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!usc!jarthur!uci-ics!rfgReferences:
<9001121726.AA22371@dopey.cs.unc.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!usc!jarthur!uci-ics!rfg From: rfg@ics.uci.edu (Ron Guilmette) Newsgroups: gnu.gcc.bug Subject: Re: Performance anomoly using constructor expressions Message-ID: <25B7EACF.23324@paris.ics.uci.edu> Date: 20 Jan 90 04:36:31 GMT References: <9001121726.AA22371@dopey.cs.unc.edu> Reply-To: rfg@ics.uci.edu (Ron Guilmette) Distribution: gnu Organization: UC Irvine Department of ICS Lines: 28