diff mbox

PATCH [9/n] X32: PR target/49798: Zero-extend symbol address to 64bit if needed

Message ID CAMe9rOr_DWO9ac04F2zv_Un0_xSUqmvp55fLeHaDPi4P=DRuDA@mail.gmail.com
State New
Headers show

Commit Message

H.J. Lu July 21, 2011, 4:13 p.m. UTC
On Wed, Jul 20, 2011 at 9:06 PM, H.J. Lu <hongjiu.lu@intel.com> wrote:
> The testcase is gcc.c-torture/compile/pr45728.c.  This patch zero-extends
> symbol address to 64bit if needd.  OK for trunk?
>
> Thanks.
>
>
> H.J.
> ----
> 2011-07-20  H.J. Lu  <hongjiu.lu@intel.com>
>
>        PR target/49798
>        * config/i386/i386.c (ix86_asm_integer): New.
>        (TARGET_ASM_INTEGER): Likewise.
>

This is the updated patch, using the same approach in sparc_assemble_integer.
OK for trunk?

Thanks.

H.J.

Comments

Richard Henderson July 21, 2011, 4:15 p.m. UTC | #1
On 07/21/2011 09:13 AM, H.J. Lu wrote:
>> >        PR target/49798
>> >        * config/i386/i386.c (ix86_asm_integer): New.
>> >        (TARGET_ASM_INTEGER): Likewise.
>> >
> This is the updated patch, using the same approach in sparc_assemble_integer.
> OK for trunk?

Is there any reason why we don't simply accept .quad in the assembler?
It seems like this is making us jump through hoops for no reason.


r~
H.J. Lu July 21, 2011, 4:20 p.m. UTC | #2
On Thu, Jul 21, 2011 at 9:15 AM, Richard Henderson <rth@redhat.com> wrote:
> On 07/21/2011 09:13 AM, H.J. Lu wrote:
>>> >        PR target/49798
>>> >        * config/i386/i386.c (ix86_asm_integer): New.
>>> >        (TARGET_ASM_INTEGER): Likewise.
>>> >
>> This is the updated patch, using the same approach in sparc_assemble_integer.
>> OK for trunk?
>
> Is there any reason why we don't simply accept .quad in the assembler?
> It seems like this is making us jump through hoops for no reason.
>

".quad  symbol" isn't really valid for 32bit.  I can add a new
".xquad" directive,
similar to ".xword" for sparc, to treat it as

.long symbol
.long 0

If this is preferred, I can prepare a new patch to generate ".xquad".
Richard Henderson July 21, 2011, 4:23 p.m. UTC | #3
On 07/21/2011 09:20 AM, H.J. Lu wrote:
> ".quad  symbol" isn't really valid for 32bit. 

Why not?  We certainly know what value to put there.

> I can add a new ".xquad" directive,
> similar to ".xword" for sparc...

That seems like exactly the same meaningless complication.


r~
H.J. Lu July 21, 2011, 4:28 p.m. UTC | #4
On Thu, Jul 21, 2011 at 9:23 AM, Richard Henderson <rth@redhat.com> wrote:
> On 07/21/2011 09:20 AM, H.J. Lu wrote:
>> ".quad  symbol" isn't really valid for 32bit.
>
> Why not?  We certainly know what value to put there.
>

x32 doesn't support 64bit relocation, like R_X86_64_64.
In many causes,  generate

.long symbol
.long 0

for ".quad symbol" is wrong. Please see:

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47446

for some examples.
Richard Henderson July 21, 2011, 4:42 p.m. UTC | #5
On 07/21/2011 09:28 AM, H.J. Lu wrote:
> On Thu, Jul 21, 2011 at 9:23 AM, Richard Henderson <rth@redhat.com> wrote:
>> On 07/21/2011 09:20 AM, H.J. Lu wrote:
>>> ".quad  symbol" isn't really valid for 32bit.
>>
>> Why not?  We certainly know what value to put there.
>>
> 
> x32 doesn't support 64bit relocation, like R_X86_64_64.

This being a self-fulfilling assertion, because you decided
to disable that relocation.  It *could* be supported.  Easily.


r~
Uros Bizjak July 21, 2011, 5:04 p.m. UTC | #6
On Thu, Jul 21, 2011 at 6:28 PM, H.J. Lu <hjl.tools@gmail.com> wrote:

>>> ".quad  symbol" isn't really valid for 32bit.
>>
>> Why not?  We certainly know what value to put there.
>>
>
> x32 doesn't support 64bit relocation, like R_X86_64_64.
> In many causes,  generate
>
> .long symbol
> .long 0
>
> for ".quad symbol" is wrong. Please see:
>
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47446
>
> for some examples.

Please also see:

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49798#c12

on why I think this is middle-end/tree-optimization issue.

Uros.
H.J. Lu July 21, 2011, 5:24 p.m. UTC | #7
On Thu, Jul 21, 2011 at 10:04 AM, Uros Bizjak <ubizjak@gmail.com> wrote:
> On Thu, Jul 21, 2011 at 6:28 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
>
>>>> ".quad  symbol" isn't really valid for 32bit.
>>>
>>> Why not?  We certainly know what value to put there.
>>>
>>
>> x32 doesn't support 64bit relocation, like R_X86_64_64.
>> In many causes,  generate
>>
>> .long symbol
>> .long 0
>>
>> for ".quad symbol" is wrong. Please see:
>>
>> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47446
>>
>> for some examples.
>
> Please also see:
>
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49798#c12
>
> on why I think this is middle-end/tree-optimization issue.
>

I still think it is a backend issue.
Uros Bizjak July 21, 2011, 5:30 p.m. UTC | #8
On Thu, Jul 21, 2011 at 7:24 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Thu, Jul 21, 2011 at 10:04 AM, Uros Bizjak <ubizjak@gmail.com> wrote:
>> On Thu, Jul 21, 2011 at 6:28 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
>>
>>>>> ".quad  symbol" isn't really valid for 32bit.
>>>>
>>>> Why not?  We certainly know what value to put there.
>>>>
>>>
>>> x32 doesn't support 64bit relocation, like R_X86_64_64.
>>> In many causes,  generate
>>>
>>> .long symbol
>>> .long 0
>>>
>>> for ".quad symbol" is wrong. Please see:
>>>
>>> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47446
>>>
>>> for some examples.
>>
>> Please also see:
>>
>> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49798#c12
>>
>> on why I think this is middle-end/tree-optimization issue.
>>
>
> I still think it is a backend issue.

/* Represents viewing something of one type as being of a second type.
   This corresponds to an "Unchecked Conversion" in Ada and roughly to
   the idiom *(type2 *)&X in C.  The only operand is the value to be
   viewed as being of another type.  **It is undefined if the type of the
   input and of the expression have different sizes.**

   ...
DEFTREECODE (VIEW_CONVERT_EXPR, "view_convert_expr", tcc_reference, 1)

We have:

<bb 2>:
  D.2709_8 = VIEW_CONVERT_EXPR<double>(&xxxx);
  D.2702_1 = u.d;
  D.2704_3 = D.2702_1 == D.2709_8;
  D.2701_4 = (int) D.2704_3;
  return D.2701_4;

Where

sizeof (double) = 64
sizeof (ptr_type) = 32.

Uros.
H.J. Lu July 21, 2011, 5:36 p.m. UTC | #9
On Thu, Jul 21, 2011 at 9:42 AM, Richard Henderson <rth@redhat.com> wrote:
> On 07/21/2011 09:28 AM, H.J. Lu wrote:
>> On Thu, Jul 21, 2011 at 9:23 AM, Richard Henderson <rth@redhat.com> wrote:
>>> On 07/21/2011 09:20 AM, H.J. Lu wrote:
>>>> ".quad  symbol" isn't really valid for 32bit.
>>>
>>> Why not?  We certainly know what value to put there.
>>>
>>
>> x32 doesn't support 64bit relocation, like R_X86_64_64.
>
> This being a self-fulfilling assertion, because you decided
> to disable that relocation.  It *could* be supported.  Easily.
>

There is no reason to have it since x32 is a 32bit environment.
I don't want/need this relocation in x32.
Uros Bizjak July 21, 2011, 5:39 p.m. UTC | #10
On Thu, Jul 21, 2011 at 6:42 PM, Richard Henderson <rth@redhat.com> wrote:
> On 07/21/2011 09:28 AM, H.J. Lu wrote:
>> On Thu, Jul 21, 2011 at 9:23 AM, Richard Henderson <rth@redhat.com> wrote:
>>> On 07/21/2011 09:20 AM, H.J. Lu wrote:
>>>> ".quad  symbol" isn't really valid for 32bit.
>>>
>>> Why not?  We certainly know what value to put there.
>>>
>>
>> x32 doesn't support 64bit relocation, like R_X86_64_64.
>
> This being a self-fulfilling assertion, because you decided
> to disable that relocation.  It *could* be supported.  Easily.

IMO, it is OK to disable 64bit relocations, and that compiler is at
fault here. Consider that something gets written to the d field (see
example of PR49798). Reading a pointer from *m fileld in DImode, we
will get non-zero bits in high 32bits of a pointer. We have to access
the pointer in SImode.

Uros.
Richard Henderson July 21, 2011, 6:02 p.m. UTC | #11
On 07/21/2011 10:39 AM, Uros Bizjak wrote:
> IMO, it is OK to disable 64bit relocations, and that compiler is at
> fault here. Consider that something gets written to the d field (see
> example of PR49798). Reading a pointer from *m fileld in DImode, we
> will get non-zero bits in high 32bits of a pointer. We have to access
> the pointer in SImode.

IMO this is only tangentially related to the compiler at all.
I think disabling 64bit relocations is unnecessarily awkward
for assembly programmers.

Consider when one wants to build jump tables.  You either have to
have a register available for zero-extension, or do the .word x, 0
thing.  Which I think is being silly and arbitrary; the assembler
damned well knows what I want when I write .quad x.


r~
H.J. Lu July 21, 2011, 6:10 p.m. UTC | #12
On Thu, Jul 21, 2011 at 11:02 AM, Richard Henderson <rth@redhat.com> wrote:
> On 07/21/2011 10:39 AM, Uros Bizjak wrote:
>> IMO, it is OK to disable 64bit relocations, and that compiler is at
>> fault here. Consider that something gets written to the d field (see
>> example of PR49798). Reading a pointer from *m fileld in DImode, we
>> will get non-zero bits in high 32bits of a pointer. We have to access
>> the pointer in SImode.
>
> IMO this is only tangentially related to the compiler at all.
> I think disabling 64bit relocations is unnecessarily awkward
> for assembly programmers.
>
> Consider when one wants to build jump tables.  You either have to
> have a register available for zero-extension, or do the .word x, 0
> thing.  Which I think is being silly and arbitrary; the assembler
> damned well knows what I want when I write .quad x.
>

It will make it harder to identify issues where you do want to
array of pointers when porting x86-64 assembly codes to x32.
H.J. Lu July 21, 2011, 6:13 p.m. UTC | #13
On Thu, Jul 21, 2011 at 10:30 AM, Uros Bizjak <ubizjak@gmail.com> wrote:
> On Thu, Jul 21, 2011 at 7:24 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
>> On Thu, Jul 21, 2011 at 10:04 AM, Uros Bizjak <ubizjak@gmail.com> wrote:
>>> On Thu, Jul 21, 2011 at 6:28 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
>>>
>>>>>> ".quad  symbol" isn't really valid for 32bit.
>>>>>
>>>>> Why not?  We certainly know what value to put there.
>>>>>
>>>>
>>>> x32 doesn't support 64bit relocation, like R_X86_64_64.
>>>> In many causes,  generate
>>>>
>>>> .long symbol
>>>> .long 0
>>>>
>>>> for ".quad symbol" is wrong. Please see:
>>>>
>>>> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47446
>>>>
>>>> for some examples.
>>>
>>> Please also see:
>>>
>>> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49798#c12
>>>
>>> on why I think this is middle-end/tree-optimization issue.
>>>
>>
>> I still think it is a backend issue.
>
> /* Represents viewing something of one type as being of a second type.
>   This corresponds to an "Unchecked Conversion" in Ada and roughly to
>   the idiom *(type2 *)&X in C.  The only operand is the value to be
>   viewed as being of another type.  **It is undefined if the type of the
>   input and of the expression have different sizes.**
>
>   ...
> DEFTREECODE (VIEW_CONVERT_EXPR, "view_convert_expr", tcc_reference, 1)
>
> We have:
>
> <bb 2>:
>  D.2709_8 = VIEW_CONVERT_EXPR<double>(&xxxx);
>  D.2702_1 = u.d;
>  D.2704_3 = D.2702_1 == D.2709_8;
>  D.2701_4 = (int) D.2704_3;
>  return D.2701_4;
>
> Where
>
> sizeof (double) = 64
> sizeof (ptr_type) = 32.
>

We may have 2 issues, one in middle-end, which generates
undefined VIEW_CONVERT_EXPR and one in back-end, which
fails to zero-extend symbol address.
H.J. Lu July 21, 2011, 8 p.m. UTC | #14
On Thu, Jul 21, 2011 at 10:30 AM, Uros Bizjak <ubizjak@gmail.com> wrote:
> On Thu, Jul 21, 2011 at 7:24 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
>> On Thu, Jul 21, 2011 at 10:04 AM, Uros Bizjak <ubizjak@gmail.com> wrote:
>>> On Thu, Jul 21, 2011 at 6:28 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
>>>
>>>>>> ".quad  symbol" isn't really valid for 32bit.
>>>>>
>>>>> Why not?  We certainly know what value to put there.
>>>>>
>>>>
>>>> x32 doesn't support 64bit relocation, like R_X86_64_64.
>>>> In many causes,  generate
>>>>
>>>> .long symbol
>>>> .long 0
>>>>
>>>> for ".quad symbol" is wrong. Please see:
>>>>
>>>> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47446
>>>>
>>>> for some examples.
>>>
>>> Please also see:
>>>
>>> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49798#c12
>>>
>>> on why I think this is middle-end/tree-optimization issue.
>>>
>>
>> I still think it is a backend issue.
>
> /* Represents viewing something of one type as being of a second type.
>   This corresponds to an "Unchecked Conversion" in Ada and roughly to
>   the idiom *(type2 *)&X in C.  The only operand is the value to be
>   viewed as being of another type.  **It is undefined if the type of the
>   input and of the expression have different sizes.**
>
>   ...
> DEFTREECODE (VIEW_CONVERT_EXPR, "view_convert_expr", tcc_reference, 1)
>
> We have:
>
> <bb 2>:
>  D.2709_8 = VIEW_CONVERT_EXPR<double>(&xxxx);
>  D.2702_1 = u.d;
>  D.2704_3 = D.2702_1 == D.2709_8;
>  D.2701_4 = (int) D.2704_3;
>  return D.2701_4;
>
> Where
>
> sizeof (double) = 64
> sizeof (ptr_type) = 32.
>

Are you sure that you used -mx32?  I couldn't reproduce it.
It looks like an x86 backend bug to me.
Uros Bizjak July 21, 2011, 8:17 p.m. UTC | #15
On Thu, Jul 21, 2011 at 10:00 PM, H.J. Lu <hjl.tools@gmail.com> wrote:

>> /* Represents viewing something of one type as being of a second type.
>>   This corresponds to an "Unchecked Conversion" in Ada and roughly to
>>   the idiom *(type2 *)&X in C.  The only operand is the value to be
>>   viewed as being of another type.  **It is undefined if the type of the
>>   input and of the expression have different sizes.**
>>
>>   ...
>> DEFTREECODE (VIEW_CONVERT_EXPR, "view_convert_expr", tcc_reference, 1)
>>
>> We have:
>>
>> <bb 2>:
>>  D.2709_8 = VIEW_CONVERT_EXPR<double>(&xxxx);
>>  D.2702_1 = u.d;
>>  D.2704_3 = D.2702_1 == D.2709_8;
>>  D.2701_4 = (int) D.2704_3;
>>  return D.2701_4;
>>
>> Where
>>
>> sizeof (double) = 64
>> sizeof (ptr_type) = 32.
>>
>
> Are you sure that you used -mx32?  I couldn't reproduce it.
> It looks like an x86 backend bug to me.

Hm, can't reproduce it anymore... x32 -O2 looks OK:

<bb 2>:
  v = {};
  v.m = &xxxx;
  D.2702_1 = u.d;
  D.2703_2 = v.d;
  D.2704_3 = D.2702_1 == D.2703_2;
  D.2701_4 = (int) D.2704_3;
  return D.2701_4;

}

Expand generates:

(insn 8 6 9 (set (reg:SI 68)
        (symbol_ref:SI ("xxxx") [flags 0x40]  <var_decl 0x7fccc360b140 xxxx>)) p
r49798.c:12 -1
     (nil))

(insn 9 8 10 (set (reg:DI 67)
        (zero_extend:DI (reg:SI 68))) pr49798.c:12 -1
     (nil))

I don't know if this is OK to be transformed to DImode load.

Uros.
H.J. Lu July 21, 2011, 8:22 p.m. UTC | #16
On Thu, Jul 21, 2011 at 1:17 PM, Uros Bizjak <ubizjak@gmail.com> wrote:
> On Thu, Jul 21, 2011 at 10:00 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
>
>>> /* Represents viewing something of one type as being of a second type.
>>>   This corresponds to an "Unchecked Conversion" in Ada and roughly to
>>>   the idiom *(type2 *)&X in C.  The only operand is the value to be
>>>   viewed as being of another type.  **It is undefined if the type of the
>>>   input and of the expression have different sizes.**
>>>
>>>   ...
>>> DEFTREECODE (VIEW_CONVERT_EXPR, "view_convert_expr", tcc_reference, 1)
>>>
>>> We have:
>>>
>>> <bb 2>:
>>>  D.2709_8 = VIEW_CONVERT_EXPR<double>(&xxxx);
>>>  D.2702_1 = u.d;
>>>  D.2704_3 = D.2702_1 == D.2709_8;
>>>  D.2701_4 = (int) D.2704_3;
>>>  return D.2701_4;
>>>
>>> Where
>>>
>>> sizeof (double) = 64
>>> sizeof (ptr_type) = 32.
>>>
>>
>> Are you sure that you used -mx32?  I couldn't reproduce it.
>> It looks like an x86 backend bug to me.
>
> Hm, can't reproduce it anymore... x32 -O2 looks OK:
>
> <bb 2>:
>  v = {};
>  v.m = &xxxx;
>  D.2702_1 = u.d;
>  D.2703_2 = v.d;
>  D.2704_3 = D.2702_1 == D.2703_2;
>  D.2701_4 = (int) D.2704_3;
>  return D.2701_4;
>
> }
>
> Expand generates:
>
> (insn 8 6 9 (set (reg:SI 68)
>        (symbol_ref:SI ("xxxx") [flags 0x40]  <var_decl 0x7fccc360b140 xxxx>)) p
> r49798.c:12 -1
>     (nil))
>
> (insn 9 8 10 (set (reg:DI 67)
>        (zero_extend:DI (reg:SI 68))) pr49798.c:12 -1
>     (nil))
>
> I don't know if this is OK to be transformed to DImode load.
>

I believe it is valid.
Uros Bizjak July 21, 2011, 9 p.m. UTC | #17
On Thu, Jul 21, 2011 at 10:22 PM, H.J. Lu <hjl.tools@gmail.com> wrote:

>> Expand generates:
>>
>> (insn 8 6 9 (set (reg:SI 68)
>>        (symbol_ref:SI ("xxxx") [flags 0x40]  <var_decl 0x7fccc360b140 xxxx>)) p
>> r49798.c:12 -1
>>     (nil))
>>
>> (insn 9 8 10 (set (reg:DI 67)
>>        (zero_extend:DI (reg:SI 68))) pr49798.c:12 -1
>>     (nil))
>>
>> I don't know if this is OK to be transformed to DImode load.
>>
>
> I believe it is valid.

How is this situation handled in other targets? I don't see that any
of other ptr_mode != Pmode targets define TARGET_ASM_INTEGER in the
way you propose.

Uros.
H.J. Lu July 21, 2011, 9:30 p.m. UTC | #18
On Thu, Jul 21, 2011 at 2:00 PM, Uros Bizjak <ubizjak@gmail.com> wrote:
> On Thu, Jul 21, 2011 at 10:22 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
>
>>> Expand generates:
>>>
>>> (insn 8 6 9 (set (reg:SI 68)
>>>        (symbol_ref:SI ("xxxx") [flags 0x40]  <var_decl 0x7fccc360b140 xxxx>)) p
>>> r49798.c:12 -1
>>>     (nil))
>>>
>>> (insn 9 8 10 (set (reg:DI 67)
>>>        (zero_extend:DI (reg:SI 68))) pr49798.c:12 -1
>>>     (nil))
>>>
>>> I don't know if this is OK to be transformed to DImode load.
>>>
>>
>> I believe it is valid.
>
> How is this situation handled in other targets? I don't see that any
> of other ptr_mode != Pmode targets define TARGET_ASM_INTEGER in the
> way you propose.
>

Other ptr_mode != Pmode targets don't run into this issue since they
have different instruction sets.  X32 may be the first (only) target for
this problem.
H.J. Lu July 22, 2011, 12:38 a.m. UTC | #19
On Thu, Jul 21, 2011 at 11:02 AM, Richard Henderson <rth@redhat.com> wrote:
> On 07/21/2011 10:39 AM, Uros Bizjak wrote:
>> IMO, it is OK to disable 64bit relocations, and that compiler is at
>> fault here. Consider that something gets written to the d field (see
>> example of PR49798). Reading a pointer from *m fileld in DImode, we
>> will get non-zero bits in high 32bits of a pointer. We have to access
>> the pointer in SImode.
>
> IMO this is only tangentially related to the compiler at all.
> I think disabling 64bit relocations is unnecessarily awkward
> for assembly programmers.
>
> Consider when one wants to build jump tables.  You either have to
> have a register available for zero-extension, or do the .word x, 0
> thing.  Which I think is being silly and arbitrary; the assembler
> damned well knows what I want when I write .quad x.
>

I withdrew this patch.  Assembler will accept ".quad foo" and
zero-extend it to 8 byte.
Richard Biener July 22, 2011, 8:11 a.m. UTC | #20
On Thu, Jul 21, 2011 at 7:30 PM, Uros Bizjak <ubizjak@gmail.com> wrote:
> On Thu, Jul 21, 2011 at 7:24 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
>> On Thu, Jul 21, 2011 at 10:04 AM, Uros Bizjak <ubizjak@gmail.com> wrote:
>>> On Thu, Jul 21, 2011 at 6:28 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
>>>
>>>>>> ".quad  symbol" isn't really valid for 32bit.
>>>>>
>>>>> Why not?  We certainly know what value to put there.
>>>>>
>>>>
>>>> x32 doesn't support 64bit relocation, like R_X86_64_64.
>>>> In many causes,  generate
>>>>
>>>> .long symbol
>>>> .long 0
>>>>
>>>> for ".quad symbol" is wrong. Please see:
>>>>
>>>> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47446
>>>>
>>>> for some examples.
>>>
>>> Please also see:
>>>
>>> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49798#c12
>>>
>>> on why I think this is middle-end/tree-optimization issue.
>>>
>>
>> I still think it is a backend issue.
>
> /* Represents viewing something of one type as being of a second type.
>   This corresponds to an "Unchecked Conversion" in Ada and roughly to
>   the idiom *(type2 *)&X in C.  The only operand is the value to be
>   viewed as being of another type.  **It is undefined if the type of the
>   input and of the expression have different sizes.**
>
>   ...
> DEFTREECODE (VIEW_CONVERT_EXPR, "view_convert_expr", tcc_reference, 1)
>
> We have:
>
> <bb 2>:
>  D.2709_8 = VIEW_CONVERT_EXPR<double>(&xxxx);
>  D.2702_1 = u.d;
>  D.2704_3 = D.2702_1 == D.2709_8;
>  D.2701_4 = (int) D.2704_3;
>  return D.2701_4;
>
> Where
>
> sizeof (double) = 64
> sizeof (ptr_type) = 32.

That's certainly bogus.

Richard.

> Uros.
>
diff mbox

Patch

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

	PR target/49798
	* config/i386/i386.c (ix86_asm_integer): New.
	(TARGET_ASM_INTEGER): Likewise.

diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c
index a60085c..d72edff 100644
--- a/gcc/config/i386/i386.c
+++ b/gcc/config/i386/i386.c
@@ -14289,6 +14289,24 @@  i386_asm_output_addr_const_extra (FILE *file, rtx x)
 
   return true;
 }
+
+/* Implementation of TARGET_ASM_INTEGER.  */
+
+static bool
+ix86_asm_integer (rtx x, unsigned int size, int aligned_p)
+{
+  if (TARGET_X32
+      && size == 8
+      && !CONST_INT_P (x)
+      && !CONST_DOUBLE_P (x))
+    {
+      /* Zero-extend symbol address to 64bit.  */
+      default_assemble_integer (x, 4, aligned_p);
+      default_assemble_integer (const0_rtx, 4, aligned_p);
+      return true;
+    }
+  return default_assemble_integer (x, size, aligned_p);
+}
 
 /* Split one or more double-mode RTL references into pairs of half-mode
    references.  The RTL can be REG, offsettable MEM, integer constant, or
@@ -34892,6 +34910,8 @@  ix86_autovectorize_vector_sizes (void)
 #define TARGET_ASM_UNALIGNED_SI_OP TARGET_ASM_ALIGNED_SI_OP
 #undef TARGET_ASM_UNALIGNED_DI_OP
 #define TARGET_ASM_UNALIGNED_DI_OP TARGET_ASM_ALIGNED_DI_OP
+#undef TARGET_ASM_INTEGER
+#define TARGET_ASM_INTEGER ix86_asm_integer
 
 #undef TARGET_PRINT_OPERAND
 #define TARGET_PRINT_OPERAND ix86_print_operand