https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99919

Aldy Hernandez <aldyh at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |aldyh at gcc dot gnu.org

--- Comment #3 from Aldy Hernandez <aldyh at gcc dot gnu.org> ---
(In reply to Martin Sebor from comment #1)
> The IL below shows there is enough information in the IL for the warning to
> determine that x_5 is never read from.
> 
> void g (struct B b)
> {
>   _Bool b$j;
>   _Bool b$i;
>   _Bool x;
>   unsigned char _1;
>   unsigned char _2;
>   unsigned char _3;
>   unsigned char _4;
> 
>   <bb 2> [local count: 1073741824]:
>   b$i_11 = b.i;
>   _1 = VIEW_CONVERT_EXPR<unsigned char>(b);
>   _2 = _1 & 1;
>   if (_2 != 0)
>     goto <bb 4>; [50.00%]
>   else
>     goto <bb 3>; [50.00%]
> 
>   <bb 3> [local count: 536870912]:
> 
>   <bb 4> [local count: 1073741824]:
>   # x_5 = PHI <x_8(D)(2), b$i_11(3)>
>   # b$j_10 = PHI <0(2), b$i_11(3)>
>   b.j = b$j_10;
>   _3 = VIEW_CONVERT_EXPR<unsigned char>(b);
>   _4 = _3 & 2;
>   if (_4 != 0)
>     goto <bb 5>; [50.00%]
>   else
>     goto <bb 6>; [50.00%]
> 
>   <bb 5> [local count: 536870913]:
>   z = x_5;
> 
>   <bb 6> [local count: 1073741824]:
>   return;
> 
> }

The warning on the above IL seems legit.

x_5 is initialized from b$i_11 when b & 1 == 0, but the read from x_5 happens
when b & 2 != 0.  So the set and the read are predicated on two different
things.

Maybe I'm missing some subtle bit field thing.  Does setting b.j somehow alter
b.i?

Reply via email to