Please enter what you're looking for to continue your search
 

vec_extract
ADD TO COMPARE ADDED TO COMPARE

 IBM Power 9 64-bit (64 bits)/ VSX  View official documentation
Purpose:

Returns the value of the bth element of vector a.

Result value: The value of each element of output is the element of a at position b modulo the number of elements of a.

Endian considerations: The element numbering within a register is left-to-right for big-endian targets, and right-to-left for little-endian targets.

Notes: Prior to ISA 3.0, less efficient code sequences must be used to implement vec_extract.

Result:

signed short

Prototypes

Assembly Instruction:
MULTILINE
Usage:
signed char result = vec_extract( vector signed char a, int b )
Performance Metrics:
📊 Unlock Performance Insights

Get access to detailed performance metrics including latency, throughput, and CPU-specific benchmarks for this intrinsic.

Example:
#include <altivec.h>
#include <stdio.h>
int main() {
 vector signed char a = {
  0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
 };
 int b = 5;
 signed char r = vec_extract(a, b);
 printf("%d\n", r);

 return 0;
}
Assembly Instruction:
MULTILINE
Usage:
signed long long result = vec_extract( vector signed long long a, int b )
Performance Metrics:
Login required
Example:
#include <altivec.h>
#include <stdio.h>
int main() {
 vector signed long long a = {
  1000, 2000
 };
 int b = 1;
 signed long long r = vec_extract(a, b);
 printf("%lld\n", r);

 return 0;
}
Assembly Instruction:
MULTILINE
Usage:
unsigned short result = vec_extract( vector unsigned short a, int b )
Performance Metrics:
Login required
Example:
#include <altivec.h>
#include <stdio.h>
int main() {
 vector unsigned short a = {
  10, 20, 30, 40, 50, 60, 70, 80
 };
 int b = 5;
 unsigned short r = vec_extract(a, b);
 printf("%u\n", r);

 return 0;
}
Assembly Instruction:
vextubrx
Usage:
unsigned char result = vec_extract( vector unsigned char a, int b )
Performance Metrics:
Login required
Example:
#include <altivec.h>
#include <stdio.h>
int main() {
 vector unsigned char a = {
  10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160
 };
 int b = 6;
 unsigned char r = vec_extract(a, b);
 printf("%u\n", r);

 return 0;
}
Assembly Instruction:
MULTILINE
Usage:
unsigned long long result = vec_extract( vector unsigned long long a, int b )
Performance Metrics:
Login required
Example:
#include <altivec.h>
#include <stdio.h>
int main() {
 vector unsigned long long a = {
  1000, 2000
 };
 int b = 0;
 unsigned long long r = vec_extract(a, b);
 printf("%llu\n", r);

 return 0;
}
Assembly Instruction:
MULTILINE
Usage:
int result = vec_extract( vector signed int a, int b )
Performance Metrics:
Login required
Example:
#include <altivec.h>
#include <stdio.h>
int main() {
 vector signed int a = {
  100, 200, 300, 400
 };
 int b = 2;
 signed int r = vec_extract(a, b);
 printf("%d\n", r);

 return 0;
}
Assembly Instruction:
MULTILINE
Usage:
float result = vec_extract( vector float a, int b )
Performance Metrics:
Login required
Example:
#include <altivec.h>
#include <stdio.h>
int main() {
 vector float a = {
  1.5f, 2.5f, 3.5f, 4.5f
 };
 int b = 2;
 float r = vec_extract(a, b);
 printf("%f\n", r);

 return 0;
}
Assembly Instruction:
MULTILINE
Usage:
signed short result = vec_extract( vector signed short a, int b )
Performance Metrics:
Login required
Example:
#include <altivec.h>
#include <stdio.h>
int main() {
 vector signed short a = {
  100, 200, 300, 400, 500, 600, 700, 800
 };
 int b = 3;
 short r = vec_extract(a, b);
 printf("%d\n", r);

 return 0;
}
Assembly Instruction:
MULTILINE
Usage:
double result = vec_extract( vector double a, int b )
Performance Metrics:
Login required
Example:
#include <altivec.h>
#include <stdio.h>
int main() {
 vector double a = {
  1.25, 2.5
 };
 int b = 1;
 double r = vec_extract(a, b);
 printf("%f\n", r);

 return 0;
}
Assembly Instruction:
MULTILINE
Usage:
unsigned int result = vec_extract( vector unsigned int a, int b )
Performance Metrics:
Login required
Example:
#include <altivec.h>
#include <stdio.h>
int main() {
 vector unsigned int a = {
  100, 200, 300, 400
 };
 int b = 2;
 unsigned int r = vec_extract(a, b);
 printf("%u\n", r);

 return 0;
}
SIMD Intrinsics Summary
SIMD Engines: 6
C Intrinsics: 10444
NEON: 4353
AVX2: 405
AVX512: 4717
SSE4.2: 598
VSX: 192
IBM-Z: 179