1 ; RUN: llc -O3 %s -o %t.s
2 ; RUN: llc -O3 -stop-after=atomic-expand %s -o %t.mir
3 ; RUN: llc -O3 -start-after=atomic-expand %s -o %t2.s
5 ; If we add tti pass correctly files should be identical
6 ; Otherwise LSR will use default TargetTransformInfo and
7 ; optimize the loop differently
10 ; Check that we can do the same with unreachable-mbb-elimination pass
11 ; RUN: llc -O3 -stop-after=unreachable-mbb-elimination %s -o %t-mbb-elim.mir
12 ; RUN: llc -O3 -start-after=unreachable-mbb-elimination %t-mbb-elim.mir -o %t3.s
16 source_filename = "loop.c"
17 target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
18 target triple = "aarch64-none-linux-gnu"
20 @q = dso_local local_unnamed_addr global ptr null, align 8
22 ; Function Attrs: nofree norecurse nounwind
23 define dso_local i32 @main(i32 %argc, ptr nocapture readnone %argv) local_unnamed_addr #0 {
25 %cmp5 = icmp sgt i32 %argc, 0
26 br i1 %cmp5, label %for.body.lr.ph, label %for.cond.cleanup
28 for.body.lr.ph: ; preds = %entry
29 %0 = load ptr, ptr @q, align 8, !tbaa !2
30 %1 = zext i32 %argc to i64
31 %2 = add nsw i64 %1, -1
33 %4 = add nuw nsw i64 %3, 1
34 %min.iters.check = icmp eq i64 %3, 0
35 br i1 %min.iters.check, label %for.body.preheader, label %vector.ph
37 for.body.preheader: ; preds = %middle.block, %for.body.lr.ph
38 %indvars.iv.ph = phi i64 [ 0, %for.body.lr.ph ], [ %ind.end, %middle.block ]
41 vector.ph: ; preds = %for.body.lr.ph
42 %n.vec = and i64 %4, 1152921504606846974
43 %ind.end = shl i64 %n.vec, 5
46 vector.body: ; preds = %vector.body, %vector.ph
47 %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
48 %offset.idx = shl i64 %index, 5
49 %induction7 = or i64 %offset.idx, 32
50 %5 = getelementptr inbounds i32, ptr %0, i64 %offset.idx
51 %6 = getelementptr inbounds i32, ptr %0, i64 %induction7
52 %7 = trunc i64 %offset.idx to i32
53 %8 = trunc i64 %induction7 to i32
54 store i32 %7, ptr %5, align 4, !tbaa !6
55 store i32 %8, ptr %6, align 4, !tbaa !6
56 %index.next = add i64 %index, 2
57 %9 = icmp eq i64 %index.next, %n.vec
58 br i1 %9, label %middle.block, label %vector.body, !llvm.loop !8
60 middle.block: ; preds = %vector.body
61 %cmp.n = icmp eq i64 %4, %n.vec
62 br i1 %cmp.n, label %for.cond.cleanup, label %for.body.preheader
64 for.cond.cleanup: ; preds = %for.body, %middle.block, %entry
67 for.body: ; preds = %for.body.preheader, %for.body
68 %indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ %indvars.iv.ph, %for.body.preheader ]
69 %arrayidx = getelementptr inbounds i32, ptr %0, i64 %indvars.iv
70 %10 = trunc i64 %indvars.iv to i32
71 store i32 %10, ptr %arrayidx, align 4, !tbaa !6
72 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 32
73 %cmp = icmp ult i64 %indvars.iv.next, %1
74 br i1 %cmp, label %for.body, label %for.cond.cleanup, !llvm.loop !10
77 attributes #0 = { nofree norecurse nounwind "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="non-leaf" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="generic" "target-features"="+neon" "unsafe-fp-math"="false" "use-soft-float"="false" }
79 !llvm.module.flags = !{!0}
82 !0 = !{i32 1, !"wchar_size", i32 4}
83 !1 = !{!"clang version 11.0.0 (https://github.com/llvm/llvm-project.git d9943e7f0ce888733ee7ba91da432e5f01f7aa85)"}
85 !3 = !{!"any pointer", !4, i64 0}
86 !4 = !{!"omnipotent char", !5, i64 0}
87 !5 = !{!"Simple C/C++ TBAA"}
89 !7 = !{!"int", !4, i64 0}
90 !8 = distinct !{!8, !9}
91 !9 = !{!"llvm.loop.isvectorized", i32 1}
92 !10 = distinct !{!10, !9}