]> git.ipfire.org Git - thirdparty/gcc.git/commit
genoutput: Accelerate the place_operands function.
authorXianmiao Qu <cooper.qu@linux.alibaba.com>
Wed, 22 May 2024 07:25:16 +0000 (15:25 +0800)
committerXianmiao Qu <cooper.qu@linux.alibaba.com>
Wed, 14 Aug 2024 06:01:05 +0000 (14:01 +0800)
commitca7936f7764116a39d785bb087584805072a3461
tree6e374c0c4d1c71cc07f8f6e784b32ea8408e4d33
parente4f9a871c8416f7363100cbcbcb5e72a381d6293
genoutput: Accelerate the place_operands function.

With the increase in the number of modes and patterns for some
backend architectures, the place_operands function becomes a
bottleneck int the speed of genoutput, and may even become a
bottleneck int the overall speed of building the GCC project.
This patch aims to accelerate the place_operands function,
the optimizations it includes are:
1. Use a hash table to store operand information,
   improving the lookup time for the first operand.
2. Move mode comparison to the beginning to avoid the scenarios of most strcmp.

I tested the speed improvements for the following backends,
Improvement Ratio
x86_64 197.9%
aarch64 954.5%
riscv 2578.6%
If the build machine is slow, then this improvement can save a lot of time.

I tested the genoutput output for x86_64/aarch64/riscv backends,
and there was no difference compared to before the optimization,
so this shouldn't introduce any functional issues.

gcc/
* genoutput.cc (struct operand_data): Add member 'eq_next' to
point to the next member with the same hash value in the
hash table.
(compare_operands): Move the comparison of the mode to the very
beginning to accelerate the comparison of the two operands.
(struct operand_data_hasher): New, a class that takes into account
the necessary elements for comparing the equality of two operands
in its hash value.
(operand_data_hasher::hash): New.
(operand_data_hasher::equal): New.
(operand_datas): New, hash table of konwn pattern operands.
(place_operands): Use a hash table instead of traversing the array
to find the same operand.
(main): Add initialization of the hash table 'operand_datas'.
gcc/genoutput.cc