[all-commits] [llvm/llvm-project] e49aac: [CycleInfo] Identify cycles with a single-pass DFS...

Fangrui Song via All-commits all-commits at lists.llvm.org
Mon Jul 20 18:34:47 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: e49aac8ff793d782e8b8a000077fb39b37629090
      https://github.com/llvm/llvm-project/commit/e49aac8ff793d782e8b8a000077fb39b37629090
  Author: Fangrui Song <i at maskray.me>
  Date:   2026-07-20 (Mon, 20 Jul 2026)

  Changed paths:
    M llvm/include/llvm/ADT/GenericCycleImpl.h
    M llvm/include/llvm/ADT/GenericCycleInfo.h
    M llvm/test/Analysis/CycleInfo/basic.ll
    M llvm/test/CodeGen/X86/cycle-info.mir

  Log Message:
  -----------
  [CycleInfo] Identify cycles with a single-pass DFS algorithm (#210491)

Replace the Havlak-Tarjan construction in GenericCycleInfoCompute, a DFS
followed by a reverse-preorder scan, with the single-pass algorithm of
Wei, Mao, Zou and Chen, "A New Algorithm for Identifying Loops in
Decompilation" (SAS 2007). One depth-first traversal tags every block
with its innermost loop header on the fly; tagLoopHeader weaves the
per-block header chains, replacing UNION-FIND.

The flat forest is reconstructed from the tags, dropping the temporary
cycle objects and the per-block worklist passes. An edge re-entering an
already-closed cycle records non-header entries, so entries need no
predecessor scan.

The cycle sets, headers, reducibility and nesting are identical for the
given DFS order, cross-checked against the old construction on random
reducible and irreducible CFGs. Two implementation-defined orders change
(with minor test churn): sibling cycles are laid out in decreasing
header preorder, and non-header entries in block preorder.

Construction cost (51x require+invalidate of <cycles> minus a 1x run,
median of interleaved rounds, x86-64): sqlite3.bc executes 27% fewer
instructions and 37% fewer cycles; a 1500-deep loop nest executes 50%
fewer instructions and 47% fewer cycles.

Aided by Claude Fable 5



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