This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/15826] don't use "if" to extract a single bit bit-field.
- From: "pinskia at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 4 Jun 2004 19:26:16 -0000
- Subject: [Bug tree-optimization/15826] don't use "if" to extract a single bit bit-field.
- References: <20040604185552.15826.kazu@cs.umass.edu>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From pinskia at gcc dot gnu dot org 2004-06-04 19:26 -------
Here is another example:
struct s {
unsigned int bit : 1;
};
unsigned int
foo (struct s *p)
{
int i;
if (p->bit)
i = 1;
else
i = 0;
return i;
}
I will note that the example in comment #1 needs to have the return values merged together before the
real optimization happens (see PR 15268 and a patch which I posted but have not gotten around to
answering/tying RTH's question/seguestion yet).
But basically it can be optimization by putting a cast to bool first so a != 0 becomes (bool)a and PHI-
opt already optimizated out the branches.
--
What |Removed |Added
----------------------------------------------------------------------------
BugsThisDependsOn| |15268
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15826