diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2021-02-16 20:13:02 +0000 |
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2021-02-16 20:13:02 +0000 |
| commit | b60736ec1405bb0a8dd40989f67ef4c93da068ab (patch) | |
| tree | 5c43fbb7c9fc45f0f87e0e6795a86267dbd12f9d /llvm/lib/Target/X86/X86FixupSetCC.cpp | |
| parent | cfca06d7963fa0909f90483b42a6d7d194d01e08 (diff) | |
Diffstat (limited to 'llvm/lib/Target/X86/X86FixupSetCC.cpp')
| -rw-r--r-- | llvm/lib/Target/X86/X86FixupSetCC.cpp | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/llvm/lib/Target/X86/X86FixupSetCC.cpp b/llvm/lib/Target/X86/X86FixupSetCC.cpp index 09668d7c5468..269f8ce6bd7a 100644 --- a/llvm/lib/Target/X86/X86FixupSetCC.cpp +++ b/llvm/lib/Target/X86/X86FixupSetCC.cpp @@ -97,28 +97,31 @@ bool X86FixupSetCCPass::runOnMachineFunction(MachineFunction &MF) { if (FlagsDefMI->readsRegister(X86::EFLAGS)) continue; - ++NumSubstZexts; - Changed = true; - // On 32-bit, we need to be careful to force an ABCD register. const TargetRegisterClass *RC = MF.getSubtarget<X86Subtarget>().is64Bit() ? &X86::GR32RegClass : &X86::GR32_ABCDRegClass; - Register ZeroReg = MRI->createVirtualRegister(RC); - Register InsertReg = MRI->createVirtualRegister(RC); + if (!MRI->constrainRegClass(ZExt->getOperand(0).getReg(), RC)) { + // If we cannot constrain the register, we would need an additional copy + // and are better off keeping the MOVZX32rr8 we have now. + continue; + } + + ++NumSubstZexts; + Changed = true; // Initialize a register with 0. This must go before the eflags def + Register ZeroReg = MRI->createVirtualRegister(RC); BuildMI(MBB, FlagsDefMI, MI.getDebugLoc(), TII->get(X86::MOV32r0), ZeroReg); // X86 setcc only takes an output GR8, so fake a GR32 input by inserting // the setcc result into the low byte of the zeroed register. BuildMI(*ZExt->getParent(), ZExt, ZExt->getDebugLoc(), - TII->get(X86::INSERT_SUBREG), InsertReg) + TII->get(X86::INSERT_SUBREG), ZExt->getOperand(0).getReg()) .addReg(ZeroReg) .addReg(MI.getOperand(0).getReg()) .addImm(X86::sub_8bit); - MRI->replaceRegWith(ZExt->getOperand(0).getReg(), InsertReg); ToErase.push_back(ZExt); } } |
