Name Strings

SPV_KHR_expect_assume

Contact

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

Contributors

  • Dmitry Sidorov, Intel

  • Alexey Sachkov, Intel

  • Alexey Sotkin, Intel

  • Ben Ashbaugh, Intel

  • Stuart Brady, ARM

Notice

Copyright (c) 2020 The Khronos Group Inc. Copyright terms at http://www.khronos.org/registry/speccopyright.html

Status

  • Complete

  • Approved by the SPIR Working Group: 2020-06-24

  • Ratified the Khronos Group: 2020-08-14

Version

Last Modified Date

2020-06-03

Revision

1

Dependencies

This extension is written against the SPIR-V Specification, Version 1.5 Revision 2.

This extension requires SPIR-V 1.0.

Overview

This extension adds OpAssumeTrueKHR and OpExpectKHR instructions that provide additional information to a compiler, similar to the llvm.assume and llvm.expect intrinsics. SPIR-V consumers may use this information to generate more efficient code.

Extension Name

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

OpExtension "SPV_KHR_expect_assume"

Modifications to the SPIR-V Specification, Version 1.5

Capabilities

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

Capability Implicitly Declares

5629

ExpectAssumeKHR
Uses the OpAssumeTrueKHR or OpExpectKHR instructions.

Instructions

Modify section 3.32.1, "Miscellaneous Instructions", adding to the end of the list of instructions:

OpAssumeTrueKHR

The instruction allows the optimizer to assume that Condition is true whenever the control flow reaches the instruction. Behavior is undefined if Condition is false instead.

Condition must be a scalar of Boolean type.

Capability: ExpectAssumeKHR

2

5630

<id>
Condition

OpExpectKHR

This instruction behaves the same as OpCopyObject by making a copy of Value, except it also provides information to the optimizer that the most probable value of Value is ExpectedValue.

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

The type of Value and ExpectedValue must be the same as Result Type.

Capability: ExpectAssumeKHR

5

5631

<id>
Result Type

Result <id>

<id>
Value

<id>
ExpectedValue

Issues

  1. What should this extension be called?

    RESOLVED: The name of the extension will be SPV_KHR_expect_assume.

Revision History

Rev Date Author Changes

1

2020-06-03

Ben Ashbaugh

Initial KHR extension.