This now try to reorder instructions in order to help create the optimizable pattern.
Details
Diff Detail
Event Timeline
I haven't looked into details, but I am a bit concerned by the number of nested level and the added length to this function, do you think it would make sense to refactor with one or multiple helper functions?
Indeed, I considered that part of this could be extract in an utility class. I wasn't really sure where to put it, but if you have a suggestion I'm taking. The TL;DR of the code is that it tries to lift an instruction + whatever depends on this instruction above another instruction in the same basic block. It needs to have alias analysis available to do it.
Looks good to me with a few comments below.
lib/Transforms/Scalar/MemCpyOptimizer.cpp | ||
---|---|---|
508 | Update the comment: according to the code, it does more than keeping only the *store* args. It contains all the instructions that needs to be placed before P to satisfy the lift. | |
525 | Should be replaceable with something like: for(auto *C : reverse(make_range(P->getIterator(), --SI->getIterator()))) | |
540 | Minor suggestion: I think this can be written NeedList ||= std::any_of(... |
Update the comment: according to the code, it does more than keeping only the *store* args. It contains all the instructions that needs to be placed before P to satisfy the lift.