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: dewar@cs.nyu.edu (Robert Dewar) Subject: Re: Can compilers do this? Date: 1996/02/23 Message-ID: #1/1 X-Deja-AN: 140844205 references: <4gjd6g$mfq@newsbf02.news.aol.com> organization: Courant Institute of Mathematical Sciences newsgroups: comp.lang.ada Date: 1996-02-23T00:00:00+00:00 List-Id: To follow up BwB's question "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 ;" They do not even have to be CONSTANT floating point variables, the compiler may well be able to figure out the current values of variables without them being CONSTANT. If indeed they are constant, I cannot imagine any compiler that would NOT do the optimization you suggest. Any compiler that did not is broken if you ask me!