Skip to content
GitLab
Projects Groups Topics Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • C Compiler2026-NO_COMPILE_NO_LIFE
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributor statistics
    • Graph
    • Compare revisions
  • Issues 0
    • Issues 0
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 0
    • Merge requests 0
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Terraform modules
  • Monitor
    • Monitor
    • Metrics
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • NO_COMPILE_NO_LIFE
  • Compiler2026-NO_COMPILE_NO_LIFE
  • Merge requests
  • !1

Perf(opt):Loop-invariant code motion

  • Review changes

  • Download
  • Patches
  • Plain diff
Merged Kiven requested to merge feat/loop-invariant-code-motion into main May 09, 2026
  • Overview 0
  • Commits 4
  • Pipelines 0
  • Changes 7

概述

实现循环不变量外提(Loop-Invariant Code Motion, LICM)优化 pass。

将循环体内的不变量指令提升到循环前置块(preheader),减少重复计算。

实现细节

  • 构建循环树(自然循环识别,基于支配树 + 回边)
  • 安全性检查:纯指令(无副作用)且所有操作数均为循环不变量
  • 有 store 的循环中,load 仅在确认无别名 store 时才外提
  • 有函数调用的循环中,load 一律不外提
  • 外提后追加 CSE + DeadCodeDelete 清理冗余

性能结果

在 ARM64 原生容器上顺序跑3次,与 commit 12485ed 基线对比:

优化前 优化后(均值) 变化
总耗时(57个AC) 8.25 min 7.32 min -11.3%

主要收益:h-5(-37%)、crypto(-33%)、crc(-28%)、sort(-25%)、huffman(-22%)

详细数据见 test/loopInvariantCodeMotion.md。

正确性

57/60 AC,3个 WA(h-8-01/02/03)为预存在 bug,与本 pass 无关。

Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: feat/loop-invariant-code-motion