Properly constrain register classes for sub-registers.
authorJakob Stoklund Olesen <stoklund@2pi.dk>
Sun, 20 May 2012 06:38:37 +0000 (06:38 +0000)
committerJakob Stoklund Olesen <stoklund@2pi.dk>
Sun, 20 May 2012 06:38:37 +0000 (06:38 +0000)
Not all GR64 registers have sub_8bit sub-registers.

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

lib/CodeGen/SelectionDAG/FastISel.cpp
test/CodeGen/X86/fast-isel.ll

index 0c1ac6982d2a597a32760de15baa94a57328a34f..07687ef8b58691cbe79c13b150fba5bf53a44f46 100644 (file)
@@ -1345,6 +1345,8 @@ unsigned FastISel::FastEmitInst_extractsubreg(MVT RetVT,
   unsigned ResultReg = createResultReg(TLI.getRegClassFor(RetVT));
   assert(TargetRegisterInfo::isVirtualRegister(Op0) &&
          "Cannot yet extract from physregs");
+  const TargetRegisterClass *RC = MRI.getRegClass(Op0);
+  MRI.constrainRegClass(Op0, TRI.getSubClassWithSubReg(RC, Idx));
   BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt,
           DL, TII.get(TargetOpcode::COPY), ResultReg)
     .addReg(Op0, getKillRegState(Op0IsKill), Idx);
index c88d52968dd8d8556a94448d218050478db7a3f5..9d9a520c6a21f99a0cf81280e4a53d026e55976d 100644 (file)
@@ -1,5 +1,5 @@
-; RUN: llc < %s -fast-isel -fast-isel-abort -march=x86 -mattr=sse2
-; RUN: llc < %s -fast-isel -fast-isel-abort -mtriple=x86_64-apple-darwin10
+; RUN: llc < %s -fast-isel -fast-isel-abort -verify-machineinstrs -march=x86 -mattr=sse2
+; RUN: llc < %s -fast-isel -fast-isel-abort -verify-machineinstrs -mtriple=x86_64-apple-darwin10
 
 ; This tests very minimal fast-isel functionality.