This is an archive of the discontinued LLVM Phabricator instance.

[DAG] More aggressively (extract_vector_elt (build_vector x, y), c) iff element is zero constant
ClosedPublic

Authored by RKSimon on Jul 18 2023, 4:56 AM.

Details

Summary

We currently don't extract vector elements from multi-use build vectors unless TLI.aggressivelyPreferBuildVectorSources accepts them, which seems a little extreme for constant build vectors (especially as under some cases ComputeKnownBits will indirectly extract the data for us).

This is causing a few regressions in some upcoming SimplifyDemandedBits work I'm looking at, all of which just need to know that the element is zero, so I've tweaked the fold to accept zero elements as well, which will typically fold very easily.

Diff Detail

Event Timeline

RKSimon created this revision.Jul 18 2023, 4:56 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 18 2023, 4:56 AM
RKSimon requested review of this revision.Jul 18 2023, 4:56 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 18 2023, 4:56 AM
dmgreen accepted this revision.Jul 18 2023, 8:32 AM

LGTM

This revision is now accepted and ready to land.Jul 18 2023, 8:32 AM
goldstein.w.n added inline comments.
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
21715

probably hasOneUse check should come first? Just because it cheaper?

This revision was landed with ongoing or failed builds.Jul 18 2023, 9:32 AM
This revision was automatically updated to reflect the committed changes.