From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by sourceware.org (Postfix) with ESMTP id D7E4A385BF83 for ; Mon, 6 Apr 2020 22:33:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org D7E4A385BF83 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-154-2ELawTa0NoapOaU8SeHUxQ-1; Mon, 06 Apr 2020 18:33:18 -0400 X-MC-Unique: 2ELawTa0NoapOaU8SeHUxQ-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3F39018A8C8A for ; Mon, 6 Apr 2020 22:33:17 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-112-28.ams2.redhat.com [10.36.112.28]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BE21E9D371; Mon, 6 Apr 2020 22:33:16 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.15.2/8.15.2) with ESMTP id 036MXEJO023601; Tue, 7 Apr 2020 00:33:15 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id 036MXDfR023600; Tue, 7 Apr 2020 00:33:13 +0200 Date: Tue, 7 Apr 2020 00:33:13 +0200 From: Jakub Jelinek To: Jeff Law Cc: gcc-patches@gcc.gnu.org Subject: [committed] cselib: Fix endless cselib loop on (plus:P (reg) (const_int 0)) Message-ID: <20200406223313.GV2212@tucnak> Reply-To: Jakub Jelinek MIME-Version: 1.0 User-Agent: Mutt/1.11.3 (2019-02-01) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Content-Disposition: inline X-Spam-Status: No, score=-18.9 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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-List-Received-Date: Mon, 06 Apr 2020 22:33:21 -0000 Hi! getopt.c hangs the compiler on h8300-elf with -O2 -g, because the IL contains addition of constant 0, the first PLUS operand is determined to have the SP_DERIVED_VALUE_P and the new code in cselib recurses indefinitely on seeing SP_DERIVED_VALUE_P with locs of (plus:P SP_DERIVED_VALUE_P (const_int 0)). Fixed by making sure cselib_subst_to_values canonicalizes it, hashing already hashes it the same too. Bootstrapped/regtested on x86_64-linux and i686-linux, tested on the getopt.i testcase using cross to h8300-elf, approved off-list by Jeff, committed to trunk. 2020-04-06 Jakub Jelinek =09* cselib.c (cselib_subst_to_values): For SP_DERIVED_VALUE_P =09+ const0_rtx return the SP_DERIVED_VALUE_P. --- gcc/cselib.c.jj=092020-04-04 10:31:15.409783959 +0200 +++ gcc/cselib.c=092020-04-06 12:05:46.055767835 +0200 @@ -2090,13 +2090,17 @@ cselib_subst_to_values (rtx x, machine_m =09{ =09 rtx t =3D cselib_subst_to_values (XEXP (x, 0), memmode); =09 if (GET_CODE (t) =3D=3D VALUE) -=09 for (struct elt_loc_list *l =3D CSELIB_VAL_PTR (t)->locs; -=09=09 l; l =3D l->next) -=09 if (GET_CODE (l->loc) =3D=3D PLUS -=09=09 && GET_CODE (XEXP (l->loc, 0)) =3D=3D VALUE -=09=09 && SP_DERIVED_VALUE_P (XEXP (l->loc, 0)) -=09=09 && CONST_INT_P (XEXP (l->loc, 1))) -=09=09return plus_constant (Pmode, l->loc, INTVAL (XEXP (x, 1))); +=09 { +=09 if (SP_DERIVED_VALUE_P (t) && XEXP (x, 1) =3D=3D const0_rtx) +=09=09return t; +=09 for (struct elt_loc_list *l =3D CSELIB_VAL_PTR (t)->locs; +=09=09 l; l =3D l->next) +=09=09if (GET_CODE (l->loc) =3D=3D PLUS +=09=09 && GET_CODE (XEXP (l->loc, 0)) =3D=3D VALUE +=09=09 && SP_DERIVED_VALUE_P (XEXP (l->loc, 0)) +=09=09 && CONST_INT_P (XEXP (l->loc, 1))) +=09=09 return plus_constant (Pmode, l->loc, INTVAL (XEXP (x, 1))); +=09 } =09 if (t !=3D XEXP (x, 0)) =09 { =09 copy =3D shallow_copy_rtx (x); =09Jakub