aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorDuncan Sands <baldrick@free.fr>2010-11-14 13:30:18 +0000
committerDuncan Sands <baldrick@free.fr>2010-11-14 13:30:18 +0000
commitcd6636c737a82949ad13db2d0d918af6424fb78b (patch)
treed3a7b6371ca1c32f8ca737e1dfb5625b7af8b6e5 /lib
parentc0362d5c6e0066c741bce056a65d8b4c026de19f (diff)
downloadexternal_llvm-cd6636c737a82949ad13db2d0d918af6424fb78b.zip
external_llvm-cd6636c737a82949ad13db2d0d918af6424fb78b.tar.gz
external_llvm-cd6636c737a82949ad13db2d0d918af6424fb78b.tar.bz2
Teach InstructionSimplify about phi nodes. I chose to have it simply
offload the work to hasConstantValue rather than do something more complicated (such handling mutually recursive phis) because (1) it is not clear it is worth it; and (2) if it is worth it, maybe such logic would be better placed in hasConstantValue. Adjust some GVN tests which are now cleaned up much further (eg: all phi nodes are removed). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@119043 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Analysis/InstructionSimplify.cpp2
-rw-r--r--lib/Transforms/InstCombine/InstCombinePHI.cpp5
2 files changed, 5 insertions, 2 deletions
diff --git a/lib/Analysis/InstructionSimplify.cpp b/lib/Analysis/InstructionSimplify.cpp
index b3e817a..210399d 100644
--- a/lib/Analysis/InstructionSimplify.cpp
+++ b/lib/Analysis/InstructionSimplify.cpp
@@ -699,6 +699,8 @@ Value *llvm::SimplifyInstruction(Instruction *I, const TargetData *TD) {
SmallVector<Value*, 8> Ops(I->op_begin(), I->op_end());
return SimplifyGEPInst(&Ops[0], Ops.size(), TD);
}
+ case Instruction::PHI:
+ return cast<PHINode>(I)->hasConstantValue();
}
}
diff --git a/lib/Transforms/InstCombine/InstCombinePHI.cpp b/lib/Transforms/InstCombine/InstCombinePHI.cpp
index f7fc62f..736473d 100644
--- a/lib/Transforms/InstCombine/InstCombinePHI.cpp
+++ b/lib/Transforms/InstCombine/InstCombinePHI.cpp
@@ -12,6 +12,7 @@
//===----------------------------------------------------------------------===//
#include "InstCombine.h"
+#include "llvm/Analysis/InstructionSimplify.h"
#include "llvm/Target/TargetData.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/STLExtras.h"
@@ -731,8 +732,8 @@ Instruction *InstCombiner::SliceUpIllegalIntegerPHI(PHINode &FirstPhi) {
Instruction *InstCombiner::visitPHINode(PHINode &PN) {
// If LCSSA is around, don't mess with Phi nodes
if (MustPreserveLCSSA) return 0;
-
- if (Value *V = PN.hasConstantValue())
+
+ if (Value *V = SimplifyInstruction(&PN, TD))
return ReplaceInstUsesWith(PN, V);
// If all PHI operands are the same operation, pull them through the PHI,