[llvm] [RISCV] Consistently use RISCVSubtarget::is64Bit() instead of isRV32/isRV64. (PR #223038)
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 11 12:53:11 PDT 2026
https://github.com/topperc created https://github.com/llvm/llvm-project/pull/223038
99% of code uses RISCVSubtarget::is64Bit().
Maybe we should consider removing is64Bit(), but right now I think we should be consistent.
>From 257635806e28ed40e0fa5246f7c3b3bd317bcdc2 Mon Sep 17 00:00:00 2001
From: Craig Topper <craig.topper at sifive.com>
Date: Fri, 11 Sep 2026 12:49:28 -0700
Subject: [PATCH] [RISCV] Consistently use RISCVSubtarget::is64Bit() inplace of
isRV32/isRV64.
99% of code uses RISCVSubtarget::is64Bit().
Maybe we should consider removing is64Bit(), but right now I think we
should be consistent.
---
llvm/lib/Target/RISCV/GISel/RISCVInstructionSelector.cpp | 6 +++---
llvm/lib/Target/RISCV/RISCVISelLowering.cpp | 2 +-
llvm/lib/Target/RISCV/RISCVInstrInfo.cpp | 2 +-
llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp | 3 +--
4 files changed, 6 insertions(+), 7 deletions(-)
diff --git a/llvm/lib/Target/RISCV/GISel/RISCVInstructionSelector.cpp b/llvm/lib/Target/RISCV/GISel/RISCVInstructionSelector.cpp
index eff674ea4f959..c8e8d8f247b63 100644
--- a/llvm/lib/Target/RISCV/GISel/RISCVInstructionSelector.cpp
+++ b/llvm/lib/Target/RISCV/GISel/RISCVInstructionSelector.cpp
@@ -1361,9 +1361,9 @@ bool RISCVInstructionSelector::select(MachineInstr &MI) {
// Use sext.h/zext.h for i16 with Zbb.
if (SrcSize == 16 &&
(STI.hasStdExtZbb() || (!IsSigned && STI.hasStdExtZbkb()))) {
- MI.setDesc(TII.get(IsSigned ? RISCV::SEXT_H
- : STI.isRV64() ? RISCV::ZEXT_H_RV64
- : RISCV::ZEXT_H_RV32));
+ MI.setDesc(TII.get(IsSigned ? RISCV::SEXT_H
+ : STI.is64Bit() ? RISCV::ZEXT_H_RV64
+ : RISCV::ZEXT_H_RV32));
constrainSelectedInstRegOperands(MI, TII, TRI, RBI);
return true;
}
diff --git a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
index 19b4a01b7733b..49694053ff4fc 100644
--- a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
+++ b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
@@ -4808,7 +4808,7 @@ static SDValue lowerBUILD_VECTOR(SDValue Op, SelectionDAG &DAG,
SDLoc DL(Op);
- if (Subtarget.isRV32() && Subtarget.hasStdExtP()) {
+ if (!Subtarget.is64Bit() && Subtarget.hasStdExtP()) {
if (VT == MVT::v2i16) {
SDValue Lo = DAG.getBitcast(
MVT::v2i16,
diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfo.cpp b/llvm/lib/Target/RISCV/RISCVInstrInfo.cpp
index ee47963aa041e..bebf521957568 100644
--- a/llvm/lib/Target/RISCV/RISCVInstrInfo.cpp
+++ b/llvm/lib/Target/RISCV/RISCVInstrInfo.cpp
@@ -544,7 +544,7 @@ void RISCVInstrInfo::copyPhysReg(MachineBasicBlock &MBB,
}
if (RISCV::GPRPairRegClass.contains(DstReg, SrcReg)) {
- if (STI.isRV32()) {
+ if (!STI.is64Bit()) {
if (STI.hasStdExtZdinx()) {
// On RV32_Zdinx, FMV.D will move a pair of registers to another pair of
// registers, in one instruction.
diff --git a/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp b/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
index 4b22da42f0aec..6877d54384a52 100644
--- a/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
+++ b/llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
@@ -262,8 +262,7 @@ InstructionCost RISCVTTIImpl::getIntImmCostInst(unsigned Opcode, unsigned Idx,
if (Imm == UINT64_C(0xffff) && ST->hasStdExtZbb())
return TTI::TCC_Free;
// zext.w
- if (Imm == UINT64_C(0xffffffff) &&
- ((ST->hasStdExtZba() && ST->isRV64()) || ST->isRV32()))
+ if (Imm == UINT64_C(0xffffffff) && (!ST->is64Bit() || ST->hasStdExtZba()))
return TTI::TCC_Free;
// bclri
if (ST->hasStdExtZbs() && (~Imm).isPowerOf2())
More information about the llvm-commits
mailing list