From patchwork Tue Apr 2 11:46:57 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 232968 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 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "localhost", Issuer "www.qmailtoaster.com" (not verified)) by ozlabs.org (Postfix) with ESMTPS id D73152C012F for ; Tue, 2 Apr 2013 22:47:21 +1100 (EST) 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:cc:subject:message-id:reply-to:mime-version :content-type; q=dns; s=default; b=VBN0nxqHk4sHqpkzrYLAy7NHfwoWG Nk/XPm/jNv9BbIRnPSLutKwKgvcL+oBC6YsPWy3am4MoV1sA4WW4xvfOfgNh3knz bjSMqeuCUW/zjTXkpm0nTIX+7e26tWOIYxyizTFQsMGF4aQOOYH7QsH0x+jT6Zvd /n25K5ay9GHotI= 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:cc:subject:message-id:reply-to:mime-version :content-type; s=default; bh=ZJPUZBEht3vFAJ0eypqeP9j7xZM=; b=Siw 7G/uDP/OfRb08pKjv+kFhNViCjnZE7kYjPBZwSgIJiRc5L2sVcshxpdvUtn2FUg6 Ay/T0RWbWWEKyKIc8WCslVTHmdNJczsbydQsnnHThXPK06x25wXHxId+edVhd28p P8IJdR4XS2q1HIiGqDn96P/aYUs+ahfTJBYnyOoc= Received: (qmail 19414 invoked by alias); 2 Apr 2013 11:47:13 -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 19373 invoked by uid 89); 2 Apr 2013 11:47:06 -0000 X-Spam-SWARE-Status: No, score=-7.6 required=5.0 tests=AWL, BAYES_00, KHOP_RCVD_UNTRUST, RCVD_IN_DNSWL_HI, RCVD_IN_HOSTKARMA_W, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.1 Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Tue, 02 Apr 2013 11:47:03 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r32Bl1vv016730 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 2 Apr 2013 07:47:01 -0400 Received: from tucnak.zalov.cz (vpn1-6-53.ams2.redhat.com [10.36.6.53]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r32Bkxcg005960 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 2 Apr 2013 07:47:01 -0400 Received: from zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.14.5/8.14.5) with ESMTP id r32Bkwxn015949; Tue, 2 Apr 2013 13:46:58 +0200 Received: (from jakub@localhost) by zalov.cz (8.14.5/8.14.5/Submit) id r32BkvwA015948; Tue, 2 Apr 2013 13:46:57 +0200 Date: Tue, 2 Apr 2013 13:46:57 +0200 From: Jakub Jelinek To: Eric Botcazou , Richard Biener Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix cond_exec_find_if_block (PR rtl-optimization/56745) Message-ID: <20130402114657.GK20616@tucnak.redhat.com> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Hi! On the (undefined behavior) testcase below, we end up with then_bb ending with __builtin_unreachable () at the tree level, therefore no successor at the RTL level, and else_bb being EXIT_BLOCK_PTR (i.e. conditional return before a bb with undefined behavior at the end). Trying to optimize that into a conditional execution of the then_bb insns doesn't work, we can't merge the else_bb with then_bb and test_bb in this case, plus it doesn't look like something that would be desirable to do (conditional return is surely better). Fixed thusly, ok for trunk/4.8? 2013-04-02 Jakub Jelinek PR rtl-optimization/56745 * ifcvt.c (cond_exec_find_if_block): Don't try to optimize if then_bb has no successors and else_bb is EXIT_BLOCK_PTR. * gcc.c-torture/compile/pr56745.c: New test. Jakub --- gcc/ifcvt.c.jj 2013-03-05 23:25:15.000000000 +0100 +++ gcc/ifcvt.c 2013-04-02 12:31:19.476859094 +0200 @@ -3473,7 +3473,7 @@ cond_exec_find_if_block (struct ce_if_bl code processing. ??? we should fix this in the future. */ if (EDGE_COUNT (then_bb->succs) == 0) { - if (single_pred_p (else_bb)) + if (single_pred_p (else_bb) && else_bb != EXIT_BLOCK_PTR) { rtx last_insn = BB_END (then_bb); --- gcc/testsuite/gcc.c-torture/compile/pr56745.c.jj 2013-04-02 12:38:54.718258527 +0200 +++ gcc/testsuite/gcc.c-torture/compile/pr56745.c 2013-04-02 12:33:22.000000000 +0200 @@ -0,0 +1,15 @@ +/* PR rtl-optimization/56745 */ + +unsigned char a[6]; + +void +foo () +{ + int i; + for (i = 5; i >= 0; i++) + { + if (++a[i] != 0) + break; + ++a[i]; + } +}