Skip to content

Commit 0d7ee52

Browse files
authored
[RISCV] Use getSignedConstant for negative values. (#125903)
The APInt constructor asserts if bits are set past the size of the APInt unless it is signed. This currently fails on RV32 because more than XLen bits are set.
1 parent de7be32 commit 0d7ee52

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

llvm/lib/Target/RISCV/RISCVISelLowering.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16353,7 +16353,7 @@ static SDValue performVP_REVERSECombine(SDNode *N, SelectionDAG &DAG,
1635316353
SDValue Temp2 = DAG.getNode(ISD::MUL, DL, XLenVT, Temp1,
1635416354
DAG.getConstant(ElemWidthByte, DL, XLenVT));
1635516355
SDValue Base = DAG.getNode(ISD::ADD, DL, XLenVT, VPLoad->getBasePtr(), Temp2);
16356-
SDValue Stride = DAG.getConstant(-ElemWidthByte, DL, XLenVT);
16356+
SDValue Stride = DAG.getSignedConstant(-ElemWidthByte, DL, XLenVT);
1635716357

1635816358
MachineFunction &MF = DAG.getMachineFunction();
1635916359
MachinePointerInfo PtrInfo(VPLoad->getAddressSpace());
@@ -16414,7 +16414,7 @@ static SDValue performVP_STORECombine(SDNode *N, SelectionDAG &DAG,
1641416414
DAG.getConstant(ElemWidthByte, DL, XLenVT));
1641516415
SDValue Base =
1641616416
DAG.getNode(ISD::ADD, DL, XLenVT, VPStore->getBasePtr(), Temp2);
16417-
SDValue Stride = DAG.getConstant(-ElemWidthByte, DL, XLenVT);
16417+
SDValue Stride = DAG.getSignedConstant(-ElemWidthByte, DL, XLenVT);
1641816418

1641916419
MachineFunction &MF = DAG.getMachineFunction();
1642016420
MachinePointerInfo PtrInfo(VPStore->getAddressSpace());

llvm/test/CodeGen/RISCV/rvv/vp-combine-reverse-load.ll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2+
; RUN: llc -mtriple=riscv32 -mattr=+f,+v -verify-machineinstrs < %s | FileCheck %s
23
; RUN: llc -mtriple=riscv64 -mattr=+f,+v -verify-machineinstrs < %s | FileCheck %s
34

45
define <vscale x 2 x float> @test_reverse_load_combiner(<vscale x 2 x float>* %ptr, i32 zeroext %evl) {

llvm/test/CodeGen/RISCV/rvv/vp-combine-store-reverse.ll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2+
; RUN: llc -mtriple=riscv32 -mattr=+f,+v -verify-machineinstrs < %s | FileCheck %s
23
; RUN: llc -mtriple=riscv64 -mattr=+f,+v -verify-machineinstrs < %s | FileCheck %s
34

45
define void @test_store_reverse_combiner(<vscale x 2 x float> %val, <vscale x 2 x float>* %ptr, i32 zeroext %evl) {

0 commit comments

Comments
 (0)