Re: Executing code at compilation time

glen herrmannsfeldt <gah@ugcs.caltech.edu>
Wed, 17 Mar 2010 05:54:37 +0000 (UTC)

          From comp.compilers

Related articles
[6 earlier articles]
Re: Executing code at compilation time apoelstra@localhost.localdomain (Andrew Poelstra) (2010-03-16)
Re: Executing code at compilation time bear@sonic.net (Ray) (2010-03-16)
Re: Executing code at compilation time pat@jantar.org (Patryk Zadarnowski) (2010-03-17)
Re: Executing code at compilation time shreyas76@gmail.com (shrey) (2010-03-16)
Re: Executing code at compilation time pronesto@gmail.com (Fernando Magno Quintao Pereira) (2010-03-16)
Re: Executing code at compilation time pat@jantar.org (Patryk Zadarnowski) (2010-03-17)
Re: Executing code at compilation time gah@ugcs.caltech.edu (glen herrmannsfeldt) (2010-03-17)
Re: Executing code at compilation time bear@sonic.net (Ray) (2010-03-19)
Re: Executing code at compilation time bear@sonic.net (Ray) (2010-03-19)
Re: Executing code at compilation time bobduff@shell01.TheWorld.com (Robert A Duff) (2010-03-21)
Re: Executing code at compilation time torbenm@diku.dk (2010-03-22)
Re: Executing code at compilation time bear@sonic.net (Ray) (2010-03-22)
Re: Executing code at compilation time gah@ugcs.caltech.edu (glen herrmannsfeldt) (2010-03-23)
[1 later articles]
| List of all articles for this month |
From: glen herrmannsfeldt <gah@ugcs.caltech.edu>
Newsgroups: comp.compilers
Date: Wed, 17 Mar 2010 05:54:37 +0000 (UTC)
Organization: California Institute of Technology, Pasadena
References: 10-03-038 10-03-044
Keywords: optimize, errors
Posted-Date: 18 Mar 2010 00:04:19 EDT

Quinn Tyler Jackson <quinn_jackson2004@yahoo.ca> wrote:
(snip)


>> for(k = 0; k < 1000; k++)
>> if(i * i + j * j + k * k % 7 == 0) t++;


This looks suspicious for the symmetry that it doesn't have.
It evaluates as:


                    if(((i * i) + (j * j) + (k * k % 7)) == 0) t++;


The compiler might be able to figure out that when i or j
is positive that the if condition is false.


                if((i * i + j * j + k * k) % 7 == 0) t++;


would have a very different result.


-- glen



Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.