From patchwork Wed Dec 23 08:49:22 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 560392 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 9449B140BF3 for ; Wed, 23 Dec 2015 19:49:36 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=AjaeI03h; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:reply-to:mime-version:content-type; q=dns; s=default; b=OJjeGO/xdC7Dn7BCx1IEwtOO4kTavAsHGdRj0qaTLBX 1RsppSyrAapdlC06qSA7UXiKz9wiSXXNv/gI8tOoN6wA2fjL9EIsgC1V9OQkNHrV b9vGqU081BntNRwKixp7eDohNZ9byBJPrmksw2/Ci7xvL7SQydTaMGl3kgs7SJ64 = DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:reply-to:mime-version:content-type; s=default; bh=Akx+PI3h9EWjg5t9qcOul3E0CZw=; b=AjaeI03hu3UzQ/AN8 HZ141+feE/7/SUx4pNG5OX02K3wYodBdLtdd2enr9ewOSwD3B7WuopBv69AiJEAt tUMqevaI5IOaIr9Bqhi0ZxGJrrAfJUhKXGmv46G15y96A0Uv0mXS8QX3/nbx3WyS XqGhvY5HS3lUtZNtYUAKhi3IFw= Received: (qmail 83875 invoked by alias); 23 Dec 2015 08:49:29 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 83862 invoked by uid 89); 23 Dec 2015 08:49:29 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.3 required=5.0 tests=AWL, BAYES_00, KAM_LAZY_DOMAIN_SECURITY, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=no version=3.3.2 spammy=2015-12-23, imply, 2015-12-10, 20151210 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Wed, 23 Dec 2015 08:49:28 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (Postfix) with ESMTPS id 203198CF43 for ; Wed, 23 Dec 2015 08:49:27 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-113-46.phx2.redhat.com [10.3.113.46]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id tBN8nPIu013735 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Wed, 23 Dec 2015 03:49:26 -0500 Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.15.2/8.15.2) with ESMTP id tBN8nNSD014277 for ; Wed, 23 Dec 2015 09:49:24 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id tBN8nMPo014276 for gcc-patches@gcc.gnu.org; Wed, 23 Dec 2015 09:49:22 +0100 Date: Wed, 23 Dec 2015 09:49:22 +0100 From: Jakub Jelinek To: gcc-patches@gcc.gnu.org Subject: [PATCH] Avoid ifcvt ICE on conditional return followed by trap (PR target/69015) Message-ID: <20151223084922.GS18720@tucnak.redhat.com> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) X-IsSubscribed: yes Hi! The find_cond_trap code isn't really prepared to turn conditional return into unconditional when converting non-conditional trap into conditional, without RTL checking it generates (label_ref (return)), the edges updates are also wrong. This patch just disables that transformation, IMHO trading conditional return + unconditional trap with conditional trap + unconditional return isn't worth it. Martin Sebor has kindly bootstrapped/regtested this on powerpc64le-linux, ok for trunk? 2015-12-23 Jakub Jelinek PR target/69015 * ifcvt.c (find_cond_trap): Give up if returnjump_p (jump). * gcc.dg/pr69015.c: New test. Jakub --- gcc/ifcvt.c.jj 2015-12-10 17:01:06.000000000 +0100 +++ gcc/ifcvt.c 2015-12-22 19:43:07.404639873 +0100 @@ -4526,8 +4526,11 @@ find_cond_trap (basic_block test_bb, edg return FALSE; /* If the conditional jump is more than just a conditional jump, then - we can not do if-conversion on this block. */ - if (! onlyjump_p (jump)) + we can not do if-conversion on this block. Give up for returnjump_p, + changing a conditional return followed by unconditional trap for + conditional trap followed by unconditional return is likely not + beneficial and harder to handle. */ + if (! onlyjump_p (jump) || returnjump_p (jump)) return FALSE; /* We must be comparing objects whose modes imply the size. */ --- gcc/testsuite/gcc.dg/pr69015.c.jj 2015-12-22 19:52:32.457756578 +0100 +++ gcc/testsuite/gcc.dg/pr69015.c 2015-12-22 19:53:39.544820625 +0100 @@ -0,0 +1,10 @@ +/* PR target/69015 */ +/* { dg-do compile } */ +/* { dg-options "-O2 -fno-if-conversion" } */ + +void +foo (int c) +{ + if (c) + __builtin_trap (); +}