This is an archive of the discontinued LLVM Phabricator instance.

[X86] X86DAGToDAGISel::matchBitExtract(): pattern b: truncation awareness
ClosedPublic

Authored by lebedev.ri on Jun 2 2019, 4:45 AM.

Diff Detail

Repository
rL LLVM

Event Timeline

lebedev.ri edited the summary of this revision. (Show Details)

Rebased, extra test exposed an alternative way to still end up
with unrecognized pattern with truncation, so handle it too.

This resulted in inlining isBitwiseNot(), not sure if it would be better to extend it with all that instead?

RKSimon added inline comments.Jun 2 2019, 10:41 AM
lib/CodeGen/SelectionDAG/SelectionDAG.cpp
8623 ↗(On Diff #202612)

Could you not create an AllOnes equivalent MaskedValueIsZero instead? MaskedValueIsAllOnes?

lebedev.ri added inline comments.Jun 2 2019, 10:45 AM
lib/CodeGen/SelectionDAG/SelectionDAG.cpp
8623 ↗(On Diff #202612)

Err, s/not//?
"Could you create an AllOnes equivalent of MaskedValueIsZero instead? MaskedValueIsAllOnes?"

Introduce SelectionDAG::MaskedValueIsAllOnes().
Is this better?

RKSimon added inline comments.Jun 2 2019, 11:31 AM
lib/CodeGen/SelectionDAG/SelectionDAG.cpp
8623 ↗(On Diff #202612)

I don't think we need a DemandedElts variant so this should work.

/// MaskedValueIsAllOnes - Return true if 'V & Mask' is known to be all ones.
bool MaskedValueIsAllOnes(SDValue Op, const APInt &Mask, unsigned Depth = 0) const;

bool SelectionDAG::MaskedValueIsAllOnes(SDValue V, const APInt &Mask, unsigned Depth) const {
  return Mask.isSubsetOf(computeKnownBits(V, Depth).One);
}
lebedev.ri marked 3 inline comments as done.

Drop demandedelements variant

RKSimon accepted this revision.Jun 2 2019, 1:45 PM

LGTM with one minor

lib/CodeGen/SelectionDAG/SelectionDAG.cpp
2248 ↗(On Diff #202617)

Remove this line - its MaskedValueIsZero specific

This revision is now accepted and ready to land.Jun 2 2019, 1:45 PM
lebedev.ri updated this revision to Diff 202671.Jun 3 2019, 2:37 AM
lebedev.ri marked an inline comment as done.

Rebased.

This revision was automatically updated to reflect the committed changes.