[PATCH] D139289: [SCCP] Propagate equality or inequality state of a not-constant
luxufan via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Dec 4 20:27:41 PST 2022
StephenFan created this revision.
Herald added a subscriber: hiraditya.
Herald added a project: All.
StephenFan requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
The equality or inequality state of a not-constant can also be used
to do constant propagation. For example,
define i32 @equal_not_constant(ptr noundef %p, ptr noundef %q) {
entry:
%cmp = icmp ne ptr %p, null
br i1 %cmp, label %if.then, label %if.end
if.then: ; preds = %entry
%cmp.then = icmp eq ptr %p, %q
br i1 %cmp.then, label %if.then1, label %if.end
if.then1: ; preds = %if.then
%cmp.then1 = icmp ne ptr %q, null
call void @use(i1 %cmp.then1)
br label %if.end
if.end:
ret i32 0
}
In this case, we can fold `%cmp.then1` as `true`.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D139289
Files:
llvm/lib/Transforms/Utils/SCCPSolver.cpp
llvm/test/Transforms/SCCP/conditions-ranges.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D139289.479970.patch
Type: text/x-patch
Size: 3756 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221205/98084998/attachment.bin>
More information about the llvm-commits
mailing list