@@ -143,19 +143,35 @@ static bool isCompressedReg(Register Reg) {
143
143
// Return true if MI is a load for which there exists a compressed version.
144
144
static bool isCompressibleLoad (const MachineInstr &MI) {
145
145
const RISCVSubtarget &STI = MI.getMF ()->getSubtarget <RISCVSubtarget>();
146
- const unsigned Opcode = MI.getOpcode ();
147
146
148
- return Opcode == RISCV::LW || (!STI.is64Bit () && Opcode == RISCV::FLW) ||
149
- Opcode == RISCV::LD || Opcode == RISCV::FLD;
147
+ switch (MI.getOpcode ()) {
148
+ default :
149
+ return false ;
150
+ case RISCV::LW:
151
+ case RISCV::LD:
152
+ return STI.hasStdExtCOrZca ();
153
+ case RISCV::FLW:
154
+ return !STI.is64Bit () && STI.hasStdExtCOrZcfOrZce ();
155
+ case RISCV::FLD:
156
+ return STI.hasStdExtCOrZcd ();
157
+ }
150
158
}
151
159
152
160
// Return true if MI is a store for which there exists a compressed version.
153
161
static bool isCompressibleStore (const MachineInstr &MI) {
154
162
const RISCVSubtarget &STI = MI.getMF ()->getSubtarget <RISCVSubtarget>();
155
- const unsigned Opcode = MI.getOpcode ();
156
163
157
- return Opcode == RISCV::SW || (!STI.is64Bit () && Opcode == RISCV::FSW) ||
158
- Opcode == RISCV::SD || Opcode == RISCV::FSD;
164
+ switch (MI.getOpcode ()) {
165
+ default :
166
+ return false ;
167
+ case RISCV::SW:
168
+ case RISCV::SD:
169
+ return STI.hasStdExtCOrZca ();
170
+ case RISCV::FSW:
171
+ return !STI.is64Bit () && STI.hasStdExtCOrZcfOrZce ();
172
+ case RISCV::FSD:
173
+ return STI.hasStdExtCOrZcd ();
174
+ }
159
175
}
160
176
161
177
// Find a single register and/or large offset which, if compressible, would
@@ -324,8 +340,7 @@ bool RISCVMakeCompressibleOpt::runOnMachineFunction(MachineFunction &Fn) {
324
340
const RISCVInstrInfo &TII = *STI.getInstrInfo ();
325
341
326
342
// This optimization only makes sense if compressed instructions are emitted.
327
- // FIXME: Support Zca, Zcf, Zcd granularity.
328
- if (!STI.hasStdExtC ())
343
+ if (!STI.hasStdExtCOrZca ())
329
344
return false ;
330
345
331
346
for (MachineBasicBlock &MBB : Fn) {
0 commit comments