blob: a71b8759f1cd5e9614fe30bfdf57db651b898608 [file] [log] [blame]
Alex Bradbury89718422017-10-19 21:37:38 +00001//===-- RISCVInstrInfo.cpp - RISCV Instruction Information ------*- C++ -*-===//
2//
Chandler Carruth2946cd72019-01-19 08:50:56 +00003// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
Alex Bradbury89718422017-10-19 21:37:38 +00006//
7//===----------------------------------------------------------------------===//
8//
9// This file contains the RISCV implementation of the TargetInstrInfo class.
10//
11//===----------------------------------------------------------------------===//
12
13#include "RISCVInstrInfo.h"
14#include "RISCV.h"
15#include "RISCVSubtarget.h"
16#include "RISCVTargetMachine.h"
Shiva Chena49a16d2019-09-13 04:03:32 +000017#include "Utils/RISCVMatInt.h"
Alex Bradbury89718422017-10-19 21:37:38 +000018#include "llvm/ADT/STLExtras.h"
19#include "llvm/ADT/SmallVector.h"
20#include "llvm/CodeGen/MachineFunctionPass.h"
21#include "llvm/CodeGen/MachineInstrBuilder.h"
22#include "llvm/CodeGen/MachineRegisterInfo.h"
Alex Bradbury315cd3a2018-01-10 21:05:07 +000023#include "llvm/CodeGen/RegisterScavenging.h"
Alex Bradbury89718422017-10-19 21:37:38 +000024#include "llvm/Support/ErrorHandling.h"
25#include "llvm/Support/TargetRegistry.h"
26
27#define GET_INSTRINFO_CTOR_DTOR
28#include "RISCVGenInstrInfo.inc"
29
30using namespace llvm;
31
Alex Bradburya3376752017-11-08 13:41:21 +000032RISCVInstrInfo::RISCVInstrInfo()
33 : RISCVGenInstrInfo(RISCV::ADJCALLSTACKDOWN, RISCV::ADJCALLSTACKUP) {}
Alex Bradburycfa62912017-11-08 12:20:01 +000034
Alex Bradburyfda60372018-04-26 15:34:27 +000035unsigned RISCVInstrInfo::isLoadFromStackSlot(const MachineInstr &MI,
36 int &FrameIndex) const {
37 switch (MI.getOpcode()) {
38 default:
39 return 0;
40 case RISCV::LB:
41 case RISCV::LBU:
42 case RISCV::LH:
43 case RISCV::LHU:
44 case RISCV::LW:
45 case RISCV::FLW:
46 case RISCV::LWU:
47 case RISCV::LD:
48 case RISCV::FLD:
49 break;
50 }
51
52 if (MI.getOperand(1).isFI() && MI.getOperand(2).isImm() &&
53 MI.getOperand(2).getImm() == 0) {
54 FrameIndex = MI.getOperand(1).getIndex();
55 return MI.getOperand(0).getReg();
56 }
57
58 return 0;
59}
60
61unsigned RISCVInstrInfo::isStoreToStackSlot(const MachineInstr &MI,
62 int &FrameIndex) const {
63 switch (MI.getOpcode()) {
64 default:
65 return 0;
66 case RISCV::SB:
67 case RISCV::SH:
68 case RISCV::SW:
69 case RISCV::FSW:
70 case RISCV::SD:
71 case RISCV::FSD:
72 break;
73 }
74
75 if (MI.getOperand(0).isFI() && MI.getOperand(1).isImm() &&
76 MI.getOperand(1).getImm() == 0) {
77 FrameIndex = MI.getOperand(0).getIndex();
78 return MI.getOperand(2).getReg();
79 }
80
81 return 0;
82}
83
Alex Bradburycfa62912017-11-08 12:20:01 +000084void RISCVInstrInfo::copyPhysReg(MachineBasicBlock &MBB,
85 MachineBasicBlock::iterator MBBI,
86 const DebugLoc &DL, unsigned DstReg,
87 unsigned SrcReg, bool KillSrc) const {
Alex Bradbury65d6ea52018-03-21 15:11:02 +000088 if (RISCV::GPRRegClass.contains(DstReg, SrcReg)) {
89 BuildMI(MBB, MBBI, DL, get(RISCV::ADDI), DstReg)
90 .addReg(SrcReg, getKillRegState(KillSrc))
91 .addImm(0);
92 return;
93 }
Alex Bradburycfa62912017-11-08 12:20:01 +000094
Alex Bradbury21d28fe2018-04-12 05:50:06 +000095 // FPR->FPR copies
96 unsigned Opc;
97 if (RISCV::FPR32RegClass.contains(DstReg, SrcReg))
98 Opc = RISCV::FSGNJ_S;
99 else if (RISCV::FPR64RegClass.contains(DstReg, SrcReg))
100 Opc = RISCV::FSGNJ_D;
101 else
102 llvm_unreachable("Impossible reg-to-reg copy");
Alex Bradbury65d6ea52018-03-21 15:11:02 +0000103
Alex Bradbury21d28fe2018-04-12 05:50:06 +0000104 BuildMI(MBB, MBBI, DL, get(Opc), DstReg)
105 .addReg(SrcReg, getKillRegState(KillSrc))
106 .addReg(SrcReg, getKillRegState(KillSrc));
Alex Bradburycfa62912017-11-08 12:20:01 +0000107}
Alex Bradbury74913e12017-11-08 13:31:40 +0000108
109void RISCVInstrInfo::storeRegToStackSlot(MachineBasicBlock &MBB,
110 MachineBasicBlock::iterator I,
111 unsigned SrcReg, bool IsKill, int FI,
112 const TargetRegisterClass *RC,
113 const TargetRegisterInfo *TRI) const {
114 DebugLoc DL;
115 if (I != MBB.end())
116 DL = I->getDebugLoc();
117
Alex Bradbury65d6ea52018-03-21 15:11:02 +0000118 unsigned Opcode;
119
Alex Bradbury87a54d62017-12-07 12:45:05 +0000120 if (RISCV::GPRRegClass.hasSubClassEq(RC))
Ana Pazos2e4106b2018-07-26 17:49:43 +0000121 Opcode = TRI->getRegSizeInBits(RISCV::GPRRegClass) == 32 ?
122 RISCV::SW : RISCV::SD;
Alex Bradbury65d6ea52018-03-21 15:11:02 +0000123 else if (RISCV::FPR32RegClass.hasSubClassEq(RC))
124 Opcode = RISCV::FSW;
Alex Bradbury0b4175f2018-04-12 05:34:25 +0000125 else if (RISCV::FPR64RegClass.hasSubClassEq(RC))
126 Opcode = RISCV::FSD;
Alex Bradbury74913e12017-11-08 13:31:40 +0000127 else
128 llvm_unreachable("Can't store this register to stack slot");
Alex Bradbury65d6ea52018-03-21 15:11:02 +0000129
130 BuildMI(MBB, I, DL, get(Opcode))
131 .addReg(SrcReg, getKillRegState(IsKill))
132 .addFrameIndex(FI)
133 .addImm(0);
Alex Bradbury74913e12017-11-08 13:31:40 +0000134}
135
136void RISCVInstrInfo::loadRegFromStackSlot(MachineBasicBlock &MBB,
137 MachineBasicBlock::iterator I,
138 unsigned DstReg, int FI,
139 const TargetRegisterClass *RC,
140 const TargetRegisterInfo *TRI) const {
141 DebugLoc DL;
142 if (I != MBB.end())
143 DL = I->getDebugLoc();
144
Alex Bradbury65d6ea52018-03-21 15:11:02 +0000145 unsigned Opcode;
146
Alex Bradbury87a54d62017-12-07 12:45:05 +0000147 if (RISCV::GPRRegClass.hasSubClassEq(RC))
Ana Pazos2e4106b2018-07-26 17:49:43 +0000148 Opcode = TRI->getRegSizeInBits(RISCV::GPRRegClass) == 32 ?
149 RISCV::LW : RISCV::LD;
Alex Bradbury65d6ea52018-03-21 15:11:02 +0000150 else if (RISCV::FPR32RegClass.hasSubClassEq(RC))
151 Opcode = RISCV::FLW;
Alex Bradbury0b4175f2018-04-12 05:34:25 +0000152 else if (RISCV::FPR64RegClass.hasSubClassEq(RC))
153 Opcode = RISCV::FLD;
Alex Bradbury74913e12017-11-08 13:31:40 +0000154 else
155 llvm_unreachable("Can't load this register from stack slot");
Alex Bradbury65d6ea52018-03-21 15:11:02 +0000156
157 BuildMI(MBB, I, DL, get(Opcode), DstReg).addFrameIndex(FI).addImm(0);
Alex Bradbury74913e12017-11-08 13:31:40 +0000158}
Alex Bradbury9fea4882018-01-10 19:53:46 +0000159
Shiva Chena49a16d2019-09-13 04:03:32 +0000160void RISCVInstrInfo::movImm(MachineBasicBlock &MBB,
161 MachineBasicBlock::iterator MBBI,
162 const DebugLoc &DL, Register DstReg, uint64_t Val,
163 MachineInstr::MIFlag Flag) const {
164 MachineFunction *MF = MBB.getParent();
165 MachineRegisterInfo &MRI = MF->getRegInfo();
166 bool IsRV64 = MF->getSubtarget<RISCVSubtarget>().is64Bit();
167 Register SrcReg = RISCV::X0;
168 Register Result = MRI.createVirtualRegister(&RISCV::GPRRegClass);
169 unsigned Num = 0;
Alex Bradbury9fea4882018-01-10 19:53:46 +0000170
Shiva Chena49a16d2019-09-13 04:03:32 +0000171 if (!IsRV64 && !isInt<32>(Val))
172 report_fatal_error("Should only materialize 32-bit constants for RV32");
Alex Bradbury099c7202018-04-18 19:02:31 +0000173
Shiva Chena49a16d2019-09-13 04:03:32 +0000174 RISCVMatInt::InstSeq Seq;
175 RISCVMatInt::generateInstSeq(Val, IsRV64, Seq);
176 assert(Seq.size() > 0);
177
178 for (RISCVMatInt::Inst &Inst : Seq) {
179 // Write the final result to DstReg if it's the last instruction in the Seq.
180 // Otherwise, write the result to the temp register.
181 if (++Num == Seq.size())
182 Result = DstReg;
183
184 if (Inst.Opc == RISCV::LUI) {
185 BuildMI(MBB, MBBI, DL, get(RISCV::LUI), Result)
186 .addImm(Inst.Imm)
187 .setMIFlag(Flag);
188 } else {
189 BuildMI(MBB, MBBI, DL, get(Inst.Opc), Result)
190 .addReg(SrcReg, RegState::Kill)
191 .addImm(Inst.Imm)
192 .setMIFlag(Flag);
193 }
194 // Only the first instruction has X0 as its source.
195 SrcReg = Result;
196 }
Alex Bradbury9fea4882018-01-10 19:53:46 +0000197}
Alex Bradburye027c932018-01-10 20:47:00 +0000198
199// The contents of values added to Cond are not examined outside of
200// RISCVInstrInfo, giving us flexibility in what to push to it. For RISCV, we
201// push BranchOpcode, Reg1, Reg2.
202static void parseCondBranch(MachineInstr &LastInst, MachineBasicBlock *&Target,
203 SmallVectorImpl<MachineOperand> &Cond) {
204 // Block ends with fall-through condbranch.
205 assert(LastInst.getDesc().isConditionalBranch() &&
206 "Unknown conditional branch");
207 Target = LastInst.getOperand(2).getMBB();
208 Cond.push_back(MachineOperand::CreateImm(LastInst.getOpcode()));
209 Cond.push_back(LastInst.getOperand(0));
210 Cond.push_back(LastInst.getOperand(1));
211}
212
213static unsigned getOppositeBranchOpcode(int Opc) {
214 switch (Opc) {
215 default:
216 llvm_unreachable("Unrecognized conditional branch");
217 case RISCV::BEQ:
218 return RISCV::BNE;
219 case RISCV::BNE:
220 return RISCV::BEQ;
221 case RISCV::BLT:
222 return RISCV::BGE;
223 case RISCV::BGE:
224 return RISCV::BLT;
225 case RISCV::BLTU:
226 return RISCV::BGEU;
227 case RISCV::BGEU:
228 return RISCV::BLTU;
229 }
230}
231
232bool RISCVInstrInfo::analyzeBranch(MachineBasicBlock &MBB,
233 MachineBasicBlock *&TBB,
234 MachineBasicBlock *&FBB,
235 SmallVectorImpl<MachineOperand> &Cond,
236 bool AllowModify) const {
237 TBB = FBB = nullptr;
238 Cond.clear();
239
240 // If the block has no terminators, it just falls into the block after it.
241 MachineBasicBlock::iterator I = MBB.getLastNonDebugInstr();
242 if (I == MBB.end() || !isUnpredicatedTerminator(*I))
243 return false;
244
245 // Count the number of terminators and find the first unconditional or
246 // indirect branch.
247 MachineBasicBlock::iterator FirstUncondOrIndirectBr = MBB.end();
248 int NumTerminators = 0;
249 for (auto J = I.getReverse(); J != MBB.rend() && isUnpredicatedTerminator(*J);
250 J++) {
251 NumTerminators++;
252 if (J->getDesc().isUnconditionalBranch() ||
253 J->getDesc().isIndirectBranch()) {
254 FirstUncondOrIndirectBr = J.getReverse();
255 }
256 }
257
258 // If AllowModify is true, we can erase any terminators after
259 // FirstUncondOrIndirectBR.
260 if (AllowModify && FirstUncondOrIndirectBr != MBB.end()) {
261 while (std::next(FirstUncondOrIndirectBr) != MBB.end()) {
262 std::next(FirstUncondOrIndirectBr)->eraseFromParent();
263 NumTerminators--;
264 }
265 I = FirstUncondOrIndirectBr;
266 }
267
268 // We can't handle blocks that end in an indirect branch.
269 if (I->getDesc().isIndirectBranch())
270 return true;
271
272 // We can't handle blocks with more than 2 terminators.
273 if (NumTerminators > 2)
274 return true;
275
276 // Handle a single unconditional branch.
277 if (NumTerminators == 1 && I->getDesc().isUnconditionalBranch()) {
278 TBB = I->getOperand(0).getMBB();
279 return false;
280 }
281
282 // Handle a single conditional branch.
283 if (NumTerminators == 1 && I->getDesc().isConditionalBranch()) {
284 parseCondBranch(*I, TBB, Cond);
285 return false;
286 }
287
288 // Handle a conditional branch followed by an unconditional branch.
289 if (NumTerminators == 2 && std::prev(I)->getDesc().isConditionalBranch() &&
290 I->getDesc().isUnconditionalBranch()) {
291 parseCondBranch(*std::prev(I), TBB, Cond);
292 FBB = I->getOperand(0).getMBB();
293 return false;
294 }
295
296 // Otherwise, we can't handle this.
297 return true;
298}
299
300unsigned RISCVInstrInfo::removeBranch(MachineBasicBlock &MBB,
301 int *BytesRemoved) const {
Alex Bradbury315cd3a2018-01-10 21:05:07 +0000302 if (BytesRemoved)
303 *BytesRemoved = 0;
Alex Bradburye027c932018-01-10 20:47:00 +0000304 MachineBasicBlock::iterator I = MBB.getLastNonDebugInstr();
305 if (I == MBB.end())
306 return 0;
307
308 if (!I->getDesc().isUnconditionalBranch() &&
309 !I->getDesc().isConditionalBranch())
310 return 0;
311
312 // Remove the branch.
Alex Bradbury315cd3a2018-01-10 21:05:07 +0000313 if (BytesRemoved)
314 *BytesRemoved += getInstSizeInBytes(*I);
Alex Bradburyad73a432019-07-18 03:23:47 +0000315 I->eraseFromParent();
Alex Bradburye027c932018-01-10 20:47:00 +0000316
317 I = MBB.end();
318
319 if (I == MBB.begin())
320 return 1;
321 --I;
322 if (!I->getDesc().isConditionalBranch())
323 return 1;
324
325 // Remove the branch.
Alex Bradbury315cd3a2018-01-10 21:05:07 +0000326 if (BytesRemoved)
327 *BytesRemoved += getInstSizeInBytes(*I);
Alex Bradburyad73a432019-07-18 03:23:47 +0000328 I->eraseFromParent();
Alex Bradburye027c932018-01-10 20:47:00 +0000329 return 2;
330}
331
332// Inserts a branch into the end of the specific MachineBasicBlock, returning
333// the number of instructions inserted.
334unsigned RISCVInstrInfo::insertBranch(
335 MachineBasicBlock &MBB, MachineBasicBlock *TBB, MachineBasicBlock *FBB,
336 ArrayRef<MachineOperand> Cond, const DebugLoc &DL, int *BytesAdded) const {
Alex Bradbury315cd3a2018-01-10 21:05:07 +0000337 if (BytesAdded)
338 *BytesAdded = 0;
Alex Bradburye027c932018-01-10 20:47:00 +0000339
340 // Shouldn't be a fall through.
341 assert(TBB && "InsertBranch must not be told to insert a fallthrough");
342 assert((Cond.size() == 3 || Cond.size() == 0) &&
343 "RISCV branch conditions have two components!");
344
345 // Unconditional branch.
346 if (Cond.empty()) {
Alex Bradbury315cd3a2018-01-10 21:05:07 +0000347 MachineInstr &MI = *BuildMI(&MBB, DL, get(RISCV::PseudoBR)).addMBB(TBB);
348 if (BytesAdded)
349 *BytesAdded += getInstSizeInBytes(MI);
Alex Bradburye027c932018-01-10 20:47:00 +0000350 return 1;
351 }
352
353 // Either a one or two-way conditional branch.
354 unsigned Opc = Cond[0].getImm();
Alex Bradbury315cd3a2018-01-10 21:05:07 +0000355 MachineInstr &CondMI =
356 *BuildMI(&MBB, DL, get(Opc)).add(Cond[1]).add(Cond[2]).addMBB(TBB);
357 if (BytesAdded)
358 *BytesAdded += getInstSizeInBytes(CondMI);
Alex Bradburye027c932018-01-10 20:47:00 +0000359
360 // One-way conditional branch.
361 if (!FBB)
362 return 1;
363
364 // Two-way conditional branch.
Alex Bradbury315cd3a2018-01-10 21:05:07 +0000365 MachineInstr &MI = *BuildMI(&MBB, DL, get(RISCV::PseudoBR)).addMBB(FBB);
366 if (BytesAdded)
367 *BytesAdded += getInstSizeInBytes(MI);
Alex Bradburye027c932018-01-10 20:47:00 +0000368 return 2;
369}
370
Alex Bradbury315cd3a2018-01-10 21:05:07 +0000371unsigned RISCVInstrInfo::insertIndirectBranch(MachineBasicBlock &MBB,
372 MachineBasicBlock &DestBB,
373 const DebugLoc &DL,
374 int64_t BrOffset,
375 RegScavenger *RS) const {
376 assert(RS && "RegScavenger required for long branching");
377 assert(MBB.empty() &&
378 "new block should be inserted for expanding unconditional branch");
379 assert(MBB.pred_size() == 1);
380
381 MachineFunction *MF = MBB.getParent();
382 MachineRegisterInfo &MRI = MF->getRegInfo();
383 const auto &TM = static_cast<const RISCVTargetMachine &>(MF->getTarget());
Alex Bradbury315cd3a2018-01-10 21:05:07 +0000384
Alex Bradbury5bf3b202018-10-04 14:30:03 +0000385 if (TM.isPositionIndependent())
Alex Bradbury315cd3a2018-01-10 21:05:07 +0000386 report_fatal_error("Unable to insert indirect branch");
387
388 if (!isInt<32>(BrOffset))
389 report_fatal_error(
390 "Branch offsets outside of the signed 32-bit range not supported");
391
392 // FIXME: A virtual register must be used initially, as the register
393 // scavenger won't work with empty blocks (SIInstrInfo::insertIndirectBranch
394 // uses the same workaround).
Daniel Sanders38368742019-08-12 22:41:02 +0000395 Register ScratchReg = MRI.createVirtualRegister(&RISCV::GPRRegClass);
Alex Bradbury315cd3a2018-01-10 21:05:07 +0000396 auto II = MBB.end();
397
398 MachineInstr &LuiMI = *BuildMI(MBB, II, DL, get(RISCV::LUI), ScratchReg)
399 .addMBB(&DestBB, RISCVII::MO_HI);
400 BuildMI(MBB, II, DL, get(RISCV::PseudoBRIND))
401 .addReg(ScratchReg, RegState::Kill)
402 .addMBB(&DestBB, RISCVII::MO_LO);
403
404 RS->enterBasicBlockEnd(MBB);
Alex Bradbury2c6c84e2019-03-11 20:43:29 +0000405 unsigned Scav = RS->scavengeRegisterBackwards(RISCV::GPRRegClass,
406 LuiMI.getIterator(), false, 0);
Alex Bradbury315cd3a2018-01-10 21:05:07 +0000407 MRI.replaceRegWith(ScratchReg, Scav);
408 MRI.clearVirtRegs();
409 RS->setRegUsed(Scav);
410 return 8;
411}
412
Alex Bradburye027c932018-01-10 20:47:00 +0000413bool RISCVInstrInfo::reverseBranchCondition(
414 SmallVectorImpl<MachineOperand> &Cond) const {
415 assert((Cond.size() == 3) && "Invalid branch condition!");
416 Cond[0].setImm(getOppositeBranchOpcode(Cond[0].getImm()));
417 return false;
418}
Alex Bradbury315cd3a2018-01-10 21:05:07 +0000419
420MachineBasicBlock *
421RISCVInstrInfo::getBranchDestBlock(const MachineInstr &MI) const {
422 assert(MI.getDesc().isBranch() && "Unexpected opcode!");
423 // The branch target is always the last operand.
424 int NumOp = MI.getNumExplicitOperands();
425 return MI.getOperand(NumOp - 1).getMBB();
426}
427
428bool RISCVInstrInfo::isBranchOffsetInRange(unsigned BranchOp,
429 int64_t BrOffset) const {
430 // Ideally we could determine the supported branch offset from the
431 // RISCVII::FormMask, but this can't be used for Pseudo instructions like
432 // PseudoBR.
433 switch (BranchOp) {
434 default:
435 llvm_unreachable("Unexpected opcode!");
436 case RISCV::BEQ:
437 case RISCV::BNE:
438 case RISCV::BLT:
439 case RISCV::BGE:
440 case RISCV::BLTU:
441 case RISCV::BGEU:
442 return isIntN(13, BrOffset);
443 case RISCV::JAL:
444 case RISCV::PseudoBR:
445 return isIntN(21, BrOffset);
446 }
447}
448
449unsigned RISCVInstrInfo::getInstSizeInBytes(const MachineInstr &MI) const {
450 unsigned Opcode = MI.getOpcode();
451
452 switch (Opcode) {
453 default: { return get(Opcode).getSize(); }
454 case TargetOpcode::EH_LABEL:
455 case TargetOpcode::IMPLICIT_DEF:
456 case TargetOpcode::KILL:
457 case TargetOpcode::DBG_VALUE:
458 return 0;
Lewis Revillcf748812019-06-26 10:35:58 +0000459 case RISCV::PseudoCALLReg:
Shiva Chend58bd8d2018-04-25 14:19:12 +0000460 case RISCV::PseudoCALL:
Mandeep Singh Grangddcb9562018-05-23 22:44:08 +0000461 case RISCV::PseudoTAIL:
Alex Bradburyda20f5c2019-04-01 14:42:56 +0000462 case RISCV::PseudoLLA:
Lewis Revilla5240362019-06-11 12:57:47 +0000463 case RISCV::PseudoLA:
Lewis Revill39263ac2019-06-19 08:40:59 +0000464 case RISCV::PseudoLA_TLS_IE:
465 case RISCV::PseudoLA_TLS_GD:
Shiva Chend58bd8d2018-04-25 14:19:12 +0000466 return 8;
Craig Topper784929d2019-02-08 20:48:56 +0000467 case TargetOpcode::INLINEASM:
468 case TargetOpcode::INLINEASM_BR: {
Alex Bradbury315cd3a2018-01-10 21:05:07 +0000469 const MachineFunction &MF = *MI.getParent()->getParent();
470 const auto &TM = static_cast<const RISCVTargetMachine &>(MF.getTarget());
471 return getInlineAsmLength(MI.getOperand(0).getSymbolName(),
472 *TM.getMCAsmInfo());
473 }
474 }
475}
Ana Pazos05a60642019-01-25 20:22:49 +0000476
477bool RISCVInstrInfo::isAsCheapAsAMove(const MachineInstr &MI) const {
478 const unsigned Opcode = MI.getOpcode();
479 switch(Opcode) {
480 default:
481 break;
482 case RISCV::ADDI:
483 case RISCV::ORI:
484 case RISCV::XORI:
485 return (MI.getOperand(1).isReg() && MI.getOperand(1).getReg() == RISCV::X0);
486 }
487 return MI.isAsCheapAsAMove();
488}