The following table lists the arithmetic operators of the Fvec classes and generic syntax. The operators have been divided into standard and advanced operations, which are described in more detail later in this section.

Fvec Arithmetic Operators

Category

Operation

Operators

Generic Syntax

Standard

Addition

+
+=

R = A + B;
R += A;

 

Subtraction

-
-=

R = A - B;
R -= A;

 

Multiplication

*
*=

R = A * B;
R *= A;

 

Division

/
/=

R = A / B;
R /= A;

Advanced

Square Root

sqrt

R = sqrt(A);

 

Reciprocal
(Newton-Raphson)

rcp
rcp_nr

R = rcp(A);
R = rcp_nr(A);

 

Reciprocal Square Root
(Newton-Raphson)

rsqrt
rsqrt_nr

R = rsqrt(A);
R = rsqrt_nr(A);

Standard Arithmetic Operator Usage

The following two tables show the return values for each class of the standard arithmetic operators, which use the syntax styles described earlier in the Return Value Notation section.

Standard Arithmetic Return Value Mapping

R A Operators B F32vec4 F64vec2 F32vec1

R0:=

A0

+

-

*

/

B0

X

X

X

R1:=

A1

+

-

*

/

B1

X

X

N/A

R2:=

A2

+

-

*

/

B2

X

 

N/A

N/A

R3:=

A3

+

-

*

/

B3

X

N/A

N/A

Arithmetic with Assignment Return Value Mapping

R Operators A F32vec4 F64vec2 F32vec1

R0:=

+=

-=

*=

/=

A0

X

X

X

 

R1:=

+=

-=

*=

/=

A1

X

X

N/A

 

R2:=

+=

-=

*=

/=

A2

X

N/A

N/A

R3:=

+=

-=

*=

/=

A3

X

N/A

N/A

This table lists standard arithmetic operator syntax and intrinsics.

Standard Arithmetic Operations for Fvec Classes

Operation

Returns

Example Syntax Usage

Intrinsic

Addition

4 floats

F32vec4 R = F32vec4 A + F32vec4 B;
F32vec4 R += F32vec4 A;

_mm_add_ps

 

2 doubles

F64vec2 R = F64vec2 A + F32vec2 B;
F64vec2 R += F64vec2 A;

_mm_add_pd

 

1 float

F32vec1 R = F32vec1 A + F32vec1 B;
F32vec1 R += F32vec1 A;

_mm_add_ss

Subtraction

4 floats

F32vec4 R = F32vec4 A - F32vec4 B;
F32vec4 R -= F32vec4 A;

_mm_sub_ps

 

2 doubles

F64vec2 R - F64vec2 A + F32vec2 B;
F64vec2 R -= F64vec2 A;

_mm_sub_pd

 

1 float

F32vec1 R = F32vec1 A - F32vec1 B;
F32vec1 R -= F32vec1 A;

_mm_sub_ss

Multiplication

4 floats

F32vec4 R = F32vec4 A * F32vec4 B;
F32vec4 R *= F32vec4 A;

_mm_mul_ps

 

2 doubles

F64vec2 R = F64vec2 A * F364vec2 B;
F64vec2 R *= F64vec2 A;

_mm_mul_pd

 

1 float

F32vec1 R = F32vec1 A * F32vec1 B;
F32vec1 R *= F32vec1 A;

_mm_mul_ss

Division

4 floats

F32vec4 R = F32vec4 A / F32vec4 B;
F32vec4 R /= F32vec4 A;

_mm_div_ps

 

2 doubles

F64vec2 R = F64vec2 A / F64vec2 B;
F64vec2 R /= F64vec2 A;

_mm_div_pd

 

1 float

F32vec1 R = F32vec1 A / F32vec1 B;
F32vec1 R /= F32vec1 A;

_mm_div_ss

Advanced Arithmetic Operator Usage

The following table shows the return values classes of the advanced arithmetic operators, which use the syntax styles described earlier in the Return Value Notation section.

Advanced Arithmetic Return Value Mapping

R Operators A F32vec4 F64vec2 F32vec1

R0:=

sqrt

rcp

rsqrt

rcp_nr

rsqrt_nr

A0

X

R1:=

sqrt

rcp

rsqrt

rcp_nr

rsqrt_nr

A1

N/A

R2:=

sqrt

rcp

rsqrt

rcp_nr

rsqrt_nr

A2

N/A

N/A

R3:=

sqrt

rcp

rsqrt

rcp_nr

rsqrt_nr

A3

N/A

N/A

f :=

add_horizontal

 

 

(A0 + A1 + A2 + A3)

 

 

N/A

N/A

d :=

add_horizontal

 

 

(A0 + A1)

 

 

N/A

N/A

This table shows examples for advanced arithmetic operators.

Advanced Arithmetic Operations for Fvec Classes

Returns

Example Syntax Usage

Intrinsic

Square Root

4 floats

F32vec4 R = sqrt(F32vec4 A);

_mm_sqrt_ps

2 doubles

F64vec2 R = sqrt(F64vec2 A);

_mm_sqrt_pd

1 float

F32vec1 R = sqrt(F32vec1 A);

_mm_sqrt_ss

Reciprocal

4 floats

F32vec4 R = rcp(F32vec4 A);

_mm_rcp_ps

2 doubles

F64vec2 R = rcp(F64vec2 A);

_mm_rcp_pd

1 float

F32vec1 R = rcp(F32vec1 A);

_mm_rcp_ss

Reciprocal Square Root

4 floats

F32vec4 R = rsqrt(F32vec4 A);

_mm_rsqrt_ps

2 doubles

F64vec2 R = rsqrt(F64vec2 A);

_mm_rsqrt_pd

1 float

F32vec1 R = rsqrt(F32vec1 A);

_mm_rsqrt_ss

Reciprocal Newton Raphson

4 floats

F32vec4 R = rcp_nr(F32vec4 A);

_mm_sub_ps
_mm_add_ps
_mm_mul_ps
_mm_rcp_ps

2 doubles

F64vec2 R = rcp_nr(F64vec2 A);

_mm_sub_pd
_mm_add_pd
_mm_mul_pd
_mm_rcp_pd

1 float

F32vec1 R = rcp_nr(F32vec1 A);

_mm_sub_ss
_mm_add_ss
_mm_mul_ss
_mm_rcp_ss

Reciprocal Square Root Newton Raphson

4 float

F32vec4 R = rsqrt_nr(F32vec4 A);

_mm_sub_pd
_mm_mul_pd
_mm_rsqrt_ps

2 doubles

F64vec2 R = rsqrt_nr(F64vec2 A);

_mm_sub_pd
_mm_mul_pd
_mm_rsqrt_pd

1 float

F32vec1 R = rsqrt_nr(F32vec1 A);

_mm_sub_ss
_mm_mul_ss
_mm_rsqrt_ss

Horizontal Add

1 float

float f = add_horizontal(F32vec4 A);

_mm_add_ss
_mm_shuffle_ss

1 double

double d = add_horizontal(F64vec2 A);

_mm_add_sd
_mm_shuffle_sd

Para obtener información más completa sobre las optimizaciones del compilador, consulte nuestro Aviso de optimización.