Name Strings

SPV_INTEL_ternary_bitwise_function

Contact

To report problems with this extension, please open a new issue at:

Contributors

  • Ben Ashbaugh, Intel

  • Victor Mustya, Intel

Notice

Copyright (c) 2025 Intel Corporation. All rights reserved.

Status

  • Complete

Version

Last Modified Date

2025-03-24

Revision

1

Dependencies

This extension is written against the SPIR-V Specification, Version 1.6, Revision 5.

This extension requires SPIR-V 1.0.

Overview

This extension adds an instruction to efficiently compute a bitwise function of three input operands. The bitwise function that is performed is described by a lookup table index. This instruction can be used to accelerate the bitwise operations used in cryptography, hash computation, and many other algorithms.

Bitwise functions may also be known as Boolean functions or logical functions, because they perform logical operations on the bits of the input operands.

Extension Name

To use this extension within a SPIR-V module, the appropriate OpExtension must be present in the module:

OpExtension "SPV_INTEL_ternary_bitwise_function"

Modifications to the SPIR-V Specification, Version 1.6

Capabilities

Modify Section 3.31, Capability, adding rows to the Capability table:

Capability Implicitly Declares

6241

TernaryBitwiseFunctionINTEL

Instructions

Modify Section 3.56.14, Bit Instructions, adding to the end of the list of instructions:

OpBitwiseFunctionINTEL

Computes a bitwise function of three input operands A, B, and C.

Result Type must be a scalar or vector of integer type.

The types of A, B, and C must be the same as Result Type.

The LUTIndex operand is a lookup table index that describes the bitwise function that is computed. It must be a constant instruction with scalar 32-bit integer type. Only the low eight bits of LUTIndex are used. If any of the upper 24 bits of LUTIndex are nonzero, then behavior is undefined.

To compute the lookup table index for a bitwise function, let sA equal to 0xAA represent the first source operand A, sB equal to 0xCC represent the second source operand B, and sC equal to 0xF0 represent the third source operand C. Then, perform the same bitwise operations on sA, sB, and sC that are desired to be performed on A, B, and C. The resulting value is the lookup table index.

For example, a bitselect operation that picks a bit from the first source operand A when the corresponding bit in the third source operand C is zero, otherwise the bit from the second source operand B, may be computed as: (A & ~C) | (B & C). The 8-bit lookup table for this operation is therefore: (sA & ~sC) | (sB & sC), or (0xAA & ~0xF0) | (0xCC & 0xF0), or (0xAA & 0x0F) | 0xC0, or 0x0A | 0xC0, or 0xCA.

Results are computed per component.

Capability:
TernaryBitwiseFunctionINTEL

7

6242

<id>
Result Type

<id>
Result

<id>
A

<id>
B

<id>
C

<id>
LUTIndex

Issues

  1. What should this extension be called?

    RESOLVED: The name of the extension will be SPV_INTEL_ternary_bitwise_function. This name is chosen to be consistent with terminology used elsewhere in SPIR-V, such as the OpBitwiseAnd instruction. It is also consistent with the "bitwise ternary logic" terminology used by the Intel CPU instructions that may be used to implement this extension.

Revision History

Rev Date Author Changes

1

2025-03-24

Ben Ashbaugh

Initial version for publication