• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; PR23524
2; The test is to check redundency produced by loop unroll pass
3; should be cleaned up by later pass.
4; RUN: opt < %s -O2 -S | FileCheck %s
5
6; After loop unroll:
7;       %niter.nsub = add nsw i32 %niter, -1
8;       ...
9;       %niter.nsub.1 = add nsw i32 %niter.nsub, -1
10; should be merged to:
11;       %dec18.1 = add nsw i32 %niter, -2
12;
13; CHECK-LABEL: @_Z3fn1v(
14; CHECK: %niter.nsub.1 = add i32 %niter, -2
15
16; ModuleID = '<stdin>'
17target triple = "x86_64-unknown-linux-gnu"
18
19@b = global i32 0, align 4
20@c = global i32 0, align 4
21
22; Function Attrs: nounwind uwtable
23define void @_Z3fn1v() #0 {
24entry:
25  %tmp = load i32, i32* @b, align 4
26  %tobool20 = icmp eq i32 %tmp, 0
27  br i1 %tobool20, label %for.end6, label %for.body.lr.ph
28
29for.body.lr.ph:                                   ; preds = %entry
30  br label %for.body
31
32for.cond1.for.cond.loopexit_crit_edge:            ; preds = %for.inc
33  %add.ptr.lcssa = phi i16* [ %add.ptr, %for.inc ]
34  %incdec.ptr.lcssa = phi i8* [ %incdec.ptr, %for.inc ]
35  br label %for.cond.loopexit
36
37for.cond.loopexit:                                ; preds = %for.body, %for.cond1.for.cond.loopexit_crit_edge
38  %r.1.lcssa = phi i16* [ %add.ptr.lcssa, %for.cond1.for.cond.loopexit_crit_edge ], [ %r.022, %for.body ]
39  %a.1.lcssa = phi i8* [ %incdec.ptr.lcssa, %for.cond1.for.cond.loopexit_crit_edge ], [ %a.021, %for.body ]
40  %tmp1 = load i32, i32* @b, align 4
41  %tobool = icmp eq i32 %tmp1, 0
42  br i1 %tobool, label %for.cond.for.end6_crit_edge, label %for.body
43
44for.body:                                         ; preds = %for.cond.loopexit, %for.body.lr.ph
45  %r.022 = phi i16* [ undef, %for.body.lr.ph ], [ %r.1.lcssa, %for.cond.loopexit ]
46  %a.021 = phi i8* [ undef, %for.body.lr.ph ], [ %a.1.lcssa, %for.cond.loopexit ]
47  %tmp2 = load i32, i32* @c, align 4
48  %tobool215 = icmp eq i32 %tmp2, 0
49  br i1 %tobool215, label %for.cond.loopexit, label %for.body3.lr.ph
50
51for.body3.lr.ph:                                  ; preds = %for.body
52  br label %for.body3
53
54for.body3:                                        ; preds = %for.inc, %for.body3.lr.ph
55  %dec18.in = phi i32 [ %tmp2, %for.body3.lr.ph ], [ %dec18, %for.inc ]
56  %r.117 = phi i16* [ %r.022, %for.body3.lr.ph ], [ %add.ptr, %for.inc ]
57  %a.116 = phi i8* [ %a.021, %for.body3.lr.ph ], [ %incdec.ptr, %for.inc ]
58  %dec18 = add nsw i32 %dec18.in, -1
59  %tmp3 = load i8, i8* %a.116, align 1
60  %cmp = icmp eq i8 %tmp3, 0
61  br i1 %cmp, label %if.then, label %for.inc
62
63if.then:                                          ; preds = %for.body3
64  %arrayidx = getelementptr inbounds i16, i16* %r.117, i64 1
65  store i16 0, i16* %arrayidx, align 2
66  store i16 0, i16* %r.117, align 2
67  %arrayidx5 = getelementptr inbounds i16, i16* %r.117, i64 2
68  store i16 0, i16* %arrayidx5, align 2
69  br label %for.inc
70
71for.inc:                                          ; preds = %if.then, %for.body3
72  %incdec.ptr = getelementptr inbounds i8, i8* %a.116, i64 1
73  %add.ptr = getelementptr inbounds i16, i16* %r.117, i64 3
74  %tobool2 = icmp eq i32 %dec18, 0
75  br i1 %tobool2, label %for.cond1.for.cond.loopexit_crit_edge, label %for.body3, !llvm.loop !0
76
77for.cond.for.end6_crit_edge:                      ; preds = %for.cond.loopexit
78  br label %for.end6
79
80for.end6:                                         ; preds = %for.cond.for.end6_crit_edge, %entry
81  ret void
82}
83
84!0 = !{!0, !1}
85!1 = !{!"llvm.loop.unroll.count", i32 2}
86