This is an archive of the discontinued LLVM Phabricator instance.

[X86] Restore X86ISelDAGToDAG::matchBEXTRFromAnd. Teach address matching to create a BEXTR pattern from a (shl (and X, mask >> C1) if C1 can be folded into addressing mode.
ClosedPublic

Authored by craig.topper on Oct 10 2018, 11:20 PM.

Details

Summary

This is an alternative to D53080 since I think using a BEXTR for a shifted mask is definitely an improvement when the shl can be absorbed into addressing mode. The other cases I'm less sure about.

We already have several tricks for handling an and of a shift in address matching. This adds a new case for BEXTR.

I've moved the BEXTR matching code back to X86ISelDAGToDAG to allow it to match. I suppose alternatively we could directly emit a X86ISD::BEXTR node that isel could pattern match. But I'm trying to view BEXTR matching as an isel concern so DAG combine can see 'and' and 'shift' operations that are well understood. We did lose a couple cases from tbm_patterns.ll, but I think there are ways to recover that.

I've also put back the manual load folding code in matchBEXTRFromAnd that I removed a few months ago in r324939. This gives us some more freedom to make decisions based on the ability to fold a load. I haven't done anything with that yet.

Diff Detail

Repository
rL LLVM

Event Timeline

craig.topper created this revision.Oct 10 2018, 11:20 PM
lebedev.ri accepted this revision.Oct 10 2018, 11:35 PM

This does not have the regressions D53080 has, so i guess this is good :)
Most likely do wait for @RKSimon though.

test/CodeGen/X86/tbm_patterns.ll
57 ↗(On Diff #169153)

These reverted/regressed back.

This revision is now accepted and ready to land.Oct 10 2018, 11:35 PM
RKSimon accepted this revision.Oct 11 2018, 2:25 AM

LGTM

This revision was automatically updated to reflect the committed changes.