From patchwork Tue Mar 19 21:02:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Makarov X-Patchwork-Id: 1913785 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=RbofEXIo; 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 4Tzkgy6qxCz1yWs for ; Wed, 20 Mar 2024 08:02:38 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 05798385842A for ; Tue, 19 Mar 2024 21:02:37 +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 DC1D73858CD1 for ; Tue, 19 Mar 2024 21:02:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DC1D73858CD1 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 DC1D73858CD1 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=1710882139; cv=none; b=DD9tB37cQT4tgDyHuZhb6WIPNCByv9QKejq8f39NJxaEbI2zPRudTDIhfgSmhXhXjruM4XZcGhYzbb1wIMYIKMGqP96SZVoI1ESgQFTuaqAKtB2DexoehOpU9BhQ6UoSBdRTsNNrTsXD3QHTddjb/n31tKXVvxLIuZlKdRIgI0A= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1710882139; c=relaxed/simple; bh=U4pXh+K+udF/vsc/xKvz6CNycMlctAvM8ELoyin3hJE=; h=DKIM-Signature:Message-ID:Date:MIME-Version:To:From:Subject; b=JwPira/hfXqKbFvwVwd4uqW2R/vJ/p6vVZsXl80V75R11tvI72fAinDfu4YFLfdqE4VqNotG60Xll3GBnjXaRRaqCrC+BVS2FW50GlAdgIZsOywEJwZIyWQvprw37W1YY8YOZNeH27Rgezz7WptZq5SbPiXexOz6EjofItYKNzY= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710882136; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type; bh=mZH3wBesRIs4hgM9q88QW4PPWGtneFYcHHSm06wk8Iw=; b=RbofEXIoxx5DSHjwpjpcDkxxi0/h9ZA5UY2wng3bsGvhHH8giTv3swQLEH91IYLHZrT+Gi sxsMRNVbDcBaox11Nk9sIVblOQThdJfasGeDcZk/t0DN8p2aQwQ4kagimrWSPo22ZDKvMC mULVllXr6HrvqQUVr23n9MXGNLidbHw= Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-164-tFsazSA9NgaOS9_fDSQ4Bw-1; Tue, 19 Mar 2024 17:02:13 -0400 X-MC-Unique: tFsazSA9NgaOS9_fDSQ4Bw-1 Received: by mail-qk1-f199.google.com with SMTP id af79cd13be357-789ea357429so479349585a.1 for ; Tue, 19 Mar 2024 14:02:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710882131; x=1711486931; h=subject:from:to:content-language:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Rvf2wAMmM5cLbPalJQUVPSA4QtQB2Mj2ZCUdnh7nmOE=; b=IfStcK+4TSFSiINLF/WgyqNWYA5WZc7XFDjRZxWEI9/hPKZhGAySmVFNqv1cr9yoD7 r8199mSomCCWVESS0L5OAC+enyZCCe3KFJ2LeTix/eJlZr3auTdVmaIXSy515t2pazmq MThnmAOZV9s7EMjheoYcw6+40r8IaK57E02/+qvZy/UPG8pXNBtE6E9FnkjPnK+AFj+K tsyzPQF1CHGByZfacG6kKCV35nXoAU/naA58nJC8Spb2NW0ifAwZoOiCqW2s3ON7nMDQ kBp8dTZHO7p6gpJy0b4m/i/KRBeixCM77QtySuefL93ojPE60nWIRf7q0V1SnSlN2/g/ BDpA== X-Gm-Message-State: AOJu0YxxiIHOmSiyO83ilscBAL4vjz2LNNWend4ollzDy6vrxJZ2ATzn HcmgdsBzcoOzDuQue/EXp/ZPPdjoPTvV6rpCPaW0w6iPur8B9Fa13ylstqcLdTSs8DJcavBr9Zh +TcRT6yU6wZHAz2ETL+XkGSrw0unTZQY5+f2MN4GcyzCYIxJVIUGH+lTwV25P3ivIPxRPEzLVt4 k25uxPVQK/11p7dNOyEap6H8UGTuUa+Pjp54P/g3Q= X-Received: by 2002:a05:620a:b03:b0:789:ed7f:94c1 with SMTP id t3-20020a05620a0b0300b00789ed7f94c1mr3814243qkg.73.1710882131435; Tue, 19 Mar 2024 14:02:11 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE5SJPdhb7xiiOTEPmp9ULHu4kGKa1LsNT4iJJ3cHxgJLnW4wuC1qREgWAk9Aqe57nk12TVSg== X-Received: by 2002:a05:620a:b03:b0:789:ed7f:94c1 with SMTP id t3-20020a05620a0b0300b00789ed7f94c1mr3814200qkg.73.1710882130799; Tue, 19 Mar 2024 14:02:10 -0700 (PDT) Received: from [192.168.1.88] (23-233-12-249.cpe.pppoe.ca. [23.233.12.249]) by smtp.gmail.com with ESMTPSA id wh12-20020a05620a56cc00b00789f2660e88sm3209216qkn.68.2024.03.19.14.02.09 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 19 Mar 2024 14:02:10 -0700 (PDT) Message-ID: <96cab043-4782-482f-ac8b-d64a2c5e362f@redhat.com> Date: Tue, 19 Mar 2024 17:02:09 -0400 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird To: "gcc-patches@gcc.gnu.org" From: Vladimir Makarov Subject: [pushed][PR99829][LRA]: Fixing LRA ICE on arm X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US X-Spam-Status: No, score=-11.1 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, HTML_MESSAGE, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, RCVD_IN_SORBS_WEB, 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: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org The following patch fixes https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99829 The patch was successfully bootstrapped and tested on x86-64, ppc64le, and aarch64. commit 9c91f8a88b2db50c8faf70786d3cef27b39ac9fc Author: Vladimir N. Makarov Date: Tue Mar 19 16:57:11 2024 -0400 [PR99829][LRA]: Fixing LRA ICE on arm LRA removed insn setting equivalence to memory whose output was reloaded. This resulted in writing an uninitiated value to the memory which triggered assert in LRA code checking the final generated code. This patch fixes the problem. Comment in the patch contains more details about the problem and its solution. gcc/ChangeLog: PR target/99829 * lra-constraints.cc (lra_constraints): Prevent removing insn with reverse equivalence to memory if the memory was reloaded. diff --git a/gcc/lra-constraints.cc b/gcc/lra-constraints.cc index 0ae81c1ff9c..10e3d4e4097 100644 --- a/gcc/lra-constraints.cc +++ b/gcc/lra-constraints.cc @@ -5213,7 +5213,7 @@ lra_constraints (bool first_p) bool changed_p; int i, hard_regno, new_insns_num; unsigned int min_len, new_min_len, uid; - rtx set, x, reg, dest_reg; + rtx set, x, reg, nosubreg_dest; rtx_insn *original_insn; basic_block last_bb; bitmap_iterator bi; @@ -5377,14 +5377,14 @@ lra_constraints (bool first_p) { if ((set = single_set (curr_insn)) != NULL_RTX) { - dest_reg = SET_DEST (set); + nosubreg_dest = SET_DEST (set); /* The equivalence pseudo could be set up as SUBREG in a case when it is a call restore insn in a mode different from the pseudo mode. */ - if (GET_CODE (dest_reg) == SUBREG) - dest_reg = SUBREG_REG (dest_reg); - if ((REG_P (dest_reg) - && (x = get_equiv (dest_reg)) != dest_reg + if (GET_CODE (nosubreg_dest) == SUBREG) + nosubreg_dest = SUBREG_REG (nosubreg_dest); + if ((REG_P (nosubreg_dest) + && (x = get_equiv (nosubreg_dest)) != nosubreg_dest /* Remove insns which set up a pseudo whose value cannot be changed. Such insns might be not in init_insns because we don't update equiv data @@ -5403,11 +5403,21 @@ lra_constraints (bool first_p) up the equivalence. */ || in_list_p (curr_insn, ira_reg_equiv - [REGNO (dest_reg)].init_insns))) + [REGNO (nosubreg_dest)].init_insns))) || (((x = get_equiv (SET_SRC (set))) != SET_SRC (set)) && in_list_p (curr_insn, ira_reg_equiv - [REGNO (SET_SRC (set))].init_insns))) + [REGNO (SET_SRC (set))].init_insns) + /* This is a reverse equivalence to memory (see ira.cc) + in store insn. We can reload all the destination and + have an output reload which is a store to memory. If + we just remove the insn, we will have the output + reload storing an undefined value to the memory. + Check that we did not reload the memory to prevent a + wrong code generation. We could implement using the + equivalence still in such case but doing this is not + worth the efforts as such case is very rare. */ + && MEM_P (nosubreg_dest))) { /* This is equiv init insn of pseudo which did not get a hard register -- remove the insn. */