This is an archive of the discontinued LLVM Phabricator instance.

[VP] Explicitly map from VP intrinsic to ISD opcode
ClosedPublic

Authored by frasercrmck on Apr 7 2022, 10:17 AM.

Details

Summary

This patch aims to overcome an issue in these mappings where, when an ISD
node was registered with BEGIN_REGISTER_VP_SDNODE but outwidth the scope
of a pair of BEGIN_REGISTER_VP_INTRINSIC/END_REGISTER_VP_INTRINSIC
macros, the switch cases fell apart. This in particular happened with
VP_SETCC, where we'd end up with something along the lines of:

case Intrinsic::vp_fcmp:
  break;
case Intrinsic::vp_icmp:
  break;
  ResOpc = ISD::VP_SETCC;
case Intrinsic::vp_store:
  ...

To remedy this, we introduce a special-purpose mapping macro which can
map any number of VP intrinsic opcodes to an ISD opcode.

As a result, we no longer need to special-case the mapping from vp.icmp
and vp.fcmp to VP_SETCC, as the new helper macro does it for us.

Thanks to @craig.topper for noticing this and to @rogfer01 for the idea.

Diff Detail

Event Timeline

frasercrmck created this revision.Apr 7 2022, 10:17 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 7 2022, 10:17 AM
frasercrmck requested review of this revision.Apr 7 2022, 10:17 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 7 2022, 10:17 AM
rogfer01 accepted this revision.Apr 7 2022, 11:06 AM

Other than the nit above, this LGTM.

Thanks for the prompt fix and the cleanup @frasercrmck!

llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
7325–7327

Formatting is a bit odd here, clang-format usually vertically aligns the backslashes.

This revision is now accepted and ready to land.Apr 7 2022, 11:06 AM
craig.topper added inline comments.Apr 7 2022, 12:22 PM
llvm/include/llvm/IR/VPIntrinsics.def
313

Does anything use the operand that vp_setcc is being used for? Can we remove it in follow up?

This revision was landed with ongoing or failed builds.Apr 8 2022, 4:42 AM
This revision was automatically updated to reflect the committed changes.
frasercrmck marked an inline comment as done.Apr 8 2022, 4:45 AM
frasercrmck added inline comments.
llvm/include/llvm/IR/VPIntrinsics.def
313

I might have misunderstood, but, do you mean the third operand? I think that's the name that's used when dumping the node (SDNode::getOperationName). The comments suggest it's also the TableGen operator name but I don't think we're doing anything like that. I'd have to check the reference patches to see if that actually came to fruition anywhere.

llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
7325–7327

Ah yes good spot, thank you. I think I renamed the macro at one point and forgot to reformat it.