RFC: Loop versioning for LICM

Thanks Hal, Philip and Adam for reviewing this RFC.

Based on suggestion I have made below changes.

Code change available at: http://reviews.llvm.org/D9151

  1. Using LAA(Loop Access Analysis) for versioning feasibility & memcheck.

As the part of feasibility analysis started using LAA.

Earlier memcheck creation was implemented under Loop Versioning, now using

LAA for this.

  1. Improved benefit analysis.

Introduced few checks to ensure the benefit of loop versioning.

  • Checking number of possible invariant promotion vs total instructions of loop.

If this goes beyond certain threshold then only do loop versioning.

Kept this threshold as a hard value as 25%(total instruction of loop), also

provided option to control this threshold.

  • Similar added check for invariant stores vs total stores in loop, kept this

threshold as a hard value 40%(total instruction of loop), also provided option

to control this threshold.

  1. Introduced threshold command line parameter to control loop nest,

benefit threshold etc.

  • loopver-invar-store-threshold

This option is to control invariant store vs total store threshold,

default 40% of total instruction.

  • loopver-invar-threshold

This option is to control invariant load & store vs total instruction threshold,

default 25% of total instruction.

  • loopver-max-depth-threshold

This option is to control maximum depth for loops getting considered,

default depth is 2.

  • loopver-memcheck-ptr-threshold

This option is to control maximum pointer/address getting considered, default is 5.

  1. Code refactoring

  2. Added test cases.

If possible, please review this change.

Regards,

Ashutosh