From patchwork Mon Apr 9 17:47:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 133050 Delivered-To: patch@linaro.org Received: by 10.46.84.29 with SMTP id i29csp485579ljb; Mon, 9 Apr 2018 10:48:03 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+eLk9eSJ28YfN6VRrAdZU7gudZLNhcS4JItUBdOPIWv8ADq3uisdNxEd3xBjy4HOi8YY66 X-Received: by 10.99.114.2 with SMTP id n2mr26100363pgc.274.1523296083695; Mon, 09 Apr 2018 10:48:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523296083; cv=none; d=google.com; s=arc-20160816; b=fF+cROqYnbT8mtzqA9L2Qj8FeWIBagPgAE3+zq2QL+AUc8QoBWmr9nqcQRIh9GJRTj vK1pqnUudDd/l/tVfSj2a8ozcVzBWKiKHn51okqSn7VA03/dUcioHqt8l85OUmt1Up0h pEetYuZ+fog6FcPn67/6u6rZl6k+nI5Tq1lJQWyHIVaF71xB1j5NhebRUrCZWvtlv/Lc hk3mVf1VnGunlDiY3cwqgvjFzrYUoLCNVlFKnDdb2WwWcHp/9vYcO58N7GyvWIdFoHQr A6jXqoMiDhQrx5yEGYSd4KbMB+QWo4NukeBbItuAYQIZpfJYHlCHjp8gSIOJnMrgb0kY 5d+w== 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=4YrdgW7h2M14+tDhYItcQQ6S6XkHyiAUfJG0KtkOQvs=; b=Tfq+r3nvdal0lemyYg8T2B/m5TIs/Jr9QXbaYIPyVJDKl1zpskk0NUOemBEOQHRc7y en4zQvPCPYUsG/XuaIaAlX55uziXXYkFprut1zMKPXuEyedgSL/UdgiUTC04M9mFkrRk 8/lbp6+/kHdYRgDeefMbo5CT/MZNzlJBkzLNEGYJib1+3v1FTJ3GRYwCigay5NNx4Qjc 5hLOx5JK9lajFDVSV1lST/7SXNAQ5VZIbSAj84Fu2TH06/ASNeSKgBWidKRxq8xdeyvF 3f+rszT9Hjakp8BxsX9Aru+2DxjXS3imcITCznjVe2o7vWG1R0kge0AlgVddG8Eh70am EG1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=Gz6MNhed; spf=pass (google.com: domain of gcc-patches-return-476072-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-476072-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 13si595924pfm.246.2018.04.09.10.48.02 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Apr 2018 10:48:03 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-476072-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=Gz6MNhed; spf=pass (google.com: domain of gcc-patches-return-476072-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-476072-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=DZ9IrJmQUgFdA/sHZaq0WV4xBExW+x6Q5gDgXT9PjbY/feeMNjgAH WQWqyXV4B5lTUN2+mGVkn+sxem94BoBvcHzdCil/aBfAY0wOweHzhPJFViu1VRi7 YLKPloTO2nf0wdCCFF+acCS6NpJMF1mrWKt8glDdBTlDeh3StY5JG0= 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=8GLjT7e6plJh6QUIXZZlL2f0PWo=; b=Gz6MNhedTBlMINcDbCpf Vrhdth5koCBPOrJvGZ+9znp7ryatN16y7xEVgbLbzpuR2sHSAO3iIWO7unmzETxL h1McTvH6HqMtWQAObls08x0t+hIjfx/IzHW1KhgCGcHqmvULJ+ppv1nWY5/Ih7N+ DoQt4g+UwW5hWauqoMH7aOA= Received: (qmail 17015 invoked by alias); 9 Apr 2018 17:47:50 -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 17001 invoked by uid 89); 9 Apr 2018 17:47:50 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.0 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=shorts 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; Mon, 09 Apr 2018 17:47:48 +0000 Received: by mail-wm0-f54.google.com with SMTP id 66so14558006wmd.3 for ; Mon, 09 Apr 2018 10:47:48 -0700 (PDT) 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=4YrdgW7h2M14+tDhYItcQQ6S6XkHyiAUfJG0KtkOQvs=; b=JKoOPGOG4ZDuwDik0zvuAneVbJr+oZXsXvLsTI7e1jxS4mJB2kq1lo0EsQNK0RBtQA 95S2Xk5Lt7I92JxQsXVwpMlR0MpvyZud7xS2ABBQzL8cOK79nbyH6JnO/9OjjLvbY/qh Us/1rGcQC+YokqZF7+FmfOKn//KiDmFx2Vu6WZOrnunxaAa32bguby95kFAM2s5eEPcP keT52LjNqyuhZgZmBUlj4T4Mg6JL7oXazfpZeJu1+a4UWZUPlm2Ri9r+/NiRUGlIVsli VS8wRYsK9VZFe1pF4QoF1KB1WwFyfzkRfdBrKTu8UkBlvRQstpnEB6GFCFUVOjxsQoUP +Ixg== X-Gm-Message-State: ALQs6tAbn6rWulQ5eg6pLz5FR0J0Uzk61f/R8X+1ZDKRG+1wSjeag9mr McfJdavoFLjCFX4efBmqkeotTPvWI+k= X-Received: by 10.28.106.5 with SMTP id f5mr624997wmc.84.1523296066561; Mon, 09 Apr 2018 10:47:46 -0700 (PDT) Received: from localhost (116.58.7.51.dyn.plus.net. [51.7.58.116]) by smtp.gmail.com with ESMTPSA id 134sm1637209wmt.29.2018.04.09.10.47.45 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 09 Apr 2018 10:47:45 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: Add missing cases to vect_get_smallest_scalar_type (PR 85286) Date: Mon, 09 Apr 2018 18:47:45 +0100 Message-ID: <877epg6zlq.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) MIME-Version: 1.0 In this PR we used WIDEN_SUM_EXPR to vectorise: short i, y; int sum; [...] for (i = x; i > 0; i--) sum += y; with 4 ints and 8 shorts per vector. The problem was that we set the VF based only on the ints, then calculated the number of vector copies based on the shorts, giving 4/8. Previously that led to ncopies==0, but after r249897 we pick it up as an ICE. In this particular case we could vectorise the reduction by setting ncopies based on the output type rather than the input type, but it doesn't seem worth adding a special "optimisation" for such a pathological case. I think it's really an instance of the more general problem that we can't vectorise using combinations of (say) 64-bit and 128-bit vectors on targets that support both. Tested on aarch64-linux-gnu and x86_64-linux-gnu. OK to install? Richard 2018-04-09 Richard Sandiford gcc/ PR tree-optimization/85286 * tree-vect-data-refs.c (vect_get_smallest_scalar_type): gcc/testsuite/ * gcc.dg/vect/pr85286.c: New test. Index: gcc/tree-vect-data-refs.c =================================================================== --- gcc/tree-vect-data-refs.c 2018-03-24 10:52:25.616823316 +0000 +++ gcc/tree-vect-data-refs.c 2018-04-09 18:44:09.676561821 +0100 @@ -132,6 +132,8 @@ vect_get_smallest_scalar_type (gimple *s if (is_gimple_assign (stmt) && (gimple_assign_cast_p (stmt) + || gimple_assign_rhs_code (stmt) == DOT_PROD_EXPR + || gimple_assign_rhs_code (stmt) == WIDEN_SUM_EXPR || gimple_assign_rhs_code (stmt) == WIDEN_MULT_EXPR || gimple_assign_rhs_code (stmt) == WIDEN_LSHIFT_EXPR || gimple_assign_rhs_code (stmt) == FLOAT_EXPR)) Index: gcc/testsuite/gcc.dg/vect/pr85286.c =================================================================== --- /dev/null 2018-04-08 19:55:28.217132277 +0100 +++ gcc/testsuite/gcc.dg/vect/pr85286.c 2018-04-09 18:44:09.675561881 +0100 @@ -0,0 +1,19 @@ +/* PR tree-optimization/45241 */ +/* { dg-do compile } */ +/* { dg-additional-options "--param scev-max-expr-complexity=0" } */ + +int +foo (short x) +{ + short i, y; + int sum; + + for (i = 0; i < x; i++) + y = x * i; + + for (i = x; i > 0; i--) + sum += y; + + return sum; +} +