[llvm-dev] SCEV and LoopStrengthReduction Formulae

via llvm-dev llvm-dev at lists.llvm.org
Mon Apr 9 16:45:43 PDT 2018


> From: fglaser at apple.com <fglaser at apple.com> On Behalf Of escha at apple.com
> Sent: Saturday, April 7, 2018 8:22 AM
> 
>> I realize this is a micro-op saving a single cycle.  But this reduces the instruction count, one less
>> instr to decode in a potentially hot path. If this all makes sense, and seems like a reasonable addition
>> to llvm, would it make sense to implement this as a supplemental LSR formula, or as a separate pass?
>
> This seems reasonable to me so long as rbx has no other uses that would complicate the problem; I’m not sure how much this occurs in hot code (a loop with an induction variable
> that isn’t used in the loop), but if it does, I don’t see why not.

Thanks for this response and the examples!  I too think it could be a win, and I've explored both: implementing this as a pass (machine function pass) and as a SCEV expression for LSR (an LSR formula).  I'm still on the fence about which approach is the 'best', or more widely accepted.  To me it seems to be more advantageous to add this as an LSR formula, that pass provides a cost model and is target independent.  However, it does rely on the fact that X86 sets the zero flag for inc/add, I'm not sure about other architectures.  Additionally, this change would be fairly similar to what LSR already does.

-Matt


More information about the llvm-dev mailing list