Skip to content

Commit cc5b086

Browse files
committed
Revert "[RISCV] Special case sign extended scalars when type legalizing nxvXi64 .vx instrinsics on RV32."
This reverts commit 8c4937b. Committed by mistake.
1 parent 8c31b68 commit cc5b086

File tree

2 files changed

+5
-46
lines changed

2 files changed

+5
-46
lines changed

llvm/lib/Target/RISCV/RISCVISelLowering.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4623,9 +4623,11 @@ static SDValue lowerVectorIntrinsicScalars(SDValue Op, SelectionDAG &DAG,
46234623

46244624
// If this is a sign-extended 32-bit constant, we can truncate it and rely
46254625
// on the instruction to sign-extend since SEW>XLEN.
4626-
if (DAG.ComputeNumSignBits(ScalarOp) > 32) {
4627-
ScalarOp = DAG.getNode(ISD::TRUNCATE, DL, MVT::i32, ScalarOp);
4628-
return DAG.getNode(Op->getOpcode(), DL, Op->getVTList(), Operands);
4626+
if (auto *CVal = dyn_cast<ConstantSDNode>(ScalarOp)) {
4627+
if (isInt<32>(CVal->getSExtValue())) {
4628+
ScalarOp = DAG.getConstant(CVal->getSExtValue(), DL, MVT::i32);
4629+
return DAG.getNode(Op->getOpcode(), DL, Op->getVTList(), Operands);
4630+
}
46294631
}
46304632

46314633
switch (IntNo) {

llvm/test/CodeGen/RISCV/rvv/vadd.ll

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1881,49 +1881,6 @@ entry:
18811881
ret <vscale x 1 x i64> %a
18821882
}
18831883

1884-
define <vscale x 1 x i64> @intrinsic_vadd_vx_sext_nxv1i64_nxv1i64_i64(<vscale x 1 x i64> %0, i32 %1, iXLen %2) nounwind {
1885-
; RV32-LABEL: intrinsic_vadd_vx_sext_nxv1i64_nxv1i64_i64:
1886-
; RV32: # %bb.0: # %entry
1887-
; RV32-NEXT: vsetvli zero, a1, e64, m1, ta, mu
1888-
; RV32-NEXT: vadd.vx v8, v8, a0
1889-
; RV32-NEXT: ret
1890-
;
1891-
; RV64-LABEL: intrinsic_vadd_vx_sext_nxv1i64_nxv1i64_i64:
1892-
; RV64: # %bb.0: # %entry
1893-
; RV64-NEXT: sext.w a0, a0
1894-
; RV64-NEXT: vsetvli zero, a1, e64, m1, ta, mu
1895-
; RV64-NEXT: vadd.vx v8, v8, a0
1896-
; RV64-NEXT: ret
1897-
entry:
1898-
%ext = sext i32 %1 to i64
1899-
%a = call <vscale x 1 x i64> @llvm.riscv.vadd.nxv1i64.i64(
1900-
<vscale x 1 x i64> undef,
1901-
<vscale x 1 x i64> %0,
1902-
i64 %ext,
1903-
iXLen %2)
1904-
1905-
ret <vscale x 1 x i64> %a
1906-
}
1907-
1908-
define <vscale x 1 x i64> @intrinsic_vadd_vx_sextload_nxv1i64_nxv1i64_i64(<vscale x 1 x i64> %0, i32* %1, iXLen %2) nounwind {
1909-
; CHECK-LABEL: intrinsic_vadd_vx_sextload_nxv1i64_nxv1i64_i64:
1910-
; CHECK: # %bb.0: # %entry
1911-
; CHECK-NEXT: lw a0, 0(a0)
1912-
; CHECK-NEXT: vsetvli zero, a1, e64, m1, ta, mu
1913-
; CHECK-NEXT: vadd.vx v8, v8, a0
1914-
; CHECK-NEXT: ret
1915-
entry:
1916-
%load = load i32, i32* %1
1917-
%ext = sext i32 %load to i64
1918-
%a = call <vscale x 1 x i64> @llvm.riscv.vadd.nxv1i64.i64(
1919-
<vscale x 1 x i64> undef,
1920-
<vscale x 1 x i64> %0,
1921-
i64 %ext,
1922-
iXLen %2)
1923-
1924-
ret <vscale x 1 x i64> %a
1925-
}
1926-
19271884
declare <vscale x 1 x i64> @llvm.riscv.vadd.mask.nxv1i64.i64(
19281885
<vscale x 1 x i64>,
19291886
<vscale x 1 x i64>,

0 commit comments

Comments
 (0)