Work around an interaction between fast-isel and regalloc=local. The
authorDan Gohman <gohman@apple.com>
Thu, 2 Oct 2008 14:56:12 +0000 (14:56 +0000)
committerDan Gohman <gohman@apple.com>
Thu, 2 Oct 2008 14:56:12 +0000 (14:56 +0000)
local register allocator's physreg liveness doesn't recognize subregs,
so it doesn't know that defs of %ecx that are immediately followed by
uses of %cl aren't dead. This comes up due to the way fast-isel emits
shift instructions.

This is a temporary workaround. Arguably, local regalloc should
handle subreg references correctly. On the other hand, perhaps
fast-isel should use INSERT_SUBREG instead of just assigning to the
most convenient super-register of %cl when lowering shifts.

This fixes MultiSource/Benchmarks/MallocBench/espresso,
MultiSource/Applications/hexxagon, and others, under -fast.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@56947 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/X86/X86FastISel.cpp

index 59500ad8b1bfdbc58211a4e09a9a3cd668f1f994..3d5759001f07bc6627606971337cb620406bc4e8 100644 (file)
@@ -741,7 +741,11 @@ bool X86FastISel::X86SelectShift(Instruction *I) {
   if (Op1Reg == 0) return false;
   TII.copyRegToReg(*MBB, MBB->end(), CReg, Op1Reg, RC, RC);
   unsigned ResultReg = createResultReg(RC);
-  BuildMI(MBB, TII.get(OpReg), ResultReg).addReg(Op0Reg);
+  BuildMI(MBB, TII.get(OpReg), ResultReg).addReg(Op0Reg)
+    // FIXME: The "Local" register allocator's physreg liveness doesn't
+    // recognize subregs. Adding the superreg of CL that's actually defined
+    // prevents it from being re-allocated for this instruction.
+    .addReg(CReg, false, true);
   UpdateValueMap(I, ResultReg);
   return true;
 }