This is an archive of the discontinued LLVM Phabricator instance.

[RISCV] Add patterns for vnsrl.vx where shift amount is truncated
ClosedPublic

Authored by luke on Jul 21 2023, 2:31 AM.

Details

Summary

Similar to D155698 where the shift amount is extended, this patch extends the
ComplexPattern to handle the case where the shift amount has been truncated.
Truncations are custom lowered to truncate_vector_vl, and in cases like i64 ->
i16 they are truncated by one power of two at a time, so we need to unravel
nested layers of them.

The pattern can also be reused for Zvbb's vwsll.vx in an upcoming patch.

Diff Detail

Event Timeline

luke created this revision.Jul 21 2023, 2:31 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 21 2023, 2:31 AM
luke requested review of this revision.Jul 21 2023, 2:31 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 21 2023, 2:31 AM
luke added inline comments.
llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp
3025

I thought we would need to check the VL of this VMSET_VL here, but the true_mask pattern used in other tablegen patterns doesn't seem to:

def true_mask : PatLeaf<(riscv_vmset_vl (XLenVT srcvalue))>;

Any idea as to why that is?

craig.topper added inline comments.Jul 24 2023, 1:28 PM
llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp
3025

I don't remember if it was because it was hard to do in tablegen or just that didn't matter because the bits past VL are undefined.

luke updated this revision to Diff 544093.Jul 25 2023, 2:18 PM

Add comments explaining vmset_vl
Check truncation doesn't go below 8 bits (Can this happen?)

luke marked an inline comment as done.Jul 25 2023, 2:19 PM
luke added inline comments.
llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp
3025

That makes sense, left a comment about the latter

This revision is now accepted and ready to land.Jul 26 2023, 11:21 AM
This revision was landed with ongoing or failed builds.Jul 26 2023, 12:27 PM
This revision was automatically updated to reflect the committed changes.
luke marked an inline comment as done.