| Summary: | sse _mm_madd_epi16, undefined * 0 should not yield uninitialised result | ||
|---|---|---|---|
| Product: | [Developer tools] valgrind | Reporter: | ttyridal |
| Component: | memcheck | Assignee: | Julian Seward <jseward> |
| Status: | REPORTED --- | ||
| Severity: | normal | CC: | dirk.farin |
| Priority: | NOR | ||
| Version First Reported In: | 3.8.0 | ||
| Target Milestone: | --- | ||
| Platform: | Other | ||
| OS: | Linux | ||
| Latest Commit: | Version Fixed/Implemented In: | ||
| Sentry Crash Report: | |||
True, but probably difficult (impossible?) to fix without some performance loss, since we'd need to insert a run time check for zero-ness of the arguments, and special-case the output if they are found to be zero. Note that this bug also shows for vectors with only some elements being zero. I am affected by this bug too, multiplying two vectors of length 15 (last coefficient in one vector is 0). Valgrind reports this as error even though it is not. |
memcheck seems to not understand that 0 multiplied with whatever is still 0 when using simd instructions. valgrind version: 3.8.1 example program to provoke the error: #include "emmintrin.h" #include <stdio.h> #include <valgrind/memcheck.h> int main(void) { __m128i a; __m128i r = _mm_madd_epi16(a,_mm_setzero_si128()); if (VALGRIND_CHECK_MEM_IS_DEFINED(&r,16)) printf("\n\nVALGRIND BUG! Memory is defined and 0 (undefined*0 == 0)\n\n"); return _mm_cvtsi128_si32(r); } gcc -msse -o test test.c && valgrind ./test Observe that VALGRIND_CHECK_MEM_IS_DEFINED will report an error, as well as the return value is deemed uninitialised. expected result: no printf and no valgrind/memcheck errors. A typical use-case is a filter function with padded data and 0 coefficients for edge handling. Reproducible: Always