diff mbox

PATCH: PR target/47372: [x32] internal compiler error: in simplify_subreg, at simplify-rtx.c:5222

Message ID 20110726194135.GA23813@intel.com
State New
Headers show

Commit Message

H.J. Lu July 26, 2011, 7:41 p.m. UTC
Hi,

Hi,

We should call simplify_gen_subreg for PIC with ptr_mode only if modes
of x and orig_x are different.  OK for trunk?

Thanks.


H.J.
---
2011-07-26  H.J. Lu  <hongjiu.lu@intel.com>

	PR target/47372
	* config/i386/i386.c (ix86_delegitimize_address): Call
	simplify_gen_subreg for PIC with ptr_mode only if modes of
	x and orig_x are different.

Comments

Uros Bizjak July 26, 2011, 8:05 p.m. UTC | #1
On Tue, Jul 26, 2011 at 9:41 PM, H.J. Lu <hongjiu.lu@intel.com> wrote:

> We should call simplify_gen_subreg for PIC with ptr_mode only if modes
> of x and orig_x are different.  OK for trunk?

Let's ask Jakub on this one...

Uros.

> 2011-07-26  H.J. Lu  <hongjiu.lu@intel.com>
>
>        PR target/47372
>        * config/i386/i386.c (ix86_delegitimize_address): Call
>        simplify_gen_subreg for PIC with ptr_mode only if modes of
>        x and orig_x are different.
>
> diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
> index 429cd62..9c52aa3 100644
> --- a/gcc/config/i386/i386.c
> +++ b/gcc/config/i386/i386.c
> @@ -12967,9 +12982,10 @@ ix86_delegitimize_address (rtx x)
>          || !MEM_P (orig_x))
>        return ix86_delegitimize_tls_address (orig_x);
>       x = XVECEXP (XEXP (x, 0), 0, 0);
> -      if (GET_MODE (orig_x) != Pmode)
> +      if (GET_MODE (orig_x) != GET_MODE (x)
> +         && GET_MODE (orig_x) != ptr_mode)
>        {
> -         x = simplify_gen_subreg (GET_MODE (orig_x), x, Pmode, 0);
> +         x = simplify_gen_subreg (GET_MODE (orig_x), x, ptr_mode, 0);
>          if (x == NULL_RTX)
>            return orig_x;
>        }
>
Jakub Jelinek July 26, 2011, 8:12 p.m. UTC | #2
On Tue, Jul 26, 2011 at 10:05:06PM +0200, Uros Bizjak wrote:
> > 2011-07-26  H.J. Lu  <hongjiu.lu@intel.com>
> >
> >        PR target/47372
> >        * config/i386/i386.c (ix86_delegitimize_address): Call
> >        simplify_gen_subreg for PIC with ptr_mode only if modes of
> >        x and orig_x are different.
> >
> > diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
> > index 429cd62..9c52aa3 100644
> > --- a/gcc/config/i386/i386.c
> > +++ b/gcc/config/i386/i386.c
> > @@ -12967,9 +12982,10 @@ ix86_delegitimize_address (rtx x)
> >          || !MEM_P (orig_x))
> >        return ix86_delegitimize_tls_address (orig_x);
> >       x = XVECEXP (XEXP (x, 0), 0, 0);

When x is no longer known to be Pmode

> > -      if (GET_MODE (orig_x) != Pmode)
> > +      if (GET_MODE (orig_x) != GET_MODE (x)
> > +         && GET_MODE (orig_x) != ptr_mode)

why not simply just
	if (GET_MODE (orig_x) != GET_MODE (x))

> >        {
> > -         x = simplify_gen_subreg (GET_MODE (orig_x), x, Pmode, 0);
> > +         x = simplify_gen_subreg (GET_MODE (orig_x), x, ptr_mode, 0);

and using GET_MODE (x) instead of Pmode/ptr_mode here?  I mean,
x is certainly not VOIDmode here, should be either SImode or DImode
and thus simplify_gen_subreg ought to work for it.

> >          if (x == NULL_RTX)
> >            return orig_x;
> >        }
> >

	Jakub
Uros Bizjak July 26, 2011, 8:21 p.m. UTC | #3
On Tue, Jul 26, 2011 at 10:12 PM, Jakub Jelinek <jakub@redhat.com> wrote:
> On Tue, Jul 26, 2011 at 10:05:06PM +0200, Uros Bizjak wrote:
>> > 2011-07-26  H.J. Lu  <hongjiu.lu@intel.com>
>> >
>> >        PR target/47372
>> >        * config/i386/i386.c (ix86_delegitimize_address): Call
>> >        simplify_gen_subreg for PIC with ptr_mode only if modes of
>> >        x and orig_x are different.
>> >
>> > diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
>> > index 429cd62..9c52aa3 100644
>> > --- a/gcc/config/i386/i386.c
>> > +++ b/gcc/config/i386/i386.c
>> > @@ -12967,9 +12982,10 @@ ix86_delegitimize_address (rtx x)
>> >          || !MEM_P (orig_x))
>> >        return ix86_delegitimize_tls_address (orig_x);
>> >       x = XVECEXP (XEXP (x, 0), 0, 0);
>
> When x is no longer known to be Pmode
>
>> > -      if (GET_MODE (orig_x) != Pmode)
>> > +      if (GET_MODE (orig_x) != GET_MODE (x)
>> > +         && GET_MODE (orig_x) != ptr_mode)
>
> why not simply just
>        if (GET_MODE (orig_x) != GET_MODE (x))
>
>> >        {
>> > -         x = simplify_gen_subreg (GET_MODE (orig_x), x, Pmode, 0);
>> > +         x = simplify_gen_subreg (GET_MODE (orig_x), x, ptr_mode, 0);
>
> and using GET_MODE (x) instead of Pmode/ptr_mode here?  I mean,
> x is certainly not VOIDmode here, should be either SImode or DImode
> and thus simplify_gen_subreg ought to work for it.

This also works, we look at orig_x that looks like:

(mem/u/c:SI (const:DI (unspec:DI [
                (symbol_ref:SI ("__sflush") [flags 0x41]
<function_decl 0x7f6f2eaad000 __sflush>)
            ] UNSPEC_GOTPCREL)) [2 S4 A8])

So, we look at SImode load, and compare it with SImode (actually
ptr_mode) symbol. Will your suggestion work with this RTX?

Thanks,
Uros.
Jakub Jelinek July 26, 2011, 8:29 p.m. UTC | #4
On Tue, Jul 26, 2011 at 10:21:11PM +0200, Uros Bizjak wrote:
> This also works, we look at orig_x that looks like:
> 
> (mem/u/c:SI (const:DI (unspec:DI [
>                 (symbol_ref:SI ("__sflush") [flags 0x41]
> <function_decl 0x7f6f2eaad000 __sflush>)
>             ] UNSPEC_GOTPCREL)) [2 S4 A8])
> 
> So, we look at SImode load, and compare it with SImode (actually
> ptr_mode) symbol. Will your suggestion work with this RTX?

Then 
      if (GET_MODE (orig_x) != GET_MODE (x))
        {
          x = simplify_gen_subreg (GET_MODE (orig_x), x, GET_MODE (x), 0);
          if (x == NULL_RTX)
            return orig_x;
        }
will work, orig_x is the above SImode MEM, x is (symbol_ref:SI ("__sflush")
[flags 0x41] <function_decl 0x7f6f2eaad000 __sflush>)
thus the modes are the same and no simplify_gen_subreg needs to be done, the
mode is already right.

	Jakub
H.J. Lu July 26, 2011, 8:33 p.m. UTC | #5
On Tue, Jul 26, 2011 at 1:29 PM, Jakub Jelinek <jakub@redhat.com> wrote:
> On Tue, Jul 26, 2011 at 10:21:11PM +0200, Uros Bizjak wrote:
>> This also works, we look at orig_x that looks like:
>>
>> (mem/u/c:SI (const:DI (unspec:DI [
>>                 (symbol_ref:SI ("__sflush") [flags 0x41]
>> <function_decl 0x7f6f2eaad000 __sflush>)
>>             ] UNSPEC_GOTPCREL)) [2 S4 A8])
>>
>> So, we look at SImode load, and compare it with SImode (actually
>> ptr_mode) symbol. Will your suggestion work with this RTX?
>
> Then
>      if (GET_MODE (orig_x) != GET_MODE (x))
>        {
>          x = simplify_gen_subreg (GET_MODE (orig_x), x, GET_MODE (x), 0);
>          if (x == NULL_RTX)
>            return orig_x;
>        }
> will work, orig_x is the above SImode MEM, x is (symbol_ref:SI ("__sflush")
> [flags 0x41] <function_decl 0x7f6f2eaad000 __sflush>)
> thus the modes are the same and no simplify_gen_subreg needs to be done, the
> mode is already right.
>

This works for my testcase. I will do a full test.

Thanks.
Uros Bizjak July 26, 2011, 8:40 p.m. UTC | #6
On Tue, Jul 26, 2011 at 10:33 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Tue, Jul 26, 2011 at 1:29 PM, Jakub Jelinek <jakub@redhat.com> wrote:
>> On Tue, Jul 26, 2011 at 10:21:11PM +0200, Uros Bizjak wrote:
>>> This also works, we look at orig_x that looks like:
>>>
>>> (mem/u/c:SI (const:DI (unspec:DI [
>>>                 (symbol_ref:SI ("__sflush") [flags 0x41]
>>> <function_decl 0x7f6f2eaad000 __sflush>)
>>>             ] UNSPEC_GOTPCREL)) [2 S4 A8])
>>>
>>> So, we look at SImode load, and compare it with SImode (actually
>>> ptr_mode) symbol. Will your suggestion work with this RTX?
>>
>> Then
>>      if (GET_MODE (orig_x) != GET_MODE (x))
>>        {
>>          x = simplify_gen_subreg (GET_MODE (orig_x), x, GET_MODE (x), 0);
>>          if (x == NULL_RTX)
>>            return orig_x;
>>        }
>> will work, orig_x is the above SImode MEM, x is (symbol_ref:SI ("__sflush")
>> [flags 0x41] <function_decl 0x7f6f2eaad000 __sflush>)
>> thus the modes are the same and no simplify_gen_subreg needs to be done, the
>> mode is already right.
>>
>
> This works for my testcase. I will do a full test.

Also OK for mainline, wih suitable ChangeLog and bootstrap/regression test.

BTW: I'm thinking of removing this check from ix86_expand_move:

@@ -15034,7 +15034,6 @@ ix86_expand_move (enum machine_mode mode
     }

   if ((flag_pic || MACHOPIC_INDIRECT)
-      && (mode == SImode || mode == DImode)
       && symbolic_operand (op1, mode))
     {
       if (TARGET_MACHO && !TARGET_64BIT)

There is no way symbolic_operand would be in different mode than SImode/DImode.

Uros.
diff mbox

Patch

diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index 429cd62..9c52aa3 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -12967,9 +12982,10 @@  ix86_delegitimize_address (rtx x)
 	  || !MEM_P (orig_x))
 	return ix86_delegitimize_tls_address (orig_x);
       x = XVECEXP (XEXP (x, 0), 0, 0);
-      if (GET_MODE (orig_x) != Pmode)
+      if (GET_MODE (orig_x) != GET_MODE (x) 
+	  && GET_MODE (orig_x) != ptr_mode)
 	{
-	  x = simplify_gen_subreg (GET_MODE (orig_x), x, Pmode, 0);
+	  x = simplify_gen_subreg (GET_MODE (orig_x), x, ptr_mode, 0);
 	  if (x == NULL_RTX)
 	    return orig_x;
 	}