Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
llvm/lib/Target/AMDGPU/AMDGPUReleaseVGPRs.cpp | ||
---|---|---|
38–39 | It doesn't map direclty into a bit-vector since there are 3 states considered (has-a-vmem-store, does-not-have-vmem-store and not-yet-computed). What do you think about a SmallVector<VMEMStore> with an enum class UsesVMEMStoreTy { UsesVMEMStore, DoesNotUseVMEMStore, NotYetComputed } ? |
llvm/lib/Target/AMDGPU/AMDGPUReleaseVGPRs.cpp | ||
---|---|---|
38–39 | Can you avoid the NotYetComputed case if you do this in RPO |
llvm/lib/Target/AMDGPU/AMDGPUReleaseVGPRs.cpp | ||
---|---|---|
38–39 | Way better! Thanks! I changed it to use a BitVector, but also I've encapsulated everything in a small class. The associated object is passed as a parameter to runOnMachineBasicBlock (instead of using a member variable). |
llvm/lib/Target/AMDGPU/AMDGPUReleaseVGPRs.cpp | ||
---|---|---|
66–97 | You can just use MBB.getNumber |
llvm/lib/Target/AMDGPU/AMDGPUReleaseVGPRs.cpp | ||
---|---|---|
69 | This loop sets the initialization value for each MachineBasicBlock. This loop does not take into account the predecessors/successors and it can be done in any order. Maybe the name lastBlockVGPRUseIsVMEMStore is misleading? Could be renamed to something such as lastVGPRUseInstInBlockIsVMEMStore or initVGPRUseInstInBlockIsVMEMStore. The loop after this one is the one that propagates the values from the predecessors to every block and that must be done in reverse-post-order. | |
101 | BitVector's operator[] returns a BitVector::reference and not a bool&. BitVector::reference encapsulates a reference to a single bit. Maybe it's worth to explicitely state the type BitVector::reference LastUseIsVMEMStore = BlockVMEMStore[MBB->getNumber()];. I think that auto looks confusing. For context, here's the code of BitVector::reference: // Encapsulation of a single bit. class reference { BitWord *WordRef; unsigned BitPos; public: reference(BitVector &b, unsigned Idx) { WordRef = &b.Bits[Idx / BITWORD_SIZE]; BitPos = Idx % BITWORD_SIZE; } reference() = delete; reference(const reference&) = default; reference &operator=(reference t) { *this = bool(t); return *this; } reference& operator=(bool t) { if (t) *WordRef |= BitWord(1) << BitPos; else *WordRef &= ~(BitWord(1) << BitPos); return *this; } operator bool() const { return ((*WordRef) & (BitWord(1) << BitPos)) != 0; } }; | |
102 | Addressed in the previous comment, since it's not a reference it's not dead. But it surely looks confusing. |
llvm/lib/Target/AMDGPU/AMDGPUReleaseVGPRs.cpp | ||
---|---|---|
102 | Bad phrasing: reference->value : Since it's not a value , but a reference, it's not dead. But it surely looks confusing. |
llvm/lib/Target/AMDGPU/AMDGPUReleaseVGPRs.cpp | ||
---|---|---|
105 | There is a bug in here: if BlockVMEMStore[MBB->getNumber()] was initialized to false because the last instruction referencing a vgpr instruction is not a store, and for one of the predecessors the last instruction referencing a vgpr is a store, we may override the false value with a true which is not correct. |
llvm/lib/Target/AMDGPU/AMDGPUReleaseVGPRs.cpp | ||
---|---|---|
69 | I brought back the old algorithm with the recusrive call. I tried several alternatives but I always found a case where the reverse post order missed propagating the values accordingly :S . |
If you're going to resize to the number of blocks, do you really need to use a DenseMap at all? You could use a bit vector indexed by the block number