From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28910 invoked by alias); 22 Sep 2009 01:20:24 -0000 Received: (qmail 28901 invoked by uid 22791); 22 Sep 2009 01:20:23 -0000 X-SWARE-Spam-Status: No, hits=-1.3 required=5.0 tests=AWL,BAYES_00,SARE_MLB_Stock6 X-Spam-Check-By: sourceware.org Received: from eastrmmtao102.cox.net (HELO eastrmmtao102.cox.net) (68.230.240.8) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 22 Sep 2009 01:20:19 +0000 Received: from eastrmimpo03.cox.net ([68.1.16.126]) by eastrmmtao102.cox.net (InterMail vM.8.00.01.00 201-2244-105-20090324) with ESMTP id <20090922012018.MXDD1164.eastrmmtao102.cox.net@eastrmimpo03.cox.net>; Mon, 21 Sep 2009 21:20:18 -0400 Received: from [192.168.1.118] ([24.254.236.21]) by eastrmimpo03.cox.net with bizsmtp id jdLH1c0050UP1Qg02dLHp4; Mon, 21 Sep 2009 21:20:18 -0400 X-VR-Score: -200.00 X-Authority-Analysis: v=1.0 c=1 a=ArLxcoEFywMA:10 a=v12QDb80AAAA:8 a=mDV3o1hIAAAA:8 a=OygYrfTGpVi_P8tTYhYA:9 a=Cq_-3rruN-3wScgV2PIeNjn2rGEA:4 a=vJm8L1ID9xUA:10 X-CM-Score: 0.00 Message-ID: <4AB82659.3060403@cox.net> Date: Tue, 22 Sep 2009 01:20:00 -0000 From: Andrew Hutchinson User-Agent: Thunderbird 2.0.0.23 (Windows/20090812) MIME-Version: 1.0 To: Joern Rennecke CC: GCC Development Subject: Re: Cannot get Bit test RTL to cooperate with Combine. References: <4AB66B33.9010409@cox.net> <20090921204853.n2kguj1an4g0s8k4-nzlynne@webmail.spamcop.net> In-Reply-To: <20090921204853.n2kguj1an4g0s8k4-nzlynne@webmail.spamcop.net> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org X-SW-Source: 2009-09/txt/msg00428.txt.bz2 Thank you so much for your information! I will investigate your patch. (I just hacked lowpart_for_combine to allow lowering something larger than word and the subreg matched no problem.) It looks like RTL generation is somewhat odd and not helping. My test used extern long x; if (x & 1).... If there is only a single reference to x then (x &1), is lowered to HI mode and does not included any subregs (nosplit-wide-types). So my patterns match. If my test code included two bit tests - I get HI mode subregs on the x &1 (which will not match) but not on x & 2 the latter is in the wider SI mode and will match. If I turn on split-wide-types, the subregs are not removed by subreg lowering since there is now mixed mode usage! Something seem backwards in expansion, regarding lowering and references. Andy Joern Rennecke wrote: > On Sun, Sep 20, 2009 at 01:49:39PM -0400, Andrew Hutchinson wrote: >> All, >> >> I have been debugging AVR port to see why we fail to match so many bit >> test opportunities. >> >> When dealing with longer modes I have come across a problem I can not >> solve. >> >> Expansion in RTL for a bit test can produce two styles. >> >> STYLE 1 Bit to be tested is NOT LSB (e.g. if ( longthing & 0x10)), the >> expanded code contains the test as: >> >> (and:SI (reg:SI 45 [ lx.1 ]) >> (const_int 16 [0x10])) >> >> Bit tests are matched by combine. Combine has no problems with this and >> eventually creates a matching pattern based on the conversion of the AND >> to a zero extraction >> >> (set (pc) >> (if_then_else (ne (zero_extract:SI (subreg:QI (reg:SI 45 [ lx.1 ]) 0) >> (const_int 1 [0x1]) >> (const_int 4 [0x4])) >> (const_int 0 [0x0])) >> (label_ref:HI 133) >> (pc))) >> >> This will match Bit test patterns and produces optimal code. :-) > > Unfortunately, when combine knows about upper bits that are zero, it > will generate an lshiftrt instead, which can't be legitimately matched > by a bit test. > > I have a patch for this which I haven't gotten around yet to test it > separately in trunk and formally submit to the patches list, but you can > extract it from arc-20081210-branch: > > 2008-12-02 J"orn Rennecke > > * combine.c (undo_since): New function, broken out of: > (undo_all). > (combine_simplify_bittest): New function. > (combine_simplify_rtx, simplify_if_then_else): Use it. > * config/arc/arc.c (arc_rtx_costs): Check for bbit test. > > svn diff -r144651:144652 > svn://gcc.gnu.org/svn/gcc/branches/arc-20081210-branch/gcc/combine.c >