<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/97390>97390</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[RISCV] Node returned by foldBinOpIntoSelectIfProfitable reports error in lowerSELECT
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
Yunzezhu94
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
Yunzezhu94
</td>
</tr>
</table>
<pre>
Here is a simple reduced case:
`int a = (a ? 4 : 8) / (8 ? -5141143369814759789L : 0);`
When compiling this case with order
`clang++ -std=c++11 -march=rv64imafdc -mabi=lp64d -w -O0 -o a.o -c a.cpp`
It reports error: llvm-project/llvm/include/llvm/CodeGen/SelectionDAGNodes.h:960: const llvm::SDValue& llvm::SDNode::getOperand(unsigned int) const: Assertion `Num < NumOperands && "Invalid child # of SDNode!"' failed.
It is because for certain cases foldBinOpIntoSelectIfProfitable may return a constant node when trueVal and falseVal of the select inst have the same value, at this time in following lowerSELECT it reports error that operands cannot be get from a constant node.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyEVMFu4zYQ_ZrxZWBDImXaOujg2OutgUVSNEWKHilyZLGgSIGkbGS_vqDk3XRz6Y3zJL55evNGMkZzdUQNbJ-Asb8n952-91NdAWOwPa3klHofmg981Xr93vxGgdBElBjNMFrCQHpSpFHJSMAPUJygOIAojEsoEfgJge3z4YwVAj_gHliNwM4Z38_4eltWZVlxLup9We229W5ff5vfLYDVwJ9AFAvvXz05VH4YjTXuiqk3cW6Md5N69EFTwJ8KlJXuCuwJ2BPiOiYN_KSWuixxPcigeuCncBOVGWSnVcZaA_xkR1FpXN9x_VLg2qPceFwrlBs1jj-1XBIGGn1IESkEH7Jea2_Degz-H1IJ2DmXwM7GKTtp-gCOXtNXcsDOr2RJJePd6fD12WuKmx74oRZFZlPexTRzZmP54fX0Ju1EwMQvYL63nK-UXkYK0mlg-8nNA9ZoXMqWz2yZ9hAjhdwTQRTP04DAj_g8DY-rEYGJ3AMYu7ibtEaj6o3VCIyj7_DRkZU5KWyHnTSW9Obh-w9vTMSWlJwiYecDKgpJGjdPK2LnrX4y7mW8uOQXDy7d78F3JsnWEg7yHQOlKTiUi3DpEjqvCe85AilM9CYtSqexkzbOhe8w9YRxpkOTvevljRZQDoS3xb0jyrREJ5mB0Lgsx_p7TpT1dwqvX759Of6J5tOAMfUyof_hkpLO-YQt4ZUSdsEPn7VuVrrhuua1XFFT7sq6LiohxKpvdK3aTrWiq_eq1qXSqhRlK4TY61Kqkq9MwwpWFbuCFbtyV4lNrYn4tt1ywfS-VS1UBQ3S2E1OwsaH68rEOFFT73hdrKxsycbHaju64_zwsdmhmWPaTtcIVWFNTPGDJZlk53_CH5fX4xtsT5iH_RgGaWzf_3d4v5pm3H9NXU3BNn1KY8yJZWdg56tJ_dRulB8-FuTTHs3qI7Dz8nW3hv0bAAD__wvShMc">