Skip to content

Commit 20b9ed6

Browse files
dtcxzywtstellar
authored andcommitted
[RISCV][ISel] Fix types in tryFoldSelectIntoOp (#90659)
``` SelectionDAG has 17 nodes: t0: ch,glue = EntryToken t6: i64,ch = CopyFromReg t0, Register:i64 %2 t8: i1 = truncate t6 t4: i64,ch = CopyFromReg t0, Register:i64 %1 t7: i1 = truncate t4 t2: i64,ch = CopyFromReg t0, Register:i64 %0 t10: i64,i1 = saddo t2, Constant:i64<1> t11: i1 = or t8, t10:1 t12: i1 = select t7, t8, t11 t13: i64 = any_extend t12 t15: ch,glue = CopyToReg t0, Register:i64 $x10, t13 t16: ch = RISCVISD::RET_GLUE t15, Register:i64 $x10, t15:1 ``` `OtherOpVT` should be i1, but `OtherOp->getValueType(0)` returns `i64`, which ignores `ResNo` in `SDValue`. Fix #90652. (cherry picked from commit 2647bd7)
1 parent ece9d35 commit 20b9ed6

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

llvm/lib/Target/RISCV/RISCVISelLowering.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -14559,7 +14559,7 @@ static SDValue tryFoldSelectIntoOp(SDNode *N, SelectionDAG &DAG,
1455914559
EVT VT = N->getValueType(0);
1456014560
SDLoc DL(N);
1456114561
SDValue OtherOp = TrueVal.getOperand(1 - OpToFold);
14562-
EVT OtherOpVT = OtherOp->getValueType(0);
14562+
EVT OtherOpVT = OtherOp.getValueType();
1456314563
SDValue IdentityOperand =
1456414564
DAG.getNeutralElement(Opc, DL, OtherOpVT, N->getFlags());
1456514565
if (!Commutative)

llvm/test/CodeGen/RISCV/pr90652.ll

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 4
2+
; RUN: llc < %s -mtriple=riscv64 | FileCheck %s
3+
4+
define i1 @test(i64 %x, i1 %cond1, i1 %cond2) {
5+
; CHECK-LABEL: test:
6+
; CHECK: # %bb.0: # %entry
7+
; CHECK-NEXT: addi a3, a0, 1
8+
; CHECK-NEXT: slt a0, a3, a0
9+
; CHECK-NEXT: not a1, a1
10+
; CHECK-NEXT: and a0, a1, a0
11+
; CHECK-NEXT: or a0, a2, a0
12+
; CHECK-NEXT: ret
13+
entry:
14+
%sadd = call { i64, i1 } @llvm.sadd.with.overflow.i64(i64 %x, i64 1)
15+
%ov = extractvalue { i64, i1 } %sadd, 1
16+
%or = or i1 %cond2, %ov
17+
%sel = select i1 %cond1, i1 %cond2, i1 %or
18+
ret i1 %sel
19+
}

0 commit comments

Comments
 (0)