This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug target/68690] New: PowerPC64: TOC save in PHP core loop results in load hit store
- From: "anton at samba dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 04 Dec 2015 04:45:18 +0000
- Subject: [Bug target/68690] New: PowerPC64: TOC save in PHP core loop results in load hit store
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68690
Bug ID: 68690
Summary: PowerPC64: TOC save in PHP core loop results in load
hit store
Product: gcc
Version: 6.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
Assignee: unassigned at gcc dot gnu.org
Reporter: anton at samba dot org
Target Milestone: ---
We see a load hit store issue in the core loop of the PHP interpreter. A simple
test case:
$ cat test.c
void (*fn)(void);
void do_nothing(void) { }
int main(void)
{
unsigned long i;
fn = do_nothing;
for (i = 0; i < 1000000000; i++)
fn();
return 0;
}
$ gcc -O2 -o test test.c
We continually save the TOC on each call:
100003f0: 00 00 3e e9 ld r9,0(r30)
100003f4: a6 03 29 7d mtctr r9
100003f8: 78 4b 2c 7d mr r12,r9
100003fc: 18 00 41 f8 std r2,24(r1) <---------- save it again!
10000400: 21 04 80 4e bctrl
10000404: 18 00 41 e8 ld r2,24(r1)
10000408: 01 00 3f 2c cmpdi r31,1
1000040c: ff ff ff 3b addi r31,r31,-1
10000410: e0 ff 82 40 bne 100003f0 <main+0x40>
This should be moved out of the loop. One way to force that is via the
-msave-toc-indirect option:
gcc -msave-toc-indirect -O2 -o test test.c
Which is over 2x faster on this (admittedly worst case) test. For something
more real world, we also see a 20% speedup on PHP7 on various microbenchmarks.