# US 11,442,712 B2 · Leveraging unspecified order of evaluation for compiler-based program optimization

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

- Number: US 11,442,712 B2
- Document ID: US11442712B2
- Status: Granted
- Kind: B2
- Application number: 17/344,375
- Filed: 2021-06-10
- Published: 2021-12-16
- Granted: 2022-09-13
- Earliest claimed: 2020-06-11
- Assignees: Indian Institute of Technology Delhi
- Applicants: Indian Institute of Technology Delhi
- Inventors: Sorav Bansal; Ankush Phulia; Vaibhav Bhagee
- Web page: https://patentgrep.com/patent/US11442712B2

## CPC

- G06F 8/443: {Optimisation}
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

A method, apparatus and system required to realize an optimization opportunity are disclosed. If an expression involves unsequenced evaluations involving side-effects and optionally references, then the expression is translated into optimized code that may involve optimized register usage, or optimized use of the underlying vectorization hardware. An alias-analysis logic is able to identify must-not-alias relationships through such expression tree structures. These must-not-alias relationships are helpful not just in optimizing the performance of that particular expression (from which these must-not-alias relationships were derived) but also in the performance of any other surrounding program statements that access the state elements participating in these must-not-alias relationships. More specifically, if the order of evaluation is unspecified and the sub expressions generate side effects, then must-not-alias relationships are inferred between expressions which can be used while optimizing surrounding code, such as the instructions following this expression with unsequenced evaluation.

## Claims

### Claim 1

A method of compiler-operation in a computing system comprising:
converting a source code into an abstract syntax tree (AST):
identifying expressions involving unsequenced evaluations that include side-effects based on a traversal of the AST to thereby identify must-not-alias relationships;
encoding the identified must-not-alias relationships with corresponding expressions into one or more language-independent intermediate representation (IR) through a custom intrinsic function call to thereby result in a non-optimized IR representation;
executing optimization passes on the non-optimized IR to generate an optimized IR based on at least one of:
extract an indication about must not alias relationships not recommended for aliasing, said indication received as a response from one or more encoded must not alias relationships through said custom intrinsic function call;
detect the must not alias relationships not recommended for aliasing based on the response and ensuring that the custom intrinsic function call does not interfere with the optimization passes;
and
removing the custom intrinsic function call that was used for encoding must-not-alias relationships from the optimized IR before assembly-code generation and thereby generating an assembly code.

### Claim 2 (depends on 1)

The method as claimed in claim 1, wherein said identifying comprises identifying expressions with potentially unsequenced evaluations that include side-effects through a bottom-up traversal of the AST.

### Claim 3 (depends on 2)

The method as claimed in claim 2, wherein the must-not-alias relationships are derived from said expressions involving unsequenced evaluations that include side effects.

### Claim 4 (depends on 1)

The method as claimed in claim 1, wherein the encoding comprises applying a custom intrinsic function call in Low Level Virtual Machine (LLVM) IR to encode the must-not-alias relationships.

### Claim 5 (depends on 4)

The method as claimed in claim 4, wherein the encoding comprises wrapping variable within the custom intrinsic function into metadata nodes for depiction as auxiliary information to a Low Level Virtual Machine (LLVM) optimization engine.

### Claim 6 (depends on 1)

The method as claimed in claim 1, wherein the non-optimized IR representation comprises the must-not-alias relationships inline.

### Claim 7 (depends on 1)

The method as claimed in claim 1, wherein the execution of the optimization passes on the non-optimized IR comprises querying by a compiler.

### Claim 8 (depends on 1)

The method as claimed in claim 1, wherein the execution of the optimization passes on the non-optimized IR comprises receiving a response in response to the queries by the compiler, the response including at least one of:
MAY-ALIAS and MUST-NOT-ALIAS.

### Claim 9

A computing system comprising:
a memory;
a processor to execute instructions stored within the memory and configured for:
converting a source code into an abstract syntax tree (AST):
identifying expressions involving unsequenced evaluations that include side-effects based on a traversal of the AST to thereby identify at least one must-not-alias relationship;
encoding the identified must not alias relationships with corresponding expressions into one or more language-independent intermediate representation (IR) based on a custom intrinsic function call to thereby result in a non-optimized IR representation;
executing an optimization pass in respect of the non-optimized IR to generate an optimized IR based on at least one of:
extract an indication about must-not-alias relationships, said indication received as a response from one or more encoded must not alias relationships through said custom intrinsic function call; and
detect the must-not-alias relationships not recommended for aliasing based on the response and ensuring that the custom intrinsic function call does not interfere with the optimization pass;
and
removing the custom intrinsic function call that was used for encoding must not alias relationships from the optimized IR before assembly-code generation and thereby generating an assembly code.
