This is an archive of the discontinued LLVM Phabricator instance.

[X86] isVectorShiftByScalarCheap - vXi8 select(shift(x,splat0),shift(x,splat1)) is better than shift(x,select(splat0,splat1))
ClosedPublic

Authored by RKSimon on Dec 22 2021, 2:34 PM.

Details

Summary

Even though we don't have vXi8 vector shifts (apart from XOP), it is still better to prefer shift (or funnel-shift/rotate) by scalar where possible.

https://llvm.godbolt.org/z/6ss6ffTxv

Diff Detail

Event Timeline

RKSimon created this revision.Dec 22 2021, 2:34 PM
RKSimon requested review of this revision.Dec 22 2021, 2:34 PM
Herald added a project: Restricted Project. · View Herald TranscriptDec 22 2021, 2:34 PM
pengfei added inline comments.Dec 22 2021, 6:25 PM
llvm/lib/Target/X86/X86ISelLowering.cpp
32997–33001

I'm confused by the summary and the code here. Do we prefer to shifts on both has XOP and not? Why do we always return false for XOP?

RKSimon added inline comments.Dec 23 2021, 2:39 AM
llvm/lib/Target/X86/X86ISelLowering.cpp
32997–33001

XOP has awesome per-element shift ops for all 128-bit vector types - so there's no need to prefer vector shifts by scalar amounts over per-element amounts.

pengfei accepted this revision.Dec 23 2021, 4:10 AM

LGTM.

llvm/lib/Target/X86/X86ISelLowering.cpp
32997–33001

Got it. Thanks!

This revision is now accepted and ready to land.Dec 23 2021, 4:10 AM
This revision was landed with ongoing or failed builds.Dec 23 2021, 6:30 AM
This revision was automatically updated to reflect the committed changes.