forked from OSchip/llvm-project
[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
This commit is contained in:
parent
538fb72226
commit
d1ce455f7b
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue