[PATCH] D28241: [LICM] Untangle some of the logic in LICM canSinkOrHoistInst
Xin Tong via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 3 09:55:07 PST 2017
trentxintong created this revision.
trentxintong added reviewers: davidxl, mkuper, danielcdh, hfinkel.
trentxintong added a subscriber: llvm-commits.
Herald added a subscriber: mzolotukhin.
canSinkOrHoistInst only checks whether its legal to sink or hoist, it does not
check whether its safe to do so, a load can be legally hoisted to the loop PH
if there is no writes in the loop and its operands are loop invariant, but it may
not be safe to do as it may fault on execution.
The untangled logic is as follow:
In licm, When we hoist or sink, we check for
- whether the instruction have invariant operands.
- whether the load/call can be invalidated by writes in the loop, by canSinkOrHoistInst.
- whether the load/call is safe to speculate in the preheader, by isSafeToExecuteUnconditionally.
In loop sink, we check.
- whether instruction operands are loop invariant.
- whether the load/call can be invalidated by writes in the loop as we are sinking into the loop
body, its always safe to execute.
https://reviews.llvm.org/D28241
Files:
include/llvm/Transforms/Utils/LoopUtils.h
lib/Transforms/Scalar/LICM.cpp
lib/Transforms/Scalar/LoopSink.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D28241.82907.patch
Type: text/x-patch
Size: 5884 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170103/3a56a184/attachment.bin>
More information about the llvm-commits
mailing list