On December 7, the US Patent & Trademark Office published Apple’s patent application titled ‘Performing variable and/or Bitwise Shift Operation for a Shift Instruction that does not provide a Variable or Bitwise Shift option.’ Apple’s patent relates to enhancing instruction sets for microprocessors and in particular, refers to a double quadword target operation in the Intel SSE2 instruction set.
Apple’s Summary
Some embodiments present a method of performing a variable shift operation. This method can be used by a microprocessor that does not allow variable shift operation for certain operand sizes. The method simulates a shift instruction that shifts an operand by a shift count. The method identifies a first shift command and a second shift command. The method computes a mask value. The mask value depends on whether the shift count is less than half of the operand size or greater than or equal to half of the operand size. The method uses the mask value to cause one of the first shift command and the second shift command to produce no shift. In some embodiments, the method allows for the shift count to be specified in bytes or in bits.
Many applications require repeated moving of blocks of data from one memory location to other memory locations. Some embodiments provide a method of moving blocks of memory to or from addresses that are not aligned at any specific address location. Each move operation may require one or more shift operations with variable shift count. The move operations may also require bitwise shifting, i.e., shifting the operand a variable number of bit positions.
Intel’s SSE2 Instruction Set
Some embodiments of the invention simulate a shift operation that cannot perform a variable or bitwise shift, by utilizing smaller shift operations that allow variable or bitwise shift operations. In the examples below, the shift operation that cannot perform variable or bitwise shifting is a double quadword target operation in the Intel SSE2 instruction set. However, one of ordinary skill will realize that the invention is applicable to other shift operations that cannot perform variable or bitwise shifting.
In order to simulate a shift operation, a novel algorithm is presented that allows the shift count to be a variable as well as a constant and the shift count can be specified in bytes or bits. The algorithm does not require a branch operation to distinguish between a shift for less than half the length of the operand and a shift equal or grater than half the length of the operand. In the following examples, a `shift double quadword` left operation PSLLDQ of the instruction set of Intel SSE2 is used to illustrate how the invention performs variable or bitwise shifting on a double quadword basis.
One of ordinary skill will realize that the same method may be applied for shift right operation and for shifting in bits instead of bytes. The same method can also be applied to any other microprocessor instruction set that has the same limitations for a shift operation that only accepts a constant shift count or only shifts in bytes when other smaller shift operations without the limitations are available.
In Patent FIG. 4 Apple illustrates different steps of moving the quadword depicted in FIG. 2 into a register by utilizing the efficient `aligned quadword` loads operations followed by `double quadword` shift with variable shift operand followed by an OR operation.
Apple lists the inventors of this patent as being Hyeonkuk Jeong and Paul Chang.
NOTICE: MacNN presents only a brief summary of patents with associated graphic(s) for journalistic news purposes as each such patent application and/or grant is revealed by the U.S. Patent & Trade Office. Readers are cautioned that the full text of any patent applications and/or grants should be read in its entirety for further details.
Written and researched by Neo.










