summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/MachineCSE.cpp
diff options
context:
space:
mode:
authorJustin Bogner <mail@justinbogner.com>2018-01-18 02:06:56 +0000
committerJustin Bogner <mail@justinbogner.com>2018-01-18 02:06:56 +0000
commita9346e050f301dfea9e1cf50d39a4b7180091b44 (patch)
tree65abd702e3ae3d94d045681c3fc33f6586250b6a /llvm/lib/CodeGen/MachineCSE.cpp
parent3feefe001b2ec9bd0fd867284560cf99d7345b1f (diff)
downloadbcm5719-llvm-a9346e050f301dfea9e1cf50d39a4b7180091b44.tar.gz
bcm5719-llvm-a9346e050f301dfea9e1cf50d39a4b7180091b44.zip
GlobalISel: Make MachineCSE runnable in the middle of the GlobalISel
Right now, it is not possible to run MachineCSE in the middle of the GlobalISel pipeline. Being able to run generic optimizations between the core passes of GlobalISel was one of the goals of the new ISel framework. This is the first attempt to do it. The problem is that MachineCSE pass assumes all register operands have a register class, which, in GlobalISel context, won't be true until after the InstructionSelect pass. The reason for this behaviour is that before replacing one virtual register with another, MachineCSE pass (and most of the other optimization machine passes) must check if the virtual registers' constraints have a (sufficiently large) intersection, and constrain the resulting register appropriately if such intersection exists. GlobalISel extends the representation of such constraints from just a register class to a triple (low-level type, register bank, register class). This commit adds MachineRegisterInfo::constrainRegAttrs method that extends MachineRegisterInfo::constrainRegClass to such a triple. The idea is that going forward we should use: - RegisterBankInfo::constrainGenericRegister within GlobalISel's InstructionSelect pass - MachineRegisterInfo::constrainRegClass within SelectionDAG ISel - MachineRegisterInfo::constrainRegAttrs everywhere else regardless the target and instruction selector it uses. Patch by Roman Tereshin. Thanks! llvm-svn: 322805
Diffstat (limited to 'llvm/lib/CodeGen/MachineCSE.cpp')
-rw-r--r--llvm/lib/CodeGen/MachineCSE.cpp13
1 files changed, 6 insertions, 7 deletions
diff --git a/llvm/lib/CodeGen/MachineCSE.cpp b/llvm/lib/CodeGen/MachineCSE.cpp
index 53c0d840ac8..8b7d2980ac8 100644
--- a/llvm/lib/CodeGen/MachineCSE.cpp
+++ b/llvm/lib/CodeGen/MachineCSE.cpp
@@ -176,8 +176,7 @@ bool MachineCSE::PerformTrivialCopyPropagation(MachineInstr *MI,
// class given a super-reg class and subreg index.
if (DefMI->getOperand(1).getSubReg())
continue;
- const TargetRegisterClass *RC = MRI->getRegClass(Reg);
- if (!MRI->constrainRegClass(SrcReg, RC))
+ if (!MRI->constrainRegAttrs(SrcReg, Reg))
continue;
DEBUG(dbgs() << "Coalescing: " << *DefMI);
DEBUG(dbgs() << "*** to: " << *MI);
@@ -588,11 +587,11 @@ bool MachineCSE::ProcessBlock(MachineBasicBlock *MBB) {
break;
}
- // Don't perform CSE if the result of the old instruction cannot exist
- // within the register class of the new instruction.
- const TargetRegisterClass *OldRC = MRI->getRegClass(OldReg);
- if (!MRI->constrainRegClass(NewReg, OldRC)) {
- DEBUG(dbgs() << "*** Not the same register class, avoid CSE!\n");
+ // Don't perform CSE if the result of the new instruction cannot exist
+ // within the constraints (register class, bank, or low-level type) of
+ // the old instruction.
+ if (!MRI->constrainRegAttrs(NewReg, OldReg)) {
+ DEBUG(dbgs() << "*** Not the same register constraints, avoid CSE!\n");
DoCSE = false;
break;
}
OpenPOWER on IntegriCloud