This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/40052] missed optimizations on (extended) logical types: (x | 1) --> 1
- 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: 7 May 2009 09:36:19 -0000
- Subject: [Bug tree-optimization/40052] missed optimizations on (extended) logical types: (x | 1) --> 1
- References: <bug-40052-12182@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #2 from rguenth at gcc dot gnu dot org 2009-05-07 09:36 -------
Of course this only works if logicals are zero-extended.
We manage to fold
int foo(unsigned char b)
{
return b | 0xff;
}
but not
int bar(unsigned char b)
{
return b & (~0 << 8);
}
appearantly because the C FE for the former generates (int) (b | 255)
because of some premature optimization in build_binary_op.
We still do not fold
int foo(unsigned char b)
{
return b | 0xfff;
}
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40052