Changeset 101613 in vbox
- Timestamp:
- Oct 27, 2023 8:41:10 AM (11 months ago)
- File:
-
- 1 edited
-
trunk/src/VBox/Runtime/testcase/tstRTArmv8.cpp (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/testcase/tstRTArmv8.cpp
r101612 r101613 43 43 44 44 #include <iprt/test.h> 45 #include <iprt/rand.h> 45 46 #include <iprt/stream.h> 46 47 #include <iprt/sort.h> … … 75 76 76 77 78 /** @callback_method_impl{FNRTSORTCMP} */ 79 static DECLCALLBACK(int) cmpu64(void const *pvElement1, void const *pvElement2, void *pvUser) 80 { 81 RT_NOREF(pvUser); 82 if (*(uint64_t const *)pvElement1 < *(uint64_t const *)pvElement2) 83 return -1; 84 if (*(uint64_t const *)pvElement1 > *(uint64_t const *)pvElement2) 85 return 1; 86 return 0; 87 } 88 89 90 static unsigned BinarySearchU64(uint64_t uValue, uint64_t const *pauEntries, unsigned idxEnd) 91 { 92 unsigned idxStart = 0; 93 for (;;) 94 { 95 unsigned const idx = (idxEnd - idxStart) / 2 + idxStart; 96 uint64_t const uEntry = pauEntries[idx]; 97 if (uValue < uEntry) 98 { 99 if (idx > idxStart) 100 idxEnd = idx; 101 else 102 return ~0U; 103 } 104 else if (uValue > uEntry) 105 { 106 if (idx + 1 < idxEnd) 107 idxStart = idx + 1; 108 else 109 return ~0U; 110 } 111 else 112 return idx; 113 } 114 } 115 116 77 117 void tstLogicalMask32(void) 78 118 { … … 95 135 uint32_t const uImmS = cOneBits | uImmSElmnLength; 96 136 uint32_t const uMask = Armv8A64ConvertImmRImmS2Mask32(uImmS, cRotations); 97 Assert(cValidMasks < RT_ELEMENTS(s_auValidMasks));137 RTTESTI_CHECK_RETV(cValidMasks < RT_ELEMENTS(s_auValidMasks)); 98 138 s_auValidMasks[cValidMasks++] = uMask; 99 139 … … 157 197 { 158 198 RTTestISub("64-bit logical masks"); 199 static uint64_t s_auValidMasks[5376]; 200 unsigned cValidMasks = 0; 159 201 160 202 /* Test all legal combinations, both directions. */ … … 172 214 uint32_t const uImmS = cOneBits | uImmSElmnLength; 173 215 uint64_t const uMask = Armv8A64ConvertImmRImmS2Mask64(uImmS, cRotations); 216 RTTESTI_CHECK_RETV(cValidMasks < RT_ELEMENTS(s_auValidMasks)); 217 s_auValidMasks[cValidMasks++] = uMask; 218 174 219 if (g_cVerbosity > 1) 175 220 RTPrintf("%016llx %s size=%02u length=%02u rotation=%02u N=%u immr=%s imms=%s\n", … … 191 236 uImmSElmnLength = 0x40; 192 237 } 238 239 /* Now the other way around, using random masks. */ 240 RTSortShell(s_auValidMasks, cValidMasks, sizeof(s_auValidMasks[0]), cmpu64, NULL); 241 242 for (unsigned iRand = 0; iRand < _32M; iRand++) 243 { 244 uint64_t const uMask = RTRandU64(); 245 unsigned const idxMask = BinarySearchU64(uMask, s_auValidMasks, cValidMasks); 246 uint32_t uImmSRev = UINT32_MAX; 247 uint32_t uImmRRev = UINT32_MAX; 248 if (!Armv8A64ConvertMask64ToImmRImmS(uMask, &uImmSRev, &uImmRRev)) 249 { 250 if (RT_LIKELY(idxMask == ~0U)) 251 { } 252 else 253 { 254 RTTestIFailed("uMask=%#018llx - false negative\n", uMask); 255 break; 256 } 257 } 258 else if (RT_LIKELY(idxMask < cValidMasks)) 259 { /* likely */ } 260 else 261 { 262 RTTestIFailed("uMask=%#018llx - false positive\n", uMask); 263 break; 264 } 265 } 193 266 } 194 267
Note:
See TracChangeset
for help on using the changeset viewer.

