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 kazu at cs dot umass dot edu  2004-06-16 06:20 -------
Now that we have a single return statement, let me regenerate t50.tailc.

struct s {
  unsigned int bit : 1;
};

unsigned int
foo (struct s *p)
{
  if (p->bit)
    return 1;
  else
    return 0;
}

unsigned int
bar (struct s *p)
{
  return (unsigned int) (p->bit);
}

unsigned int
andrew (struct s *p)
{
  int i;
  if (p->bit)
    i = 1;
  else
    i = 0;
  return i;
}

I get:

;; Function foo (foo)

foo (p)
{
  _Bool T.7;
  unsigned int T.2;
  int T.1;
  unsigned int T.0;

<bb 0>:
  T.0_3 = p_2->bit;
  T.7_8 = T.0_3 != 0;
  T.2_1 = (unsigned int)T.7_8;
  return T.2_1;

}



;; Function bar (bar)

bar (p)
{
  unsigned int T.3;

<bb 0>:
  T.3_2 = p_1->bit;
  return T.3_2;

}



;; Function andrew (andrew)

andrew (p)
{
  _Bool T.16;
  int i;
  unsigned int T.6;
  int T.5;
  unsigned int T.4;

<bb 0>:
  T.4_3 = p_2->bit;
  T.16_9 = T.4_3 != 0;
  i_1 = (int)T.16_9;
  T.6_5 = (unsigned int)i_1;
  return T.6_5;

}

So basically, the problems boils down to the tree combiner.


-- 


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]