summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJakob Stoklund Olesen <stoklund@2pi.dk>2012-05-20 18:42:55 +0000
committerJakob Stoklund Olesen <stoklund@2pi.dk>2012-05-20 18:42:55 +0000
commit2f06a6579cedd7887f1f115effa21782da488550 (patch)
treec78e56dcfb1e74feef0c4c221c78a1a414db7b28
parent00f07dec0c389f7618fa79c2ee16f028fc6d1d1a (diff)
downloadbcm5719-llvm-2f06a6579cedd7887f1f115effa21782da488550.tar.gz
bcm5719-llvm-2f06a6579cedd7887f1f115effa21782da488550.zip
Constrain regclasses in PeepholeOptimizer.
It can be necessary to restrict to a sub-class before accessing sub-registers. llvm-svn: 157164
-rw-r--r--llvm/lib/CodeGen/PeepholeOptimizer.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/PeepholeOptimizer.cpp b/llvm/lib/CodeGen/PeepholeOptimizer.cpp
index ab672c9c585..81cf9011d1d 100644
--- a/llvm/lib/CodeGen/PeepholeOptimizer.cpp
+++ b/llvm/lib/CodeGen/PeepholeOptimizer.cpp
@@ -150,6 +150,13 @@ optimizeExtInstr(MachineInstr *MI, MachineBasicBlock *MBB,
// No other uses.
return false;
+ // Ensure DstReg can get a register class that actually supports
+ // sub-registers. Don't change the class until we commit.
+ const TargetRegisterClass *DstRC = MRI->getRegClass(DstReg);
+ DstRC = TM->getRegisterInfo()->getSubClassWithSubReg(DstRC, SubIdx);
+ if (!DstRC)
+ return false;
+
// The source has other uses. See if we can replace the other uses with use of
// the result of the extension.
SmallPtrSet<MachineBasicBlock*, 4> ReachedBBs;
@@ -247,8 +254,10 @@ optimizeExtInstr(MachineInstr *MI, MachineBasicBlock *MBB,
continue;
// About to add uses of DstReg, clear DstReg's kill flags.
- if (!Changed)
+ if (!Changed) {
MRI->clearKillFlags(DstReg);
+ MRI->constrainRegClass(DstReg, DstRC);
+ }
unsigned NewVR = MRI->createVirtualRegister(RC);
BuildMI(*UseMBB, UseMI, UseMI->getDebugLoc(),
OpenPOWER on IntegriCloud