This is an archive of the discontinued LLVM Phabricator instance.

[GlobalISel] Improve elimination of dead instructions in legalizer
ClosedPublic

Authored by Petar.Avramovic on Sep 2 2021, 6:54 AM.

Details

Summary

Add eraseInstr(s) utility function. Before deleting an instruction
collects its use instructions. After deletion deletes use instructions
that became trivially dead.
This patch clears all dead instructions in existing legalizer mir tests.

Diff Detail

Event Timeline

Petar.Avramovic created this revision.Sep 2 2021, 6:54 AM
Petar.Avramovic requested review of this revision.Sep 2 2021, 6:54 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 2 2021, 6:54 AM
aemerson added inline comments.Sep 2 2021, 2:05 PM
llvm/lib/CodeGen/GlobalISel/Legalizer.cpp
187

Is this observer call necessary? I thought deletions were automatically handled?

arsenm added inline comments.Sep 2 2021, 5:20 PM
llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp
2827–2828

Why does custom legalization need special casing? Why doesn't the observer get these too?

Petar.Avramovic edited the summary of this revision. (Show Details)

move eraseInstrs to utils, also use it in custom legalize.

aemerson accepted this revision.Sep 18 2021, 3:05 PM

The data from D109858 shows that this approach gives a measurable improvement in compile time, especially at -O0. LGTM.

This revision is now accepted and ready to land.Sep 18 2021, 3:05 PM
This revision was landed with ongoing or failed builds.Sep 20 2021, 4:02 AM
This revision was automatically updated to reflect the committed changes.

Thanks for the review and compile time performance testing.

foad added inline comments.Sep 21 2021, 2:34 AM
llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-fcanonicalize.mir
5

Did you mean to remove this line? Is codegen different for GFX9 and GFX10 now?

llvm/test/CodeGen/AMDGPU/GlobalISel/legalize-fcanonicalize.mir
5

No, missed that. Basically when two lines share check prefix script(update_mir_test_checks) shuffles check blocks, so I run script without shared prefixes and then return # RUN: lines that share prefix.