From patchwork Wed Jun 9 07:24:29 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sandra Loosemore X-Patchwork-Id: 55114 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 5658EB7D20 for ; Thu, 10 Jun 2010 03:23:24 +1000 (EST) Received: (qmail 10250 invoked by alias); 9 Jun 2010 17:23:22 -0000 Received: (qmail 10241 invoked by uid 22791); 9 Jun 2010 17:23:21 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL, BAYES_00, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (38.113.113.100) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 09 Jun 2010 17:23:15 +0000 Received: (qmail 23541 invoked from network); 9 Jun 2010 17:23:14 -0000 Received: from unknown (HELO ?192.168.2.3?) (sandra@127.0.0.2) by mail.codesourcery.com with ESMTPA; 9 Jun 2010 17:23:14 -0000 Message-ID: <4C0FCE4D.7010005@codesourcery.com> Date: Wed, 09 Jun 2010 13:24:29 -0400 From: Sandra Loosemore User-Agent: Thunderbird 2.0.0.23 (X11/20090817) MIME-Version: 1.0 To: gcc-patches@gcc.gnu.org, Eric Botcazou Subject: RFC: fix think-o in tree-ssa-loop-ivopts.c Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Still working on PR42505, I found another problem in the ivopts cost computation. This is apparently not the cause of the regression in PR42505 either, but there's clearly something wrong here..... This patch http://gcc.gnu.org/ml/gcc-patches/2009-05/msg01579.html which was committed as r139821 includes this bit: > /* Having offset does not affect runtime cost in case it is added to > symbol, but it increases complexity. */ > if (offset) > cost.complexity++; > > - cost.cost += n_sums * add_cost (TYPE_MODE (ctype), speed); > - return cost; > + cost.cost += add_cost (TYPE_MODE (ctype), speed); > + > + aratio = ratio > 0 ? ratio : -ratio; > + if (aratio != 1) > + cost.cost += multiply_by_cost (aratio, TYPE_MODE (ctype), speed); > > fallback: > { The "cost" is never referred to again in the fallback code, so it seems like deleting the return statement was an unintended mistake. I quickly put together the attached patch with the obvious fix and re-ran CSiBE on x86-64 native.... and I found that code size went up, giving back about half the improvement I got from adjusting the iv setup costs for -Os. So, I'm wondering: Eric, were the runtime speed improvements you claimed you saw here http://gcc.gnu.org/ml/gcc-patches/2009-05/msg01858.html actually present in the checked-in version of the patch, where the result of the fancy cost computation is simply discarded, or in some other version of the patch that implemented what I presume was the intended behavior? Do we know for sure that the fancy cost computation actually even an improvement over the fallback case? TBH, I don't really have time to work on re-checking x86 benchmark results myself.... I'm just trying to grok the costs code so I can fix PR42505 for one of our ARM customers. ;-) -Sandra 2010-06-09 Sandra Loosemore gcc/ * tree-ssa-loop-ivopts.c (get_computation_cost_at): Return the computed cost. Index: gcc/tree-ssa-loop-ivopts.c =================================================================== --- gcc/tree-ssa-loop-ivopts.c (revision 160471) +++ gcc/tree-ssa-loop-ivopts.c (working copy) @@ -3875,6 +3875,7 @@ get_computation_cost_at (struct ivopts_d aratio = ratio > 0 ? ratio : -ratio; if (aratio != 1) cost.cost += multiply_by_cost (aratio, TYPE_MODE (ctype), speed); + return cost; fallback: if (can_autoinc)