Source Code Optimization using Equivalent Mutants
This work addresses code optimization for software developers, offering a novel but incremental method that leverages existing mutation testing concepts.
The paper tackles the problem of source code optimization by repurposing equivalent mutants—syntactically modified but functionally equivalent program versions—to enhance code while preserving behavior, and demonstrates that this approach can outperform traditional compiler optimizations in applicable cases.
A mutant is a program obtained by syntactically modifying a program's source code; an equivalent mutant is a mutant, which is functionally equivalent to the original program. Mutants are primarily used in \emph{mutation testing}, and when deriving a test suite, obtaining an equivalent mutant is considered to be highly negative, although these equivalent mutants could be used for other purposes. We present an approach that considers equivalent mutants valuable, and utilizes them for source code optimization. Source code optimization enhances a program's source code preserving its behavior. We showcase a procedure to achieve source code optimization based on equivalent mutants and discuss proper mutation operators. Experimental evaluation with Java and C programs demonstrates the applicability of the proposed approach. An algorithmic approach for source code optimization using equivalent mutants is proposed. It is showcased that whenever applicable, the approach can outperform traditional compiler optimizations.