This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Tr : [redundency elimination, code motion, commun expression elimination] GCC optimizations


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 09/23/11 09:53, Jeff Kenton wrote:
> On 09/23/2011 11:16 AM, Ian Lance Taylor wrote:
>> David Brown<david@westcontrol.com>  writes:
>> 
>>>> It's the same for
>>>> 
>>>> if (x == 1)      { a=b; c=d; e=f; foo(); } else if (x == 2) {
>>>> a=b; c=d; e=f; foo(); }
>>>> 
>>>> GCC don't factor out the common part
>>>> 
>>> You are right - which is odd, since there is no reason why it
>>> could not (unlike the original case where there is no "else").
>>> Surely this would count as a significant missed optimisation,
>>> especially for big switch() code.
>> I don't think it is a significant missed optimization, as people
>> rarely write code like that.  They normally write
>> 
>> if (x == 1 || x == 2) { a=b; c=d; e=f; foo(); }
>> 
>> The proposed optimization only applies when somebody has
>> laboriously written out the exact same sequence of code twice.
>> 
>> I'm not opposed to such an optimization if it works reliably and
>> is not too expensive.  I just don't think it will make much
>> difference on ordinary code.
>> 
>> Ian
> 
> People don't write that kind of code (we hope), but machine
> generated code can have all kinds of weirdness.  Still not a big
> deal, but it might be more common than you think.
The tail merging code in the RTL optimizers might pick this stuff up
and Tom's work on block merging might as well.  It'd be worth looking
into why they aren't triggering.

jeff
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJOfK5HAAoJEBRtltQi2kC7pbIH/1tT4EPQlxJaUqlW4Strw6aE
1XfD5YHlcwnMvcbDbmZuglRVtQN+YZptw7rWfJ/47Pvad4yuzvOUmhQKUyYCd0q+
7bXXBDNP9irxoDOOuU5EA9678ZFIiCCDVFAy/ld3WmiP5UQ+Zkx4GEPwsWoIjmvh
umcCRFFQXK+Kosnxcqk9cbhYRg3/9aaP2FSuthoveZbRk9cZQcQyfyxz9RMaCli+
hFe6wh/l7d8h+8WUummebV9B5y+zKehtXH3G+f43EyWKm8LwnNPLLj6dU/1J/6IB
OPrPjgCLAbz+k7P28VpzSfW18td3wMnBFioE3t89PdJfQwTgYK1wC3iIdVkm8RA=
=we18
-----END PGP SIGNATURE-----


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]