From patchwork Mon Sep 9 09:09:12 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Zolotukhin X-Patchwork-Id: 273531 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "www.sourceware.org", Issuer "StartCom Class 1 Primary Intermediate Server CA" (not verified)) by ozlabs.org (Postfix) with ESMTPS id EE5AF2C00D8 for ; Mon, 9 Sep 2013 19:09:52 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; q=dns; s=default; b=G5iRJVccL5Xjg5adq zb9TAtNvnOwEnJ3+obvfOToCDkJPIpNmAwKNHvK+MumzBBYaG7yPSm/l4pdUZFhq Cu4TN3gSxDg+tBSdCgeL5gCebw6aofsnop1h8NHf6hxyU3+KSpSNBG+921sFuzgj D+/ow+Iq+8XsPMmYIPd8uTwSfU= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=default; bh=M//JE4Groa6pbgpBkuQgR69 6YMU=; b=MLxLnyPfBSaRYAfcf3IczDUfRHdHWFxedyqxiZOvDQa1yRRDV7txEEt TeKAczcm6U63aZfKYw5mCgKQ5ynzH9rOGiNgdrCVdL9XV6cBDymSbdD3OcA7pW/S iqoLBlRG93FBS7hp7gZAvyRjC2twzOXgZo8XeKO5Sn54PboiwnOc= Received: (qmail 2867 invoked by alias); 9 Sep 2013 09:09:45 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 2851 invoked by uid 89); 9 Sep 2013 09:09:44 -0000 Received: from mail-pa0-f52.google.com (HELO mail-pa0-f52.google.com) (209.85.220.52) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Mon, 09 Sep 2013 09:09:44 +0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED, AWL, BAYES_00, FREEMAIL_FROM autolearn=ham version=3.3.2 X-HELO: mail-pa0-f52.google.com Received: by mail-pa0-f52.google.com with SMTP id kq13so5976448pab.39 for ; Mon, 09 Sep 2013 02:09:42 -0700 (PDT) X-Received: by 10.68.49.168 with SMTP id v8mr6840017pbn.33.1378717782365; Mon, 09 Sep 2013 02:09:42 -0700 (PDT) Received: from msticlxl57.ims.intel.com ([192.55.54.42]) by mx.google.com with ESMTPSA id tz3sm15028763pbc.20.1969.12.31.16.00.00 (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 09 Sep 2013 02:09:41 -0700 (PDT) Date: Mon, 9 Sep 2013 13:09:12 +0400 From: "Michael V. Zolotukhin" To: Jakub Jelinek Cc: Jan Hubicka , "H.J. Lu" , Eric Botcazou , Kirill Yukhin , GCC Patches , Ond??ej B?lka , Uros Bizjak Subject: Re: [PATCH, x86] Use vector moves in memmove expanding Message-ID: <20130909090912.GD53568@msticlxl57.ims.intel.com> References: <7703907.JSoGtmLQkn@polaris> <20130909072317.GA53568@msticlxl57.ims.intel.com> <20130909072434.GA21984@kam.mff.cuni.cz> <20130909074205.GB53568@msticlxl57.ims.intel.com> <20130909074643.GC1817@tucnak.redhat.com> <20130909075249.GC53568@msticlxl57.ims.intel.com> <20130909075902.GD1817@tucnak.redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20130909075902.GD1817@tucnak.redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes > I think it is worthwhile, various targets have many different ways to expand > memcpy, admittedly i?86/x86_64 probably the biggest number of these, and > while right now you've encountered it on ia32 with certain options doesn't > mean that in a few years it couldn't hit some unrelated target, arm, sh, > sparc, whatever. Ok, that makes sense. I've never written torture tests before, could you please check if I did it right? Changelog: gcc: 2013-09-09 Michael Zolotukhin * config/i386/i386.c (ix86_expand_movmem): Fix epilogue generation. gcc/testsuite: 2013-09-09 Michael Zolotukhin * gcc.c-torture/execute/memcpy-3.c: New test. * gcc.c-torture/execute/memcpy-3.x: New file. Michael > Jakub diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index a8d70bc..50e9fa9 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -23329,7 +23329,7 @@ ix86_expand_movmem (rtx dst, rtx src, rtx count_exp, rtx align_exp, if (count_exp != const0_rtx && epilogue_size_needed > 1) expand_movmem_epilogue (dst, src, destreg, srcreg, count_exp, - size_needed); + epilogue_size_needed); if (jump_around_label) emit_label (jump_around_label); return true; diff --git a/gcc/testsuite/gcc.c-torture/execute/memcpy-3.c b/gcc/testsuite/gcc.c-torture/execute/memcpy-3.c new file mode 100644 index 0000000..f1ceb88 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/memcpy-3.c @@ -0,0 +1,18 @@ +static void __attribute__((noinline, noclone)) +my_memcpy (char *dest, const char *src, int n) +{ + __builtin_memcpy (dest, src, n); +} + +int +main (void) +{ + char a1[4], a2[4]; + __builtin_memset (a1, 'a', 4); + __builtin_memset (a2, 'b', 4); + my_memcpy (a2, a1, 4); + if (a2[0] != 'a') + __builtin_abort (); + return 0; +} + diff --git a/gcc/testsuite/gcc.c-torture/execute/memcpy-3.x b/gcc/testsuite/gcc.c-torture/execute/memcpy-3.x new file mode 100644 index 0000000..4458269 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/memcpy-3.x @@ -0,0 +1,7 @@ +if { [istarget "i?86-*-*"] } { + set additional_flags "-mtune=pentiumpro -minline-all-stringops" +} +if { [istarget "x86_64-*-*"] } { + set additional_flags "-minline-all-stringops" +} +return 0