From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29276 invoked by alias); 16 Jul 2004 07:01:41 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 29246 invoked by alias); 16 Jul 2004 07:01:37 -0000 Date: Fri, 16 Jul 2004 07:01:00 -0000 Message-ID: <20040716070137.29245.qmail@sourceware.org> From: "zlomj9am at artax dot karlin dot mff dot cuni dot cz" To: gcc-bugs@gcc.gnu.org In-Reply-To: <20040501142654.15242.anton@mips.complang.tuwien.ac.at> References: <20040501142654.15242.anton@mips.complang.tuwien.ac.at> Reply-To: gcc-bugzilla@gcc.gnu.org Subject: [Bug rtl-optimization/15242] pessimization of "goto *" X-Bugzilla-Reason: CC X-SW-Source: 2004-07/txt/msg01980.txt.bz2 List-Id: ------- Additional Comments From zlomj9am at artax dot karlin dot mff dot cuni dot cz 2004-07-16 07:01 ------- Subject: Re: pessimization of "goto *" > > The optimization is enabled at -O2 > Not as far as I can tell (tried it on i386 with patched versions of > gcc-3.5-20040704 and gcc-3.5-20040523). Yes, it is enabled by the patch. The patch duplicates block with computed goto to place where a uncond jump to the conputed goto block is if the block is small enough. The computed jump in the small testcase is not duplicated, because the uncond jumps from other places do not jump to a basic block which contains the computed jump but to other block: f: pushl %ebp movl %esp, %ebp pushl %ebx movl 8(%ebp), %ebx .p2align 2,,3 .L37: cmpl $4, %ebx jle .L39 .L34: movl $5, %ebx .L9: movl a.1118(,%ebx,4), %eax jmp *%eax .p2align 2,,3 .L39: testl %ebx, %ebx jg .L9 jmp .L34 .p2align 2,,3 .L3: popl %ebx leave ret .p2align 2,,3 .L2: sall %ebx jmp .L37 .p2align 2,,3 .L1: addl $2, %ebx jmp .L37 .p2align 2,,3 .L5: decl %ebx jmp .L37 .p2align 2,,3 .L4: incl %ebx jmp .L37 However, I see that after the L39 there is a cond jump to the computed jump block. This is not handled by my patch but could be. > We would like to use -fno-reorder-blocks with > duplicate_computed_gotos, either through an extra option, or by just > having duplicate_computed_gotos all the time (at least for our code > these gotos were duplicated already in the source code, so duplicating > them again in the back end is closer to the idea of > -fno-reorder-blocks than not duplicating them). Adding an new flag is possible. However, I do not see why you explicitelly want to disable reorder-blocks. > One other thing I noticed is that apparently there is no combining > pass (or its tree-ssa equivalent) after duplicate_computed_gotos, > resulting in compiling code like > > goto *a[i]; > > into > > movl a.0(,%ebx,4), %eax > jmp *%eax > > instead of > > jmp *a.0(,%ebx,4) The combiner should have already combined these insns before the duplication of computed gotos is run. This pass just duplicates some insns. Josef -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15242