attribute pure and gcse

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

according to the gcc 3.3 manual, functions marked pure
should be candidates for common subexpression
elimination.

In the following case (which seems a good candidate),
the second call to square is not eliminated by gcse
(leastaways not with 3.3 on ppc). Is this expected, or
should cse be doing better here?

int square(int a) __attribute__ ((pure));

int square(int a)
{
        int j=0;
        while(j!=a)
        {
                a = j*a;
                j++;
        }
        return a;
}

int main()
{
        return square(2) * square(2);
}


Thanks,

Dara

__________________________________
Do you Yahoo!?
Yahoo! Small Business $15K Web Design Giveaway 
http://promotions.yahoo.com/design_giveaway/

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux