re PR rtl-optimization/52773 (internal error: in replace_pseudos_in, at reload1.c...
authorBernd Schmidt <bernds@codesourcery.com>
Sat, 17 Jan 2015 07:35:40 +0000 (07:35 +0000)
committerJeff Law <law@gcc.gnu.org>
Sat, 17 Jan 2015 07:35:40 +0000 (00:35 -0700)
PR rtl-optimization/52773
* calls.c (emit_library_call_value): When pushing arguments use
stack_pointer_rtx rather than virtual_outgoing_args_rtx in
CALL_INSN_FUNCTION_USAGE.  Only emit one of use of the magic
stack pointer reference into CALL_INSN_FUNCTION_USAGE.

PR rtl-optimization/52773
* gcc.c-torture/compile/pr52773.c: New test.

From-SVN: r219796

gcc/ChangeLog
gcc/calls.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/compile/pr52773.c [new file with mode: 0644]

index 04ae25502c797741d17daeeea3305720ab650f7b..80f8c927b0eba7721846e44ecf956f6b8c6c1f39 100644 (file)
@@ -1,3 +1,11 @@
+2015-01-17  Bernd Schmidt  <bernds@codesourcery.com>
+
+       PR rtl-optimization/52773
+       * calls.c (emit_library_call_value): When pushing arguments use
+       stack_pointer_rtx rather than virtual_outgoing_args_rtx in
+       CALL_INSN_FUNCTION_USAGE.  Only emit one of use of the magic
+       stack pointer reference into CALL_INSN_FUNCTION_USAGE.
+
 2015-01-17  Jeff Law  <law@redhat.com>
 
        PR rtl-optimization/32790
index 1c2f0adfa2354277bfa579aa24406a03cb154229..ec44624d7c9af242937064a39bae0124f0836e48 100644 (file)
@@ -3808,6 +3808,7 @@ emit_library_call_value_1 (int retval, rtx orgfun, rtx value,
   int reg_parm_stack_space = 0;
   int needed;
   rtx_insn *before_call;
+  bool have_push_fusage;
   tree tfom;                   /* type_for_mode (outmode, 0) */
 
 #ifdef REG_PARM_STACK_SPACE
@@ -4165,6 +4166,8 @@ emit_library_call_value_1 (int retval, rtx orgfun, rtx value,
 
   /* Push the args that need to be pushed.  */
 
+  have_push_fusage = false;
+
   /* ARGNUM indexes the ARGVEC array in the order in which the arguments
      are to be pushed.  */
   for (count = 0; count < nargs; count++, argnum--)
@@ -4256,14 +4259,19 @@ emit_library_call_value_1 (int retval, rtx orgfun, rtx value,
          if (argblock)
            use = plus_constant (Pmode, argblock,
                                 argvec[argnum].locate.offset.constant);
+         else if (have_push_fusage)
+           continue;
          else
-           /* When arguments are pushed, trying to tell alias.c where
-              exactly this argument is won't work, because the
-              auto-increment causes confusion.  So we merely indicate
-              that we access something with a known mode somewhere on
-              the stack.  */
-           use = gen_rtx_PLUS (Pmode, virtual_outgoing_args_rtx,
-                               gen_rtx_SCRATCH (Pmode));
+           {
+             /* When arguments are pushed, trying to tell alias.c where
+                exactly this argument is won't work, because the
+                auto-increment causes confusion.  So we merely indicate
+                that we access something with a known mode somewhere on
+                the stack.  */
+             use = gen_rtx_PLUS (Pmode, stack_pointer_rtx,
+                                 gen_rtx_SCRATCH (Pmode));
+             have_push_fusage = true;
+           }
          use = gen_rtx_MEM (argvec[argnum].mode, use);
          use = gen_rtx_USE (VOIDmode, use);
          call_fusage = gen_rtx_EXPR_LIST (VOIDmode, use, call_fusage);
index 41ad87e0954cd5c8857157c64ee49bbc20615f5c..3d424ce53dd63d70915328bc17f38838f9e717a4 100644 (file)
@@ -1,3 +1,8 @@
+2015-01-16  Bernd Schmidt  <bernds@codesourcery.com>
+
+       PR rtl-optimization/52773
+       * gcc.c-torture/compile/pr52773.c: New test.
+
 2015-01-16  Paolo Carlini  <paolo.carlini@oracle.com>
 
        PR c++/62134
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr52773.c b/gcc/testsuite/gcc.c-torture/compile/pr52773.c
new file mode 100644 (file)
index 0000000..8daa5ee
--- /dev/null
@@ -0,0 +1,16 @@
+/* pr52773.c */
+
+struct s {
+    short x;
+    short _pad[2];
+};
+
+static short mat_a_x;
+
+void transform(const struct s *src, struct s *dst, int n)
+{
+    int i;
+
+    for (i = 0; i < n; ++i)
+       dst[i].x = (src[i].x * mat_a_x) >> 6;
+}