From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12384 invoked by alias); 30 Jan 2011 19:37:28 -0000 Received: (qmail 12318 invoked by uid 22791); 30 Jan 2011 19:37:28 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL,BAYES_00,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail.lysator.liu.se (HELO mail.lysator.liu.se) (130.236.254.3) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 30 Jan 2011 19:37:20 +0000 Received: from mail.lysator.liu.se (localhost [127.0.0.1]) by mail.lysator.liu.se (Postfix) with ESMTP id 8830340018 for ; Sun, 30 Jan 2011 20:37:17 +0100 (CET) Received: from [83.252.231.52] (c83-252-231-52.bredband.comhem.se [83.252.231.52]) (using SSLv3 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.lysator.liu.se (Postfix) with ESMTP id 5B7C34001E for ; Sun, 30 Jan 2011 20:37:17 +0100 (CET) Subject: Optimizing From: Magnus Fromreide To: gcc-help@gcc.gnu.org Content-Type: text/plain; charset="ISO-8859-1" Date: Sun, 30 Jan 2011 20:18:00 -0000 Message-ID: <1296416236.32435.15.camel@sara> Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org X-SW-Source: 2011-01/txt/msg00461.txt.bz2 Consider the following code: ---- #define SRC "Big blob of text goes here" extern int foo(int, const void*, int); void f1(void) { foo(1, SRC, sizeof(SRC) - 1); } void f2(void) { char buf[sizeof(SRC) - 1]; __builtin_memcpy(buf, SRC, sizeof(SRC) - 1); foo(1, buf, sizeof(SRC) - 1); } ---- Is it a valid optimization for the compiler to generate the same instructions for f2 as it generates for f1? Would it be hard to make GCC do it? /MF