[llvm] 745ff71 - [RISCV] Consistently use RISCVSubtarget::is64Bit() instead of isRV32/isRV64. (#223038)
via llvm-commits
llvm-commits at lists.llvm.org
Sat Sep 12 21:02:37 PDT 2026
Author: Craig Topper
Date: 2026-09-12T21:02:32-07:00
New Revision: 745ff71c706f6a55c7fa1cda660860925e0b2739
URL: https://github.com/llvm/llvm-project/commit/745ff71c706f6a55c7fa1cda660860925e0b2739
DIFF: https://github.com/llvm/llvm-project/commit/745ff71c706f6a55c7fa1cda660860925e0b2739.diff
LOG: [RISCV] Consistently use RISCVSubtarget::is64Bit() instead of isRV32/isRV64. (#223038)
99% of code uses RISCVSubtarget::is64Bit().
Maybe we should consider removing is64Bit(), and using isRV64() instead
but right now I think we should be consistent.
Added:
Modified:
llvm/lib/Target/RISCV/GISel/RISCVInstructionSelector.cpp
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
llvm/lib/Target/RISCV/RISCVInstrInfo.cpp
llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
Removed:
################################################################################
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 20d21b1a8da14..788ae8a57b779 100644
--- a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
+++ b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
@@ -4796,7 +4796,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 957cc37cf5cca..6d83480fa6c69 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