-
Bug
-
Resolution: Fixed
-
Medium
-
Code Generation Tools
-
CODEGEN-12527
-
-
-
default
-
The attached file has this code ...
// Run test for (uint16_t i = 0; i < USED_SIZE; i += 16) { __float16 vecZero = (__float16)(0); __float16 vec = *(__float16 *)(array + i); __bool16 cmp_res = __cmp_lt_bool(vec, vecZero); SimdVectorTest cmp_res_v = SimdVectorTest::fromNative(cmp_res); cmp_res = cmp_res_v.toNative(); __float16 res = __select(cmp_res, vec, vecZero); *(__float16 *)(array + i) = res; } // Verify Results for (uint16_t i = 45; i < 60; ++i) printf("array[%d]: %g\n", i, array[i]);
SimdVectorTest is a class that wraps the vector type __bool16. When built with no optimization, the expected result is produced.
array[45]: -5 array[46]: -4 array[47]: -3 array[48]: -2 array[49]: -1 array[50]: 0 array[51]: 0 array[52]: 0 array[53]: 0 array[54]: 0 array[55]: 0 array[56]: 0 array[57]: 0 array[58]: 0 array[59]: 0
When built with --opt_level=3, incorrect output is produced.
array[45]: -5 array[46]: -4 array[47]: -3 array[48]: -2 array[49]: -1 array[50]: 0 array[51]: 1 array[52]: 2 array[53]: 3 array[54]: 4 array[55]: 5 array[56]: 0 array[57]: 0 array[58]: 0 array[59]: 0