Page MenuHomePhabricator

[AMDGPU] Do not generate mul with 1 in AMDGPU Atomic Optimizer
ClosedPublic

Authored by mbrkusanin on Fri, Sep 25, 9:10 AM.

Details

Summary

Check if operand of mul is constant value of one for certain atomic
instructions in order to avoid making unnecessary instructions when
-amdgpu-atomic-optimizer is present.

Diff Detail

Event Timeline

mbrkusanin created this revision.Fri, Sep 25, 9:10 AM
mbrkusanin requested review of this revision.Fri, Sep 25, 9:10 AM
arsenm added inline comments.Fri, Sep 25, 10:55 AM
llvm/test/CodeGen/AMDGPU/atomic_optimizations_mul_one.mir
1 ↗(On Diff #294336)

It's weird to use MIR and -run-pass for an IR pass. Should have regular ll test, with an end to end llc line and an opt line for just the pass

foad added inline comments.Mon, Sep 28, 4:16 AM
llvm/lib/Target/AMDGPU/AMDGPUAtomicOptimizer.cpp
407

It would be neater to have a BuildMul helper function that checks for and optimizes the mul-by-1 case.

  • Changed test to opt + llc global-isel (SDag was already removing these mul instructions, just later on). Should I split the file into two tests?
mbrkusanin added inline comments.Mon, Sep 28, 7:50 AM
llvm/lib/Target/AMDGPU/AMDGPUAtomicOptimizer.cpp
407

A new BuildMul or update the current one (looks like some unittests need to be updated in this case)?

foad added inline comments.Mon, Sep 28, 7:56 AM
llvm/lib/Target/AMDGPU/AMDGPUAtomicOptimizer.cpp
407

I was suggesting a new BuildMul helper function in this source file, not changing IRBuilder at all.

  • Added buildMul that checks for mul with 1.
arsenm added inline comments.Tue, Sep 29, 6:31 AM
llvm/test/CodeGen/AMDGPU/GlobalISel/atomic_optimizations_mul_one.ll
8–11

These negative checks are extremely fragile. These should use positive checks

  • Updated llc test check lines.
llvm/test/CodeGen/AMDGPU/GlobalISel/atomic_optimizations_mul_one.ll
8–11

Just llc or opt check lines as well?

arsenm added inline comments.Tue, Sep 29, 7:22 AM
llvm/test/CodeGen/AMDGPU/GlobalISel/atomic_optimizations_mul_one.ll
8–11

Both. Negative checks are just too easy to get wrong

  • Updated opt test check lines.
arsenm accepted this revision.Tue, Sep 29, 7:46 AM
This revision is now accepted and ready to land.Tue, Sep 29, 7:46 AM