@@ -2226,6 +2226,7 @@ SDValue X86DAGToDAGISel::matchIndexRecursively(SDValue N,
2226
2226
return N;
2227
2227
2228
2228
EVT VT = N.getValueType ();
2229
+ unsigned Opc = N.getOpcode ();
2229
2230
2230
2231
// index: add(x,c) -> index: x, disp + c
2231
2232
if (CurDAG->isBaseWithConstantOffset (N)) {
@@ -2236,15 +2237,15 @@ SDValue X86DAGToDAGISel::matchIndexRecursively(SDValue N,
2236
2237
}
2237
2238
2238
2239
// index: add(x,x) -> index: x, scale * 2
2239
- if (N. getOpcode () == ISD::ADD && N.getOperand (0 ) == N.getOperand (1 )) {
2240
+ if (Opc == ISD::ADD && N.getOperand (0 ) == N.getOperand (1 )) {
2240
2241
if (AM.Scale <= 4 ) {
2241
2242
AM.Scale *= 2 ;
2242
2243
return matchIndexRecursively (N.getOperand (0 ), AM, Depth + 1 );
2243
2244
}
2244
2245
}
2245
2246
2246
2247
// index: shl(x,i) -> index: x, scale * (1 << i)
2247
- if (N. getOpcode () == X86ISD::VSHLI) {
2248
+ if (Opc == X86ISD::VSHLI) {
2248
2249
uint64_t ShiftAmt = N.getConstantOperandVal (1 );
2249
2250
uint64_t ScaleAmt = 1ULL << ShiftAmt;
2250
2251
if ((AM.Scale * ScaleAmt) <= 8 ) {
@@ -2255,17 +2256,17 @@ SDValue X86DAGToDAGISel::matchIndexRecursively(SDValue N,
2255
2256
2256
2257
// index: sext(add_nsw(x,c)) -> index: sext(x), disp + sext(c)
2257
2258
// TODO: call matchIndexRecursively(AddSrc) if we won't corrupt sext?
2258
- if (N. getOpcode () == ISD::SIGN_EXTEND && !VT.isVector ()) {
2259
+ if (Opc == ISD::SIGN_EXTEND && !VT.isVector ()) {
2259
2260
SDValue Src = N.getOperand (0 );
2260
2261
if (Src.getOpcode () == ISD::ADD && Src->getFlags ().hasNoSignedWrap ()) {
2261
2262
if (CurDAG->isBaseWithConstantOffset (Src)) {
2262
2263
SDValue AddSrc = Src.getOperand (0 );
2263
2264
auto *AddVal = cast<ConstantSDNode>(Src.getOperand (1 ));
2264
- uint64_t Offset = (uint64_t )AddVal->getSExtValue () * AM. Scale ;
2265
- if (!foldOffsetIntoAddress (Offset, AM)) {
2265
+ uint64_t Offset = (uint64_t )AddVal->getSExtValue ();
2266
+ if (!foldOffsetIntoAddress (Offset * AM. Scale , AM)) {
2266
2267
SDLoc DL (N);
2267
- SDValue ExtSrc = CurDAG->getNode (ISD::SIGN_EXTEND , DL, VT, AddSrc);
2268
- SDValue ExtVal = CurDAG->getConstant (AddVal-> getSExtValue () , DL, VT);
2268
+ SDValue ExtSrc = CurDAG->getNode (Opc , DL, VT, AddSrc);
2269
+ SDValue ExtVal = CurDAG->getConstant (Offset , DL, VT);
2269
2270
SDValue ExtAdd = CurDAG->getNode (ISD::ADD, DL, VT, ExtSrc, ExtVal);
2270
2271
insertDAGNode (*CurDAG, N, ExtSrc);
2271
2272
insertDAGNode (*CurDAG, N, ExtVal);
0 commit comments