I think this is a more standard way of doing this.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
I admit that I initially wasn't convinced by the idea of ComplexPattern including both the matching logic (which is only return true) and a bit of selection logic (selectImm) in the input DAG. But on a second thought this allows the two logics be kept together.
Also if this is the common way to do this then we better use existing idioms. To be fair that undef in the SDNodeXForm has always looked a bit off to me.
Thanks for the cleanup @craig.topper
Yeah the undef looked off to me too.
I'm now wondering if we could extend this further and emit the vsetvli from inside here. If remove the explicit VL and SEWs operands from m the instructions, we might be able to attach the implicit VL physical register def from the vsetvli directly to the implicit physical register use in the instruction. We'd probably need multiple complex patterns to templatize the SEW value and tail policy. The main advantage of this is it might allow us to more directly match the new vsetivli instruction rather than going digging for the immediate from the ADDI instruction in the custom inserter.