[PATCH] D17203: [LICM] Hoist and sink entire inner loops.
Chris Diamand via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 17 05:33:49 PST 2016
chrisdiamand_arm added a comment.
In http://reviews.llvm.org/D17203#354312, @reames wrote:
> Taking a step back, can you give a motivating example on why we might want to do this? Your tests look like they'd be caught by loop-unswitch and LICM together, but I suspect that's just because the tests are (correctly) simple.
The motivation behind this is to handle things like the following:
void expensive_loop(...) {
for (...)
do_stuff;
}
for (int i = 0; i < big_number; ++i)
expensive_loop(...);
I noticed that setting `__attribute__((noinline))` on `expensive_loop()` made it run much faster. If inlining is disabled, the call to `expensive_loop()` can be sunk and is only run once. With inlining, the loop in `expensive_loop()` gets turned into a subloop, and can't be moved, so the inner loop is run `big_number` times. This patch would allow the inlined contents of `expensive_loop()` to be removed from the outer loop.
Cheers!
Chris
http://reviews.llvm.org/D17203
More information about the llvm-commits
mailing list