From patchwork Wed Aug 5 14:18:18 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 504030 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 CCD2A1402C7 for ; Thu, 6 Aug 2015 00:18:32 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=jD+qwr1S; 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:subject:date:message-id:mime-version:content-type :content-transfer-encoding; q=dns; s=default; b=TfK4it8FCyhJZXlu 1McN4FtU+0WFgWCURWj++Spm/THG5YuPAfvpJCbRkqlA5hdyP+QgbCzQQeRRQmuV ycriokOeSY/Lw7GBqMM8I5IyGiLMmbLproAqWloJuSms/P2rk7xBGaCVHMlZig6D 2gT0BXTHnQ79Ms/JfaSYSZxwmCw= 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:subject:date:message-id:mime-version:content-type :content-transfer-encoding; s=default; bh=ultP6acsYULHFeUUA3ME1Z OLjIo=; b=jD+qwr1Sc7nqQm2xu7NA1uX5XR8YJp5ao0MfKBtCTwHS1ZC3mhJH3I 4HdjeFEUipa/7ubvuHWCmqECoSRkPk40kUNLN+u7nMbnD79KmzsiOXdTB8Bx32+T qS9dyAFAbMnMOaKK7f6HyO7MCdulcQhJ2EY9GJmQDJ+FeOIxhcsQ4= Received: (qmail 61010 invoked by alias); 5 Aug 2015 14:18:25 -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 60999 invoked by uid 89); 5 Aug 2015 14:18:24 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.3 required=5.0 tests=AWL, BAYES_00, SPF_PASS autolearn=ham version=3.3.2 X-HELO: eu-smtp-delivery-143.mimecast.com Received: from eu-smtp-delivery-143.mimecast.com (HELO eu-smtp-delivery-143.mimecast.com) (146.101.78.143) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 05 Aug 2015 14:18:23 +0000 Received: from cam-owa1.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.140]) by eu-smtp-1.mimecast.com with ESMTP id uk-mta-35-VaEZJlSORwOq8JU55pdjIA-1; Wed, 05 Aug 2015 15:18:18 +0100 Received: from localhost ([10.1.2.79]) by cam-owa1.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Wed, 5 Aug 2015 15:18:18 +0100 From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@arm.com Subject: Fix reload1.c warning for some targets Date: Wed, 05 Aug 2015 15:18:18 +0100 Message-ID: <87d1z1kedx.fsf@e105548-lin.cambridge.arm.com> User-Agent: Gnus/5.130012 (Ma Gnus v0.12) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 X-MC-Unique: VaEZJlSORwOq8JU55pdjIA-1 Building some targets results in a warning about orig_dup[i] potentially being used uninitialised. I think the warning is fair, since it isn't obvious that the reog_data-based loop bound remains unchanged between: for (i = 0; i < recog_data.n_dups; i++) orig_dup[i] = *recog_data.dup_loc[i]; and: for (i = 0; i < recog_data.n_dups; i++) *recog_data.dup_loc[i] = orig_dup[i]; Tested on x86_64-linux-gnu. OK to install? Thanks, Richard gcc/ * reload1.c (elimination_costs_in_insn): Make it obvious to the compiler that the n_dups and n_operands loop bounds are invariant. diff --git a/gcc/reload1.c b/gcc/reload1.c index ce06e06..ad243e3 100644 --- a/gcc/reload1.c +++ b/gcc/reload1.c @@ -3708,10 +3708,12 @@ elimination_costs_in_insn (rtx_insn *insn) /* Eliminate all eliminable registers occurring in operands that can be handled by reload. */ extract_insn (insn); - for (i = 0; i < recog_data.n_dups; i++) + int n_dups = recog_data.n_dups; + for (i = 0; i < n_dups; i++) orig_dup[i] = *recog_data.dup_loc[i]; - for (i = 0; i < recog_data.n_operands; i++) + int n_operands = recog_data.n_operands; + for (i = 0; i < n_operands; i++) { orig_operand[i] = recog_data.operand[i]; @@ -3756,7 +3758,7 @@ elimination_costs_in_insn (rtx_insn *insn) } } - for (i = 0; i < recog_data.n_dups; i++) + for (i = 0; i < n_dups; i++) *recog_data.dup_loc[i] = *recog_data.operand_loc[(int) recog_data.dup_num[i]]; @@ -3764,9 +3766,9 @@ elimination_costs_in_insn (rtx_insn *insn) check_eliminable_occurrences (old_body); /* Restore the old body. */ - for (i = 0; i < recog_data.n_operands; i++) + for (i = 0; i < n_operands; i++) *recog_data.operand_loc[i] = orig_operand[i]; - for (i = 0; i < recog_data.n_dups; i++) + for (i = 0; i < n_dups; i++) *recog_data.dup_loc[i] = orig_dup[i]; /* Update all elimination pairs to reflect the status after the current