[llvm-dev] How to best deal with undesirable Induction Variable Simplification?
Danila Malyutin via llvm-dev
llvm-dev at lists.llvm.org
Thu Aug 8 10:36:08 PDT 2019
Recently I've come across two instances where Induction Variable Simplification lead to noticable performance regressions.
In one case, the removal of extra IV lead to the inability to reschedule instructions in a tight loop to reduce stalls. In that case, there were enough registers to spare, so using extra register for extra induction variable was preferable since it reduced dependencies in the loop.
In the second case, there was a big nested loop made even bigger after unswitching. However, the inner loop body was rather simple, of the form:
Due to unswitching there were several such loops each with the different number of p+=n ops, so when the IndVars pass rewrote all exit values, it added a lot of slightly different offsets to the main loop header that couldn't fit in the available registers which lead to unnecessary spills/reloads.
I am wondering what is the usual strategy for dealing with such "pessimizations"? Is it possible to somehow modify the IndVarSimplify pass to take those issues into account (for example, tell it that adding offset computation + gep is potentially more expensive than simply reusing last var from the loop) or should it be recovered in some later pass? If so, is there an easy way to revert IV elimination? Have anyone dealt with similar issues before?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the llvm-dev