This is an archive of the discontinued LLVM Phabricator instance.

[DAG] isBitwiseNot / isConstOrConstSplat - add support for build vector undefs + truncation (PR41020)
ClosedPublic

Authored by RKSimon on Jun 1 2019, 1:12 PM.

Details

Summary

Add (opt-in) support for implicit truncation to isConstOrConstSplat, which allows us to match truncated 'all ones' cases in isBitwiseNot.

PR41020 compares against using ISD::isBuildVectorAllOnes() instead, but that predicate silently accepts any UNDEF elements in the build vector which might not be what we want in isBitwiseNot - so I've added an opt-in 'AllowUndefs' flag that is set to false by default but will allow us to enable it on individual cases where its safe.

Diff Detail

Event Timeline

RKSimon created this revision.Jun 1 2019, 1:12 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 1 2019, 1:12 PM
Herald added a subscriber: javed.absar. · View Herald Transcript
nikic added inline comments.Jun 2 2019, 1:01 AM
lib/CodeGen/SelectionDAG/SelectionDAG.cpp
8667 ↗(On Diff #202566)

CVT.bitsGE(NSVT) should be an assertion, it holds for all build_vectors.

RKSimon marked an inline comment as done.Jun 2 2019, 3:01 AM
RKSimon added inline comments.
lib/CodeGen/SelectionDAG/SelectionDAG.cpp
8667 ↗(On Diff #202566)

Nice catch!

RKSimon updated this revision to Diff 202590.Jun 2 2019, 3:19 AM

assert that the build vector elements are same size / truncated

avoid temp APInt by using APInt::countTrailingOnes() instead of truncating to call isAllOnesValue()

nikic accepted this revision.Jun 2 2019, 3:53 AM

LGTM

This revision is now accepted and ready to land.Jun 2 2019, 3:53 AM
This revision was automatically updated to reflect the committed changes.