[PATCH] Have fold transform bool_var != 1 to !bool_var
Andrew Pinski
pinskia@physics.uc.edu
Thu Nov 24 21:18:00 GMT 2005
I noticed that fold was not converting bool_var != 1 (and bool_var == 0) to
!bool_var which gives a little better code generation for the function like:
_Bool f(_Bool a)
{
return a!=1;
}
For x86_64 currently we get:
xorl %eax, %eax
cmpb $1, %dil
setne %al
ret
With the patch I am posting, we get it to:
movzbl %dil, %eax
xorl $1, %eax
ret
Which is much better and shorter.
OK? Bootstapped and tested on x86_64-linux-gnu with no
regressions.
Thanks,
Andrew Pinski
ChangeLog:
* fold-const.c (fold_build): Convert bool_var != 1 and
bool_var == 0 to !bool_var.
* gcc.dg/tree-ssa/bool-10.c: New test.
* gcc.dg/tree-ssa/bool-11.c: New test.
* /gcc.dg/tree-ssa/bool-7.c: Un-xfail.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: fixPR24989.diff.txt
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20051124/b405a59f/attachment.txt>
More information about the Gcc-patches
mailing list