aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2006-10-29 18:23:37 +0000
committerChris Lattner <sabre@nondot.org>2006-10-29 18:23:37 +0000
commit5a145f0094d7e15ca3c0326b1af2ea0ad19f9726 (patch)
tree21f37c101a6d123d9ab4b7e239a378a3a2d61438
parenta97c67c8665de3384fcd3656006504f79eceebfc (diff)
Fix a load folding issue that Evan noticed: there is no need to export values
used by comparisons in the main block. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31279 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp24
1 files changed, 17 insertions, 7 deletions
diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
index cf49143c30..6381f526f6 100644
--- a/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
+++ b/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
@@ -841,12 +841,11 @@ void SelectionDAGLowering::FindMergedConditions(Value *Cond,
// caseblock.
if (BOp && isa<SetCondInst>(BOp) &&
// The operands of the setcc have to be in this block. We don't know
- // how to export them from some other block.
- isExportableFromCurrentBlock(BOp->getOperand(0), BB) &&
- isExportableFromCurrentBlock(BOp->getOperand(1), BB)) {
- ExportFromCurrentBlock(BOp->getOperand(0));
- ExportFromCurrentBlock(BOp->getOperand(1));
-
+ // how to export them from some other block. If this is the first block
+ // of the sequence, no exporting is needed.
+ (CurBB == CurMBB ||
+ (isExportableFromCurrentBlock(BOp->getOperand(0), BB) &&
+ isExportableFromCurrentBlock(BOp->getOperand(1), BB)))) {
ISD::CondCode SignCond, UnsCond, FPCond, Condition;
switch (BOp->getOpcode()) {
default: assert(0 && "Unknown setcc opcode!");
@@ -903,7 +902,6 @@ void SelectionDAGLowering::FindMergedConditions(Value *Cond,
SelectionDAGISel::CaseBlock CB(ISD::SETEQ, Cond, ConstantBool::getTrue(),
TBB, FBB, CurBB);
SwitchCases.push_back(CB);
- ExportFromCurrentBlock(Cond);
return;
}
@@ -993,6 +991,18 @@ void SelectionDAGLowering::visitBr(BranchInst &I) {
(BOp->getOpcode() == Instruction::And ||
BOp->getOpcode() == Instruction::Or)) {
FindMergedConditions(BOp, Succ0MBB, Succ1MBB, CurMBB, BOp->getOpcode());
+
+ // If the compares in later blocks need to use values not currently
+ // exported from this block, export them now. This block should always be
+ // the first entry.
+ assert(SwitchCases[0].ThisBB == CurMBB && "Unexpected lowering!");
+
+ for (unsigned i = 1, e = SwitchCases.size(); i != e; ++i) {
+ ExportFromCurrentBlock(SwitchCases[i].CmpLHS);
+ ExportFromCurrentBlock(SwitchCases[i].CmpRHS);
+ }
+
+ // Emit the branch for this block.
visitSwitchCase(SwitchCases[0]);
SwitchCases.erase(SwitchCases.begin());
return;