forked from OSchip/llvm-project
[NFC][InstCombine] Adjust naming for some methods to match coding standards
Requested as preparatory cleanup in https://reviews.llvm.org/D86306#inline-799065
This commit is contained in:
parent
b6d7ed469f
commit
56c529300e
|
@ -615,16 +615,16 @@ public:
|
||||||
|
|
||||||
/// Try to rotate an operation below a PHI node, using PHI nodes for
|
/// Try to rotate an operation below a PHI node, using PHI nodes for
|
||||||
/// its operands.
|
/// its operands.
|
||||||
Instruction *FoldPHIArgOpIntoPHI(PHINode &PN);
|
Instruction *foldPHIArgOpIntoPHI(PHINode &PN);
|
||||||
Instruction *FoldPHIArgBinOpIntoPHI(PHINode &PN);
|
Instruction *foldPHIArgBinOpIntoPHI(PHINode &PN);
|
||||||
Instruction *FoldPHIArgGEPIntoPHI(PHINode &PN);
|
Instruction *foldPHIArgGEPIntoPHI(PHINode &PN);
|
||||||
Instruction *FoldPHIArgLoadIntoPHI(PHINode &PN);
|
Instruction *foldPHIArgLoadIntoPHI(PHINode &PN);
|
||||||
Instruction *FoldPHIArgZextsIntoPHI(PHINode &PN);
|
Instruction *foldPHIArgZextsIntoPHI(PHINode &PN);
|
||||||
|
|
||||||
/// If an integer typed PHI has only one use which is an IntToPtr operation,
|
/// If an integer typed PHI has only one use which is an IntToPtr operation,
|
||||||
/// replace the PHI with an existing pointer typed PHI if it exists. Otherwise
|
/// replace the PHI with an existing pointer typed PHI if it exists. Otherwise
|
||||||
/// insert a new pointer typed PHI and replace the original one.
|
/// insert a new pointer typed PHI and replace the original one.
|
||||||
Instruction *FoldIntegerTypedPHI(PHINode &PN);
|
Instruction *foldIntegerTypedPHI(PHINode &PN);
|
||||||
|
|
||||||
/// Helper function for FoldPHIArgXIntoPHI() to set debug location for the
|
/// Helper function for FoldPHIArgXIntoPHI() to set debug location for the
|
||||||
/// folded operation.
|
/// folded operation.
|
||||||
|
|
|
@ -94,7 +94,7 @@ void InstCombinerImpl::PHIArgMergedDebugLoc(Instruction *Inst, PHINode &PN) {
|
||||||
// ptr_val_inc = ...
|
// ptr_val_inc = ...
|
||||||
// ...
|
// ...
|
||||||
//
|
//
|
||||||
Instruction *InstCombinerImpl::FoldIntegerTypedPHI(PHINode &PN) {
|
Instruction *InstCombinerImpl::foldIntegerTypedPHI(PHINode &PN) {
|
||||||
if (!PN.getType()->isIntegerTy())
|
if (!PN.getType()->isIntegerTy())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
if (!PN.hasOneUse())
|
if (!PN.hasOneUse())
|
||||||
|
@ -293,7 +293,7 @@ Instruction *InstCombinerImpl::FoldIntegerTypedPHI(PHINode &PN) {
|
||||||
|
|
||||||
/// If we have something like phi [add (a,b), add(a,c)] and if a/b/c and the
|
/// If we have something like phi [add (a,b), add(a,c)] and if a/b/c and the
|
||||||
/// adds all have a single use, turn this into a phi and a single binop.
|
/// adds all have a single use, turn this into a phi and a single binop.
|
||||||
Instruction *InstCombinerImpl::FoldPHIArgBinOpIntoPHI(PHINode &PN) {
|
Instruction *InstCombinerImpl::foldPHIArgBinOpIntoPHI(PHINode &PN) {
|
||||||
Instruction *FirstInst = cast<Instruction>(PN.getIncomingValue(0));
|
Instruction *FirstInst = cast<Instruction>(PN.getIncomingValue(0));
|
||||||
assert(isa<BinaryOperator>(FirstInst) || isa<CmpInst>(FirstInst));
|
assert(isa<BinaryOperator>(FirstInst) || isa<CmpInst>(FirstInst));
|
||||||
unsigned Opc = FirstInst->getOpcode();
|
unsigned Opc = FirstInst->getOpcode();
|
||||||
|
@ -386,7 +386,7 @@ Instruction *InstCombinerImpl::FoldPHIArgBinOpIntoPHI(PHINode &PN) {
|
||||||
return NewBinOp;
|
return NewBinOp;
|
||||||
}
|
}
|
||||||
|
|
||||||
Instruction *InstCombinerImpl::FoldPHIArgGEPIntoPHI(PHINode &PN) {
|
Instruction *InstCombinerImpl::foldPHIArgGEPIntoPHI(PHINode &PN) {
|
||||||
GetElementPtrInst *FirstInst =cast<GetElementPtrInst>(PN.getIncomingValue(0));
|
GetElementPtrInst *FirstInst =cast<GetElementPtrInst>(PN.getIncomingValue(0));
|
||||||
|
|
||||||
SmallVector<Value*, 16> FixedOperands(FirstInst->op_begin(),
|
SmallVector<Value*, 16> FixedOperands(FirstInst->op_begin(),
|
||||||
|
@ -540,7 +540,7 @@ static bool isSafeAndProfitableToSinkLoad(LoadInst *L) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Instruction *InstCombinerImpl::FoldPHIArgLoadIntoPHI(PHINode &PN) {
|
Instruction *InstCombinerImpl::foldPHIArgLoadIntoPHI(PHINode &PN) {
|
||||||
LoadInst *FirstLI = cast<LoadInst>(PN.getIncomingValue(0));
|
LoadInst *FirstLI = cast<LoadInst>(PN.getIncomingValue(0));
|
||||||
|
|
||||||
// FIXME: This is overconservative; this transform is allowed in some cases
|
// FIXME: This is overconservative; this transform is allowed in some cases
|
||||||
|
@ -654,7 +654,7 @@ Instruction *InstCombinerImpl::FoldPHIArgLoadIntoPHI(PHINode &PN) {
|
||||||
/// TODO: This function could handle other cast types, but then it might
|
/// TODO: This function could handle other cast types, but then it might
|
||||||
/// require special-casing a cast from the 'i1' type. See the comment in
|
/// require special-casing a cast from the 'i1' type. See the comment in
|
||||||
/// FoldPHIArgOpIntoPHI() about pessimizing illegal integer types.
|
/// FoldPHIArgOpIntoPHI() about pessimizing illegal integer types.
|
||||||
Instruction *InstCombinerImpl::FoldPHIArgZextsIntoPHI(PHINode &Phi) {
|
Instruction *InstCombinerImpl::foldPHIArgZextsIntoPHI(PHINode &Phi) {
|
||||||
// We cannot create a new instruction after the PHI if the terminator is an
|
// We cannot create a new instruction after the PHI if the terminator is an
|
||||||
// EHPad because there is no valid insertion point.
|
// EHPad because there is no valid insertion point.
|
||||||
if (Instruction *TI = Phi.getParent()->getTerminator())
|
if (Instruction *TI = Phi.getParent()->getTerminator())
|
||||||
|
@ -728,7 +728,7 @@ Instruction *InstCombinerImpl::FoldPHIArgZextsIntoPHI(PHINode &Phi) {
|
||||||
/// If all operands to a PHI node are the same "unary" operator and they all are
|
/// If all operands to a PHI node are the same "unary" operator and they all are
|
||||||
/// only used by the PHI, PHI together their inputs, and do the operation once,
|
/// only used by the PHI, PHI together their inputs, and do the operation once,
|
||||||
/// to the result of the PHI.
|
/// to the result of the PHI.
|
||||||
Instruction *InstCombinerImpl::FoldPHIArgOpIntoPHI(PHINode &PN) {
|
Instruction *InstCombinerImpl::foldPHIArgOpIntoPHI(PHINode &PN) {
|
||||||
// We cannot create a new instruction after the PHI if the terminator is an
|
// We cannot create a new instruction after the PHI if the terminator is an
|
||||||
// EHPad because there is no valid insertion point.
|
// EHPad because there is no valid insertion point.
|
||||||
if (Instruction *TI = PN.getParent()->getTerminator())
|
if (Instruction *TI = PN.getParent()->getTerminator())
|
||||||
|
@ -738,9 +738,9 @@ Instruction *InstCombinerImpl::FoldPHIArgOpIntoPHI(PHINode &PN) {
|
||||||
Instruction *FirstInst = cast<Instruction>(PN.getIncomingValue(0));
|
Instruction *FirstInst = cast<Instruction>(PN.getIncomingValue(0));
|
||||||
|
|
||||||
if (isa<GetElementPtrInst>(FirstInst))
|
if (isa<GetElementPtrInst>(FirstInst))
|
||||||
return FoldPHIArgGEPIntoPHI(PN);
|
return foldPHIArgGEPIntoPHI(PN);
|
||||||
if (isa<LoadInst>(FirstInst))
|
if (isa<LoadInst>(FirstInst))
|
||||||
return FoldPHIArgLoadIntoPHI(PN);
|
return foldPHIArgLoadIntoPHI(PN);
|
||||||
|
|
||||||
// Scan the instruction, looking for input operations that can be folded away.
|
// Scan the instruction, looking for input operations that can be folded away.
|
||||||
// If all input operands to the phi are the same instruction (e.g. a cast from
|
// If all input operands to the phi are the same instruction (e.g. a cast from
|
||||||
|
@ -763,7 +763,7 @@ Instruction *InstCombinerImpl::FoldPHIArgOpIntoPHI(PHINode &PN) {
|
||||||
// otherwise call FoldPHIArgBinOpIntoPHI.
|
// otherwise call FoldPHIArgBinOpIntoPHI.
|
||||||
ConstantOp = dyn_cast<Constant>(FirstInst->getOperand(1));
|
ConstantOp = dyn_cast<Constant>(FirstInst->getOperand(1));
|
||||||
if (!ConstantOp)
|
if (!ConstantOp)
|
||||||
return FoldPHIArgBinOpIntoPHI(PN);
|
return foldPHIArgBinOpIntoPHI(PN);
|
||||||
} else {
|
} else {
|
||||||
return nullptr; // Cannot fold this operation.
|
return nullptr; // Cannot fold this operation.
|
||||||
}
|
}
|
||||||
|
@ -1207,7 +1207,7 @@ Instruction *InstCombinerImpl::visitPHINode(PHINode &PN) {
|
||||||
if (Value *V = SimplifyInstruction(&PN, SQ.getWithInstruction(&PN)))
|
if (Value *V = SimplifyInstruction(&PN, SQ.getWithInstruction(&PN)))
|
||||||
return replaceInstUsesWith(PN, V);
|
return replaceInstUsesWith(PN, V);
|
||||||
|
|
||||||
if (Instruction *Result = FoldPHIArgZextsIntoPHI(PN))
|
if (Instruction *Result = foldPHIArgZextsIntoPHI(PN))
|
||||||
return Result;
|
return Result;
|
||||||
|
|
||||||
// If all PHI operands are the same operation, pull them through the PHI,
|
// If all PHI operands are the same operation, pull them through the PHI,
|
||||||
|
@ -1219,14 +1219,14 @@ Instruction *InstCombinerImpl::visitPHINode(PHINode &PN) {
|
||||||
// FIXME: The hasOneUse check will fail for PHIs that use the value more
|
// FIXME: The hasOneUse check will fail for PHIs that use the value more
|
||||||
// than themselves more than once.
|
// than themselves more than once.
|
||||||
PN.getIncomingValue(0)->hasOneUse())
|
PN.getIncomingValue(0)->hasOneUse())
|
||||||
if (Instruction *Result = FoldPHIArgOpIntoPHI(PN))
|
if (Instruction *Result = foldPHIArgOpIntoPHI(PN))
|
||||||
return Result;
|
return Result;
|
||||||
|
|
||||||
// If this is a trivial cycle in the PHI node graph, remove it. Basically, if
|
// If this is a trivial cycle in the PHI node graph, remove it. Basically, if
|
||||||
// this PHI only has a single use (a PHI), and if that PHI only has one use (a
|
// this PHI only has a single use (a PHI), and if that PHI only has one use (a
|
||||||
// PHI)... break the cycle.
|
// PHI)... break the cycle.
|
||||||
if (PN.hasOneUse()) {
|
if (PN.hasOneUse()) {
|
||||||
if (Instruction *Result = FoldIntegerTypedPHI(PN))
|
if (Instruction *Result = foldIntegerTypedPHI(PN))
|
||||||
return Result;
|
return Result;
|
||||||
|
|
||||||
Instruction *PHIUser = cast<Instruction>(PN.user_back());
|
Instruction *PHIUser = cast<Instruction>(PN.user_back());
|
||||||
|
|
Loading…
Reference in New Issue