[Bug driver/50740] CPUID leaf 7 for BMI/BMI2/AVX2 feature detection not qualified with max_level and doesn't use subleaf
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=50740 Mark Warner changed: What|Removed |Added CC||warnerme at ptd dot net --- Comment #4 from Mark Warner --- In the file cpuid.h, there is a problem with the definition: #define __cpuid(level, a, b, c, d) \ __asm__ ("cpuid\n\t" \ : "=a" (a), "=b" (b), "=c" (c), "=d" (d) \ : "0" (level)) With the ecx undefined, the leaf 7 (Extended Features %eax == 7) can not be accessed. Leaf 7 (%eax) can only be accessed when sub-leaf (%ecx) is 0 I suggest instead: #define __cpuid(level, a, b, c, d) \ __asm__ ("cpuid\n\t" \ : "=a" (a), "=b" (b), "=c" (c), "=d" (d) \ : "0" (level), "2" (0))
[Bug target/83401] New: cpuid function for leaf 7 may not be accessed when sub-leaf (%ecx) is undefined
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83401 Bug ID: 83401 Summary: cpuid function for leaf 7 may not be accessed when sub-leaf (%ecx) is undefined Product: gcc Version: 5.4.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: warnerme at ptd dot net Target Milestone: --- In the file cpuid.h, there is a problem with the definition: #define __cpuid(level, a, b, c, d) \ __asm__ ("cpuid\n\t" \ : "=a" (a), "=b" (b), "=c" (c), "=d" (d) \ : "0" (level)) With the ecx undefined, the leaf 7 (Extended Features %eax == 7) can not be accessed. Leaf 7 (%eax) can only be accessed when sub-leaf (%ecx) is 0 I suggest instead: #define __cpuid(level, a, b, c, d) \ __asm__ ("cpuid\n\t" \ : "=a" (a), "=b" (b), "=c" (c), "=d" (d) \ : "0" (level), "2" (0))
[Bug c/59933] New: for loop goes wild with assert() enabled
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59933 Bug ID: 59933 Summary: for loop goes wild with assert() enabled Product: gcc Version: 4.8.2 Status: UNCONFIRMED Severity: major Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: warnerme at ptd dot net I have this odd case where a for loop goes wild. But it only fails when assert() is enabled. gcc -Iinc -g -O2 -DDEBUG -fstack-protector-all -W -Wstrict-prototypes -Wall -Wextra -Wcast-align -Wnested-externs -Wshadow -c -o build/NSQ_del_dec.o c/NSQ_del_dec.c If -DNDEBUG is used, the code works fine, although there is a slight difference between CYGWIN32 (4.8.2-2) and CYGWIN64 (4.8.2-1). This was not a problem with gcc 4.7. if (RDmin_Q10 < RDmax_Q10) { #if 1 /* THIS IS THE CODE THAT FAILS */ for (k = i; k < (int)(sizeof(NSQ_del_dec_struct) / sizeof(opus_int32)); ++k) { psDelDec[RDmax_ind].sLPC_Q14[k] = psDelDec[RDmin_ind].sLPC_Q14[k]; } #else /* THIS IS THE WORK-AROUND */ int n = (sizeof(NSQ_del_dec_struct) / sizeof(opus_int32)) - i; opus_int32 *src = &psDelDec[RDmin_ind].sLPC_Q14[i]; opus_int32 *dst = &psDelDec[RDmax_ind].sLPC_Q14[i]; while (n-- > 0) *dst++ = *src++; #endif psSampleState[RDmax_ind][0] = psSampleState[RDmin_ind][1]; } I've tried lots of combinations of code to get the work around, and this even fails when I insert printf-s, but the most common with this exact code is that it does sizeof(NSQ_del_dec_struct) number of loops leaving out the / sizeof(opus_int32). I have had some test test where the loop didn't stop till it destroyed enough stack to crash it. Sorry, that the file is a bit big but trying to whittle it down usually made the problem go away.
[Bug c/59933] for loop goes wild with assert() enabled
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59933 --- Comment #1 from Mark Warner --- Created attachment 31945 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=31945&action=edit C source of subroutines which contain problem for loop This is a file from OPUS. As sent it can't be run, but the problem was bad enough that I thought looking at the generated code might be enough. All, except system, include files are inlined.
[Bug c/59933] for loop goes wild with assert() enabled
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59933 --- Comment #5 from Mark Warner --- sizeof(NSQ_del_dec_struct) / sizeof(opus_int32) is guaranteed to produced a even number with a remainder of 0. Note the __attribute__ ((__aligned__ (8))) to make it a multiple of 8 in size.
[Bug c/59933] for loop goes wild with assert() enabled
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59933 --- Comment #6 from Mark Warner --- If it is invalid, why does -Wall not trigger anything ?
[Bug c/59933] for loop goes wild with assert() enabled
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59933 --- Comment #11 from Mark Warner --- I'm confused .. what about.. for (k = i; k < (int)(sizeof(NSQ_del_dec_struct) / sizeof(opus_int32)); ++k) ... is illegal or invalid ? Why does it only fail if -DDEBUG is defined ? I mean, this code worked fine for months .. and now