https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124056
Bug ID: 124056
Summary: Flags output is not handled correctly with "asm goto"
Product: gcc
Version: 15.2.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: middle-end
Assignee: unassigned at gcc dot gnu.org
Reporter: ubizjak at gmail dot com
Target Milestone: ---
Following testcase:
--cut here--
void foo (void);
void bar (void);
int qux (void)
{
_Bool err;
asm goto ("# insn" :"=@ccz" (err) : : : lab);
if (err)
{
bar ();
return -1;
}
return 0;
lab:
if (err)
{
foo ();
return -2;
}
return 1;
}
--cut here--
compiles with -O2 to:
qux:
insn
je .L11
.L2:
xorl %eax, %eax
ret
.L5:
movl $1, %eax
ret
.L11:
subq $8, %rsp
call bar
movl $-1, %eax
addq $8, %rsp
ret
where the part that calls foo and returns -2 is simply gone missing.