aboutsummaryrefslogtreecommitdiff
path: root/lib/Target/PowerPC/PPC32ISelSimple.cpp
diff options
context:
space:
mode:
authorNate Begeman <natebegeman@mac.com>2004-09-29 05:00:31 +0000
committerNate Begeman <natebegeman@mac.com>2004-09-29 05:00:31 +0000
commit1f49e868aad763540be5e2076b5af6dbff5bf1c1 (patch)
treeb7e617752ed591f37a8df528b99805e120529572 /lib/Target/PowerPC/PPC32ISelSimple.cpp
parenta771347336c92d8e35d28e01dedea87bed34a753 (diff)
Generate better code by being far less clever when it comes to the select instruction. Don't create overlapping register lifetimes
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16580 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/PowerPC/PPC32ISelSimple.cpp')
-rw-r--r--lib/Target/PowerPC/PPC32ISelSimple.cpp24
1 files changed, 17 insertions, 7 deletions
diff --git a/lib/Target/PowerPC/PPC32ISelSimple.cpp b/lib/Target/PowerPC/PPC32ISelSimple.cpp
index 9f1229a53b..c273e8fb31 100644
--- a/lib/Target/PowerPC/PPC32ISelSimple.cpp
+++ b/lib/Target/PowerPC/PPC32ISelSimple.cpp
@@ -1296,7 +1296,6 @@ void PPC32ISel::emitSelectOperation(MachineBasicBlock *MBB,
BuildMI(*MBB, IP, PPC::CMPWI, 2, PPC::CR0).addReg(CondReg).addSImm(0);
Opcode = getPPCOpcodeForSetCCNumber(Instruction::SetNE);
}
- unsigned TrueValue = getReg(TrueVal, BB, BB->end());
MachineBasicBlock *thisMBB = BB;
const BasicBlock *LLVM_BB = BB->getBasicBlock();
@@ -1306,22 +1305,33 @@ void PPC32ISel::emitSelectOperation(MachineBasicBlock *MBB,
// thisMBB:
// ...
// cmpTY cr0, r1, r2
- // %TrueValue = ...
- // bCC sinkMBB
+ // bCC copy1MBB
+ // fallthrough --> copy0MBB
MachineBasicBlock *copy0MBB = new MachineBasicBlock(LLVM_BB);
+ MachineBasicBlock *copy1MBB = new MachineBasicBlock(LLVM_BB);
MachineBasicBlock *sinkMBB = new MachineBasicBlock(LLVM_BB);
- BuildMI(BB, Opcode, 2).addReg(PPC::CR0).addMBB(sinkMBB);
+ BuildMI(BB, Opcode, 2).addReg(PPC::CR0).addMBB(copy1MBB);
F->getBasicBlockList().insert(It, copy0MBB);
+ F->getBasicBlockList().insert(It, copy1MBB);
F->getBasicBlockList().insert(It, sinkMBB);
// Update machine-CFG edges
BB->addSuccessor(copy0MBB);
- BB->addSuccessor(sinkMBB);
+ BB->addSuccessor(copy1MBB);
// copy0MBB:
// %FalseValue = ...
- // fallthrough
+ // b sinkMBB
BB = copy0MBB;
unsigned FalseValue = getReg(FalseVal, BB, BB->begin());
+ BuildMI(BB, PPC::B, 1).addMBB(sinkMBB);
+ // Update machine-CFG edges
+ BB->addSuccessor(sinkMBB);
+
+ // copy1MBB:
+ // %TrueValue = ...
+ // fallthrough
+ BB = copy1MBB;
+ unsigned TrueValue = getReg(TrueVal, BB, BB->begin());
// Update machine-CFG edges
BB->addSuccessor(sinkMBB);
@@ -1330,7 +1340,7 @@ void PPC32ISel::emitSelectOperation(MachineBasicBlock *MBB,
// ...
BB = sinkMBB;
BuildMI(BB, PPC::PHI, 4, DestReg).addReg(FalseValue)
- .addMBB(copy0MBB).addReg(TrueValue).addMBB(thisMBB);
+ .addMBB(copy0MBB).addReg(TrueValue).addMBB(copy1MBB);
// For a register pair representing a long value, define the second reg
// FIXME: Can this really be correct for selecting longs?