From patchwork Tue Apr 15 16:12:38 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Evgeny Stupachenko X-Patchwork-Id: 339315 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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id A3A6F140093 for ; Wed, 16 Apr 2014 02:12:50 +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 :mime-version:date:message-id:subject:from:to:cc:content-type; q=dns; s=default; b=f5nFOVCKzTvqHIHWuHRxOnLx4CTjexH6qr2WbnI/2dy mD2MOd6toWlxooi7Ir/3RPLZDc3BIX8EVsMxWkDlMYAvshM9qgAJBtDOItNMmR4a 7jlKSEO19pWAyq2CaYtTG6iPTvq3bwY0exmWvLAh4ogzPWnpb27XaDCwz2YsS/28 = 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 :mime-version:date:message-id:subject:from:to:cc:content-type; s=default; bh=6BndYZ4vUa8xC4ayHFnXBmOP+oY=; b=yi2Z2Egs+EKk12K+O bKLxxsWnce9bKxpGCBBzL8/HMVPcnN3B3wtGaho8rwfpATToIl4nZl4USRAqmuGN XgiVDNVSwsocjUX2A/0hyPGlqJRz+Yt0Bvcie0E2Fb1wVaN8pWw2QONMiDJd4KDL 28WE13nW/NA8bj4rMJ1EdTltlo= Received: (qmail 2903 invoked by alias); 15 Apr 2014 16:12:43 -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 2883 invoked by uid 89); 15 Apr 2014 16:12:41 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.6 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-Spam-User: qpsmtpd, 2 recipients X-HELO: mail-ob0-f172.google.com Received: from mail-ob0-f172.google.com (HELO mail-ob0-f172.google.com) (209.85.214.172) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Tue, 15 Apr 2014 16:12:40 +0000 Received: by mail-ob0-f172.google.com with SMTP id wo20so1170178obc.17 for ; Tue, 15 Apr 2014 09:12:38 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.182.241.67 with SMTP id wg3mr2257679obc.16.1397578358397; Tue, 15 Apr 2014 09:12:38 -0700 (PDT) Received: by 10.76.170.39 with HTTP; Tue, 15 Apr 2014 09:12:38 -0700 (PDT) Date: Tue, 15 Apr 2014 20:12:38 +0400 Message-ID: Subject: [PATCH 3/3, x86] X86 Silvermont vector cost model tune From: Evgeny Stupachenko To: Uros Bizjak Cc: "H.J. Lu" , GCC Patches , uros@gcc.gnu.org X-IsSubscribed: yes 3d part: 2014-04-15 Evgeny Stupachenko * config/i386/i386.c (x86_add_stmt_cost): Fixing vector cost model for Silvermont. return retval; On Thu, Mar 6, 2014 at 12:58 AM, Evgeny Stupachenko wrote: > slm_cost/intel_cost and TARGET_SLOW_PSHUFB are just preparation to a > next vectorization patch. > Changes in ix86_add_stmt_cost gives real performance to Silvermont. > Let's move all to stage1. > > On Wed, Mar 5, 2014 at 9:29 PM, Uros Bizjak wrote: >> On Wed, Mar 5, 2014 at 5:46 PM, H.J. Lu wrote: >>> On Wed, Mar 5, 2014 at 7:58 AM, Evgeny Stupachenko wrote: >>>> Hi, >>>> >>>> The patch is for x86 Silvermont. >>>> It improves x86 Silvermont vector cost model. >>>> It gives +20% on facerec spec on Silvermont. >>>> It passes make check and bootstrap on x86. >>>> >>>> Is this patch ok for stage1? >>>> >>>> ChangeLog: >>>> >>>> 2014-03-05 Evgeny Stupachenko >>>> >>>> * config/i386/x86-tune.def (TARGET_SLOW_PSHUFB): Target for slow byte >>>> shuffle on some x86 architectures. >>>> * config/i386/i386.h (TARGET_SLOW_PSHUFB): Ditto. >>>> * config/i386/i386.c (processor_costs): Fixing vec_to_scalar_cost for >>>> Silvermont according latency table. >>>> (expand_vec_perm_even_odd_1): Avoid byte shuffles in architectures >>>> where they are slow (TARGET_SLOW_PSHUFB). >>>> (x86_add_stmt_cost): Fixing vector cost model for Silvermont. >>>> >>>> Thanks, >>>> Evgeny >>> >>> There are 3 separate changes in this patch: >>> >>> 1. Update slm_cost, which doesn't have a ChangeLog entry. >>> 2. Add TARGET_SLOW_PSHUFB. >>> 3. Update ix86_add_stmt_cost. >>> >>> I suggest you break it into 3 independent patches. >> >> I think that slm_cost/intel_cost and TARGET_SLOW_PSHUFB changes can >> still go into mainline at this stage since they are trivial tuning >> changes that should not destabilize the compiler. >> >> The ix86_add_stmt_cost should wait for stage 1. >> >> Uros. diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index 0ae3cda..2522b5c 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -81,6 +81,7 @@ along with GCC; see the file COPYING3. If not see #include "context.h" #include "pass_manager.h" #include "target-globals.h" +#include "tree-vectorizer.h" static rtx legitimize_dllimport_symbol (rtx, bool); static rtx legitimize_pe_coff_extern_decl (rtx, bool); @@ -46329,6 +46330,18 @@ ix86_add_stmt_cost (void *data, int count, enum vect_cost_for_stmt kind, count *= 50; /* FIXME. */ retval = (unsigned) (count * stmt_cost); + + /* We need to multiply all vector stmt cost by 1.8 (estimated cost) + for Silvermont as it has out of order integer pipeline and can execute + 2 scalar instruction per tick, but has in order SIMD pipeline. */ + if (TARGET_SILVERMONT || TARGET_INTEL) + if (stmt_info && stmt_info->stmt) + { + tree lhs_op = gimple_get_lhs (stmt_info->stmt); + if (lhs_op && TREE_CODE (TREE_TYPE (lhs_op)) == INTEGER_TYPE) + retval = (retval * 18) / 10; + } + cost[where] += retval;