[cfe-users] Vector instruction

Christophe Duvernois christophe.duvernois at gmail.com
Wed Jun 26 06:52:05 PDT 2013


Hi

I started to play with vector instruction with clang3.3 on ubuntu 12.04
32bit
I made a little test case (see code below) which crash when i try to
compare to vector or display some element ... Is that normal?

Thank you for your help.

-----------------------------------------------------------------------------------------------------------------
#include <stdio.h>
#include <stdint.h>
#include <iostream>

typedef uint64_t __v2i __attribute__ ((__vector_size__ (16)));
typedef uint32_t __v4i __attribute__ ((__vector_size__ (16)));
typedef char __v16i __attribute__ ((__vector_size__ (16)));

int main(){
 uint32_t array[10][4];
 for(uint32_t i = 0; i < 10; i++){
array[i][0] = 10*i +1;
array[i][1] = 10*i +2;
array[i][2] = 10*i +3;
array[i][3] = 10*i +4;
}
 __v4i vectOne = (__v4i) {1, 1, 1, 1};
__v4i* vectArray = (__v4i*)&array;

for(uint32_t i = 0; i < 10; i++){
__v4i vectArrayLine = (__v4i) {array[i][0], array[i][1], array[i][2],
array[i][3]};
fprintf(stderr, "%d : 0x%x 0x%x 0x%x 0x%x\n", i, vectArrayLine[0],
vectArrayLine[1], vectArrayLine[2], vectArrayLine[3]);
 uint32_t* v;
v = (uint32_t*)&vectArray[i];
fprintf(stderr, "%d : 0x%x 0x%x 0x%x 0x%x\n", i, v[0], v[1], v[2], v[3]);
 fprintf(stderr, "%d : 0x%x\n", i, vectArray[i][0]);
fprintf(stderr, "%d : 0x%x\n", i, vectArray[i][1]);
fprintf(stderr, "%d : 0x%x\n", i, vectArray[i][2]);
fprintf(stderr, "%d : 0x%x\n", i, vectArray[i][3]);
 //fprintf(stderr, "%d : 0x%x 0x%x 0x%x 0x%x\n", i, vectArray[i][0],
vectArray[i][1], vectArray[i][2], vectArray[i][3]); // this line crash ??
                __v4i vcomp0 = (vectOne == vectArrayLine ); //ok
//__v4i vcomp = (vectOne == vectArray[0]); // this line crash
 //fprintf(stderr, "%d : 0x%x 0x%x 0x%x 0x%x\n", i, vcomp[0], vcomp[1],
vcomp[2], vcomp[3]);
}
 return 0;
}
-----------------------------------------------------------------------------------------------------------------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-users/attachments/20130626/d4aa47ad/attachment.html>


More information about the cfe-users mailing list