While experimenting with the LoopUnroller pass for SystemZ, it was obvious that some loops regressed, due to the fact that LSR introduced negative offsets for load / store operations. These require an extra load-address instruction for float and vector types on SystemZ..
To be able to avoid this, I tried using isLegalAddressingMode() by returning false for float / double. This however caused other regressions.
Therefore I had to add a new method to TargetTransformInfo which adds an extra cost for the where appropriate. It seems to make sense generally to let targets adjust LSR formula rating.
During rating of formulas, the new TTI method needs to look at the actual user instructions. This was a bit awkward to get in place, and it may very well be that the code owner of this file could do a better job of it, or do some refactoring. I resorted to passing the Fixups to RateFormula, while letting the LSRUse access the right LSRFixup by means of an index. I had to rearrange code a bit to be able to use the LSRFixup class as an argument to RateFormula.
This seems to be the only viable way of using partial / runtime loop unrolling on SystemZ.
We should mention that the addressing mode is of the form reg + Offset.