Xianmiao Qu <cooper...@linux.alibaba.com> writes: > 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'.
LGTM. thanks, sam
signature.asc
Description: PGP signature