<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/90652>90652</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[RISCV] Assertion `LHS.getValueType() == VT && RHS.getValueType() == VT && "Cannot use select on differing types"' failed.
</td>
</tr>
<tr>
<th>Labels</th>
<td>
backend:RISC-V,
crash
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
dtcxzyw
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
dtcxzyw
</td>
</tr>
</table>
<pre>
Reduced test case: https://godbolt.org/z/ToPME8sW1
```
define i1 @test(i64 %x, i1 %cond1, i1 %cond2) {
entry:
%sadd = call { i64, i1 } @llvm.sadd.with.overflow.i64(i64 %x, i64 1)
%ov = extractvalue { i64, i1 } %sadd, 1
%or = or i1 %cond2, %ov
%sel = select i1 %cond1, i1 %cond2, i1 %or
ret i1 %sel
}
```
```
llc: /root/llvm-project/llvm/include/llvm/CodeGen/SelectionDAG.h:1239: llvm::SDValue llvm::SelectionDAG::getSelect(const llvm::SDLoc&, llvm::EVT, llvm::SDValue, llvm::SDValue, llvm::SDValue): Assertion `LHS.getValueType() == VT && RHS.getValueType() == VT && "Cannot use select on differing types"' 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/llc -o /app/output.s -x86-asm-syntax=intel -mtriple=riscv64 <source>
1. Running pass 'Function Pass Manager' on module '<source>'.
2. Running pass 'RISC-V DAG->DAG Pattern Instruction Selection' on function '@test'
#0 0x000000000395b768 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x395b768)
#1 0x0000000003958ebc SignalHandler(int) Signals.cpp:0:0
#2 0x000079ecb9e42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#3 0x000079ecb9e969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
#4 0x000079ecb9e42476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
#5 0x000079ecb9e287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
#6 0x000079ecb9e2871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
#7 0x000079ecb9e39e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#8 0x0000000000bd692f llvm::SelectionDAG::getSelect(llvm::SDLoc const&, llvm::EVT, llvm::SDValue, llvm::SDValue, llvm::SDValue) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0xbd692f)
#9 0x0000000001ab4ab6 tryFoldSelectIntoOp(llvm::SDNode*, llvm::SelectionDAG&, llvm::SDValue, llvm::SDValue, bool) RISCVISelLowering.cpp:0:0
#10 0x0000000001b125a6 llvm::RISCVTargetLowering::PerformDAGCombine(llvm::SDNode*, llvm::TargetLowering::DAGCombinerInfo&) const (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x1b125a6)
#11 0x00000000035cdb7d (anonymous namespace)::DAGCombiner::combine(llvm::SDNode*) DAGCombiner.cpp:0:0
#12 0x00000000035cf48c (anonymous namespace)::DAGCombiner::Run(llvm::CombineLevel) DAGCombiner.cpp:0:0
#13 0x00000000035d1a6a llvm::SelectionDAG::Combine(llvm::CombineLevel, llvm::AAResults*, llvm::CodeGenOptLevel) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x35d1a6a)
#14 0x00000000037273d2 llvm::SelectionDAGISel::CodeGenAndEmitDAG() (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x37273d2)
#15 0x000000000372af15 llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x372af15)
#16 0x000000000372c987 llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (.part.0) SelectionDAGISel.cpp:0:0
#17 0x0000000002976b71 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (.part.0) MachineFunctionPass.cpp:0:0
#18 0x0000000002f36633 llvm::FPPassManager::runOnFunction(llvm::Function&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x2f36633)
#19 0x0000000002f36871 llvm::FPPassManager::runOnModule(llvm::Module&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x2f36871)
#20 0x0000000002f370d5 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x2f370d5)
#21 0x000000000082aa5c compileModule(char**, llvm::LLVMContext&) llc.cpp:0:0
#22 0x0000000000728f26 main (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x728f26)
#23 0x000079ecb9e29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#24 0x000079ecb9e29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#25 0x000000000082157e _start (/opt/compiler-explorer/clang-assertions-trunk/bin/llc+0x82157e)
Program terminated with signal: SIGSEGV
Compiler returned: 139
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzMWF1P6zwS_jXmxmqVON8XvSgt5UWCPYgi9hI5jtt6cezIdqA9v35lJ6Vx6DkHdtnVi0AiE88zzzMz_oix1mwrKJ2B5BIgVBmy_3l4AwiBZHmBW7OTatYbL0pZHWYPtGoJraCh2kCCNQXRHO6MaTSI5gCtAFptZVVKbqZSbQFa_QRo9Sjv765y_c8QBEsQzEEa9L_usaIbJihkIQRxYHEBylkaQ4CSPUAL9wIlRIoq9B8RQAUE2WUHQ4VRB0vCPUE7SOOqgiBaQoI5tyMhS-MjRra08Th_rad23PSNmd1UvlK14fJt6gb6NNIYhgAVA3z56tDp3ihMzCvmLT0XpSNiLeHQWTlnqXxFiw54qIJyN1JTTon5bTqOj1Id_RU9emjK-_Rny7N1GD1yTmxtAVopKQ1AK5uqSaPkvyg5PgK0YoLwtqInw0JW9JoKgFZrR5hJsZxfT3cgmocoKiym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