This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 02/10] addr32: Only handle zero-extended DImode addresses


On Fri, Mar 9, 2012 at 4:26 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Thu, Mar 8, 2012 at 7:20 AM, Uros Bizjak <ubizjak@gmail.com> wrote:
>> On Sun, Mar 4, 2012 at 9:13 PM, Uros Bizjak <ubizjak@gmail.com> wrote:
>>
>>>> We only need to handle zero-extended addresses in DImode.
>>>> OK for trunk?
>>>
>>>> 2012-03-02 ?H.J. Lu ?<hongjiu.lu@intel.com>
>>>>
>>>> ? ? ? ?* config/i386/i386.c (ix86_print_operand_address): Only handle
>>>> ? ? ? ?zero-extended DImode addresses.
>>>
>>> OK.
>>
>> The patch was reverted due to PR target/52530.
>>
>
> Revert breaks Pmode == SImode for x32. ?Here is a different patch.
> It checks Pmode == DImode instead of TARGET_64BIT. ?Tested on
> Linux/x32. ?OK for trunk?

This will still emit i.e. "leal 1(%rSImode), %rSImode" on Pmode ==
SImode targets, so you win nothing really.

Attached patch finally decouples LEA operand handling from generic
address handling, and by introducing %E operand modifier, we are able
to always emit DImode registers for LEAs (which is good anyway to
avoid unnecessary addr32 prefixes). Luckily, the "leal 1(%rSImode),
%rSImode" triggered some unknown problem with Sun assembler, so we
were able to detect the problem.

I would like to point out that the patched compiler now also emits
address registers in their natural mode (modulo zero-extended RTXes)
and fixes following failure on Pmode == SImode targets:

--cut here--
struct foo
{
?int *f;
?int i;
};

void
__attribute__ ((noinline))
bar (struct foo x)
{
?*(x.f) = 1;
}
--cut here--

For Pmode == SImode, the compiler emitted (%rdi) address, which was
wrong, since "i" was passed in the high part of (%rdi) register.

2012-03-09 ?Uros Bizjak ?<ubizjak@gmail.com>

? ? ? ?PR target/52530
? ? ? ?* config/i386/i386.c (ix86_print_operand): Handle 'E' operand modifier.
? ? ? ?(ix86_print_operand_address): Handle UNSPEC_LEA_ADDR. Do not fallback
? ? ? ?to set code to 'q'.
? ? ? ?* config/i386/i386.md (UNSPEC_LEA_ADDR): New unspec.
? ? ? ?(*movdi_internal_rex64): Use %E operand modifier for lea.
? ? ? ?(*movsi_internal): Ditto.
? ? ? ?(*lea_1): Ditto.
? ? ? ?(*lea<mode>_2): Ditto.
? ? ? ?(*lea_{3,4,5,6}_zext): Ditto.
? ? ? ?(*tls_global_dynamic_32_gnu): Ditto.
? ? ? ?(*tls_global_dynamic_64): Ditto.
? ? ? ?(*tls_dynamic_gnu2_lea_32): Ditto.
? ? ? ?(*tls_dynamic_gnu2_lea_64): Ditto.
? ? ? ?(pro_epilogue_adjust_stack_<mode>_add): Ditto.

Patch was tested on x86_64-pc-linux-gnu {,-m32}. I have also eyeballed
x32 code (Pmode == SImode) and found no problems.

Committed to mainline SVN.

H.J., can you please construct a runtime test from the above example code?

Uros.

Attachment: p.diff.txt
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]