[all-commits] [llvm/llvm-project] c2aea9: [Hexagon] Fix O(N^2) compile-time regression in H...

Abinaya Saravanan via All-commits all-commits at lists.llvm.org
Fri Apr 17 02:40:51 PDT 2026


  Branch: refs/heads/release/22.x
  Home:   https://github.com/llvm/llvm-project
  Commit: c2aea991dba1ddf23dada53653ce06ce605f2d93
      https://github.com/llvm/llvm-project/commit/c2aea991dba1ddf23dada53653ce06ce605f2d93
  Author: Abinaya Saravanan <asaravan at qti.qualcomm.com>
  Date:   2026-04-17 (Fri, 17 Apr 2026)

  Changed paths:
    M llvm/lib/Target/Hexagon/HexagonOptAddrMode.cpp
    A llvm/test/CodeGen/Hexagon/opt-addr-mode-large-unodelist.ll

  Log Message:
  -----------
  [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

(cherry picked from commit 06b82d1a18791bc966e9b18ac34f63c888d10723)



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list