]> git.ipfire.org Git - thirdparty/gcc.git/commit
bpf: fix cbranch miscompilation in CPUv1 [PR122141]
authorDavid Faust <david.faust@oracle.com>
Fri, 10 Oct 2025 17:35:07 +0000 (10:35 -0700)
committerDavid Faust <david.faust@oracle.com>
Fri, 10 Oct 2025 19:29:31 +0000 (12:29 -0700)
commit6a77bf08e5a5fb1554ff99b231c4a9ae2d3f1149
tree9461810ee6836eb004368070557dbc82b06c592f
parent0e95ebf465c2c05be8cddb8d4659c7b26b1e1a19
bpf: fix cbranch miscompilation in CPUv1 [PR122141]

As diagnosed by Andrew in the linked PR, when reversing the branch
condition to work around lack of some cbranch instructions, we must
use swap_condition rather than reverse_condition.

PR target/122141

gcc/

* config/bpf/bpf.cc (bpf_expand_cbranch): Use swap_condition
rather than reverse_condition when reversing jump condition to
work around missing instructions in very old BPF ISAs.

gcc/testsuite/

* gcc.target/bpf/pr122141-1.c: New.
* gcc.target/bpf/pr122141-2.c: New.

Suggested-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
gcc/config/bpf/bpf.cc
gcc/testsuite/gcc.target/bpf/pr122141-1.c [new file with mode: 0644]
gcc/testsuite/gcc.target/bpf/pr122141-2.c [new file with mode: 0644]