- To: gcc-help@xxxxxxxxxxx
- Subject: Re: Which pass optimizes if (x != x + 10) to if (1)?
- From: Andrew Haley <aph@xxxxxxxxxx>
- Date: Wed, 21 Mar 2012 09:25:32 +0000
- Comment: DKIM? See http://www.dkim.org
- Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys
- In-reply-to: <CACgzC7AVnGWCxU9pWk6WJgw7WrKH7=5opNydQJPCmyWuLdwWDQ@mail.gmail.com>
- User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.1) Gecko/20120216 Thunderbird/10.0.1
On 03/21/2012 07:00 AM, Zhenqiang Chen wrote:
> Thank you for the comment. I found the root cause. In function
> tree_swap_operands_p (fold-const.c), there is a check
>
> if (optimize_function_for_size_p (cfun))
> return 0;
>
> which blocks to swap (x != x + 10) to (x + 10 != x). And the following
> optimization can only handle (x + 10 != x).
>
> In most cases, constant-folding will benefit for code size. Any reason
> to add this check?
If you search the history you'll probably find a bug that was
fixed by this (admittedly rather odd) test.
Andrew.
[Linux C Programming]
[Linux Kernel]
[eCos]
[Fedora Development]
[Fedora Announce]
[Autoconf]
[The DWARVES Debugging Tools]
[Yosemite Campsites]
[Yosemite News]
[Linux GCC]