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: [[I2:%.*]] = getelementptr inbounds [[TMP0]], ptr undef, i64 0, i32 1, i32 0
24 ; CHECK-NEXT: [[I4:%.*]] = getelementptr inbounds [[TMP0]], ptr undef, i64 0, i32 1, i32 0
25 ; CHECK-NEXT: br label [[BB6:%.*]]
27 ; CHECK-NEXT: [[TMP0]] = phi <2 x double> [ <double 1.800000e+01, double 2.800000e+01>, [[BB:%.*]] ], [ [[TMP3:%.*]], [[BB17:%.*]] ], [ [[TMP3]], [[BB16:%.*]] ], [ [[TMP3]], [[BB16]] ]
28 ; CHECK-NEXT: store <2 x double> [[TMP0]], ptr [[I]], align 8
29 ; CHECK-NEXT: [[TMP3]] = load <2 x double>, ptr [[I2]], align 8
30 ; CHECK-NEXT: br i1 undef, label [[BB11:%.*]], label [[BB12:%.*]]
32 ; CHECK-NEXT: ret void
34 ; CHECK-NEXT: store <2 x double> [[TMP3]], ptr [[I4]], align 8
35 ; CHECK-NEXT: br i1 undef, label [[BB13:%.*]], label [[BB14:%.*]]
37 ; CHECK-NEXT: br label [[BB14]]
39 ; CHECK-NEXT: br i1 undef, label [[BB15:%.*]], label [[BB16]]
41 ; CHECK-NEXT: unreachable
43 ; CHECK-NEXT: switch i32 undef, label [[BB17]] [
44 ; CHECK-NEXT: i32 32, label [[BB6]]
45 ; CHECK-NEXT: i32 103, label [[BB6]]
48 ; CHECK-NEXT: br i1 undef, label [[BB6]], label [[BB18:%.*]]
50 ; CHECK-NEXT: unreachable
53 %i = getelementptr inbounds %0, ptr undef, i64 0, i32 1, i32 0
54 %i1 = getelementptr inbounds %0, ptr undef, i64 0, i32 1, i32 1
55 %i2 = getelementptr inbounds %0, ptr undef, i64 0, i32 1, i32 0
56 %i3 = getelementptr inbounds %0, ptr undef, i64 0, i32 1, i32 1
57 %i4 = getelementptr inbounds %0, ptr undef, i64 0, i32 1, i32 0
58 %i5 = getelementptr inbounds %0, ptr undef, i64 0, i32 1, i32 1
61 bb6: ; preds = %bb17, %bb16, %bb16, %bb
62 %i7 = phi double [ 2.800000e+01, %bb ], [ %i10, %bb17 ], [ %i10, %bb16 ], [ %i10, %bb16 ]
63 %i8 = phi double [ 1.800000e+01, %bb ], [ %i9, %bb17 ], [ %i9, %bb16 ], [ %i9, %bb16 ]
64 store double %i8, ptr %i, align 8
65 store double %i7, ptr %i1, align 8
66 %i9 = load double, ptr %i2, align 8
67 %i10 = load double, ptr %i3, align 8
68 br i1 undef, label %bb11, label %bb12
74 store double %i9, ptr %i4, align 8
75 store double %i10, ptr %i5, align 8
76 br i1 undef, label %bb13, label %bb14
81 bb14: ; preds = %bb13, %bb12
82 br i1 undef, label %bb15, label %bb16
88 switch i32 undef, label %bb17 [
94 br i1 undef, label %bb6, label %bb18