From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by sourceware.org (Postfix) with ESMTPS id 14A393857824 for ; Sat, 11 Dec 2021 11:47:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 14A393857824 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=embecosm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=embecosm.com Received: by mail-wr1-x433.google.com with SMTP id t9so19125275wrx.7 for ; Sat, 11 Dec 2021 03:47:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; h=date:from:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=s4c/UhHK/m0VsjrVuKPTOTLJ+8cLbCDgkG3U7Yri9ZA=; b=baEN4Y+fPhxG/haxyOeHq82oCsngeEIGkCIM1N16WSTJCIQ8wGu8Iibq5oZ38AgiLG GJ9hgkzqh+V/iJfxaF8THV/2IMGpJ9/jX2jD8BzFILTTiqMebJdTJgsA2+PTIkweDaKX Fg1EOBAKVhe+mpRQAorebe7OoWX/KII7ijgOLzG7AbARvfDGX9HbCKsXtGKIzXPscKGC 7sl+w8+7lvsVbp2VZ6Iaerci+Kul53v4Y5upq5ezDPk8NiM57JxHDdWB6Jox0gJuqzjT 4kxV6q6iVqhMojK40E3zW9PVmq8pmJ/pVn2sJBCKzqbX+lj75gd63gCDI/CwlLRtyqBR NyYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:in-reply-to:message-id :references:user-agent:mime-version; bh=s4c/UhHK/m0VsjrVuKPTOTLJ+8cLbCDgkG3U7Yri9ZA=; b=JugdmbFkAx1YPNRJN4NKzwSnHLMUOZZNb+fSAv5ZQIGIa6JGEHKK6Z9WKlTVrc0l2c jC45QcXPmqixCOIZegcEzSPGI3UjWbv0XcCE7D9NjpQHLUe971z4XdKWS9ZZuZWQTGMT AeGAOx43OUa3AzLtyBVid4yeOjYBL1HH5N5ZqHzeNCn5A5sK+RDKvxUHkS4J3W71wR2I +KMYJriYG+F2y4eoQeN/mh6e6q/Wp/FS9UhGOSPix2BGIxfCI224LpJhsHK45/t4uKMB zvy+evFhYnJM0C09ocYDOYQ181lBWSvKi+MTRL+U1cOysu/BAzLKUzAyE6oub7go3usf IR2Q== X-Gm-Message-State: AOAM532BQRp2MnJ918bF83JNLSyk7oEFIqVFNZbEkl/G1lVmCflA1HB8 CMPaiN3N1cXGYloYJdgInvC1NWSvW4SgpQ== X-Google-Smtp-Source: ABdhPJzj3PhGGqQKelau+v0kXkBc6MA9NgbHDR+CsuQTEi3j6tW04XjjI+c//LAP1JkNpcip/F87Xw== X-Received: by 2002:a05:6000:1105:: with SMTP id z5mr20402828wrw.615.1639223236197; Sat, 11 Dec 2021 03:47:16 -0800 (PST) Received: from tpp.orcam.me.uk (tpp.orcam.me.uk. [2001:8b0:154:0:ea6a:64ff:fe24:f2fc]) by smtp.gmail.com with ESMTPSA id a3sm2112555wri.98.2021.12.11.03.47.15 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 11 Dec 2021 03:47:15 -0800 (PST) Date: Sat, 11 Dec 2021 11:47:14 +0000 (GMT) From: "Maciej W. Rozycki" To: gdb-patches@sourceware.org cc: Andrew Burgess Subject: [PATCH 2/6] Avoid redundant operations in `fortran_array_walker' In-Reply-To: Message-ID: References: User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 11 Dec 2021 11:47:18 -0000 Move inner dimension's element type determination outside the respective loops in `fortran_array_walker'. The operation is exactly the same with each iteration, so there is no point in redoing it for each element and while a smart compiler might be able to move it outside the loop it is regardless a bad coding style. No functional change. --- gdb/f-array-walker.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) gdb-fortran-array-walker-walk-type.diff Index: src/gdb/f-array-walker.h =================================================================== --- src.orig/gdb/f-array-walker.h +++ src/gdb/f-array-walker.h @@ -208,6 +208,8 @@ class fortran_array_walker if (nss != m_ndimensions) { + struct type *subarray_type = TYPE_TARGET_TYPE (check_typedef (type)); + /* For dimensions other than the inner most, walk each element and recurse while peeling off one more dimension of the array. */ for (LONGEST i = lowerbound; @@ -218,13 +220,13 @@ class fortran_array_walker LONGEST new_offset = offset + calc.index_offset (i); /* Now print the lower dimension. */ - struct type *subarray_type - = TYPE_TARGET_TYPE (check_typedef (type)); walk_1 (nss + 1, subarray_type, new_offset, (i == upperbound)); } } else { + struct type *elt_type = check_typedef (TYPE_TARGET_TYPE (type)); + /* For the inner most dimension of the array, process each element within this dimension. */ for (LONGEST i = lowerbound; @@ -233,7 +235,6 @@ class fortran_array_walker { LONGEST elt_off = offset + calc.index_offset (i); - struct type *elt_type = check_typedef (TYPE_TARGET_TYPE (type)); if (is_dynamic_type (elt_type)) { CORE_ADDR e_address = m_address + elt_off;