Skip to content

Commit 938d0d6

Browse files
committed
[RISCV] Replace uses of hasStdExtC with COrZca.
Except MakeCompressible which will need more work. Reviewed By: reames Differential Revision: https://reviews.llvm.org/D139504
1 parent fe42ebe commit 938d0d6

File tree

4 files changed

+8
-2
lines changed

4 files changed

+8
-2
lines changed

llvm/lib/Target/RISCV/MCTargetDesc/RISCVMatInt.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,8 @@ InstSeq generateInstSeq(int64_t Val, const FeatureBitset &ActiveFeatures) {
366366
int getIntMatCost(const APInt &Val, unsigned Size,
367367
const FeatureBitset &ActiveFeatures, bool CompressionCost) {
368368
bool IsRV64 = ActiveFeatures[RISCV::Feature64Bit];
369-
bool HasRVC = CompressionCost && ActiveFeatures[RISCV::FeatureStdExtC];
369+
bool HasRVC = CompressionCost && (ActiveFeatures[RISCV::FeatureStdExtC] ||
370+
ActiveFeatures[RISCV::FeatureExtZca]);
370371
int PlatRegSize = IsRV64 ? 64 : 32;
371372

372373
// Split the constant into platform register sized chunks, and calculate cost

llvm/lib/Target/RISCV/RISCVMakeCompressible.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,7 @@ bool RISCVMakeCompressibleOpt::runOnMachineFunction(MachineFunction &Fn) {
332332
const RISCVInstrInfo &TII = *STI.getInstrInfo();
333333

334334
// This optimization only makes sense if compressed instructions are emitted.
335+
// FIXME: Support Zca, Zcf, Zcd granularity.
335336
if (!STI.hasStdExtC())
336337
return false;
337338

llvm/lib/Target/RISCV/RISCVRegisterInfo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,7 @@ void RISCVRegisterInfo::getOffsetOpcodes(const StackOffset &Offset,
562562

563563
unsigned
564564
RISCVRegisterInfo::getRegisterCostTableIndex(const MachineFunction &MF) const {
565-
return MF.getSubtarget<RISCVSubtarget>().hasStdExtC() ? 1 : 0;
565+
return MF.getSubtarget<RISCVSubtarget>().hasStdExtCOrZca() ? 1 : 0;
566566
}
567567

568568
// Add two address hints to improve chances of being able to use a compressed

llvm/test/CodeGen/RISCV/add-before-shl.ll

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
; RUN: < %s | FileCheck -check-prefixes=RV32C %s
88
; RUN: llc -mtriple=riscv64 -mattr=+c -verify-machineinstrs --riscv-no-aliases \
99
; RUN: < %s | FileCheck -check-prefixes=RV64C %s
10+
; RUN: llc -mtriple=riscv32 -mattr=+experimental-zca -verify-machineinstrs --riscv-no-aliases \
11+
; RUN: < %s | FileCheck -check-prefixes=RV32C %s
12+
; RUN: llc -mtriple=riscv64 -mattr=+experimental-zca -verify-machineinstrs --riscv-no-aliases \
13+
; RUN: < %s | FileCheck -check-prefixes=RV64C %s
1014

1115
; These test that constant adds are not moved after shifts by DAGCombine,
1216
; if the constant is cheaper to materialise before it has been shifted.

0 commit comments

Comments
 (0)