llvm.org GIT mirror llvm / c03e9a1
Simplify findNonImmUse; return the result using the return value instead of via a by-reference argument. No functionality change. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@63118 91177308-0d34-0410-b5e6-96231b3b80d8 Dan Gohman 10 years ago
1 changed file(s) with 15 addition(s) and 17 deletion(s). Raw diff Collapse all Expand all
248248 return NULL;
249249 }
250250
251 /// findNonImmUse - Return true by reference in "found" if "Use" is an
252 /// non-immediate use of "Def". This function recursively traversing
253 /// up the operand chain ignoring certain nodes.
254 static void findNonImmUse(SDNode *Use, SDNode* Def, SDNode *ImmedUse,
255 SDNode *Root, bool &found,
251 /// findNonImmUse - Return true if "Use" is a non-immediate use of "Def".
252 /// This function recursively traverses up the operand chain, ignoring
253 /// certain nodes.
254 static bool findNonImmUse(SDNode *Use, SDNode* Def, SDNode *ImmedUse,
255 SDNode *Root,
256256 SmallPtrSet &Visited) {
257 if (found ||
258 Use->getNodeId() < Def->getNodeId() ||
257 if (Use->getNodeId() < Def->getNodeId() ||
259258 !Visited.insert(Use))
260 return;
261
262 for (unsigned i = 0, e = Use->getNumOperands(); !found && i != e; ++i) {
259 return false;
260
261 for (unsigned i = 0, e = Use->getNumOperands(); i != e; ++i) {
263262 SDNode *N = Use->getOperand(i).getNode();
264263 if (N == Def) {
265264 if (Use == ImmedUse || Use == Root)
266265 continue; // We are not looking for immediate use.
267266 assert(N != Root);
268 found = true;
269 break;
267 return true;
270268 }
271269
272270 // Traverse up the operand chain.
273 findNonImmUse(N, Def, ImmedUse, Root, found, Visited);
274 }
271 if (findNonImmUse(N, Def, ImmedUse, Root, Visited))
272 return true;
273 }
274 return false;
275275 }
276276
277277 /// isNonImmUse - Start searching from Root up the DAG to check is Def can
286286 /// its chain operand.
287287 static inline bool isNonImmUse(SDNode *Root, SDNode *Def, SDNode *ImmedUse) {
288288 SmallPtrSet Visited;
289 bool found = false;
290 findNonImmUse(Root, Def, ImmedUse, Root, found, Visited);
291 return found;
289 return findNonImmUse(Root, Def, ImmedUse, Root, Visited);
292290 }
293291
294292