This is the mail archive of the gcc-bugs@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]

[Bug middle-end/78947] sub-optimal code for (bool)(int ? int : int)


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78947

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2016-12-29
     Ever confirmed|0                           |1

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed, this is fold-cost folding:
(bool)(a?b:c)
into a ? (bool) b : (bool)c;
early.

Rewriting the code slightly gets the code you wanted:
bool condSet(int cond, int a, int b) {
    int c;
    c = cond ? a : b;
    return c;
}

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