[llvm-bugs] [Bug 43879] New: InstCombine incorrectly optimizes `select`s with conditionally undef values
via llvm-bugs
llvm-bugs at lists.llvm.org
Fri Nov 1 13:07:01 PDT 2019
https://bugs.llvm.org/show_bug.cgi?id=43879
Bug ID: 43879
Summary: InstCombine incorrectly optimizes `select`s with
conditionally undef values
Product: libraries
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: Scalar Optimizations
Assignee: unassignedbugs at nondot.org
Reporter: george.burgess.iv at gmail.com
CC: llvm-bugs at lists.llvm.org
Found while trying to bootstrap clang-tidy.
The intent of the repro is to call @bar() once and return false if `%B` is
true. Otherwise, it should loop calling @bar() forever. (The non-reduced code
isn't an infloop, but the infloop doesn't appear to make a difference here)
[ub] ~/l/t/gbiv_repro [ 20ms ] ((6082a062…)) ~> git rev-parse HEAD
6082a062a76d0bc9c9c641f5600569bafdf4c338
[ub] ~/l/t/gbiv_repro [ 5ms ] ((6082a062…)) ~> cat repro.ll
declare void @bar()
define dso_local i1 @_Z3foob(i1 zeroext %B) local_unnamed_addr #0 {
entry:
br label %loop
loop:
%x = phi i1 [ undef, %entry ], [ %foo, %loop.end ]
call void @bar()
br label %loop.end
loop.end:
%foo = select i1 %B, i1 false, i1 %x
br i1 %B, label %return, label %loop
return:
ret i1 %foo
}
[ub] ~/l/t/gbiv_repro [ 2ms ] ((6082a062…)) ~> ../build/release/bin/opt
-instcombine < repro.ll -S
; ModuleID = '<stdin>'
source_filename = "<stdin>"
declare void @bar()
define dso_local i1 @_Z3foob(i1 zeroext %B) local_unnamed_addr {
entry:
br label %loop
loop: ; preds = %loop.end, %entry
call void @bar()
br label %loop.end
loop.end: ; preds = %loop
br i1 %B, label %return, label %loop
return: ; preds = %loop.end
ret i1 undef
}
AIUI, select should block undef from entering the program if %B is true, so the
`ret i1 undef` shouldn't be possible.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20191101/5bdeb2f0/attachment.html>
More information about the llvm-bugs
mailing list