- SWR_ASSERT(pIndices->getType() == mInt64Ty && pLastIndex->getType() == mInt64Ty, "Function expects gfxptr_t for both input parameters.");
-
- Value* vIndices = VUNDEF_I();
-
- {
- // store 0 index on stack to be used to conditionally load from if index address is OOB
- Value* pZeroIndex = ALLOCA(mInt16Ty);
- STORE(C((uint16_t)0), pZeroIndex);
-
- // Load a SIMD of index pointers
- for (int64_t lane = 0; lane < mVWidth; lane++)
- {
- // Calculate the address of the requested index
- Value *pIndex = GEP(pIndices, C(lane), mInt16PtrTy);
-
- pLastIndex = INT_TO_PTR(pLastIndex, mInt16PtrTy);
-
- // check if the address is less than the max index,
- Value* mask = ICMP_ULT(pIndex, pLastIndex);
-
- // if valid, load the index. if not, load 0 from the stack
- Value* pValid = SELECT(mask, pIndex, pZeroIndex);
- Value *index = LOAD(pValid, "valid index", PointerType::get(mInt16Ty, 0), GFX_MEM_CLIENT_FETCH);
-
- // zero extended index to 32 bits and insert into the correct simd lane
- index = Z_EXT(index, mInt32Ty);
- vIndices = VINSERT(vIndices, index, lane);
- }
- }
-
- return vIndices;