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

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Here is a bitfield testcase which shows this was a latent issue:
```
struct f
{
  unsigned t:3;
  unsigned t1:4;
};
unsigned f2(struct f);
unsigned
f1(int t, struct f y)
{
  int tt = 0;
  if(t)
    tt = y.t1;
  return tt;
}
```


We should produce:
```
        ubfx    w8, w1, #3, #4
        cmp     w0, #0
        csel    w0, wzr, w8, eq
        ret
``

But currently produces:
```
        cbz     w0, .L3
        ubfx    x0, x1, 3, 4
        ret
.L3:
        mov     w0, 0
        ret
```

The IR is similar too:
```
(insn 11 10 12 3 (set (subreg:DI (reg:QI 96) 0)
        (zero_extract:DI (subreg:DI (reg/v:SI 95 [ y ]) 0)
            (const_int 4 [0x4])
            (const_int 3 [0x3]))) "/app/example.cpp":12:11 832 {*extzvdi}
     (expr_list:REG_DEAD (reg/v:SI 95 [ y ])
        (nil)))
(insn 12 11 24 3 (set (reg:SI 93 [ <retval> ])
        (zero_extend:SI (reg:QI 96))) "/app/example.cpp":13:10 146
{*zero_extendqisi2_aarch64}
     (expr_list:REG_DEAD (reg:QI 96)
        (nil)))
```

Reply via email to