1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -basic-aa -slp-vectorizer -mtriple=x86_64-apple-macosx10.9.0 -mcpu=corei7-avx -S < %s | FileCheck %s
3 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
4 target triple = "x86_64-apple-macosx10.9.0"
7 ; This test used to crash because we were following phi chains incorrectly.
8 ; We used indices to get the incoming value of two phi nodes rather than
9 ; incoming block lookup.
10 ; This can give wrong results when the ordering of incoming
11 ; edges in the two phi nodes don't match.
14 %1 = type { double, double }
15 %2 = type { double, double }
18 ;define fastcc void @bar() {
21 ; CHECK-NEXT: [[TMP1:%.*]] = getelementptr inbounds [[TMP0:%.*]], %0* undef, i64 0, i32 1, i32 0
22 ; CHECK-NEXT: [[TMP2:%.*]] = getelementptr inbounds [[TMP0]], %0* undef, i64 0, i32 1, i32 1
23 ; CHECK-NEXT: [[TMP3:%.*]] = getelementptr inbounds [[TMP0]], %0* undef, i64 0, i32 1, i32 0
24 ; CHECK-NEXT: [[TMP4:%.*]] = getelementptr inbounds [[TMP0]], %0* undef, i64 0, i32 1, i32 1
25 ; CHECK-NEXT: [[TMP5:%.*]] = getelementptr inbounds [[TMP0]], %0* undef, i64 0, i32 1, i32 0
26 ; CHECK-NEXT: [[TMP6:%.*]] = getelementptr inbounds [[TMP0]], %0* undef, i64 0, i32 1, i32 1
27 ; CHECK-NEXT: br label [[TMP7:%.*]]
28 ; CHECK: [[TMP8:%.*]] = phi <2 x double> [ <double 1.800000e+01, double 2.800000e+01>, [[TMP0]] ], [ [[TMP11:%.*]], [[TMP21:%.*]] ], [ [[TMP11]], [[TMP18:%.*]] ], [ [[TMP11]], [[TMP18]] ]
29 ; CHECK-NEXT: [[TMP9:%.*]] = bitcast double* [[TMP1]] to <2 x double>*
30 ; CHECK-NEXT: store <2 x double> [[TMP8]], <2 x double>* [[TMP9]], align 8
31 ; CHECK-NEXT: [[TMP10:%.*]] = bitcast double* [[TMP3]] to <2 x double>*
32 ; CHECK-NEXT: [[TMP11]] = load <2 x double>, <2 x double>* [[TMP10]], align 8
33 ; CHECK-NEXT: br i1 undef, label [[TMP12:%.*]], label [[TMP13:%.*]]
35 ; CHECK: [[TMP14:%.*]] = bitcast double* [[TMP5]] to <2 x double>*
36 ; CHECK-NEXT: store <2 x double> [[TMP11]], <2 x double>* [[TMP14]], align 8
37 ; CHECK-NEXT: br i1 undef, label [[TMP15:%.*]], label [[TMP16:%.*]]
38 ; CHECK: br label [[TMP16]]
39 ; CHECK: br i1 undef, label [[TMP17:%.*]], label [[TMP18]]
41 ; CHECK: [[TMP19:%.*]] = extractelement <2 x double> [[TMP11]], i32 0
42 ; CHECK-NEXT: [[TMP20:%.*]] = extractelement <2 x double> [[TMP11]], i32 1
43 ; CHECK-NEXT: switch i32 undef, label [[TMP21]] [
44 ; CHECK-NEXT: i32 32, label [[TMP7]]
45 ; CHECK-NEXT: i32 103, label [[TMP7]]
47 ; CHECK: br i1 undef, label [[TMP7]], label [[TMP22:%.*]]
50 %1 = getelementptr inbounds %0, %0* undef, i64 0, i32 1, i32 0
51 %2 = getelementptr inbounds %0, %0* undef, i64 0, i32 1, i32 1
52 %3 = getelementptr inbounds %0, %0* undef, i64 0, i32 1, i32 0
53 %4 = getelementptr inbounds %0, %0* undef, i64 0, i32 1, i32 1
54 %5 = getelementptr inbounds %0, %0* undef, i64 0, i32 1, i32 0
55 %6 = getelementptr inbounds %0, %0* undef, i64 0, i32 1, i32 1
58 ; <label>:7 ; preds = %18, %17, %17, %0
59 %8 = phi double [ 2.800000e+01, %0 ], [ %11, %18 ], [ %11, %17 ], [ %11, %17 ]
60 %9 = phi double [ 1.800000e+01, %0 ], [ %10, %18 ], [ %10, %17 ], [ %10, %17 ]
61 store double %9, double* %1, align 8
62 store double %8, double* %2, align 8
63 %10 = load double, double* %3, align 8
64 %11 = load double, double* %4, align 8
65 br i1 undef, label %12, label %13
67 ; <label>:12 ; preds = %7
70 ; <label>:13 ; preds = %7
71 store double %10, double* %5, align 8
72 store double %11, double* %6, align 8
73 br i1 undef, label %14, label %15
75 ; <label>:14 ; preds = %13
78 ; <label>:15 ; preds = %14, %13
79 br i1 undef, label %16, label %17
81 ; <label>:16 ; preds = %15
84 ; <label>:17 ; preds = %15
85 switch i32 undef, label %18 [
90 ; <label>:18 ; preds = %17
91 br i1 undef, label %7, label %19
93 ; <label>:19 ; preds = %18