CHLOE: Loop Transformation over Fully Homomorphic Encryption via Multi-Level Vectorization and Control-Path Reduction

Song Bian, Zian Zhao, Ruiyu Shen, Zhou Zhang, Ran Mao, Dawei Li, Yizhong Liu, Masaki Waga, Kohei Suenaga, Zhenyu Guan, Jiafeng Hua, Yier Jin, Jianwei Liu

Abstract

Fully Homomorphic Encryption (FHE) enables computation on encrypted data but suffers from significant performance overheads, particularly in programs containing complex or "oblivious" loops. We present CHLOE, a compiler framework that optimizes loop execution through intelligent segmentation, multi-level vectorization, and control-path reduction. By classifying loops and applying closed-form mathematical analysis, CHLOE achieves speedups ranging from $3.2\times$ to $10^5\times$ over state-of-the-art FHE compilers.

Introduction

Fully Homomorphic Encryption (FHE) is often described as the "holy grail" of cryptography, allowing for secure computation without data decryption. Despite its promise, FHE remains orders of magnitude slower than plaintext computing. A primary bottleneck is the handling of loop structures. Standard loops introduce branching complexity, requiring the execution of all paths via masking, and "oblivious loops"—where termination conditions are encrypted—often necessitate inefficient full unrolling.

Methodology: The CHLOE Framework

CHLOE addresses these challenges through a multi-level compiler architecture built on the MLIR framework. The system categorizes loops into Transparent Loops (with public conditions) and Oblivious Loops (with encrypted conditions).

The CHLOE compiler workflow, illustrating front-end, loop optimization, and back-end passes.

The core optimization strategy involves several key components:

  1. Loop Segmentation: Breaking complex loop bodies into independent arithmetic (additions/multiplications) and non-arithmetic (comparisons) segments. This allows the compiler to apply specialized optimizations to each part.
  2. Multi-Level Vectorization: Utilizing SIMD (Single Instruction, Multiple Data) capabilities of schemes like CKKS and BFV. CHLOE employs SIMD-PBS (Programmable Bootstrapping) to amortize the cost of expensive bootstrapping operations across multiple data points.
  3. Control-Path Reduction: For oblivious loops following known mathematical recurrences (e.g., the Fibonacci sequence), CHLOE uses Closed-Form Analysis to replace iterative loops with single analytical expressions.
  4. Cost-Aware Type Alignment: A cost model guides the selection of data representations (e.g., switching between LWE and RLWE ciphertexts) to minimize computational noise and total latency.

Key Insights and Comparative Analysis

CHLOE's performance stems from its ability to avoid unnecessary unrolling and its "cross-scheme" nature. Unlike many compilers restricted to a single FHE scheme, CHLOE acts as a hybrid compiler, dynamically selecting the optimal tool (CKKS, BFV, or TFHE) for different program segments.

Comparison of CHLOE against state-of-the-art FHE compilers across various features and loop support.

As shown in the comparative analysis, CHLOE is the only general-purpose compiler supporting a hybrid of BFV, TFHE, and CKKS with integrated scheme switching and advanced loop optimizations like segmentation and distribution.

Evaluation and Results

The framework was evaluated against real-world benchmarks including database querying, SVM classification, and iterative image segmentation.

  • Transparent Loops: CHLOE achieved speedups of $3.2\times$ to $54\times$ over HEIR and Google's Transpiler. Its vectorization strategy allowed execution time to remain nearly flat as data size increased, whereas other compilers saw linear increases in latency.
  • Oblivious Loops: In cases where closed-form solutions were applicable, CHLOE outperformed human-assisted unrolling by up to $10^5\times$.
  • Efficiency: In image segmentation tasks, CHLOE demonstrated a $172\times$ performance improvement over the nearest competitor.

Conclusion and Limitations

While CHLOE significantly advances FHE compiler technology, it introduces higher memory overhead due to the requirements of SIMD-PBS. Furthermore, performance gains are limited in loops with immediate data dependencies between arithmetic and non-arithmetic operations within the same iteration. Future work will focus on optimizing ciphertext conversion to handle complex data reuse scenarios more efficiently.

Summary updated

BibTeX
@inproceedings{bian2025chloe,
  author = {Song Bian and Zian Zhao and Ruiyu Shen and Zhou Zhang and Ran Mao and Dawei Li and Yizhong Liu and Masaki Waga and Kohei Suenaga and Zhenyu Guan and Jiafeng Hua and Yier Jin and Jianwei Liu},
  title = {{CHLOE: Loop Transformation over Fully Homomorphic Encryption via Multi-Level Vectorization and Control-Path Reduction}},
  booktitle = {SP},
  year = {2025},
  url = {https://openreview.net/forum?id=9iPxVyotC7},
}
Figure