xref: /aosp_15_r20/external/llvm/test/Transforms/LoopDeletion/simplify-then-delete.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: opt < %s -S -indvars -loop-deletion -simplifycfg | FileCheck %s
2*9880d681SAndroid Build Coastguard Worker; PR5794
3*9880d681SAndroid Build Coastguard Worker
4*9880d681SAndroid Build Coastguard Worker; Indvars and loop deletion should be able to eliminate all looping
5*9880d681SAndroid Build Coastguard Worker; in this testcase.
6*9880d681SAndroid Build Coastguard Worker
7*9880d681SAndroid Build Coastguard Worker; CHECK:      define i32 @pmat(i32 %m, i32 %n, double* %y) #0 {
8*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: entry:
9*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT:   ret i32 0
10*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: }
11*9880d681SAndroid Build Coastguard Worker
12*9880d681SAndroid Build Coastguard Workertarget datalayout = "e-p:64:64:64"
13*9880d681SAndroid Build Coastguard Worker
14*9880d681SAndroid Build Coastguard Workerdefine i32 @pmat(i32 %m, i32 %n, double* %y) nounwind {
15*9880d681SAndroid Build Coastguard Workerentry:
16*9880d681SAndroid Build Coastguard Worker  %cmp4 = icmp sgt i32 %m, 0
17*9880d681SAndroid Build Coastguard Worker  br i1 %cmp4, label %bb.n10, label %w.e12
18*9880d681SAndroid Build Coastguard Worker
19*9880d681SAndroid Build Coastguard Workerw.c:
20*9880d681SAndroid Build Coastguard Worker  %cmp = icmp slt i32 %inc11, %m
21*9880d681SAndroid Build Coastguard Worker  br i1 %cmp, label %w.c2.p, label %w.c.w.e12c
22*9880d681SAndroid Build Coastguard Worker
23*9880d681SAndroid Build Coastguard Workerw.c.w.e12c:
24*9880d681SAndroid Build Coastguard Worker  br label %w.c.w.e12c.s
25*9880d681SAndroid Build Coastguard Worker
26*9880d681SAndroid Build Coastguard Workerw.c.w.e12c.s:
27*9880d681SAndroid Build Coastguard Worker  br label %w.e12
28*9880d681SAndroid Build Coastguard Worker
29*9880d681SAndroid Build Coastguard Workerbb.n10:
30*9880d681SAndroid Build Coastguard Worker  %cmp51 = icmp sgt i32 %n, 0
31*9880d681SAndroid Build Coastguard Worker  br i1 %cmp51, label %bb.n10.w.c.w.e12c.sc, label %bb.n10.bb.n10.sc
32*9880d681SAndroid Build Coastguard Worker
33*9880d681SAndroid Build Coastguard Workerbb.n10.bb.n10.sc:
34*9880d681SAndroid Build Coastguard Worker  br label %bb.n10.s
35*9880d681SAndroid Build Coastguard Worker
36*9880d681SAndroid Build Coastguard Workerbb.n10.w.c.w.e12c.sc:
37*9880d681SAndroid Build Coastguard Worker  br label %w.c.w.e12c.s
38*9880d681SAndroid Build Coastguard Worker
39*9880d681SAndroid Build Coastguard Workerbb.n10.s:
40*9880d681SAndroid Build Coastguard Worker  br label %w.c2.p
41*9880d681SAndroid Build Coastguard Worker
42*9880d681SAndroid Build Coastguard Workerw.c2.p:
43*9880d681SAndroid Build Coastguard Worker  %i.05 = phi i32 [ 0, %bb.n10.s ], [ %inc11, %w.c ]
44*9880d681SAndroid Build Coastguard Worker  br i1 false, label %bb.n, label %w.e
45*9880d681SAndroid Build Coastguard Worker
46*9880d681SAndroid Build Coastguard Workerw.c2:
47*9880d681SAndroid Build Coastguard Worker  br i1 undef, label %w.b6, label %w.c2.w.ec
48*9880d681SAndroid Build Coastguard Worker
49*9880d681SAndroid Build Coastguard Workerw.c2.w.ec:
50*9880d681SAndroid Build Coastguard Worker  br label %w.e
51*9880d681SAndroid Build Coastguard Worker
52*9880d681SAndroid Build Coastguard Workerbb.n:
53*9880d681SAndroid Build Coastguard Worker  br label %w.b6
54*9880d681SAndroid Build Coastguard Worker
55*9880d681SAndroid Build Coastguard Workerw.b6:
56*9880d681SAndroid Build Coastguard Worker  br label %w.c2
57*9880d681SAndroid Build Coastguard Worker
58*9880d681SAndroid Build Coastguard Workerw.e:
59*9880d681SAndroid Build Coastguard Worker  %i.08 = phi i32 [ undef, %w.c2.w.ec ], [ %i.05, %w.c2.p ]
60*9880d681SAndroid Build Coastguard Worker  %inc11 = add nsw i32 %i.08, 1
61*9880d681SAndroid Build Coastguard Worker  br label %w.c
62*9880d681SAndroid Build Coastguard Worker
63*9880d681SAndroid Build Coastguard Workerw.e12:
64*9880d681SAndroid Build Coastguard Worker  ret i32 0
65*9880d681SAndroid Build Coastguard Worker}
66*9880d681SAndroid Build Coastguard Worker
67*9880d681SAndroid Build Coastguard Worker; CHECK: attributes #0 = { nounwind }
68