From patchwork Fri Nov 17 09:17:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 119102 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp279579qgn; Fri, 17 Nov 2017 01:17:47 -0800 (PST) X-Google-Smtp-Source: AGs4zMZSo2T7j7Gbha6F3XTVpySbrKaGJw7LqB7iN6TqYfQcN1+ZsNeLKzx8BthDTewsbpTvyOna X-Received: by 10.98.155.129 with SMTP id e1mr1390099pfk.119.1510910267726; Fri, 17 Nov 2017 01:17:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510910267; cv=none; d=google.com; s=arc-20160816; b=p2XCB02THd8ZwLE9kGLTjQkNaWItfRq9PTdbXIoKcWSao7BSkJUwfeSK2F/Qm1jpjd uPGivPnkszt+yv8P2DUhzHtxPfmBCnzWnsjTuSHGvqKSMtTkJu+RglRCGz1UGRdfdDl3 VWF1fNY27cTOo1UHe+Itdp7EWwmNZszfwql2dog6d0bwILU5QY/c+DrbLovk9qjw/2PO gzARGFUNEl5oIFfWEPU8gNYAYOiUGCC6G3g3ezDKr7vJSub2bwvde32EatJo4YlcK9RR +xCyCtEWlgUcfF4LhVmSVumiJCz8BhtALjTWqGySDj1+ckCG38g6jVUrVykPH+P3rrkw vdBw== 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=61wdMiA6r44t1ev5nspfk68LJHRGs89yL6ZOPkDjmFw=; b=MHk7aVOcs+3fe6Seva3POyjo1Uu/0d5c/+s6LigbUaR5Atj/0dxCgtWWjXzuGojQ+z qOJypA7mQip6xPO/kstVdID6Lc32vyWTBXF/zaj5QzAqZZZsT36Xf7uy6I720m1fCKx7 1kieaN2lIMs8AHxo2p0gfa1yvnrf/dnhvd6gLCVIyzW+s7gSkhlB2oHx2CxHFsDRP5I3 TlILQtRCgdaG3G4sqwB6KH704V8j1iN+iapmwM1+6IhWn1s8YQss8nLGOjoTTVCxvFUi fNY04OLraEFWVsMGHy55hCwfLdaUP02L1SsicAmBEwlYvgE1IxulbiQC/aS5h570M9s1 if3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=GHBUtn54; spf=pass (google.com: domain of gcc-patches-return-467093-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-467093-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 w24si219391pll.440.2017.11.17.01.17.47 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 17 Nov 2017 01:17:47 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-return-467093-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=GHBUtn54; spf=pass (google.com: domain of gcc-patches-return-467093-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-467093-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=tac8FFMYa9jFAl3zMsTGCzD2f7asd kHBu4qpOL4C/jHo3Enp93ZjM2/d+IYzgFfCpinpxpYVh3B4+dWUofdTfIVOoAyZC +6sujvUfZxJJl7c6s1spx8t70tIcbONwxhQ3c2kjTAiQIDbscqSWnk4uVoZOMkwp iFuYVL2sT4rYk4= 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=RShhNvO78mLqbjTgWil49d2W2yI=; b=GHB Utn54fS4h1UXGkDNCau9nhMIZh8HGB5ECxfSY8FUDD87ZxtpD59223jgveJJi6AA y0Uj5POEXUDvxsD6GSRjhQlvIawaxtvDdOLibR8lWUxtgAX5JIl+cwpP3L77BP7O Plh7Kw7CBKpSqkYpDy5/eEaePup1pQ0FfSchJ1QA= Received: (qmail 112224 invoked by alias); 17 Nov 2017 09:17:18 -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 112214 invoked by uid 89); 17 Nov 2017 09:17:17 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-10.7 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, KB_WAM_FROM_NAME_SINGLEWORD, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=HX-Received:Fri, UD:tree-vect-stmts.c, UD:tree-vect-loop.c X-HELO: mail-wr0-f173.google.com Received: from mail-wr0-f173.google.com (HELO mail-wr0-f173.google.com) (209.85.128.173) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 17 Nov 2017 09:17:16 +0000 Received: by mail-wr0-f173.google.com with SMTP id u98so1490586wrb.13 for ; Fri, 17 Nov 2017 01:17:15 -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=61wdMiA6r44t1ev5nspfk68LJHRGs89yL6ZOPkDjmFw=; b=dSGp73v0eIPiZ5TEOGri28C4SlvMsCxSy0UfEl+iNVESfsx9LoosQsMMLkZuJ7AqrD A3v/gTTsN2sL2Fcvox5h2ivbNTZUKJ3CO3aHFuBZHVdRHRm93Cf7Lay+zNcFBbdW4dMx KSg007qBJ5DUBWwJ/y5HEqYIG4AnmGIVvYlx5Z10i9zcc+zV1Qp7Swvm2VIelRtnFiPu 1DRMuYNqeUpR0nWXoJpMTdJfUFYBKWdPRDYHj7pI0wlMuLx8bp0yn+KtHDv2SIK3rINa JghbQjMghjFwm0Dfp4cYSlXOI4NNam9YadonM8NWwikIsK9lElb+H8oqnFqAK0dOWkQy pVjg== X-Gm-Message-State: AJaThX5o1YT3dJuWwxBKoUp3JgXHG2qj/WPz88gbSvR8pli19Bj5b90O 3/T7Z7UhtjKHvvaOsjqyAUQ5tHXqUsQ= X-Received: by 10.223.135.121 with SMTP id 54mr3744955wrz.160.1510910233716; Fri, 17 Nov 2017 01:17:13 -0800 (PST) Received: from localhost ([2.25.234.120]) by smtp.gmail.com with ESMTPSA id c54sm5187711wra.84.2017.11.17.01.17.12 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 17 Nov 2017 01:17:12 -0800 (PST) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [1/7] Move code that stubs out IFN_MASK_LOADs References: <87375d2rkr.fsf@linaro.org> Date: Fri, 17 Nov 2017 09:17:13 +0000 In-Reply-To: <87375d2rkr.fsf@linaro.org> (Richard Sandiford's message of "Fri, 17 Nov 2017 09:16:20 +0000") Message-ID: <87y3n51cyu.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) MIME-Version: 1.0 vectorizable_mask_load_store replaces scalar IFN_MASK_LOAD calls with dummy assignments, so that they never survive vectorisation. This patch moves the code to vect_transform_loop instead, so that we only change the scalar statements once all of them have been vectorised. This makes it easier to handle other types of functions that need stubbing out, and also makes it easier to handle groups and patterns. Richard 2017-11-17 Richard Sandiford gcc/ * tree-vect-loop.c (vect_transform_loop): Stub out scalar IFN_MASK_LOAD calls here rather than... * tree-vect-stmts.c (vectorizable_mask_load_store): ...here. Index: gcc/tree-vect-loop.c =================================================================== --- gcc/tree-vect-loop.c 2017-11-17 09:06:36.818836579 +0000 +++ gcc/tree-vect-loop.c 2017-11-17 09:06:42.552270752 +0000 @@ -7743,6 +7743,25 @@ vect_transform_loop (loop_vec_info loop_ gsi_next (&si); } } /* stmts in BB */ + + /* Stub out scalar statements that must not survive vectorization. + Doing this here helps with grouped statements, or statements that + are involved in patterns. */ + for (gimple_stmt_iterator gsi = gsi_start_bb (bb); + !gsi_end_p (gsi); gsi_next (&gsi)) + { + gcall *call = dyn_cast (gsi_stmt (gsi)); + if (call && gimple_call_internal_p (call, IFN_MASK_LOAD)) + { + tree lhs = gimple_get_lhs (call); + if (!VECTOR_TYPE_P (TREE_TYPE (lhs))) + { + tree zero = build_zero_cst (TREE_TYPE (lhs)); + gimple *new_stmt = gimple_build_assign (lhs, zero); + gsi_replace (&gsi, new_stmt, true); + } + } + } } /* BBs in loop */ /* The vectorization factor is always > 1, so if we use an IV increment of 1. Index: gcc/tree-vect-stmts.c =================================================================== --- gcc/tree-vect-stmts.c 2017-11-17 09:06:36.818836579 +0000 +++ gcc/tree-vect-stmts.c 2017-11-17 09:06:42.553230162 +0000 @@ -2342,20 +2342,6 @@ vectorizable_mask_load_store (gimple *st STMT_VINFO_RELATED_STMT (prev_stmt_info) = new_stmt; prev_stmt_info = vinfo_for_stmt (new_stmt); } - - /* Ensure that even with -fno-tree-dce the scalar MASK_LOAD is removed - from the IL. */ - if (STMT_VINFO_RELATED_STMT (stmt_info)) - { - stmt = STMT_VINFO_RELATED_STMT (stmt_info); - stmt_info = vinfo_for_stmt (stmt); - } - tree lhs = gimple_call_lhs (stmt); - new_stmt = gimple_build_assign (lhs, build_zero_cst (TREE_TYPE (lhs))); - set_vinfo_for_stmt (new_stmt, stmt_info); - set_vinfo_for_stmt (stmt, NULL); - STMT_VINFO_STMT (stmt_info) = new_stmt; - gsi_replace (gsi, new_stmt, true); return true; } else if (vls_type != VLS_LOAD) @@ -2472,23 +2458,6 @@ vectorizable_mask_load_store (gimple *st } } - if (vls_type == VLS_LOAD) - { - /* Ensure that even with -fno-tree-dce the scalar MASK_LOAD is removed - from the IL. */ - if (STMT_VINFO_RELATED_STMT (stmt_info)) - { - stmt = STMT_VINFO_RELATED_STMT (stmt_info); - stmt_info = vinfo_for_stmt (stmt); - } - tree lhs = gimple_call_lhs (stmt); - new_stmt = gimple_build_assign (lhs, build_zero_cst (TREE_TYPE (lhs))); - set_vinfo_for_stmt (new_stmt, stmt_info); - set_vinfo_for_stmt (stmt, NULL); - STMT_VINFO_STMT (stmt_info) = new_stmt; - gsi_replace (gsi, new_stmt, true); - } - return true; }