summaryrefslogtreecommitdiff
path: root/lib/CodeGen/PeepholeOptimizer.cpp
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
commit418a3638acfa95e4212a38100adfc2f8cdd45919 (patch)
tree48bc0964867915ac874907257e508515ef9ccc90 /lib/CodeGen/PeepholeOptimizer.cpp
parent0fda545c2c164dc607f48f4b77f54c35bcafa413 (diff)
downloadllvm-418a3638acfa95e4212a38100adfc2f8cdd45919.tar.gz
llvm-418a3638acfa95e4212a38100adfc2f8cdd45919.tar.bz2
llvm-418a3638acfa95e4212a38100adfc2f8cdd45919.tar.xz
Constrain regclasses in PeepholeOptimizer.
It can be necessary to restrict to a sub-class before accessing sub-registers. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@157164 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/PeepholeOptimizer.cpp')
-rw-r--r--lib/CodeGen/PeepholeOptimizer.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/CodeGen/PeepholeOptimizer.cpp b/lib/CodeGen/PeepholeOptimizer.cpp
index ab672c9c58..81cf9011d1 100644
--- a/lib/CodeGen/PeepholeOptimizer.cpp
+++ b/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(),