[PATCH] D113656: [LICM] Check a heuristic case to hoist load
JinGu Kang via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 11 02:01:21 PST 2021
jaykang10 created this revision.
jaykang10 added reviewers: efriedma, nikic, mkazantsev, reames.
Herald added subscribers: jeroen.dobbelaere, asbirlea, george.burgess.iv, kosarev, hiraditya.
jaykang10 requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Let's see an example with MemorySSA.
loop.header:
; 2 = MemoryPhi({entry,liveOnEntry},{loop.body,1})
%i.0 = phi i32 [ 0, %entry ], [ %inc, %loop.body ]
...
loop.body:
; MemoryUse(2) MayAlias
%0 = load i32**, i32*** @a, align 8, !tbaa !8
%idxprom = zext i32 %i.0 to i64
%arrayidx = getelementptr inbounds i32*, i32** %0, i64 %idxprom
; 1 = MemoryDef(2)
store i32* null, i32** %arrayidx, align 8, !tbaa !8
...
As you can see, there is a dependence with MayAlias between `%0 = load` of MemoryUse(2) and `store` of `1 = MemoryDef(2)`. However, it is WAR dependence at first iteration of the loop and there is no dependence at rest of iteration. In this case, we can hoist the '%0 = load` to preheader.
It fixes https://bugs.llvm.org/show_bug.cgi?id=52143.
https://reviews.llvm.org/D113656
Files:
llvm/include/llvm/Transforms/Utils/LoopUtils.h
llvm/lib/Transforms/Scalar/LICM.cpp
llvm/test/Transforms/LICM/heuristic-hoist-load.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D113656.386451.patch
Type: text/x-patch
Size: 8272 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211111/315d7158/attachment.bin>
More information about the llvm-commits
mailing list