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: 915180 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-477805-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="ZWzDFf53"; 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 40mkmq5GRWz9s3X for ; Thu, 17 May 2018 18:22:02 +1000 (AEST) 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=e1Mnpd7C+wSkaQY76q+eft/jceWrveVixNqU99zhoU61cf68sn4IS w3PwBKs9NPzVi0ePNENe90iR8FAXS+t7ZY83oeC6jwFadnBGgiNxS3aI0EBXc2Uv uSUsgFuEOnhHOc8ona24n/Q1dp1EMVjDIHKpB5oHgll29exiZalCWk= 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=ZWzDFf537BBjMZXFtH+3 KHKPzMRTnAZdgrMMZWhETdqyqZaDT4paLSiwZ4YINr0N/7ydJUQAVLTia4B0sJdH 7j7W2I5u0nAhSmIwFOlEuIPr83SEQcHHAj9rymk0moLBeu6RkBzhHhsP1uhG0s/n ZbvcFZcSr7cY894wiwnKo20= 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-Google-Smtp-Source: AB8JxZqLSzbeQEFT6zEJXi8llLNbOwOJAANxlGiFKP4S+of29kansoYXcxkrQjQwlXiZAsu0aMuxmA== 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