aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2006-11-21 17:05:13 +0000
committerChris Lattner <sabre@nondot.org>2006-11-21 17:05:13 +0000
commit13c654a42a1ef4f04d0f19256e6265438c2f7d07 (patch)
treeeb1ab7b4da5d0889311842c2a3aaac4f9bae908c /lib
parent12c49af81e370df835ca1b72cdcefcadafcede4b (diff)
downloadexternal_llvm-13c654a42a1ef4f04d0f19256e6265438c2f7d07.zip
external_llvm-13c654a42a1ef4f04d0f19256e6265438c2f7d07.tar.gz
external_llvm-13c654a42a1ef4f04d0f19256e6265438c2f7d07.tar.bz2
This xform is handled by FoldOpIntoPhi in visitCastInst in a more elegant way.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31889 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Transforms/Scalar/InstructionCombining.cpp31
1 files changed, 1 insertions, 30 deletions
diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp
index 968e6ad..5a586e0 100644
--- a/lib/Transforms/Scalar/InstructionCombining.cpp
+++ b/lib/Transforms/Scalar/InstructionCombining.cpp
@@ -5784,7 +5784,7 @@ Instruction *InstCombiner::visitCastInst(CastInst &CI) {
return &CI;
}
}
-
+
// If we are casting a malloc or alloca to a pointer to a type of the same
// size, rewrite the allocation instruction to allocate the "right" type.
//
@@ -7144,35 +7144,6 @@ Instruction *InstCombiner::visitPHINode(PHINode &PN) {
if (Value *V = PN.hasConstantValue())
return ReplaceInstUsesWith(PN, V);
- // If the only user of this instruction is a cast instruction, and all of the
- // incoming values are constants, change this PHI to merge together the casted
- // constants.
- if (PN.hasOneUse())
- if (CastInst *CI = dyn_cast<CastInst>(PN.use_back()))
- if (CI->getType() != PN.getType()) { // noop casts will be folded
- bool AllConstant = true;
- for (unsigned i = 0, e = PN.getNumIncomingValues(); i != e; ++i)
- if (!isa<Constant>(PN.getIncomingValue(i))) {
- AllConstant = false;
- break;
- }
- if (AllConstant) {
- // Make a new PHI with all casted values.
- PHINode *New = new PHINode(CI->getType(), PN.getName(), &PN);
- for (unsigned i = 0, e = PN.getNumIncomingValues(); i != e; ++i) {
- Constant *OldArg = cast<Constant>(PN.getIncomingValue(i));
- New->addIncoming(ConstantExpr::getCast(OldArg, New->getType()),
- PN.getIncomingBlock(i));
- }
-
- // Update the cast instruction.
- CI->setOperand(0, New);
- WorkList.push_back(CI); // revisit the cast instruction to fold.
- WorkList.push_back(New); // Make sure to revisit the new Phi
- return &PN; // PN is now dead!
- }
- }
-
// If all PHI operands are the same operation, pull them through the PHI,
// reducing code size.
if (isa<Instruction>(PN.getIncomingValue(0)) &&