This is an archive of the discontinued LLVM Phabricator instance.

[X86] Add custom code to EVEX to VEX pass to turn unmasked 128-bit VPALIGND/Q into VPALIGNR if the extended registers aren't being used.
ClosedPublic

Authored by craig.topper on Oct 28 2017, 4:32 PM.

Details

Summary

This will enable us to prefer VALIGND/Q during shuffle lowering in order to get the extended register encoding space when BWI isn't available. But if we end up not using the extended registers we can switch VPALIGNR for the shorter VEX encoding.

Diff Detail

Repository
rL LLVM

Event Timeline

craig.topper created this revision.Oct 28 2017, 4:32 PM
craig.topper edited the summary of this revision. (Show Details)Oct 28 2017, 4:35 PM
craig.topper added reviewers: RKSimon, aymanmus.
RKSimon added inline comments.Oct 29 2017, 4:28 AM
lib/Target/X86/X86EvexToVex.cpp
156 ↗(On Diff #120738)

Assertion message

220 ↗(On Diff #120738)

If you can see other 'custom' instructions being added here in the future, pulling it out as a helper function would make sense.

240 ↗(On Diff #120738)

Is this better?

MI.setDesc(TII->get(NewOpc));
248 ↗(On Diff #120738)

Pull out this helper function change as an NFC?

This takes a slightly different approach and manually adds the relevant instructions to the EVEX tables and then uses custom logic to just do the necessary immediate modification.

RKSimon accepted this revision.Nov 1 2017, 3:54 AM

LGTM with a couple of minor observations

lib/Target/X86/X86EvexToVex.cpp
168 ↗(On Diff #120766)

Pull out MI.Opcode() - it's called often enough.

173 ↗(On Diff #120766)

Worth asserting that NewOpcode is VPALIGNRrri/VPALIGNRrmi?

This revision is now accepted and ready to land.Nov 1 2017, 3:54 AM
This revision was automatically updated to reflect the committed changes.