Also, if (std::find(Rdx->begin(), Rdx->end(), UserInst) != Rdx->end()) continue; You can use X.count(y) to search inside a set. http://llvm-reviews.chandlerc.com/D3143