This is an archive of the discontinued LLVM Phabricator instance.

[GlobalISel][Localizer] Rewrite localizer to run in 2 phases, inter & intra block.
ClosedPublic

Authored by aemerson on Jun 13 2019, 3:45 PM.

Details

Summary

Inter-block location is the same as what currently happens, except now it only runs on the entry block because that's where the problematic constants with long live ranges come from.

The second phase is a new intra-block localization phase which attempts to re-sink the already localized instructions further right before one of the multiple uses.

One additional change is to also localize G_GLOBAL_VALUE as they're constants too, unless it has more than 2 users.

Overall, these changes improve CTMark code size on arm64 by 1.2%.

Full code size results:

Program                                         baseline       new       diff
------------------------------------------------------------------------------
 test-suite...-typeset/consumer-typeset.test    1249984      1217216     -2.6%
 test-suite...:: CTMark/ClamAV/clamscan.test    1264928      1232152     -2.6%
 test-suite :: CTMark/SPASS/SPASS.test          1394092      1361316     -2.4%
 test-suite...Mark/mafft/pairlocalalign.test    731320       714928      -2.2%
 test-suite :: CTMark/lencod/lencod.test        1340592      1324200     -1.2%
 test-suite :: CTMark/kimwitu++/kc.test         3853512      3820420     -0.9%
 test-suite :: CTMark/Bullet/bullet.test        3406036      3389652     -0.5%
 test-suite...ark/tramp3d-v4/tramp3d-v4.test    8017000      8016992     -0.0%
 test-suite...TMark/7zip/7zip-benchmark.test    2856588      2856588      0.0%
 test-suite...:: CTMark/sqlite3/sqlite3.test    765704       765704       0.0%
 Geomean difference                                                      -1.2%

Diff Detail

Repository
rL LLVM

Event Timeline

aemerson created this revision.Jun 13 2019, 3:45 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 13 2019, 3:45 PM
paquette added inline comments.Jun 14 2019, 10:55 AM
llvm/lib/CodeGen/GlobalISel/Localizer.cpp
51 ↗(On Diff #204645)

Do we know how this impacts other targets?

qcolombet accepted this revision.Jun 14 2019, 11:02 AM

LGTM modulo want @paquette pointed out.

This revision is now accepted and ready to land.Jun 14 2019, 11:02 AM
aemerson marked an inline comment as done.Jun 14 2019, 12:10 PM
aemerson added inline comments.
llvm/lib/CodeGen/GlobalISel/Localizer.cpp
51 ↗(On Diff #204645)

I'm not able to test that, but I think that if we're going to improve this pass and accept it's not simply a short term hack, we need to put this into a target cost model.

I'll also change this to not use std::distance but loop until we hit a threshold for compile time reasons.

This revision was automatically updated to reflect the committed changes.