[llvm] [RISCV] Use DenseMap to track V0 definition. NFC (PR #84465)

Luke Lau via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 8 03:36:05 PST 2024


================
@@ -198,20 +198,29 @@ bool RISCVFoldMasks::runOnMachineFunction(MachineFunction &MF) {
   // $v0:vr = COPY %mask:vr
   // %x:vr = Pseudo_MASK %a:vr, %b:br, $v0:vr
   //
-  // Because $v0 isn't in SSA, keep track of it so we can check the mask operand
-  // on each pseudo.
-  MachineInstr *CurrentV0Def;
-  for (MachineBasicBlock &MBB : MF) {
-    CurrentV0Def = nullptr;
-    for (MachineInstr &MI : MBB) {
-      Changed |= convertToUnmasked(MI, CurrentV0Def);
-      Changed |= convertVMergeToVMv(MI, CurrentV0Def);
+  // Because $v0 isn't in SSA, keep track of its definition at each use so we
+  // can check mask operands.
+  for (const MachineBasicBlock &MBB : MF) {
+    const MachineInstr *CurrentV0Def = nullptr;
----------------
lukel97 wrote:

This ignores defs of V0 from outside the BB, since we're only interested in the local
```
$v0:vr = COPY %mask:vr
%x:vr = Pseudo_MASK %a:vr, %b:br, $v0:vr
```
format.

https://github.com/llvm/llvm-project/pull/84465


More information about the llvm-commits mailing list