Skip to content

Commit c08c9f9

Browse files
topperctstellar
authored andcommitted
[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. (cherry picked from commit 0d7ee52)
1 parent 49a8fb2 commit c08c9f9

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
@@ -16297,7 +16297,7 @@ static SDValue performVP_REVERSECombine(SDNode *N, SelectionDAG &DAG,
1629716297
SDValue Temp2 = DAG.getNode(ISD::MUL, DL, XLenVT, Temp1,
1629816298
DAG.getConstant(ElemWidthByte, DL, XLenVT));
1629916299
SDValue Base = DAG.getNode(ISD::ADD, DL, XLenVT, VPLoad->getBasePtr(), Temp2);
16300-
SDValue Stride = DAG.getConstant(-ElemWidthByte, DL, XLenVT);
16300+
SDValue Stride = DAG.getSignedConstant(-ElemWidthByte, DL, XLenVT);
1630116301

1630216302
MachineFunction &MF = DAG.getMachineFunction();
1630316303
MachinePointerInfo PtrInfo(VPLoad->getAddressSpace());
@@ -16358,7 +16358,7 @@ static SDValue performVP_STORECombine(SDNode *N, SelectionDAG &DAG,
1635816358
DAG.getConstant(ElemWidthByte, DL, XLenVT));
1635916359
SDValue Base =
1636016360
DAG.getNode(ISD::ADD, DL, XLenVT, VPStore->getBasePtr(), Temp2);
16361-
SDValue Stride = DAG.getConstant(-ElemWidthByte, DL, XLenVT);
16361+
SDValue Stride = DAG.getSignedConstant(-ElemWidthByte, DL, XLenVT);
1636216362

1636316363
MachineFunction &MF = DAG.getMachineFunction();
1636416364
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)