Closed
Description
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.
Activity
llvmbot commentedon Jul 2, 2024
@llvm/issue-subscribers-backend-risc-v
Author: None (Yunzezhu94)
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.
[RISCV] Add a check in lowerSELECT after foldBinOpIntoSelectIfProfita…
[RISCV] Add a check in lowerSELECT after foldBinOpIntoSelectIfProfita…