[llvm] peephole-opt: Fold uses of REG_SEQUENCE subregisters (WIP) (PR #161225)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 10 01:16:26 PDT 2025


================
@@ -220,6 +220,58 @@ class CopyRewriter : public Rewriter {
   }
 };
 
+/// Rewriter for REG_SEQUENCE source operands.  This class is used for
+/// rewriting uses of REG_SEQUENCE operands in arbitrary instructions
+/// whereas the RegSequenceRewriter is used for rewriting REG_SEQUENCE
+/// instructions.
----------------
arsenm wrote:

I think this is attacking the problem too directly. In general we should not see subregister uses on foldable instructions in the first place. I expect the IR to look something like:

```
  %inst0 = V_...
  %inst1 = V_...
  %seq = REG_SEQUENCE %inst0, %inst1
  %extract = COPY %seq.subN
  %inst = v_... %extract
```

The peephole fold would then turn that extract copy into a direct reference to %instN 



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


More information about the llvm-commits mailing list