This is an archive of the discontinued LLVM Phabricator instance.

[AMDGPU] Update InstrCost calculation
Changes PlannedPublic

Authored by yassingh on Nov 29 2022, 11:46 AM.

Details

Summary

Fixes inconsistency in PerfHintAnalysis while using opaque
pointers. Opaque pointers got rid of bitcasts that affected
both MemoryBound and WaveLimiterHint calculation as
InstCost will be different.

Diff Detail

Event Timeline

yassingh created this revision.Nov 29 2022, 11:46 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 29 2022, 11:46 AM
yassingh requested review of this revision.Nov 29 2022, 11:46 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 29 2022, 11:46 AM
arsenm added inline comments.Nov 29 2022, 11:50 AM
llvm/lib/Target/AMDGPU/AMDGPUPerfHintAnalysis.cpp
228

I'm pretty sure this skips a lot more casts.

This also looks backwards. Opaque pointers avoid a lot of bitcasts, not introduce them

272

Probably shouldn't count free instructions here. Rather than inventing a new cost counting, can we use TTI costs?

llvm/test/CodeGen/AMDGPU/perfhint-instr-cost.ll
4

This is adding a new test with typed pointers

arsenm requested changes to this revision.Nov 29 2022, 11:50 AM
This revision now requires changes to proceed.Nov 29 2022, 11:50 AM
yassingh updated this revision to Diff 478813.Nov 29 2022, 11:03 PM

Addressed Matt's comments

yassingh added inline comments.Nov 29 2022, 11:11 PM
llvm/lib/Target/AMDGPU/AMDGPUPerfHintAnalysis.cpp
228

Updated bitcast check.
"This also looks backwards. Opaque pointers avoid a lot of bitcasts, not introduce them"
Not sure how else to add this check. Should we entirely avoid this check and update test to use opaque pointers?

272

How do we use that cost model here? We don't have IndirectAccessCost, isLargeStrideCost, etc defined there.

arsenm added inline comments.Nov 30 2022, 12:33 PM
llvm/lib/Target/AMDGPU/AMDGPUPerfHintAnalysis.cpp
228

I can see this help get the same results for typed and opaque pointers, but in the direction that hurts the case you're looking at?

All tests need to be updated to use opaque pointers. Typed pointers are off by default and are only still around because so many tests need to be updated

llvm/test/CodeGen/AMDGPU/perfhint-instr-cost.ll
1

If you're going to directly check the debug output, you need REQUIRES: asserts

llvm/test/CodeGen/AMDGPU/perfhint.ll
2

This is the wrong way to switch this. You need to textually replace all the pointers in the test. You can run https://gist.github.com/nikic/98357b71fd67756b0f064c9517b62a34, although that should be in a separate change from any functional patch

arsenm added inline comments.Nov 30 2022, 12:34 PM
llvm/lib/Target/AMDGPU/AMDGPUPerfHintAnalysis.cpp
272

Call getInstructionCost from here? You don't need to push all the logic here into TTI

yassingh added inline comments.Dec 20 2022, 7:48 PM
llvm/test/CodeGen/AMDGPU/perfhint.ll
2

Updted the test to use opaque pointers D140452

yassingh planned changes to this revision.Dec 21 2022, 8:00 PM