From patchwork Sun Jun 12 06:40:36 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ira Rosen X-Patchwork-Id: 1827 Return-Path: Delivered-To: unknown Received: from imap.gmail.com (74.125.47.109) by localhost6.localdomain6 with IMAP4-SSL; 14 Jun 2011 16:45:45 -0000 Delivered-To: patches@linaro.org Received: by 10.52.181.10 with SMTP id ds10cs394538vdc; Sat, 11 Jun 2011 23:40:38 -0700 (PDT) Received: by 10.43.70.1 with SMTP id ye1mr5032308icb.467.1307860837678; Sat, 11 Jun 2011 23:40:37 -0700 (PDT) Received: from mail-pv0-f178.google.com (mail-pv0-f178.google.com [74.125.83.178]) by mx.google.com with ESMTPS id x8si28903982ict.76.2011.06.11.23.40.37 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 11 Jun 2011 23:40:37 -0700 (PDT) Received-SPF: neutral (google.com: 74.125.83.178 is neither permitted nor denied by best guess record for domain of ira.rosen@linaro.org) client-ip=74.125.83.178; Authentication-Results: mx.google.com; spf=neutral (google.com: 74.125.83.178 is neither permitted nor denied by best guess record for domain of ira.rosen@linaro.org) smtp.mail=ira.rosen@linaro.org Received: by pvg7 with SMTP id 7so1975686pvg.37 for ; Sat, 11 Jun 2011 23:40:36 -0700 (PDT) MIME-Version: 1.0 Received: by 10.142.125.18 with SMTP id x18mr629158wfc.207.1307860836650; Sat, 11 Jun 2011 23:40:36 -0700 (PDT) Received: by 10.143.93.4 with HTTP; Sat, 11 Jun 2011 23:40:36 -0700 (PDT) Date: Sun, 12 Jun 2011 09:40:36 +0300 Message-ID: Subject: [patch] Improve peeling heuristic in the vectorizer From: Ira Rosen To: gcc-patches@gcc.gnu.org Cc: Patch Tracking Hi, gcc.dg/vect/vect-72.c is not expected to use loop peeling for alignment, but it does on ARM with double-word vectors. The loop contains two data-refs of type char: one is aligned and the other is misaligned by 1. When the cost model is disabled the peeling heuristic chooses to peel a number of scalar iterations that aligns the highest number of data-refs in the loop. When there are two (with different alignment), the decision is arbitrary, which causes the vectorizer to peel 7 iterations in vect-72.c, while not peeling at all is an obviously better option (at least since the cost model is disabled). This patch takes into account the required number of iterations to peel. Bootstrapped and tested on powerpc64-suse-linux, and tested the vectorizer testsuite on arm-linux-gnueabi. Committed. Ira ChangeLog: * tree-vect-data-refs.c (vect_peeling_hash_get_most_frequent): Take number of iterations to peel into account for equally frequent misalignment values. Index: tree-vect-data-refs.c =================================================================== --- tree-vect-data-refs.c (revision 174964) +++ tree-vect-data-refs.c (working copy) @@ -1248,7 +1248,9 @@ vect_peeling_hash_get_most_frequent (void **slot, vect_peel_info elem = (vect_peel_info) *slot; vect_peel_extended_info max = (vect_peel_extended_info) data; - if (elem->count > max->peel_info.count) + if (elem->count > max->peel_info.count + || (elem->count == max->peel_info.count + && max->peel_info.npeel > elem->npeel)) { max->peel_info.npeel = elem->npeel; max->peel_info.count = elem->count;