From patchwork Fri Nov 17 09:18:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 119105 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp281777qgn; Fri, 17 Nov 2017 01:20:21 -0800 (PST) X-Google-Smtp-Source: AGs4zMbcCs5v52F6PSx7lvuj8t6QxgpmRyLLoMYm3dFt42wOFy8A3oBn5ZhDUX//DQDgx5r/qXIw X-Received: by 10.98.87.13 with SMTP id l13mr1393219pfb.193.1510910421613; Fri, 17 Nov 2017 01:20:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510910421; cv=none; d=google.com; s=arc-20160816; b=d0uE1rZxlaQpslGm/BIlOAN2Xqvn/XrzndueMnbUuHZP5EsNu1wYQKEoHAcouIjb7q HH3z4WGDNMIoI4gK2iqTcgQ7LJSag9NcwzF8URFG98U+fQSQkhVy5rvzlx+O1XZIM3im O1RSWdyTf8sckMktJbgepv0pkvniOceZp4RRniVTSLz5atkh3rY0mZ2qUBQ8aiOcnYMG hLa8cQTWOBN8kII0WKPM+R9OnAZNz6FKw5CJtIAVAIn1+SIe+SAD2yi4OPi9fx49incK cS96bgHPfYN+8qa7XdJ+VnEs4wtohSON3lEgzqCraJOnlW910MNwBoOxfbs6L5Lv/0UP jB+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:user-agent:message-id:in-reply-to:date:references :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=rTwoY6TAF9nCZoHtLallF5BOPEV2sCchpPQt2yw2GMU=; b=d7/bmUt/cvci8PnEBeNEI2SWgbze+hYD9b+YwaOO5WyvhmBxqeVgmwx4u2nTfLGHc8 SEXTqC20OL75zL4BS/E0iHwbWjSlO74HMaoMk+CWitDmOLW1ChwLcSOxe0eT32Xwy2g7 wBR9a8mfY0RGwRosYRaWqiBT6oXJyhlY397OPDcrGlfdQdgsgD5nFAI7ttj9UsFbdFBA ODNKUoGZb43FRi9uyzyjnmOHlDlz1bsm0qPkduUcGfofcXwORSQfUuRMh09KGn9+8isL 6OhjgVQVuk009NLpH+Yki5OvRCGndw4PQ8gq2UDgtAxL+haT7SEB+ANIRSU+NnQnQ/1V 9wEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=gZQjm/KA; spf=pass (google.com: domain of gcc-patches-return-467098-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-467098-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 a90si2428605plc.722.2017.11.17.01.20.21 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 17 Nov 2017 01:20:21 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-return-467098-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=gZQjm/KA; spf=pass (google.com: domain of gcc-patches-return-467098-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-467098-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:references:date:in-reply-to:message-id:mime-version :content-type; q=dns; s=default; b=ITVhl1XvDQ9asXzOb69X7hTCwDzhu zKMGjqzjjrHctrVxPxoDANMTrEHzc2/aN/OsGoH/y+xpPttnMTn4D9eZ4K52GDu1 GHa6/kXfmMU9g+Rt1fjE08/GFGWx47iPY/udmsyq7iIgIqtqh4miwUg3JVDOiZtg EGx9IBQ1LbPArI= 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=JyFrc62DiAOgwto5nCTrUycAMX8=; b=gZQ jm/KA/IGAX88noet9qFzycs6IZrj2VIQQs9pG00Paut1aEhoTnjWRTuARux8kJL8 o2eP1Hfb/Z4AXT0bYHmCAZ+AqWFYKwX3DjknvCldyZ/duE+KIIi2p/jYq2U8DpDr bKxcUE3trJ/iFSrBJng3NUAl0XP9EycnWiZM+CTw= Received: (qmail 118193 invoked by alias); 17 Nov 2017 09:19:02 -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 118137 invoked by uid 89); 17 Nov 2017 09:19:01 -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-wr0-f178.google.com Received: from mail-wr0-f178.google.com (HELO mail-wr0-f178.google.com) (209.85.128.178) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 17 Nov 2017 09:19:00 +0000 Received: by mail-wr0-f178.google.com with SMTP id u97so1528688wrc.1 for ; Fri, 17 Nov 2017 01:18:59 -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=rTwoY6TAF9nCZoHtLallF5BOPEV2sCchpPQt2yw2GMU=; b=O7Lr1Zujk21kaC9kYsxGBNhj4GLXH7iFJUDhNWX8Krwyy/ovDhxnswUpUs/grPbHPl BBKm/8xA1Ry1kRSl4YGomXsZama5odPznZcT7H9/t390oYL5nWXDVMqJhV1eCcMkcZYo aGVs+ph+adI8cXuW4s6ydaC4klMHN8FZoLntQTOJZEsCqC2s9DncEzj5ochMI3AxOgiZ 160tKGH2yyWBfC9YdaV1rbQvhDzzt0rfabeiX29nENVn1hwNr7uoMWy+3RYr8ns/S6GH GG2TJiK0I+KgZngnFv1vacV/PMqS9wVcJbBJCaw9HpPlO5A2zpp0pAC6GQWBtwWzQm1C D3LA== X-Gm-Message-State: AJaThX6ChVOb/6wWqEg6I8WkHVUTpObmpqM8RQc/cHRelgyjDtXT67YC M6kjAbLc9iVKNBjL0V9Sy4XhZylXPkw= X-Received: by 10.223.165.4 with SMTP id i4mr3988153wrb.158.1510910337737; Fri, 17 Nov 2017 01:18:57 -0800 (PST) Received: from localhost ([2.25.234.120]) by smtp.gmail.com with ESMTPSA id n14sm3760094wrg.38.2017.11.17.01.18.56 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 17 Nov 2017 01:18:57 -0800 (PST) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [4/7] Split rhs checking out of vectorizable_{,mask_load_}store References: <87375d2rkr.fsf@linaro.org> Date: Fri, 17 Nov 2017 09:18:58 +0000 In-Reply-To: <87375d2rkr.fsf@linaro.org> (Richard Sandiford's message of "Fri, 17 Nov 2017 09:16:20 +0000") Message-ID: <87lgj51cvx.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) MIME-Version: 1.0 This patch splits out the rhs checking code that's common to both vectorizable_mask_load_store and vectorizable_store. Richard 2017-11-17 Richard Sandiford gcc/ * tree-vect-stmts.c (vect_check_store_rhs): New function, split out from... (vectorizable_mask_load_store): ...here. (vectorizable_store): ...and here. Index: gcc/tree-vect-stmts.c =================================================================== --- gcc/tree-vect-stmts.c 2017-11-17 09:06:49.784303349 +0000 +++ gcc/tree-vect-stmts.c 2017-11-17 09:06:53.395522598 +0000 @@ -2091,6 +2091,55 @@ vect_check_load_store_mask (gimple *stmt return true; } +/* Return true if stored value RHS is suitable for vectorizing store + statement STMT. When returning true, store the type of the + vectorized store value in *RHS_VECTYPE_OUT and the type of the + store in *VLS_TYPE_OUT. */ + +static bool +vect_check_store_rhs (gimple *stmt, tree rhs, tree *rhs_vectype_out, + vec_load_store_type *vls_type_out) +{ + /* In the case this is a store from a constant make sure + native_encode_expr can handle it. */ + if (CONSTANT_CLASS_P (rhs) && native_encode_expr (rhs, NULL, 64) == 0) + { + if (dump_enabled_p ()) + dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, + "cannot encode constant as a byte sequence.\n"); + return false; + } + + stmt_vec_info stmt_info = vinfo_for_stmt (stmt); + gimple *def_stmt; + enum vect_def_type dt; + tree rhs_vectype; + if (!vect_is_simple_use (rhs, stmt_info->vinfo, &def_stmt, &dt, + &rhs_vectype)) + { + if (dump_enabled_p ()) + dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, + "use not simple.\n"); + return false; + } + + tree vectype = STMT_VINFO_VECTYPE (stmt_info); + if (rhs_vectype && !useless_type_conversion_p (vectype, rhs_vectype)) + { + if (dump_enabled_p ()) + dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, + "incompatible vector types.\n"); + return false; + } + + *rhs_vectype_out = rhs_vectype; + if (dt == vect_constant_def || dt == vect_external_def) + *vls_type_out = VLS_STORE_INVARIANT; + else + *vls_type_out = VLS_STORE; + return true; +} + /* Function vectorizable_mask_load_store. Check if STMT performs a conditional load or store that can be vectorized. @@ -2161,12 +2210,8 @@ vectorizable_mask_load_store (gimple *st if (gimple_call_internal_fn (stmt) == IFN_MASK_STORE) { tree rhs = gimple_call_arg (stmt, 3); - if (!vect_is_simple_use (rhs, loop_vinfo, &def_stmt, &dt, &rhs_vectype)) + if (!vect_check_store_rhs (stmt, rhs, &rhs_vectype, &vls_type)) return false; - if (dt == vect_constant_def || dt == vect_external_def) - vls_type = VLS_STORE_INVARIANT; - else - vls_type = VLS_STORE; } else vls_type = VLS_LOAD; @@ -2200,9 +2245,7 @@ vectorizable_mask_load_store (gimple *st else if (!VECTOR_MODE_P (TYPE_MODE (vectype)) || !can_vec_mask_load_store_p (TYPE_MODE (vectype), TYPE_MODE (mask_vectype), - vls_type == VLS_LOAD) - || (rhs_vectype - && !useless_type_conversion_p (vectype, rhs_vectype))) + vls_type == VLS_LOAD)) return false; if (!vec_stmt) /* transformation not required. */ @@ -5798,26 +5841,7 @@ vectorizable_store (gimple *stmt, gimple } op = gimple_assign_rhs1 (stmt); - - /* In the case this is a store from a constant make sure - native_encode_expr can handle it. */ - if (CONSTANT_CLASS_P (op) && native_encode_expr (op, NULL, 64) == 0) - return false; - - if (!vect_is_simple_use (op, vinfo, &def_stmt, &dt, &rhs_vectype)) - { - if (dump_enabled_p ()) - dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, - "use not simple.\n"); - return false; - } - - if (dt == vect_constant_def || dt == vect_external_def) - vls_type = VLS_STORE_INVARIANT; - else - vls_type = VLS_STORE; - - if (rhs_vectype && !useless_type_conversion_p (vectype, rhs_vectype)) + if (!vect_check_store_rhs (stmt, op, &rhs_vectype, &vls_type)) return false; elem_type = TREE_TYPE (vectype);