Arithmetic Functions for Intel® Graphics Technology

Performs binary arithmetic operations. This topic only applies to Intel® 64 and IA-32 architectures targeting Intel® Graphics Technology.

Syntax

Addition

char _gfx_add_i8(char src0, char src1, unsigned int flags);

short _gfx_add_i16(short src0, short src1, unsigned int flags);

int _gfx_add_i32(int src0, int src1, unsigned int flags); float _gfx_add_f32(float src0, float src1, unsigned int flags); double _gfx_add_f64(double src0, double src1, unsigned int flags);

Subtraction

char _gfx_sub_i8(char src0, char src1, unsigned int flags);

short _gfx_sub_i16(short src0, short src1, unsigned int flags);

int _gfx_sub_i32(int src0, int src1, unsigned int flags);

float _gfx_sub_f32(float src0, float src1, unsigned int flags);

double _gfx_sub_f64(double src0, double src1, unsigned int flags);

Multiplication

char _gfx_mullo_i8(char src0, char src1, unsigned int flags);

short _gfx_mullo_i16(short src0, short src1, unsigned int flags);

int _gfx_mullo_i32(int src0, int src1, unsigned int flags);

float _gfx_mul_f32(float src0, float src1, unsigned int flags);

double _gfx_mul_f64(double src0, double src1, unsigned int flags);

Parameters

src0, src1

The operands of the binary operation.

flags

A flag indicating the additional semantic of the operation. Possible values are:

GFX_SAT

Performs the operation in saturating mode.

0

Performs the operation in non-saturating mode.

Description

These functions perform the corresponding binary operation between src0 and src1, with additional semantics described by the flags argument, for various operand types. The type of the operation is reflected in the intrinsic type suffix.

The currently supported operations are:

Operation

Basic Semantics

add

src0 + src1

sub

src0 - src1

mullo, mul

src0 * src1

mullo applies to the char, short and int types. The term mullo indicates that the result is truncated to the width of the destination type.

mul applies to floating point types.

The operations can be performed in saturating or non-saturating modes, specified by the value of flags. In saturating mode, if the result of the operation exceeds the saturation range for the destination type, the result is clamped to the nearest saturation range boundary. Saturation ranges are:

Type

Saturation Range

char

-128 to 127

short

-32768 to 32767

int

-2147483648 to 2147483647

float, double

-1 to 1

For example:

  • _gfx_add_i8(100, 100, GFX_SAT); returns 127.

  • _gfx_add_i8(100, 100, 0); returns -56, as in a normal addition operation.

This intrinsic can be used in vector context, such as in array notation of a vector loop, where the compiler will vectorize the intrinsic and it will perform independent operations in parallel.

Return Values

The result of the operation.

For more complete information about compiler optimizations, see our Optimization Notice.