From patchwork Wed Feb 28 13:09:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 86517 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 62ABE3858433 for ; Wed, 28 Feb 2024 13:09:51 +0000 (GMT) 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.223.131]) by sourceware.org (Postfix) with ESMTPS id 4C3003858408 for ; Wed, 28 Feb 2024 13:09:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4C3003858408 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 4C3003858408 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=195.135.223.131 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1709125762; cv=none; b=IDnTU91Au9tjABUzN+c+C4OdDi90xBjrrqV3kQqfo/X2Ika/c5T1WU2x+cWTo5PHRef2StOhVRXxyOrULUmclYIGFrPk7BvAY6KahjW1jf/MBySugyPhC7/lTmNVmAYhq3hd8UPzG7heOV7AibGwr9y4JbEppcwMisqdsAQerPs= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1709125762; c=relaxed/simple; bh=qZtIwZlnIARX+X62v7NxCHl1CZivw1PJILyjTVL4q7g=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:Date: From:To:Subject:MIME-Version; b=gQWIn9rVfvT8siRc1h9wXH/j82IySrQ2VbNsRgdSXKOOjkJQOZo0BkJ/rZeFT/itWAyLPKv7e0t/XWjRQR7/p+5NiqyvPNsglZXuwBqlmrQ3XHu7ikHxV1iJXa1qQzJ+ICwDrpgspCOOfu+GLw6uKWk+KHCPv1AqhiRhPnnE2sc= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from [10.168.4.150] (unknown [10.168.4.150]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 3D75F1F795 for ; Wed, 28 Feb 2024 13:09:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1709125759; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=HE376U9t6++KDG01RU6pEnRNQoFYiFpwhQc8ajXtyY0=; b=eVLFWqiV70oGbtWU/vUDlHvt+1B4mSz4dUatttPjEUnTDV37c+wYoH73AOhSCsPnDLFlWP 1HQel78K+6TYeMUJUQ+enXr7mJb+1hS8JtdK310hO3JdnJ3e8UkmJNAr5GULnhauUYxzeA Mu8H0e3Sh+CFz8GGedUOznfUwkVobGI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1709125759; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=HE376U9t6++KDG01RU6pEnRNQoFYiFpwhQc8ajXtyY0=; b=DKrJAbS2PnaV1LAwoVtn7KdwT9mg2j98jh79ZzLO0STSdm+XK9ozbLRjwceR3o+W2IaLFZ 4/0iRKAtmZxondBA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1709125757; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=HE376U9t6++KDG01RU6pEnRNQoFYiFpwhQc8ajXtyY0=; b=TZEJgP5u1oLvVvYedG3+tSVIoGkRDqYcBZnDOt0J9luDi4qhrLXAJHWPgPwGIlEj/Cd5pC 10eCHFgjHLvMC9ge4dkS+VII0HyjeHTaoK7w5E826lOrYWURe3u5kpwxkqODXj50tDzjsC 81jppaVO6rE4BgmEnv8UsmnRuMkU9x0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1709125757; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=HE376U9t6++KDG01RU6pEnRNQoFYiFpwhQc8ajXtyY0=; b=kf1rSyeL091G++HjTsIQepgBd6iylWxZOA4IBr36HRSSdOcPG/Fo338tDbotv9YgGJ7+CH NO4rcyFxPMVFs9Dw== Date: Wed, 28 Feb 2024 14:09:17 +0100 (CET) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH 2/2] tree-optimization/113831 - revert original fix MIME-Version: 1.0 Authentication-Results: smtp-out2.suse.de; none X-Spamd-Result: default: False [-0.60 / 50.00]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; TO_DN_NONE(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; MISSING_MID(2.50)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; DBL_BLOCKED_OPENRESOLVER(0.00)[tree-ssa-sccvn.cc:url]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCVD_COUNT_ZERO(0.00)[0]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; BAYES_HAM(-3.00)[100.00%] X-Spam-Level: X-Spam-Score: -0.60 X-Spam-Status: No, score=-10.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, MISSING_MID, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Message-Id: <20240228130951.62ABE3858433@sourceware.org> This reverts the original fix for PR113831 which is better fixed by the PR114121 fix. I've XFAILed instead of removing the PR108355 testcase again. Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed. PR tree-optimization/113831 PR tree-optimization/108355 * tree-ssa-sccvn.cc (copy_reference_ops_from_ref): Revert PR113831 fix. * gcc.dg/tree-ssa/ssa-fre-104.c: XFAIL. --- gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-104.c | 2 +- gcc/tree-ssa-sccvn.cc | 134 -------------------- 2 files changed, 1 insertion(+), 135 deletions(-) diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-104.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-104.c index f0f12ef82b7..425c32dd93c 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-104.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-104.c @@ -21,4 +21,4 @@ int main() { *c = &d; } -/* { dg-final { scan-tree-dump-not "foo" "fre1" } } */ +/* { dg-final { scan-tree-dump-not "foo" "fre1" { xfail *-*-* } } } */ diff --git a/gcc/tree-ssa-sccvn.cc b/gcc/tree-ssa-sccvn.cc index 21123644a5a..0b7fb0663c7 100644 --- a/gcc/tree-ssa-sccvn.cc +++ b/gcc/tree-ssa-sccvn.cc @@ -912,8 +912,6 @@ copy_reference_ops_from_ref (tree ref, vec *result) { /* For non-calls, store the information that makes up the address. */ tree orig = ref; - unsigned start = result->length (); - bool seen_variable_array_ref = false; while (ref) { vn_reference_op_s temp; @@ -1000,12 +998,6 @@ copy_reference_ops_from_ref (tree ref, vec *result) tree eltype = TREE_TYPE (TREE_TYPE (TREE_OPERAND (ref, 0))); /* Record index as operand. */ temp.op0 = TREE_OPERAND (ref, 1); - /* When the index is not constant we have to apply the same - logic as get_ref_base_and_extent which eventually uses - global ranges to refine the overall ref extent. Record - we've seen such a case, fixup below. */ - if (TREE_CODE (temp.op0) == SSA_NAME) - seen_variable_array_ref = true; /* Always record lower bounds and element size. */ temp.op1 = array_ref_low_bound (ref); /* But record element size in units of the type alignment. */ @@ -1098,132 +1090,6 @@ copy_reference_ops_from_ref (tree ref, vec *result) else ref = NULL_TREE; } - poly_int64 offset, size, max_size; - tree base; - bool rev; - if (seen_variable_array_ref - && handled_component_p (orig) - && (base = get_ref_base_and_extent (orig, - &offset, &size, &max_size, &rev)) - && known_size_p (max_size) - && known_eq (size, max_size)) - { - poly_int64 orig_offset = offset; - poly_int64 tem; - if (TREE_CODE (base) == MEM_REF - && mem_ref_offset (base).to_shwi (&tem)) - offset += tem * BITS_PER_UNIT; - HOST_WIDE_INT coffset = offset.to_constant (); - /* When get_ref_base_and_extent computes an offset constrained to - a constant position we have to fixup variable array indexes in - the ref to avoid the situation where based on context we'd have - to value-number the same vn_reference ops differently. Make - the vn_reference ops differ by adjusting those indexes to - appropriate constants. */ - poly_int64 off = 0; - bool oob_index = false; - for (unsigned i = result->length (); i > start; --i) - { - auto &op = (*result)[i-1]; - if (flag_checking - && op.opcode == ARRAY_REF - && TREE_CODE (op.op0) == INTEGER_CST) - { - /* The verifier below chokes on inconsistencies of handling - out-of-bound accesses so disable it in that case. */ - tree atype = (*result)[i].type; - if (TREE_CODE (atype) == ARRAY_TYPE) - if (tree dom = TYPE_DOMAIN (atype)) - if ((TYPE_MIN_VALUE (dom) - && TREE_CODE (TYPE_MIN_VALUE (dom)) == INTEGER_CST - && (wi::to_widest (op.op0) - < wi::to_widest (TYPE_MIN_VALUE (dom)))) - || (TYPE_MAX_VALUE (dom) - && TREE_CODE (TYPE_MAX_VALUE (dom)) == INTEGER_CST - && (wi::to_widest (op.op0) - > wi::to_widest (TYPE_MAX_VALUE (dom))))) - oob_index = true; - } - if ((op.opcode == ARRAY_REF - || op.opcode == ARRAY_RANGE_REF) - && TREE_CODE (op.op0) == SSA_NAME) - { - /* There's a single constant index that get's 'off' closer - to 'offset'. */ - unsigned HOST_WIDE_INT elsz - = tree_to_uhwi (op.op2) * vn_ref_op_align_unit (&op); - unsigned HOST_WIDE_INT idx - = (coffset - off.to_constant ()) / BITS_PER_UNIT / elsz; - if (idx == 0) - op.op0 = op.op1; - else - op.op0 = wide_int_to_tree (TREE_TYPE (op.op0), - wi::to_poly_wide (op.op1) + idx); - op.off = idx * elsz; - off += op.off * BITS_PER_UNIT; - } - else - { - if (op.opcode == ERROR_MARK) - /* two-ops codes have the offset in the first op. */ - ; - else if (op.opcode == ADDR_EXPR - || op.opcode == SSA_NAME - || op.opcode == CONSTRUCTOR - || TREE_CODE_CLASS (op.opcode) == tcc_declaration - || TREE_CODE_CLASS (op.opcode) == tcc_constant) - /* end-of ref. */ - gcc_assert (i == result->length ()); - else if (op.opcode == COMPONENT_REF) - { - /* op.off is tracked in bytes, re-do it manually - because of bitfields. */ - tree field = op.op0; - /* We do not have a complete COMPONENT_REF tree here so we - cannot use component_ref_field_offset. Do the interesting - parts manually. */ - tree this_offset = DECL_FIELD_OFFSET (field); - if (op.op1 || !poly_int_tree_p (this_offset)) - gcc_unreachable (); - else - { - poly_offset_int woffset - = (wi::to_poly_offset (this_offset) - << LOG2_BITS_PER_UNIT); - woffset += wi::to_offset (DECL_FIELD_BIT_OFFSET (field)); - off += woffset.force_shwi (); - } - } - else - { - gcc_assert (known_ne (op.off, -1) - /* The constant offset can be -1. */ - || op.opcode == MEM_REF - /* Out-of-bound indices can compute to - a known -1 offset. */ - || ((op.opcode == ARRAY_REF - || op.opcode == ARRAY_RANGE_REF) - && poly_int_tree_p (op.op0) - && poly_int_tree_p (op.op1) - && TREE_CODE (op.op2) == INTEGER_CST)); - off += op.off * BITS_PER_UNIT; - } - } - } - if (flag_checking && !oob_index) - { - ao_ref r; - if (start != 0) - ; - else if (ao_ref_init_from_vn_reference (&r, 0, 0, TREE_TYPE (orig), - *result)) - gcc_assert (known_eq (r.offset, orig_offset) - && known_eq (r.size, size) - && known_eq (r.max_size, max_size)); - else - gcc_unreachable (); - } - } } /* Build a alias-oracle reference abstraction in *REF from the vn_reference