From: Andrew Carlotti <andrew.carlotti@arm.com>
To: gcc-patches@gcc.gnu.org
Cc: Richard Sandiford <richard.sandiford@arm.com>,
Richard Earnshaw <richard.earnshaw@arm.com>
Subject: [PATCH 2/5] aarch64: Don't use FEAT_MAX as array length
Date: Tue, 9 Apr 2024 14:25:17 +0100 [thread overview]
Message-ID: <4c366314-a9b8-e1ff-9d6c-dc4f11eca41c@e124511.cambridge.arm.com> (raw)
In-Reply-To: <33371799-7353-cd99-3f78-9abe31ad24ec@e124511.cambridge.arm.com>
There was an assumption in some places that the aarch64_fmv_feature_data
array contained FEAT_MAX elements. While this assumption held up till
now, it is safer and more flexible to use the array size directly.
gcc/ChangeLog:
* config/aarch64/aarch64.cc (compare_feature_masks):
Use ARRAY_SIZE to determine iteration bounds.
(aarch64_mangle_decl_assembler_name): Ditto.
diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc
index 1ea84c8bd7386e399f6ffa3a5e36408cf8831fc6..5de842fcc212c78beba1fa99639e79562d718579 100644
--- a/gcc/config/aarch64/aarch64.cc
+++ b/gcc/config/aarch64/aarch64.cc
@@ -19899,7 +19899,8 @@ compare_feature_masks (aarch64_fmv_feature_mask mask1,
auto diff_mask = mask1 ^ mask2;
if (diff_mask == 0ULL)
return 0;
- for (int i = FEAT_MAX - 1; i > 0; i--)
+ static const int num_features = ARRAY_SIZE (aarch64_fmv_feature_data);
+ for (int i = num_features - 1; i > 0; i--)
{
auto bit_mask = aarch64_fmv_feature_data[i].feature_mask;
if (diff_mask & bit_mask)
@@ -19982,7 +19983,8 @@ aarch64_mangle_decl_assembler_name (tree decl, tree id)
name += "._";
- for (int i = 0; i < FEAT_MAX; i++)
+ static const int num_features = ARRAY_SIZE (aarch64_fmv_feature_data);
+ for (int i = 0; i < num_features; i++)
{
if (feature_mask & aarch64_fmv_feature_data[i].feature_mask)
{
next prev parent reply other threads:[~2024-04-09 13:25 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-09 13:24 [PATCH 0/5] aarch64: FMV feature list fixes Andrew Carlotti
2024-04-09 13:24 ` [PATCH 1/5] aarch64: Reorder FMV feature priorities Andrew Carlotti
2024-04-09 13:25 ` Andrew Carlotti [this message]
2024-04-09 15:33 ` [PATCH 2/5] aarch64: Don't use FEAT_MAX as array length Richard Sandiford
2024-04-10 12:33 ` Andrew Carlotti
2024-04-09 13:26 ` [PATCH 3/5] aarch64: Fix typo and make rdma/rdm alias for FMV Andrew Carlotti
2024-04-09 13:26 ` [PATCH 4/5] aarch64: Remove unsupported FMV features Andrew Carlotti
2024-04-09 13:27 ` [PATCH 5/5] aarch64: Combine some " Andrew Carlotti
2024-04-09 15:43 ` [PATCH 0/5] aarch64: FMV feature list fixes Richard Sandiford
2024-04-10 11:10 ` Andrew Carlotti
2024-04-10 16:42 ` Richard Sandiford
2024-04-10 17:11 ` Andrew Carlotti
2024-04-10 18:51 ` Richard Sandiford
2024-04-10 19:03 ` Andrew Carlotti
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4c366314-a9b8-e1ff-9d6c-dc4f11eca41c@e124511.cambridge.arm.com \
--to=andrew.carlotti@arm.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=richard.earnshaw@arm.com \
--cc=richard.sandiford@arm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).