[PATCH] D39011: [SimplifyCFG] try harder to forward switch condition to phi (PR34471)
Daniel Berlin via llvm-commits
llvm-commits at lists.llvm.org
Sun Oct 22 10:08:17 PDT 2017
result of opt -gvn on pr34471.ll:
; ModuleID = 'foo.ll'
source_filename = "foo.ll"
define i32 @PR34471(i32 %x) {
entry:
switch i32 %x, label %else3 [
i32 17, label %return
i32 19, label %if19
i32 42, label %if42
]
if19: ; preds = %entry
br label %return
if42: ; preds = %entry
br label %return
else3: ; preds = %entry
br label %return
return: ; preds = %else3, %if42,
%if19, %entry
%r = phi i32 [ 19, %if19 ], [ 42, %if42 ], [ 0, %else3 ], [ 17, %entry ]
ret i32 %r
}
-correlated-propagation gives the same answer, as do -newgvn and a few
other passes.
On Sun, Oct 22, 2017 at 10:06 AM, Daniel Berlin via Phabricator <
reviews at reviews.llvm.org> wrote:
> dberlin added a comment.
>
> Hey Sanjay,
> GVN/NewGVN/et al will undo this transform, and propagate constants. In
> fact, i expect pretty much any pass that can, will.
>
> This definitely belongs in the late simplification category at best.
>
> More than that, i'm concerned this is the wrong fix.
>
> Why is the right answer to undo the transform (which will cause fights
> between passes) in simplifycfg instead of improving the codegen to
> recognize the issue?
>
> It seems the same code you are using to detect and undo the transforrm in
> simplification could be used to codegen it better.
>
>
> Repository:
> rL LLVM
>
> https://reviews.llvm.org/D39011
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171022/125f6233/attachment.html>
More information about the llvm-commits
mailing list