From patchwork Wed Feb 2 18:08:16 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aldy Hernandez X-Patchwork-Id: 81502 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]) by ozlabs.org (Postfix) with SMTP id 0FF79B6EED for ; Thu, 3 Feb 2011 05:08:47 +1100 (EST) Received: (qmail 25946 invoked by alias); 2 Feb 2011 18:08:30 -0000 Received: (qmail 25766 invoked by uid 22791); 2 Feb 2011 18:08:26 -0000 X-SWARE-Spam-Status: No, hits=-6.3 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, SPF_HELO_PASS, TW_FN, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 02 Feb 2011 18:08:21 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id p12I8HZW010749 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 2 Feb 2011 13:08:17 -0500 Received: from vishnu.quesejoda.com (vpn-239-147.phx2.redhat.com [10.3.239.147]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p12I8GmH003813; Wed, 2 Feb 2011 13:08:16 -0500 Message-ID: <4D499D90.2090301@redhat.com> Date: Wed, 02 Feb 2011 12:08:16 -0600 From: Aldy Hernandez User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.13) Gecko/20101209 Fedora/3.1.7-0.35.b3pre.fc14 Lightning/1.0b3pre Thunderbird/3.1.7 MIME-Version: 1.0 To: Richard Henderson CC: gcc-patches , MARLIER Patrick Subject: Re: [trans-mem] handle memset (PR/47492) References: <4D46FD58.5050207@redhat.com> <4D498A35.8040306@redhat.com> In-Reply-To: <4D498A35.8040306@redhat.com> 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 > Patrick's test case at the end of this thread can be handled > with a separate one liner. Well, I don't know about a one liner unless I'm missing something, but here goes... I set the bits for TM memcpy/memmove as well, btw. As always, thanks Patrick for keeping us honest :). OK for branch? * trans-mem.c (expand_call_tm): Annotate BUILT_IN_TM_* calls. (find_tm_replacement_function): Add comment. Index: testsuite/gcc.dg/tm/memset-2.c =================================================================== --- testsuite/gcc.dg/tm/memset-2.c (revision 0) +++ testsuite/gcc.dg/tm/memset-2.c (revision 0) @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-fgnu-tm -fdump-tree-tmlower" } */ + +char array[4]; + +void *memset(void *s, int c, __SIZE_TYPE__); + +int main() +{ + __transaction [[atomic]] { + memset(array, 'b', sizeof(4)); + } + return 0; +} + +/* { dg-final { scan-tree-dump-times "GTMA_HAVE_STORE" 1 "tmlower" } } */ +/* { dg-final { cleanup-tree-dump "tmlower" } } */ Index: trans-mem.c =================================================================== --- trans-mem.c (revision 169535) +++ trans-mem.c (working copy) @@ -478,6 +478,8 @@ find_tm_replacement_function (tree fndec /* ??? We may well want TM versions of most of the common functions. For now, we've already these two defined. */ + /* Adjust expand_call_tm() attributes as necessary for the cases + handled here: */ if (DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL) switch (DECL_FUNCTION_CODE (fndecl)) { @@ -2179,10 +2181,17 @@ expand_call_tm (struct tm_region *region struct cgraph_node *node; bool retval = false; + fn_decl = gimple_call_fndecl (stmt); + + if (fn_decl == built_in_decls[BUILT_IN_TM_MEMCPY] + || fn_decl == built_in_decls[BUILT_IN_TM_MEMMOVE]) + transaction_subcode_ior (region, GTMA_HAVE_STORE | GTMA_HAVE_LOAD); + if (fn_decl == built_in_decls[BUILT_IN_TM_MEMSET]) + transaction_subcode_ior (region, GTMA_HAVE_STORE); + if (is_tm_pure_call (stmt)) return false; - fn_decl = gimple_call_fndecl (stmt); if (fn_decl) retval = is_tm_ending_fndecl (fn_decl); if (!retval)