@@ -149,13 +149,23 @@ def BCLRIANDIMaskLow : SDNodeXForm<imm, [{
149
149
SDLoc(N), N->getValueType(0));
150
150
}]>;
151
151
152
+ def SimmShiftRightBy2XForm : SDNodeXForm<imm, [{
153
+ return CurDAG->getSignedTargetConstant(N->getSExtValue() >> 2, SDLoc(N),
154
+ N->getValueType(0));
155
+ }]>;
156
+
157
+ def SimmShiftRightBy3XForm : SDNodeXForm<imm, [{
158
+ return CurDAG->getSignedTargetConstant(N->getSExtValue() >> 3, SDLoc(N),
159
+ N->getValueType(0));
160
+ }]>;
161
+
152
162
def CSImm12MulBy4 : PatLeaf<(imm), [{
153
163
if (!N->hasOneUse())
154
164
return false;
155
165
int64_t C = N->getSExtValue();
156
166
// Skip if C is simm12, an lui, or can be optimized by the PatLeaf AddiPair.
157
167
return !isInt<13>(C) && !isShiftedInt<20, 12>(C) && isShiftedInt<12, 2>(C);
158
- }]>;
168
+ }], SimmShiftRightBy2XForm >;
159
169
160
170
def CSImm12MulBy8 : PatLeaf<(imm), [{
161
171
if (!N->hasOneUse())
@@ -164,17 +174,7 @@ def CSImm12MulBy8 : PatLeaf<(imm), [{
164
174
// Skip if C is simm12, an lui or can be optimized by the PatLeaf AddiPair or
165
175
// CSImm12MulBy4.
166
176
return !isInt<14>(C) && !isShiftedInt<20, 12>(C) && isShiftedInt<12, 3>(C);
167
- }]>;
168
-
169
- def SimmShiftRightBy2XForm : SDNodeXForm<imm, [{
170
- return CurDAG->getSignedTargetConstant(N->getSExtValue() >> 2, SDLoc(N),
171
- N->getValueType(0));
172
- }]>;
173
-
174
- def SimmShiftRightBy3XForm : SDNodeXForm<imm, [{
175
- return CurDAG->getSignedTargetConstant(N->getSExtValue() >> 3, SDLoc(N),
176
- N->getValueType(0));
177
- }]>;
177
+ }], SimmShiftRightBy3XForm>;
178
178
179
179
// Pattern to exclude simm12 immediates from matching, namely `non_imm12`.
180
180
// GISel currently doesn't support PatFrag for leaf nodes, so `non_imm12`
@@ -654,10 +654,10 @@ foreach i = {1,2,3} in {
654
654
}
655
655
656
656
def : Pat<(add_like (XLenVT GPR:$r), CSImm12MulBy4:$i),
657
- (SH2ADD (XLenVT (ADDI (XLenVT X0), (SimmShiftRightBy2XForm CSImm12MulBy4:$i) )),
657
+ (SH2ADD (XLenVT (ADDI (XLenVT X0), CSImm12MulBy4:$i)),
658
658
GPR:$r)>;
659
659
def : Pat<(add_like (XLenVT GPR:$r), CSImm12MulBy8:$i),
660
- (SH3ADD (XLenVT (ADDI (XLenVT X0), (SimmShiftRightBy3XForm CSImm12MulBy8:$i) )),
660
+ (SH3ADD (XLenVT (ADDI (XLenVT X0), CSImm12MulBy8:$i)),
661
661
GPR:$r)>;
662
662
663
663
} // Predicates = [HasStdExtZba]
0 commit comments