<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/94323>94323</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[ValueTracking] Assertion `(Known.Zero & Known.One) == 0 && "Bits known to be one AND zero?"' failed.
</td>
</tr>
<tr>
<th>Labels</th>
<td>
crash-on-valid,
llvm:analysis
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
dtcxzyw
</td>
</tr>
</table>
<pre>
Reproducer: https://godbolt.org/z/811cs5jK7
```
; opt -passes=inline test.ll -S
define i32 @func_131() {
entry:
br label %common.ret
common.ret: ; preds = %if.then309, %entry
ret i32 0
if.then309: ; No predecessors!
%0 = call range(i8 5, 6) i8 @llvm.ctpop.i8(i8 0)
%call444 = call i8 @safe_rshift_func_int8_t_s_u(i8 %0)
br label %common.ret
}
define i8 @safe_rshift_func_int8_t_s_u(i8 %left) {
entry:
%left. = tail call i8 @llvm.smin.i8(i8 %left, i8 0)
ret i8 0
}
```
```
opt: /root/llvm-project/llvm/lib/Analysis/ValueTracking.cpp:2059: void computeKnownBits(const llvm::Value*, const llvm::APInt&, llvm::KnownBits&, unsigned int, const llvm::SimplifyQuery&): Assertion `(Known.Zero & Known.One) == 0 && "Bits known to be one AND zero?"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0. Program arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/opt -o /app/output.s -S -passes=inline <source>
#0 0x0000000004e08988 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4e08988)
#1 0x0000000004e060dc SignalHandler(int) Signals.cpp:0:0
#2 0x00007abb18842520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#3 0x00007abb188969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
#4 0x00007abb18842476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
#5 0x00007abb188287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
#6 0x00007abb1882871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
#7 0x00007abb18839e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#8 0x00000000045bad0b computeKnownBits(llvm::Value const*, llvm::APInt const&, llvm::KnownBits&, unsigned int, llvm::SimplifyQuery const&) ValueTracking.cpp:0:0
#9 0x00000000045baeee llvm::computeKnownBits(llvm::Value const*, llvm::KnownBits&, unsigned int, llvm::SimplifyQuery const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x45baeee)
#10 0x00000000045bafc6 llvm::computeKnownBits(llvm::Value const*, unsigned int, llvm::SimplifyQuery const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x45bafc6)
#11 0x00000000043b5544 simplifyICmpInst(unsigned int, llvm::Value*, llvm::Value*, llvm::SimplifyQuery const&, unsigned int) InstructionSimplify.cpp:0:0
#12 0x00000000043b7139 isICmpTrue(llvm::CmpInst::Predicate, llvm::Value*, llvm::Value*, llvm::SimplifyQuery const&, unsigned int) InstructionSimplify.cpp:0:0
#13 0x00000000043bce34 llvm::simplifyBinaryIntrinsic(unsigned int, llvm::Type*, llvm::Value*, llvm::Value*, llvm::SimplifyQuery const&, llvm::CallBase const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x43bce34)
#14 0x00000000043be108 simplifyIntrinsic(llvm::CallBase*, llvm::Value*, llvm::ArrayRef<llvm::Value*>, llvm::SimplifyQuery const&) InstructionSimplify.cpp:0:0
#15 0x00000000043bf104 llvm::simplifyCall(llvm::CallBase*, llvm::Value*, llvm::ArrayRef<llvm::Value*>, llvm::SimplifyQuery const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x43bf104)
#16 0x00000000043b2742 simplifyInstructionWithOperands(llvm::Instruction*, llvm::ArrayRef<llvm::Value*>, llvm::SimplifyQuery const&, unsigned int) InstructionSimplify.cpp:0:0
#17 0x00000000043c2b1b llvm::simplifyInstruction(llvm::Instruction*, llvm::SimplifyQuery const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x43c2b1b)
#18 0x00000000040508ed llvm::CloneAndPruneIntoFromInst(llvm::Function*, llvm::Function const*, llvm::Instruction const*, llvm::ValueMap<llvm::Value const*, llvm::WeakTrackingVH, llvm::ValueMapConfig<llvm::Value const*, llvm::sys::SmartMutex<false>>>&, bool, llvm::SmallVectorImpl<llvm::ReturnInst*>&, char const*, llvm::ClonedCodeInfo*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x40508ed)
#19 0x0000000004051775 llvm::CloneAndPruneFunctionInto(llvm::Function*, llvm::Function const*, llvm::ValueMap<llvm::Value const*, llvm::WeakTrackingVH, llvm::ValueMapConfig<llvm::Value const*, llvm::sys::SmartMutex<false>>>&, bool, llvm::SmallVectorImpl<llvm::ReturnInst*>&, char const*, llvm::ClonedCodeInfo*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4051775)
#20 0x00000000040bf675 llvm::InlineFunction(llvm::CallBase&, llvm::InlineFunctionInfo&, bool, llvm::AAResults*, bool, llvm::Function*) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x40bf675)
#21 0x00000000036e6044 llvm::InlinerPass::run(llvm::LazyCallGraph::SCC&, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>&, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x36e6044)
#22 0x0000000002e0f61e llvm::detail::PassModel<llvm::LazyCallGraph::SCC, llvm::InlinerPass, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&>::run(llvm::LazyCallGraph::SCC&, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>&, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x2e0f61e)
#23 0x00000000042b081b llvm::PassManager<llvm::LazyCallGraph::SCC, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&>::run(llvm::LazyCallGraph::SCC&, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>&, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x42b081b)
#24 0x0000000002e0e44e llvm::detail::PassModel<llvm::LazyCallGraph::SCC, llvm::PassManager<llvm::LazyCallGraph::SCC, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&>, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&>::run(llvm::LazyCallGraph::SCC&, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>&, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x2e0e44e)
#25 0x00000000042b2569 llvm::ModuleToPostOrderCGSCCPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x42b2569)
#26 0x0000000002e0e42e llvm::detail::PassModel<llvm::Module, llvm::ModuleToPostOrderCGSCCPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x2e0e42e)
#27 0x0000000004c0d73c llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x4c0d73c)
#28 0x00000000008d51f2 llvm::runPassPipeline(llvm::StringRef, llvm::Module&, llvm::TargetMachine*, llvm::TargetLibraryInfoImpl*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::ToolOutputFile*, llvm::StringRef, llvm::ArrayRef<llvm::PassPlugin>, llvm::ArrayRef<std::function<void (llvm::PassBuilder&)>>, llvm::opt_tool::OutputKind, llvm::opt_tool::VerifierKind, bool, bool, bool, bool, bool, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8d51f2)
#29 0x00000000008c842c optMain (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8c842c)
#30 0x00007abb18829d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#31 0x00007abb18829e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#32 0x00000000008bf87e _start (/opt/compiler-explorer/clang-assertions-trunk/bin/opt+0x8bf87e)
Program terminated with signal: SIGSEGV
Compiler returned: 139
```
cc @nikic
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsWlFzm7ga_TXKi8YeLAGGhzwQJ-5m2mxzm97uzH3xCBC2NrLESKJN-uvvSGAbYTs3br293Z1mspsC0tF3znf0IUBEa7YUlF6C6ApE1xekMSupLktTPH19_nKRy_L58gOtlSybgiqAM7gyptYAZwDNAZovZZlLbsZSLQGafwVonkwmhY7-fDsFwTUIMhAH3W97iK-grA0c1URrqgG-ZoIzQaGh2ow5h6OHtmFJK3uaYQRBGFSNKBYTPAEoASiFYHrVtqLCqGcbjDuCMFeQk5xyCFBUyPVairGiphva_b93FmfwdT826FrRUkOAry00q8ZmRQUOUoBm9kQbRxeEosbFHfTH7XXBmUP8XTpQWlCtpdIATTYAAEWBG6ognENFxJIClLAERna42CrAEisL55_X48LUsh6zpG0SAJT2cCxCGIY7tLajJhVdKL1ilVk4bZkwycIs9KJpYWwIPaQXdZ1e94luEvfqcTitz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