http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59429
--- Comment #8 from Jeffrey A. Law <law at redhat dot com> --- So I think we need to make a gross level determination of what a canonical form for this stuff ought to be, then look at what it would take to transform into that canonical form. I think the key here is to realize that we want the negated constant to be the true result of the first COND_EXPR and the 0/1 result to always be the result of the second COND_EXPR. That way the negated constant is carried by the PHI node and we can use the result of the second COND_EXPR directly without additional code.