'_mm256_blend_pd : merge elements from two vector

I have a function as below, and I'd like to leverage some avx intrinsics to speed it up.

 bool Box::intersect(Line & line)
 {
    double left_x = line.x0();
    double right_x = line.x1();
    double lower_y = line.y0();
    double upper_y = line.y1();
    
    if (left_x > right_x) { std::swap(left_x, right_x); }
    if (lower_y > upper_y) { std::swap(lower_y, upper_y); }

    double box[4] = {x0(), y0(), x1(), y1()};

    if (box[0] < left_x || box[2] > right_x || box[3] < lower_y || box[1] > upper_y)
    {
       return false;
    }

    if (box[0]  <= left_x && box[2]  >= right_x && box[1]  <= lower_y && box[3]  >= upper_y)
    {
       return true;
    }

    if (line.x0() == line.x1() || line.y0() == line.y1())
    {
       return true;
    }

     return false;
 }

For the first two if condition, I want to make two __mm256 vector and compare it

double line_arr[4] = {left_x, right_x, lower_y, upper_y};
__m256d vec_line = _mm256_loadu_pd(line_arr);
__m256d vec_box = _mm256_loadu_pd(box);

auto vec_left = _mm256_blend_pd( vec_box, vec_line, /*???*/);
auto vec_right = _mm256_blend_pd( vec_box, vec_line, /*???*/);
auto vec_res = _mm256_cmp_pd(vec_left, vec_right, _CMP_LT_OS);
if (vec_res[0] || vec_res[1] || vec_res[2] || vec_res[3])
{
   return false;
}

The problem is, how could I select elements from different vector and merge them into one __m256 vector by using _mm256_blend_pd?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source