On Thu, Nov 07, 2013 at 04:39:03PM +0100, Richard Biener wrote:
> On Thu, Nov 7, 2013 at 4:15 PM, Marek Polacek <pola...@redhat.com> wrote:
> > Here, forward propagation turned
> >   _6 = a.1_5 & 1;
> >   _7 = (_Bool) _6;
> > into
> >   _7 = (_Bool) a.1_5;
> > but that's wrong: e.g. if a = 2 then (_Bool) _6 is 0, but (_Bool) a.1_5 is 
> > 1.
> 
> ?
> 
> (_Bool) 2
> 
> should truncate the value to zero.

You're right, say:
_Bool foo (int x)
{
  return (_Bool) (x & 1);
}
which due to the simplify_conversion_from_bitmask optimization is optimized
into:
  _Bool _3;

  <bb 2>:
  _3 = (_Bool) x_1(D);
  return _3;
is indeed expanded as:
            (set (reg:QI 90 [ D.1789 ])
                (and:QI (reg:QI 90 [ D.1789 ])
                    (const_int 1 [0x1])))

        Jakub

Reply via email to