common-subexpression-eliminator

Eliminate redundant computations across basic blocks in compiler optimization.

17|2|Updated Feb 16, 2026
One-click install
npx skills add https://github.com/rainoftime/pl-skills --skill common-subexpression-eliminator
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: common-subexpression-eliminator
Source: https://github.com/rainoftime/pl-skills/tree/main/common-subexpression-eliminator
Command: npx skills add https://github.com/rainoftime/pl-skills --skill common-subexpression-eliminator

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires ssa-constructor, and includes references (resource) and scripts (resource) components.

What problem does it solve?

This Skill addresses the inefficiency in code caused by repeated calculations of the same expression, leading to performance bottlenecks.

Core Features & Use Cases

  • Redundancy Identification: Detects identical subexpressions within code.
  • Value Reuse: Replaces duplicate computations with a single computed value.
  • Use Case: When building an optimizing compiler, this skill can be integrated to significantly speed up program execution by ensuring that expensive calculations are performed only once.

Quick Start

Use the common-subexpression-eliminator skill to optimize the provided C++ code snippet for common subexpressions.

Frequently Asked Questions about common-subexpression-eliminator

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How does common subexpression elimination improve code performance?

Global common subexpression elimination requires SSA construction to map data flow across basic blocks. Integrating static analysis frameworks like SSA enables effective redundancy identification and value reuse throughout the program's control flow graph.

How do I eliminate redundant computations across basic blocks in C++ code?

You can eliminate redundant computations by applying common subexpression elimination to your C++ code snippets. The optimization detects identical subexpressions, reuses the computed value, and removes the duplicate instructions across basic blocks.

Does common subexpression elimination handle memory aliasing and side effects?

Common subexpression elimination handles memory aliasing conservatively and considers side effects during analysis. This conservative approach ensures that expressions are only eliminated when it is safe to reuse values without altering program semantics.

What are the limitations of common subexpression elimination in compiler optimization?

Limitations of common subexpression elimination include its dependency on SSA construction for global analysis and its conservative handling of memory aliasing. It cannot safely optimize redundant expressions when side effects or ambiguous memory references prevent value reuse.