This is an archive of the discontinued LLVM Phabricator instance.

[DAG] SelectionDAG::isSplatValue - add initial BITCAST handling
ClosedPublic

Authored by RKSimon on Feb 25 2022, 3:22 AM.

Details

Summary

This patch adds support for recognising vector splats by peeking through bitcasts to vectors with smaller element types - if all the offset subelements are splats then the bitcasted vector is a splat as well.

We don't have great coverage for isSplatValue so I've made this pretty specific to the use case I'm trying to fix - regressions in some vXi64 vector shift by splat cases that 32-bit x86 doesn't recognise because the shift amount buildvector has been type legalised to v2Xi32.

We can add further support (floats, bitcast from larger element types, undef elements) when we have actual test coverage.

Diff Detail

Unit TestsFailed

Event Timeline

RKSimon created this revision.Feb 25 2022, 3:22 AM
RKSimon requested review of this revision.Feb 25 2022, 3:23 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 25 2022, 3:23 AM

The IR in the tests neither shows bitcast nor small element vector. Are they generated during the lowering? Do we have specific tests for the patch?

llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
2645

nit: VT.getScalarSizeInBits()

2652

Why do we need a bitcast if both SrcVT and VT are integer and have the same width? Don't SrcVT == VT?

RKSimon updated this revision to Diff 412108.Mar 1 2022, 7:49 AM

address comments

RKSimon marked an inline comment as done.Mar 1 2022, 7:51 AM

The IR in the tests neither shows bitcast nor small element vector. Are they generated during the lowering? Do we have specific tests for the patch?

We're mostly relying on type legalization to expose this, but I've added an explicit test case at rG70ab0a9b62206add0738833cb40ea47fe5f52700

llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
2652

This was actually superfluous.

pengfei accepted this revision.Mar 1 2022, 4:57 PM

LGTM, thanks!

This revision is now accepted and ready to land.Mar 1 2022, 4:57 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 1 2022, 4:57 PM
craig.topper added inline comments.Mar 1 2022, 5:26 PM
llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
2654

"are a" -> "is a "

thanks everyone

This revision was landed with ongoing or failed builds.Mar 2 2022, 3:26 AM
This revision was automatically updated to reflect the committed changes.