https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70593
Bug ID: 70593 Summary: [6 Regression] Miscompilation of xen starting with r226901 Product: gcc Version: 6.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: middle-end Assignee: unassigned at gcc dot gnu.org Reporter: jakub at gcc dot gnu.org Target Milestone: --- __attribute__((noinline, noclone)) unsigned long foo (unsigned long x, unsigned long y, unsigned z) { unsigned long a, b, c, d = z; asm volatile ("xorl\t%k1, %k1\n\txorl\t%k2, %k2\n\txorl\t%k3, %k3\n\tmovl\t$7, %k0" : "=&c" (d), "=&D" (a), "=&S" (b), "=&r" (c) : "0" (d), "1" (x), "2" (y), "3" (d) : "memory"); return d; } int main () { if (foo (1, 2, 3) != 7) __builtin_abort (); return 0; } is miscompiled on x86_64-linux at -O2 starting with r226901, -O2 -fno-tree-coalesce-vars works. The return value d is in %rcx at the end of the inline asm, but with -O2 the copy of %rcx to %rax is lost.