[Bug rtl-optimization/118887] New: Missed CSE of symbolic address computation
law at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Sat Feb 15 05:40:22 GMT 2025
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118887
Bug ID: 118887
Summary: Missed CSE of symbolic address computation
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: rtl-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: law at gcc dot gnu.org
Target Milestone: ---
This code on riscv generates poor code at -O2:
struct S
{
char p[48];
unsigned long long q, r, s;
} s[50];
struct D
{
unsigned long long q, r;
} d[50];
void
foo (void)
{
unsigned long i;
for (i = 0; i < 50; ++i)
{
d[i].q = s[i].q;
d[i].r = s[i].r;
}
}
In particular note the redundant address calculations for "s":
lui a1,%hi(s+2047)
addi a1,a1,%lo(s+2047)
lui a5,%hi(s+48)
addi a5,a5,%lo(s+48)
To produce s+48, we could have just subtracted 1999 from the s+2047
computation. That would have an instruction.
More information about the Gcc-bugs
mailing list