https://llvm.org/bugs/show_bug.cgi?id=26223
Bug ID: 26223 Summary: [GC] Effective rematerialization at non-entry polls Product: libraries Version: trunk Hardware: PC OS: Linux Status: NEW Severity: normal Priority: P Component: Scalar Optimizations Assignee: unassignedb...@nondot.org Reporter: listm...@philipreames.com CC: llvm-bugs@lists.llvm.org Classification: Unclassified (This bug is specific to the implementation of rewrite-statepoints-for-gc.) If we have a bit of code like this: %addr = gep %o, 8 loop { if (poll) { safepoint(); } load %addr } We currently end up rewriting this as: %addr = gep %o, 8 loop { %addr1 = phi (%addr, %addr2) if (poll) { safepoint(); %remat = gep %o.relocated, 8 } %addr2 = phi (%addr1, %remat) load %addr2 } This ends up forcing us to rematerialize the address explicitly and likely will cause us to spill/fill the address if register constrained. This creates a bunch of dependent loads (fill from stack, load from result) which show up as hot in a couple of benchmarks. A much better result would be: %addr = gep %o, 8 loop { if (poll) { safepoint(); } %remat = gep %o.relocated, 8 load %remat } This version allows the GEP to be folded directly into x86's native addressing modes. (Note: For conciseness, I'm not writing the phis for relocating %o, assume they're all there.) I can see a couple of ways of approaching this: - Rematerialize not at relocations, but at uses. This would require either a post rewriting CSE to clean up, or a bit of smarts to avoid naive placement. This might be overly x86 specific. - Push rematerializations into unconditional successors. This would have the effect of eliminating PHIs (because we know the remat is also legal there). - Add a post processing pass which tries to pull remat values through their only use. This could be done as either a step in RS4GC, or possibly just an instcombine rule. Given a single use gep of a gc-relocate, look to see if the single use is a phi of the original value. If so, replace the PHI with a gep of the PHI producing the fixed up base. -- You are receiving this mail because: You are on the CC list for the bug.
_______________________________________________ llvm-bugs mailing list llvm-bugs@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs