[all-commits] [llvm/llvm-project] 48f1a2: [LoopInfo] Derive Loop::contains(BlockT*) from the...
Fangrui Song via All-commits
all-commits at lists.llvm.org
Wed Jul 22 19:38:45 PDT 2026
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 48f1a20589b9b1da2ab211f8bf95e89ed5c10576
https://github.com/llvm/llvm-project/commit/48f1a20589b9b1da2ab211f8bf95e89ed5c10576
Author: Fangrui Song <i at maskray.me>
Date: 2026-07-22 (Wed, 22 Jul 2026)
Changed paths:
M llvm/docs/Frontend/PerformanceTips.md
M llvm/include/llvm/Support/GenericLoopInfo.h
M llvm/include/llvm/Support/GenericLoopInfoImpl.h
M llvm/lib/Transforms/Scalar/LoopSimplifyCFG.cpp
M llvm/lib/Transforms/Utils/FixIrreducible.cpp
Log Message:
-----------
[LoopInfo] Derive Loop::contains(BlockT*) from the block-to-loop map (#207613)
Each Loop stored its blocks twice: the Blocks vector and a DenseBlockSet
used only for O(1) contains(BlockT *). Block lists are inclusive, so building
LoopInfo inserted every block into that set once per enclosing loop --
an O(blocks * depth) cost.
Drop DenseBlockSet and answer contains(BlockT *) from the innermost loop
in LoopInfoBase's block-number-indexed map. This removes the per-build
set maintenance and shrinks sizeof(Loop) from 160 to 72 bytes. Each Loop
keeps a back-pointer to its LoopInfo for the lookup; contains() stays
total for a block from another function (e.g. a global's use).
Note: A pass restructuring the loop nest must not rely on
`contains(BlockT *)` while the block lists and the map are transiently
out of sync, and should scan getBlocks() instead (as FixIrreducible and
LoopSimplifyCFG do). LoopInfoBase::verify() checks the block lists
rather than contains() for the same reason.
Aided by Claude Opus 4.8
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