From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10814 invoked by alias); 2 Sep 2014 06:00:36 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 10781 invoked by uid 48); 2 Sep 2014 06:00:32 -0000 From: "amker.cheng at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/62631] gcc.dg/tree-ssa/ivopts-lt-2.c FAILs Date: Tue, 02 Sep 2014 06:00:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 5.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: amker.cheng at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 5.0 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2014-09/txt/msg00257.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=62631 --- Comment #4 from bin.cheng --- Hi Rainer, This is caused by abnormal huge cost of function call `shiftadd_cost (true, DImode, 2)'. It returns 100+ cost, resulting in huge cost when representing use 1 with cand 4: use 1 compare in statement if (i_12 <= 99) at position type unsigned int base i_4(D) + 1 step 1 is a biv related candidates i_4(D) is invariant (2), eliminable p_8 is invariant (1), eliminable candidate 4 (important) original biv type int * base p_8 step 4 base object (void *) p_8 Use 1: cand cost compl. depends on 0 4 0 inv_expr:0 1 4 0 4 23 0 inv_expr:1 <------huge cost. 5 0 0 6 0 0 8 4 1 I worked out a patch fixing this from ivopt. Because I am not firmiliar with sparc ISA, could you please help me confirm that below fixed assembly is better than the original version? The orignal assembly: f1: sllx %o1, 2, %g1 add %o0, %g1, %o0 .LL2: st %g0, [%o0] add %o1, 1, %g1 add %o0, 4, %o0 cmp %g1, 99 bleu,pt %icc, .LL2 srl %g1, 0, %o1 jmp %o7+8 nop .size f1, .-f1 The fixed version assembly: f1: .register %g2, #scratch sllx %o1, 2, %g1 mov 99, %g2 add %o0, %g1, %o0 sub %g2, %o1, %o1 srl %o1, 0, %g1 add %g1, 1, %g1 sllx %g1, 2, %g1 add %o0, %g1, %g1 st %g0, [%o0] .LL5: add %o0, 4, %o0 cmp %o0, %g1 blu,a,pt %xcc, .LL5 st %g0, [%o0] jmp %o7+8 nop .size f1, .-f1 Though it has larger loop setup code, the loop itself is simplified. If yes, I will send out the patch for review. Thanks, bin