1 ; RUN: opt < %s -instcombine -S | FileCheck %s
3 define void @f(i64 %val, i32 %limit, i32 *%ptr) {
5 ; CHECK: %0 = trunc i64 %val to i32
6 ; CHECK: %1 = phi i32 [ %0, %entry ], [ {{.*}}, %loop ]
8 %tempvector = insertelement <16 x i64> undef, i64 %val, i32 0
9 %vector = shufflevector <16 x i64> %tempvector, <16 x i64> undef, <16 x i32> zeroinitializer
10 %0 = add <16 x i64> %vector, <i64 0, i64 1, i64 2, i64 3, i64 4, i64 5, i64 6, i64 7, i64 8, i64 9, i64 10, i64 11, i64 12, i64 13, i64 14, i64 15>
11 %1 = trunc <16 x i64> %0 to <16 x i32>
15 %2 = phi <16 x i32> [ %1, %entry ], [ %inc, %loop ]
16 %elt = extractelement <16 x i32> %2, i32 0
17 %end = icmp ult i32 %elt, %limit
19 %4 = sext i32 %elt to i64
20 %5 = getelementptr i32, i32* %ptr, i64 %4
22 %inc = add <16 x i32> %2, <i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16>
23 br i1 %end, label %loop, label %ret
29 define void @copy(i64 %val, i32 %limit, i32 *%ptr) {
31 ; CHECK: %0 = trunc i64 %val to i32
32 ; CHECK: %1 = phi i32 [ %0, %entry ], [ {{.*}}, %loop ]
34 %tempvector = insertelement <16 x i64> undef, i64 %val, i32 0
35 %vector = shufflevector <16 x i64> %tempvector, <16 x i64> undef, <16 x i32> zeroinitializer
36 %0 = add <16 x i64> %vector, <i64 0, i64 1, i64 2, i64 3, i64 4, i64 5, i64 6, i64 7, i64 8, i64 9, i64 10, i64 11, i64 12, i64 13, i64 14, i64 15>
37 %1 = trunc <16 x i64> %0 to <16 x i32>
41 %2 = phi <16 x i32> [ %1, %entry ], [ %inc, %loop ]
42 %elt = extractelement <16 x i32> %2, i32 0
43 %eltcopy = extractelement <16 x i32> %2, i32 0
44 %end = icmp ult i32 %elt, %limit
45 %3 = add i32 10, %eltcopy
46 %4 = sext i32 %elt to i64
47 %5 = getelementptr i32, i32* %ptr, i64 %4
49 %inc = add <16 x i32> %2, <i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16>
50 br i1 %end, label %loop, label %ret
56 define void @nocopy(i64 %val, i32 %limit, i32 *%ptr) {
57 ; CHECK-LABEL: @nocopy
59 ; CHECK: phi <16 x i32> [ %3, %entry ], [ %inc, %loop ]
61 %tempvector = insertelement <16 x i64> undef, i64 %val, i32 0
62 %vector = shufflevector <16 x i64> %tempvector, <16 x i64> undef, <16 x i32> zeroinitializer
63 %0 = add <16 x i64> %vector, <i64 0, i64 1, i64 2, i64 3, i64 4, i64 5, i64 6, i64 7, i64 8, i64 9, i64 10, i64 11, i64 12, i64 13, i64 14, i64 15>
64 %1 = trunc <16 x i64> %0 to <16 x i32>
68 %2 = phi <16 x i32> [ %1, %entry ], [ %inc, %loop ]
69 %elt = extractelement <16 x i32> %2, i32 0
70 %eltcopy = extractelement <16 x i32> %2, i32 1
71 %end = icmp ult i32 %elt, %limit
72 %3 = add i32 10, %eltcopy
73 %4 = sext i32 %elt to i64
74 %5 = getelementptr i32, i32* %ptr, i64 %4
76 %inc = add <16 x i32> %2, <i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16, i32 16>
77 br i1 %end, label %loop, label %ret
83 define i1 @g(<3 x i32> %input_2) {
85 ; CHECK: extractelement <3 x i32> %input_2, i32 0
90 %input_2.addr.0 = phi <3 x i32> [ %input_2, %entry ], [ %div45, %for.body ]
91 %input_1.addr.1 = phi <3 x i32> [ undef, %entry ], [ %dec43, %for.body ]
92 br i1 undef, label %for.end, label %for.body
94 ; CHECK-NOT: extractelement <3 x i32> %{{.*}}, i32 0
96 %dec43 = add <3 x i32> %input_1.addr.1, <i32 -1, i32 -1, i32 -1>
97 %sub44 = sub <3 x i32> <i32 -1, i32 -1, i32 -1>, %dec43
98 %div45 = sdiv <3 x i32> %input_2.addr.0, %sub44
102 %0 = extractelement <3 x i32> %input_2.addr.0, i32 0
103 %.89 = select i1 false, i32 0, i32 %0
104 %tobool313 = icmp eq i32 %.89, 0