Skip to content

Commit a3f5189

Browse files
authored
Sve/Scatter test: Add Debug.Assert for array length (#116158)
* Add Debug.Assert for array length * review feedback
1 parent b79d4c4 commit a3f5189

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

src/tests/JIT/HardwareIntrinsics/Arm/Shared/SveGatherVectorFirstFaultingVectorBases.template

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ namespace JIT.HardwareIntrinsics.Arm
135135
{Op2BaseType} baseAddrToValidate = (({Op2BaseType})baseArrayPtr + (sizeof({RetBaseType}) * inArray2[i]));
136136

137137
// Make sure we got the correct base pointers.
138+
Debug.Assert((int)inArray2[i] < (int)baseArray.Length, $"Index {inArray2[i]} exceeds array length {baseArray.Length}");
138139
Debug.Assert(*(({RetBaseType}*)baseAddrToValidate) == baseArray[inArray2[i]]);
139140

140141
inArray2[i] = baseAddrToValidate;
@@ -157,6 +158,7 @@ namespace JIT.HardwareIntrinsics.Arm
157158
{Op2BaseType} baseAddrToValidate = (({Op2BaseType})baseArrayPtr + (sizeof({RetBaseType}) * inArray2Ffr[i]));
158159

159160
// Make sure we got the correct base pointers.
161+
Debug.Assert((int)inArray2Ffr[i] < (int)baseArray.Length, $"Index {inArray2Ffr[i]} exceeds array length {baseArray.Length}");
160162
Debug.Assert(*(({RetBaseType}*)baseAddrToValidate) == baseArray[inArray2Ffr[i]]);
161163

162164
inArray2Ffr[i] = baseAddrToValidate;
@@ -207,7 +209,7 @@ namespace JIT.HardwareIntrinsics.Arm
207209
{
208210
{Op2BaseType} baseAddrToValidate = (({Op2BaseType})_dataTable.baseArrayPtr + (sizeof({RetBaseType}) * _data2[i]));
209211

210-
// Make sure we got the correct base pointers.
212+
// Make sure we got the correct base pointers.
211213
Debug.Assert(*(({RetBaseType}*)baseAddrToValidate) == (({RetBaseType}*)_dataTable.baseArrayPtr)[_data2[i]]);
212214

213215
_data2[i] = baseAddrToValidate;

src/tests/JIT/HardwareIntrinsics/Arm/Shared/SveGatherVectorVectorBases.template

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ namespace JIT.HardwareIntrinsics.Arm
124124
{Op2BaseType} baseAddrToValidate = (({Op2BaseType})baseArrayPtr + (sizeof({RetBaseType}) * inArray2[i]));
125125

126126
// Make sure we got the correct base pointers.
127+
Debug.Assert((int)inArray2[i] < (int)baseArray.Length, $"Index {inArray2[i]} exceeds array length {baseArray.Length}");
127128
Debug.Assert(*(({RetBaseType}*)baseAddrToValidate) == baseArray[inArray2[i]]);
128129

129130
inArray2[i] = baseAddrToValidate;
@@ -172,7 +173,7 @@ namespace JIT.HardwareIntrinsics.Arm
172173
{
173174
{Op2BaseType} baseAddrToValidate = (({Op2BaseType})_dataTable.baseArrayPtr + (sizeof({RetBaseType}) * _data2[i]));
174175

175-
// Make sure we got the correct base pointers.
176+
// Make sure we got the correct base pointers.
176177
Debug.Assert(*(({RetBaseType}*)baseAddrToValidate) == (({RetBaseType}*)_dataTable.baseArrayPtr)[_data2[i]]);
177178

178179
_data2[i] = baseAddrToValidate;

src/tests/JIT/HardwareIntrinsics/Arm/Shared/SveScatterVectorBases.template

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ namespace JIT.HardwareIntrinsics.Arm._Sve
120120
{Op2BaseType} baseAddrToValidate = (({Op2BaseType})outArrayPtr + (sizeof({Op2BaseType}) * inAddress[i]));
121121

122122
// Make sure we got the correct base pointers.
123+
Debug.Assert((int)inAddress[i] < (int)outArray.Length, $"Index {inAddress[i]} exceeds array length {outArray.Length}");
123124
Debug.Assert(*(({Op1BaseType}*)baseAddrToValidate) == outArray[inAddress[i]]);
124125

125126
inAddress[i] = baseAddrToValidate;
@@ -193,7 +194,7 @@ namespace JIT.HardwareIntrinsics.Arm._Sve
193194
{
194195
{Op2BaseType} baseAddrToValidate = (({Op2BaseType})_dataTable.outArrayPtr + (sizeof({Op2BaseType}) * _addressArr[i]));
195196

196-
// Make sure we got the correct base pointers.
197+
// Make sure we got the correct base pointers.
197198
Debug.Assert(*(({Op1BaseType}*)baseAddrToValidate) == (({Op1BaseType}*)_dataTable.outArrayPtr)[_addressArr[i]]);
198199

199200
_addressArr[i] = baseAddrToValidate;

0 commit comments

Comments
 (0)