1 ; RUN: opt < %s -force-vector-width=4 -force-vector-interleave=1 -loop-vectorize -S | FileCheck %s
3 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
5 ; CHECK-LABEL: @PR34687(
7 ; CHECK-NEXT: [[INDEX:%.*]] = phi i32 [ 0, %vector.ph ], [ [[INDEX_NEXT:%.*]], %[[LATCH:.*]] ]
8 ; CHECK-NEXT: [[VEC_PHI:%.*]] = phi <4 x i32> [ zeroinitializer, %vector.ph ], [ [[TMP17:%.*]], %[[LATCH]] ]
10 ; CHECK: [[TMP13:%.*]] = and <4 x i32> [[VEC_PHI]], <i32 255, i32 255, i32 255, i32 255>
11 ; CHECK-NEXT: [[TMP14:%.*]] = add nuw nsw <4 x i32> [[TMP13]], {{.*}}
12 ; CHECK-NEXT: [[INDEX_NEXT]] = add i32 [[INDEX]], 4
13 ; CHECK: [[TMP16:%.*]] = trunc <4 x i32> [[TMP14]] to <4 x i8>
14 ; CHECK-NEXT: [[TMP17]] = zext <4 x i8> [[TMP16]] to <4 x i32>
15 ; CHECK-NEXT: br i1 {{.*}}, label %middle.block, label %vector.body
17 define i8 @PR34687(i1 %c, i32 %x, i32 %n) {
22 %i = phi i32 [ 0, %entry ], [ %i.next, %if.end ]
23 %r = phi i32 [ 0, %entry ], [ %r.next, %if.end ]
24 br i1 %c, label %if.then, label %if.end
27 %tmp0 = sdiv i32 undef, undef
31 %tmp1 = and i32 %r, 255
32 %i.next = add nsw i32 %i, 1
33 %r.next = add nuw nsw i32 %tmp1, %x
34 %cond = icmp eq i32 %i.next, %n
35 br i1 %cond, label %for.end, label %for.body
38 %tmp2 = phi i32 [ %r.next, %if.end ]
39 %tmp3 = trunc i32 %tmp2 to i8
43 ; CHECK-LABEL: @PR35734(
45 ; CHECK: [[TMP3:%.*]] = insertelement <4 x i32> zeroinitializer, i32 %y, i32 0
46 ; CHECK-NEXT: br label %vector.body
48 ; CHECK-NEXT: [[INDEX:%.*]] = phi i32 [ 0, %vector.ph ], [ [[INDEX_NEXT:%.*]], %vector.body ]
49 ; CHECK-NEXT: [[VEC_PHI:%.*]] = phi <4 x i32> [ [[TMP3]], %vector.ph ], [ [[TMP9:%.*]], %vector.body ]
50 ; CHECK: [[TMP5:%.*]] = and <4 x i32> [[VEC_PHI]], <i32 1, i32 1, i32 1, i32 1>
51 ; CHECK-NEXT: [[TMP6:%.*]] = add <4 x i32> [[TMP5]], <i32 -1, i32 -1, i32 -1, i32 -1>
52 ; CHECK-NEXT: [[INDEX_NEXT]] = add i32 [[INDEX]], 4
53 ; CHECK: [[TMP8:%.*]] = trunc <4 x i32> [[TMP6]] to <4 x i1>
54 ; CHECK-NEXT: [[TMP9]] = sext <4 x i1> [[TMP8]] to <4 x i32>
55 ; CHECK-NEXT: br i1 {{.*}}, label %middle.block, label %vector.body
57 define i32 @PR35734(i32 %x, i32 %y) {
62 %i = phi i32 [ %x, %entry ], [ %i.next, %for.body ]
63 %r = phi i32 [ %y, %entry ], [ %r.next, %for.body ]
65 %r.next = add i32 %tmp0, -1
66 %i.next = add nsw i32 %i, 1
67 %cond = icmp sgt i32 %i, 77
68 br i1 %cond, label %for.end, label %for.body
71 %tmp1 = phi i32 [ %r.next, %for.body ]