# US 2014/0007063 A1 · Strength reduction compiler optimizations for conditional operations

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 2014/0007063 A1
- Document ID: US20140007063A1
- Status: Published application
- Kind: A1
- Application number: 13/767,146
- Filed: 2013-02-14
- Published: 2014-01-02
- Earliest claimed: 2012-07-02
- Assignees: International Business Machines Corporation
- Applicants: International Business Machines Corporation
- Inventors: William J. Schmidt
- Web page: https://patentgrep.com/patent/US20140007063A1

## CPC

- G06F 8/4441: {Reducing the execution time required by the program code}
- G06F 8/37: {Compiler construction; Parser generation}
- G06F 8/41: Compilation
- G06F 8/433: {Dependency analysis; Data or control flow analysis}
- G06F 8/443: {Optimisation}
- G06F 9/30145: {Instruction analysis, e.g. decoding, instruction word fields}
- G06F 9/44: Arrangements for executing specific programs
- G06F 9/45516: {Runtime code conversion or optimisation}
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

An optimizing compiler includes a strength reduction mechanism that optimizes a computer program that includes conditional operations by analyzing the instructions in the computer program in a single pass, determining whether instruction substitution is profitable for original instructions in the code, and performing instruction substitution for one or more original instructions for which instruction substitution is deemed profitable, including conditional operations. The substituted instructions result in strength reduction in the computer program.

## Claims

### Claim at position 1

1-6. (canceled)

### Claim 7

A computer-implemented method executed by at least one processor for processing a plurality of instructions in a computer program, the method comprising the steps of:
analyzing the computer program in a single pass;
determining whether a conditional operation in the computer program could be improved by substituting at least one alternative instruction for at least one original instruction in the operation; and
when the conditional operation in the computer program could be improved, substituting the at least one alternative instruction for the at least one original instruction.

### Claim 8 (depends on 7)

The method of claim 7 wherein the step of analyzing the computer program in the single pass comprises the steps of:
constructing a control flow graph of the instructions in the computer program;
building a dominator tree corresponding to the control flow graph that indicates which blocks in the control flow graph dominate other blocks in the control flow graph; and
determining an order of analyzing the instructions in the control flow graph in the single pass based on the dominator tree.

### Claim 9 (depends on 8)

The method of claim 8 wherein the step of analyzing the computer program in the single pass further comprises the steps of:
constructing a candidate table of instructions in the computer program in an order determined by the dominator tree;
computing cost of each candidate in the candidate table; and
determining whether a selected candidate in the candidate table is profitable based on the computed cost.

### Claim 10 (depends on 9)

The method of claim 9 wherein, when the step of determining whether a selected candidate in the candidate table is profitable determines the cost of the selected candidate in the candidate table is profitable, performing the steps of:
inserting a temporary variable into the computer program; and
replacing at least one original instruction in the computer program with an alternative instruction that references the temporary variable.

### Claim 11 (depends on 10)

The method of claim 10 wherein, when the step of determining whether the cost of a selected candidate in the candidate table is profitable determines the cost of the selected candidate in the candidate table is profitable, further performing the step of removing at least one unneeded instruction from the computer program, wherein the instruction is unneeded due to the insertion of the temporary variable and the replacement of the at least one original instruction with the at least one alternative instruction.

### Claim 12 (depends on 7)

The method of claim 7 wherein the step of determining whether a conditional operation in the computer program could be improved comprises the steps of:
computing a cost of the at least one alternative instruction;
computing a cost of the at least one original instruction; and
when the cost of the at least one alternative instruction is less than the cost of the at least one original instruction, determining the conditional operation in the computer program could be improved.

### Claim at position 8

13-18. (canceled)

### Claim 19

A computer-implemented method executed by at least one processor for processing a plurality of instructions in a computer program, the method comprising the steps of:
generating a control flow graph of the computer program, the control flow graph comprising a plurality of basic blocks;
generating a dominator tree that represents which basic blocks in the control flow graph dominate other basic blocks in the control flow graph;
processing the instructions in the control flow graph in an order determined by the dominator tree to generate a candidate table of instructions with corresponding data;
computing cost of each candidate in the candidate table;
for each selected candidate in the candidate table, when the cost for the selected candidate indicates the selected candidate is profitable, performing the steps of:
substituting at least one alternative instruction for at least one original instruction in the computer program; and
removing at least one unneeded instruction from the computer program, wherein an instruction is unneeded due to the replacement of the at least one original instruction with the at least one alternative instruction.
