[PATCH] D122913: [InstCombine] Simplify PHI node whose type and type of its cond differ
Hirochika Matsumoto via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 1 08:43:17 PDT 2022
hkmatsumoto created this revision.
hkmatsumoto added a reviewer: nikic.
Herald added a subscriber: hiraditya.
Herald added a project: All.
hkmatsumoto requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Currently LLVM optimizes the code below:
llvm
define i8 @foo(i8 %cond) {
entry:
switch i8 %cond, label %default [
i8 -1, label %sw.-1
i8 0, label %sw.0
i8 1, label %sw.1
]
default:
unreachable
sw.-1:
br label %merge
sw.0:
br label %merge
sw.1:
br label %merge
merge:
%ret = phi i8 [ 1, %sw.1 ], [ 0, %sw.0 ], [ -1, %sw.-1 ]
ret i8 %ret
}
to:
llvm
define i8 @foo(i8 %cond) {
ret i8 %cond
}
But once we make @foo return larger types, say i32 it no longer
optimizes. This patch covers such cases.
Fixes https://github.com/llvm/llvm-project/issues/54561
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D122913
Files:
llvm/lib/Transforms/InstCombine/InstCombinePHI.cpp
llvm/test/Transforms/InstCombine/pr54561.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D122913.419773.patch
Type: text/x-patch
Size: 8789 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220401/b6232db0/attachment.bin>
More information about the llvm-commits
mailing list