1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -passes=slp-vectorizer -S -o - -mtriple=x86_64-unknown-linux -mcpu=haswell -slp-threshold=-3 < %s | FileCheck %s
3 @e = dso_local local_unnamed_addr global i32 0, align 4
4 @f = dso_local local_unnamed_addr global i32 0, align 4
6 ; Function Attrs: nofree norecurse nounwind uwtable
7 define dso_local i32 @g() local_unnamed_addr {
10 ; CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr @e, align 4
11 ; CHECK-NEXT: [[TOBOOL_NOT19:%.*]] = icmp eq i32 [[TMP0]], 0
12 ; CHECK-NEXT: br i1 [[TOBOOL_NOT19]], label [[WHILE_END:%.*]], label [[WHILE_BODY:%.*]]
14 ; CHECK-NEXT: [[C_022:%.*]] = phi ptr [ [[C_022_BE:%.*]], [[WHILE_BODY_BACKEDGE:%.*]] ], [ undef, [[ENTRY:%.*]] ]
15 ; CHECK-NEXT: [[TMP1:%.*]] = phi <2 x ptr> [ [[TMP14:%.*]], [[WHILE_BODY_BACKEDGE]] ], [ undef, [[ENTRY]] ]
16 ; CHECK-NEXT: [[TMP9:%.*]] = extractelement <2 x ptr> [[TMP1]], i32 1
17 ; CHECK-NEXT: [[TMP2:%.*]] = ptrtoint ptr [[TMP9]] to i64
18 ; CHECK-NEXT: [[TMP3:%.*]] = trunc i64 [[TMP2]] to i32
19 ; CHECK-NEXT: [[INCDEC_PTR1:%.*]] = getelementptr inbounds i32, ptr [[C_022]], i64 1
20 ; CHECK-NEXT: [[TMP4:%.*]] = getelementptr i32, <2 x ptr> [[TMP1]], <2 x i64> <i64 1, i64 1>
21 ; CHECK-NEXT: switch i32 [[TMP3]], label [[WHILE_BODY_BACKEDGE]] [
22 ; CHECK-NEXT: i32 2, label [[SW_BB:%.*]]
23 ; CHECK-NEXT: i32 4, label [[SW_BB6:%.*]]
26 ; CHECK-NEXT: [[TMP5:%.*]] = extractelement <2 x ptr> [[TMP4]], i32 0
27 ; CHECK-NEXT: [[TMP6:%.*]] = ptrtoint ptr [[TMP5]] to i64
28 ; CHECK-NEXT: [[TMP7:%.*]] = trunc i64 [[TMP6]] to i32
29 ; CHECK-NEXT: [[INCDEC_PTR5:%.*]] = getelementptr inbounds i32, ptr [[C_022]], i64 2
30 ; CHECK-NEXT: store i32 [[TMP7]], ptr [[INCDEC_PTR1]], align 4
31 ; CHECK-NEXT: [[TMP8:%.*]] = getelementptr i32, <2 x ptr> [[TMP1]], <2 x i64> <i64 2, i64 2>
32 ; CHECK-NEXT: br label [[WHILE_BODY_BACKEDGE]]
34 ; CHECK-NEXT: [[INCDEC_PTR8:%.*]] = getelementptr inbounds i32, ptr [[C_022]], i64 2
35 ; CHECK-NEXT: [[INCDEC_PTR:%.*]] = getelementptr inbounds i32, ptr [[TMP9]], i64 1
36 ; CHECK-NEXT: [[TMP10:%.*]] = ptrtoint ptr [[INCDEC_PTR]] to i64
37 ; CHECK-NEXT: [[TMP11:%.*]] = trunc i64 [[TMP10]] to i32
38 ; CHECK-NEXT: [[TMP12:%.*]] = getelementptr i32, <2 x ptr> [[TMP1]], <2 x i64> <i64 2, i64 2>
39 ; CHECK-NEXT: [[TMP13:%.*]] = extractelement <2 x ptr> [[TMP4]], i32 0
40 ; CHECK-NEXT: store i32 [[TMP11]], ptr [[TMP13]], align 4
41 ; CHECK-NEXT: br label [[WHILE_BODY_BACKEDGE]]
42 ; CHECK: while.body.backedge:
43 ; CHECK-NEXT: [[C_022_BE]] = phi ptr [ [[INCDEC_PTR1]], [[WHILE_BODY]] ], [ [[INCDEC_PTR8]], [[SW_BB6]] ], [ [[INCDEC_PTR5]], [[SW_BB]] ]
44 ; CHECK-NEXT: [[TMP14]] = phi <2 x ptr> [ [[TMP4]], [[WHILE_BODY]] ], [ [[TMP12]], [[SW_BB6]] ], [ [[TMP8]], [[SW_BB]] ]
45 ; CHECK-NEXT: br label [[WHILE_BODY]]
47 ; CHECK-NEXT: ret i32 undef
50 %0 = load i32, ptr @e, align 4
51 %tobool.not19 = icmp eq i32 %0, 0
52 br i1 %tobool.not19, label %while.end, label %while.body
54 while.body: ; preds = %entry, %while.body.backedge
55 %c.022 = phi ptr [ %c.022.be, %while.body.backedge ], [ undef, %entry ]
56 %b.021 = phi ptr [ %b.021.be, %while.body.backedge ], [ undef, %entry ]
57 %a.020 = phi ptr [ %a.020.be, %while.body.backedge ], [ undef, %entry ]
58 %incdec.ptr = getelementptr inbounds i32, ptr %c.022, i64 1
59 %1 = ptrtoint ptr %c.022 to i64
60 %2 = trunc i64 %1 to i32
61 %incdec.ptr1 = getelementptr inbounds i32, ptr %a.020, i64 1
62 %incdec.ptr2 = getelementptr inbounds i32, ptr %b.021, i64 1
63 switch i32 %2, label %while.body.backedge [
68 sw.bb: ; preds = %while.body
69 %incdec.ptr3 = getelementptr inbounds i32, ptr %b.021, i64 2
70 %3 = ptrtoint ptr %incdec.ptr2 to i64
71 %4 = trunc i64 %3 to i32
72 %incdec.ptr4 = getelementptr inbounds i32, ptr %a.020, i64 2
73 store i32 %4, ptr %incdec.ptr1, align 4
74 %incdec.ptr5 = getelementptr inbounds i32, ptr %c.022, i64 2
75 br label %while.body.backedge
77 sw.bb6: ; preds = %while.body
78 %incdec.ptr7 = getelementptr inbounds i32, ptr %a.020, i64 2
79 %incdec.ptr8 = getelementptr inbounds i32, ptr %c.022, i64 2
80 %5 = ptrtoint ptr %incdec.ptr to i64
81 %6 = trunc i64 %5 to i32
82 %incdec.ptr9 = getelementptr inbounds i32, ptr %b.021, i64 2
83 store i32 %6, ptr %incdec.ptr2, align 4
84 br label %while.body.backedge
86 while.body.backedge: ; preds = %sw.bb6, %while.body, %sw.bb
87 %c.022.be = phi ptr [ %incdec.ptr, %while.body ], [ %incdec.ptr8, %sw.bb6 ], [ %incdec.ptr5, %sw.bb ]
88 %b.021.be = phi ptr [ %incdec.ptr2, %while.body ], [ %incdec.ptr9, %sw.bb6 ], [ %incdec.ptr3, %sw.bb ]
89 %a.020.be = phi ptr [ %incdec.ptr1, %while.body ], [ %incdec.ptr7, %sw.bb6 ], [ %incdec.ptr4, %sw.bb ]
92 while.end: ; preds = %entry