llvm-project/llvm/test/Transforms/InstMerge
Djordje Todorovic 2cdc6f2ca6 Reland "[LICM] Hoist LOAD without sinking the STORE"
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].

[0] https://bugs.llvm.org/show_bug.cgi?id=51193

Differential revision: https://reviews.llvm.org/D113289
2021-12-02 03:53:50 -08:00
..
exceptions.ll
st_sink_barrier_call.ll
st_sink_bugfix_22613.ll Reland "[LICM] Hoist LOAD without sinking the STORE" 2021-12-02 03:53:50 -08:00
st_sink_check_debug.ll
st_sink_debuginvariant.ll
st_sink_no_barrier_call.ll
st_sink_no_barrier_load.ll
st_sink_no_barrier_store.ll
st_sink_split_bb.ll
st_sink_two_stores.ll
st_sink_with_barrier.ll