19
19
using namespace llvm ;
20
20
21
21
static bool checkRegisters (Register FirstDest, const MachineInstr &SecondMI) {
22
+ if (!SecondMI.getOperand (1 ).isReg ())
23
+ return false ;
24
+
22
25
if (SecondMI.getOperand (1 ).getReg () != FirstDest)
23
26
return false ;
24
27
@@ -53,8 +56,16 @@ static bool isLDADD(const MachineInstr *FirstMI, const MachineInstr &SecondMI) {
53
56
return checkRegisters (FirstMI->getOperand (0 ).getReg (), SecondMI);
54
57
}
55
58
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
58
69
static bool isSLLISRLI (const MachineInstr *FirstMI,
59
70
const MachineInstr &SecondMI) {
60
71
if (SecondMI.getOpcode () != RISCV::SRLI)
@@ -95,10 +106,6 @@ static bool isAUIPCADDI(const MachineInstr *FirstMI,
95
106
if (FirstMI->getOpcode () != RISCV::AUIPC)
96
107
return false ;
97
108
98
- // The first operand of ADDI might be a frame index.
99
- if (!SecondMI.getOperand (1 ).isReg ())
100
- return false ;
101
-
102
109
return checkRegisters (FirstMI->getOperand (0 ).getReg (), SecondMI);
103
110
}
104
111
@@ -118,10 +125,6 @@ static bool isLUIADDI(const MachineInstr *FirstMI,
118
125
if (FirstMI->getOpcode () != RISCV::LUI)
119
126
return false ;
120
127
121
- // The first operand of ADDI might be a frame index.
122
- if (!SecondMI.getOperand (1 ).isReg ())
123
- return false ;
124
-
125
128
return checkRegisters (FirstMI->getOperand (0 ).getReg (), SecondMI);
126
129
}
127
130
0 commit comments