[llvm] [AMPGPU] Emit s_singleuse_vdst instructions when a register is used multiple times in the same instruction. (PR #89601)
Scott Egerton via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 30 04:13:35 PDT 2024
================
@@ -83,26 +84,13 @@ class AMDGPUInsertSingleUseVDST : public MachineFunctionPass {
// instruction to be marked as a single use producer.
bool AllProducerOperandsAreSingleUse = true;
- for (const auto &Operand : MI.operands()) {
- if (!Operand.isReg())
- continue;
- const auto Reg = Operand.getReg();
-
- // Count the number of times each register is read.
- if (Operand.readsReg())
- for (const MCRegUnit &Unit : TRI->regunits(Reg))
- RegisterUseCount[Unit]++;
+ // Gather a list of Registers used before updating use counts to avoid
+ // double counting registers that appear multiple times in a single
+ // MachineInstr.
+ DenseSet<MCRegUnit> RegistersUsed;
----------------
ScottEgerton wrote:
I've now changed this to a SmallVector + llvm::is_contained to avoid duplicates.
https://github.com/llvm/llvm-project/pull/89601
More information about the llvm-commits
mailing list