From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate.crashing.org (gate.crashing.org [63.228.1.57]) by sourceware.org (Postfix) with ESMTP id 46C9A393BC3D for ; Wed, 13 Jan 2021 19:21:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 46C9A393BC3D Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=kernel.crashing.org Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=segher@kernel.crashing.org Received: from gate.crashing.org (localhost.localdomain [127.0.0.1]) by gate.crashing.org (8.14.1/8.14.1) with ESMTP id 10DJKGjk015931; Wed, 13 Jan 2021 13:20:16 -0600 Received: (from segher@localhost) by gate.crashing.org (8.14.1/8.14.1/Submit) id 10DJKFeR015928; Wed, 13 Jan 2021 13:20:15 -0600 X-Authentication-Warning: gate.crashing.org: segher set sender to segher@kernel.crashing.org using -f Date: Wed, 13 Jan 2021 13:20:15 -0600 From: Segher Boessenkool To: Fredrik Noring Cc: Alexander Monakov , gcc-help@gcc.gnu.org Subject: Re: m68k: Simple loop compiles into boundless recursion with -O2 Message-ID: <20210113192015.GT30983@gate.crashing.org> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.2.3i X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, KAM_NUMSUBJECT, TXREP, T_SPF_HELO_PERMERROR, T_SPF_PERMERROR autolearn=no autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-help@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-help mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Jan 2021 19:21:27 -0000 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 > 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