Skip to content

[RISCV] Node returned by foldBinOpIntoSelectIfProfitable reports error in lowerSELECT #97390

Closed
@Yunzezhu94

Description

@Yunzezhu94
Contributor

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

self-assigned this
on Jul 2, 2024
llvmbot

llvmbot commented on Jul 2, 2024

@llvmbot
Member

@llvm/issue-subscribers-backend-risc-v

Author: None (Yunzezhu94)

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Participants

    @dtcxzyw@llvmbot@Yunzezhu94

    Issue actions

      [RISCV] Node returned by foldBinOpIntoSelectIfProfitable reports error in lowerSELECT · Issue #97390 · llvm/llvm-project