1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 4
2 ; RUN: opt < %s -passes=vector-combine -S -mtriple=x86_64-- -mattr=sse2 | FileCheck %s
3 ; RUN: opt < %s -passes=vector-combine -S -mtriple=x86_64-- -mattr=avx2 | FileCheck %s
7 define <8 x i32> @concat_extract_subvectors(<8 x i32> %x) {
8 ; CHECK-LABEL: define <8 x i32> @concat_extract_subvectors(
9 ; CHECK-SAME: <8 x i32> [[X:%.*]]) #[[ATTR0:[0-9]+]] {
10 ; CHECK-NEXT: ret <8 x i32> [[X]]
12 %lo = shufflevector <8 x i32> %x, <8 x i32> poison, <4 x i32> <i32 0, i32 1, i32 2, i32 3>
13 %hi = shufflevector <8 x i32> %x, <8 x i32> poison, <4 x i32> <i32 4, i32 5, i32 6, i32 7>
14 %concat = shufflevector <4 x i32> %lo, <4 x i32> %hi, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>
18 ; negative test - shuffle contains undef
20 define <8 x i32> @concat_extract_subvectors_undef(<8 x i32> %x) {
21 ; CHECK-LABEL: define <8 x i32> @concat_extract_subvectors_undef(
22 ; CHECK-SAME: <8 x i32> [[X:%.*]]) #[[ATTR0]] {
23 ; CHECK-NEXT: [[LO:%.*]] = shufflevector <8 x i32> [[X]], <8 x i32> undef, <4 x i32> <i32 0, i32 1, i32 2, i32 8>
24 ; CHECK-NEXT: [[HI:%.*]] = shufflevector <8 x i32> [[X]], <8 x i32> undef, <4 x i32> <i32 4, i32 5, i32 6, i32 8>
25 ; CHECK-NEXT: [[CONCAT:%.*]] = shufflevector <4 x i32> [[LO]], <4 x i32> [[HI]], <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>
26 ; CHECK-NEXT: ret <8 x i32> [[CONCAT]]
28 %lo = shufflevector <8 x i32> %x, <8 x i32> undef, <4 x i32> <i32 0, i32 1, i32 2, i32 8>
29 %hi = shufflevector <8 x i32> %x, <8 x i32> undef, <4 x i32> <i32 4, i32 5, i32 6, i32 8>
30 %concat = shufflevector <4 x i32> %lo, <4 x i32> %hi, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>
34 ; shuffle contains poison
36 define <8 x i32> @concat_extract_subvectors_poison(<8 x i32> %x) {
37 ; CHECK-LABEL: define <8 x i32> @concat_extract_subvectors_poison(
38 ; CHECK-SAME: <8 x i32> [[X:%.*]]) #[[ATTR0]] {
39 ; CHECK-NEXT: ret <8 x i32> [[X]]
41 %lo = shufflevector <8 x i32> %x, <8 x i32> poison, <4 x i32> <i32 0, i32 1, i32 2, i32 8>
42 %hi = shufflevector <8 x i32> %x, <8 x i32> poison, <4 x i32> <i32 4, i32 5, i32 6, i32 8>
43 %concat = shufflevector <4 x i32> %lo, <4 x i32> %hi, <8 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7>
47 ; broadcast loads are free on AVX (and blends are much cheap than general 2-operand shuffles)
49 define <4 x double> @blend_broadcasts_v4f64(ptr %p0, ptr %p1) {
50 ; CHECK-LABEL: define <4 x double> @blend_broadcasts_v4f64(
51 ; CHECK-SAME: ptr [[P0:%.*]], ptr [[P1:%.*]]) #[[ATTR0]] {
52 ; CHECK-NEXT: [[LD0:%.*]] = load <4 x double>, ptr [[P0]], align 32
53 ; CHECK-NEXT: [[LD1:%.*]] = load <4 x double>, ptr [[P1]], align 32
54 ; CHECK-NEXT: [[BCST0:%.*]] = shufflevector <4 x double> [[LD0]], <4 x double> undef, <4 x i32> zeroinitializer
55 ; CHECK-NEXT: [[BCST1:%.*]] = shufflevector <4 x double> [[LD1]], <4 x double> undef, <4 x i32> zeroinitializer
56 ; CHECK-NEXT: [[BLEND:%.*]] = shufflevector <4 x double> [[BCST0]], <4 x double> [[BCST1]], <4 x i32> <i32 0, i32 5, i32 6, i32 3>
57 ; CHECK-NEXT: ret <4 x double> [[BLEND]]
59 %ld0 = load <4 x double>, ptr %p0, align 32
60 %ld1 = load <4 x double>, ptr %p1, align 32
61 %bcst0 = shufflevector <4 x double> %ld0, <4 x double> undef, <4 x i32> zeroinitializer
62 %bcst1 = shufflevector <4 x double> %ld1, <4 x double> undef, <4 x i32> zeroinitializer
63 %blend = shufflevector <4 x double> %bcst0, <4 x double> %bcst1, <4 x i32> <i32 0, i32 5, i32 6, i32 3>
64 ret <4 x double> %blend