1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -basicaa -slp-vectorizer -S -mtriple=x86_64-apple-macosx10.8.0 -mcpu=corei7 | FileCheck %s
4 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
5 target triple = "x86_64-apple-darwin13.3.0"
7 @a = common global double 0.000000e+00, align 8
12 ; CHECK-NEXT: [[INIT:%.*]] = load double, double* @a, align 8
13 ; CHECK-NEXT: br label [[LOOP:%.*]]
15 ; CHECK-NEXT: [[PHI:%.*]] = phi double [ [[ADD2:%.*]], [[LOOP]] ], [ [[INIT]], [[ENTRY:%.*]] ]
16 ; CHECK-NEXT: [[POSTADD1_PHI:%.*]] = phi double [ [[POSTADD1:%.*]], [[LOOP]] ], [ [[INIT]], [[ENTRY]] ]
17 ; CHECK-NEXT: [[POSTADD2_PHI:%.*]] = phi double [ [[POSTADD2:%.*]], [[LOOP]] ], [ [[INIT]], [[ENTRY]] ]
18 ; CHECK-NEXT: [[ADD1:%.*]] = fadd double [[POSTADD1_PHI]], undef
19 ; CHECK-NEXT: [[ADD2]] = fadd double [[POSTADD2_PHI]], [[PHI]]
20 ; CHECK-NEXT: [[MUL2:%.*]] = fmul double [[ADD2]], 0.000000e+00
21 ; CHECK-NEXT: [[BINARYOP_B:%.*]] = fadd double [[POSTADD1_PHI]], [[MUL2]]
22 ; CHECK-NEXT: [[MUL1:%.*]] = fmul double [[ADD1]], 0.000000e+00
23 ; CHECK-NEXT: [[TMP:%.*]] = fadd double [[POSTADD2_PHI]], 0.000000e+00
24 ; CHECK-NEXT: [[BINARY_V:%.*]] = fadd double [[MUL1]], [[BINARYOP_B]]
25 ; CHECK-NEXT: [[POSTADD1]] = fadd double [[BINARY_V]], 0.000000e+00
26 ; CHECK-NEXT: [[POSTADD2]] = fadd double [[TMP]], 1.000000e+00
27 ; CHECK-NEXT: [[TOBOOL:%.*]] = fcmp une double [[POSTADD1]], 0.000000e+00
28 ; CHECK-NEXT: br i1 [[TOBOOL]], label [[EXIT:%.*]], label [[LOOP]]
30 ; CHECK-NEXT: ret i32 1
33 %init = load double, double* @a, align 8
37 %phi = phi double [ %add2, %loop ], [ %init, %entry ]
38 %postadd1_phi = phi double [ %postadd1, %loop ], [ %init, %entry ]
39 %postadd2_phi = phi double [ %postadd2, %loop ], [ %init, %entry ]
40 %add1 = fadd double %postadd1_phi, undef
41 %add2 = fadd double %postadd2_phi, %phi
42 %mul2 = fmul double %add2, 0.000000e+00
43 %binaryop_B = fadd double %postadd1_phi, %mul2
44 %mul1 = fmul double %add1, 0.000000e+00
45 %tmp = fadd double %postadd2_phi, 0.000000e+00
47 ; tryToVectorize() starts with this binary instruction.
48 ; At the same time vectorization wraps around the loop, vectorizes
49 ; postadd1/2 and eventually binary_V and tmp. So binary_V itself is replaced
50 ; with a vector instruction.
51 ; The SLPVectorizer crashed because it tried to use binary_V
52 ; after vectorization to re-arrange instructions.
53 %binary_V = fadd double %mul1, %binaryop_B
55 %postadd1 = fadd double %binary_V, 0.000000e+00
56 %postadd2 = fadd double %tmp, 1.000000e+00
57 %tobool = fcmp une double %postadd1, 0.000000e+00
58 br i1 %tobool, label %exit, label %loop