Patent ID: 7966606

Claim:
A method comprising: receiving a select statement of a code segment in a compiler that executes on a processor, wherein the select statement corresponds to ((x & A) cond B) ? C : D; determining whether a plurality of compile-time constants are present in the select statement and a selected one of the plurality of compile-time constants is a single-bit value, and whether a pair of relational expressions including a value present in the select statement can be predetermined, including determining that the select statement can be transformed if A is a single bit constant, x is an integer, and C−D is a power of two, or that C−D is a string of logical one values and a first compile-time value (Y) is equal to a least significant bit of C−D and a second compile-time value (X) is equal to C−D+Y and that log 2 X−log 2 (Y) is a power of two, and otherwise determining that the select statement cannot be transformed; if the select statement can be transformed, selecting a first transformation or a second transformation based on compile-time evaluated values of at least some of the plurality of compile-time constants of the select statement; performing the selected transformation to obtain at least one new statement; replacing the select statement with the at least one new statement and storing the code segment including the at least one new statement in a storage.