llvm-project
06b82d1a - [Hexagon] Fix O(N^2) compile-time regression in HexagonOptAddrMode (#189531)

Commit
27 days ago
[Hexagon] Fix O(N^2) compile-time regression in HexagonOptAddrMode (#189531) In HexagonOptAddrMode::processAddUses, isSafeToExtLR was called inside the loop over UNodeList with loop-invariant arguments. isSafeToExtLR iterates over UNodeList, so the total work was O(N^2) in the number of uses. The arguments (AddSN, AddMI, BaseReg, UNodeList) do not change across iterations. Move the call to after the loop; the function returns the same value regardless of which iteration calls it, and the complexity drops to O(N). Background ---------- Commit 8c0483bba2d2 ("RegisterCoalescer: Fix assert on remat to copy-to-physreg with subregs") introduced register coalescer rematerialization changes that produce additional uses of A2_addi instructions on the Hexagon backend, inflating UNodeList. This exposed the pre-existing O(N^2) behavior in processAddUses. Measurements ------------ Input: rkvdec-vdpu383-h264.i (Hexagon kernel driver, -O2) Tool: hexagon-linux-musl-clang (clang-20) Scenario | HexagonOptAddrMode | Total --------------------------------------|-------------------|--------- Before blamed commit (baseline) | 1.35 s | ~195 s After blamed commit, without fix | 221,845 s | >61 h After blamed commit, with fix | 52.16 s | ~225 s Fixes: https://github.com/llvm/llvm-project/issues/178535
Author
Parents
Loading