public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Segher Boessenkool <segher@kernel.crashing.org>
To: Fredrik Noring <noring@nocrew.org>
Cc: Alexander Monakov <amonakov@ispras.ru>, gcc-help@gcc.gnu.org
Subject: Re: m68k: Simple loop compiles into boundless recursion with -O2
Date: Wed, 13 Jan 2021 13:20:15 -0600	[thread overview]
Message-ID: <20210113192015.GT30983@gate.crashing.org> (raw)
In-Reply-To: <X/8gK9JtEvr4jQtt@sx9>

Hi!

On Wed, Jan 13, 2021 at 05:30:35PM +0100, Fredrik Noring wrote:
> Many thanks, Alexander,
> 
> > Please invoke objdump with -dr instead to see the relocations.
> 
> Indeed:
> 
>   1a:	4eb9 0000 0000 	jsr 0 <memset2>
> 			1c: R_68K_32	memset

Yup, always always always use -dr :-)

> > The relocation associated with this instruction should point to memset.
> > Most likely the compiler is optimizing your memset2 function to call
> > the standard function 'memset'.
> > 
> > When implementing memset itself you need to pass -ffreestanding to GCC,
> > which will disable this optimization.
> 
> Yes, I had -nostdlib but -ffreestanding is apparently needed as well. Thanks
> again.

You probably want -ffreestanding anyway for your situation: -nostdlib
does not mean "there is no standard library", it just means "do not link
with it".

For the archives, no one has said it yet: to just disable the
optimisation transforming the loop into a memset, you can use
-fno-tree-loop-distribute-patterns .


Segher

  reply	other threads:[~2021-01-13 19:21 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-13 16:01 Fredrik Noring
2021-01-13 16:09 ` Alexander Monakov
2021-01-13 16:30   ` Fredrik Noring
2021-01-13 19:20     ` Segher Boessenkool [this message]
2021-01-13 19:53       ` Fredrik Noring
2021-01-13 21:46         ` Segher Boessenkool
2021-01-13 21:54           ` AW: " Stefan Franke
2021-01-14 14:54           ` Fredrik Noring
2021-01-14 15:05             ` Alexander Monakov
2021-01-14 15:09               ` Alexander Monakov
2021-01-14 15:15                 ` AW: " Stefan Franke
2021-01-14 15:33                   ` Alexander Monakov
2021-01-14 15:56                     ` AW: " Stefan Franke
2021-01-15  2:23     ` Liu Hao
2021-01-15  6:23       ` Fredrik Noring
2021-01-13 16:23 ` AW: " Stefan Franke
2021-01-13 17:27   ` Fredrik Noring

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=20210113192015.GT30983@gate.crashing.org \
    --to=segher@kernel.crashing.org \
    --cc=amonakov@ispras.ru \
    --cc=gcc-help@gcc.gnu.org \
    --cc=noring@nocrew.org \
    /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).