This is an archive of the discontinued LLVM Phabricator instance.

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

Authored by frasercrmck on Apr 8 2021, 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.Apr 8 2021, 3:59 AM
frasercrmck requested review of this revision.Apr 8 2021, 3:59 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 8 2021, 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.Apr 8 2021, 4:02 AM
frasercrmck added inline comments.Apr 8 2021, 4:16 AM
llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp
1153

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.Apr 8 2021, 9:55 AM
llvm/lib/Target/RISCV/RISCVInstrInfoVSDPatterns.td
433

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.Apr 12 2021, 3:38 AM
frasercrmck added inline comments.
llvm/lib/Target/RISCV/RISCVInstrInfoVSDPatterns.td
433

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.Apr 12 2021, 9:37 AM
This revision was automatically updated to reflect the committed changes.
frasercrmck marked an inline comment as done.