public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Sergei Organov <osv@topconrd.ru>
To: Michael Meissner <gcc-mail@the-meissners.org>
Cc: gcc@gcc.gnu.org, Andrew Pinski <pinskia@physics.uc.edu>
Subject: Re: How to replace -O1 with corresponding -f's?
Date: Tue, 21 Jun 2005 12:49:00 -0000	[thread overview]
Message-ID: <87u0jr7u4t.fsf@osv.topcon.com> (raw)
In-Reply-To: <20050621095059.GA24035@tiktok.the-meissners.org>

Michael Meissner <gcc-mail@the-meissners.org> writes:

> On Mon, Jun 20, 2005 at 07:57:17PM +0400, Sergei Organov wrote:
> > Andrew Pinski <pinskia@physics.uc.edu> writes:
> > 
> > > On Jun 20, 2005, at 11:28 AM, Sergei Organov wrote:
> > > 
> > > > Andrew Pinski <pinskia@physics.uc.edu> writes:
> > > >
> > > >> On Jun 20, 2005, at 10:54 AM, Sergei Organov wrote:
> > > >>
> > > >>> so SYMBOL_FLAG_SMALL (flags 0x6 vs 0x2) is somehow being missed when -O1
> > > 
> > > >>
> > > >>> is turned on. Seems to be something at tree-to-RTX conversion time.
> > > >>> Constant folding?
> > > >>
> > > >> No, it would mean that the target says that this is not a small data.
> > > >> Also try it with the following code and you will see there is no
> > > >> difference:
> > > 
> > > >>
> > > >>          double osvf() { return 314314314; }
> > > >
> > > > There is no difference in the sense that here both -O0 and -O1 behave
> > > > roughly the same. So the problem is with detecting "smallness" for true
> > > > constants by the target, right?
> > > 
> > > I think the bug is in rs6000_elf_in_small_data_p but since I have not
> > > debuged it yet I don't know for sure.
> > > 
> > > Could you file a bug?  This is a target bug.
> > 
> > Yeah, and I've reported it rather long ago against gcc-3.3 (PR 9571).
> > That time there were 3 problems reported in the PR of which only the
> > first one seems to be fixed (or are the rest just re-appeared in 4.0?).
> > 
> > I think PR 9571 is in fact regression with respect to 2.95.x despite the
> > [wrong] comments:
> > 
> > ------- Additional Comment #5 From Franz Sirl  2003-06-17 15:31  [reply] -------
> > 
> > r0 is used as a pointer to sdata2, this is a bug, it should be r2. And
> > since only r2 is initialized in the ecrt*.o files, how can this work?
> > Besides that, even if you initialize r0 manually, it is practically
> > clobbered in about every function.
> 
> It's been a long time since I've hacked the PowerPC, but IIRC the instruction
> set, a base register of '0' does not mean r0, but instead it means use 0 as the
> base address.  Every place that uses a base register should use the register
> class 'b' (BASE_REGS) instead of 'r' (GENERAL_REGS), which excludes r0 from
> being considered.
> 
> Under the 32-bit eABI calling sequence, you have three small data areas:
> 
> The small data area that r2 points to (.sdata/.sbss).
> 
> The small data area that r13 points to (.sdata2/.sbss2).
> 
> The small data area centered around location 0 (ie, small positive
> addresses, and the most negative addresses). I don't recall that we
> had special sections for this, since for many embedded apps, they
> couldn't allocate to those addresses.
> 
> For these relocations, you should use R_PPC_EMB_SDA21, which the
> linker will fill in both the offset and the appropriate base register
> into the instruction.

Exactly, and that's what gcc actually and correctly does. My comment in
the PR exactly matches what you've said above:

 ------- Additional Comment #7 From Sergei Organov  2003-10-14 14:42  [reply] -------

 > r0 is used as a pointer to sdata2, this is a bug, it should be r2.

 No, the %r0 you see is fake. In the object file it's a special
 relocatable symbol that is resolved to either 2 (r2) or 13 (r13) by the
 linker depending on actual output section the symbol refers to, so
 there is no bug here.


IMHO, the assembly output is just somewhat misleading mentioning %r0 in
the place in question, -- it better should be just 0 I think as
SYM@sda21(0) would create less confusion than SYM@sda21(%r0).

On the other hand, I must admit the PR with item 1 (wrong section
attribute) fixed is not a regression anymore. I apologize, but I've
compared gcc-3.x/4.x with *patched* version of gcc-2.95.x that I've
hacked to force it to put double/float constants into .sdata2 section.
Now I've applied my hack to gcc-4.1.0 and get similar results, though
the patch is indeed a hack and is not satisfactory.

I think there is a fundamental problem that compiler-generated symbols
referring to constants are generated too late, at RTL level, and thus
aren't handled by the small section logic working on the tree level. Any
thoughts?

-- 
Sergei.

  reply	other threads:[~2005-06-21 12:49 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-06-20 13:40 Sergei Organov
2005-06-20 14:04 ` Andrew Haley
2005-06-20 14:26   ` Andrew Pinski
2005-06-20 14:55     ` Sergei Organov
2005-06-20 15:01       ` Andrew Pinski
2005-06-20 15:29         ` Sergei Organov
2005-06-20 15:36           ` Andrew Pinski
2005-06-20 15:58             ` Sergei Organov
2005-06-21  9:55               ` Michael Meissner
2005-06-21 12:49                 ` Sergei Organov [this message]
2005-06-20 17:18             ` Sergei Organov
2005-06-24 16:09             ` Sergei Organov
2005-06-20 14:28   ` Sergei Organov
2005-06-22 19:29     ` Zack Weinberg
2005-06-20 14:25 ` Scott Robert Ladd
2005-06-20 14:35 ` Andrew Pinski
2005-06-20 15:04   ` Sergei Organov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87u0jr7u4t.fsf@osv.topcon.com \
    --to=osv@topconrd.ru \
    --cc=gcc-mail@the-meissners.org \
    --cc=gcc@gcc.gnu.org \
    --cc=pinskia@physics.uc.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).