This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/19719] missed optimization on boolean operation with boolean arguments
- From: "rguenth at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 16 May 2005 13:52:09 -0000
- Subject: [Bug tree-optimization/19719] missed optimization on boolean operation with boolean arguments
- References: <20050131061122.19719.yuri@tsoft.com>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From rguenth at gcc dot gnu dot org 2005-05-16 13:52 -------
It's a problem of tree-lowering. In .t02.original we still have
return <retval> = (int) (a && b);
in .t03.generic it's
bool doAnd(bool, bool) (a, b)
{
int D.1578;
bool iftmp.0;
bool D.1582;
bool D.1583;
D.1582 = !a;
if (D.1582)
{
goto <D1580>;
}
else
{
}
D.1583 = !b;
if (D.1583)
{
goto <D1580>;
}
else
{
}
iftmp.0 = 1;
goto <D1581>;
<D1580>:;
iftmp.0 = 0;
<D1581>:;
D.1578 = (int) iftmp.0;
return D.1578;
}
Note that changing the function to
bool f(bool b1, bool b2) { int b1i = b1; int b2i = b2; return (!!b1i && !!b2i); }
results in the much better
bool manualAnd(bool, bool) (a, b)
{
int D.1590;
bool D.1591;
bool D.1592;
bool D.1593;
{
int ai;
int bi;
ai = (int) a;
bi = (int) b;
D.1591 = ai != 0;
D.1592 = bi != 0;
D.1593 = D.1591 && D.1592;
D.1590 = (int) D.1593;
return D.1590;
}
}
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19719