From patchwork Tue Dec 1 08:48:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 1408673 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gcc.gnu.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=maueXK3f; dkim-atps=neutral Received: from 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 RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4ClbNR1mY2z9sW4 for ; Tue, 1 Dec 2020 19:48:21 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 69E47393D009; Tue, 1 Dec 2020 08:48:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 69E47393D009 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1606812497; bh=UWTOrNVgLISbWAm8zYEeiCKxNKjhmmMFCSb4arAas8Q=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=maueXK3f/SOJX70niJ8cMHvFTNXHn3GzSM2Dl298e3UKBx9WlST+5eoxX08NsKs/u j3dgNpOWASMflyqTtgNrSRHSVWGjsmQsdYik0++vj8dhJmuT1NUhVwUTB40JgZLin8 YG19GQWrMfOT++Mm9OOeJC4+s1X7hg1GhcA+741o= 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 [216.205.24.124]) by sourceware.org (Postfix) with ESMTP id E14E4389202E for ; Tue, 1 Dec 2020 08:48:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org E14E4389202E 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-471-U6szDtY-PjSdY-6uK2NqHw-1; Tue, 01 Dec 2020 03:48:12 -0500 X-MC-Unique: U6szDtY-PjSdY-6uK2NqHw-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id CE889E7167; Tue, 1 Dec 2020 08:48:11 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-113-127.ams2.redhat.com [10.36.113.127]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 925625C1A3; Tue, 1 Dec 2020 08:48:05 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.16.1/8.16.1) with ESMTPS id 0B18m2j92004380 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 1 Dec 2020 09:48:03 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.16.1/8.16.1/Submit) id 0B18m2dR2004378; Tue, 1 Dec 2020 09:48:02 +0100 Date: Tue, 1 Dec 2020 09:48:01 +0100 To: Richard Biener , Jeff Law Subject: [PATCH] loop-invariant: JUMP_INSNs aren't loop invariant [PR97954] Message-ID: <20201201084801.GP3788@tucnak> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-6.6 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_H3, RCVD_IN_MSPIKE_WL, 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-Patchwork-Original-From: Jakub Jelinek via Gcc-patches From: Jakub Jelinek Reply-To: Jakub Jelinek Cc: gcc-patches@gcc.gnu.org Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" Hi! The following testcase ICEs because loop invariant motion moves asm goto with a single output as invariant. Normally, jumps aren't really moved, because if they are single set, they have their SET_DEST (pc) and pc_rtx has VOIDmode on which one of the functions find_invariant_insn calls bails out. The code already punts on insns that can throw or trap. And for asm goto without outputs, it isn't single set, or asm goto with two or more outputs it isn't single set either. Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2020-12-01 Jakub Jelinek PR rtl-optimization/97954 * loop-invariant.c (find_invariant_insn): Punt on JUMP_P insns. * gcc.dg/pr97954.c: New test. Jakub --- gcc/loop-invariant.c.jj 2020-01-12 11:54:36.000000000 +0100 +++ gcc/loop-invariant.c 2020-11-30 09:56:37.022696142 +0100 @@ -1099,6 +1099,10 @@ find_invariant_insn (rtx_insn *insn, boo if (HAVE_cc0 && sets_cc0_p (insn)) return; + /* Jumps have control flow side-effects. */ + if (JUMP_P (insn)) + return; + set = single_set (insn); if (!set) return; --- gcc/testsuite/gcc.dg/pr97954.c.jj 2020-11-30 10:31:54.870891248 +0100 +++ gcc/testsuite/gcc.dg/pr97954.c 2020-11-30 10:31:08.875407984 +0100 @@ -0,0 +1,12 @@ +/* PR rtl-optimization/97954 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +int +foo (void) +{ + int x; + lab: + asm goto ("": "=r" (x) : : : lab); + return x; +}