genattrtab: Optimize attribute removal by linking entries
Speeds up attribute definition generation by allowing direct removal of instruction entries.
This commit optimizes the genattrtab tool by modifying how instruction entries are removed from attribute values. By adding a ‘prev’ pointer to insn_ent, entries can now be removed in constant time, avoiding a quadratic cost that previously dominated processing for large attribute lists on targets like AArch64 and RISC-V. This change significantly reduces genattrtab’s execution time.
In Details
In genattrtab.cc, the remove_insn_ent function previously incurred quadratic cost by searching for the predecessor of an entry to remove. This commit introduces a prev pointer in the insn_ent struct, allowing direct removal in O(1) time. This optimization is crucial for backends with extensive instruction attribute lists, such as AArch64 and RISC-V, where this search was a performance bottleneck.
- genattrtab
- A GCC internal tool that generates attribute tables used by various backends for instruction selection and scheduling.
- insn
- An 'instruction' in the context of a target architecture's assembly language, often represented internally by GCC.