conversions: fix undefined behaviour from shift by 64 (#1788)

Avoid a shift by 64 on a `uint64_t`.  The value resulting from the
spurious shift was overwritten later, so just avoid the shift in that
case.

Signed-off-by: Sven van Haastregt <sven.vanhaastregt@arm.com>
This commit is contained in:
Sven van Haastregt
2023-07-19 09:48:59 +01:00
committed by GitHub
parent 3c1f2814b8
commit c3babfeebb

View File

@@ -538,7 +538,6 @@ int ConversionsTest::DoTest(Type outType, Type inType, SaturationMode sat,
cl_ulong wall_start = mach_absolute_time(); cl_ulong wall_start = mach_absolute_time();
#endif #endif
uint64_t lastCase = 1ULL << (8 * gTypeSizes[inType]);
cl_uint threads = GetThreadCount(); cl_uint threads = GetThreadCount();
DataInitInfo info = { 0, 0, outType, inType, sat, round, threads }; DataInitInfo info = { 0, 0, outType, inType, sat, round, threads };
@@ -601,7 +600,9 @@ int ConversionsTest::DoTest(Type outType, Type inType, SaturationMode sat,
// Figure out how many elements are in a work block // Figure out how many elements are in a work block
// we handle 64-bit types a bit differently. // we handle 64-bit types a bit differently.
if (8 * gTypeSizes[inType] > 32) lastCase = 0x100000000ULL; uint64_t lastCase = (8 * gTypeSizes[inType] > 32)
? 0x100000000ULL
: 1ULL << (8 * gTypeSizes[inType]);
if (!gWimpyMode && gIsEmbedded) if (!gWimpyMode && gIsEmbedded)
step = blockCount * EMBEDDED_REDUCTION_FACTOR; step = blockCount * EMBEDDED_REDUCTION_FACTOR;