https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68416
Bug ID: 68416 Summary: [MPX] GCC emits a lot of redundant bndmov instructions Product: gcc Version: 6.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: ienkovich at gcc dot gnu.org Target Milestone: --- Many tests show we have lots of redundant bndmov instructions. E.g.: >cat test.c int foo(int **arr, int i) { return (*arr)[i]; } >gcc -O2 -mmpx -fcheck-pointer-bounds test.c -S >cat test.s .file "test.c" .text .p2align 4,,15 .globl foo .type foo, @function foo: .LFB1: .cfi_startproc bndcl (%rdi), %bnd0 bndmov %bnd0, -24(%rsp) movslq %esi, %rsi bndcu 7(%rdi), %bnd0 movq (%rdi), %rax bndldx (%rdi,%rax), %bnd3 leaq (%rax,%rsi,4), %rax bndmov %bnd3, -24(%rsp) bndcl (%rax), %bnd3 bndmov -24(%rsp), %bnd1 bndcu 3(%rax), %bnd1 movl (%rax), %eax bnd ret Here we have 3 bndmov instructions we don't need.