http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53315
--- Comment #9 from Andi Kleen <andi-gcc at firstfloor dot org> 2012-05-11 21:35:47 UTC --- Sorry I was wrong earlier. Retested now fully with a full test case and HJs patch and i always get aborts The xbegin gets miscompiled now, the in transaction branch disappears. 400460: 48 83 ec 08 sub $0x8,%rsp 400464: b8 ff ff ff ff mov $0xffffffff,%eax 400469: c7 f8 00 00 00 00 xbeginq 40046f <main+0xf> 40046f: bf d8 06 40 00 mov $0x4006d8,%edi 400474: 31 f6 xor %esi,%esi 400476: 31 c0 xor %eax,%eax 400478: e8 b3 ff ff ff callq 400430 <printf@plt> 40047d: 31 ff xor %edi,%edi 40047f: e8 bc ff ff ff callq 400440 <exit@plt> /* PR53315 and PR53291 */ /* { dg-do run } */ /* { dg-options "-O2 -mrtm" } */ #include <immintrin.h> #include <cpuid.h> #include <stdlib.h> #include <stdio.h> static int cpu_has_rtm(void) { if (__get_cpuid_max(0, NULL) >= 7) { unsigned a, b, c, d; __cpuid_count(7, 0, a, b, c, d); return !!(b & bit_RTM); } return 0; } int main(void) { int flag = -1; unsigned status; if (!cpu_has_rtm) { printf("no tsx support. untested\n"); exit(0); } if ((status = _xbegin()) == _XBEGIN_STARTED) { flag = _xtest(); _xend(); } else { /* Note this is legal according to the TSX spec */ printf("unexpected abort %x. untested\n", status); exit(0); } if (flag != 1) abort(); if (_xtest() != 0) abort(); return 0; }