From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17137 invoked by alias); 10 Dec 2015 22:27:40 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 17125 invoked by uid 89); 10 Dec 2015 22:27:39 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.7 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 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; Thu, 10 Dec 2015 22:27:39 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id C8CD3C0A8481; Thu, 10 Dec 2015 22:27:37 +0000 (UTC) Received: from localhost.localdomain (ovpn-113-32.phx2.redhat.com [10.3.113.32]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id tBAMRbfd016616; Thu, 10 Dec 2015 17:27:37 -0500 Subject: Re: [PATCH] Fix phiopt ICE in Factor conversion in COND_EXPR (PR tree-optimization/66949) To: Marek Polacek , GCC Patches References: <20151208162133.GQ3175@redhat.com> Cc: Kugan From: Jeff Law Message-ID: <5669FC58.3070901@redhat.com> Date: Thu, 10 Dec 2015 22:27:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 In-Reply-To: <20151208162133.GQ3175@redhat.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2015-12/txt/msg01190.txt.bz2 On 12/08/2015 09:21 AM, Marek Polacek wrote: > The following is a conservative fix for this PR. This is an ICE transpiring > in the new "Factor conversion in COND_EXPR" optimization added in r225722. > > Before this optimization kicks in, we have > : > ... > p1_32 = (short unsigned int) _20; > > : > ... > iftmp.0_18 = (short unsigned int) _20; > > : > ... > # iftmp.0_19 = PHI > > after factor_out_conditional_conversion does its work, we end up with those two > def stmts removed and instead of the PHI we'll have > > # _35 = PHI <_20(3), _20(2)> > iftmp.0_19 = (short unsigned int) _35; > > That itself looks like a fine optimization, but after factor_out_conditional_conversion > there's > 320 phis = phi_nodes (bb2); > 321 phi = single_non_singleton_phi_for_edges (phis, e1, e2); > 322 gcc_assert (phi); > and phis look like > b.2_38 = PHI > _35 = PHI <_20(3), _20(2)> > so single_non_singleton_phi_for_edges returns NULL and the subsequent assert triggers. Cute. > > With this patch we won't ICE (and PRE should clean this up anyway), but I don't know, > maybe I should try harder to optimize even this problematical case (not sure how hard > it would be...)? So if this kind of situation is created by the first phiopt, then DOM should fix it. As you note PRE will catch it if the second phiopt pass creates this degenerate PHI. If created by the last phiopt pass, then hopefully coalescing would save us. Jeff