From patchwork Tue Feb 20 09:43: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: 128863 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp4439600ljc; Tue, 20 Feb 2018 01:43:59 -0800 (PST) X-Google-Smtp-Source: AH8x226kkkUJ/eX2p/jIYWYFZChHVwlEiUjqMb3sRj6xp0zzozxYqrkXEAArQv8dLPgCgF3ENM2/ X-Received: by 2002:a17:902:6184:: with SMTP id u4-v6mr16635033plj.390.1519119839618; Tue, 20 Feb 2018 01:43:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519119839; cv=none; d=google.com; s=arc-20160816; b=tfYVoZjEii/Myy4sIIgqfDctoFxizJ9xjfwnl16K9CSx1eGWhGRMEGRQEBQdWeVbFq REgcM74bbAfl2X50wEigygPKw8/IE58YKx+7CE0bNKqCPA1TGO/xbo0YgAsUPiBgJVz4 jstQJBsuAvksbL5EFN8N48/8fz6qR221TMBPP1/hEjw2EMsqPcpQVE2bw9z38EYZ7vy7 F2EHlCDR3skq2bz2FsWp2ejyckVCBQa330V1qbfAivzAarNOn1Fy5WbOvHZ6ry0IsAW4 LxSQatpI6WfNV5uWPQ1g3PLprc1gfwx7gQ6LyDjTXmEP7ZvwwXdHWtRL46ydmeIvVT4Y StvA== 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=l++dS93aEd8ESc00uM85B7PMQZVE4+vJkyslDcsYUV0=; b=GG5VGhtr0wiqFY5o4wwNH0IIbiffTOgU1TExAeYW14LDbmMzAg+MX+84qzrQ8Ke9j8 K9NBmheBtDgKV21WwnGHl0bnWC3FTPa6q0kfJSyxN7L4UGUB2P3Oz5O09jeKGE6ggRaM hn6rzl3hD32/AuwUEeL8kgC4GSJn10E46Ln5fUNhtUMxw+Ro9LnVj1OWgjd+e0ETomHI aPz4QB299l5SSBky6liRYErZ8zM5OZXqJs5V3tjP/T5b2r9BYg9c5hX7qLPOqeMpi0f9 hd9RMzCFI/qK9jhW+zPuRBSh1Xj1PmNaatFy5eIKTpthMq+QwUEw7qiOOvA6bMMLwroQ +XNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=CA2pPkcV; spf=pass (google.com: domain of gcc-patches-return-473583-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-473583-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 9si2507436pfi.351.2018.02.20.01.43.59 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 20 Feb 2018 01:43:59 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-return-473583-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=CA2pPkcV; spf=pass (google.com: domain of gcc-patches-return-473583-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-473583-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=pesgsllfPFNzFzjU75CsZvDNL9RngjAY8eGBK+7CQzIx1Ipoqrp/B PViWiiu24jY6s/S8rU2/8b/hK3t89NGyQl2q0HwHgGoPSQ0jU+l0OLeAQECMxjxD h+Qf+G/iWrsAR3fFpBgMnlYeG+v7nR4AuSzHPGfsr0AiUd8bWN07q8= 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=TMgJnPhY4rDWTmkgZ20AR7QQv+c=; b=CA2pPkcVGFOaCcMeSES2 JUOMhuFATqEbNd01Gi0ZJezEaLM5drp41Yx6EQ4+xk46GmJduDg/qYS9zYezFn/t fsu7B0PXcIkf8WKHMekeHUI/pKJfjA26n32648+W5RVsmjqQ+hxJhwj8ZlQpq3kf jJYjFW1mHwoX/lmVRdWk00k= Received: (qmail 95129 invoked by alias); 20 Feb 2018 09:43:48 -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 94751 invoked by uid 89); 20 Feb 2018 09:43:47 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.1 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=H*r:dyn.plus.net X-HELO: mail-wr0-f180.google.com Received: from mail-wr0-f180.google.com (HELO mail-wr0-f180.google.com) (209.85.128.180) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 20 Feb 2018 09:43:45 +0000 Received: by mail-wr0-f180.google.com with SMTP id l43so12447087wrc.2 for ; Tue, 20 Feb 2018 01:43:45 -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=l++dS93aEd8ESc00uM85B7PMQZVE4+vJkyslDcsYUV0=; b=BXOmpIEY+K8DG0PvGOfmkZfKxfrUC/HQfrGadSuZlhPRJ/dI/RVWf0l4RXV2avEqOZ IX6ifYzdvDxRFUMNuhH65OjZgRYZJMFXKRO9jPjIeZrBKRquHTNBCw49BD4GljvGJI8F PpJFkc7p8MuRE4zZaxVbou0dNYTP47qC2Z2Ukx5q0JrjoeNLfz3UpQd0//Y0N6RBsTMQ M9qCMCR5PY85X1Spob6anNq09D+kIbe0RIuSTeuczNbLucGTNm40i/m6bSy9lzM/oOhU HhttT8H5JPTdhWmZ/2WeVxXlMSGzDHnqXhxWe8S8bhIOEyJdnpDzV3w7iYO+mSIDy2G2 eIvw== X-Gm-Message-State: APf1xPC8aSO3hd0ygniuafLWMe3Toam3XzObSWpBhykcE3zooPvPJnFf lFX6HKU0L3bD6sCwIXn8vN2ZfEn0noQ= X-Received: by 10.28.190.18 with SMTP id o18mr3528801wmf.86.1519119823417; Tue, 20 Feb 2018 01:43:43 -0800 (PST) Received: from localhost (79.58.7.51.dyn.plus.net. [51.7.58.79]) by smtp.gmail.com with ESMTPSA id t91sm29878076wrc.21.2018.02.20.01.43.41 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 20 Feb 2018 01:43:42 -0800 (PST) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: Fixed incorrect TARGET_MEM_REF alignment (PR 84419) Date: Tue, 20 Feb 2018 09:43:40 +0000 Message-ID: <87po50ro6r.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) MIME-Version: 1.0 expand_call_mem_ref checks for TARGET_MEM_REFs that have compatible type, but it didn't then go on to install the specific type we need, which might have different alignment due to: if (TYPE_ALIGN (type) != align) type = build_aligned_type (type, align); This was causing masked stores to be incorrectly marked as aligned on AVX512. Tested on aarch64-linux-gnu, x86_64-linux-gnu and powerpc64-linux-gnu. Also tested by Alexander on AVX512 hw. OK to install? Richard 2018-02-20 Richard Sandiford gcc/ PR tree-optimization/84419 * internal-fn.c (expand_call_mem_ref): Create a TARGET_MEM_REF with the required type if its current type is compatible but different. gcc/testsuite/ PR tree-optimization/84419 * gcc.dg/vect/pr84419.c: New test. Index: gcc/internal-fn.c =================================================================== --- gcc/internal-fn.c 2018-01-13 18:01:51.235735290 +0000 +++ gcc/internal-fn.c 2018-02-20 09:40:47.547217244 +0000 @@ -2444,11 +2444,14 @@ expand_call_mem_ref (tree type, gcall *s && types_compatible_p (TREE_TYPE (mem), type)) { tree offset = TMR_OFFSET (mem); - if (alias_ptr_type != TREE_TYPE (offset) || !integer_zerop (offset)) + if (type != TREE_TYPE (mem) + || alias_ptr_type != TREE_TYPE (offset) + || !integer_zerop (offset)) { mem = copy_node (mem); TMR_OFFSET (mem) = wide_int_to_tree (alias_ptr_type, wi::to_poly_wide (offset)); + TREE_TYPE (mem) = type; } return mem; } Index: gcc/testsuite/gcc.dg/vect/pr84419.c =================================================================== --- /dev/null 2018-02-19 19:34:42.906488063 +0000 +++ gcc/testsuite/gcc.dg/vect/pr84419.c 2018-02-20 09:40:47.548217201 +0000 @@ -0,0 +1,21 @@ +#include + +#define SIZE 400 + +int foo[SIZE]; +char bar[SIZE]; + +void __attribute__ ((noinline)) foo_func(void) +{ + int i; + for (i = 1; i < SIZE; i++) + if (bar[i]) + foo[i] = 1; +} + +int main() +{ + memset(bar, 1, sizeof(bar)); + foo_func(); + return 0; +}