Changes in directory llvm/lib/CodeGen/SelectionDAG:
SelectionDAGISel.cpp updated: 1.300 -> 1.301 --- Log message: 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 --- Diffs of the changes: (+35 -15) SelectionDAGISel.cpp | 50 +++++++++++++++++++++++++++++++++++--------------- 1 files changed, 35 insertions(+), 15 deletions(-) Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp diff -u llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.300 llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.301 --- llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1.300 Fri Oct 27 16:36:01 2006 +++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Fri Oct 27 16:54:23 2006 @@ -888,22 +888,43 @@ 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 @@ // 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; _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits