This is an archive of the discontinued LLVM Phabricator instance.

[X86] Match (cmp (and (shr X, C), mask), 0) to BEXTR+TEST.
ClosedPublic

Authored by craig.topper on Oct 15 2018, 11:06 PM.

Details

Summary

Without this we match the CMP+AND to a TEST and then match the SHR separately. I'm trusting analyzeCompare to remove the TEST during the peephole pass. Otherwise we need to check the flag users to see if they only use the Z flag.

This recovers a case lost by r344270.

Diff Detail

Repository
rL LLVM

Event Timeline

craig.topper created this revision.Oct 15 2018, 11:06 PM
lebedev.ri added inline comments.Oct 16 2018, 12:17 AM
lib/Target/X86/X86ISelDAGToDAG.cpp
457 ↗(On Diff #169785)

Can probably be a separate preparatory cleanup commit.

3564 ↗(On Diff #169785)

Is this correct?
We will always use MVT::i32, even for X86::TEST64rr?
We shouldn't be using CmpVT here?

craig.topper added inline comments.Oct 16 2018, 9:11 AM
lib/Target/X86/X86ISelDAGToDAG.cpp
3564 ↗(On Diff #169785)

The TEST instruction returns flags not data. We always use MVT::i32 for the flags.

This revision is now accepted and ready to land.Oct 16 2018, 9:32 AM
This revision was automatically updated to reflect the committed changes.