@@ -1464,9 +1464,15 @@ bool RISCVTargetLowering::getTgtMemIntrinsic(IntrinsicInfo &Info,
14641464 auto &DL = I.getModule()->getDataLayout();
14651465
14661466 auto SetRVVLoadStoreInfo = [&](unsigned PtrOp, bool IsStore,
1467- bool IsUnitStrided) {
1467+ bool IsUnitStrided, bool UsePtrVal = false ) {
14681468 Info.opc = IsStore ? ISD::INTRINSIC_VOID : ISD::INTRINSIC_W_CHAIN;
1469- Info.ptrVal = I.getArgOperand(PtrOp);
1469+ // We can't use ptrVal if the intrinsic can access memory before the
1470+ // pointer. This means we can't use it for strided or indexed intrinsics.
1471+ if (UsePtrVal)
1472+ Info.ptrVal = I.getArgOperand(PtrOp);
1473+ else
1474+ Info.fallbackAddressSpace =
1475+ I.getArgOperand(PtrOp)->getType()->getPointerAddressSpace();
14701476 Type *MemTy;
14711477 if (IsStore) {
14721478 // Store value is the first operand.
@@ -1526,7 +1532,7 @@ bool RISCVTargetLowering::getTgtMemIntrinsic(IntrinsicInfo &Info,
15261532 case Intrinsic::riscv_seg7_load:
15271533 case Intrinsic::riscv_seg8_load:
15281534 return SetRVVLoadStoreInfo(/*PtrOp*/ 0, /*IsStore*/ false,
1529- /*IsUnitStrided*/ false);
1535+ /*IsUnitStrided*/ false, /*UsePtrVal*/ true );
15301536 case Intrinsic::riscv_seg2_store:
15311537 case Intrinsic::riscv_seg3_store:
15321538 case Intrinsic::riscv_seg4_store:
@@ -1537,19 +1543,21 @@ bool RISCVTargetLowering::getTgtMemIntrinsic(IntrinsicInfo &Info,
15371543 // Operands are (vec, ..., vec, ptr, vl)
15381544 return SetRVVLoadStoreInfo(/*PtrOp*/ I.arg_size() - 2,
15391545 /*IsStore*/ true,
1540- /*IsUnitStrided*/ false);
1546+ /*IsUnitStrided*/ false, /*UsePtrVal*/ true );
15411547 case Intrinsic::riscv_vle:
15421548 case Intrinsic::riscv_vle_mask:
15431549 case Intrinsic::riscv_vleff:
15441550 case Intrinsic::riscv_vleff_mask:
15451551 return SetRVVLoadStoreInfo(/*PtrOp*/ 1,
15461552 /*IsStore*/ false,
1547- /*IsUnitStrided*/ true);
1553+ /*IsUnitStrided*/ true,
1554+ /*UsePtrVal*/ true);
15481555 case Intrinsic::riscv_vse:
15491556 case Intrinsic::riscv_vse_mask:
15501557 return SetRVVLoadStoreInfo(/*PtrOp*/ 1,
15511558 /*IsStore*/ true,
1552- /*IsUnitStrided*/ true);
1559+ /*IsUnitStrided*/ true,
1560+ /*UsePtrVal*/ true);
15531561 case Intrinsic::riscv_vlse:
15541562 case Intrinsic::riscv_vlse_mask:
15551563 case Intrinsic::riscv_vloxei:
@@ -1584,7 +1592,7 @@ bool RISCVTargetLowering::getTgtMemIntrinsic(IntrinsicInfo &Info,
15841592 case Intrinsic::riscv_vlseg8ff:
15851593 return SetRVVLoadStoreInfo(/*PtrOp*/ I.arg_size() - 2,
15861594 /*IsStore*/ false,
1587- /*IsUnitStrided*/ false);
1595+ /*IsUnitStrided*/ false, /*UsePtrVal*/ true );
15881596 case Intrinsic::riscv_vlseg2_mask:
15891597 case Intrinsic::riscv_vlseg3_mask:
15901598 case Intrinsic::riscv_vlseg4_mask:
@@ -1601,7 +1609,7 @@ bool RISCVTargetLowering::getTgtMemIntrinsic(IntrinsicInfo &Info,
16011609 case Intrinsic::riscv_vlseg8ff_mask:
16021610 return SetRVVLoadStoreInfo(/*PtrOp*/ I.arg_size() - 4,
16031611 /*IsStore*/ false,
1604- /*IsUnitStrided*/ false);
1612+ /*IsUnitStrided*/ false, /*UsePtrVal*/ true );
16051613 case Intrinsic::riscv_vlsseg2:
16061614 case Intrinsic::riscv_vlsseg3:
16071615 case Intrinsic::riscv_vlsseg4:
0 commit comments