This is an archive of the discontinued LLVM Phabricator instance.

[DAG] Add non-uniform vector support to (shl (srl x, c1), c2) -> (and (shift x, c3))
ClosedPublic

Authored by RKSimon on Apr 11 2022, 10:38 AM.

Diff Detail

Event Timeline

RKSimon created this revision.Apr 11 2022, 10:38 AM
RKSimon requested review of this revision.Apr 11 2022, 10:38 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 11 2022, 10:38 AM
craig.topper added inline comments.Apr 11 2022, 9:47 PM
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
8979

Can these two SHL of mask be replaced with

Mask = DAG.getNode(ISD::SHL, DL, VT, Mask, N1)

As far as I can tell we're shifting by N01 + (N1 - N01) which should just be N1?

RKSimon added inline comments.Apr 12 2022, 1:31 AM
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
8979

Agreed: https://alive2.llvm.org/ce/z/rf8VHG

I'll add an explicit test and update the patch.

RKSimon updated this revision to Diff 422150.Apr 12 2022, 2:32 AM

Ensure we test up to the max shift bounds and merge shl(shl(x,N01),sub(N1,N01)) shifts

RKSimon updated this revision to Diff 422185.Apr 12 2022, 5:08 AM

rebase and refactor to reuse the existing MatchShiftAmount lambda

This revision is now accepted and ready to land.Apr 12 2022, 9:17 AM
This revision was landed with ongoing or failed builds.Apr 13 2022, 3:37 AM
This revision was automatically updated to reflect the committed changes.