From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4050 invoked by alias); 15 Aug 2007 19:53:45 -0000 Received: (qmail 4012 invoked by uid 22791); 15 Aug 2007 19:53:43 -0000 X-Spam-Check-By: sourceware.org Received: from dmz.mips-uk.com (HELO dmz.mips-uk.com) (194.74.144.194) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 15 Aug 2007 19:53:37 +0000 Received: from internal-mx1 ([192.168.192.240] helo=ukservices1.mips.com) by dmz.mips-uk.com with esmtp (Exim 3.35 #1 (Debian)) id 1ILOsp-0000dO-00; Wed, 15 Aug 2007 20:50:23 +0100 Received: from southgate.mips.com ([192.168.192.171]) by ukservices1.mips.com with esmtp (Exim 3.36 #1 (Debian)) id 1ILOsk-0003IJ-00; Wed, 15 Aug 2007 20:50:18 +0100 Message-ID: <46C358FA.2030506@mips.com> Date: Wed, 15 Aug 2007 19:53:00 -0000 From: Nigel Stephens User-Agent: IceDove 1.5.0.12 (X11/20070606) MIME-Version: 1.0 To: Sandra Loosemore CC: Andrew Pinski , GCC Patches , Guy Morrogh , David Ung , Thiemo Seufer , Richard Sandiford Subject: Re: PATCH: fine-tuning for can_store_by_pieces References: <46C3343A.5080407@codesourcery.com> <46C34624.4070505@codesourcery.com> In-Reply-To: <46C34624.4070505@codesourcery.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-MIPS-Technologies-UK-MailScanner: Found to be clean X-MIPS-Technologies-UK-MailScanner-From: nigel@mips.com X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2007-08/txt/msg00957.txt.bz2 Sandra Loosemore wrote: > Andrew Pinski wrote: >> On 8/15/07, Sandra Loosemore wrote: >>> On MIPS we can get better code by having can_store_by_pieces >>> differentiate >>> between the cases where it's used for memset operations, and those >>> where it's >>> used to copy a string constant. This patch introduces new SET_RATIO >>> and >>> SET_BY_PIECES_P macros, with appropriate defaults to preserve the >>> existing >>> behavior. I checked other targets and made the ones that override >>> the default >>> STORE_BY_PIECES_P clone the same definition for SET_BY_PIECES_P. >> >> Are you sure that the cause of the real issue here is not really PR >> 31150? > > I don't think so. Nigel originally developed this patch against gcc > 3.4; I just verified that it still does something useful for current > mainline. > >> I don't think copying string constants and memcpy/memset >> should be different in terms of heuristics. >> >> It seems if you gave a testcase where this is profitable, it would be >> better to judge this patch (and maybe a testcase for the testsuite >> also). > > I'll see if I can come up with something specific, or perhaps Nigel > has a test case. No I don't have a specific test case: it's not a failure case, but an optimisation. Note that store_by_pieces is used for two different purposes: to copy string constants to memory (e.g. __builtin_strcpy) or initialise local arrays, and also to set a memory buffer to a single constant value (__builtin_memset). IMHO the benefit computation of using a movstr versus expanding it inline does need to be different for each case, since on a 32-bit MIPS processor the strcpy gets expanded into a repeated sequence of three instructions (lui; ori; sw) where each immediate value is the next 4-byte chunk of the string; whereas in the second case the immediate value is computed only once, followed then by a sequence of "sw" instructions. Nigel