This is an archive of the discontinued LLVM Phabricator instance.

[X86] Correct the register class for specific mask register constraints in getRegForInlineAsmConstraint when the VT is a scalar type
ClosedPublic

Authored by craig.topper on May 2 2019, 10:45 AM.

Details

Summary

The default impementation in the base class for TargetLowering::getRegForInlineAsmConstraint doesn't work for mask registers when the VT is a scalar type integer types since the only legal mask types are vXi1. So we end up just getting whatever the first register class that contains the register. Currently this appears to be VK1, but its really dependent on the order tablegen outputs the register classes.

Some code in the caller ends up looking up the type for this register class and find v1i1 then generates a copyfromreg from the physical k-register with the v1i1 type. Then it generates an any_extend from v1i1 to the scalar VT which isn't legal. This bad any_extend sticks around until isel where it selects a MOVZX32rr8 with a v1i1 input or maybe a i8 input. Not sure but eventually we pick up a copy from VK1 to GR8 in MachineIR which isn't supported. This leads to a failure in physical register copying.

This patch uses the scalar type to find a VK class of the right size. In the attached test case this will be VK16. This causes a bitcast from vk16 to i16 to be generated instead of an any_extend. This will be properly iseled to a VK16 to GR32 copy and a GR32->GR16 extract_subreg.

Fixes PR41678

Diff Detail

Repository
rL LLVM

Event Timeline

craig.topper created this revision.May 2 2019, 10:45 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 2 2019, 10:45 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
RKSimon accepted this revision.May 2 2019, 2:55 PM

LGTM

This revision is now accepted and ready to land.May 2 2019, 2:55 PM
This revision was automatically updated to reflect the committed changes.