This is an archive of the discontinued LLVM Phabricator instance.

[VectorUtils] Add getShuffleDemandedElts helper
ClosedPublic

Authored by RKSimon on Oct 27 2022, 3:30 AM.

Details

Summary

We have similar code to translate a demanded elements mask for a shuffle's operands in multiple places - this patch adds a helper function to VectorUtils and updates a number of locations to use it directly.

Diff Detail

Event Timeline

RKSimon created this revision.Oct 27 2022, 3:30 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 27 2022, 3:30 AM
RKSimon requested review of this revision.Oct 27 2022, 3:30 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 27 2022, 3:30 AM
spatel added inline comments.Oct 30 2022, 6:01 AM
llvm/lib/Analysis/VectorUtils.cpp
432–434

Can we assert that SrcWidth == DemandedLHS.getBitWidth() == DemandedRHS.getBitWidth() ?

RKSimon added inline comments.Oct 30 2022, 6:11 AM
llvm/lib/Analysis/VectorUtils.cpp
432–434

Many of the the use cases we have we could technically get away with them being entirely uninitialized upon calling getShuffleDemandedElts - (a couple still initialize before calling getShuffleDemandedElts but its unnecessary). Which do you think is better? TBH I have no preference.

spatel added inline comments.Oct 30 2022, 6:35 AM
llvm/lib/Analysis/VectorUtils.cpp
432–434

Ah, I missed that this is now init'ing with getZero().
That looks good. So remove init from the callers if it's still there, and add a line to the header comment to make it explicit that the LHS/RHS outputs are initialized by this function.

RKSimon updated this revision to Diff 471837.Oct 30 2022, 8:03 AM

Make the initialization of DemandedLHS/RHS more explicit and remove local initializations

spatel accepted this revision.Oct 30 2022, 9:17 AM

LGTM

This revision is now accepted and ready to land.Oct 30 2022, 9:17 AM
This revision was landed with ongoing or failed builds.Oct 30 2022, 10:04 AM
This revision was automatically updated to reflect the committed changes.