[PATCH] D135354: [LoopPredication] Insert assumes of conditions of predicated guards
Dmitry Makogon via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 6 03:53:28 PDT 2022
dmakogon created this revision.
dmakogon added reviewers: mkazantsev, nikic, fhahn, chandlerc.
Herald added a subscriber: hiraditya.
Herald added a project: All.
dmakogon requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
As LoopPredication performs non-equivalent transforms removing some checks from loops, other passes may not be able to perform transforms they'd be able to do if the checks were left in loops.
For example, LoopPredication may turn a range check expressed via widenable condition like this
loop:
%iv.1 = phi i32 [ %iv.1.start, %entry ], [ %iv.1.next, %latch ]
%cond.1 = icmp ult i32 %iv.1, %iv.1.end
%wc = call i1 @llvm.experimental.widenable.condition()
%explicit_guard_cond = and i1 %cond.1, %wc
br i1 %explicit_guard_cond, label %loop.next, label %deopt
into an invariant check above loop.
Other passes may not be able to figure the fact that the new condition implies the old one, so such branch in %loop.next block:
loop.next:
br i1 %cond.1, label %if.true, label %if.false
wouldn't get optimized.
This patch makes LoopPredication insert assumes of the replaced conditions either after a guard call or in the true block of widenable condition branch.
https://reviews.llvm.org/D135354
Files:
llvm/lib/Transforms/Scalar/LoopPredication.cpp
llvm/test/Transforms/LoopPredication/assumes.ll
llvm/test/Transforms/LoopPredication/basic.ll
llvm/test/Transforms/LoopPredication/basic_widenable_branch_guards.ll
llvm/test/Transforms/LoopPredication/invariant_load.ll
llvm/test/Transforms/LoopPredication/nested.ll
llvm/test/Transforms/LoopPredication/profitability.ll
llvm/test/Transforms/LoopPredication/reverse.ll
llvm/test/Transforms/LoopPredication/visited.ll
llvm/test/Transforms/LoopPredication/widened.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D135354.465691.patch
Type: text/x-patch
Size: 74006 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221006/642b1c1d/attachment-0001.bin>
More information about the llvm-commits
mailing list