[llvm-dev] [RFC] design doc for straight-line scalar optimizations

David Chisnall via llvm-dev llvm-dev at lists.llvm.org
Tue Aug 25 10:32:58 PDT 2015


On 25 Aug 2015, at 03:05, escha via llvm-dev <llvm-dev at lists.llvm.org> wrote:
> 
> These are just a few examples I spotted; it’s probably a more general LLVM problem as a whole that passes which manipulate GEPs and induction variables tend to be oblivious of addressing modes, or tuned towards a particular sort of addressing mode.

The canonical form for a loop in LLVM IR is to have a single induction variable and derive all other variables from it.  This is good for mid-level optimisers, but often ends up generating quite sub-optimal code on at least some targets.  For example, turning an add-immediate of another variable in each loop iteration into a multiply (one instruction, multi-cycle latency) of the loop induction variable a constant (which takes one instruction to materialise on MIPS, as there’s no multiply-by-immediate instruction).

If we had some documentation of precisely *what* the canonical forms are for each phase in the optimisation pipeline, then it would be easier to understand these effects and know when we need some de-canonicalise pass before codegen.

David



More information about the llvm-dev mailing list