[llvm-commits] CVS: llvm/lib/Transforms/Utils/SimplifyCFG.cpp
Chris Lattner
lattner at cs.uiuc.edu
Tue Sep 28 22:43:45 PDT 2004
Changes in directory llvm/lib/Transforms/Utils:
SimplifyCFG.cpp updated: 1.52 -> 1.53
---
Log message:
Do not insert trivially dead select instructions, which allows us to
potentially fold more in one pass.
---
Diffs of the changes: (+11 -2)
Index: llvm/lib/Transforms/Utils/SimplifyCFG.cpp
diff -u llvm/lib/Transforms/Utils/SimplifyCFG.cpp:1.52 llvm/lib/Transforms/Utils/SimplifyCFG.cpp:1.53
--- llvm/lib/Transforms/Utils/SimplifyCFG.cpp:1.52 Wed Sep 15 12:06:42 2004
+++ llvm/lib/Transforms/Utils/SimplifyCFG.cpp Wed Sep 29 00:43:32 2004
@@ -753,10 +753,19 @@
FalseSucc->removePredecessor(BI->getParent());
// Insert a new select instruction.
- Value *NewRetVal = new SelectInst(BI->getCondition(), TrueValue,
- FalseValue, "retval", BI);
+ Value *NewRetVal;
+ Value *BrCond = BI->getCondition();
+ if (TrueValue != FalseValue)
+ NewRetVal = new SelectInst(BrCond, TrueValue,
+ FalseValue, "retval", BI);
+ else
+ NewRetVal = TrueValue;
+
new ReturnInst(NewRetVal, BI);
BI->getParent()->getInstList().erase(BI);
+ if (BrCond->use_empty())
+ if (Instruction *BrCondI = dyn_cast<Instruction>(BrCond))
+ BrCondI->getParent()->getInstList().erase(BrCondI);
return true;
}
}
More information about the llvm-commits
mailing list