This is an archive of the discontinued LLVM Phabricator instance.

[X86] Use BEXTR/BEXTRI for 64-bit 'and' with a large mask
ClosedPublic

Authored by craig.topper on Jul 31 2017, 11:57 PM.

Details

Summary

The 64-bit 'and' with immediate instruction only supports a 32-bit immediate. So for larger constants we have to load the constant into a register first. If the immediate happens to be a mask we can use the BEXTRI instruction to perform the masking. We already do something similar using the BZHI instruction from the BMI2 instruction set.

Diff Detail

Repository
rL LLVM

Event Timeline

craig.topper created this revision.Jul 31 2017, 11:57 PM
RKSimon edited edge metadata.Aug 1 2017, 3:51 AM

Nice - useful for BMI1 as well do you think? Would use a second register like the AND case but requires a smaller immediate and would allow more load folding opportunities.

Are there any CPUs that support BMI1 without TBM or BMI2?

Are there any CPUs that support BMI1 without TBM or BMI2?

Yes, Jaguar (btver2)

craig.topper retitled this revision from [X86] Use BEXTRI for 64-bit 'and' with a large mask to [X86] Use BEXTR/BEXTRI for 64-bit 'and' with a large mask.

Added BEXTR for BMI1 only.

RKSimon accepted this revision.Aug 1 2017, 10:04 AM

LGTM - thanks.

This revision is now accepted and ready to land.Aug 1 2017, 10:04 AM
This revision was automatically updated to reflect the committed changes.