From 609ccbb2407ff346ffcedd7b8d7937fb98e11a01 Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Sat, 13 Nov 2021 08:34:22 -0800 Subject: [PATCH] [PowerPC] Use SDNode::uses (NFC) --- llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp | 12 ++--- llvm/lib/Target/PowerPC/PPCISelLowering.cpp | 78 +++++++++++------------------ 2 files changed, 33 insertions(+), 57 deletions(-) diff --git a/llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp b/llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp index ef9cb45..7a6276b 100644 --- a/llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp +++ b/llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp @@ -6276,9 +6276,7 @@ void PPCDAGToDAGISel::PostprocessISelDAG() { // be folded with the isel so that we don't need to materialize a register // containing zero. bool PPCDAGToDAGISel::AllUsersSelectZero(SDNode *N) { - for (SDNode::use_iterator UI = N->use_begin(), UE = N->use_end(); - UI != UE; ++UI) { - SDNode *User = *UI; + for (const SDNode *User : N->uses()) { if (!User->isMachineOpcode()) return false; if (User->getMachineOpcode() != PPC::SELECT_I4 && @@ -6312,18 +6310,14 @@ bool PPCDAGToDAGISel::AllUsersSelectZero(SDNode *N) { void PPCDAGToDAGISel::SwapAllSelectUsers(SDNode *N) { SmallVector ToReplace; - for (SDNode::use_iterator UI = N->use_begin(), UE = N->use_end(); - UI != UE; ++UI) { - SDNode *User = *UI; + for (SDNode *User : N->uses()) { assert((User->getMachineOpcode() == PPC::SELECT_I4 || User->getMachineOpcode() == PPC::SELECT_I8) && "Must have all select users"); ToReplace.push_back(User); } - for (SmallVector::iterator UI = ToReplace.begin(), - UE = ToReplace.end(); UI != UE; ++UI) { - SDNode *User = *UI; + for (SDNode *User : ToReplace) { SDNode *ResNode = CurDAG->getMachineNode(User->getMachineOpcode(), SDLoc(User), User->getValueType(0), User->getOperand(0), diff --git a/llvm/lib/Target/PowerPC/PPCISelLowering.cpp b/llvm/lib/Target/PowerPC/PPCISelLowering.cpp index a7b2fec..7c9f378 100644 --- a/llvm/lib/Target/PowerPC/PPCISelLowering.cpp +++ b/llvm/lib/Target/PowerPC/PPCISelLowering.cpp @@ -2570,9 +2570,8 @@ static bool provablyDisjointOr(SelectionDAG &DAG, const SDValue &N) { bool PPCTargetLowering::SelectAddressEVXRegReg(SDValue N, SDValue &Base, SDValue &Index, SelectionDAG &DAG) const { - for (SDNode::use_iterator UI = N->use_begin(), E = N->use_end(); - UI != E; ++UI) { - if (MemSDNode *Memop = dyn_cast(*UI)) { + for (SDNode *U : N->uses()) { + if (MemSDNode *Memop = dyn_cast(U)) { if (Memop->getMemoryVT() == MVT::f64) { Base = N.getOperand(0); Index = N.getOperand(1); @@ -13205,12 +13204,12 @@ static bool findConsecutiveLoad(LoadSDNode *LD, SelectionDAG &DAG) { if (isConsecutiveLS(ChainLD, LD, VT.getStoreSize(), 1, DAG)) return true; - for (SDNode::use_iterator UI = LoadRoot->use_begin(), - UE = LoadRoot->use_end(); UI != UE; ++UI) - if (((isa(*UI) && - cast(*UI)->getChain().getNode() == LoadRoot) || - UI->getOpcode() == ISD::TokenFactor) && !Visited.count(*UI)) - Queue.push_back(*UI); + for (SDNode *U : LoadRoot->uses()) + if (((isa(U) && + cast(U)->getChain().getNode() == LoadRoot) || + U->getOpcode() == ISD::TokenFactor) && + !Visited.count(U)) + Queue.push_back(U); } } @@ -13267,11 +13266,9 @@ SDValue PPCTargetLowering::ConvertSETCCToSubtract(SDNode *N, // If all users of SETCC extend its value to a legal integer type // then we replace SETCC with a subtraction - for (SDNode::use_iterator UI = N->use_begin(), - UE = N->use_end(); UI != UE; ++UI) { - if (UI->getOpcode() != ISD::ZERO_EXTEND) + for (const SDNode *U : N->uses()) + if (U->getOpcode() != ISD::ZERO_EXTEND) return SDValue(); - } ISD::CondCode CC = cast(N->getOperand(2))->get(); auto OpSize = N->getOperand(0).getValueSizeInBits(); @@ -13448,10 +13445,7 @@ SDValue PPCTargetLowering::DAGCombineTruncBoolExt(SDNode *N, if (isa(Inputs[i])) continue; - for (SDNode::use_iterator UI = Inputs[i].getNode()->use_begin(), - UE = Inputs[i].getNode()->use_end(); - UI != UE; ++UI) { - SDNode *User = *UI; + for (const SDNode *User : Inputs[i].getNode()->uses()) { if (User != N && !Visited.count(User)) return SDValue(); @@ -13472,10 +13466,7 @@ SDValue PPCTargetLowering::DAGCombineTruncBoolExt(SDNode *N, } for (unsigned i = 0, ie = PromOps.size(); i != ie; ++i) { - for (SDNode::use_iterator UI = PromOps[i].getNode()->use_begin(), - UE = PromOps[i].getNode()->use_end(); - UI != UE; ++UI) { - SDNode *User = *UI; + for (const SDNode *User : PromOps[i].getNode()->uses()) { if (User != N && !Visited.count(User)) return SDValue(); @@ -13660,10 +13651,7 @@ SDValue PPCTargetLowering::DAGCombineExtBoolTrunc(SDNode *N, if (isa(Inputs[i])) continue; - for (SDNode::use_iterator UI = Inputs[i].getNode()->use_begin(), - UE = Inputs[i].getNode()->use_end(); - UI != UE; ++UI) { - SDNode *User = *UI; + for (SDNode *User : Inputs[i].getNode()->uses()) { if (User != N && !Visited.count(User)) return SDValue(); @@ -13685,10 +13673,7 @@ SDValue PPCTargetLowering::DAGCombineExtBoolTrunc(SDNode *N, } for (unsigned i = 0, ie = PromOps.size(); i != ie; ++i) { - for (SDNode::use_iterator UI = PromOps[i].getNode()->use_begin(), - UE = PromOps[i].getNode()->use_end(); - UI != UE; ++UI) { - SDNode *User = *UI; + for (SDNode *User : PromOps[i].getNode()->uses()) { if (User != N && !Visited.count(User)) return SDValue(); @@ -15383,36 +15368,33 @@ SDValue PPCTargetLowering::PerformDAGCombine(SDNode *N, APInt::getAllOnes(Bits /* alignment */) .zext(Add.getScalarValueSizeInBits()))) { SDNode *BasePtr = Add->getOperand(0).getNode(); - for (SDNode::use_iterator UI = BasePtr->use_begin(), - UE = BasePtr->use_end(); - UI != UE; ++UI) { - if (UI->getOpcode() == ISD::INTRINSIC_WO_CHAIN && - cast(UI->getOperand(0))->getZExtValue() == - IID) { + for (SDNode *U : BasePtr->uses()) { + if (U->getOpcode() == ISD::INTRINSIC_WO_CHAIN && + cast(U->getOperand(0))->getZExtValue() == IID) { // We've found another LVSL/LVSR, and this address is an aligned // multiple of that one. The results will be the same, so use the // one we've just found instead. - return SDValue(*UI, 0); + return SDValue(U, 0); } } } if (isa(Add->getOperand(1))) { SDNode *BasePtr = Add->getOperand(0).getNode(); - for (SDNode::use_iterator UI = BasePtr->use_begin(), - UE = BasePtr->use_end(); UI != UE; ++UI) { - if (UI->getOpcode() == ISD::ADD && - isa(UI->getOperand(1)) && + for (SDNode *U : BasePtr->uses()) { + if (U->getOpcode() == ISD::ADD && + isa(U->getOperand(1)) && (cast(Add->getOperand(1))->getZExtValue() - - cast(UI->getOperand(1))->getZExtValue()) % - (1ULL << Bits) == 0) { - SDNode *OtherAdd = *UI; - for (SDNode::use_iterator VI = OtherAdd->use_begin(), - VE = OtherAdd->use_end(); VI != VE; ++VI) { - if (VI->getOpcode() == ISD::INTRINSIC_WO_CHAIN && - cast(VI->getOperand(0))->getZExtValue() == IID) { - return SDValue(*VI, 0); + cast(U->getOperand(1))->getZExtValue()) % + (1ULL << Bits) == + 0) { + SDNode *OtherAdd = U; + for (SDNode *V : OtherAdd->uses()) { + if (V->getOpcode() == ISD::INTRINSIC_WO_CHAIN && + cast(V->getOperand(0))->getZExtValue() == + IID) { + return SDValue(V, 0); } } } -- 2.7.4