From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,270d47706116d3c X-Google-Attributes: gid103376,public From: "Marin David Condic, 407.796.8997, M/S 731-93" Subject: Re: Can compilers do this? Date: 1996/02/26 Message-ID: <96022613123645@psavax.pwfl.com>#1/1 X-Deja-AN: 141388062 sender: Ada programming language comments: Gated by NETNEWS@AUVM.AMERICAN.EDU x-vms-to: SMTP%"info-ada@vm1.nodak.edu" newsgroups: comp.lang.ada x-vms-cc: CONDIC Date: 1996-02-26T00:00:00+00:00 List-Id: Robert Dewar writes: >Subject: Re: Can compilers do this? > >BwB says > >"Also, suppose Y and X are floating point variables, and M and B are >CONSTANT floating point variables (not named numbers) initialized to >1.0 and 0.0 respectively. If one writes > > Y := M * X + B ; > >can (and will) any compiler reduce this to > > Y := X ; > > >Sure, this is just standard constant propagation, a very common >optimization. > Except that you might not always want to. Constant folding can be a "good" optimization from a speed standpoint, but a "bad" optimization from a test standpoint. When we build control systems, we typically like to keep tables and assorted "constants" as "rubber constants". They are declared constants so that the program can't change the values, but when they're loaded into the box, we can change them with test equipment in order to affect "trim" on the control or accomplish other test stuff. If they were optimized away, you couldn't do this. The EDS-Scicon compiler we are working with gives us a "pragma VOLATILE" command to make sure that the constants aren't optimized away. I personally think anyone making a compiler for embedded systems should provide a similar option Pax, MDC Marin David Condic, Senior Computer Engineer ATT: 407.796.8997 M/S 731-93 Technet: 796.8997 Pratt & Whitney, GESP Fax: 407.796.4669 P.O. Box 109600 Internet: CONDICMA@PWFL.COM West Palm Beach, FL 33410-9600 Internet: MDCONDIC@AOL.COM =============================================================================== "Nobody shot me." -- Last words of Frank Gusenberg when asked by police who shot him fourteen times with a machine gun in the Saint Valentine's Day Massacre. ===============================================================================