mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-02 07:32:52 +00:00
Codegen cond&cond with two branches. This compiles (f.e.) PowerPC/and-branch.ll to:
cmpwi cr0, r4, 4 bgt cr0, LBB1_2 ;UnifiedReturnBlock LBB1_3: ;entry cmplwi cr0, r3, 0 bne cr0, LBB1_2 ;UnifiedReturnBlock instead of: cmpwi cr7, r4, 4 mfcr r2 addic r4, r3, -1 subfe r3, r4, r3 rlwinm r2, r2, 30, 31, 31 or r2, r2, r3 cmplwi cr0, r2, 0 bne cr0, LBB1_2 ;UnifiedReturnBlock LBB1_1: ;cond_true git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31232 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
00ef504797
commit
d2f9ee9ea7
@ -888,22 +888,43 @@ void SelectionDAGLowering::FindMergedConditions(Value *Cond,
|
||||
return;
|
||||
}
|
||||
|
||||
// Codegen X | Y as:
|
||||
// jmp_if_X TBB
|
||||
// TmpBB:
|
||||
// jmp_if_Y TBB
|
||||
// jmp FBB
|
||||
//
|
||||
// This requires creation of TmpBB after CurBB.
|
||||
|
||||
// Create TmpBB after CurBB.
|
||||
MachineFunction::iterator BBI = CurBB;
|
||||
MachineBasicBlock *TmpBB = new MachineBasicBlock(CurBB->getBasicBlock());
|
||||
CurBB->getParent()->getBasicBlockList().insert(++BBI, TmpBB);
|
||||
|
||||
// Emit the LHS condition.
|
||||
FindMergedConditions(BOp->getOperand(0), TBB, TmpBB, CurBB, Opc);
|
||||
if (Opc == Instruction::Or) {
|
||||
// Codegen X | Y as:
|
||||
// jmp_if_X TBB
|
||||
// jmp TmpBB
|
||||
// TmpBB:
|
||||
// jmp_if_Y TBB
|
||||
// jmp FBB
|
||||
//
|
||||
|
||||
// Emit the RHS condition into TmpBB.
|
||||
FindMergedConditions(BOp->getOperand(1), TBB, FBB, TmpBB, Opc);
|
||||
// Emit the LHS condition.
|
||||
FindMergedConditions(BOp->getOperand(0), TBB, TmpBB, CurBB, Opc);
|
||||
|
||||
// Emit the RHS condition into TmpBB.
|
||||
FindMergedConditions(BOp->getOperand(1), TBB, FBB, TmpBB, Opc);
|
||||
} else {
|
||||
assert(Opc == Instruction::And && "Unknown merge op!");
|
||||
// Codegen X & Y as:
|
||||
// jmp_if_X TmpBB
|
||||
// jmp FBB
|
||||
// TmpBB:
|
||||
// jmp_if_Y TBB
|
||||
// jmp FBB
|
||||
//
|
||||
// This requires creation of TmpBB after CurBB.
|
||||
|
||||
// Emit the LHS condition.
|
||||
FindMergedConditions(BOp->getOperand(0), TmpBB, FBB, CurBB, Opc);
|
||||
|
||||
// Emit the RHS condition into TmpBB.
|
||||
FindMergedConditions(BOp->getOperand(1), TBB, FBB, TmpBB, Opc);
|
||||
}
|
||||
}
|
||||
|
||||
void SelectionDAGLowering::visitBr(BranchInst &I) {
|
||||
@ -950,12 +971,11 @@ void SelectionDAGLowering::visitBr(BranchInst &I) {
|
||||
//
|
||||
if (BinaryOperator *BOp = dyn_cast<BinaryOperator>(CondVal)) {
|
||||
if (BOp->hasOneUse() &&
|
||||
(/*BOp->getOpcode() == Instruction::And ||*/
|
||||
(BOp->getOpcode() == Instruction::And ||
|
||||
BOp->getOpcode() == Instruction::Or)) {
|
||||
if (BOp->getOpcode() == Instruction::And)
|
||||
I.getParent()->dump();
|
||||
FindMergedConditions(BOp, Succ0MBB, Succ1MBB, CurMBB, BOp->getOpcode());
|
||||
//std::cerr << "FOUND: " << SwitchCases.size() << " merged conditions:\n";
|
||||
//I.getParent()->dump();
|
||||
|
||||
visitSwitchCase(SwitchCases[0]);
|
||||
SwitchCases.erase(SwitchCases.begin());
|
||||
return;
|
||||
|
Loading…
Reference in New Issue
Block a user