PR79066, non-PIC code generated for powerpc glibc with -fpic
authorAlan Modra <amodra@gmail.com>
Tue, 17 Jan 2017 02:54:11 +0000 (13:24 +1030)
committerAlan Modra <amodra@gcc.gnu.org>
Tue, 17 Jan 2017 02:54:11 +0000 (13:24 +1030)
PR target/79066
* config/rs6000/rs6000.md (elf_high, elf_low): Disable when pic.
* config/rs6000/rs6000.c (rs6000_emit_allocate_stack): Don't allow
symbolic stack limit when pic.
testsuite/
* gcc.target/powerpc/pr79066.c: New.

From-SVN: r244515

gcc/ChangeLog
gcc/config/rs6000/rs6000.c
gcc/config/rs6000/rs6000.md
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/powerpc/pr79066.c [new file with mode: 0644]

index ead236ff5fb567667a9753ff810f870054ba500c..073b53ee84395f8a3921aa5991326a3fb54d890b 100644 (file)
@@ -1,3 +1,10 @@
+2017-01-17  Alan Modra  <amodra@gmail.com>
+
+       PR target/79066
+       * config/rs6000/rs6000.md (elf_high, elf_low): Disable when pic.
+       * config/rs6000/rs6000.c (rs6000_emit_allocate_stack): Don't allow
+       symbolic stack limit when pic.
+
 2017-01-16  Martin Sebor  <msebor@redhat.com>
 
        PR tree-optimization/78608
index 29b3fd65624d4ba99b956435129b3b7116163f0d..37ad7d04c2fc5b19eafbb2b2a959786d53280bab 100644 (file)
@@ -27669,7 +27669,8 @@ rs6000_emit_allocate_stack (HOST_WIDE_INT size, rtx copy_reg, int copy_off)
        }
       else if (GET_CODE (stack_limit_rtx) == SYMBOL_REF
               && TARGET_32BIT
-              && DEFAULT_ABI == ABI_V4)
+              && DEFAULT_ABI == ABI_V4
+              && !flag_pic)
        {
          rtx toload = gen_rtx_CONST (VOIDmode,
                                      gen_rtx_PLUS (Pmode,
index b3334749860d92c2f9ba3519027e2468c926214e..f00334a1d09d45e421128a16ee5aa2a1167f2d63 100644 (file)
 (define_insn "elf_high"
   [(set (match_operand:SI 0 "gpc_reg_operand" "=b*r")
        (high:SI (match_operand 1 "" "")))]
-  "TARGET_ELF && ! TARGET_64BIT"
+  "TARGET_ELF && !TARGET_64BIT && !flag_pic"
   "lis %0,%1@ha")
 
 (define_insn "elf_low"
   [(set (match_operand:SI 0 "gpc_reg_operand" "=r")
        (lo_sum:SI (match_operand:SI 1 "gpc_reg_operand" "b")
                   (match_operand 2 "" "")))]
-   "TARGET_ELF && ! TARGET_64BIT"
+   "TARGET_ELF && !TARGET_64BIT && !flag_pic"
    "la %0,%2@l(%1)")
 \f
 ;; Call and call_value insns
index 09c5d52aa4bf1ec33a7426cc67ef8454415a3e9d..c00a050732b0ddb435091eefb2d0b4a1bda1b03d 100644 (file)
@@ -1,3 +1,7 @@
+2017-01-17  Alan Modra  <amodra@gmail.com>
+
+       * gcc.target/powerpc/pr79066.c: New.
+
 2017-01-16  Jeff Law  <law@redhat.com>
 
        PR tree-optimization/33562
diff --git a/gcc/testsuite/gcc.target/powerpc/pr79066.c b/gcc/testsuite/gcc.target/powerpc/pr79066.c
new file mode 100644 (file)
index 0000000..86b2014
--- /dev/null
@@ -0,0 +1,14 @@
+/* { dg-do compile { target { fpic && ilp32 } } } */
+/* { dg-options "-O2 -fpic" } */
+/* { dg-final { scan-assembler-not "lis.*@ha" } } */
+
+union U { double x; int i[2]; };
+
+double
+foo (double x)
+{
+  union U v;
+  v.i[0] = 0x7ff00000;
+  v.i[1] = 0;
+  return x / v.x;
+}