From patchwork Fri Nov 17 09:18:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 838906 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-467096-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="WoCAw1d5"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3ydXcT47l7z9s4q for ; Fri, 17 Nov 2017 20:19:21 +1100 (AEDT) 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:references:date:in-reply-to:message-id:mime-version :content-type; q=dns; s=default; b=Y/tZIZz619kUkUaQHja489KYslztz q6EqNrMHMgIryr5PzB7AXTb9Rtls9cVkxwvMm94DceXh/Cd02PDO3KrdJonboclK /MMQI9L1uRW1ZD/hg5ndkiwBHAA832bRTxL/xV2IO63+gqQGFKdcIpaFZcfGG4Gh eY93Xob2VpYjqM= 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:references:date:in-reply-to:message-id:mime-version :content-type; s=default; bh=MNrLj6uP9maTynP8UAcWLdIj4ow=; b=WoC Aw1d5k8WjkmF1XIXiDr2pRzddMKQh83H5vjySlEqgiPuOITiZpObi4zyTZYacL9j i+d0gbCQKpdSdh+BNzB4HB3QuomG/EqYO5Xq0+/O4TMCO6+3JMaLZ6O134Mu0fAS vPfAsglBCXD87pAppBJNcpqu/gLi2FCLNHD+KBFk= Received: (qmail 116380 invoked by alias); 17 Nov 2017 09:18:24 -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 116345 invoked by uid 89); 17 Nov 2017 09:18:23 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.5 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KB_WAM_FROM_NAME_SINGLEWORD, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-wm0-f43.google.com Received: from mail-wm0-f43.google.com (HELO mail-wm0-f43.google.com) (74.125.82.43) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 17 Nov 2017 09:18:21 +0000 Received: by mail-wm0-f43.google.com with SMTP id v186so5014545wma.2 for ; Fri, 17 Nov 2017 01:18:21 -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:references:date :in-reply-to:message-id:user-agent:mime-version; bh=9PYpMZqa9knvQ7ffhXXJpH6aWjgfk9WgoWH5MLgdWHI=; b=gSzvZlaYzOvLnsLBuqNTJLbSl1t/zk/eaEG9HWgb7d7rdKQmX6D03Og8EmKEM8ZB06 v+XR4SlPOPy3gmLZDruLoKYIaLVzzCojSuth3W2AqEywSMDIEOMFU4DqENgDFPVfnqf1 qT9d2IECp7A1YhebIb6kXcm/3GMXgxrmyQckOMJG1Spiz194Gcen0xz2L/yRL17f2GTq VNyWJmieqQYt+Ii2YnB0YdRMQs+TKvF22rZCEDqisZv23f2chScCPMmxzlHOxhOPH8Yp QG/ff7RaJ4gJilsnguuz/hWCFC5TriP3pmbcNeCIicQEPRbMzHpoKpUiRYyvBelDUr4D uK2A== X-Gm-Message-State: AJaThX4IXYVD3iDXVgH686ztrNFCX/OLXA+r37Boe9UFecNZ6iKBPXQJ CVb8RVaVhRqUNpHxipnJ5D3+VWAN/t8= X-Google-Smtp-Source: AGs4zMYvL1mfT8dmVHaOLSyEHyLs66OJZGJttOuMcKhQxRGYmY0HsPVHJUtsNrkiRCpxlAHsYlbkFA== X-Received: by 10.28.247.15 with SMTP id v15mr3446759wmh.152.1510910299222; Fri, 17 Nov 2017 01:18:19 -0800 (PST) Received: from localhost ([2.25.234.120]) by smtp.gmail.com with ESMTPSA id o20sm3114785wro.6.2017.11.17.01.18.18 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 17 Nov 2017 01:18:18 -0800 (PST) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [3/7] Split mask checking out of vectorizable_mask_load_store References: <87375d2rkr.fsf@linaro.org> Date: Fri, 17 Nov 2017 09:18:19 +0000 In-Reply-To: <87375d2rkr.fsf@linaro.org> (Richard Sandiford's message of "Fri, 17 Nov 2017 09:16:20 +0000") Message-ID: <87po8h1cx0.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) MIME-Version: 1.0 This patch splits the mask argument checking out of vectorizable_mask_load_store, so that a later patch can use it in both vectorizable_load and vectorizable_store. It also adds dump messages for false returns. This is mostly useful for the TYPE_VECTOR_SUBPARTS check, which can fail if pattern recognition didn't convert the mask properly. Richard 2017-11-17 Richard Sandiford gcc/ * tree-vect-stmts.c (vect_check_load_store_mask): New function, split out from... (vectorizable_mask_load_store): ...here. Index: gcc/tree-vect-stmts.c =================================================================== --- gcc/tree-vect-stmts.c 2017-11-17 09:06:46.238323981 +0000 +++ gcc/tree-vect-stmts.c 2017-11-17 09:06:49.784303349 +0000 @@ -2023,6 +2023,74 @@ get_load_store_type (gimple *stmt, tree return true; } +/* Return true if boolean argument MASK is suitable for vectorizing + conditional load or store STMT. When returning true, store the + type of the vectorized mask in *MASK_VECTYPE_OUT. */ + +static bool +vect_check_load_store_mask (gimple *stmt, tree mask, tree *mask_vectype_out) +{ + if (!VECT_SCALAR_BOOLEAN_TYPE_P (TREE_TYPE (mask))) + { + if (dump_enabled_p ()) + dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, + "mask argument is not a boolean.\n"); + return false; + } + + if (TREE_CODE (mask) != SSA_NAME) + { + if (dump_enabled_p ()) + dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, + "mask argument is not an SSA name.\n"); + return false; + } + + stmt_vec_info stmt_info = vinfo_for_stmt (stmt); + gimple *def_stmt; + enum vect_def_type dt; + tree mask_vectype; + if (!vect_is_simple_use (mask, stmt_info->vinfo, &def_stmt, &dt, + &mask_vectype)) + { + if (dump_enabled_p ()) + dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, + "mask use not simple.\n"); + return false; + } + + tree vectype = STMT_VINFO_VECTYPE (stmt_info); + if (!mask_vectype) + mask_vectype = get_mask_type_for_scalar_type (TREE_TYPE (vectype)); + + if (!mask_vectype || !VECTOR_BOOLEAN_TYPE_P (mask_vectype)) + { + if (dump_enabled_p ()) + dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, + "could not find an appropriate vector mask type.\n"); + return false; + } + + if (may_ne (TYPE_VECTOR_SUBPARTS (mask_vectype), + TYPE_VECTOR_SUBPARTS (vectype))) + { + if (dump_enabled_p ()) + { + dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, + "vector mask type "); + dump_generic_expr (MSG_MISSED_OPTIMIZATION, TDF_SLIM, mask_vectype); + dump_printf (MSG_MISSED_OPTIMIZATION, + " does not match vector data type "); + dump_generic_expr (MSG_MISSED_OPTIMIZATION, TDF_SLIM, vectype); + dump_printf (MSG_MISSED_OPTIMIZATION, ".\n"); + } + return false; + } + + *mask_vectype_out = mask_vectype; + return true; +} + /* Function vectorizable_mask_load_store. Check if STMT performs a conditional load or store that can be vectorized. @@ -2065,11 +2133,6 @@ vectorizable_mask_load_store (gimple *st ncopies = vect_get_num_copies (loop_vinfo, vectype); gcc_assert (ncopies >= 1); - mask = gimple_call_arg (stmt, 2); - - if (!VECT_SCALAR_BOOLEAN_TYPE_P (TREE_TYPE (mask))) - return false; - /* FORNOW. This restriction should be relaxed. */ if (nested_in_vect_loop && ncopies > 1) { @@ -2089,21 +2152,11 @@ vectorizable_mask_load_store (gimple *st if (!STMT_VINFO_DATA_REF (stmt_info)) return false; - elem_type = TREE_TYPE (vectype); - - if (TREE_CODE (mask) != SSA_NAME) - return false; - - if (!vect_is_simple_use (mask, loop_vinfo, &def_stmt, &dt, &mask_vectype)) + mask = gimple_call_arg (stmt, 2); + if (!vect_check_load_store_mask (stmt, mask, &mask_vectype)) return false; - if (!mask_vectype) - mask_vectype = get_mask_type_for_scalar_type (TREE_TYPE (vectype)); - - if (!mask_vectype || !VECTOR_BOOLEAN_TYPE_P (mask_vectype) - || may_ne (TYPE_VECTOR_SUBPARTS (mask_vectype), - TYPE_VECTOR_SUBPARTS (vectype))) - return false; + elem_type = TREE_TYPE (vectype); if (gimple_call_internal_fn (stmt) == IFN_MASK_STORE) {