From patchwork Thu Nov 4 09:15:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 47036 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 71DE03858032 for ; Thu, 4 Nov 2021 09:15:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 71DE03858032 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1636017348; bh=qlA9E+NOGa5q2DnWxX6hdyjEk9UVRwcw64sjQkQ5A4c=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=mm9KsHfD5vqvYkuf90i6y+srOC0wMBco35698ceqUMkLLkIM3ww9PLBgFdUDKqdvQ XLA+QjOAyZGZHz7/TPQxfj/YwzBuCBMrpI3MTGProfh9Ubsq6Ip3CklifdzkVW7vHt mO7XDSfBYhSJpHlUHszK1qoLfFPaBsfJS4tqPpV8= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by sourceware.org (Postfix) with ESMTPS id 74C613858409 for ; Thu, 4 Nov 2021 09:15:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 74C613858409 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 42C5B1FD33 for ; Thu, 4 Nov 2021 09:15:17 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 2B85213BD9 for ; Thu, 4 Nov 2021 09:15:17 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 6Vh3CaWkg2FyEwAAMHmgww (envelope-from ) for ; Thu, 04 Nov 2021 09:15:17 +0000 Date: Thu, 4 Nov 2021 10:15:16 +0100 (CET) To: gcc-patches@gcc.gnu.org Subject: [PATCH] VN/PRE TLC Message-ID: <87652787-401p-qoq0-12p8-147qrn8r924@fhfr.qr> MIME-Version: 1.0 X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, SUBJ_ALL_CAPS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Richard Biener via Gcc-patches From: Richard Biener Reply-To: Richard Biener Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" This removes an always true parameter of vn_nary_op_insert_into and moves valueization to the two callers of vn_nary_op_compute_hash instead of doing it therein where this function name does not suggest such thing. Also remove extra valueization from PRE phi-translation. Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed. 2021-11-03 Richard Biener * tree-ssa-sccvn.c (vn_nary_op_insert_into): Remove always true parameter and inline valueization. (vn_nary_op_lookup_1): Inline valueization from ... (vn_nary_op_compute_hash): ... here and remove it here. * tree-ssa-pre.c (phi_translate_1): Do not valueize before vn_nary_lookup_pieces. (get_representative_for): Mark created SSA representatives as visited. --- gcc/tree-ssa-pre.c | 5 +---- gcc/tree-ssa-sccvn.c | 43 +++++++++++++++++++++---------------------- 2 files changed, 22 insertions(+), 26 deletions(-) diff --git a/gcc/tree-ssa-pre.c b/gcc/tree-ssa-pre.c index dc55d868cc1..0669aaaac47 100644 --- a/gcc/tree-ssa-pre.c +++ b/gcc/tree-ssa-pre.c @@ -1391,6 +1391,7 @@ get_representative_for (const pre_expr e, basic_block b = NULL) vn_ssa_aux_t vn_info = VN_INFO (name); vn_info->value_id = value_id; vn_info->valnum = valnum ? valnum : name; + vn_info->visited = true; /* ??? For now mark this SSA name for release by VN. */ vn_info->needs_insertion = true; add_to_value (value_id, get_or_alloc_expr_for_name (name)); @@ -1508,10 +1509,6 @@ phi_translate_1 (bitmap_set_t dest, return constant; } - /* vn_nary_* do not valueize operands. */ - for (i = 0; i < newnary->length; ++i) - if (TREE_CODE (newnary->op[i]) == SSA_NAME) - newnary->op[i] = VN_INFO (newnary->op[i])->valnum; tree result = vn_nary_op_lookup_pieces (newnary->length, newnary->opcode, newnary->type, diff --git a/gcc/tree-ssa-sccvn.c b/gcc/tree-ssa-sccvn.c index d5242597684..7be5d4e406f 100644 --- a/gcc/tree-ssa-sccvn.c +++ b/gcc/tree-ssa-sccvn.c @@ -427,7 +427,7 @@ static vn_nary_op_t vn_nary_op_insert_stmt (gimple *, tree); static unsigned int vn_nary_length_from_stmt (gimple *); static vn_nary_op_t alloc_vn_nary_op_noinit (unsigned int, obstack *); static vn_nary_op_t vn_nary_op_insert_into (vn_nary_op_t, - vn_nary_op_table_type *, bool); + vn_nary_op_table_type *); static void init_vn_nary_op_from_stmt (vn_nary_op_t, gassign *); static void init_vn_nary_op_from_pieces (vn_nary_op_t, unsigned int, enum tree_code, tree, tree *); @@ -490,7 +490,7 @@ VN_INFO (tree name) boolean_type_node, ops); nary->predicated_values = 0; nary->u.result = boolean_true_node; - vn_nary_op_insert_into (nary, valid_info->nary, true); + vn_nary_op_insert_into (nary, valid_info->nary); gcc_assert (nary->unwind_to == NULL); /* Also do not link it into the undo chain. */ last_inserted_nary = nary->next; @@ -500,7 +500,7 @@ VN_INFO (tree name) boolean_type_node, ops); nary->predicated_values = 0; nary->u.result = boolean_false_node; - vn_nary_op_insert_into (nary, valid_info->nary, true); + vn_nary_op_insert_into (nary, valid_info->nary); gcc_assert (nary->unwind_to == NULL); last_inserted_nary = nary->next; nary->next = (vn_nary_op_t)(void *)-1; @@ -2440,7 +2440,7 @@ vn_nary_build_or_lookup_1 (gimple_match_op *res_op, bool insert, vno1->predicated_values = 0; vno1->u.result = result; init_vn_nary_op_from_stmt (vno1, as_a (new_stmt)); - vn_nary_op_insert_into (vno1, valid_info->nary, true); + vn_nary_op_insert_into (vno1, valid_info->nary); /* Also do not link it into the undo chain. */ last_inserted_nary = vno1->next; vno1->next = (vn_nary_op_t)(void *)-1; @@ -3855,10 +3855,6 @@ vn_nary_op_compute_hash (const vn_nary_op_t vno1) inchash::hash hstate; unsigned i; - for (i = 0; i < vno1->length; ++i) - if (TREE_CODE (vno1->op[i]) == SSA_NAME) - vno1->op[i] = SSA_VAL (vno1->op[i]); - if (((vno1->length == 2 && commutative_tree_code (vno1->opcode)) || (vno1->length == 3 @@ -4000,6 +3996,10 @@ vn_nary_op_lookup_1 (vn_nary_op_t vno, vn_nary_op_t *vnresult) if (vnresult) *vnresult = NULL; + for (unsigned i = 0; i < vno->length; ++i) + if (TREE_CODE (vno->op[i]) == SSA_NAME) + vno->op[i] = SSA_VAL (vno->op[i]); + vno->hashcode = vn_nary_op_compute_hash (vno); slot = valid_info->nary->find_slot_with_hash (vno, vno->hashcode, NO_INSERT); if (!slot) @@ -4064,23 +4064,22 @@ alloc_vn_nary_op (unsigned int length, tree result, unsigned int value_id) return vno1; } -/* Insert VNO into TABLE. If COMPUTE_HASH is true, then compute - VNO->HASHCODE first. */ +/* Insert VNO into TABLE. */ static vn_nary_op_t -vn_nary_op_insert_into (vn_nary_op_t vno, vn_nary_op_table_type *table, - bool compute_hash) +vn_nary_op_insert_into (vn_nary_op_t vno, vn_nary_op_table_type *table) { vn_nary_op_s **slot; - if (compute_hash) - { - vno->hashcode = vn_nary_op_compute_hash (vno); - gcc_assert (! vno->predicated_values - || (! vno->u.values->next - && vno->u.values->n == 1)); - } + gcc_assert (! vno->predicated_values + || (! vno->u.values->next + && vno->u.values->n == 1)); + + for (unsigned i = 0; i < vno->length; ++i) + if (TREE_CODE (vno->op[i]) == SSA_NAME) + vno->op[i] = SSA_VAL (vno->op[i]); + vno->hashcode = vn_nary_op_compute_hash (vno); slot = table->find_slot_with_hash (vno, vno->hashcode, INSERT); vno->unwind_to = *slot; if (*slot) @@ -4211,7 +4210,7 @@ vn_nary_op_insert_pieces (unsigned int length, enum tree_code code, { vn_nary_op_t vno1 = alloc_vn_nary_op (length, result, value_id); init_vn_nary_op_from_pieces (vno1, length, code, type, ops); - return vn_nary_op_insert_into (vno1, valid_info->nary, true); + return vn_nary_op_insert_into (vno1, valid_info->nary); } static vn_nary_op_t @@ -4257,7 +4256,7 @@ vn_nary_op_insert_pieces_predicated (unsigned int length, enum tree_code code, vno1->u.values->result = result; vno1->u.values->n = 1; vno1->u.values->valid_dominated_by_p[0] = pred_e->dest->index; - return vn_nary_op_insert_into (vno1, valid_info->nary, true); + return vn_nary_op_insert_into (vno1, valid_info->nary); } static bool @@ -4290,7 +4289,7 @@ vn_nary_op_insert_stmt (gimple *stmt, tree result) = alloc_vn_nary_op (vn_nary_length_from_stmt (stmt), result, VN_INFO (result)->value_id); init_vn_nary_op_from_stmt (vno1, as_a (stmt)); - return vn_nary_op_insert_into (vno1, valid_info->nary, true); + return vn_nary_op_insert_into (vno1, valid_info->nary); } /* Compute a hashcode for PHI operation VP1 and return it. */