From patchwork Wed Jan 3 15:06:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 123328 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp10280627qgn; Wed, 3 Jan 2018 07:06:40 -0800 (PST) X-Google-Smtp-Source: ACJfBouNhHn88gg03DccZCgKfUe2CRxeHxnVR3fRRlAox+U3jgOdq8IjbN0EbY5mfubaAh+qaE8d X-Received: by 10.101.66.67 with SMTP id d3mr1474628pgq.244.1514992000339; Wed, 03 Jan 2018 07:06:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1514992000; cv=none; d=google.com; s=arc-20160816; b=uNlWLdUjvw+MJT99LepP6ihKakS089F8dj6wGCf/2i1bu2kzTuvjSVNswYyEuZq5c+ 64wM2j1ke5BtdC/tR7Yd2BKdSUCxUdXgc7yDRqMz6aFB0ZoHftcDWOeb239siO8k/PZ2 rTQEc1DXlZZiiYtqA2QgK8w/nY8HiQQds4+I/8fclhmg2oaf0MB7Y4wUOBRGwpQx5hS4 5b1ReVCg1zyGHsBIJpm8qSgrIboMlhCBElhp+H2Js+NP+/z6/OvXxZXcrJuLlZWltojV KzhiF2s6EWbunyBReucoAIsNbjn7yfnGdKFLIJbLXVR86taMb6UiKOmYg97yQPMWK6q/ 40GA== 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:cc: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=JcfNoO5VxxjKoVjxi9Y6hsdxSvtpCMaGPwDmSetdDIc=; b=BOhtsjPMkXljD8xdrNIFYBY2SfsPQX8r7vBBwh6S5PliuSlxd0kEgZW3plqzsSmQtY bKfYi7vQROZnA0VgdWr8/rTgO2TS4T2YHZP88yJQFmCYBOG+wBLeA7FiV6tDO0j4ueOQ 9SJSvMmV5z1qY1Dr/iHjsESNV6y40M3RcpkqYJnMp7Kf4Vcb4OkpPrgTv686qDuyrS9g G5fDcOcIw0VLjAmyFXdT2u2FRdjDGsgeV04tn4vUkRoDuKqgZppy4RTBOws3hzwfUhG2 39MSJZze4E12x8tJq8Fcm7Qd+QmwDqNSz+sMrzuxIfr3qmyYqFe1+RdEr5AQYQLjksos 2gDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=tNbVLZn3; spf=pass (google.com: domain of gcc-patches-return-470075-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-470075-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 9si792579ple.790.2018.01.03.07.06.40 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Jan 2018 07:06:40 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-return-470075-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=tNbVLZn3; spf=pass (google.com: domain of gcc-patches-return-470075-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-470075-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:cc:subject:date:message-id:mime-version:content-type; q=dns; s=default; b=u4TnpfO007mN01aeBXp1qStCrBCaJuz+V5o7IoLHONZfrG2chD e5cNqQfkFE9UmIf/j8WTrN8J0pVw9OdgBcpFR1gOEnqlsb1ggvN9fa6YNX7SQZ7d vQj8w1+110VodMjqB+bbxogV9cdNdZQcHSAy0aYs/4N/lT+z77OUFGXlg= 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:cc:subject:date:message-id:mime-version:content-type; s= default; bh=DQIcIrqBnYuExhkJ6fidtyNR9pE=; b=tNbVLZn3UHnN06N0+ikk BIKwMYQnJNWV/6Fjx+c3N3Ud1Zk4iSAGcsd/sbwX7HCdW9sFbc1SDvyS6XunaEJY c3qTTBT9unjXbQV6idNDWOT/w/4z8lajBjFN+QBlsVzDqapsPaxYCPUaKPy8EdFU MNEi8cFzrMVc2Ga0JkkXF8M= Received: (qmail 114022 invoked by alias); 3 Jan 2018 15:06:29 -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 114009 invoked by uid 89); 3 Jan 2018 15:06:28 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-10.5 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, KAM_NUMSUBJECT, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=9206 X-HELO: mail-wm0-f54.google.com Received: from mail-wm0-f54.google.com (HELO mail-wm0-f54.google.com) (74.125.82.54) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 03 Jan 2018 15:06:26 +0000 Received: by mail-wm0-f54.google.com with SMTP id 9so3154820wme.4 for ; Wed, 03 Jan 2018 07:06:26 -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:cc:subject:date :message-id:user-agent:mime-version; bh=JcfNoO5VxxjKoVjxi9Y6hsdxSvtpCMaGPwDmSetdDIc=; b=uGE8AcffuFF3lfSx/LIJzaN1bo15Dk6ppaaKmCq3c7A/PL9SIBMJVuECo/mk8f9g+T LNcBTvYnQyP/LtFXBqaVhRREp8J037Hb4cWyqbJykiu2gMu6MimzPQUikPdKHb0JSJno S+eyVm42pQlrNVmF7v56W6wliURSuk6SNbdjYa+kBDIXNQP1mczELoTL4afuS6iJTXns hbIeMIFXrcjJxcHDBGQzuYh07mZyjM2cG4jWauaa07Ta+iaadlEvozfUYljN6yG6TzCW dVd5NLpt/jXu/stIrlZGbq6PsQS9aB9vq43JMcndhrgGZWJhbGwqFp14eXvnWygH3k32 2U2w== X-Gm-Message-State: AKGB3mJwXGQREocNEni/RImGozfyTxssFC7qzVQeXIzU/XgCkzI8ieOj yMgVYFTpveiAw+AtoAs/c4axiA== X-Received: by 10.28.46.67 with SMTP id u64mr1635866wmu.64.1514991984710; Wed, 03 Jan 2018 07:06:24 -0800 (PST) Received: from localhost (92.40.248.19.threembb.co.uk. [92.40.248.19]) by smtp.gmail.com with ESMTPSA id r64sm2471538wrb.62.2018.01.03.07.06.23 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 03 Jan 2018 07:06:23 -0800 (PST) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.guenther@gmail.com, richard.sandiford@linaro.org Cc: richard.guenther@gmail.com Subject: Revert DECL_USER_ALIGN part of r241959 Date: Wed, 03 Jan 2018 15:06:21 +0000 Message-ID: <87k1wzm176.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) MIME-Version: 1.0 r241959 included code to stop us increasing the alignment of a "user-aligned" variable. This wasn't the main purpose of the patch, and I think it was just there to make the testcase work. The documentation for the aligned attribute says: This attribute specifies a minimum alignment for the variable or structure field, measured in bytes. The DECL_USER_ALIGN code seemed to be treating as a sort of maximum instead, but there's not really such a thing as a maximum here: the variable might still end up at the start of a section that has a higher alignment, or might end up by chance on a "very aligned" boundary at link or load time. I think people who add alignment attributes want to ensure that accesses to that variable are fast, so it seems counter-intuitive for it to make the access slower. The vect-align-4.c test is an example of this: for targets with 128-bit vectors, we get better code without the aligned attribute than we do with it. Tested on aarch64-linux-gnu so far, will test more widely if OK. Thanks, Richard 2018-01-03 Richard Sandiford gcc/ * tree-vect-data-refs.c (vect_compute_data_ref_alignment): Don't punt for user-aligned variables. gcc/testsuite/ * gcc.dg/vect/vect-align-4.c: New test. * gcc.dg/vect/vect-nb-iter-ub-2.c (cc): Remove alignment attribute and redefine as a structure with an unaligned member "b". (foo): Update accordingly. Index: gcc/tree-vect-data-refs.c =================================================================== --- gcc/tree-vect-data-refs.c 2018-01-03 15:03:14.301330558 +0000 +++ gcc/tree-vect-data-refs.c 2018-01-03 15:03:14.454324422 +0000 @@ -920,19 +920,6 @@ vect_compute_data_ref_alignment (struct return true; } - if (DECL_USER_ALIGN (base)) - { - if (dump_enabled_p ()) - { - dump_printf_loc (MSG_NOTE, vect_location, - "not forcing alignment of user-aligned " - "variable: "); - dump_generic_expr (MSG_NOTE, TDF_SLIM, base); - dump_printf (MSG_NOTE, "\n"); - } - return true; - } - /* Force the alignment of the decl. NOTE: This is the only change to the code we make during the analysis phase, before deciding to vectorize the loop. */ Index: gcc/testsuite/gcc.dg/vect/vect-align-4.c =================================================================== --- /dev/null 2018-01-03 08:32:43.873058927 +0000 +++ gcc/testsuite/gcc.dg/vect/vect-align-4.c 2018-01-03 15:03:14.453324462 +0000 @@ -0,0 +1,15 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target vect_int } */ +/* { dg-add-options bind_pic_locally } */ + +__attribute__((aligned (8))) int a[2048] = {}; + +void +f1 (void) +{ + for (int i = 0; i < 2048; i++) + a[i]++; +} + +/* { dg-final { scan-tree-dump-not "Vectorizing an unaligned access" "vect" } } */ +/* { dg-final { scan-tree-dump-not "Alignment of access forced using peeling" "vect" } } */ Index: gcc/testsuite/gcc.dg/vect/vect-nb-iter-ub-2.c =================================================================== --- gcc/testsuite/gcc.dg/vect/vect-nb-iter-ub-2.c 2018-01-03 15:03:14.301330558 +0000 +++ gcc/testsuite/gcc.dg/vect/vect-nb-iter-ub-2.c 2018-01-03 15:03:14.454324422 +0000 @@ -3,18 +3,19 @@ #include "tree-vect.h" int ii[32]; -char cc[66] __attribute__((aligned(1))) = +struct { char a; char b[66]; } cc = { 0, { 0, 0, 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0, 10, 0, 11, 0, 12, 0, 13, 0, 14, 0, 15, 0, 16, 0, 17, 0, 18, 0, 19, 0, 20, 0, 21, 0, 22, 0, 23, 0, 24, 0, 25, 0, 26, 0, 27, 0, 28, 0, 29, 0, - 30, 0, 31, 0 }; + 30, 0, 31, 0 } +}; void __attribute__((noinline,noclone)) foo (int s) { int i; for (i = 0; i < s; i++) - ii[i] = (int) cc[i*2]; + ii[i] = (int) cc.b[i*2]; } int main (int argc, const char **argv)