1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -passes=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() {
22 ; CHECK-NEXT: [[I:%.*]] = getelementptr inbounds [[TMP0:%.*]], ptr undef, i64 0, i32 1, i32 0
23 ; CHECK-NEXT: [[I1:%.*]] = getelementptr inbounds [[TMP0]], ptr undef, i64 0, i32 1, i32 1
24 ; CHECK-NEXT: [[I2:%.*]] = getelementptr inbounds [[TMP0]], ptr undef, i64 0, i32 1, i32 0
25 ; CHECK-NEXT: [[I3:%.*]] = getelementptr inbounds [[TMP0]], ptr undef, i64 0, i32 1, i32 1
26 ; CHECK-NEXT: [[I4:%.*]] = getelementptr inbounds [[TMP0]], ptr undef, i64 0, i32 1, i32 0
27 ; CHECK-NEXT: br label [[BB6:%.*]]
29 ; CHECK-NEXT: [[I7:%.*]] = phi double [ 2.800000e+01, [[BB:%.*]] ], [ [[I10:%.*]], [[BB17:%.*]] ], [ [[I10]], [[BB16:%.*]] ], [ [[I10]], [[BB16]] ]
30 ; CHECK-NEXT: [[I8:%.*]] = phi double [ 1.800000e+01, [[BB]] ], [ [[TMP1:%.*]], [[BB17]] ], [ [[TMP1]], [[BB16]] ], [ [[TMP1]], [[BB16]] ]
31 ; CHECK-NEXT: store double [[I8]], ptr [[I]], align 8
32 ; CHECK-NEXT: store double [[I7]], ptr [[I1]], align 8
33 ; CHECK-NEXT: [[I10]] = load double, ptr [[I3]], align 8
34 ; CHECK-NEXT: [[TMP0]] = load <2 x double>, ptr [[I2]], align 8
35 ; CHECK-NEXT: br i1 undef, label [[BB11:%.*]], label [[BB12:%.*]]
37 ; CHECK-NEXT: ret void
39 ; CHECK-NEXT: store <2 x double> [[TMP0]], ptr [[I4]], align 8
40 ; CHECK-NEXT: br i1 undef, label [[BB13:%.*]], label [[BB14:%.*]]
42 ; CHECK-NEXT: br label [[BB14]]
44 ; CHECK-NEXT: br i1 undef, label [[BB15:%.*]], label [[BB16]]
46 ; CHECK-NEXT: unreachable
48 ; CHECK-NEXT: [[TMP1]] = extractelement <2 x double> [[TMP0]], i32 0
49 ; CHECK-NEXT: switch i32 undef, label [[BB17]] [
50 ; CHECK-NEXT: i32 32, label [[BB6]]
51 ; CHECK-NEXT: i32 103, label [[BB6]]
54 ; CHECK-NEXT: br i1 undef, label [[BB6]], label [[BB18:%.*]]
56 ; CHECK-NEXT: unreachable
59 %i = getelementptr inbounds %0, ptr undef, i64 0, i32 1, i32 0
60 %i1 = getelementptr inbounds %0, ptr undef, i64 0, i32 1, i32 1
61 %i2 = getelementptr inbounds %0, ptr undef, i64 0, i32 1, i32 0
62 %i3 = getelementptr inbounds %0, ptr undef, i64 0, i32 1, i32 1
63 %i4 = getelementptr inbounds %0, ptr undef, i64 0, i32 1, i32 0
64 %i5 = getelementptr inbounds %0, ptr undef, i64 0, i32 1, i32 1
67 bb6: ; preds = %bb17, %bb16, %bb16, %bb
68 %i7 = phi double [ 2.800000e+01, %bb ], [ %i10, %bb17 ], [ %i10, %bb16 ], [ %i10, %bb16 ]
69 %i8 = phi double [ 1.800000e+01, %bb ], [ %i9, %bb17 ], [ %i9, %bb16 ], [ %i9, %bb16 ]
70 store double %i8, ptr %i, align 8
71 store double %i7, ptr %i1, align 8
72 %i9 = load double, ptr %i2, align 8
73 %i10 = load double, ptr %i3, align 8
74 br i1 undef, label %bb11, label %bb12
80 store double %i9, ptr %i4, align 8
81 store double %i10, ptr %i5, align 8
82 br i1 undef, label %bb13, label %bb14
87 bb14: ; preds = %bb13, %bb12
88 br i1 undef, label %bb15, label %bb16
94 switch i32 undef, label %bb17 [
100 br i1 undef, label %bb6, label %bb18
102 bb18: ; preds = %bb17