Page MenuHomePhabricator

[RISCV] Support vector SET[U]LT and SET[U]GE with splatted immediates
ClosedPublic

Authored by frasercrmck on Thu, Apr 8, 3:59 AM.

Details

Summary

This patch adds more optimized codegen for the above SETCC forms,
by matching the '.vi' vector forms when the immediate is a 5-bit signed
immediate plus 1. The immediate can be decremented and the corresponding
SET[U]LE or SET[U]GT forms can be matched.

This work was left as a TODO from D94168.

Diff Detail

Event Timeline

frasercrmck created this revision.Thu, Apr 8, 3:59 AM
frasercrmck requested review of this revision.Thu, Apr 8, 3:59 AM
Herald added a project: Restricted Project. · View Herald TranscriptThu, Apr 8, 3:59 AM
frasercrmck retitled this revision from [RISCV] Support vector SET[U]LT and SET[U]GE with spatted immediates to [RISCV] Support vector SET[U]LT and SET[U]GE with splatted immediates.Thu, Apr 8, 4:02 AM
frasercrmck added inline comments.Thu, Apr 8, 4:16 AM
llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp
1156–1161

I was unsure of this function pointer approach but duplicating all of what was selectVSplatSimm5 felt silly. It seemed to generate better code than using std::function<bool(int64_t)> but my X86 isn't where it should be.

craig.topper added inline comments.Thu, Apr 8, 9:55 AM
llvm/lib/Target/RISCV/RISCVInstrInfoVSDPatterns.td
436

Are we confident that we'll never see SETULT/SETUGE with a 0 splat? It doesn't happen for simple cases, but I wonder if the constant can appear later and our target specific nodes like RISCVISD::VMV_V_X_VL or RISCVISD::SPLAT_VECTOR_I64 can prevent setcc optimizations from seeing it.

  • rebase
  • test and fix for unsigned comparisons with 0
frasercrmck marked an inline comment as done.Mon, Apr 12, 3:38 AM
frasercrmck added inline comments.
llvm/lib/Target/RISCV/RISCVInstrInfoVSDPatterns.td
436

Yes, you're right. I've fixed that now, and added a couple of tests using the vmv.v.x intrinsic to check it's not misoptimized.

This revision is now accepted and ready to land.Mon, Apr 12, 9:37 AM
This revision was automatically updated to reflect the committed changes.
frasercrmck marked an inline comment as done.