aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Scalar
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Transforms/Scalar')
-rw-r--r--llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp35
-rw-r--r--llvm/lib/Transforms/Scalar/GVN.cpp1
-rw-r--r--llvm/lib/Transforms/Scalar/NewGVN.cpp1
-rw-r--r--llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp2
4 files changed, 17 insertions, 22 deletions
diff --git a/llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp b/llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp
index 584cdad..e448230 100644
--- a/llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp
+++ b/llvm/lib/Transforms/Scalar/DFAJumpThreading.cpp
@@ -1206,19 +1206,18 @@ private:
// value for the new predecessor ClonedBB. The value will either be the same
// value from BB or a cloned value.
for (BasicBlock *Succ : BlocksToUpdate) {
- for (auto II = Succ->begin(); PHINode *Phi = dyn_cast<PHINode>(II);
- ++II) {
- Value *Incoming = Phi->getIncomingValueForBlock(BB);
+ for (PHINode &Phi : Succ->phis()) {
+ Value *Incoming = Phi.getIncomingValueForBlock(BB);
if (Incoming) {
if (isa<Constant>(Incoming)) {
- Phi->addIncoming(Incoming, ClonedBB);
+ Phi.addIncoming(Incoming, ClonedBB);
continue;
}
Value *ClonedVal = VMap[Incoming];
if (ClonedVal)
- Phi->addIncoming(ClonedVal, ClonedBB);
+ Phi.addIncoming(ClonedVal, ClonedBB);
else
- Phi->addIncoming(Incoming, ClonedBB);
+ Phi.addIncoming(Incoming, ClonedBB);
}
}
}
@@ -1313,27 +1312,19 @@ private:
void cleanPhiNodes(BasicBlock *BB) {
// If BB is no longer reachable, remove any remaining phi nodes
if (pred_empty(BB)) {
- std::vector<PHINode *> PhiToRemove;
- for (auto II = BB->begin(); PHINode *Phi = dyn_cast<PHINode>(II); ++II) {
- PhiToRemove.push_back(Phi);
- }
- for (PHINode *PN : PhiToRemove) {
- PN->replaceAllUsesWith(PoisonValue::get(PN->getType()));
- PN->eraseFromParent();
+ for (PHINode &PN : make_early_inc_range(BB->phis())) {
+ PN.replaceAllUsesWith(PoisonValue::get(PN.getType()));
+ PN.eraseFromParent();
}
return;
}
// Remove any incoming values that come from an invalid predecessor
- for (auto II = BB->begin(); PHINode *Phi = dyn_cast<PHINode>(II); ++II) {
- std::vector<BasicBlock *> BlocksToRemove;
- for (BasicBlock *IncomingBB : Phi->blocks()) {
- if (!isPredecessor(BB, IncomingBB))
- BlocksToRemove.push_back(IncomingBB);
- }
- for (BasicBlock *BB : BlocksToRemove)
- Phi->removeIncomingValue(BB);
- }
+ for (PHINode &Phi : BB->phis())
+ Phi.removeIncomingValueIf([&](unsigned Index) {
+ BasicBlock *IncomingBB = Phi.getIncomingBlock(Index);
+ return !isPredecessor(BB, IncomingBB);
+ });
}
/// Checks if BB was already cloned for a particular next state value. If it
diff --git a/llvm/lib/Transforms/Scalar/GVN.cpp b/llvm/lib/Transforms/Scalar/GVN.cpp
index b9b5b58..638952a 100644
--- a/llvm/lib/Transforms/Scalar/GVN.cpp
+++ b/llvm/lib/Transforms/Scalar/GVN.cpp
@@ -699,6 +699,7 @@ uint32_t GVNPass::ValueTable::lookupOrAdd(Value *V) {
case Instruction::FPTrunc:
case Instruction::FPExt:
case Instruction::PtrToInt:
+ case Instruction::PtrToAddr:
case Instruction::IntToPtr:
case Instruction::AddrSpaceCast:
case Instruction::BitCast:
diff --git a/llvm/lib/Transforms/Scalar/NewGVN.cpp b/llvm/lib/Transforms/Scalar/NewGVN.cpp
index d6b7633..3c1a8ba 100644
--- a/llvm/lib/Transforms/Scalar/NewGVN.cpp
+++ b/llvm/lib/Transforms/Scalar/NewGVN.cpp
@@ -2066,6 +2066,7 @@ NewGVN::performSymbolicEvaluation(Instruction *I,
case Instruction::FPTrunc:
case Instruction::FPExt:
case Instruction::PtrToInt:
+ case Instruction::PtrToAddr:
case Instruction::IntToPtr:
case Instruction::Select:
case Instruction::ExtractElement:
diff --git a/llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp b/llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp
index 60e5df0..7ffccf7 100644
--- a/llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp
+++ b/llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp
@@ -355,6 +355,8 @@ void SimplifyCFGPass::printPipeline(
OS << (Options.ForwardSwitchCondToPhi ? "" : "no-") << "forward-switch-cond;";
OS << (Options.ConvertSwitchRangeToICmp ? "" : "no-")
<< "switch-range-to-icmp;";
+ OS << (Options.ConvertSwitchToArithmetic ? "" : "no-")
+ << "switch-to-arithmetic;";
OS << (Options.ConvertSwitchToLookupTable ? "" : "no-")
<< "switch-to-lookup;";
OS << (Options.NeedCanonicalLoop ? "" : "no-") << "keep-loops;";