On Fri, Nov 8, 2024 at 3:18 PM Uros Bizjak <ubiz...@gmail.com> wrote:
>
> On Fri, Nov 8, 2024 at 6:52 AM Hongtao Liu <crazy...@gmail.com> wrote:
>
> > > > >         PR target/117418
> > > > >         * config/i386/i386-options.cc 
> > > > > (ix86_option_override_internal): raise an
> > > > >         error with option -mx32 -maddress-mode=long.
> > > > >
> > > > > gcc/testsuite/ChangeLog:
> > > > >
> > > > >         PR target/117418
> > > > >         * gcc.target/i386/pr117418-1.c: New test.
> > > > > ---
> > > > >  gcc/config/i386/i386-options.cc            |  4 ++++
> > > > >  gcc/testsuite/gcc.target/i386/pr117418-1.c | 13 +++++++++++++
> > > > >  2 files changed, 17 insertions(+)
> > > > >  create mode 100644 gcc/testsuite/gcc.target/i386/pr117418-1.c
> > > > >
> > > > > diff --git a/gcc/config/i386/i386-options.cc 
> > > > > b/gcc/config/i386/i386-options.cc
> > > > > index 239269ecbdd..ba1abea2537 100644
> > > > > --- a/gcc/config/i386/i386-options.cc
> > > > > +++ b/gcc/config/i386/i386-options.cc
> > > > > @@ -2190,6 +2190,10 @@ ix86_option_override_internal (bool 
> > > > > main_args_p,
> > > > >         error ("address mode %qs not supported in the %s bit mode",
> > > > >                TARGET_64BIT_P (opts->x_ix86_isa_flags) ? "short" : 
> > > > > "long",
> > > > >                TARGET_64BIT_P (opts->x_ix86_isa_flags) ? "64" : "32");
> > > > > +
> > > > > +      if (TARGET_X32_P (opts->x_ix86_isa_flags)
> > > > > +         && opts_set->x_ix86_pmode == PMODE_DI)
> > > > > +       error ("address mode 'long' not supported in the x32 ABI");
> > > >
> > > > This looks wrong.   Try the encoded patch.
> > > >
> > > So it means -maddress-mode=long will override x32 to use 64-bit pointer?
> > No, answered by myself.
> > The upper 32-bit is zero, so it's still 32-bit memory space although
> > it uses a 64-bit register as a pointer.
> > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82267
>
> Yes, ptr_mode and Pmode are two different things. ptr_mode is ABI
> mandated pointer mode, while Pmode is an implementation detail. As
> most of the targets, x32 used Pmode == ptr_mode, but as evident from
> the quoted PR, it resulted in many 0x67 prefixes due to address size
> overrides to handle SImode ptr_mode ABI requirements.
>
> -maddress-mode=long was added just for x32 to mitigate this problem.
> It was beneficial for some applications, thus the request to make it
> the default, but it remained as it is.
>
> Because this option is not the default one, it has (some) tendency to
> bitrot, when some new committed code assumes ptr_mode == Pmode. IIRC,
> HJ had a tester that exercised -maddress-mode=long for -mx32 to hunt
> middle-end and back-end issues with ptr_mode != Pmode.
Thanks for explaining the background and reasons for it
>
> Uros.



-- 
BR,
Hongtao

Reply via email to