1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2; RUN: opt -mtriple=i386-linux-gnu -slp-vectorizer -S %s | FileCheck %s
3
4%struct.a = type { [2 x i64] }
5
6@a = external global %struct.a
7@b = external global %struct.a
8@c = external global %struct.a
9
10define void @f(i1 %x) #0 {
11; CHECK-LABEL: @f(
12; CHECK-NEXT:  entry:
13; CHECK-NEXT:    [[TMP0:%.*]] = load <2 x i64>, <2 x i64>* bitcast (%struct.a* @a to <2 x i64>*), align 8
14; CHECK-NEXT:    br i1 [[X:%.*]], label [[WHILE_BODY_LR_PH:%.*]], label [[WHILE_END:%.*]]
15; CHECK:       while.body.lr.ph:
16; CHECK-NEXT:    [[TMP1:%.*]] = extractelement <2 x i64> [[TMP0]], i32 1
17; CHECK-NEXT:    [[ICMP_A1:%.*]] = icmp eq i64 [[TMP1]], 0
18; CHECK-NEXT:    [[TMP2:%.*]] = load <2 x i64>, <2 x i64>* bitcast (%struct.a* @b to <2 x i64>*), align 8
19; CHECK-NEXT:    [[TMP3:%.*]] = insertelement <2 x i1> poison, i1 [[ICMP_A1]], i32 0
20; CHECK-NEXT:    [[TMP4:%.*]] = insertelement <2 x i1> [[TMP3]], i1 [[ICMP_A1]], i32 1
21; CHECK-NEXT:    [[TMP5:%.*]] = select <2 x i1> [[TMP4]], <2 x i64> [[TMP2]], <2 x i64> [[TMP0]]
22; CHECK-NEXT:    br label [[WHILE_END]]
23; CHECK:       while.end:
24; CHECK-NEXT:    [[TMP6:%.*]] = phi <2 x i64> [ [[TMP0]], [[ENTRY:%.*]] ], [ [[TMP5]], [[WHILE_BODY_LR_PH]] ]
25; CHECK-NEXT:    [[TMP7:%.*]] = load <2 x i64>, <2 x i64>* bitcast (%struct.a* @c to <2 x i64>*), align 8
26; CHECK-NEXT:    [[TMP8:%.*]] = extractelement <2 x i64> [[TMP6]], i32 0
27; CHECK-NEXT:    [[ICMP_D0:%.*]] = icmp eq i64 [[TMP8]], 0
28; CHECK-NEXT:    br i1 [[ICMP_D0]], label [[IF_END:%.*]], label [[IF_THEN:%.*]]
29; CHECK:       if.then:
30; CHECK-NEXT:    [[AND0_TMP:%.*]] = and i64 [[TMP8]], 8
31; CHECK-NEXT:    [[TMP9:%.*]] = insertelement <2 x i64> poison, i64 [[AND0_TMP]], i32 0
32; CHECK-NEXT:    [[TMP10:%.*]] = extractelement <2 x i64> [[TMP6]], i32 1
33; CHECK-NEXT:    [[TMP11:%.*]] = insertelement <2 x i64> [[TMP9]], i64 [[TMP10]], i32 1
34; CHECK-NEXT:    [[TMP12:%.*]] = and <2 x i64> [[TMP11]], [[TMP7]]
35; CHECK-NEXT:    store <2 x i64> [[TMP12]], <2 x i64>* bitcast (%struct.a* @a to <2 x i64>*), align 8
36; CHECK-NEXT:    br label [[IF_END]]
37; CHECK:       if.end:
38; CHECK-NEXT:    ret void
39;
40entry:
41  %a0 = load i64, i64* getelementptr inbounds (%struct.a, %struct.a* @a, i32 0, i32 0, i32 0), align 8
42  %a1 = load i64, i64* getelementptr inbounds (%struct.a, %struct.a* @a, i32 0, i32 0, i32 1), align 8
43  br i1 %x, label %while.body.lr.ph, label %while.end
44
45while.body.lr.ph:
46  %icmp.a1 = icmp eq i64 %a1, 0
47  %b0 = load i64, i64* getelementptr inbounds (%struct.a, %struct.a* @b, i32 0, i32 0, i32 0), align 8
48  %b1 = load i64, i64* getelementptr inbounds (%struct.a, %struct.a* @b, i32 0, i32 0, i32 1), align 8
49  %c0 = select i1 %icmp.a1, i64 %b0, i64 %a0
50  %c1 = select i1 %icmp.a1, i64 %b1, i64 %a1
51  br label %while.end
52
53while.end:
54  %d0 = phi i64 [ %a0, %entry ], [ %c0, %while.body.lr.ph ]
55  %d1 = phi i64 [ %a1, %entry ], [ %c1, %while.body.lr.ph ]
56  %e0 = load i64, i64* getelementptr inbounds (%struct.a, %struct.a* @c, i32 0, i32 0, i32 0), align 8
57  %e1 = load i64, i64* getelementptr inbounds (%struct.a, %struct.a* @c, i32 0, i32 0, i32 1), align 8
58  %icmp.d0 = icmp eq i64 %d0, 0
59  br i1 %icmp.d0, label %if.end, label %if.then
60
61if.then:
62  %and0.tmp = and i64 %d0, 8
63  %and0 = and i64 %and0.tmp, %e0
64  %and1 = and i64 %e1, %d1
65  store i64 %and0, i64* getelementptr inbounds (%struct.a, %struct.a* @a, i32 0, i32 0, i32 0), align 8
66  store i64 %and1, i64* getelementptr inbounds (%struct.a, %struct.a* @a, i32 0, i32 0, i32 1), align 8
67  br label %if.end
68
69if.end:
70  ret void
71}
72
73attributes #0 = { "target-features"="+sse2" }
74