1; RUN: opt < %s -basicaa -slp-vectorizer -S -mtriple=x86_64-apple-macosx10.8.0 -mcpu=corei7
2
3; Check if the SLPVectorizer does not crash when handling
4; unreachable blocks with unscheduleable instructions.
5
6target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
7target triple = "x86_64-apple-macosx10.9.0"
8
9define void @foo(i32* nocapture %x) #0 {
10entry:
11  br label %bb2
12
13bb1:                                    ; an unreachable block
14  %t3 = getelementptr inbounds i32* %x, i64 4
15  %t4 = load i32* %t3, align 4
16  %t5 = getelementptr inbounds i32* %x, i64 5
17  %t6 = load i32* %t5, align 4
18  %bad = fadd float %bad, 0.000000e+00  ; <- an instruction with self dependency,
19                                        ;    but legal in unreachable code
20  %t7 = getelementptr inbounds i32* %x, i64 6
21  %t8 = load i32* %t7, align 4
22  %t9 = getelementptr inbounds i32* %x, i64 7
23  %t10 = load i32* %t9, align 4
24  br label %bb2
25
26bb2:
27  %t1.0 = phi i32 [ %t4, %bb1 ], [ 2, %entry ]
28  %t2.0 = phi i32 [ %t6, %bb1 ], [ 2, %entry ]
29  %t3.0 = phi i32 [ %t8, %bb1 ], [ 2, %entry ]
30  %t4.0 = phi i32 [ %t10, %bb1 ], [ 2, %entry ]
31  store i32 %t1.0, i32* %x, align 4
32  %t12 = getelementptr inbounds i32* %x, i64 1
33  store i32 %t2.0, i32* %t12, align 4
34  %t13 = getelementptr inbounds i32* %x, i64 2
35  store i32 %t3.0, i32* %t13, align 4
36  %t14 = getelementptr inbounds i32* %x, i64 3
37  store i32 %t4.0, i32* %t14, align 4
38  ret void
39}
40
41