Open
Description
https://godbolt.org/z/b6vfG688K
typedef long int intptr_t;
typedef unsigned char uint8_t;
typedef unsigned short int uint16_t;
typedef unsigned int uint32_t;
typedef unsigned long int uint64_t;
typedef struct {
union {
uint8_t u6_ucaddr[16];
uint16_t u6_usaddr[8];
uint32_t u6_uladdr[4];
uint64_t u6_ulladdr[2];
} u6_addr;
} In6Addr;
struct policy_match_cond {
In6Addr src_ipv6;
In6Addr dst_ipv6;
};
typedef struct mbuf {
void *userdata;
} __attribute__((__aligned__(64))) Mbuf;
typedef struct {
In6Addr src_ip;
In6Addr dst_ip;
} __attribute__((__aligned__(64))) MbufContext;
void test(Mbuf *mbuf, struct policy_match_cond *condition)
{
(condition->dst_ipv6.u6_addr.u6_uladdr)[0] = ((((((((MbufContext *)((mbuf))->userdata))->dst_ip).u6_addr.u6_uladdr)[0])&0xFF000000) >> 24);
(condition->dst_ipv6.u6_addr.u6_uladdr)[1] = ((((((((MbufContext *)((mbuf))->userdata))->dst_ip).u6_addr.u6_uladdr)[1])&0xFF000000) >> 24);
}
Clang is one more load than GCC.
The primary cause maybe clang not handle union's TBAA, like issue #146652.
But in this case, we might be able to delete the second load in InstCombine/CSE/GVN step?