From: Jakub Jelinek Date: Fri, 20 Dec 2019 08:23:42 +0000 (+0100) Subject: re PR target/92841 (Optimize -fstack-protector-strong code generation a bit) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=3439487f01f3e563c7521b4cc86409fb9797f990;p=gcc.git re PR target/92841 (Optimize -fstack-protector-strong code generation a bit) PR target/92841 * config/i386/i386.md (*stack_protect_set_3): For pic_32bit_operand always use lea{q}, no matter what value which_alternative has. * gcc.target/i386/pr92841-2.c: New test. From-SVN: r279633 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index e486d7cffde..686c72717bb 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,9 @@ 2019-12-20 Jakub Jelinek + PR target/92841 + * config/i386/i386.md (*stack_protect_set_3): For pic_32bit_operand + always use lea{q}, no matter what value which_alternative has. + PR target/93002 * config/i386/i386.md (dec reg; cmp $-1, reg; jne lab): New define_peephole2. diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md index b0176c8bf94..8844a702941 100644 --- a/gcc/config/i386/i386.md +++ b/gcc/config/i386/i386.md @@ -19863,12 +19863,13 @@ { output_asm_insn ("mov{q}\t{%3, %1|%1, %3}", operands); output_asm_insn ("mov{q}\t{%1, %0|%0, %1}", operands); - if (which_alternative == 0) + if (pic_32bit_operand (operands[2], DImode)) + return "lea{q}\t{%E2, %1|%1, %E2}"; + else if (which_alternative == 0) return "mov{l}\t{%k2, %k1|%k1, %k2}"; else if (which_alternative == 2) return "movabs{q}\t{%2, %1|%1, %2}"; - else if (pic_32bit_operand (operands[2], DImode) - || ix86_use_lea_for_mov (insn, operands + 1)) + else if (ix86_use_lea_for_mov (insn, operands + 1)) return "lea{q}\t{%E2, %1|%1, %E2}"; else return "mov{q}\t{%2, %1|%1, %2}"; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index c4231c82de7..ee072abf7a8 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,8 @@ 2019-12-20 Jakub Jelinek + PR target/92841 + * gcc.target/i386/pr92841-2.c: New test. + PR target/93002 * gcc.target/i386/pr93002.c: New test. diff --git a/gcc/testsuite/gcc.target/i386/pr92841-2.c b/gcc/testsuite/gcc.target/i386/pr92841-2.c new file mode 100644 index 00000000000..b2d5eb86389 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr92841-2.c @@ -0,0 +1,18 @@ +/* PR target/92841 */ +/* { dg-do compile { target { { { *-*-linux* } && lp64 } && fstack_protector } } } */ +/* { dg-options "-O2 -fpic -fstack-protector-strong -masm=att" } */ +/* { dg-final { scan-assembler "leaq\tbuf2\\\(%rip\\\)," } } */ + +static char buf2[64]; +void bar (char *, char *); + +void +foo () +{ + char buf[64]; + char *p = buf2; + asm ("" : "+a" (p)); + char *q = buf; + asm ("" : "+r" (q)); + bar (p, q); +}