Skip to content

Commit eb79be7

Browse files
committed
addressed review comments.
1 parent 783a2ad commit eb79be7

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

llvm/lib/Target/RISCV/RISCVMacroFusion.cpp

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
using namespace llvm;
2020

2121
static bool checkRegisters(Register FirstDest, const MachineInstr &SecondMI) {
22+
if (!SecondMI.getOperand(1).isReg())
23+
return false;
24+
2225
if (SecondMI.getOperand(1).getReg() != FirstDest)
2326
return false;
2427

@@ -53,8 +56,16 @@ static bool isLDADD(const MachineInstr *FirstMI, const MachineInstr &SecondMI) {
5356
return checkRegisters(FirstMI->getOperand(0).getReg(), SecondMI);
5457
}
5558

56-
// Fuse SLLI by 32 feeding into SRLI by 32 or less or
57-
// SLLI by exactly 48 feeding into SRLI by exactly 48.
59+
// Fuse these patterns:
60+
//
61+
// $rd = slli $rs0, 32
62+
// $rd = srli $rs1, x
63+
// where 0 <= x <= 32
64+
//
65+
// and
66+
//
67+
// $rd = slli $rs0, 48
68+
// $rd = srli $rs1, 48
5869
static bool isSLLISRLI(const MachineInstr *FirstMI,
5970
const MachineInstr &SecondMI) {
6071
if (SecondMI.getOpcode() != RISCV::SRLI)
@@ -95,10 +106,6 @@ static bool isAUIPCADDI(const MachineInstr *FirstMI,
95106
if (FirstMI->getOpcode() != RISCV::AUIPC)
96107
return false;
97108

98-
// The first operand of ADDI might be a frame index.
99-
if (!SecondMI.getOperand(1).isReg())
100-
return false;
101-
102109
return checkRegisters(FirstMI->getOperand(0).getReg(), SecondMI);
103110
}
104111

@@ -118,10 +125,6 @@ static bool isLUIADDI(const MachineInstr *FirstMI,
118125
if (FirstMI->getOpcode() != RISCV::LUI)
119126
return false;
120127

121-
// The first operand of ADDI might be a frame index.
122-
if (!SecondMI.getOperand(1).isReg())
123-
return false;
124-
125128
return checkRegisters(FirstMI->getOperand(0).getReg(), SecondMI);
126129
}
127130

0 commit comments

Comments
 (0)