summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/CodeGenPrepare.cpp
diff options
context:
space:
mode:
authorSanjay Patel <spatel@rotateright.com>2019-03-20 15:53:06 +0000
committerSanjay Patel <spatel@rotateright.com>2019-03-20 15:53:06 +0000
commitd1ce455f7b6d5ae2db8018bc89426d5cf3de4e83 (patch)
treee38ccdc54ede2ad3375bee560114cde01216d6ca /llvm/lib/CodeGen/CodeGenPrepare.cpp
parent538fb72226cf6dff95af83f7777e12b8dbd061ea (diff)
downloadbcm5719-llvm-d1ce455f7b6d5ae2db8018bc89426d5cf3de4e83.tar.gz
bcm5719-llvm-d1ce455f7b6d5ae2db8018bc89426d5cf3de4e83.zip
[CGP] convert chain of 'if' to 'switch'; NFC
This should be extended, but CGP does some strange things, so I'm intentionally not changing the potential order of any transforms yet. llvm-svn: 356566
Diffstat (limited to 'llvm/lib/CodeGen/CodeGenPrepare.cpp')
-rw-r--r--llvm/lib/CodeGen/CodeGenPrepare.cpp27
1 files changed, 13 insertions, 14 deletions
diff --git a/llvm/lib/CodeGen/CodeGenPrepare.cpp b/llvm/lib/CodeGen/CodeGenPrepare.cpp
index 44f1709b6e9..68bab28c0b7 100644
--- a/llvm/lib/CodeGen/CodeGenPrepare.cpp
+++ b/llvm/lib/CodeGen/CodeGenPrepare.cpp
@@ -6876,6 +6876,7 @@ bool CodeGenPrepare::optimizeInst(Instruction *I, DominatorTree &DT,
if (InsertedInsts.count(I))
return false;
+ // TODO: Move into the switch on opcode below here.
if (PHINode *P = dyn_cast<PHINode>(I)) {
// It is possible for very late stage optimizations (such as SimplifyCFG)
// to introduce PHI nodes too late to be cleaned up. If we detect such a
@@ -6994,20 +6995,18 @@ bool CodeGenPrepare::optimizeInst(Instruction *I, DominatorTree &DT,
if (tryToSinkFreeOperands(I))
return true;
- if (CallInst *CI = dyn_cast<CallInst>(I))
- return optimizeCallInst(CI, ModifiedDT);
-
- if (SelectInst *SI = dyn_cast<SelectInst>(I))
- return optimizeSelectInst(SI, ModifiedDT);
-
- if (ShuffleVectorInst *SVI = dyn_cast<ShuffleVectorInst>(I))
- return optimizeShuffleVectorInst(SVI);
-
- if (auto *Switch = dyn_cast<SwitchInst>(I))
- return optimizeSwitchInst(Switch);
-
- if (isa<ExtractElementInst>(I))
- return optimizeExtractElementInst(I);
+ switch (I->getOpcode()) {
+ case Instruction::Call:
+ return optimizeCallInst(cast<CallInst>(I), ModifiedDT);
+ case Instruction::Select:
+ return optimizeSelectInst(cast<SelectInst>(I), ModifiedDT);
+ case Instruction::ShuffleVector:
+ return optimizeShuffleVectorInst(cast<ShuffleVectorInst>(I));
+ case Instruction::Switch:
+ return optimizeSwitchInst(cast<SwitchInst>(I));
+ case Instruction::ExtractElement:
+ return optimizeExtractElementInst(cast<ExtractElementInst>(I));
+ }
return false;
}
OpenPOWER on IntegriCloud