Skip to main content
QUICK REVIEW

[Paper Review] A Differential Fuzzing-Based Evaluation of Functional Equivalence in LLM-Generated Code Refactorings

Simantika Dristi, Matthew B. Dwyer|arXiv (Cornell University)|Feb 17, 2026
Software Testing and Debugging TechniquesComputer Science0 citations
TL;DR

The paper uses differential fuzzing (Eq@DFuzz) to assess functional equivalence of LLM-generated code refactorings across six models, three datasets, and two refactoring types, revealing substantial non-equivalence and gaps in test-suite-based evaluation.

ABSTRACT

With the rapid adoption of large language models (LLMs) in automated code refactoring, assessing and ensuring functional equivalence between LLM-generated refactoring and the original implementation becomes critical. While prior work typically relies on predefined test cases to evaluate correctness, in this work, we leverage differential fuzzing to check functional equivalence in LLM-generated code refactorings. Unlike test-based evaluation, a differential fuzzing-based equivalence checker needs no predefined test cases and can explore a much larger input space by executing and comparing thousands of automatically generated test inputs. In a large-scale evaluation of six LLMs (CodeLlama, Codestral, StarChat2, Qwen-2.5, Olmo-3, and GPT-4o) across three datasets and two refactoring types, we find that LLMs show a non-trivial tendency to alter program semantics, producing 19-35% functionally non-equivalent refactorings. Our experiments further demonstrate that about 21% of these non-equivalent refactorings remain undetected by the existing test suites of the three evaluated datasets. Collectively, the findings of this study imply that reliance on existing tests might overestimate functional equivalence in LLM-generated code refactorings, which remain prone to semantic divergence.

Motivation & Objective

  • Motivate reliable evaluation of LLM-driven code refactoring beyond test-pass metrics.
  • Assess functional equivalence of refactorings produced by multiple LLMs on diverse datasets.
  • Show that traditional test suites may miss a substantial fraction of semantic divergences.

Proposed method

  • Use six LLMs (CodeLlama, Codestral, StarChat2, Qwen-2.5, Olmo-3, GPT-4o) to generate refactorings.
  • Apply two prompts (performance optimization and code simplification) to produce 4,368 refactorings across three datasets.
  • Evaluate functional equivalence with Eq@DFuzz, a differential fuzzing checker generating 1,000–2,000 test inputs per refactoring.
  • Compare Eq@DFuzz results to traditional test-suite correctness (Corr@Test).
  • Analyze equivalence across datasets (HumanEval, MBPP, APPS) and refactoring types (simplification, optimization).
  • Report non-equivalent refactorings and test-suite gaps.
Figure 1. Overview of our approach
Figure 1. Overview of our approach

Experimental results

Research questions

  • RQ1RQ1: What fraction of LLM-generated code refactorings are functionally equivalent to the original according to differential fuzzing?
  • RQ2RQ2: Do existing test suites reliably detect non-equivalence, or is there a gap relative to Eq@DFuzz?
  • RQ3RQ3: How do equivalence rates vary by dataset and refactoring type?
  • RQ4RQ4: Does refactoring complexity influence the likelihood of semantic divergence?

Key findings

  • LLMs produce a substantial fraction (19-35%) of non-equivalent refactorings across models, datasets, and refactoring types.
  • APPS dataset yields the highest non-equivalence (32.09%) compared with MBPP (25.33%) and HumanEval (22.10%).
  • Non-equivalence rates are similar between simplification and optimization (~26%).
  • Approximately 21% of non-equivalent refactorings pass all tests in existing suites ( Corr@Test = 1 ) but are non-equivalent under Eq@DFuzz.
  • Reliance on test suites may overestimate functional equivalence in LLM-generated refactorings.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.