When doing load/store promotion within LICM, if we cannot prove that it is safe to sink the store we won't hoist the load, even though we can prove the load could be dereferenced and moved outside the loop. This patch implements the load promotion by moving it in the loop preheader by inserting proper PHI in the loop. The store is kept as is in the loop. By doing this, we avoid doing the load from a memory location in each iteration.
Please consider this small example:
loop { var = *ptr; if (var) break; *ptr= var + 1; }
After this patch, it will be:
var0 = *ptr; loop { var1 = phi (var0, var2); if (var1) break; var2 = var1 + 1; *ptr = var2; }
This addresses some problems from [0].
Make this comment generic.
e.g. Will return true if a sub-class wants to keep one of the loads or stores after SSA construction.