Patchwork [google/gcc-4_8] Backport r198101 (fix for PR56847) into google/gcc-4_8

login
register
mail settings
Submitter Han Shen
Date April 25, 2013, 12:49 a.m.
Message ID <CACkGtria_a6h0GWF9h60HxpE3WnAUzVB2mtSZKqW36L7xGEhwA@mail.gmail.com>
Download mbox | patch
Permalink /patch/239367/
State New
Headers show

Comments

Han Shen - April 25, 2013, 12:49 a.m.
Hi, this patch back port trunk@198101 to fix PR rtl-optimization/56847.

Passed bootstrap and regression test.

Ok for branch google/gcc-4_8?

2013-04-19  Vladimir Makarov  <vmakarov@redhat.com>

        PR rtl-optimization/56847
        * lra-constraints.c (process_alt_operands): Discourage alternative
        with non-matche doffsettable memory constraint fro memory with
        known offset.



H.
Dehao Chen - April 25, 2013, 3:16 a.m.
Looks good.

Dehao

On Wed, Apr 24, 2013 at 5:49 PM, Han Shen(沈涵) <shenhan@google.com> wrote:
> Hi, this patch back port trunk@198101 to fix PR rtl-optimization/56847.
>
> Passed bootstrap and regression test.
>
> Ok for branch google/gcc-4_8?
>
> 2013-04-19  Vladimir Makarov  <vmakarov@redhat.com>
>
>         PR rtl-optimization/56847
>         * lra-constraints.c (process_alt_operands): Discourage alternative
>         with non-matche doffsettable memory constraint fro memory with
>         known offset.
>
> diff --git a/gcc/lra-constraints.c b/gcc/lra-constraints.c
> index e3b4add..9e4924c 100644
> --- a/gcc/lra-constraints.c
> +++ b/gcc/lra-constraints.c
> @@ -1978,8 +1978,15 @@ process_alt_operands (int only_alternative)
>        (op, this_alternative) == NO_REGS))))
>   reject += LRA_MAX_REJECT;
>
> -      if (! ((const_to_mem && constmemok)
> -     || (MEM_P (op) && offmemok)))
> +      if (MEM_P (op) && offmemok)
> + {
> +  /* If we know offset and this non-offsetable memory,
> +     something wrong with this memory and it is better
> +     to try other memory possibilities.  */
> +  if (MEM_OFFSET_KNOWN_P (op))
> +    reject += LRA_MAX_REJECT;
> + }
> +      else if (! (const_to_mem && constmemok))
>   {
>    /* We prefer to reload pseudos over reloading other
>       things, since such reloads may be able to be
> diff --git a/gcc/testsuite/gcc.dg/pr56847.c b/gcc/testsuite/gcc.dg/pr56847.c
> new file mode 100644
> index 0000000..b94aae1
> --- /dev/null
> +++ b/gcc/testsuite/gcc.dg/pr56847.c
> @@ -0,0 +1,12 @@
> +/* PR rtl-optimization/56847 */
> +/* { dg-do compile { target pie } } */
> +/* { dg-options "-O2 -fpie" } */
> +
> +struct S { long int a, b; } e;
> +__thread struct S s;
> +
> +void
> +foo (void)
> +{
> +  s = e;
> +}
>
>
> H.

Patch

diff --git a/gcc/lra-constraints.c b/gcc/lra-constraints.c
index e3b4add..9e4924c 100644
--- a/gcc/lra-constraints.c
+++ b/gcc/lra-constraints.c
@@ -1978,8 +1978,15 @@  process_alt_operands (int only_alternative)
       (op, this_alternative) == NO_REGS))))
  reject += LRA_MAX_REJECT;

-      if (! ((const_to_mem && constmemok)
-     || (MEM_P (op) && offmemok)))
+      if (MEM_P (op) && offmemok)
+ {
+  /* If we know offset and this non-offsetable memory,
+     something wrong with this memory and it is better
+     to try other memory possibilities.  */
+  if (MEM_OFFSET_KNOWN_P (op))
+    reject += LRA_MAX_REJECT;
+ }
+      else if (! (const_to_mem && constmemok))
  {
   /* We prefer to reload pseudos over reloading other
      things, since such reloads may be able to be
diff --git a/gcc/testsuite/gcc.dg/pr56847.c b/gcc/testsuite/gcc.dg/pr56847.c
new file mode 100644
index 0000000..b94aae1
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr56847.c
@@ -0,0 +1,12 @@ 
+/* PR rtl-optimization/56847 */
+/* { dg-do compile { target pie } } */
+/* { dg-options "-O2 -fpie" } */
+
+struct S { long int a, b; } e;
+__thread struct S s;
+
+void
+foo (void)
+{
+  s = e;
+}