AnsweredAssumed Answered

How to activate ALTIVEC2 in gcc ?

Question asked by Alois Hahn on Oct 16, 2014
Latest reply on Oct 20, 2014 by Yiping Wang

Hi,

 

this is a specific question about using the new altivec instructions (altivec2 extensions) of the e6500 in gcc

 

I use the target specific option -mcpu=e6500.

Building file: main.cpp
"/home/freescale/CodeWarrior_PA_10.4.0/eclipse/../Cross_Tools/gcc-4.8.2-Ee6500-aeabi/bin/powerpc-aeabi-g++" "../Sources/main.cpp" @"Sources/main_1.args" -o"Sources/main.o"
Sources/main_1.args : -O0 -g -Wall -std=c++0x -trigraphs -fno-use-cxa-atexit -fno-exceptions -frtti -fno-threadsafe-statics --param max-inline-recursive-depth=8 -c -mbig-endian -fno-builtin -fomit-frame-pointer -Wno-unknown-pragmas -m32 -mcpu=e6500  

 

With this option he compiler sets the predefined macro __ALTIVEC__,

which ist checked

e.g. in #include <altivec.h>

 

altivec.h

#if !defined(__VEC__) || !defined(__ALTIVEC__)
#error Use the "-maltivec" flag to enable PowerPC AltiVec support
#endif

 

altivec.h checks __ALTIVEC2__ as well

#ifdef __ALTIVEC2__
/* New Altivec instructions */
#define vec_absd __builtin_vec_absd
#define vec_lvexbx __builtin_vec_lvexbx
#define vec_lvexhx __builtin_vec_lvexhx
#define vec_lvexwx __builtin_vec_lvexwx
#define vec_stvexbx __builtin_vec_stvexbx
#define vec_stvexhx __builtin_vec_stvexhx
#define vec_stvexwx __builtin_vec_stvexwx
#define vec_lvswx __builtin_vec_lvswx
#define vec_lvswxl __builtin_vec_lvswxl
#define vec_stvswx __builtin_vec_stvswx
#define vec_stvswxl __builtin_vec_stvswxl
#define vec_lvsm __builtin_vec_lvsm
#define vec_lvtlx __builtin_vec_lvtlx
#define vec_lvtlxl __builtin_vec_lvtlxl
#define vec_lvtrx __builtin_vec_lvtrx
#define vec_lvtrxl __builtin_vec_lvtrxl
#define vec_stvflx __builtin_vec_stvflx
#define vec_stvflxl __builtin_vec_stvflxl
#define vec_stvfrx __builtin_vec_stvfrx
#define vec_stvfrxl __builtin_vec_stvfrxl
#endif

 

Apparently __ALTIVEC2__ is not set by the -mcpu=e6500 setting.

 

Seems that -maltivec2 option does the job and sets __ALTIVEC2__.

 

Should I use -maltivec2 option? Are there any recommendations ?
Does gcc generate new altivec instructions when I just use -mcpu=e6500 w/o-maltivec2 ?

 

best regards

Alois

Outcomes