From patchwork Tue Jan 9 21:59:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 123980 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp4523321qgn; Tue, 9 Jan 2018 13:59:58 -0800 (PST) X-Google-Smtp-Source: ACJfBouvQM7KRFI6iEHIS94Xp0v56dIX+1ZQxAle6iZ4gO87Y3LgkEVpcW5xUZ2pQCP6Daayh3jE X-Received: by 10.101.73.133 with SMTP id r5mr12870355pgs.285.1515535198277; Tue, 09 Jan 2018 13:59:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1515535198; cv=none; d=google.com; s=arc-20160816; b=NTGZqcjTMc/fQQUIWhn8INWDUw3ArsznaWNVOv3AmikkIBjxyAdvwx/vxQJxNyJqFO vJEavCxq5qGJI5V6o8nv7tKMaFWOg/5vvS72T1uythZRpLXrzxphZrPECt1HGmw4mqLY ELG6PMzHlsOi4R2WIG1qFmTcL+pTdrKeABlnN4tmMHebzWcCZbNwMNX9tcL8FKmXG80x ytLp7yWMxiW4JV+iBNk9A2Ge1QDlEu5aGGYZTykAhnMPvF1uNIPO8KRSsvdwzb/O0FCH zPDIxnoUVoaSVJdfxQY8jJM4G+pxvrVpDGKlQfWbqSx+5H0YP24suE4fkZfQgzUrtR9o Yx3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:user-agent:message-id:date:subject:mail-followup-to:to :from:delivered-to:sender:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:mailing-list:dkim-signature :domainkey-signature:arc-authentication-results; bh=9PRmjUGUKUW04IHGnMKgNN9xX6q3p4mpFKyV9thB6UU=; b=eFFSWw+cqibH2Oy7isNi2BxDKiN+o2mU7jLRGxj6BKnccCFuTgHrX+um45nNwagVH3 6AoO9u9OCkcB+CkATYMsoM54r8jvEirhqS724QEn/ZzFlebPwfERmko1mFYmVfLDyAir Z1PKAac2L+OtqbmG2T5N4JlhaSGsz720UGPmsJe+nolPuKjpFwEI3zMXNL1bhwwsodnB cAVgKKwqruPg34LALtUcFcZe8qWcPKB2tD+1FkhFPkxm8H1GbHCeh6QBAxxvKmk46Gcz QgSYitOTiHsNneZBmqqUf+K6oos7j3Mw6NwdjGXNhEin4T5mzRGkXe43+3IaIBtYZisS 7AQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=laf4afWj; spf=pass (google.com: domain of gcc-patches-return-470613-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-470613-patch=linaro.org@gcc.gnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id m61si10949743plb.136.2018.01.09.13.59.58 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Jan 2018 13:59:58 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-return-470613-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=laf4afWj; spf=pass (google.com: domain of gcc-patches-return-470613-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-470613-patch=linaro.org@gcc.gnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:subject:date:message-id:mime-version:content-type; q=dns; s= default; b=OAMuLEz3/4INibG+H0UT7o+aEIvmjCHiRdt9v4xzl6h7GlKOcVf6Y XPS5/U6QnCYyXDn0RfUDVeReQAkul6RPmLDjfQrZ5MKLICsGiJBsUkr8FiNqfN0E AXiknsUw5pq/suTqGr5pE9mKzPocNPKkzwQB2bOu7oWGGKYHtrEJ9E= 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:from :to:subject:date:message-id:mime-version:content-type; s= default; bh=uju62ZBgH6lhULr0P3wgl1rqpdk=; b=laf4afWjlk76tuxyYXb9 2ZA0h5eUNdk3qAvd/keHzUbYWwsr6RXSF/xiSK648Az87fP9q3UILpJn03Y7/BH9 VKZm1mRkKTaaap8SqKVEuEhrKJCa3VSPiXOOMLCph5SDVJypsGK/zl5Bbrosc25w NsbdPja8YPHe2v5NZO5N74Q= Received: (qmail 18222 invoked by alias); 9 Jan 2018 21:59:47 -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 18190 invoked by uid 89); 9 Jan 2018 21:59:46 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.3 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:2882 X-HELO: mail-wr0-f176.google.com Received: from mail-wr0-f176.google.com (HELO mail-wr0-f176.google.com) (209.85.128.176) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 09 Jan 2018 21:59:44 +0000 Received: by mail-wr0-f176.google.com with SMTP id d9so318047wre.3 for ; Tue, 09 Jan 2018 13:59:43 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:mail-followup-to:subject:date:message-id :user-agent:mime-version; bh=9PRmjUGUKUW04IHGnMKgNN9xX6q3p4mpFKyV9thB6UU=; b=YWBGkgEyuVLoq059Jy9ooRbNZ15TiWauh8jNu545NWJs7v0ARKzMzeEyBb1ftWImU3 0cCJTO3rZFYUbo9Siryf4r/03q0pmHkLfXstEfeIQsa1CtwecQXUYBK9axM8Ki89zzpx oHJT0j26tehcCL/wCw8u8hSzh88360UXz9x76DbIDVSwOHhOkRN00IDTqX/vtqgom/P7 KmlWoqnM9fzghWHM/CXH+deXIVuCa3ZI/2m07CWqNSLA7K1ExpL4MZICV1cEYk40HE9x FUE/3uRlA2UJrCSa7DwmAO9Mi06MOuxJzc2P7rk/GhCYBAymPw7Pgw969vGZS8CqwjLA Z5bw== X-Gm-Message-State: AKGB3mLzYo4ovuryioK9k4HtJPT6vZTY4vPMWQd2CrrxZWLWRIo+t7hG Bm28nvhLxF1RZ4T2QNeqWOKERV6ydP4= X-Received: by 10.223.186.9 with SMTP id o9mr14334598wrg.199.1515535181919; Tue, 09 Jan 2018 13:59:41 -0800 (PST) Received: from localhost ([95.144.14.233]) by smtp.gmail.com with ESMTPSA id e4sm17516491wmi.14.2018.01.09.13.59.40 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 09 Jan 2018 13:59:41 -0800 (PST) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: Don't use permutes for single-element accesses (PR83753) Date: Tue, 09 Jan 2018 21:59:40 +0000 Message-ID: <87lgh6bsmr.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) MIME-Version: 1.0 After cunrolling the inner loop, the remaining loop in the testcase has a single 32-bit access and a group of 64-bit accesses. We first try to vectorise at 128 bits (VF 4), but decide not to for cost reasons. We then try with 64 bits (VF 2) instead. This means that the group of 64-bit accesses uses a single-element vector, which is deliberately supported as of r251538. We then try to create "permutes" for these single-element vectors and fall foul of: for (i = 0; i < 6; i++) sel[i] += exact_div (nelt, 2); in vect_grouped_store_supported, since nelt==1. Maybe we shouldn't even be trying to vectorise statements in the single-element case, and instead just copy the scalar statement for each member of the group. But until then, this patch treats non-strided grouped accesses as VMAT_CONTIGUOUS if no permutation is necessary. Tested on aarch64-linux-gnu, x86_64-linux-gnu and powerpc64le-linux-gnu. OK to install? Richard 2018-01-09 Richard Sandiford gcc/ PR tree-optimization/83753 * tree-vect-stmts.c (get_group_load_store_type): Use VMAT_CONTIGUOUS for non-strided grouped accesses if the number of elements is 1. gcc/testsuite/ PR tree-optimization/83753 * gcc.dg/torture/pr83753.c: New test. Index: gcc/tree-vect-stmts.c =================================================================== --- gcc/tree-vect-stmts.c 2018-01-09 15:46:34.439449019 +0000 +++ gcc/tree-vect-stmts.c 2018-01-09 18:15:53.481983778 +0000 @@ -1849,10 +1849,16 @@ get_group_load_store_type (gimple *stmt, && (can_overrun_p || !would_overrun_p) && compare_step_with_zero (stmt) > 0) { - /* First try using LOAD/STORE_LANES. */ - if (vls_type == VLS_LOAD - ? vect_load_lanes_supported (vectype, group_size) - : vect_store_lanes_supported (vectype, group_size)) + /* First cope with the degenerate case of a single-element + vector. */ + if (known_eq (TYPE_VECTOR_SUBPARTS (vectype), 1U)) + *memory_access_type = VMAT_CONTIGUOUS; + + /* Otherwise try using LOAD/STORE_LANES. */ + if (*memory_access_type == VMAT_ELEMENTWISE + && (vls_type == VLS_LOAD + ? vect_load_lanes_supported (vectype, group_size) + : vect_store_lanes_supported (vectype, group_size))) { *memory_access_type = VMAT_LOAD_STORE_LANES; overrun_p = would_overrun_p; Index: gcc/testsuite/gcc.dg/torture/pr83753.c =================================================================== --- /dev/null 2018-01-08 18:48:58.045015662 +0000 +++ gcc/testsuite/gcc.dg/torture/pr83753.c 2018-01-09 18:15:53.480983817 +0000 @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options "-mcpu=xgene1" { target aarch64*-*-* } } */ + +typedef struct { + int m1[10]; + double m2[10][8]; +} blah; + +void +foo (blah *info) { + int i, d; + + for (d=0; d<10; d++) { + info->m1[d] = 0; + info->m2[d][0] = 1; + for (i=1; i<8; i++) + info->m2[d][i] = 2; + } +}