[X86] Do not allow FixupSetCC to relax constraints
authorHarald van Dijk <harald@gigawatt.nl>
Sat, 28 Nov 2020 17:46:56 +0000 (17:46 +0000)
committerHarald van Dijk <harald@gigawatt.nl>
Sat, 28 Nov 2020 17:46:56 +0000 (17:46 +0000)
commit47e2fafbf3d933532f46ef6e8515e7005df52758
treee3cb8374088823edecf99795fe2d09fe4fa6d114
parentc6b62efb9103466b6cefca1bd99a5b04b4ced044
[X86] Do not allow FixupSetCC to relax constraints

The build bots caught two additional pre-existing problems exposed by the test change part of my change https://reviews.llvm.org/D91339, when expensive checks are enabled. https://reviews.llvm.org/D91924 fixes one of them, this fixes the other.

FixupSetCC will change code in the form of

  %setcc = SETCCr ...
  %ext1 = MOVZX32rr8 %setcc

to

  %zero = MOV32r0
  %setcc = SETCCr ...
  %ext2 = INSERT_SUBREG %zero, %setcc, %subreg.sub_8bit

and replace uses of %ext1 with %ext2.

The register class for %ext2 did not take into account any constraints on %ext1, which may have been required by its uses. This change ensures that the original constraints are honoured, by instead of creating a new %ext2 register, reusing %ext1 and further constraining it as needed. This requires a slight reorganisation to account for the fact that it is possible for the constraining to fail, in which case no changes should be made.

Reviewed By: RKSimon

Differential Revision: https://reviews.llvm.org/D91933
llvm/lib/Target/X86/X86FixupSetCC.cpp