Skip to content

LATX: extend EFLAGS reduction across TU calls and native patterns - #431

Draft
LaurenIsACoder wants to merge 7 commits into
lat-opensource:masterfrom
LaurenIsACoder:lauren/spec2000-eflags-tu-pattern
Draft

LATX: extend EFLAGS reduction across TU calls and native patterns#431
LaurenIsACoder wants to merge 7 commits into
lat-opensource:masterfrom
LaurenIsACoder:lauren/spec2000-eflags-tu-pattern

Conversation

@LaurenIsACoder

Copy link
Copy Markdown
Contributor

Summary

  • analyze EFLAGS requirements through bounded, analysis-only direct-call callee graphs and normal near returns
  • propagate the resulting direct-call liveness through the full TU fixed point, including predecessor TBs
  • let flag reduction consume native pattern metadata for CMP, TEST, BT, SUB, SHR, AND, floating-point Jcc, SETcc, CMOVcc, SBB, and NEG patterns
  • keep indirect edges, missing successors, cross-page callees, locked fallbacks, zero-count shifts, and shared RET code conservative

Design

LATX_EFLAGS_CROSS=0 keeps the existing behavior and LATX_EFLAGS_CROSS=1 enables the direct-call analysis. Callee decoding is bounded and analysis-only: temporary TBs do not enter the execution TU, HBR input, AOT TB set, thunk table, or translation metrics.

The direct-call model assumes the normal ABI discipline that a near RET returns through the slot created by its matching direct CALL. Unknown and indirect control flow still requires all flags. Cross-page callees are intentionally excluded until AOT/SMC can record caller-to-callee page invalidation dependencies.

Pattern discovery runs before flag reduction. A consumer removes only the architectural EFLAGS reads replaced by its native translation; later consumers still preserve the corresponding producer flags. Locked memory operations and masked-zero shifts retain their ordinary EFLAGS paths.

Validation

  • rebased on origin/master at d58864a036f
  • LoongArch release x86_64 build: PASS
  • LoongArch i386 build: PASS
  • 54 focused native-pattern EFLAGS cases: PASS
  • direct-call cross-boundary modes 0 and 1, cold and hot AOT: PASS
  • SPEC CPU2000 integer train, cold AOT generation: 12/12 PASS
  • SPEC CPU2000 integer train, hot AOT execution with cache mapping verified: 12/12 PASS
  • 12 SPEC integer AOT files reduced by 194,760 bytes (0.599%) versus the prior pattern candidate

Runtime movement was sensitive to AOT code layout in individual benchmarks, so this PR claims the verified EFLAGS/code-size reduction and leaves layout tuning to a separate follow-up.

Signed-off-by: Hanlu Li <heuleehanlu@gmail.com>
Signed-off-by: Hanlu Li <heuleehanlu@gmail.com>
Signed-off-by: Hanlu Li <heuleehanlu@gmail.com>
Signed-off-by: Hanlu Li <heuleehanlu@gmail.com>
Signed-off-by: Hanlu Li <heuleehanlu@gmail.com>
Signed-off-by: Hanlu Li <heuleehanlu@gmail.com>
Signed-off-by: Hanlu Li <heuleehanlu@gmail.com>
@LaurenIsACoder
LaurenIsACoder force-pushed the lauren/spec2000-eflags-tu-pattern branch from 165d9da to 10151ef Compare August 27, 2026 12:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant