On 12 June 2015 at 14:03, Eric Blake <ebl...@redhat.com> wrote: > On 06/12/2015 05:01 AM, Peter Maydell wrote: > >>> 4. >>> >>> [qemu/target-arm/translate-a64.c:5729]: (style) Redundant condition: >>> size<3. 'A && (!A || B)' is equivalent to 'A || B' >>> >>> if (size > 3 >>> || (size < 3 && is_q) >>> || (size == 3 && !is_q)) { >> >> ...but I'm less sure about this one. I'm not even sure >> what it's trying to suggest this should simplify to: >> just dropping "size < 3" is obviously wrong, and the >> condition format isn't "A && (!A || B)" either. > > Let's break it down into the 6 possibilities based on the binary * > ternary conditions being checked: > >> 3, is_q => accept >> 3, !is_q => accept > == 3, is_q => reject > == 3, !is_q => accept > < 3, is_q => accept > < 3, !is_q => reject > > Here's a shorter conditional with the same properties, but it's gross: > > if (size > 3 || (is_q != (size == 3))) { > > Too much mental thought to prove it accepts the same set of conditions.
Yeah, I think this is the kind of thing where I say "the compiler should do this simplification if it cares enough" :-) -- PMM