Boolean Expression Reordering for Short-Circuit Optimization

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

In programming languages that support short-circuit evaluation of Boolean expressions, the order of subexpressions significantly impacts execution time, and there is a need for an automated process to optimize these expressions to reduce expected execution time.

Innovation Solution

The optimization process involves profiling Boolean expressions using test vectors to determine condition probabilities, reordering them to maximize short-circuit termination and minimize execution time, and applying Boolean algebra transformations to generate logically equivalent expressions with lower costs.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Loss of time

If the order of subexpressions in Boolean expressions is optimized to maximize short-circuit evaluation, then the expected execution time is reduced, but the complexity of the optimization process increases

Engineering Contradiction:
Improveexpected execution timeVSAvoidoptimization process complexity
Core Design Contradiction:
Loss of timeVSDevice complexity

Solution Approach 1:

The system changes the order of subexpressions in Boolean expressions based on statistical execution time information. By reordering subexpressions to place those with higher probability of causing short-circuit evaluation first, the expected execution time is reduced. The optimization process profiles execution times, determines optimal ordering, and reorders subexpressions accordingly.

Inventive Principle:
Principle #35Parameter changes

Solution Approach 2:

The system uses feedback from profiling execution times of Boolean expressions to determine optimal reordering. Execution time data is collected, statistical information is derived, and this information feeds back into the reordering process to optimize future evaluations. The feedback loop continues to refine the ordering based on observed execution characteristics.

Inventive Principle:
Principle #23Feedback

2Productivity

If Boolean expressions are reordered to increase short-circuit evaluation probability, then execution efficiency improves, but the difficulty of automated optimization increases

Engineering Contradiction:
Improveexecution efficiencyVSAvoidautomated optimization difficulty
Core Design Contradiction:
ProductivityVSDifficulty of detecting and measuring

Solution Approach 1:

The system replaces manual analysis of Boolean expressions with automated profiling and statistical analysis. Instead of requiring human experts to manually optimize expressions, the system automatically measures execution times, derives statistical information, and performs reordering through computational algorithms, thereby reducing the difficulty of automated optimization.

Inventive Principle:
Principle #28Mechanics substitution (Replace mechanical system)

Solution Approach 2:

The optimization system serves itself by automatically profiling its own performance characteristics. The system profiles execution times of Boolean expressions, derives statistical information about their behavior, and uses this self-generated information to perform automated reordering, eliminating the need for external manual optimization expertise.

Inventive Principle:
Principle #25Self-service

3Reliability

If all subexpressions are evaluated to ensure complete Boolean evaluation, then evaluation accuracy is maintained, but execution time increases

Engineering Contradiction:
Improveevaluation accuracyVSAvoidexecution time
Core Design Contradiction:
ReliabilityVSLoss of time

Solution Approach 1:

The system performs preliminary evaluation of subexpressions based on statistical probability information. By determining which subexpressions are most likely to cause short-circuit evaluation and placing them first in the evaluation order, the system prepares for early termination before all subexpressions must be evaluated, thereby reducing execution time while maintaining accuracy through proper short-circuit logic implementation.

Inventive Principle:
Principle #10Preliminary action

Data Source

PatentUS7818720B2System and method for control logic code reordering based on stochastic execution time information
Publication Date: 2010.10.19 NXP USA INC
  • US7818720B2 patent drawing
  • US7818720B2 patent drawing
  • US7818720B2 patent drawing

AI summary

A method, computer program product, and data processing system for performing automated optimization of a control processing flow containing Boolean conditional expressions is disclosed. Each conditional expression is profiled using a representative set of test vectors to determine the probabilities of individual conditions and combinations of conditions in the expression. Next, the expression is restructured or reordered, including selective computation of subexpressions, based on the probability information, so as to maximize the probability of a short-circuit termination of evaluation of the expression and/or to minimize the statistical execution time of the expression. This process is performed for all Boolean conditional expressions related to the control processing flow.