1; RUN: opt -mtriple=x86_64-unknown-linux-gnu -load-store-vectorizer -mcpu haswell -S -o - %s | FileCheck --check-prefix=CHECK-HSW %s
2; RUN: opt -mtriple=x86_64-unknown-linux-gnu -load-store-vectorizer -mcpu knl -S -o - %s | FileCheck --check-prefix=CHECK-KNL %s
3; RUN: opt -mtriple=x86_64-unknown-linux-gnu -aa-pipeline=basic-aa -passes='function(load-store-vectorizer)' -mcpu haswell -S -o - %s | FileCheck --check-prefix=CHECK-HSW %s
4; RUN: opt -mtriple=x86_64-unknown-linux-gnu -aa-pipeline=basic-aa -passes='function(load-store-vectorizer)' -mcpu knl -S -o - %s | FileCheck --check-prefix=CHECK-KNL %s
5
6define <8 x double> @loadwidth_insert_extract(double* %ptr) {
7    %a = bitcast double* %ptr to <2 x double> *
8    %b = getelementptr <2 x double>, <2 x double>* %a, i32 1
9    %c = getelementptr <2 x double>, <2 x double>* %a, i32 2
10    %d = getelementptr <2 x double>, <2 x double>* %a, i32 3
11; CHECK-HSW: load <4 x double>
12; CHECK-HSW: load <4 x double>
13; CHECK-HSW-NOT: load
14; CHECK-KNL: load <8 x double>
15; CHECK-KNL-NOT: load
16    %la = load <2 x double>, <2 x double> *%a
17    %lb = load <2 x double>, <2 x double> *%b
18    %lc = load <2 x double>, <2 x double> *%c
19    %ld = load <2 x double>, <2 x double> *%d
20    ; Scalarize everything - Explicitly not a shufflevector to test this code
21    ; path in the LSV
22    %v1 = extractelement <2 x double> %la, i32 0
23    %v2 = extractelement <2 x double> %la, i32 1
24    %v3 = extractelement <2 x double> %lb, i32 0
25    %v4 = extractelement <2 x double> %lb, i32 1
26    %v5 = extractelement <2 x double> %lc, i32 0
27    %v6 = extractelement <2 x double> %lc, i32 1
28    %v7 = extractelement <2 x double> %ld, i32 0
29    %v8 = extractelement <2 x double> %ld, i32 1
30    ; Make a vector again
31    %i1 = insertelement <8 x double> undef, double %v1, i32 0
32    %i2 = insertelement <8 x double> %i1, double %v2, i32 1
33    %i3 = insertelement <8 x double> %i2, double %v3, i32 2
34    %i4 = insertelement <8 x double> %i3, double %v4, i32 3
35    %i5 = insertelement <8 x double> %i4, double %v5, i32 4
36    %i6 = insertelement <8 x double> %i5, double %v6, i32 5
37    %i7 = insertelement <8 x double> %i6, double %v7, i32 6
38    %i8 = insertelement <8 x double> %i7, double %v8, i32 7
39    ret <8 x double> %i8
40}
41