From patchwork Fri Sep 15 10:47:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 112707 Delivered-To: patch@linaro.org Received: by 10.80.163.150 with SMTP id s22csp452602edb; Fri, 15 Sep 2017 03:47:26 -0700 (PDT) X-Received: by 10.99.4.204 with SMTP id 195mr24680432pge.35.1505472446313; Fri, 15 Sep 2017 03:47:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1505472446; cv=none; d=google.com; s=arc-20160816; b=0AtSyC6S5hj5O73UXhBvgvzCu3EXiJsnHAO7tkhvz1UVbiQ/dy9juuv6oYUNjJHlJS CKyiHTzvAojhq2CPho1NFKUNWij1gLpFyOpjq+3sCsS0YDMTpgahb+MVT8vp6AodEnJK BF4YMNWjuejNNzGH576volSEJ0Ct+eP4mRfRxDQYJyS/L9sgHWC5WEAgVsG0G5eRMddU MIihAYto/Hce4+deB5nGgszOJvPJFlX+5/w0j2kPQW/5H00CYyz/v/MLV7pcixTyAquy SlqusWmaF8ulrcGPWY9uvT1UMbiQJqd/5EMZP61CDBlYINvocB0A8LB3unPMWGN9KdaI 2Z5Q== 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=1B0VSO6Zv3PdBEWEWrzOaMp0RRyVdOiadTuJtUz+RNk=; b=t7Cs0YMuxJ0bADHqOCpYzWNozMENfO7VDcIAmugQDJNrvc3a/Oqr5keSvFaKdC+dsh HHzXxuZl065Trdu9AC0F/2yPyhrkEN5X5KQ3Ax6J+oIySxm3n0/iv0zdVRKKuIkinZNx rxsczK33IIAU4dvqJ3lbEAwaPJWN4a5ydolHjILyfd8Qs/zyfBRo1+8VICDRfauwTdiV e1Y7CbizJCMr4qRF7YqXyr8LmM/MQxaGegg8k+y8PgXK0wdvGyuanYo4yFWSSpWR/gOl UcjrKVYJcWSJupk46lgrTTjlaRbGhgTrEMWYNCSF/PWdY/j4qIpYyqyoJ7nY51yh/2ls pqNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=VTG0RzKs; spf=pass (google.com: domain of gcc-patches-return-462219-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-462219-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 h19si459994pgk.399.2017.09.15.03.47.25 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 15 Sep 2017 03:47:26 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-462219-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=VTG0RzKs; spf=pass (google.com: domain of gcc-patches-return-462219-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-462219-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=RklCz9GcToDOzQfEzPZki81SDvrXv3gMDWkDrxh/YRGAyckTpdl1c UwVxAADykT3CL6SJNyfIpDgpd35NPaL6gfYt/YAmfnakrMNuRwhxzv+yT/N0ChH/ pM7H75fVH29Omv0rWOd66DRPP4Vshbx2ycRjPJYHErz7IkxLpGBAX0= 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=N9+L7c533h0/0RuRsDO2R9VtTXs=; b=VTG0RzKsOTjw7t+J0hfe 4/SDP4iT2QUW2mDsa4YVTc8lFDWZskAz92i8eUIm1ZnioxOEzyl41P9toeP4sk8b 6cs9NSe9j3BgylPq4Z0Ffat9fjvmyw76g/psHaQEKBTYvM9VNjGpaDayrZdiz0N+ mCkQ+X23g7utqNHnZNsoKhg= Received: (qmail 82430 invoked by alias); 15 Sep 2017 10:47:13 -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 82417 invoked by uid 89); 15 Sep 2017 10:47:12 -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= X-HELO: mail-wr0-f169.google.com Received: from mail-wr0-f169.google.com (HELO mail-wr0-f169.google.com) (209.85.128.169) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 15 Sep 2017 10:47:11 +0000 Received: by mail-wr0-f169.google.com with SMTP id u96so1484755wrb.6 for ; Fri, 15 Sep 2017 03:47:11 -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=1B0VSO6Zv3PdBEWEWrzOaMp0RRyVdOiadTuJtUz+RNk=; b=P+qxYPF68brYMPqyL3rAHOhtG+lyjXdA/qnf0KEJGVztfILHAU3aLSGLzQ5CZabs0v 0codq3szmAYLT2ywcml5Wui1JQUQpktacEYkfADTwq3O3PZkmc6ckUpmAAfX92hNcjMk a5nwzVBzz4RKLSc+hwj0/91LruhnlNyO9kR0Vj1Se98XXQxmInI8/8AB7U/Lor9HqMUt uhIuIVEzsrM+GuNyim3oYJME/z2DdHYqqqKlFtuh1zQxZxgfGmIEyoJPezcpbhgkFsyI QPKje0QuhKyRNXkPTo/coxihn6Sg2e8x0bkD+oreSgwlXTZz2KKKracCYUXLqckT+1U1 QMMw== X-Gm-Message-State: AHPjjUhDraOgQE+m0FLbwS8T3b9tsGu5wbmHsofkKA2xD8kxHahh7pA2 MoWCxUP/2sPaf+Mh0rTSuQ== X-Google-Smtp-Source: ADKCNb6WACa5eU0CJ3q/130ZDa+zypefd8+Bz0DZ87O+kwnJBWwdrTyEQtHLJ1+teK7Y67JVVFXE0Q== X-Received: by 10.223.139.211 with SMTP id w19mr20042013wra.199.1505472429306; Fri, 15 Sep 2017 03:47:09 -0700 (PDT) Received: from localhost (92.40.248.1.threembb.co.uk. [92.40.248.1]) by smtp.gmail.com with ESMTPSA id d18sm462158wra.89.2017.09.15.03.47.08 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 15 Sep 2017 03:47:08 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: Fix vectorizable_mask_load_store handling of invariant masks Date: Fri, 15 Sep 2017 11:47:07 +0100 Message-ID: <8760cknsr8.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 vectorizable_mask_load_store was not passing the required mask type to vect_get_vec_def_for_operand. This doesn't matter for masks that are defined in the loop, since their STMT_VINFO_VECTYPE will be what we need anyway. But it's not possible to tell which mask type the caller needs when looking at an invariant scalar boolean. As the comment above the function says: In case OP is an invariant or constant, a new stmt that creates a vector def needs to be introduced. VECTYPE may be used to specify a required type for vector invariant. This fixes the attached testcase for SVE. Tested on aarch64-linux-gnu, x86_64-linux-gnu and powerpc64le-linux-gnu. OK to install? Richard 2017-09-15 Richard Sandiford gcc/ * tree-vect-stmts.c (vectorizable_mask_load_store): Pass mask_vectype to vect_get_vec_def_for_operand when getting the mask operand. gcc/testsuite/ * gfortran.dg/vect/mask-store-1.f90: New test. Index: gcc/tree-vect-stmts.c =================================================================== --- gcc/tree-vect-stmts.c 2017-09-15 11:36:58.331030784 +0100 +++ gcc/tree-vect-stmts.c 2017-09-15 11:39:17.850889641 +0100 @@ -2331,7 +2331,8 @@ vectorizable_mask_load_store (gimple *st { tree rhs = gimple_call_arg (stmt, 3); vec_rhs = vect_get_vec_def_for_operand (rhs, stmt); - vec_mask = vect_get_vec_def_for_operand (mask, stmt); + vec_mask = vect_get_vec_def_for_operand (mask, stmt, + mask_vectype); /* We should have catched mismatched types earlier. */ gcc_assert (useless_type_conversion_p (vectype, TREE_TYPE (vec_rhs))); @@ -2388,7 +2389,8 @@ vectorizable_mask_load_store (gimple *st if (i == 0) { - vec_mask = vect_get_vec_def_for_operand (mask, stmt); + vec_mask = vect_get_vec_def_for_operand (mask, stmt, + mask_vectype); dataref_ptr = vect_create_data_ref_ptr (stmt, vectype, NULL, NULL_TREE, &dummy, gsi, &ptr_incr, false, &inv_p); Index: gcc/testsuite/gfortran.dg/vect/mask-store-1.f90 =================================================================== --- /dev/null 2017-09-15 10:12:35.472207962 +0100 +++ gcc/testsuite/gfortran.dg/vect/mask-store-1.f90 2017-09-15 11:39:17.849889812 +0100 @@ -0,0 +1,11 @@ +subroutine foo(a, b, x, n) + real(kind=8) :: a(n), b(n), tmp + logical(kind=1) :: x + integer(kind=4) :: i, n + do i = 1, n + if (x) then + a(i) = b(i) + end if + b(i) = b(i) + 10 + end do +end subroutine