Int64_t pointer to AVX2 intrinsic _m256i

Hi, I have a strange problem with the internal functions of AVX2. I am creating a pointer to the vector _m256i with int64_t * cast. Then I assign the value by dereferencing the pointer. The strange thing is that the value is not observed in the vector variable unless I ran a few cout statements after it. The pointer and the vector have the same memory address and dereferencing the pointer produces the correct value, but the vector does not. What am I missing?

// Vector Variable 
__m256i R_A0to3 = _mm256_set1_epi32(0xFFFFFFFF);

int64_t *ptr = NULL;
for(int m=0; m<4; m++){
    // Cast pointer to vector type
    ptr = (int64_t*)&R_A0to3;

    cout<<"ptr_ADDRESS:      "<<ptr<<endl;
    cout<<"&R_A0to3_ADDRESS: "<<&R_A0to3<<endl;

    // access
    ptr[m] = (int64_t) m_array[m];

    // generic function that prints out register
    print_mm256_reg<int64_t>(R_A0to3, "R_A0to3");
    cout<<"m_array: "<< m_array[m]<<std::ends;

    // Additional print statements
    cout<<"ptr[m]: "<< ptr[m]<<std::endl;
    cout<<"ptr[0]: "<< ptr[0]<<std::endl;
    cout<<"ptr[1]: "<< ptr[1]<<std::endl;
    cout<<"ptr[2]: "<< ptr[2]<<std::endl;
    cout<<"ptr[3]: "<< ptr[3]<<std::endl;
    print_mm256_reg<int64_t>(R_A0to3, "R_A0to3");
}

Output:
 ptr_ADDRESS      0x7ffd9313e880
 &R_A0to3_ADDRESS 0x7ffd9313e880
 m_array: 8
 printing reg -    R_C0to3    -1|  -1|  -1|  -1|
 printing reg -    R_D0to3    -1|  -1|  -1|  -1|

Output with Additional print statements:
ptr_ADDRESS      0x7ffd36359e20
&R_A0to3_ADDRESS 0x7ffd36359e20
printing reg -    R_A0to3     -1|  -1|  -1|  -1|
m_array: 8

ptr[0]: 8
ptr[1]: -1
ptr[2]: -1
ptr[3]: -1
printing reg -    R_A0to3      8|  -1|  -1|  -1|
+3
source share
1 answer

_mm256_extract_epi64 _mm256_insert_epi64, . , _mm256_store_si256 _mm256_lddqu_si256 . undefined, (, , ).

+2

All Articles