From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by sourceware.org (Postfix) with ESMTPS id D89953835E35 for ; Wed, 14 Dec 2022 07:48:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D89953835E35 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id A6CB021B27 for ; Wed, 14 Dec 2022 07:48:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1671004083; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=z26HvQqPemXH9LIW2miwLGd1VcGjgyMb+CHtjuDfqiU=; b=2DFkQJfE8V4dDYvvJkzcAz4TdIzBRa87K1LMDYqtz3eDUOHNdHzNIWp15TsYewd4Dcx4qx J4LIdYMeRb0rMfrDXpWaKUmz/CtBL+YJgP1diMf1sxVC3M00Rv9t18vtitO0E8lM7MNAI4 xR/2zYFg1H0SRt43XalIP4PEqvNwtho= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1671004083; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=z26HvQqPemXH9LIW2miwLGd1VcGjgyMb+CHtjuDfqiU=; b=XXriXFHbFqYL6HECPHxSwL5DRoncyKpThJVdEefDTQXR+Cd0OIljZgbhXMmNHi4bqhze2H KyeMx/YlhPj6LNAA== Received: from wotan.suse.de (wotan.suse.de [10.160.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id A1B252C141 for ; Wed, 14 Dec 2022 07:48:03 +0000 (UTC) Date: Wed, 14 Dec 2022 07:48:03 +0000 (UTC) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] tree-optimization/107617 - big-endian .LEN_STORE VN User-Agent: Alpine 2.22 (LSU 394 2020-01-19) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII 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 autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Message-ID: <20221214074803.ohmbb0UucWZNJ-B8pF3eBpVYpuB-uORPCUa3hVT_NNw@z> The following fixes a mistake in interpreting .LEN_STORE definitions during value-numbering when in big-endian mode. We cannot offset the encoding of the RHS but instead encode to an offsetted position which is then treated correctly by the endian aware copying code. Bootstrapped and tested on x86_64-unkown-linux-gnu and on s390 by Robin, pushed. PR tree-optimization/107617 * tree-ssa-sccvn.cc (vn_walk_cb_data::push_partial_def): Handle negative pd.rhs_off. (vn_reference_lookup_3): Properly provide pd.rhs_off for .LEN_STORE on big-endian targets. --- gcc/tree-ssa-sccvn.cc | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/gcc/tree-ssa-sccvn.cc b/gcc/tree-ssa-sccvn.cc index b9f289b6eca..fa2f65df159 100644 --- a/gcc/tree-ssa-sccvn.cc +++ b/gcc/tree-ssa-sccvn.cc @@ -2090,7 +2090,7 @@ vn_walk_cb_data::push_partial_def (pd_data pd, len = ROUND_UP (pd.size, BITS_PER_UNIT) / BITS_PER_UNIT; memset (this_buffer, 0, len); } - else + else if (pd.rhs_off >= 0) { len = native_encode_expr (pd.rhs, this_buffer, bufsize, (MAX (0, -pd.offset) @@ -2105,6 +2105,24 @@ vn_walk_cb_data::push_partial_def (pd_data pd, return (void *)-1; } } + else /* negative pd.rhs_off indicates we want to chop off first bits */ + { + if (-pd.rhs_off >= bufsize) + return (void *)-1; + len = native_encode_expr (pd.rhs, + this_buffer + -pd.rhs_off / BITS_PER_UNIT, + bufsize - -pd.rhs_off / BITS_PER_UNIT, + MAX (0, -pd.offset) / BITS_PER_UNIT); + if (len <= 0 + || len < (ROUND_UP (pd.size, BITS_PER_UNIT) / BITS_PER_UNIT + - MAX (0, -pd.offset) / BITS_PER_UNIT)) + { + if (dump_file && (dump_flags & TDF_DETAILS)) + fprintf (dump_file, "Failed to encode %u " + "partial definitions\n", ndefs); + return (void *)-1; + } + } unsigned char *p = buffer; HOST_WIDE_INT size = pd.size; @@ -3349,10 +3367,13 @@ vn_reference_lookup_3 (ao_ref *ref, tree vuse, void *data_, } else if (fn == IFN_LEN_STORE) { - pd.rhs_off = 0; pd.offset = offset2i; pd.size = (tree_to_uhwi (len) + -tree_to_shwi (bias)) * BITS_PER_UNIT; + if (BYTES_BIG_ENDIAN) + pd.rhs_off = pd.size - tree_to_uhwi (TYPE_SIZE (vectype)); + else + pd.rhs_off = 0; if (ranges_known_overlap_p (offset, maxsize, pd.offset, pd.size)) return data->push_partial_def (pd, set, set, -- 2.35.3