This is an archive of the discontinued LLVM Phabricator instance.

[SelectionDAG] Add FoldBUILD_VECTOR to simplify new BUILD_VECTOR nodes
ClosedPublic

Authored by RKSimon on Oct 26 2018, 6:39 AM.

Details

Summary

Similar to FoldCONCAT_VECTORS, this patch adds FoldBUILD_VECTOR to simplify cases that can avoid the creation of the BUILD_VECTOR - if all the operands are UNDEF or if the BUILD_VECTOR simplifies to a copy.

This exposed an assumption in some AMDGPU code that getBuildVector was guaranteed to be a BUILD_VECTOR node that I've tried to handle.

Diff Detail

Repository
rL LLVM

Event Timeline

RKSimon created this revision.Oct 26 2018, 6:39 AM

The common code changes as well as the AMDGPU bits look good to me.

Any more comments?

Looks like this is missing handling for a one-element BUILD_VECTOR?

RKSimon updated this revision to Diff 171553.Oct 29 2018, 12:24 PM

Thanks @efriedma - adding one-operand BUILD_VECTOR handling.

RKSimon updated this revision to Diff 171556.Oct 29 2018, 12:32 PM

Fix merge typo

efriedma added inline comments.Oct 29 2018, 12:58 PM
lib/CodeGen/SelectionDAG/SelectionDAG.cpp
3834 ↗(On Diff #171556)

Is it actually possible for IdentitySrc to be null here? Even if it is, does it make a difference?

RKSimon added inline comments.Oct 29 2018, 1:03 PM
lib/CodeGen/SelectionDAG/SelectionDAG.cpp
3834 ↗(On Diff #171556)

No it makes no difference - not sure if its even worth an assert?

efriedma added inline comments.Oct 29 2018, 1:06 PM
lib/CodeGen/SelectionDAG/SelectionDAG.cpp
3834 ↗(On Diff #171556)

Not worth an assert IMO.

RKSimon updated this revision to Diff 171587.Oct 29 2018, 3:16 PM

Just use IsIdentity

This revision is now accepted and ready to land.Oct 29 2018, 4:01 PM
This revision was automatically updated to reflect the committed changes.