From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28308 invoked by alias); 23 Jul 2015 19:05:28 -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 28298 invoked by uid 89); 23 Jul 2015 19:05:28 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL,BAYES_00,KAM_LAZY_DOMAIN_SECURITY,RP_MATCHES_RCVD,SPF_HELO_PASS 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, 23 Jul 2015 19:05:22 +0000 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id 7786BB6E64; Thu, 23 Jul 2015 19:05:21 +0000 (UTC) Received: from localhost.localdomain (ovpn-113-54.phx2.redhat.com [10.3.113.54]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t6NJ5Kot008712; Thu, 23 Jul 2015 15:05:21 -0400 Subject: Re: [PR66726] Factor conversion out of COND_EXPR To: Kugan , Bernhard Reutner-Fischer References: <55974BF2.3060603@linaro.org> <20150704085143.GA14895@nbbrfq.cc.univie.ac.at> <5597D24B.8010900@linaro.org> <559AF515.6010700@redhat.com> <559BCB15.9010209@linaro.org> <559BE505.5070802@redhat.com> <559EFEE5.6030006@linaro.org> <55A02DBF.6030608@redhat.com> <55A24E7D.4080609@linaro.org> <55A6073D.1020800@linaro.org> <55A6AA4D.1030106@redhat.com> <55A74691.3050303@linaro.org> Cc: "gcc-patches@gcc.gnu.org" From: Jeff Law Message-ID: <55B13AF0.3020204@redhat.com> Date: Thu, 23 Jul 2015 19:48:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.0.1 MIME-Version: 1.0 In-Reply-To: <55A74691.3050303@linaro.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2015-07/txt/msg01973.txt.bz2 On 07/15/2015 11:52 PM, Kugan wrote: > >>> >>> diff --git a/gcc/tree-ssa-reassoc.c b/gcc/tree-ssa-reassoc.c >>> index 932c83a..3058eb5 100644 >>> --- a/gcc/tree-ssa-reassoc.c >>> +++ b/gcc/tree-ssa-reassoc.c >> >>> return false; >>> bb = gimple_bb (stmt); >>> if (!single_succ_p (bb)) >>> @@ -2729,9 +2743,8 @@ final_range_test_p (gimple stmt) >>> >>> lhs = gimple_assign_lhs (stmt); >>> rhs = gimple_assign_rhs1 (stmt); >>> - if (!INTEGRAL_TYPE_P (TREE_TYPE (lhs)) >>> - || TREE_CODE (rhs) != SSA_NAME >>> - || TREE_CODE (TREE_TYPE (rhs)) != BOOLEAN_TYPE) >>> + if (TREE_CODE (TREE_TYPE (rhs)) != BOOLEAN_TYPE >>> + && TREE_CODE (TREE_TYPE (lhs)) != BOOLEAN_TYPE) >>> return false; >> So you're ensuring that one of the two is a boolean... Note that >> previously we ensured that the rhs was a boolean and the lhs was an >> integral type (which I believe is true for booleans). >> >> Thus if we had >> bool x; >> int y; >> >> x = (bool) y; >> >> The old code would have rejected that case. But I think it gets through >> now, right? >> >> I think once that issue is addressed, this will be good for the trunk. >> > > Thanks for the review. How about: > > - if (!INTEGRAL_TYPE_P (TREE_TYPE (lhs)) > - || TREE_CODE (rhs) != SSA_NAME > - || TREE_CODE (TREE_TYPE (rhs)) != BOOLEAN_TYPE) > + if (gimple_assign_cast_p (stmt) > + && (!INTEGRAL_TYPE_P (TREE_TYPE (lhs)) > + || TREE_CODE (rhs) != SSA_NAME > + || TREE_CODE (TREE_TYPE (rhs)) != BOOLEAN_TYPE)) But then I think you need to verify that for the _234 = a_2(D) == 2; case that type of the RHS is a boolean. ie, each case has requirements for the types. I don't think they can be reasonably unified. So something like this: if (gimple_assign_cast_p (stmt) && ! (correct types for cast) return false; if (!gimple_assign_cast_p (stmt) && ! (correct types for tcc_comparison case)) return false; This works because we've already verified that it's either a type conversion or a comparison on the RHS. Jeff