This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/78947] sub-optimal code for (bool)(int ? int : int)
- From: "pinskia at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 29 Dec 2016 03:44:33 +0000
- Subject: [Bug middle-end/78947] sub-optimal code for (bool)(int ? int : int)
- Auto-submitted: auto-generated
- References: <bug-78947-4@http.gcc.gnu.org/bugzilla/>
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;
}