https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99988
Bug ID: 99988 Summary: aarch64: GCC generates excessive consecutive bti j instructions Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: acoplan at gcc dot gnu.org Target Milestone: --- Created attachment 50535 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50535&action=edit minimal reproducer For the attached testcase (reduced from the linux kernel), GCC generates multiple redundant sequences of back-to-back bti j instructions, the longest of which is 262 instructions long. To reproduce: $ aarch64-linux-gnu-gcc -c test.c -S -o - -O2 -mbranch-protection=standard | uniq -c | grep "bti j" | sort -nr 262 hint 36 // bti j 7 hint 36 // bti j 6 hint 36 // bti j 4 hint 36 // bti j 4 hint 36 // bti j 3 hint 36 // bti j 2 hint 36 // bti j 2 hint 36 // bti j 2 hint 36 // bti j 2 hint 36 // bti j 2 hint 36 // bti j 2 hint 36 // bti j 2 hint 36 // bti j