[Paper Review] Idempotent Slices with Applications to Code-Size Reduction
The paper formalizes idempotent backward slices in GSA form, provides a sound linear-time slice-identification algorithm, and demonstrates a slice-based code-size reduction approach (SBCR) that can merge non-contiguous instructions, achieving up to significant reductions in LLVM binaries.
Given a value computed within a program, an idempotent backward slice with respect to this value is a maximal subprogram that computes it. An informal notion of an idempotent slice has previously been used by Guimaraes et al. to transform eager into strict evaluation in the LLVM intermediate representation. However, that algorithm is insufficient to be correctly applied to general control-flow graphs. This paper addresses these omissions by formalizing the notion of idempotent backward slices and presenting a sound and efficient algorithm for extracting them from programs in Gated Static Single Assignment (GSA) form. As an example of their practical use, the paper describes how identifying and extracting idempotent backward slices enables a sparse code-size reduction optimization; that is, one capable of merging non-contiguous sequences of instructions within the control-flow graph of a single function or across functions. Experiments with the LLVM test suite show that, in specific benchmarks, this new algorithm achieves code-size reductions up to -7.24% on programs highly optimized by the -Os sequence of passes from clang 17.
Motivation & Objective
- Formalize the notion of idempotent backward slices and identify gaps in prior approaches for general control-flow graphs.
- Develop a sound, efficient algorithm to extract idempotent backward slices from programs in GSA form.
- Demonstrate how idempotent slices enable a code-size reduction optimization by outlining and merging slices.
- Implement the slicing algorithm in LLVM and evaluate its effectiveness on the LLVM test suite.
Proposed method
- Convert SSA to GSA using the Tu and Padua gating-path algorithm to obtain explicit data-control dependencies.
- Traverse the GSA to identify idempotent backward slices with a loop- and function-aware stop condition.
- Outline identified slices into standalone functions with guarded interfaces and prove semantic soundness (Theorem 4.2).
- Merge identical/semantically equivalent slice functions using a two-phase duplicate elimination (structural hashing and canonical comparison).
- Apply a cost-model-based decision to outline versus keep slices in place (parameters I, P, C).
- Evaluate SBCR against baselines (FMSA and LLVM IROutliner) on the LLVM test-suite, focusing on code-size changes.

Experimental results
Research questions
- RQ1What are the ideal cost-model parameters for SBCR?
- RQ2How much code-size reduction can idempotent slice outlining achieve and how does it compare to previous work?
- RQ3What is the runtime and compilation overhead of slice outlining relative to prior techniques?
- RQ4What is the asymptotic behavior of the slice outlining algorithm?
- RQ5Is there a cumulative benefit when combining SBCR with other code-size reduction techniques?
Key findings
- Idempotent backward slices can be identified correctly from GSA form and do not require hammock structure or CSSA properties.
- Backward slicing runs in linear time with respect to the program’s CFG edges.
- SBCR can reduce .text size in LLVM binaries by up to 7.24% on a geometric mean across 2007 benchmarks when combined with -Os optimizations.
- SBCR discovers non-contiguous and cross-function slice opportunities not captured by prior methods like function merging by sequence alignment or LLVM IROutliner.
- The proposed approach is complementary to existing techniques and yields substantial reductions in specific benchmarks (e.g., AMGmk).
- A soundness guarantee is provided: the outlined slice preserves the original criterion value and program semantics within the slice’s loop.
![Figure 2 : (a) Program with a slice criterion: the instruction $s=s+1$ . (b) Dense slice, adapted from Blazy et al. [ 3 , Fig. 1] . (c) Program in Static Single-Assignment form. (d) Program in Gated Static Single-Assignment form. (e) Idempotent backward slice with respect to SSA variable $s_{3}$ . (](https://ar5iv.labs.arxiv.org/html/2603.09726/assets/x2.png)
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.