I have a few questions regarding cost calculation in loop strength
1. Ignoring LSR uses of kind ICmpZero.
These usually come from the loop latch conditions. On Hexagon most loops
that would contain such a LSR use are going to be converted to hardware
loops and the entire check will disappear. There is no need to analyze
these cases in LSR. In fact, completely ignoring them improves
performance. Would it be reasonable to add a target hook to check if the
target wants to ignore these? I suppose this could apply to other target
with hardware loop support.
What it the motivation behind this code?
// Rough heuristic; favor registers which don't require extra setup
// instructions in the preheader.
if (!isa<SCEVUnknown>(Reg) &&
I'd imagine that this accounts for the extra code that needs to be
added, but why is it what it is? After extra formulas are generated,
some of them can contain constants that were not in the code before and
thus may require an instruction to put them into a register, yet for
constants the SetupCost will be 0. On a similar note, are SCEVUnknowns
presumed to already have a register?
There are many addressing modes that are legal on Hexagon, yet given a
choice, some are preferable to others. LSR treats all of them as
equivalent as long as a formula can be folded completely into it. Has
anyone thought about making the cost of an addressing mode be more detailed?
A lot of that code looks rather mysterious. Is there a document that was
the original inspiration?