public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH 1/2] Revert PR49721's patch
  2014-08-09  3:51 [middle-end/PATCH 0/2] Fix AARCH64 ILP32 ld.so miscompiling Andrew Pinski
@ 2014-08-09  3:51 ` Andrew Pinski
  2014-10-13 22:35   ` Andrew Pinski
  2014-08-09  3:51 ` [PATCH 2/2] Fix ILP32 ld.so Andrew Pinski
  2014-09-11  4:50 ` [middle-end/PATCH 0/2] Fix AARCH64 ILP32 ld.so miscompiling Andrew Pinski
  2 siblings, 1 reply; 12+ messages in thread
From: Andrew Pinski @ 2014-08-09  3:51 UTC (permalink / raw)
  To: gcc-patches; +Cc: Andrew Pinski

OK? When the second patch is approved?

Thanks,
Andrew Pinski

ChangeLog:
	Revert:
	2011-08-19  H.J. Lu  <hongjiu.lu@intel.com>

        PR middle-end/49721
        * explow.c (convert_memory_address_addr_space): Also permute the
        conversion and addition of constant for zero-extend.

---
 gcc/explow.c |   19 +++++++------------
 1 files changed, 7 insertions(+), 12 deletions(-)

diff --git a/gcc/explow.c b/gcc/explow.c
index 92c4e57..eb7dc85 100644
--- a/gcc/explow.c
+++ b/gcc/explow.c
@@ -376,23 +376,18 @@ convert_memory_address_addr_space (enum machine_mode to_mode ATTRIBUTE_UNUSED,
 
     case PLUS:
     case MULT:
-      /* FIXME: For addition, we used to permute the conversion and
-	 addition operation only if one operand is a constant and
-	 converting the constant does not change it or if one operand
-	 is a constant and we are using a ptr_extend instruction
-	 (POINTERS_EXTEND_UNSIGNED < 0) even if the resulting address
-	 may overflow/underflow.  We relax the condition to include
-	 zero-extend (POINTERS_EXTEND_UNSIGNED > 0) since the other
-	 parts of the compiler depend on it.  See PR 49721.
-
+      /* For addition we can safely permute the conversion and addition
+	 operation if one operand is a constant and converting the constant
+	 does not change it or if one operand is a constant and we are
+	 using a ptr_extend instruction  (POINTERS_EXTEND_UNSIGNED < 0).
 	 We can always safely permute them if we are making the address
 	 narrower.  */
       if (GET_MODE_SIZE (to_mode) < GET_MODE_SIZE (from_mode)
 	  || (GET_CODE (x) == PLUS
 	      && CONST_INT_P (XEXP (x, 1))
-	      && (POINTERS_EXTEND_UNSIGNED != 0
-		  || XEXP (x, 1) == convert_memory_address_addr_space
-		  			(to_mode, XEXP (x, 1), as))))
+	      && (XEXP (x, 1) == convert_memory_address_addr_space
+				   (to_mode, XEXP (x, 1), as)
+                 || POINTERS_EXTEND_UNSIGNED < 0)))
 	return gen_rtx_fmt_ee (GET_CODE (x), to_mode,
 			       convert_memory_address_addr_space
 				 (to_mode, XEXP (x, 0), as),
-- 
1.7.2.5

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 2/2] Fix ILP32 ld.so.
  2014-08-09  3:51 [middle-end/PATCH 0/2] Fix AARCH64 ILP32 ld.so miscompiling Andrew Pinski
  2014-08-09  3:51 ` [PATCH 1/2] Revert PR49721's patch Andrew Pinski
@ 2014-08-09  3:51 ` Andrew Pinski
  2014-10-13 22:40   ` Andrew Pinski
                     ` (2 more replies)
  2014-09-11  4:50 ` [middle-end/PATCH 0/2] Fix AARCH64 ILP32 ld.so miscompiling Andrew Pinski
  2 siblings, 3 replies; 12+ messages in thread
From: Andrew Pinski @ 2014-08-09  3:51 UTC (permalink / raw)
  To: gcc-patches; +Cc: Andrew Pinski

This patch fixes the original problem that HJL was having with x32 in
PR 47727, it is more constraint than HJL's patch only care about what
is happening inside a CONST;  if we allow it for other cases,
the RTL and generated code is incorrect as it does not have the needed
zero extend.  This allows ILP32 to work correctlya and allows &a + 2 to
be still generated correctly when doing a convert_memory_address_addr_space.


OK?  Bootstrapped and tested on x86_64-linux-gnu (though not with x32 but
visually looked at the failing testcase with a much older compiler).
Also tested on aarch64-linux-gnu with no regressions and also fixing ld.so
for ILP32.

Thanks,
Andrew Pinski

ChangeLog:
	* explow.c (convert_memory_address_addr_space): Rename to ...
	(convert_memory_address_addr_space_1): This.  Add in_const argument.
	Inside a CONST RTL, permute the conversion and addition of constant
	for zero and sign extended pointers.
	(convert_memory_address_addr_space): New function.


---
 gcc/explow.c |   40 ++++++++++++++++++++++++++++------------
 1 files changed, 28 insertions(+), 12 deletions(-)

diff --git a/gcc/explow.c b/gcc/explow.c
index eb7dc85..64017a0 100644
--- a/gcc/explow.c
+++ b/gcc/explow.c
@@ -310,11 +310,13 @@ break_out_memory_refs (rtx x)
    an address in the address space's address mode, or vice versa (TO_MODE says
    which way).  We take advantage of the fact that pointers are not allowed to
    overflow by commuting arithmetic operations over conversions so that address
-   arithmetic insns can be used.  */
+   arithmetic insns can be used. IN_CONST is true if this conversion is inside
+   a CONST.  */
 
-rtx
-convert_memory_address_addr_space (enum machine_mode to_mode ATTRIBUTE_UNUSED,
-				   rtx x, addr_space_t as ATTRIBUTE_UNUSED)
+static rtx
+convert_memory_address_addr_space_1 (enum machine_mode to_mode ATTRIBUTE_UNUSED,
+				     rtx x, addr_space_t as ATTRIBUTE_UNUSED,
+				     bool in_const)
 {
 #ifndef POINTERS_EXTEND_UNSIGNED
   gcc_assert (GET_MODE (x) == to_mode || GET_MODE (x) == VOIDmode);
@@ -370,8 +372,8 @@ convert_memory_address_addr_space (enum machine_mode to_mode ATTRIBUTE_UNUSED,
 
     case CONST:
       return gen_rtx_CONST (to_mode,
-			    convert_memory_address_addr_space
-			      (to_mode, XEXP (x, 0), as));
+			    convert_memory_address_addr_space_1
+			      (to_mode, XEXP (x, 0), as, true));
       break;
 
     case PLUS:
@@ -381,16 +383,18 @@ convert_memory_address_addr_space (enum machine_mode to_mode ATTRIBUTE_UNUSED,
 	 does not change it or if one operand is a constant and we are
 	 using a ptr_extend instruction  (POINTERS_EXTEND_UNSIGNED < 0).
 	 We can always safely permute them if we are making the address
-	 narrower.  */
+	 narrower. Inside a CONST RTL, this is safe for both pointers
+	 zero or sign extended as pointers cannot wrap. */
       if (GET_MODE_SIZE (to_mode) < GET_MODE_SIZE (from_mode)
 	  || (GET_CODE (x) == PLUS
 	      && CONST_INT_P (XEXP (x, 1))
-	      && (XEXP (x, 1) == convert_memory_address_addr_space
-				   (to_mode, XEXP (x, 1), as)
-                 || POINTERS_EXTEND_UNSIGNED < 0)))
+	      && ((in_const && POINTERS_EXTEND_UNSIGNED !=0)
+		  || XEXP (x, 1) == convert_memory_address_addr_space_1
+				     (to_mode, XEXP (x, 1), as, in_const)
+                  || POINTERS_EXTEND_UNSIGNED < 0)))
 	return gen_rtx_fmt_ee (GET_CODE (x), to_mode,
-			       convert_memory_address_addr_space
-				 (to_mode, XEXP (x, 0), as),
+			       convert_memory_address_addr_space_1
+				 (to_mode, XEXP (x, 0), as, in_const),
 			       XEXP (x, 1));
       break;
 
@@ -402,6 +406,18 @@ convert_memory_address_addr_space (enum machine_mode to_mode ATTRIBUTE_UNUSED,
 			x, POINTERS_EXTEND_UNSIGNED);
 #endif /* defined(POINTERS_EXTEND_UNSIGNED) */
 }
+
+/* Given X, a memory address in address space AS' pointer mode, convert it to
+   an address in the address space's address mode, or vice versa (TO_MODE says
+   which way).  We take advantage of the fact that pointers are not allowed to
+   overflow by commuting arithmetic operations over conversions so that address
+   arithmetic insns can be used.  */
+
+rtx
+convert_memory_address_addr_space (enum machine_mode to_mode, rtx x, addr_space_t as)
+{
+  return convert_memory_address_addr_space_1 (to_mode, x, as, false);
+}
 \f
 /* Return something equivalent to X but valid as a memory address for something
    of mode MODE in the named address space AS.  When X is not itself valid,
-- 
1.7.2.5

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [middle-end/PATCH 0/2] Fix AARCH64 ILP32 ld.so miscompiling
@ 2014-08-09  3:51 Andrew Pinski
  2014-08-09  3:51 ` [PATCH 1/2] Revert PR49721's patch Andrew Pinski
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Andrew Pinski @ 2014-08-09  3:51 UTC (permalink / raw)
  To: gcc-patches; +Cc: Andrew Pinski

The problem is that HJL's patch in 2011 to try and fix his miscompiling of x32
ld.so was in fact incorrect and causes problems with AARCH64 ILP32.
The testcase which is being miscompiled after HJL's patch (which he was also
trying to fix up with his patch on x32):
void f(int *a, int b, long long d) __attribute__((noinline,noclone));
void f(int *a, int b, long long d)
{
   if((0x6ffffeff - b) < 11)
     a[(0x6ffffeff - b) +34+0+16+3+12] = d;
}

int main(void)
{
  int *d = (int*)(int)0xfffefe90;
  f(d, 0x6ffffeff, -1);
  if (d[34+0+16+3+12] != -1)
    __builtin_abort();

  __builtin_printf("Works.\n");
  return 0;
}
--- CUT ---
The tree level in optimized for AARCH64 looks like:
  _72 = _48 * 4294967292;
  _73 = _72 + 3221224704;
  _74 = &MEM[(struct link_map *)&FRAME.21].l_info + _73;
  *_74 = dyn_15;

Expand then comes along and does not the addition with a zero extend so we
get the following AARCH64 assembly code:
	madd	w2, w2, w6, w0
	mov	x0, -1073741825
	movk	x0, 0xfac8, lsl 0
	str	w3, [x2, x0]

Notice how we have an addition inside the store, since the address will
overflow we get the incorrect address where the store is happening (the
address would have the 33rd bit set).

These two patches have been tested on aarch64-linux-gnu (including testing
with ILP32 multi-lib) with no regression.

The first patch reverts HJL's patch and the second one fixes the issue
which HJL was trying to fix in the first place; I will explain how
in the email with the patch.

Thanks,
Andrew Pinski


Andrew Pinski (2):
  Revert:     2011-08-19  H.J. Lu  <hongjiu.lu@intel.com>
  Fix ILP32 ld.so.

 gcc/explow.c |   53 ++++++++++++++++++++++++++++++++---------------------
 1 files changed, 32 insertions(+), 21 deletions(-)

-- 
1.7.2.5

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [middle-end/PATCH 0/2] Fix AARCH64 ILP32 ld.so miscompiling
  2014-08-09  3:51 [middle-end/PATCH 0/2] Fix AARCH64 ILP32 ld.so miscompiling Andrew Pinski
  2014-08-09  3:51 ` [PATCH 1/2] Revert PR49721's patch Andrew Pinski
  2014-08-09  3:51 ` [PATCH 2/2] Fix ILP32 ld.so Andrew Pinski
@ 2014-09-11  4:50 ` Andrew Pinski
  2 siblings, 0 replies; 12+ messages in thread
From: Andrew Pinski @ 2014-09-11  4:50 UTC (permalink / raw)
  To: Andrew Pinski; +Cc: GCC Patches

Ping.

On Fri, Aug 8, 2014 at 8:51 PM, Andrew Pinski <apinski@cavium.com> wrote:
> The problem is that HJL's patch in 2011 to try and fix his miscompiling of x32
> ld.so was in fact incorrect and causes problems with AARCH64 ILP32.
> The testcase which is being miscompiled after HJL's patch (which he was also
> trying to fix up with his patch on x32):
> void f(int *a, int b, long long d) __attribute__((noinline,noclone));
> void f(int *a, int b, long long d)
> {
>    if((0x6ffffeff - b) < 11)
>      a[(0x6ffffeff - b) +34+0+16+3+12] = d;
> }
>
> int main(void)
> {
>   int *d = (int*)(int)0xfffefe90;
>   f(d, 0x6ffffeff, -1);
>   if (d[34+0+16+3+12] != -1)
>     __builtin_abort();
>
>   __builtin_printf("Works.\n");
>   return 0;
> }
> --- CUT ---
> The tree level in optimized for AARCH64 looks like:
>   _72 = _48 * 4294967292;
>   _73 = _72 + 3221224704;
>   _74 = &MEM[(struct link_map *)&FRAME.21].l_info + _73;
>   *_74 = dyn_15;
>
> Expand then comes along and does not the addition with a zero extend so we
> get the following AARCH64 assembly code:
>         madd    w2, w2, w6, w0
>         mov     x0, -1073741825
>         movk    x0, 0xfac8, lsl 0
>         str     w3, [x2, x0]
>
> Notice how we have an addition inside the store, since the address will
> overflow we get the incorrect address where the store is happening (the
> address would have the 33rd bit set).
>
> These two patches have been tested on aarch64-linux-gnu (including testing
> with ILP32 multi-lib) with no regression.
>
> The first patch reverts HJL's patch and the second one fixes the issue
> which HJL was trying to fix in the first place; I will explain how
> in the email with the patch.
>
> Thanks,
> Andrew Pinski
>
>
> Andrew Pinski (2):
>   Revert:     2011-08-19  H.J. Lu  <hongjiu.lu@intel.com>
>   Fix ILP32 ld.so.
>
>  gcc/explow.c |   53 ++++++++++++++++++++++++++++++++---------------------
>  1 files changed, 32 insertions(+), 21 deletions(-)
>
> --
> 1.7.2.5
>

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 1/2] Revert PR49721's patch
  2014-08-09  3:51 ` [PATCH 1/2] Revert PR49721's patch Andrew Pinski
@ 2014-10-13 22:35   ` Andrew Pinski
  2014-10-14  9:40     ` Richard Biener
                       ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Andrew Pinski @ 2014-10-13 22:35 UTC (permalink / raw)
  To: Andrew Pinski; +Cc: GCC Patches

On Fri, Aug 8, 2014 at 8:51 PM, Andrew Pinski <apinski@cavium.com> wrote:
> OK? When the second patch is approved?

Ping?

>
> Thanks,
> Andrew Pinski
>
> ChangeLog:
>         Revert:
>         2011-08-19  H.J. Lu  <hongjiu.lu@intel.com>
>
>         PR middle-end/49721
>         * explow.c (convert_memory_address_addr_space): Also permute the
>         conversion and addition of constant for zero-extend.
>
> ---
>  gcc/explow.c |   19 +++++++------------
>  1 files changed, 7 insertions(+), 12 deletions(-)
>
> diff --git a/gcc/explow.c b/gcc/explow.c
> index 92c4e57..eb7dc85 100644
> --- a/gcc/explow.c
> +++ b/gcc/explow.c
> @@ -376,23 +376,18 @@ convert_memory_address_addr_space (enum machine_mode to_mode ATTRIBUTE_UNUSED,
>
>      case PLUS:
>      case MULT:
> -      /* FIXME: For addition, we used to permute the conversion and
> -        addition operation only if one operand is a constant and
> -        converting the constant does not change it or if one operand
> -        is a constant and we are using a ptr_extend instruction
> -        (POINTERS_EXTEND_UNSIGNED < 0) even if the resulting address
> -        may overflow/underflow.  We relax the condition to include
> -        zero-extend (POINTERS_EXTEND_UNSIGNED > 0) since the other
> -        parts of the compiler depend on it.  See PR 49721.
> -
> +      /* For addition we can safely permute the conversion and addition
> +        operation if one operand is a constant and converting the constant
> +        does not change it or if one operand is a constant and we are
> +        using a ptr_extend instruction  (POINTERS_EXTEND_UNSIGNED < 0).
>          We can always safely permute them if we are making the address
>          narrower.  */
>        if (GET_MODE_SIZE (to_mode) < GET_MODE_SIZE (from_mode)
>           || (GET_CODE (x) == PLUS
>               && CONST_INT_P (XEXP (x, 1))
> -             && (POINTERS_EXTEND_UNSIGNED != 0
> -                 || XEXP (x, 1) == convert_memory_address_addr_space
> -                                       (to_mode, XEXP (x, 1), as))))
> +             && (XEXP (x, 1) == convert_memory_address_addr_space
> +                                  (to_mode, XEXP (x, 1), as)
> +                 || POINTERS_EXTEND_UNSIGNED < 0)))
>         return gen_rtx_fmt_ee (GET_CODE (x), to_mode,
>                                convert_memory_address_addr_space
>                                  (to_mode, XEXP (x, 0), as),
> --
> 1.7.2.5
>

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 2/2] Fix ILP32 ld.so.
  2014-08-09  3:51 ` [PATCH 2/2] Fix ILP32 ld.so Andrew Pinski
@ 2014-10-13 22:40   ` Andrew Pinski
  2014-10-14 18:44   ` Richard Henderson
  2014-10-15  8:25   ` Andreas Schwab
  2 siblings, 0 replies; 12+ messages in thread
From: Andrew Pinski @ 2014-10-13 22:40 UTC (permalink / raw)
  To: Andrew Pinski; +Cc: GCC Patches

On Fri, Aug 8, 2014 at 8:51 PM, Andrew Pinski <apinski@cavium.com> wrote:
> This patch fixes the original problem that HJL was having with x32 in
> PR 47727, it is more constraint than HJL's patch only care about what
> is happening inside a CONST;  if we allow it for other cases,
> the RTL and generated code is incorrect as it does not have the needed
> zero extend.  This allows ILP32 to work correctlya and allows &a + 2 to
> be still generated correctly when doing a convert_memory_address_addr_space.
>
>
> OK?  Bootstrapped and tested on x86_64-linux-gnu (though not with x32 but
> visually looked at the failing testcase with a much older compiler).
> Also tested on aarch64-linux-gnu with no regressions and also fixing ld.so
> for ILP32.

Ping?

>
> Thanks,
> Andrew Pinski
>
> ChangeLog:
>         * explow.c (convert_memory_address_addr_space): Rename to ...
>         (convert_memory_address_addr_space_1): This.  Add in_const argument.
>         Inside a CONST RTL, permute the conversion and addition of constant
>         for zero and sign extended pointers.
>         (convert_memory_address_addr_space): New function.
>
>
> ---
>  gcc/explow.c |   40 ++++++++++++++++++++++++++++------------
>  1 files changed, 28 insertions(+), 12 deletions(-)
>
> diff --git a/gcc/explow.c b/gcc/explow.c
> index eb7dc85..64017a0 100644
> --- a/gcc/explow.c
> +++ b/gcc/explow.c
> @@ -310,11 +310,13 @@ break_out_memory_refs (rtx x)
>     an address in the address space's address mode, or vice versa (TO_MODE says
>     which way).  We take advantage of the fact that pointers are not allowed to
>     overflow by commuting arithmetic operations over conversions so that address
> -   arithmetic insns can be used.  */
> +   arithmetic insns can be used. IN_CONST is true if this conversion is inside
> +   a CONST.  */
>
> -rtx
> -convert_memory_address_addr_space (enum machine_mode to_mode ATTRIBUTE_UNUSED,
> -                                  rtx x, addr_space_t as ATTRIBUTE_UNUSED)
> +static rtx
> +convert_memory_address_addr_space_1 (enum machine_mode to_mode ATTRIBUTE_UNUSED,
> +                                    rtx x, addr_space_t as ATTRIBUTE_UNUSED,
> +                                    bool in_const)
>  {
>  #ifndef POINTERS_EXTEND_UNSIGNED
>    gcc_assert (GET_MODE (x) == to_mode || GET_MODE (x) == VOIDmode);
> @@ -370,8 +372,8 @@ convert_memory_address_addr_space (enum machine_mode to_mode ATTRIBUTE_UNUSED,
>
>      case CONST:
>        return gen_rtx_CONST (to_mode,
> -                           convert_memory_address_addr_space
> -                             (to_mode, XEXP (x, 0), as));
> +                           convert_memory_address_addr_space_1
> +                             (to_mode, XEXP (x, 0), as, true));
>        break;
>
>      case PLUS:
> @@ -381,16 +383,18 @@ convert_memory_address_addr_space (enum machine_mode to_mode ATTRIBUTE_UNUSED,
>          does not change it or if one operand is a constant and we are
>          using a ptr_extend instruction  (POINTERS_EXTEND_UNSIGNED < 0).
>          We can always safely permute them if we are making the address
> -        narrower.  */
> +        narrower. Inside a CONST RTL, this is safe for both pointers
> +        zero or sign extended as pointers cannot wrap. */
>        if (GET_MODE_SIZE (to_mode) < GET_MODE_SIZE (from_mode)
>           || (GET_CODE (x) == PLUS
>               && CONST_INT_P (XEXP (x, 1))
> -             && (XEXP (x, 1) == convert_memory_address_addr_space
> -                                  (to_mode, XEXP (x, 1), as)
> -                 || POINTERS_EXTEND_UNSIGNED < 0)))
> +             && ((in_const && POINTERS_EXTEND_UNSIGNED !=0)
> +                 || XEXP (x, 1) == convert_memory_address_addr_space_1
> +                                    (to_mode, XEXP (x, 1), as, in_const)
> +                  || POINTERS_EXTEND_UNSIGNED < 0)))
>         return gen_rtx_fmt_ee (GET_CODE (x), to_mode,
> -                              convert_memory_address_addr_space
> -                                (to_mode, XEXP (x, 0), as),
> +                              convert_memory_address_addr_space_1
> +                                (to_mode, XEXP (x, 0), as, in_const),
>                                XEXP (x, 1));
>        break;
>
> @@ -402,6 +406,18 @@ convert_memory_address_addr_space (enum machine_mode to_mode ATTRIBUTE_UNUSED,
>                         x, POINTERS_EXTEND_UNSIGNED);
>  #endif /* defined(POINTERS_EXTEND_UNSIGNED) */
>  }
> +
> +/* Given X, a memory address in address space AS' pointer mode, convert it to
> +   an address in the address space's address mode, or vice versa (TO_MODE says
> +   which way).  We take advantage of the fact that pointers are not allowed to
> +   overflow by commuting arithmetic operations over conversions so that address
> +   arithmetic insns can be used.  */
> +
> +rtx
> +convert_memory_address_addr_space (enum machine_mode to_mode, rtx x, addr_space_t as)
> +{
> +  return convert_memory_address_addr_space_1 (to_mode, x, as, false);
> +}
>
>  /* Return something equivalent to X but valid as a memory address for something
>     of mode MODE in the named address space AS.  When X is not itself valid,
> --
> 1.7.2.5
>

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 1/2] Revert PR49721's patch
  2014-10-13 22:35   ` Andrew Pinski
@ 2014-10-14  9:40     ` Richard Biener
  2014-10-15 17:31     ` Jeff Law
  2014-10-15 17:33     ` Jeff Law
  2 siblings, 0 replies; 12+ messages in thread
From: Richard Biener @ 2014-10-14  9:40 UTC (permalink / raw)
  To: Andrew Pinski; +Cc: Andrew Pinski, GCC Patches

On Tue, Oct 14, 2014 at 12:35 AM, Andrew Pinski <pinskia@gmail.com> wrote:
> On Fri, Aug 8, 2014 at 8:51 PM, Andrew Pinski <apinski@cavium.com> wrote:
>> OK? When the second patch is approved?
>
> Ping?

Ok if the second patch was approved.

Richard.

>>
>> Thanks,
>> Andrew Pinski
>>
>> ChangeLog:
>>         Revert:
>>         2011-08-19  H.J. Lu  <hongjiu.lu@intel.com>
>>
>>         PR middle-end/49721
>>         * explow.c (convert_memory_address_addr_space): Also permute the
>>         conversion and addition of constant for zero-extend.
>>
>> ---
>>  gcc/explow.c |   19 +++++++------------
>>  1 files changed, 7 insertions(+), 12 deletions(-)
>>
>> diff --git a/gcc/explow.c b/gcc/explow.c
>> index 92c4e57..eb7dc85 100644
>> --- a/gcc/explow.c
>> +++ b/gcc/explow.c
>> @@ -376,23 +376,18 @@ convert_memory_address_addr_space (enum machine_mode to_mode ATTRIBUTE_UNUSED,
>>
>>      case PLUS:
>>      case MULT:
>> -      /* FIXME: For addition, we used to permute the conversion and
>> -        addition operation only if one operand is a constant and
>> -        converting the constant does not change it or if one operand
>> -        is a constant and we are using a ptr_extend instruction
>> -        (POINTERS_EXTEND_UNSIGNED < 0) even if the resulting address
>> -        may overflow/underflow.  We relax the condition to include
>> -        zero-extend (POINTERS_EXTEND_UNSIGNED > 0) since the other
>> -        parts of the compiler depend on it.  See PR 49721.
>> -
>> +      /* For addition we can safely permute the conversion and addition
>> +        operation if one operand is a constant and converting the constant
>> +        does not change it or if one operand is a constant and we are
>> +        using a ptr_extend instruction  (POINTERS_EXTEND_UNSIGNED < 0).
>>          We can always safely permute them if we are making the address
>>          narrower.  */
>>        if (GET_MODE_SIZE (to_mode) < GET_MODE_SIZE (from_mode)
>>           || (GET_CODE (x) == PLUS
>>               && CONST_INT_P (XEXP (x, 1))
>> -             && (POINTERS_EXTEND_UNSIGNED != 0
>> -                 || XEXP (x, 1) == convert_memory_address_addr_space
>> -                                       (to_mode, XEXP (x, 1), as))))
>> +             && (XEXP (x, 1) == convert_memory_address_addr_space
>> +                                  (to_mode, XEXP (x, 1), as)
>> +                 || POINTERS_EXTEND_UNSIGNED < 0)))
>>         return gen_rtx_fmt_ee (GET_CODE (x), to_mode,
>>                                convert_memory_address_addr_space
>>                                  (to_mode, XEXP (x, 0), as),
>> --
>> 1.7.2.5
>>

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 2/2] Fix ILP32 ld.so.
  2014-08-09  3:51 ` [PATCH 2/2] Fix ILP32 ld.so Andrew Pinski
  2014-10-13 22:40   ` Andrew Pinski
@ 2014-10-14 18:44   ` Richard Henderson
  2014-10-15  8:25   ` Andreas Schwab
  2 siblings, 0 replies; 12+ messages in thread
From: Richard Henderson @ 2014-10-14 18:44 UTC (permalink / raw)
  To: Andrew Pinski, gcc-patches

On 08/08/2014 08:51 PM, Andrew Pinski wrote:
> ChangeLog:
> 	* explow.c (convert_memory_address_addr_space): Rename to ...
> 	(convert_memory_address_addr_space_1): This.  Add in_const argument.
> 	Inside a CONST RTL, permute the conversion and addition of constant
> 	for zero and sign extended pointers.
> 	(convert_memory_address_addr_space): New function.

Ok, with one nit...

> +	      && ((in_const && POINTERS_EXTEND_UNSIGNED !=0)

Missing space after !=


r~

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 2/2] Fix ILP32 ld.so.
  2014-08-09  3:51 ` [PATCH 2/2] Fix ILP32 ld.so Andrew Pinski
  2014-10-13 22:40   ` Andrew Pinski
  2014-10-14 18:44   ` Richard Henderson
@ 2014-10-15  8:25   ` Andreas Schwab
  2 siblings, 0 replies; 12+ messages in thread
From: Andreas Schwab @ 2014-10-15  8:25 UTC (permalink / raw)
  To: Andrew Pinski; +Cc: gcc-patches

Tested on ia64-suse-linux and installed as obvious.

Andreas.

	* explow.c (convert_memory_address_addr_space_1): Mark in_const
	as ATTRIBUTE_UNUSED.

Index: explow.c
===================================================================
--- explow.c	(revision 216239)
+++ explow.c	(working copy)
@@ -316,7 +316,7 @@
 static rtx
 convert_memory_address_addr_space_1 (enum machine_mode to_mode ATTRIBUTE_UNUSED,
 				     rtx x, addr_space_t as ATTRIBUTE_UNUSED,
-				     bool in_const)
+				     bool in_const ATTRIBUTE_UNUSED)
 {
 #ifndef POINTERS_EXTEND_UNSIGNED
   gcc_assert (GET_MODE (x) == to_mode || GET_MODE (x) == VOIDmode);

-- 
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 1/2] Revert PR49721's patch
  2014-10-13 22:35   ` Andrew Pinski
  2014-10-14  9:40     ` Richard Biener
@ 2014-10-15 17:31     ` Jeff Law
  2014-10-15 17:32       ` Andrew Pinski
  2014-10-15 17:33     ` Jeff Law
  2 siblings, 1 reply; 12+ messages in thread
From: Jeff Law @ 2014-10-15 17:31 UTC (permalink / raw)
  To: Andrew Pinski, Andrew Pinski; +Cc: GCC Patches

On 10/13/14 16:35, Andrew Pinski wrote:
> On Fri, Aug 8, 2014 at 8:51 PM, Andrew Pinski <apinski@cavium.com> wrote:
>> OK? When the second patch is approved?
>
> Ping?
>
>>
>> Thanks,
>> Andrew Pinski
>>
>> ChangeLog:
>>          Revert:
>>          2011-08-19  H.J. Lu  <hongjiu.lu@intel.com>
>>
>>          PR middle-end/49721
>>          * explow.c (convert_memory_address_addr_space): Also permute the
>>          conversion and addition of constant for zero-extend.
OK if/when 2nd patch is approved.  As far as I can tell, it hasn't been 
approved yet.

jeff

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 1/2] Revert PR49721's patch
  2014-10-15 17:31     ` Jeff Law
@ 2014-10-15 17:32       ` Andrew Pinski
  0 siblings, 0 replies; 12+ messages in thread
From: Andrew Pinski @ 2014-10-15 17:32 UTC (permalink / raw)
  To: Jeff Law; +Cc: Andrew Pinski, GCC Patches

On Wed, Oct 15, 2014 at 10:29 AM, Jeff Law <law@redhat.com> wrote:
> On 10/13/14 16:35, Andrew Pinski wrote:
>>
>> On Fri, Aug 8, 2014 at 8:51 PM, Andrew Pinski <apinski@cavium.com> wrote:
>>>
>>> OK? When the second patch is approved?
>>
>>
>> Ping?
>>
>>>
>>> Thanks,
>>> Andrew Pinski
>>>
>>> ChangeLog:
>>>          Revert:
>>>          2011-08-19  H.J. Lu  <hongjiu.lu@intel.com>
>>>
>>>          PR middle-end/49721
>>>          * explow.c (convert_memory_address_addr_space): Also permute the
>>>          conversion and addition of constant for zero-extend.
>
> OK if/when 2nd patch is approved.  As far as I can tell, it hasn't been
> approved yet.

Both patches were approved yesterday.  Richard Biener approved this
one and Richard Henderson approved the second patch with a minor
change.

Thanks,
Andrew

>
> jeff
>

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 1/2] Revert PR49721's patch
  2014-10-13 22:35   ` Andrew Pinski
  2014-10-14  9:40     ` Richard Biener
  2014-10-15 17:31     ` Jeff Law
@ 2014-10-15 17:33     ` Jeff Law
  2 siblings, 0 replies; 12+ messages in thread
From: Jeff Law @ 2014-10-15 17:33 UTC (permalink / raw)
  To: Andrew Pinski, Andrew Pinski; +Cc: GCC Patches

On 10/13/14 16:35, Andrew Pinski wrote:
> On Fri, Aug 8, 2014 at 8:51 PM, Andrew Pinski <apinski@cavium.com> wrote:
>> OK? When the second patch is approved?
>
> Ping?
Nevermind my comments, both were approved in the last day or two.

jeff

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2014-10-15 17:32 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-09  3:51 [middle-end/PATCH 0/2] Fix AARCH64 ILP32 ld.so miscompiling Andrew Pinski
2014-08-09  3:51 ` [PATCH 1/2] Revert PR49721's patch Andrew Pinski
2014-10-13 22:35   ` Andrew Pinski
2014-10-14  9:40     ` Richard Biener
2014-10-15 17:31     ` Jeff Law
2014-10-15 17:32       ` Andrew Pinski
2014-10-15 17:33     ` Jeff Law
2014-08-09  3:51 ` [PATCH 2/2] Fix ILP32 ld.so Andrew Pinski
2014-10-13 22:40   ` Andrew Pinski
2014-10-14 18:44   ` Richard Henderson
2014-10-15  8:25   ` Andreas Schwab
2014-09-11  4:50 ` [middle-end/PATCH 0/2] Fix AARCH64 ILP32 ld.so miscompiling Andrew Pinski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).