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

Thomas Koenig <tkoenig at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|2015-11-16 00:00:00         |2023-7-16
                 CC|                            |tkoenig at gcc dot gnu.org

--- Comment #7 from Thomas Koenig <tkoenig at gcc dot gnu.org> ---
Just stumbled across this.

A maybe simpler testcase:

typedef struct
{
  unsigned long x: 42;
  unsigned b: 1;
  unsigned long y: 42;
} myfield;

typedef struct
{
   unsigned long x: 7;  
   unsigned b: 1;
   unsigned long y: 42;
} yourfield;

void foo(myfield *x)
{
  x->b = 1;
}

void bar (yourfield *x)
{
    x->b = 1;
}

gets, on RISC-V,

foo:
        ld      a5,0(a0)
        li      a4,1
        slli    a4,a4,42
        or      a5,a5,a4
        sd      a5,0(a0)
        ret
bar:
        ld      a5,0(a0)
        ori     a5,a5,128
        sd      a5,0(a0)
        ret

Using an indexed load byte/store byte would be an advantage for foo, at least.

Reply via email to