1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -passes=loop-vectorize -S -mtriple=aarch64-unknown-linux-gnu -force-vector-interleave=1 -force-vector-width=4 < %s | FileCheck %s
4 ; The test checks that there is no assert caused by issue described in PR36032
6 target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
8 %struct.anon = type { i8 }
10 @c = local_unnamed_addr global [6 x i8] zeroinitializer, align 1
11 @b = internal global %struct.anon zeroinitializer, align 1
13 ; Function Attrs: noreturn nounwind
14 define void @_Z1dv() local_unnamed_addr #0 {
15 ; CHECK-LABEL: @_Z1dv(
17 ; CHECK-NEXT: [[CALL:%.*]] = tail call ptr @"_ZN3$_01aEv"(ptr nonnull @b)
18 ; CHECK-NEXT: br label [[FOR_COND:%.*]]
20 ; CHECK-NEXT: [[F_0:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[ADD5:%.*]], [[FOR_COND_CLEANUP:%.*]] ]
21 ; CHECK-NEXT: [[G_0:%.*]] = phi i32 [ undef, [[ENTRY]] ], [ [[G_1_LCSSA:%.*]], [[FOR_COND_CLEANUP]] ]
22 ; CHECK-NEXT: [[CMP12:%.*]] = icmp ult i32 [[G_0]], 4
23 ; CHECK-NEXT: [[CONV:%.*]] = and i32 [[F_0]], 65535
24 ; CHECK-NEXT: br i1 [[CMP12]], label [[FOR_BODY_LR_PH:%.*]], label [[FOR_COND_CLEANUP]]
25 ; CHECK: for.body.lr.ph:
26 ; CHECK-NEXT: [[TMP0:%.*]] = zext i32 [[G_0]] to i64
27 ; CHECK-NEXT: br label [[FOR_BODY:%.*]]
28 ; CHECK: for.cond.cleanup.loopexit:
29 ; CHECK-NEXT: br label [[FOR_COND_CLEANUP]]
30 ; CHECK: for.cond.cleanup:
31 ; CHECK-NEXT: [[G_1_LCSSA]] = phi i32 [ [[G_0]], [[FOR_COND]] ], [ 4, [[FOR_COND_CLEANUP_LOOPEXIT:%.*]] ]
32 ; CHECK-NEXT: [[ADD5]] = add nuw nsw i32 [[CONV]], 4
33 ; CHECK-NEXT: br label [[FOR_COND]]
35 ; CHECK-NEXT: [[INDVARS_IV:%.*]] = phi i64 [ [[TMP0]], [[FOR_BODY_LR_PH]] ], [ [[INDVARS_IV_NEXT:%.*]], [[FOR_BODY]] ]
36 ; CHECK-NEXT: [[TMP1:%.*]] = trunc i64 [[INDVARS_IV]] to i32
37 ; CHECK-NEXT: [[ADD:%.*]] = add i32 [[CONV]], [[TMP1]]
38 ; CHECK-NEXT: [[IDXPROM:%.*]] = zext i32 [[ADD]] to i64
39 ; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds [6 x i8], ptr @c, i64 0, i64 [[IDXPROM]]
40 ; CHECK-NEXT: [[TMP2:%.*]] = load i8, ptr [[ARRAYIDX]], align 1
41 ; CHECK-NEXT: [[ARRAYIDX3:%.*]] = getelementptr inbounds i8, ptr [[CALL]], i64 [[INDVARS_IV]]
42 ; CHECK-NEXT: store i8 [[TMP2]], ptr [[ARRAYIDX3]], align 1
43 ; CHECK-NEXT: [[INDVARS_IV_NEXT]] = add nuw nsw i64 [[INDVARS_IV]], 1
44 ; CHECK-NEXT: [[EXITCOND:%.*]] = icmp eq i64 [[INDVARS_IV_NEXT]], 4
45 ; CHECK-NEXT: br i1 [[EXITCOND]], label [[FOR_COND_CLEANUP_LOOPEXIT]], label [[FOR_BODY]]
48 %call = tail call ptr @"_ZN3$_01aEv"(ptr nonnull @b) #2
51 for.cond: ; preds = %for.cond.cleanup, %entry
52 %f.0 = phi i32 [ 0, %entry ], [ %add5, %for.cond.cleanup ]
53 %g.0 = phi i32 [ undef, %entry ], [ %g.1.lcssa, %for.cond.cleanup ]
54 %cmp12 = icmp ult i32 %g.0, 4
55 %conv = and i32 %f.0, 65535
56 br i1 %cmp12, label %for.body.lr.ph, label %for.cond.cleanup
58 for.body.lr.ph: ; preds = %for.cond
59 %0 = zext i32 %g.0 to i64
62 for.cond.cleanup.loopexit: ; preds = %for.body
63 br label %for.cond.cleanup
65 for.cond.cleanup: ; preds = %for.cond.cleanup.loopexit, %for.cond
66 %g.1.lcssa = phi i32 [ %g.0, %for.cond ], [ 4, %for.cond.cleanup.loopexit ]
67 %add5 = add nuw nsw i32 %conv, 4
70 for.body: ; preds = %for.body, %for.body.lr.ph
71 %indvars.iv = phi i64 [ %0, %for.body.lr.ph ], [ %indvars.iv.next, %for.body ]
72 %1 = trunc i64 %indvars.iv to i32
73 %add = add i32 %conv, %1
74 %idxprom = zext i32 %add to i64
75 %arrayidx = getelementptr inbounds [6 x i8], ptr @c, i64 0, i64 %idxprom
76 %2 = load i8, ptr %arrayidx, align 1
77 %arrayidx3 = getelementptr inbounds i8, ptr %call, i64 %indvars.iv
78 store i8 %2, ptr %arrayidx3, align 1
79 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
80 %exitcond = icmp eq i64 %indvars.iv.next, 4
81 br i1 %exitcond, label %for.cond.cleanup.loopexit, label %for.body
84 declare ptr @"_ZN3$_01aEv"(ptr) local_unnamed_addr #1