From patchwork Mon Mar 4 16:49:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 1907778 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=GD0t2dj4; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TpPnS0w4xz23fC for ; Tue, 5 Mar 2024 03:50:02 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C7EA23858428 for ; Mon, 4 Mar 2024 16:50:00 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id E4B003858C5E for ; Mon, 4 Mar 2024 16:49:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E4B003858C5E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org E4B003858C5E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1709570984; cv=none; b=fX7X67PEJjUggBN1aGo7VatwlsUGJVjAyqyFkCiIZWKbWkjIds2ZSX78bwWuYqjTQth5GnfPfpEzm9wjqwaxWMhk08/cmitml2RdKfaq38Xfi3qa09+iiWtBPQvscKX0/3f1G+ng50KXBf72dcC3f1ch6QYOQkr3Oh/U8bVgYdo= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1709570984; c=relaxed/simple; bh=cSbGDH+EqaD7gTLPnaKSHYs52lFNRsJInL8iPCWH09s=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=o0hK4/1S9uX8H4v8kJz6hwBWITWdKHrNQ/M3HM+3HqXPlak12fFM7PFHXAcnaHTqhIzdtkTbquyvYgOxT0IhJXlXcpMH4pVKh59nr7yV3+YVneiHdtK8put0wy2MOsa4kKU3XT8sCj73sMLQbBpNlTLxAwbzVEqAF5kqIoZGGNI= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709570982; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references; bh=d9J858BHSZ2jj1IeQi75RTFll9KGv8uJh2BSZ1j0UBA=; b=GD0t2dj4lTrlEni3pmq/hvzFYe/HY8NAtJZDMGXr78HKdkZVOini4J/Qhk/0xIFPvSSY+C 082W8a2WpF27tJweKpQa7X4L5EI0pgKneaNA5tIyg8x/iTCfipHfFEvrveP0v2JZPLssFU 0WPh0HHxrlWw2wNJ3nQ0EokkmClM5CM= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-118-6UcGRYmbMKyp4hhqzHlQYw-1; Mon, 04 Mar 2024 11:49:39 -0500 X-MC-Unique: 6UcGRYmbMKyp4hhqzHlQYw-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id CB1A23811F30; Mon, 4 Mar 2024 16:49:38 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.45.226.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5C1852166B31; Mon, 4 Mar 2024 16:49:38 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 424Gnaj91800486 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Mon, 4 Mar 2024 17:49:36 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 424GnZHj1800485; Mon, 4 Mar 2024 17:49:35 +0100 Date: Mon, 4 Mar 2024 17:49:35 +0100 From: Jakub Jelinek To: Jeff Law , Rainer Orth Cc: Greg McGary , gcc-patches@gcc.gnu.org Subject: [PATCH] combine: Fix recent WORD_REGISTER_OPERATIONS check [PR113010] Message-ID: References: <20240227001736.3690294-1-gkm@rivosinc.com> <4a986781-7be8-4e45-a2d7-567d1df58ee3@gmail.com> MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.6 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-3.9 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, 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: , Reply-To: Jakub Jelinek Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org On Mon, Mar 04, 2024 at 05:18:39PM +0100, Rainer Orth wrote: > > On 2/26/24 17:17, Greg McGary wrote: > >> The sign-bit-copies of a sign-extending load cannot be known until runtime on > >> WORD_REGISTER_OPERATIONS targets, except in the case of a zero-extending MEM > >> load. See the fix for PR112758. > >> 2024-02-22 Greg McGary > >> PR rtl-optimization/113010 > >> * combine.cc (simplify_comparison): Simplify a SUBREG on > >> WORD_REGISTER_OPERATIONS targets only if it is a zero-extending > >> MEM load. > >> * gcc.c-torture/execute/pr113010.c: New test. > > I think this is fine for the trunk. I'll do some final testing on it > > tomorrow. > > unfortunately, the patch broke Solaris/SPARC bootstrap > (sparc-sun-solaris2.11): > > /vol/gcc/src/hg/master/local/gcc/combine.cc: In function 'rtx_code simplify_comparison(rtx_code, rtx_def**, rtx_def**)': > /vol/gcc/src/hg/master/local/gcc/combine.cc:12101:25: error: '*(unsigned int*)((char*)&inner_mode + offsetof(scalar_int_mode, scalar_int_mode::m_mode))' may be used uninitialized [-Werror=maybe-uninitialized] > 12101 | scalar_int_mode mode, inner_mode, tmode; > | ^~~~~~~~~~ I don't see how it could ever work properly, inner_mode in that spot is just uninitialized. I think we shouldn't worry about paradoxical subregs of non-scalar_int_mode REGs/MEMs and for the scalar_int_mode ones should initialize inner_mode before we use it. Another option would be to use maybe_lt (GET_MODE_PRECISION (GET_MODE (SUBREG_REG (op0))), BITS_PER_WORD) and load_extend_op (GET_MODE (SUBREG_REG (op0))) == ZERO_EXTEND, or set machine_mode smode = GET_MODE (SUBREG_REG (op0)); and use it in those two spots. 2024-03-04 Jakub Jelinek PR rtl-optimization/113010 * combine.cc (simplify_comparison): Guard the WORD_REGISTER_OPERATIONS check on scalar_int_mode of SUBREG_REG and initialize inner_mode. Jakub --- gcc/combine.cc.jj 2024-03-04 10:01:21.054937316 +0100 +++ gcc/combine.cc 2024-03-04 17:40:51.556052647 +0100 @@ -12554,6 +12554,8 @@ simplify_comparison (enum rtx_code code, if (paradoxical_subreg_p (op0)) { if (WORD_REGISTER_OPERATIONS + && is_a (GET_MODE (SUBREG_REG (op0)), + &inner_mode) && GET_MODE_PRECISION (inner_mode) < BITS_PER_WORD /* On WORD_REGISTER_OPERATIONS targets the bits beyond sub_mode aren't considered undefined,