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

            Bug ID: 71509
           Summary: Bitfield causes load hit store with larger store than
                    load
           Product: gcc
           Version: 7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: anton at samba dot org
  Target Milestone: ---

I notice a nasty load hit store in the following test case built with -O2 on
ppc64le. The load is larger than the store, which means on many CPUs the store
cannot be forwarded and it has to wait until it completes in the cache.

struct sk_buff a;

struct sk_buff {
        long blah;
        char csum_level:2;
};

void __skb_decr_checksum_unnecessary(struct sk_buff *p1)
{
        p1->csum_level--;
}

void func(void);

void tcp_v4_rcv(void)
{
        struct sk_buff *b = &a;

        func();
        __skb_decr_checksum_unnecessary(b);
        func();
        __skb_decr_checksum_unnecessary(b);
}

We end up with this odd situation where we do both a byte and a double
word load:

# objdump  -d testcase.o | grep r31

  58:   08 00 5f e9     ld      r10,8(r31)
  5c:   08 00 3f 89     lbz     r9,8(r31)
  70:   08 00 3f 99     stb     r9,8(r31)

  7c:   08 00 5f e9     ld      r10,8(r31)
  84:   08 00 3f 89     lbz     r9,8(r31)
  a0:   08 00 3f 99     stb     r9,8(r31)

Reply via email to