Patent ID: 8370817

Claim:
A method, in a data processing system comprising a processor, for performing a scalar operation, comprising: identifying, by the processor, the scalar operation in source code; generating, by the processor, an expression tree for the scalar operation, wherein the expression tree has leaf nodes corresponding to scalar operands of the scalar operation; determining, by the processor, an alignment of the scalar operands in respective registers that store the scalar operands such that all of the scalar operands of the scalar operation are aligned with each other; propagating, by the processor, the alignment of the scalar operands up the expression tree; annotating, by the processor, the expression tree based on the propagation of the alignment of the scalar operands up the expression tree, wherein annotating the expression tree based on the propagation of the alignment comprises annotating selected nodes of the expression tree to identify shift operations to be performed with respect to the selected nodes, wherein the shift operations are determined with reference to all other shift operations within a given region of the source code in which all of the shift operations are considered by means of an optimization process which finds a minimum number of the shift operations within the given region of the source code such that all of the scalar operands of the scalar operation are aligned with each other, wherein the optimization process determines common sub-expressions of scalar operations, and wherein the shift operations are selected such that for a number of instances of the common sub-expressions a same shift operation is utilized; and generating, by the processor, executable code for the scalar operation based on the expression tree and the alignment of all of the scalar operands, wherein generating the executable code for the scalar operation includes inserting, by the processor, shift instructions into the executable code based on the alignment of all of the scalar operands.