[all-commits] [llvm/llvm-project] ecb9d8: [LICM] Hoist LOAD without sinking the STORE
Djordje Todorovic via All-commits
all-commits at lists.llvm.org
Wed Dec 1 04:28:43 PST 2021
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: ecb9d8e4e3c4623c2edcd2c50727103927d31508
https://github.com/llvm/llvm-project/commit/ecb9d8e4e3c4623c2edcd2c50727103927d31508
Author: Djordje Todorovic <djordje.todorovic at syrmia.com>
Date: 2021-12-01 (Wed, 01 Dec 2021)
Changed paths:
M llvm/include/llvm/Transforms/Utils/SSAUpdater.h
M llvm/lib/Transforms/Scalar/LICM.cpp
M llvm/lib/Transforms/Utils/SSAUpdater.cpp
M llvm/test/Transforms/InstMerge/st_sink_bugfix_22613.ll
A llvm/test/Transforms/LICM/hoist-load-without-store.ll
M llvm/test/Transforms/LICM/promote-capture.ll
M llvm/test/Transforms/LICM/scalar-promote-memmodel.ll
M llvm/test/Transforms/LICM/scalar-promote.ll
Log Message:
-----------
[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
More information about the All-commits
mailing list