]> git.ipfire.org Git - thirdparty/gcc.git/commit
cfgexpand: Fix up "=@ccz" etc. outputs on asm goto [PR124056]
authorJakub Jelinek <jakub@redhat.com>
Wed, 11 Feb 2026 10:34:09 +0000 (11:34 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Wed, 11 Feb 2026 10:34:09 +0000 (11:34 +0100)
commit1c68b2b4e244dff5f1087c37a68dd891ffae58b4
tree126f1703efe2c88f85ed52646cc3e9cec63f35f0
parentc158d510ee96158a4f90255148222fb1ce356832
cfgexpand: Fix up "=@ccz" etc. outputs on asm goto [PR124056]

The following testcase is miscompiled, because after_md_seq which is
what is emitted for "=@cc?" outputs to initialize a pseudo with
the result is emitted just once, on the asm goto fallthru edge, before
after_rtl_seq (on that edge that is the correct ordering), but a copy
of after_rtl_seq is also emitted on the other edges from asm goto, but
after_md_seq is not.
So, the pseudo with the flags checking is initialized only in the
fallthru case and not when asm goto is left through one of the other
labels (unless those are degenerate).

The following patch arranges to emit that sequence duplicated on all the
edges before after_rtl_seq sequence, by modifying after_rtl_seq so that
it includes after_md_seq followed by the old after_rtl_seq.

2026-02-11  Jakub Jelinek  <jakub@redhat.com>

PR middle-end/124056
* cfgexpand.cc (expand_asm_stmt): If after_md_seq is non-NULL, emit
it at the start of after_rtl_seq instead of after fallthru_label.

* gcc.target/i386/pr124056.c: New test.
gcc/cfgexpand.cc
gcc/testsuite/gcc.target/i386/pr124056.c [new file with mode: 0644]