This is an archive of the discontinued LLVM Phabricator instance.

[SelectionDAGBuilder] Don't create MGATHER/MSCATTER with Scale != ElemSize
ClosedPublic

Authored by nikic on Apr 28 2022, 3:33 AM.

Details

Summary

This is an alternative to D124530. In getUniformBase() only create scales that match the gather/scatter element size. If targets also support other scales, then they can produce those scales in DAG combines. This is what X86 already does (as long as the resulting scale would be 1, 2, 4 or 8).

This essentially restores the pre-opaque-pointer state of things.

Fixes https://github.com/llvm/llvm-project/issues/55021.

Diff Detail

Event Timeline

nikic created this revision.Apr 28 2022, 3:33 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 28 2022, 3:33 AM
nikic requested review of this revision.Apr 28 2022, 3:33 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 28 2022, 3:33 AM

In principle I prefer this route as it means a target doesn't have to support something they never want to use and it'll also allow DAGCombine more time to optimise the parts that cannot be done by the target's gather/scatter instructions themselves.

llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
4410

Shouldn't we also always allow unit scaling (i.e. ScaleVal==1)? I know there's the IndexType = ISD::SIGNED_SCALED oddity, but that's the unnecessary duplication I mentioned before that I have inflight patches to remove (see D123381).

nikic updated this revision to Diff 425984.Apr 29 2022, 1:05 AM

Also allow "scaling" by 1.

pengfei accepted this revision.Apr 29 2022, 5:20 AM

LGTM, thanks!

This revision is now accepted and ready to land.Apr 29 2022, 5:20 AM
This revision was landed with ongoing or failed builds.Apr 29 2022, 5:58 AM
This revision was automatically updated to reflect the committed changes.
skan added a subscriber: skan.May 5 2022, 6:39 PM