[PATCH] D77808: [SCCP] Use conditional info with AND/OR branch conditions.
Florian Hahn via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 9 08:46:17 PDT 2020
fhahn created this revision.
fhahn added reviewers: efriedma, davide, mssimpso.
Herald added a subscriber: hiraditya.
Herald added a project: LLVM.
Currently SCCP does not combine the information of conditions joined by
AND in the true branch or OR in the false branch.
For branches on AND, 2 copies will be inserted for the true branch, with
one being the operand of the other as in the code below. We can combine
the information using intersection. Note that for the OR case, the
copies are inserted in the false branch, where using intersection is
safe as well.
define void @foo(i32 %a) {
entry:
%lt = icmp ult i32 %a, 100
%gt = icmp ugt i32 %a, 20
%and = and i1 %lt, %gt
; Has predicate info
; branch predicate info { TrueEdge: 1 Comparison: %lt = icmp ult i32 %a, 100 Edge: [label %entry,label %true] }
%a.0 = call i32 @llvm.ssa.copy.140247425954880(i32 %a)
; Has predicate info
; branch predicate info { TrueEdge: 0 Comparison: %lt = icmp ult i32 %a, 100 Edge: [label %entry,label %false] }
%a.1 = call i32 @llvm.ssa.copy.140247425954880(i32 %a)
br i1 %lt, label %true, label %false
true: ; preds = %entry
call void @use(i32 %a.0)
%true.1 = icmp ne i32 %a.0, 20
call void @use.i1(i1 %true.1)
ret void
false: ; preds = %entry
call void @use(i32 %a.1)
ret void
}
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D77808
Files:
llvm/lib/Transforms/Scalar/SCCP.cpp
llvm/test/Transforms/SCCP/conditions-ranges.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D77808.256320.patch
Type: text/x-patch
Size: 4632 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200409/6c5cee1a/attachment.bin>
More information about the llvm-commits
mailing list