This is an archive of the discontinued LLVM Phabricator instance.

[X86] fold select to mask instructions.
ClosedPublic

Authored by LuoYuanke on May 25 2023, 10:35 PM.

Details

Summary

When avx512 is available the lhs operand of select instruction can be
folded with mask instruction, while the rhs operand can't. This patch is
to commute the lhs and rhs of the select instruction to create the
opportunity of folding.

Diff Detail

Event Timeline

LuoYuanke created this revision.May 25 2023, 10:35 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 25 2023, 10:35 PM
LuoYuanke requested review of this revision.May 25 2023, 10:35 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 25 2023, 10:35 PM
RKSimon added inline comments.May 26 2023, 2:09 AM
llvm/lib/Target/X86/X86ISelLowering.cpp
20028

Do we actually need canCombineAsMaskOperation to take 2 input operands? Its other use in lowerVECTOR_SHUFFLE looks like it could be split to call it twice.

LuoYuanke added inline comments.May 26 2023, 4:43 AM
llvm/lib/Target/X86/X86ISelLowering.cpp
20028

Taking 1 input operand looks better.

LuoYuanke updated this revision to Diff 526028.May 26 2023, 4:44 AM

NFC. Address Simon's comments.

RKSimon accepted this revision.May 26 2023, 5:13 AM

LGTM - please commit the canCombineAsMaskOperation/lowerVECTOR_SHUFFLE refactor first as a pre-commit and then the commuteSelect patch afterward.

This revision is now accepted and ready to land.May 26 2023, 5:13 AM
LuoYuanke updated this revision to Diff 526046.May 26 2023, 6:26 AM

Rebase and add code comments.

This revision was landed with ongoing or failed builds.May 26 2023, 6:53 AM
This revision was automatically updated to reflect the committed changes.