[Mlir-commits] [mlir] [mlir][x86vector] Sink Vector.transfer_reads and vector.load before the consumer (PR #169333)
Renato Golin
llvmlistbot at llvm.org
Tue Dec 9 08:10:31 PST 2025
https://github.com/rengolin commented:
This is getting closer, thanks!
There are some unsafe assumptions (inline comments), which I think we can address in the core algorithm.
I would flip this around. Something like:
```c++
users = node.getUsers()
if (users.size() > 1) return failure();
user = users[0];
producers = user.getProducers();
// Get all producers in program order
inOrder.push_back(node);
while(node = node->getNextNode()) {
if (node == user)
break;
if (llvm::is_contained(producers, node) {
inOrder.push_back(node);
producers.erase(find(producers, node));
continue;
}
}
// Push the user to the end of the list, to make the code below easier
inOrder.push_back(user);
// In reverse order, see if you can push the producer down
it = inOrder.end()-1;
for (to = it, from = it-1; it != inOrder.begin(); it-=2) {
// Search every op between the two for users of the producer (from)
// where we can't push below that
node = from;
while (node = node->getNextNode()) {
if (node == to) break;
if (llvm::is_contained(node.getProducers(), from)) break;
}
// Now, we should be safe to move "from" to before "node"
from->moveBefore(node);
}
```
_Note: unverified pseudo-code. This is just the idea behind it._
https://github.com/llvm/llvm-project/pull/169333
More information about the Mlir-commits
mailing list