• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2; RUN: opt -hardware-loops -S -verify-loop-lcssa %s | FileCheck %s
3
4target datalayout = "E-m:e-i64:64-n32:64"
5target triple = "ppc64-unknown-linux-elf"
6
7declare i1 @cond() readnone
8
9; Make sure we do not crash on the test.
10
11define void @test() {
12; CHECK-LABEL: @test(
13; CHECK-NEXT:  entry:
14; CHECK-NEXT:    br label [[WHILE_COND:%.*]]
15; CHECK:       while.cond:
16; CHECK-NEXT:    br label [[FOR_BODY:%.*]]
17; CHECK:       for.body:
18; CHECK-NEXT:    br label [[FOR_INC:%.*]]
19; CHECK:       for.inc:
20; CHECK-NEXT:    [[C_0:%.*]] = call i1 @cond()
21; CHECK-NEXT:    br i1 [[C_0]], label [[WHILE_COND25:%.*]], label [[FOR_BODY]]
22; CHECK:       while.cond25:
23; CHECK-NEXT:    [[INDVAR:%.*]] = phi i64 [ [[INDVAR_NEXT:%.*]], [[LAND_RHS:%.*]] ], [ 0, [[FOR_INC]] ]
24; CHECK-NEXT:    [[INDVARS_IV349:%.*]] = phi i64 [ [[INDVARS_IV_NEXT350:%.*]], [[LAND_RHS]] ], [ 50, [[FOR_INC]] ]
25; CHECK-NEXT:    [[CMP26_NOT:%.*]] = icmp eq i64 [[INDVARS_IV349]], 0
26; CHECK-NEXT:    br i1 [[CMP26_NOT]], label [[WHILE_END187:%.*]], label [[LAND_RHS]]
27; CHECK:       land.rhs:
28; CHECK-NEXT:    [[INDVARS_IV_NEXT350]] = add nsw i64 [[INDVARS_IV349]], -1
29; CHECK-NEXT:    [[C_1:%.*]] = call i1 @cond()
30; CHECK-NEXT:    [[INDVAR_NEXT]] = add i64 [[INDVAR]], 1
31; CHECK-NEXT:    br i1 [[C_1]], label [[WHILE_COND25]], label [[WHILE_END:%.*]]
32; CHECK:       while.end:
33; CHECK-NEXT:    [[INDVAR_LCSSA1:%.*]] = phi i64 [ [[INDVAR]], [[LAND_RHS]] ]
34; CHECK-NEXT:    [[C_2:%.*]] = call i1 @cond()
35; CHECK-NEXT:    br i1 [[C_2]], label [[WHILE_END187]], label [[WHILE_COND35_PREHEADER:%.*]]
36; CHECK:       while.cond35.preheader:
37; CHECK-NEXT:    [[TMP0:%.*]] = mul nsw i64 [[INDVAR_LCSSA1]], -1
38; CHECK-NEXT:    [[TMP1:%.*]] = add i64 [[TMP0]], 51
39; CHECK-NEXT:    call void @llvm.set.loop.iterations.i64(i64 [[TMP1]])
40; CHECK-NEXT:    br label [[WHILE_COND35:%.*]]
41; CHECK:       while.cond35:
42; CHECK-NEXT:    [[TMP2:%.*]] = call i1 @llvm.loop.decrement.i64(i64 1)
43; CHECK-NEXT:    br i1 [[TMP2]], label [[LAND_RHS37:%.*]], label [[IF_END51:%.*]]
44; CHECK:       land.rhs37:
45; CHECK-NEXT:    br label [[WHILE_COND35]]
46; CHECK:       if.end51:
47; CHECK-NEXT:    br label [[WHILE_COND_BACKEDGE:%.*]]
48; CHECK:       while.cond.backedge:
49; CHECK-NEXT:    br label [[WHILE_COND]]
50; CHECK:       while.end187:
51; CHECK-NEXT:    ret void
52;
53entry:
54  br label %while.cond
55
56while.cond:                                       ; preds = %while.cond.backedge, %entry
57  br label %for.body
58
59for.body:                                         ; preds = %for.inc, %while.cond
60  br label %for.inc
61
62for.inc:                                          ; preds = %for.body
63  %c.0 = call i1 @cond()
64  br i1 %c.0, label %while.cond25, label %for.body
65
66while.cond25:                                     ; preds = %land.rhs, %for.inc
67  %indvars.iv349 = phi i64 [ %indvars.iv.next350, %land.rhs ], [ 50, %for.inc ]
68  %cmp26.not = icmp eq i64 %indvars.iv349, 0
69  br i1 %cmp26.not, label %while.end187, label %land.rhs
70
71land.rhs:                                         ; preds = %while.cond25
72  %indvars.iv.next350 = add nsw i64 %indvars.iv349, -1
73  %c.1 = call i1 @cond()
74  br i1 %c.1, label %while.cond25, label %while.end
75
76while.end:                                        ; preds = %land.rhs
77  %c.2 = call i1 @cond()
78  br i1 %c.2, label %while.end187, label %while.cond35.preheader
79
80while.cond35.preheader:                           ; preds = %while.end
81  %0 = and i64 %indvars.iv349, 4294967295
82  br label %while.cond35
83
84while.cond35:                                     ; preds = %land.rhs37, %while.cond35.preheader
85  %indvars.iv351 = phi i64 [ %0, %while.cond35.preheader ], [ %indvars.iv.next352, %land.rhs37 ]
86  %cmp36 = icmp sgt i64 %indvars.iv351, 0
87  br i1 %cmp36, label %land.rhs37, label %if.end51
88
89land.rhs37:                                       ; preds = %while.cond35
90  %indvars.iv.next352 = add nsw i64 %indvars.iv351, -1
91  br label %while.cond35
92
93if.end51:                                         ; preds = %while.cond35
94  br label %while.cond.backedge
95
96while.cond.backedge:                              ; preds = %if.end51
97  br label %while.cond
98
99while.end187:                                     ; preds = %while.end, %while.cond25
100  ret void
101}
102