1target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128"
2; RUN: opt < %s -bb-vectorize -bb-vectorize-req-chain-depth=3 -bb-vectorize-ignore-target-info -instcombine -gvn -S | FileCheck %s
3; RUN: opt < %s -bb-vectorize -bb-vectorize-req-chain-depth=3 -bb-vectorize-search-limit=4 -bb-vectorize-ignore-target-info -instcombine -gvn -S | FileCheck %s -check-prefix=CHECK-SL4
4
5define double @test1(double %A1, double %A2, double %B1, double %B2) {
6; CHECK-LABEL: @test1(
7; CHECK-SL4-LABEL: @test1(
8; CHECK-SL4-NOT: <2 x double>
9; CHECK: %X1.v.i1.1 = insertelement <2 x double> undef, double %B1, i32 0
10; CHECK: %X1.v.i1.2 = insertelement <2 x double> %X1.v.i1.1, double %B2, i32 1
11; CHECK: %X1.v.i0.1 = insertelement <2 x double> undef, double %A1, i32 0
12; CHECK: %X1.v.i0.2 = insertelement <2 x double> %X1.v.i0.1, double %A2, i32 1
13	%X1 = fsub double %A1, %B1
14	%X2 = fsub double %A2, %B2
15; CHECK: %X1 = fsub <2 x double> %X1.v.i0.2, %X1.v.i1.2
16	%Y1 = fmul double %X1, %A1
17	%Y2 = fmul double %X2, %A2
18; CHECK: %Y1 = fmul <2 x double> %X1, %X1.v.i0.2
19	%Z1 = fadd double %Y1, %B1
20        ; Here we have a dependency chain: the short search limit will not
21        ; see past this chain and so will not see the second part of the
22        ; pair to vectorize.
23        %mul41 = fmul double %Z1, %Y2
24        %sub48 = fsub double %Z1, %mul41
25        %mul62 = fmul double %Z1, %sub48
26        %sub69 = fsub double %Z1, %mul62
27        %mul83 = fmul double %Z1, %sub69
28        %sub90 = fsub double %Z1, %mul83
29        %mul104 = fmul double %Z1, %sub90
30        %sub111 = fsub double %Z1, %mul104
31        %mul125 = fmul double %Z1, %sub111
32        %sub132 = fsub double %Z1, %mul125
33        %mul146 = fmul double %Z1, %sub132
34        %sub153 = fsub double %Z1, %mul146
35        ; end of chain.
36	%Z2 = fadd double %Y2, %B2
37; CHECK: %Z1 = fadd <2 x double> %Y1, %X1.v.i1.2
38	%R1  = fdiv double %Z1, %Z2
39        %R   = fmul double %R1, %sub153
40; CHECK: %Z1.v.r1 = extractelement <2 x double> %Z1, i32 0
41; CHECK: %Z1.v.r2 = extractelement <2 x double> %Z1, i32 1
42; CHECK: %R1 = fdiv double %Z1.v.r1, %Z1.v.r2
43	ret double %R
44; CHECK: ret double %R
45}
46
47