[PATCH] D11345: ignore duplicate divisor uses when transforming into reciprocal multiplies (PR24141)
Sanjay Patel
spatel at rotateright.com
Mon Jul 20 13:30:04 PDT 2015
spatel added inline comments.
================
Comment at: lib/CodeGen/SelectionDAG/DAGCombiner.cpp:8372-8374
@@ -8371,3 +8371,5 @@
for (auto *U : N1->uses()) {
- if (U->getOpcode() == ISD::FDIV && U->getOperand(1) == N1)
- Users.push_back(U);
+ if (U->getOpcode() == ISD::FDIV && U->getOperand(1) == N1) {
+ // Only count unique users; duplicates may be present in the list.
+ if (std::find(Users.begin(), Users.end(), U) == Users.end())
+ Users.push_back(U);
----------------
echristo wrote:
> Could probably merge it into the existing if statement?
>
> That said, I guess using std::find on it is how we do it for most of these, I assume we don't expect a lot of users and so would want to use a different mechanism?
Sure, I can merge it into the compound 'if'.
I thought about changing this to a set (DenseSet?) rather than SmallVector, but I'm also assuming that we would not expect more than a few users, so left it as-is for now.
If you would prefer using a set here, let me know. Thanks!
http://reviews.llvm.org/D11345
More information about the llvm-commits
mailing list