This is an archive of the discontinued LLVM Phabricator instance.

[SelectionDAG] Optional handling of UNDEF elements in matchUnaryPredicate
ClosedPublic

Authored by RKSimon on Dec 18 2018, 6:00 AM.

Details

Summary

Now that SimplifyDemandedBits/SimplifyDemandedVectorElts is simplifying vector elements, we're seeing more constant BUILD_VECTOR containing UNDEFs.

This patch provides opt-in handling of UNDEF elements in matchUnaryPredicate, passing NULL instead of the result ConstantSDNode* argument.

I've updated SelectionDAG::simplifyShift to demonstrate its use.

An equivalent matchBinaryPredicate patch is in progress.

Diff Detail

Repository
rL LLVM

Event Timeline

RKSimon created this revision.Dec 18 2018, 6:00 AM

I think this is the right way to go.

SimplifyDemandedVectorElts is getting better and better at identifying unused lanes of a vector. The more we improve that logic, the higher the risk of propagating undefs to unused lanes of a constant build_vector. Teaching matchUnaryPredicate (and, in future, matchBinaryPredicate too) how/when to ignore undef elements makes a lot of sense to me. It makes the logic resilient to the presence of undefs, and it avoids unexpected regressions (indirectly caused by the aggressive propagation of undefs).

This revision is now accepted and ready to land.Dec 18 2018, 5:47 PM
This revision was automatically updated to reflect the committed changes.