[llvm-commits] [llvm] r90299 - /llvm/trunk/lib/Transforms/Scalar/GVN.cpp
Chris Lattner
sabre at nondot.org
Tue Dec 1 22:44:58 PST 2009
Author: lattner
Date: Wed Dec 2 00:44:58 2009
New Revision: 90299
URL: http://llvm.org/viewvc/llvm-project?rev=90299&view=rev
Log:
factor some code better.
Modified:
llvm/trunk/lib/Transforms/Scalar/GVN.cpp
Modified: llvm/trunk/lib/Transforms/Scalar/GVN.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/GVN.cpp?rev=90299&r1=90298&r2=90299&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/GVN.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/GVN.cpp Wed Dec 2 00:44:58 2009
@@ -1187,6 +1187,13 @@
return V;
}
+static bool isLifetimeStartOrEnd(Instruction *Inst) {
+ if (IntrinsicInst* II = dyn_cast<IntrinsicInst>(Inst))
+ return II->getIntrinsicID() == Intrinsic::lifetime_start ||
+ II->getIntrinsicID() == Intrinsic::lifetime_end;
+ return false;
+}
+
/// processNonLocalLoad - Attempt to eliminate a load whose dependencies are
/// non-local by performing PHI construction.
bool GVN::processNonLocalLoad(LoadInst *LI,
@@ -1254,21 +1261,14 @@
Instruction *DepInst = DepInfo.getInst();
// Loading the allocation -> undef.
- if (isa<AllocaInst>(DepInst) || isMalloc(DepInst)) {
+ if (isa<AllocaInst>(DepInst) || isMalloc(DepInst) ||
+ // Loading immediately after lifetime begin or end -> undef.
+ isLifetimeStartOrEnd(DepInst)) {
ValuesPerBlock.push_back(AvailableValueInBlock::get(DepBB,
UndefValue::get(LI->getType())));
continue;
}
- // Loading immediately after lifetime begin or end -> undef.
- if (IntrinsicInst* II = dyn_cast<IntrinsicInst>(DepInst)) {
- if (II->getIntrinsicID() == Intrinsic::lifetime_start ||
- II->getIntrinsicID() == Intrinsic::lifetime_end) {
- ValuesPerBlock.push_back(AvailableValueInBlock::get(DepBB,
- UndefValue::get(LI->getType())));
- }
- }
-
if (StoreInst *S = dyn_cast<StoreInst>(DepInst)) {
// Reject loads and stores that are to the same address but are of
// different types if we have to.
More information about the llvm-commits
mailing list