From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25309 invoked by alias); 11 Oct 2016 09:28:59 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 25292 invoked by uid 89); 11 Oct 2016 09:28:58 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_PASS autolearn=ham version=3.3.2 spammy=seq, gimple_seq, GSI_SAME_STMT, sk:gsi_ins X-HELO: mx2.suse.de Received: from mx2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 11 Oct 2016 09:28:48 +0000 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 07BEFAC47; Tue, 11 Oct 2016 09:28:46 +0000 (UTC) To: Richard Biener References: <678ff58e-4aa3-6145-f56b-780bf618338c@suse.cz> Cc: GCC Patches From: =?UTF-8?Q?Martin_Li=c5=a1ka?= Subject: [PATCH] Add a helper function: create_tmp Message-ID: Date: Tue, 11 Oct 2016 09:28:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/mixed; boundary="------------FF549E9AEA4B7993902D86B3" X-IsSubscribed: yes X-SW-Source: 2016-10/txt/msg00691.txt.bz2 This is a multi-part message in MIME format. --------------FF549E9AEA4B7993902D86B3 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Content-length: 134 Following patch is a small infrastructure enhancement in gimple-fold.c. Tests of the whole series have been running. Thanks, Martin --------------FF549E9AEA4B7993902D86B3 Content-Type: text/x-patch; name="0002-Add-a-helper-function-create_tmp.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0002-Add-a-helper-function-create_tmp.patch" Content-length: 5971 >From cf5983472b8482734393680493293811e5400d6e Mon Sep 17 00:00:00 2001 From: marxin Date: Tue, 11 Oct 2016 11:20:33 +0200 Subject: [PATCH 2/5] Add a helper function: create_tmp gcc/ChangeLog: 2016-10-11 Martin Liska * gimple-fold.c (create_tmp): New function. (gimple_fold_builtin_memory_op): Use the function. (gimple_fold_builtin_strchr): Likewise. (gimple_fold_builtin_strcat): Likewise. (gimple_build): Likewise. --- gcc/gimple-fold.c | 64 ++++++++++++++++++++----------------------------------- 1 file changed, 23 insertions(+), 41 deletions(-) diff --git a/gcc/gimple-fold.c b/gcc/gimple-fold.c index 3aaa09c..348f331 100644 --- a/gcc/gimple-fold.c +++ b/gcc/gimple-fold.c @@ -171,6 +171,19 @@ can_refer_decl_in_current_unit_p (tree decl, tree from_decl) return !node || !node->global.inlined_to; } +/* Create a temporary for TYPE for a statement STMT. If the current function + is in SSA form, a SSA name is created. Otherwise a temporary register + is made. */ + +static tree +create_tmp (tree type, gimple *stmt = NULL) +{ + if (gimple_in_ssa_p (cfun)) + return make_ssa_name (type, stmt); + else + return create_tmp_reg (type); +} + /* CVAL is value taken from DECL_INITIAL of variable. Try to transform it into acceptable form for is_gimple_min_invariant. FROM_DECL (if non-NULL) specify variable whose constructor contains CVAL. */ @@ -747,11 +760,7 @@ gimple_fold_builtin_memory_op (gimple_stmt_iterator *gsi, if (is_gimple_reg_type (TREE_TYPE (srcmem))) { new_stmt = gimple_build_assign (NULL_TREE, srcmem); - if (gimple_in_ssa_p (cfun)) - srcmem = make_ssa_name (TREE_TYPE (srcmem), - new_stmt); - else - srcmem = create_tmp_reg (TREE_TYPE (srcmem)); + srcmem = create_tmp (TREE_TYPE (srcmem), new_stmt); gimple_assign_set_lhs (new_stmt, srcmem); gimple_set_vuse (new_stmt, gimple_vuse (stmt)); gsi_insert_before (gsi, new_stmt, GSI_SAME_STMT); @@ -1038,10 +1047,7 @@ gimple_fold_builtin_memory_op (gimple_stmt_iterator *gsi, if (! is_gimple_min_invariant (srcvar)) { new_stmt = gimple_build_assign (NULL_TREE, srcvar); - if (gimple_in_ssa_p (cfun)) - srcvar = make_ssa_name (TREE_TYPE (srcvar), new_stmt); - else - srcvar = create_tmp_reg (TREE_TYPE (srcvar)); + srcvar = create_tmp (TREE_TYPE (srcvar), new_stmt); gimple_assign_set_lhs (new_stmt, srcvar); gimple_set_vuse (new_stmt, gimple_vuse (stmt)); gsi_insert_before (gsi, new_stmt, GSI_SAME_STMT); @@ -1535,10 +1541,7 @@ gimple_fold_builtin_strchr (gimple_stmt_iterator *gsi, bool is_strrchr) gimple_seq stmts = NULL; gimple *new_stmt = gimple_build_call (strlen_fn, 1, str); gimple_set_location (new_stmt, loc); - if (gimple_in_ssa_p (cfun)) - len = make_ssa_name (size_type_node); - else - len = create_tmp_reg (size_type_node); + len = create_tmp (size_type_node); gimple_call_set_lhs (new_stmt, len); gimple_seq_add_stmt_without_update (&stmts, new_stmt); @@ -1611,10 +1614,7 @@ gimple_fold_builtin_strcat (gimple_stmt_iterator *gsi, tree dst, tree src) gimple_seq stmts = NULL, stmts2; gimple *repl = gimple_build_call (strlen_fn, 1, dst); gimple_set_location (repl, loc); - if (gimple_in_ssa_p (cfun)) - newdst = make_ssa_name (size_type_node); - else - newdst = create_tmp_reg (size_type_node); + newdst = create_tmp (size_type_node); gimple_call_set_lhs (repl, newdst); gimple_seq_add_stmt_without_update (&stmts, repl); @@ -6376,10 +6376,7 @@ gimple_build (gimple_seq *seq, location_t loc, tree res = gimple_simplify (code, type, op0, seq, gimple_build_valueize); if (!res) { - if (gimple_in_ssa_p (cfun)) - res = make_ssa_name (type); - else - res = create_tmp_reg (type); + res = create_tmp (type); gimple *stmt; if (code == REALPART_EXPR || code == IMAGPART_EXPR @@ -6405,10 +6402,7 @@ gimple_build (gimple_seq *seq, location_t loc, tree res = gimple_simplify (code, type, op0, op1, seq, gimple_build_valueize); if (!res) { - if (gimple_in_ssa_p (cfun)) - res = make_ssa_name (type); - else - res = create_tmp_reg (type); + res = create_tmp (type); gimple *stmt = gimple_build_assign (res, code, op0, op1); gimple_set_location (stmt, loc); gimple_seq_add_stmt_without_update (seq, stmt); @@ -6429,10 +6423,7 @@ gimple_build (gimple_seq *seq, location_t loc, seq, gimple_build_valueize); if (!res) { - if (gimple_in_ssa_p (cfun)) - res = make_ssa_name (type); - else - res = create_tmp_reg (type); + res = create_tmp (type); gimple *stmt; if (code == BIT_FIELD_REF) stmt = gimple_build_assign (res, code, @@ -6462,10 +6453,7 @@ gimple_build (gimple_seq *seq, location_t loc, gimple *stmt = gimple_build_call (decl, 1, arg0); if (!VOID_TYPE_P (type)) { - if (gimple_in_ssa_p (cfun)) - res = make_ssa_name (type); - else - res = create_tmp_reg (type); + res = create_tmp (type); gimple_call_set_lhs (stmt, res); } gimple_set_location (stmt, loc); @@ -6491,10 +6479,7 @@ gimple_build (gimple_seq *seq, location_t loc, gimple *stmt = gimple_build_call (decl, 2, arg0, arg1); if (!VOID_TYPE_P (type)) { - if (gimple_in_ssa_p (cfun)) - res = make_ssa_name (type); - else - res = create_tmp_reg (type); + res = create_tmp (type); gimple_call_set_lhs (stmt, res); } gimple_set_location (stmt, loc); @@ -6522,10 +6507,7 @@ gimple_build (gimple_seq *seq, location_t loc, gimple *stmt = gimple_build_call (decl, 3, arg0, arg1, arg2); if (!VOID_TYPE_P (type)) { - if (gimple_in_ssa_p (cfun)) - res = make_ssa_name (type); - else - res = create_tmp_reg (type); + res = create_tmp (type); gimple_call_set_lhs (stmt, res); } gimple_set_location (stmt, loc); -- 2.9.2 --------------FF549E9AEA4B7993902D86B3--