From patchwork Thu May 17 08:21:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 136119 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp1978262lji; Thu, 17 May 2018 01:22:08 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpUpvGSqpyu67vIVthZ0FG5sTLkY+kcH/AaAORi8sAY5w4lDctfNO81k+6jYqMzHjEkW9r1 X-Received: by 2002:a63:7d47:: with SMTP id m7-v6mr3360131pgn.443.1526545327982; Thu, 17 May 2018 01:22:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526545327; cv=none; d=google.com; s=arc-20160816; b=KuMW5BnqJik75Dla8zgfeQyYeG/dYfaRTK1EhccWA8HXR37V8hCkAZjm66IWc0kqh9 g99jQ3fJaYlFzslJyOiwY/WL52RyLyBBvqRdUjlIhmXjk6OV2tE/329hTiZ5/uc4lIY/ mbglUNkNTVCecuMB24mr1BQfqbm0rDdQMBWSldWq/IJ8Q49m+c5OOIAHbVFffJCgVXNv kFyRj0c4IysxDCxiK0NGzjbeFh1RYCKNNTTmt5G94nakJJEaIGsvJVhk4oj9RwhNyW/L Bm7M4srplOxmMMawEvFnst/k3Uzj+OUUJ1nlwsmtQwjQ75LGj6GcAmOfb+GfVEVA6rBp jmDw== 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=5KQzhp5rurnHcr///UqCTSNNcwfe92ireBdV+YRzUiM=; b=Z4EsQVyxhH0SL8yfaGi1QzDJFey5d4BrPPrPvp4M7jRM/MpdzeJ+hD63sMSlKmr8T9 TzciGiEV3tpeMyqhRemNcAYyQjr+h1W6FBpSEjNt0OjpSVwUpEccyvuytCc1ZJaCbDRY Q33V5mE6fwvSjffo4wpbknX0ASzPDBNFiFC/kzUJ3ko7olSv4vxr7OIu+AMTQp6rWPJA tOhC9o4xxCJ5KYJl0Bc4d9XphQY+ihqB4pCQdCiKC07k1IOuQXnPludg6RB95Z4sDpLS ddPO4iw0Jd2I1RZgJLuFiTRI4QhLjyd1+qv4GEpHBol6y1j+rhW7aY3PCsuFWZIArjGZ Yz+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=dUXsKNak; spf=pass (google.com: domain of gcc-patches-return-477805-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-477805-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 1-v6si4650061plx.236.2018.05.17.01.22.07 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 17 May 2018 01:22:07 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-477805-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=dUXsKNak; spf=pass (google.com: domain of gcc-patches-return-477805-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-477805-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=hR0d6JaACe7n3dXZSALxwLy4K9JZw5/XfqTFXZd4ZubgPKtMaLSRP +/weOcqfO1cVQJ6MPrr3OqUF5xDugoE65Vtzz1z5IOHv1OfhZ34UTv0fR9aRuXoN 6OQ1HGQYNBCX3oRmBlDSVY6QhTDqEek8TCSQrOduYLvYmoLJbqUoPQ= 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=BsZKQSDMzXjCAwplOwLDWzoEDDw=; b=dUXsKNakqDFTIHGw/zrJ HN+qCVsWmHVyWJGW3QcJRLRVQV6RMhej2uXKuLqJdeh1OnP1YXHmYYiNVETltYyh ndNUYjcq4X0G6uUt45RqvqbaEZRGH73zuHxfq1NFjlv92NP1fjFI1tKz976sfiwk YAS39qnDEJ9PZ6i3OCkum6Q= Received: (qmail 114602 invoked by alias); 17 May 2018 08:21:55 -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 114328 invoked by uid 89); 17 May 2018 08:21:19 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-10.8 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=Builtin, gcall 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; Thu, 17 May 2018 08:21:16 +0000 Received: by mail-wr0-f178.google.com with SMTP id p4-v6so4696136wrh.3 for ; Thu, 17 May 2018 01:21:16 -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=5KQzhp5rurnHcr///UqCTSNNcwfe92ireBdV+YRzUiM=; b=tcL+lgIgCvfgxgQm/TV0DO6/6zVsr/g9ppNf3vf6xvfrOiT/I+UMgeesIPLom7PcED qQseXw/qPuVoPjvzqWGDyUVQIu2VJelqv7V0sUJdyLv7Uy/ysiImicRbrTYQGa64Vi7o LuQvLXGkpSF/Zp1vka0zmqrz8yJILNf2zV9ehaxQeSFT1hI3jzldRLn8edgrYvlPahzP cyHmccHmmqjbf8n2FEd1NLsIWXRV3U6n+cDGfexmVvrsDeDy3JS4DK1KbXQQFb4kA6xA ytwIhLSiOrbPLXsu2dV/U3R+fFPSgzEn+DZt3cBltPV39MYIv4octhONrXx7B8hhKsWF 0XDg== X-Gm-Message-State: ALKqPwd2qL/Q4qtH46Tqoc76xw4DV/Jbn/p0gaTtHElXl0Klt+dEILyB EsGdFENRlaWiMOM+4fnUzxTLBVocewc= X-Received: by 2002:adf:b8b0:: with SMTP id i45-v6mr3299703wrf.105.1526545274229; Thu, 17 May 2018 01:21:14 -0700 (PDT) Received: from localhost ([217.140.96.141]) by smtp.gmail.com with ESMTPSA id k130-v6sm6799332wmg.15.2018.05.17.01.21.13 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 17 May 2018 01:21:13 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: Allow gimple_build with internal functions Date: Thu, 17 May 2018 09:21:12 +0100 Message-ID: <87603mofpj.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) MIME-Version: 1.0 This patch makes the function versions of gimple_build and gimple_simplify take combined_fns rather than built_in_codes, so that they work with internal functions too. The old gimple_builds were unused, so no existing callers need to be updated. Tested on aarch64-linux-gnu (with and without SVE), aarch64_be-elf and x86_64-linux-gnu. OK to install? Richard 2018-05-17 Richard Sandiford gcc/ * gimple-fold.h (gimple_build): Make the function forms take combined_fn rather than built_in_function. (gimple_simplify): Likewise. * gimple-match-head.c (gimple_simplify): Likewise. * gimple-fold.c (gimple_build): Likewise. * tree-vect-loop.c (get_initial_def_for_reduction): Use gimple_build rather than gimple_build_call_internal. (get_initial_defs_for_reduction): Likewise. (vect_create_epilog_for_reduction): Likewise. (vectorizable_live_operation): Likewise. Index: gcc/gimple-fold.h =================================================================== --- gcc/gimple-fold.h 2018-05-16 20:17:39.114152860 +0100 +++ gcc/gimple-fold.h 2018-05-17 09:17:32.876478942 +0100 @@ -86,28 +86,25 @@ gimple_build (gimple_seq *seq, { return gimple_build (seq, UNKNOWN_LOCATION, code, type, op0, op1, op2); } -extern tree gimple_build (gimple_seq *, location_t, - enum built_in_function, tree, tree); +extern tree gimple_build (gimple_seq *, location_t, combined_fn, tree, tree); inline tree -gimple_build (gimple_seq *seq, - enum built_in_function fn, tree type, tree arg0) +gimple_build (gimple_seq *seq, combined_fn fn, tree type, tree arg0) { return gimple_build (seq, UNKNOWN_LOCATION, fn, type, arg0); } -extern tree gimple_build (gimple_seq *, location_t, - enum built_in_function, tree, tree, tree); +extern tree gimple_build (gimple_seq *, location_t, combined_fn, + tree, tree, tree); inline tree -gimple_build (gimple_seq *seq, - enum built_in_function fn, tree type, tree arg0, tree arg1) +gimple_build (gimple_seq *seq, combined_fn fn, + tree type, tree arg0, tree arg1) { return gimple_build (seq, UNKNOWN_LOCATION, fn, type, arg0, arg1); } -extern tree gimple_build (gimple_seq *, location_t, - enum built_in_function, tree, tree, tree, tree); +extern tree gimple_build (gimple_seq *, location_t, combined_fn, + tree, tree, tree, tree); inline tree -gimple_build (gimple_seq *seq, - enum built_in_function fn, tree type, - tree arg0, tree arg1, tree arg2) +gimple_build (gimple_seq *seq, combined_fn fn, + tree type, tree arg0, tree arg1, tree arg2) { return gimple_build (seq, UNKNOWN_LOCATION, fn, type, arg0, arg1, arg2); } @@ -153,11 +150,11 @@ extern tree gimple_simplify (enum tree_c gimple_seq *, tree (*)(tree)); extern tree gimple_simplify (enum tree_code, tree, tree, tree, tree, gimple_seq *, tree (*)(tree)); -extern tree gimple_simplify (enum built_in_function, tree, tree, +extern tree gimple_simplify (combined_fn, tree, tree, gimple_seq *, tree (*)(tree)); -extern tree gimple_simplify (enum built_in_function, tree, tree, tree, +extern tree gimple_simplify (combined_fn, tree, tree, tree, gimple_seq *, tree (*)(tree)); -extern tree gimple_simplify (enum built_in_function, tree, tree, tree, tree, +extern tree gimple_simplify (combined_fn, tree, tree, tree, tree, gimple_seq *, tree (*)(tree)); #endif /* GCC_GIMPLE_FOLD_H */ Index: gcc/gimple-match-head.c =================================================================== --- gcc/gimple-match-head.c 2018-03-30 12:28:37.301927949 +0100 +++ gcc/gimple-match-head.c 2018-05-17 09:17:32.876478942 +0100 @@ -478,55 +478,53 @@ gimple_simplify (enum tree_code code, tr return maybe_push_res_to_seq (rcode, type, ops, seq); } -/* Builtin function with one argument. */ +/* Builtin or internal function with one argument. */ tree -gimple_simplify (enum built_in_function fn, tree type, +gimple_simplify (combined_fn fn, tree type, tree arg0, gimple_seq *seq, tree (*valueize)(tree)) { if (constant_for_folding (arg0)) { - tree res = fold_const_call (as_combined_fn (fn), type, arg0); + tree res = fold_const_call (fn, type, arg0); if (res && CONSTANT_CLASS_P (res)) return res; } code_helper rcode; tree ops[3] = {}; - if (!gimple_simplify (&rcode, ops, seq, valueize, - as_combined_fn (fn), type, arg0)) + if (!gimple_simplify (&rcode, ops, seq, valueize, fn, type, arg0)) return NULL_TREE; return maybe_push_res_to_seq (rcode, type, ops, seq); } -/* Builtin function with two arguments. */ +/* Builtin or internal function with two arguments. */ tree -gimple_simplify (enum built_in_function fn, tree type, +gimple_simplify (combined_fn fn, tree type, tree arg0, tree arg1, gimple_seq *seq, tree (*valueize)(tree)) { if (constant_for_folding (arg0) && constant_for_folding (arg1)) { - tree res = fold_const_call (as_combined_fn (fn), type, arg0, arg1); + tree res = fold_const_call (fn, type, arg0, arg1); if (res && CONSTANT_CLASS_P (res)) return res; } code_helper rcode; tree ops[3] = {}; - if (!gimple_simplify (&rcode, ops, seq, valueize, - as_combined_fn (fn), type, arg0, arg1)) + if (!gimple_simplify (&rcode, ops, seq, valueize, fn, type, arg0, arg1)) return NULL_TREE; return maybe_push_res_to_seq (rcode, type, ops, seq); } -/* Builtin function with three arguments. */ +/* Builtin or internal function with three arguments. */ tree -gimple_simplify (enum built_in_function fn, tree type, +gimple_simplify (combined_fn fn, tree type, tree arg0, tree arg1, tree arg2, gimple_seq *seq, tree (*valueize)(tree)) { @@ -534,7 +532,7 @@ gimple_simplify (enum built_in_function && constant_for_folding (arg1) && constant_for_folding (arg2)) { - tree res = fold_const_call (as_combined_fn (fn), type, arg0, arg1, arg2); + tree res = fold_const_call (fn, type, arg0, arg1, arg2); if (res && CONSTANT_CLASS_P (res)) return res; } @@ -542,7 +540,7 @@ gimple_simplify (enum built_in_function code_helper rcode; tree ops[3] = {}; if (!gimple_simplify (&rcode, ops, seq, valueize, - as_combined_fn (fn), type, arg0, arg1, arg2)) + fn, type, arg0, arg1, arg2)) return NULL_TREE; return maybe_push_res_to_seq (rcode, type, ops, seq); } Index: gcc/gimple-fold.c =================================================================== --- gcc/gimple-fold.c 2018-05-01 19:30:33.230500376 +0100 +++ gcc/gimple-fold.c 2018-05-17 09:17:32.876478942 +0100 @@ -7204,14 +7204,20 @@ gimple_build (gimple_seq *seq, location_ statements possibly defining it to SEQ. */ tree -gimple_build (gimple_seq *seq, location_t loc, - enum built_in_function fn, tree type, tree arg0) +gimple_build (gimple_seq *seq, location_t loc, combined_fn fn, + tree type, tree arg0) { tree res = gimple_simplify (fn, type, arg0, seq, gimple_build_valueize); if (!res) { - tree decl = builtin_decl_implicit (fn); - gimple *stmt = gimple_build_call (decl, 1, arg0); + gcall *stmt; + if (internal_fn_p (fn)) + stmt = gimple_build_call_internal (as_internal_fn (fn), 1, arg0); + else + { + tree decl = builtin_decl_implicit (as_builtin_fn (fn)); + stmt = gimple_build_call (decl, 1, arg0); + } if (!VOID_TYPE_P (type)) { res = create_tmp_reg_or_ssa_name (type); @@ -7230,14 +7236,20 @@ gimple_build (gimple_seq *seq, location_ statements possibly defining it to SEQ. */ tree -gimple_build (gimple_seq *seq, location_t loc, - enum built_in_function fn, tree type, tree arg0, tree arg1) +gimple_build (gimple_seq *seq, location_t loc, combined_fn fn, + tree type, tree arg0, tree arg1) { tree res = gimple_simplify (fn, type, arg0, arg1, seq, gimple_build_valueize); if (!res) { - tree decl = builtin_decl_implicit (fn); - gimple *stmt = gimple_build_call (decl, 2, arg0, arg1); + gcall *stmt; + if (internal_fn_p (fn)) + stmt = gimple_build_call_internal (as_internal_fn (fn), 2, arg0, arg1); + else + { + tree decl = builtin_decl_implicit (as_builtin_fn (fn)); + stmt = gimple_build_call (decl, 2, arg0, arg1); + } if (!VOID_TYPE_P (type)) { res = create_tmp_reg_or_ssa_name (type); @@ -7256,16 +7268,22 @@ gimple_build (gimple_seq *seq, location_ statements possibly defining it to SEQ. */ tree -gimple_build (gimple_seq *seq, location_t loc, - enum built_in_function fn, tree type, - tree arg0, tree arg1, tree arg2) +gimple_build (gimple_seq *seq, location_t loc, combined_fn fn, + tree type, tree arg0, tree arg1, tree arg2) { tree res = gimple_simplify (fn, type, arg0, arg1, arg2, seq, gimple_build_valueize); if (!res) { - tree decl = builtin_decl_implicit (fn); - gimple *stmt = gimple_build_call (decl, 3, arg0, arg1, arg2); + gcall *stmt; + if (internal_fn_p (fn)) + stmt = gimple_build_call_internal (as_internal_fn (fn), + 3, arg0, arg1, arg2); + else + { + tree decl = builtin_decl_implicit (as_builtin_fn (fn)); + stmt = gimple_build_call (decl, 3, arg0, arg1, arg2); + } if (!VOID_TYPE_P (type)) { res = create_tmp_reg_or_ssa_name (type); Index: gcc/tree-vect-loop.c =================================================================== --- gcc/tree-vect-loop.c 2018-05-16 12:50:14.893361868 +0100 +++ gcc/tree-vect-loop.c 2018-05-17 09:17:32.877478908 +0100 @@ -4179,12 +4179,10 @@ get_initial_def_for_reduction (gimple *s else if (!TYPE_VECTOR_SUBPARTS (vectype).is_constant ()) { /* Option2 (variable length): the first element is INIT_VAL. */ - init_def = build_vector_from_val (vectype, def_for_init); - gcall *call = gimple_build_call_internal (IFN_VEC_SHL_INSERT, - 2, init_def, init_val); - init_def = make_ssa_name (vectype); - gimple_call_set_lhs (call, init_def); - gimple_seq_add_stmt (&stmts, call); + init_def = gimple_build_vector_from_val (&stmts, vectype, + def_for_init); + init_def = gimple_build (&stmts, CFN_VEC_SHL_INSERT, + vectype, init_def, init_val); } else { @@ -4327,11 +4325,8 @@ get_initial_defs_for_reduction (slp_tree while (k > 0) { k -= 1; - gcall *call = gimple_build_call_internal - (IFN_VEC_SHL_INSERT, 2, init, elts[k]); - init = make_ssa_name (vector_type); - gimple_call_set_lhs (call, init); - gimple_seq_add_stmt (&ctor_seq, call); + init = gimple_build (&ctor_seq, CFN_VEC_SHL_INSERT, + vector_type, init, elts[k]); } } else @@ -5234,10 +5229,8 @@ vect_create_epilog_for_reduction (vec