https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126729
Bug ID: 126729
Summary: [17 Regression] factor load does not handle
scalar_storage_order correctly.
Product: gcc
Version: 17.0
Status: UNCONFIRMED
Keywords: wrong-code
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: pinskia at gcc dot gnu.org
Target Milestone: ---
Take:
```
struct S0 { int a; int v; }
__attribute__((scalar_storage_order("little-endian")));
union U0 { struct S0 s; int i[2]; }
__attribute__((scalar_storage_order("little-endian")));
struct S1 { int a; int v; }
__attribute__((scalar_storage_order("big-endian")));
union U1 { struct S1 s; int i[2]; }
__attribute__((scalar_storage_order("big-endian")));
int f(void *a, bool b, bool bb)
{
if (b)
{
union U0 t = *((union U0*)a);
if (bb)
return t.i[0];
return t.s.a;
}
{
union U1 t = *((union U1*)a);
if (bb)
return t.i[0];
return t.s.a;
}
}
```
There should be a bytswap on either of the branches but currently there is not.