From patchwork Fri Apr 29 15:55:50 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Cheng X-Patchwork-Id: 616883 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]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3qxJGJ1V2Lz9t3p for ; Sat, 30 Apr 2016 01:56:23 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=kXw01hMu; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:mime-version:content-type; q=dns; s=default; b=VfGizJb7zf95Tc5E3SkpKLBUzka/OWZSj12F4AqQyd6cdU1Yyg F3mrwBnJ98uEJoGf8j/IvB7nmQMbLhJ1znaDwbXx89TKZb4zAsv0r0MlzPFZQYtj a+JqkpMKhw0uR/nWg9Kcu16hR8NAmRGzU9ojE9oZ26ygbXOia7debtxsA= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:mime-version:content-type; s= default; bh=+4B7qygu2Brdo+/Ou3/gkeKQG+4=; b=kXw01hMu8Nmk7FwPIzX9 gcWXqvKI8uIb5Xcf7xmEbVUhlDCI2NnCm0QMBiZZB7lWU0jU25JKcJiq/oq+zRzK gB1mEN00z5H17GAg62LjvBmVg8yKBtnBSUWXqh91p/ADOaVEfnn9jxJNqfIwVTNC 4yewqHysbHC9hEzxitCLcWE= Received: (qmail 37229 invoked by alias); 29 Apr 2016 15:56:10 -0000 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 Received: (qmail 37135 invoked by uid 89); 29 Apr 2016 15:56:10 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00, SPF_PASS autolearn=ham version=3.3.2 spammy=H*c:HHH, H*MI:outlook, HAccept-Language:en-GB, H*MI:prod X-HELO: eu-smtp-delivery-143.mimecast.com Received: from eu-smtp-delivery-143.mimecast.com (HELO eu-smtp-delivery-143.mimecast.com) (207.82.80.143) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 29 Apr 2016 15:55:57 +0000 Received: from emea01-db3-obe.outbound.protection.outlook.com (mail-db3lrp0083.outbound.protection.outlook.com [213.199.154.83]) (Using TLS) by eu-smtp-1.mimecast.com with ESMTP id uk-mta-24-bj5S7F1cR-SegwFHy8Q6sQ-1; Fri, 29 Apr 2016 16:55:52 +0100 Received: from DB5PR08MB1144.eurprd08.prod.outlook.com (10.166.174.137) by DB5PR08MB1142.eurprd08.prod.outlook.com (10.166.174.135) with Microsoft SMTP Server (TLS) id 15.1.477.8; Fri, 29 Apr 2016 15:55:50 +0000 Received: from DB5PR08MB1144.eurprd08.prod.outlook.com ([10.166.174.137]) by DB5PR08MB1144.eurprd08.prod.outlook.com ([10.166.174.137]) with mapi id 15.01.0477.014; Fri, 29 Apr 2016 15:55:50 +0000 From: Bin Cheng To: "gcc-patches@gcc.gnu.org" CC: nd Subject: [PATCH GCC]Don't clobber cbase when computing iv_use cost. Date: Fri, 29 Apr 2016 15:55:50 +0000 Message-ID: x-ms-office365-filtering-correlation-id: 218d0711-456b-4d22-5585-08d37046bcc8 x-microsoft-exchange-diagnostics: 1; DB5PR08MB1142; 5:LWaISH0x8Lnrh46VZyiVOb/xyaridEPrUUwxbvWI1LMdyuKwo0kE6cMEIFrLYbIMtOW8dp/vbfCCyUD7NqJzBBe4cgJKzW9/a1NOdirgkrbp+ZCqDj1sD0nBCVr0WSjIOwFOyrf1cVglkkoUJnYzmQ==; 24:MWzicoX5GLCN5Cb8XaF6BrJdYRSu0unTQV3l5YMVxy7X7MRSYg+Y8KT5ATSOf/MoIHj6Quf9pAdTLR/WoPNQGmda0f7U3zUZVy+WGSUaFF8=; 7:xHJMjF0KpC5UawfelI2KeO5C5tDW1fNJvrxNgd6jGXqcE32b5C6EN+5R2uDTDZFwPFgyxnonfYqF/HAnhlhAYw9wfhJf2eu1yJ4fB6AXkjYFSnvNLoaNGOfRLdHGDp0iWjlWU2GmEQP2OaAevAXZsrCSGxC6PWZ/e14aUACJCqaFxjZ3qREHD4U0F2TkXbAc; 20:Xfg3WcgJvcpDlKkhqSYnR7uoL77eGT+X1xLRtam957AoxMtdZafNk4Wr8cW0LTX2ca+nHx+1zfiuDO9WeOpBLdttJbXOygDnCv2Auyutz80XQSsnTt54Z91s5apVn2/9bf6W7c8c5Yzuuh5EidY4UxWdVKINrBLjvA5zKOna9IU= x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:DB5PR08MB1142; nodisclaimer: True x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(102415293)(102615271)(9101521072)(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046)(6055026); SRVR:DB5PR08MB1142; BCL:0; PCL:0; RULEID:; SRVR:DB5PR08MB1142; x-forefront-prvs: 0927AA37C7 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(6009001)(377424004)(450100001)(92566002)(4326007)(81166005)(189998001)(110136002)(5002640100001)(3280700002)(5003600100002)(66066001)(76576001)(122556002)(5008740100001)(1096002)(86362001)(99936001)(11100500001)(50986999)(33656002)(54356999)(87936001)(2906002)(102836003)(3846002)(6116002)(586003)(74316001)(5004730100002)(229853001)(1220700001)(2501003)(77096005)(10400500002)(3660700001)(558084003)(2900100001)(19580405001)(19580395003)(9686002)(2351001)(106116001); DIR:OUT; SFP:1101; SCL:1; SRVR:DB5PR08MB1142; H:DB5PR08MB1144.eurprd08.prod.outlook.com; FPR:; SPF:None; MLV:sfv; LANG:en; spamdiagnosticoutput: 1:23 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-originalarrivaltime: 29 Apr 2016 15:55:50.5076 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB5PR08MB1142 X-MC-Unique: bj5S7F1cR-SegwFHy8Q6sQ-1 X-IsSubscribed: yes Hi, This fixes a latent bug I introduced. Variable "cbase" shouldn't be modified since it will be used afterwards. Bootstrap and test on x86_64. I think it's an obvious change, is it OK? Thanks, bin 2016-04-28 Bin Cheng * tree-ssa-loop-ivopts.c (get_computation_cost_at): Don't clobber cbase. diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c index 7be4f16..acafaff 100644 --- a/gcc/tree-ssa-loop-ivopts.c +++ b/gcc/tree-ssa-loop-ivopts.c @@ -4927,17 +4927,19 @@ get_computation_cost_at (struct ivopts_data *data, (ratio, mem_mode, TYPE_ADDR_SPACE (TREE_TYPE (utype)))) { + tree real_cbase = cbase; + if (cstepi == 0 && stmt_is_after_inc) { if (POINTER_TYPE_P (ctype)) - cbase = fold_build2 (POINTER_PLUS_EXPR, ctype, cbase, cstep); + real_cbase = fold_build2 (POINTER_PLUS_EXPR, ctype, cbase, cstep); else - cbase = fold_build2 (PLUS_EXPR, ctype, cbase, cstep); + real_cbase = fold_build2 (PLUS_EXPR, ctype, cbase, cstep); } - cbase - = fold_build2 (MULT_EXPR, ctype, cbase, build_int_cst (ctype, ratio)); + real_cbase = fold_build2 (MULT_EXPR, ctype, real_cbase, + build_int_cst (ctype, ratio)); cost = difference_cost (data, - ubase, cbase, + ubase, real_cbase, &symbol_present, &var_present, &offset, depends_on); cost.cost /= avg_loop_niter (data->current_loop);