This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug tree-optimization/15826] don't use "if" to extract a single bit bit-field.


------- 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]