• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
4
5; If we add tti pass correctly files should be identical
6; Otherwise LSR will use default TargetTransformInfo and
7; optimize the loop differently
8; RUN: cmp %t.s %t2.s
9
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
13; RUN: cmp %t.s %t3.s
14
15; ModuleID = 'loop.c'
16source_filename = "loop.c"
17target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
18target triple = "aarch64-none-linux-gnu"
19
20@q = dso_local local_unnamed_addr global i32* null, align 8
21
22; Function Attrs: nofree norecurse nounwind
23define dso_local i32 @main(i32 %argc, i8** nocapture readnone %argv) local_unnamed_addr #0 {
24entry:
25  %cmp5 = icmp sgt i32 %argc, 0
26  br i1 %cmp5, label %for.body.lr.ph, label %for.cond.cleanup
27
28for.body.lr.ph:                                   ; preds = %entry
29  %0 = load i32*, i32** @q, align 8, !tbaa !2
30  %1 = zext i32 %argc to i64
31  %2 = add nsw i64 %1, -1
32  %3 = lshr i64 %2, 5
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
36
37for.body.preheader:                               ; preds = %middle.block, %for.body.lr.ph
38  %indvars.iv.ph = phi i64 [ 0, %for.body.lr.ph ], [ %ind.end, %middle.block ]
39  br label %for.body
40
41vector.ph:                                        ; preds = %for.body.lr.ph
42  %n.vec = and i64 %4, 1152921504606846974
43  %ind.end = shl i64 %n.vec, 5
44  br label %vector.body
45
46vector.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, i32* %0, i64 %offset.idx
51  %6 = getelementptr inbounds i32, i32* %0, i64 %induction7
52  %7 = trunc i64 %offset.idx to i32
53  %8 = trunc i64 %induction7 to i32
54  store i32 %7, i32* %5, align 4, !tbaa !6
55  store i32 %8, i32* %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
59
60middle.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
63
64for.cond.cleanup:                                 ; preds = %for.body, %middle.block, %entry
65  ret i32 0
66
67for.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, i32* %0, i64 %indvars.iv
70  %10 = trunc i64 %indvars.iv to i32
71  store i32 %10, i32* %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
75}
76
77attributes #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" }
78
79!llvm.module.flags = !{!0}
80!llvm.ident = !{!1}
81
82!0 = !{i32 1, !"wchar_size", i32 4}
83!1 = !{!"clang version 11.0.0 (https://github.com/llvm/llvm-project.git d9943e7f0ce888733ee7ba91da432e5f01f7aa85)"}
84!2 = !{!3, !3, i64 0}
85!3 = !{!"any pointer", !4, i64 0}
86!4 = !{!"omnipotent char", !5, i64 0}
87!5 = !{!"Simple C/C++ TBAA"}
88!6 = !{!7, !7, i64 0}
89!7 = !{!"int", !4, i64 0}
90!8 = distinct !{!8, !9}
91!9 = !{!"llvm.loop.isvectorized", i32 1}
92!10 = distinct !{!10, !9}
93