From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 48744 invoked by alias); 21 Dec 2017 18:57:03 -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 48702 invoked by uid 89); 21 Dec 2017 18:57:03 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.9 required=5.0 tests=BAYES_00,GIT_PATCH_2,GIT_PATCH_3,SPF_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy= X-HELO: mx2.suse.de Received: from mx2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 21 Dec 2017 18:57:02 +0000 Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 1A9A4AD82; Thu, 21 Dec 2017 18:56:59 +0000 (UTC) Date: Thu, 21 Dec 2017 18:57:00 -0000 User-Agent: K-9 Mail for Android In-Reply-To: <20171221175045.GA2353@tucnak> References: <20171221175045.GA2353@tucnak> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PATCH] Fix factor_out_conditional_conversion caused ICE (PR tree-optimization/83521) To: Jakub Jelinek ,Jeff Law CC: gcc-patches@gcc.gnu.org From: Richard Biener Message-ID: <4D573FA9-46E7-4CBF-9349-42D8093D243E@suse.de> X-SW-Source: 2017-12/txt/msg01444.txt.bz2 On December 21, 2017 6:50:45 PM GMT+01:00, Jakub Jelinek = wrote: >Hi! > >The problem here is that the code expects fold_build1 will actually not >fold, because using gimple_build_assign (..., VIEW_CONVERT_EXPR, temp); >is valid only if TREE_CODE (temp) =3D=3D VIEW_CONVERT_EXPR. >So, either we can replace the fold_build1 with build1, or we should >just >use the gimple_build_assign overload that will handle even what >> will fold to (in this case >a >). > >Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? OK.=20 Richard.=20 >2017-12-21 Jakub Jelinek > > PR tree-optimization/83521 > * tree-ssa-phiopt.c (factor_out_conditional_conversion): Use > gimple_build_assign without code on result of > fold_build1 (VIEW_CONVERT_EXPR, ...), as it might not create > a VIEW_CONVERT_EXPR. > > * gcc.dg/pr83521.c: New test. > >--- gcc/tree-ssa-phiopt.c.jj 2017-12-20 20:40:18.000000000 +0100 >+++ gcc/tree-ssa-phiopt.c 2017-12-21 11:25:33.335004838 +0100 >@@ -548,8 +548,12 @@ factor_out_conditional_conversion (edge >=20 > /* Create the conversion stmt and insert it. */ > if (convert_code =3D=3D VIEW_CONVERT_EXPR) >- temp =3D fold_build1 (VIEW_CONVERT_EXPR, TREE_TYPE (result), temp); >- new_stmt =3D gimple_build_assign (result, convert_code, temp); >+ { >+ temp =3D fold_build1 (VIEW_CONVERT_EXPR, TREE_TYPE (result), >temp); >+ new_stmt =3D gimple_build_assign (result, temp); >+ } >+ else >+ new_stmt =3D gimple_build_assign (result, convert_code, temp); > gsi =3D gsi_after_labels (gimple_bb (phi)); > gsi_insert_before (&gsi, new_stmt, GSI_SAME_STMT); >=20 >--- gcc/testsuite/gcc.dg/pr83521.c.jj 2017-12-21 11:29:54.348662949 >+0100 >+++ gcc/testsuite/gcc.dg/pr83521.c 2017-12-21 11:29:41.000000000 +0100 >@@ -0,0 +1,10 @@ >+/* PR tree-optimization/83521 */ >+/* { dg-do compile } */ >+/* { dg-options "-O1 -fno-tree-forwprop" } */ >+ >+int >+foo (unsigned int x, int y) >+{ >+ int *z =3D (int *)&x; >+ return (y =3D=3D 0) ? y : *z; >+} > > Jakub