re PR target/92841 (Optimize -fstack-protector-strong code generation a bit)
authorJakub Jelinek <jakub@redhat.com>
Fri, 20 Dec 2019 08:23:42 +0000 (09:23 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 20 Dec 2019 08:23:42 +0000 (09:23 +0100)
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

gcc/ChangeLog
gcc/config/i386/i386.md
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/i386/pr92841-2.c [new file with mode: 0644]

index e486d7cffde7abe016bfaac288e6dc8f062b47d6..686c72717bb2797c2797ec9866cb62ac5de80b15 100644 (file)
@@ -1,5 +1,9 @@
 2019-12-20  Jakub Jelinek  <jakub@redhat.com>
 
+       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.
index b0176c8bf944e7cf404330b83f7e31258ce766c5..8844a702941a0a7d2768ef6a006a10cc59d9a708 100644 (file)
 {
   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}";
index c4231c82de7835622c56f9e3f8775395b8b44c55..ee072abf7a859fd435409c6bd5af1ea08fb22104 100644 (file)
@@ -1,5 +1,8 @@
 2019-12-20  Jakub Jelinek  <jakub@redhat.com>
 
+       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 (file)
index 0000000..b2d5eb8
--- /dev/null
@@ -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);
+}