[llvm] [RegAlloc] Account for use availability when applying rematerializable weight discount (PR #159180)
Luke Lau via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 22 04:43:19 PDT 2025
================
@@ -124,6 +124,17 @@ bool VirtRegAuxInfo::isRematerializable(const LiveInterval &LI,
if (!TII.isTriviallyReMaterializable(*MI))
return false;
+
+ // If MI has register uses, it will only be rematerializable if its uses are
----------------
lukel97 wrote:
> The live interval can have multiple definitions, but each use of the register is only going to consume one of them.
That's what the ` if (LI.getVNInfoAt(UseIdx) != VNI) continue;` check is for, it narrows down the uses to only those that are using the current definition in the outer loop. But I agree that this is a very awkward way of doing it.
> I think what you want here instead is to track whether any defs require virt reg uses, and then for the uses of the register which read that def, check that the other live values are live.
I don't think we have use-def chain information on the VNInfo level, so we can't check which specific defs have virt reg uses. But I think we can just do one iteration of the uses via MRI and look up the defs from the use's slot index, I've done this in 277a9eca764d541e09b9e6bde45c623284b03f2e
https://github.com/llvm/llvm-project/pull/159180
More information about the llvm-commits
mailing list