[PATCH] [X86] Add _mm256_set_m128 and friends

Andrea Di Biagio Andrea_DiBiagio at sn.scee.net
Tue May 19 09:12:59 PDT 2015


Hi Michael,

I suggested a couple of changes to the patch.

I hope it helps!
-Andrea


================
Comment at: lib/Headers/avxintrin.h:1273-1278
@@ -1272,1 +1272,8 @@
 
+static __inline __m256 __attribute__((__always_inline__, __nodebug__))
+_mm256_set_m128 (__m128 __hi, __m128 __lo) {
+  __m256 __hi256 = _mm256_castps128_ps256(__hi);
+  __m256 __lo256 = _mm256_castps128_ps256(__lo);
+  return __builtin_shufflevector(__lo256, __hi256, 0, 1, 2, 3, 8, 9, 10, 11);
+}
+
----------------
You can simply this using a single shuffle.

```
_mm256_set_m128 (__m128 __hi, __m128 __lo) {
  return (__m256) __builtin_shufflevector(__lo, __hi, 0, 1, 2, 3, 4, 5, 6, 7);
}
```

================
Comment at: test/CodeGen/avx-shuffle-builtins.c:177-183
@@ -176,1 +176,9 @@
 
+__m256 test_mm256_set_m128(__m128 hi, __m128 lo) {
+  // CHECK-LABEL: @test_mm256_set_m128
+  // CHECK: shufflevector{{.*}}<i32 0, i32 1, i32 2, i32 3, i32 undef, i32 undef, i32 undef, i32 undef>
+  // CHECK: shufflevector{{.*}}<i32 0, i32 1, i32 2, i32 3, i32 undef, i32 undef, i32 undef, i32 undef>
+  // CHECK: shufflevector{{.*}}<i32 0, i32 1, i32 2, i32 3, i32 8, i32 9, i32 10, i32 11>
+  return _mm256_set_m128(hi, lo);
+}
+
----------------
You would only need to check for a single shufflevector with mask <0,1,2,3,4,5,6,7> if you simplify the body of '_mm256_set_m128'.

http://reviews.llvm.org/D9855

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the cfe-commits mailing list