Browse Prior Art Database

# Algorithm for Compiling Compound Logical Expressions in Optimizing Compilers

IP.com Disclosure Number: IPCOM000084329D
Original Publication Date: 1975-Oct-01
Included in the Prior Art Database: 2005-Mar-02
Document File: 2 page(s) / 13K

IBM

## Related People

Seaman, RP: AUTHOR

## Abstract

An algorithm is described for optimizing the compilation of compound logical expressions, when the component variables are all bits or patterns of bits in the same byte. The optimization makes use of two TEST UNDER MASK or a COMPARE BITS UNDER MASK instruction if that is available on the machine being used.

This text was extracted from a PDF file.
This is the abbreviated version, containing approximately 55% of the total text.

Page 1 of 2

Algorithm for Compiling Compound Logical Expressions in Optimizing Compilers

An algorithm is described for optimizing the compilation of compound logical expressions, when the component variables are all bits or patterns of bits in the same byte. The optimization makes use of two TEST UNDER MASK or a COMPARE BITS UNDER MASK instruction if that is available on the machine being used.

Apply the following rules repetitively to the logical expression:-

1. Where an operator is OR (|), see if either operand is the comparison of a bit variable (or substring) with a constant. If this is the case, make the operand a comparison involving the = operator if this is possible. e.g., transform; B = `1'B into B7 = `0'B

X < `1'B into X7 = `1'B, etc.

leave; Z = `101'B as is,

K = `11'B as is.

2. If both operands of the | operator are now comparisons involving the 7 = operator, and if each comparison is the comparison of a bit variable or substring with a constant, and if both bit variables or substrings are parts of the same byte, then replace the | operation with the combined or function cor (A, M1, M2) where:

A - byte address of the byte containing both operands.

M1 - a string of 8 bits corresponding to the bits of A and containing 1's where there is a 1 in either constant, and 0's elsewhere (the 1's mask'').

M2 - a string of 8 bits corresponding to the bits of A and containing 1's where there is a 0 in either constant, and 0's elsewhere (the 0's mask'').

The cor function returns true if A contains a 1 in any of the positions occupied by a 1 in the 0's mask, or if A contains a 0 in any of the positions occupied by a 1 in the 1's mask.

3. If one operand of | is a cor function, and the other operand is another cor function, or a comparison involving the 7 = operator between a bit variable or substring and a constant, see if the variables involved share the same byte. If they do, the | operation can be replaced by...