Re: Missed optimization question

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

 



On Sun, 1 Dec 2019, Arvind Sankar wrote:

Hi, for the below example, gcc (9.2.0) at -O and above generates
identical code for f1 and f2 (on x86_64 at least). So one would think
that the compiler "knows" that the min(m,b) can be reduced to m, however
f3 doesn't get optimized away into return 1; at any level of
optimization.

f4 is closest to the real example, where there's a bounds check on a
variable that was already min'd with the bound, but the check doesn't
get optimized away.

Why would this be the case?

Please file a report in gcc's bugzilla.

min(a,min(a,b)) is only simplified during reassoc. min(a,b)<=b is not simplified. min(a,b)==b is simplified to a>=b before reassoc.

Adding 2 transformations to match.pd would be quite simple, but is unlikely to happen until there is a bug report in the right place.

--
Marc Glisse



[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