1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -loop-reduce %s -o - -S | FileCheck %s --check-prefix=LEGACYPM
3 ; RUN: opt -passes='loop(loop-reduce)' %s -o - -S | FileCheck %s --check-prefix=NEWPM
5 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
7 define dso_local i32 @test1() local_unnamed_addr {
8 ; LEGACYPM-LABEL: @test1(
9 ; LEGACYPM-NEXT: entry:
10 ; LEGACYPM-NEXT: br label [[FOR_COND:%.*]]
12 ; LEGACYPM-NEXT: callbr void asm sideeffect "", "!i,!i,~{dirflag},~{fpsr},~{flags}"()
13 ; LEGACYPM-NEXT: to label [[ASM_FALLTHROUGH_I_I:%.*]] [label [[COND_TRUE_I:%.*]], label %for.endsplit]
14 ; LEGACYPM: asm.fallthrough.i.i:
15 ; LEGACYPM-NEXT: unreachable
16 ; LEGACYPM: cond.true.i:
17 ; LEGACYPM-NEXT: br label [[DO_BODY_I_I_DO_BODY_I_I_CRIT_EDGE:%.*]]
18 ; LEGACYPM: do.body.i.i.do.body.i.i_crit_edge:
19 ; LEGACYPM-NEXT: br i1 true, label [[DO_BODY_I_I_RDRAND_INT_EXIT_I_CRIT_EDGE:%.*]], label [[DO_BODY_I_I_DO_BODY_I_I_CRIT_EDGE]]
20 ; LEGACYPM: do.body.i.i.rdrand_int.exit.i_crit_edge:
21 ; LEGACYPM-NEXT: br i1 true, label [[DO_BODY_I_I_RDRAND_INT_EXIT_I_CRIT_EDGE_FOR_END_CRIT_EDGE:%.*]], label [[FOR_INC:%.*]]
22 ; LEGACYPM: do.body.i.i.rdrand_int.exit.i_crit_edge.for.end_crit_edge:
23 ; LEGACYPM-NEXT: [[LSR_IV_NEXT_LCSSA_LCSSA:%.*]] = phi i64 [ undef, [[DO_BODY_I_I_RDRAND_INT_EXIT_I_CRIT_EDGE]] ]
24 ; LEGACYPM-NEXT: br label [[FOR_END:%.*]]
26 ; LEGACYPM-NEXT: br label [[FOR_COND]]
27 ; LEGACYPM: for.endsplit:
28 ; LEGACYPM-NEXT: br label [[FOR_END]]
30 ; LEGACYPM-NEXT: [[PGOCOUNT_PROMOTED24:%.*]] = phi i64 [ [[LSR_IV_NEXT_LCSSA_LCSSA]], [[DO_BODY_I_I_RDRAND_INT_EXIT_I_CRIT_EDGE_FOR_END_CRIT_EDGE]] ], [ undef, [[FOR_ENDSPLIT:%.*]] ]
31 ; LEGACYPM-NEXT: ret i32 undef
33 ; NEWPM-LABEL: @test1(
35 ; NEWPM-NEXT: br label [[FOR_COND:%.*]]
37 ; NEWPM-NEXT: callbr void asm sideeffect "", "!i,!i,~{dirflag},~{fpsr},~{flags}"()
38 ; NEWPM-NEXT: to label [[ASM_FALLTHROUGH_I_I:%.*]] [label [[COND_TRUE_I:%.*]], label %for.end]
39 ; NEWPM: asm.fallthrough.i.i:
40 ; NEWPM-NEXT: unreachable
42 ; NEWPM-NEXT: br label [[DO_BODY_I_I_DO_BODY_I_I_CRIT_EDGE:%.*]]
43 ; NEWPM: do.body.i.i.do.body.i.i_crit_edge:
44 ; NEWPM-NEXT: br i1 true, label [[DO_BODY_I_I_RDRAND_INT_EXIT_I_CRIT_EDGE:%.*]], label [[DO_BODY_I_I_DO_BODY_I_I_CRIT_EDGE]]
45 ; NEWPM: do.body.i.i.rdrand_int.exit.i_crit_edge:
46 ; NEWPM-NEXT: [[TMP0:%.*]] = add i64 1, undef
47 ; NEWPM-NEXT: br i1 true, label [[FOR_END:%.*]], label [[FOR_INC:%.*]]
49 ; NEWPM-NEXT: br label [[FOR_COND]]
51 ; NEWPM-NEXT: [[PGOCOUNT_PROMOTED24:%.*]] = phi i64 [ undef, [[FOR_COND]] ], [ [[TMP0]], [[DO_BODY_I_I_RDRAND_INT_EXIT_I_CRIT_EDGE]] ]
52 ; NEWPM-NEXT: ret i32 undef
57 for.cond: ; preds = %for.inc, %entry
58 ; It's ok to modify this test in the future should we be able to split critical
59 ; edges here, just noting that this is the critical edge that we care about.
60 callbr void asm sideeffect "", "!i,!i,~{dirflag},~{fpsr},~{flags}"()
61 to label %asm.fallthrough.i.i [label %cond.true.i, label %for.end]
63 asm.fallthrough.i.i: ; preds = %for.cond
66 cond.true.i: ; preds = %for.cond
67 br label %do.body.i.i.do.body.i.i_crit_edge
69 do.body.i.i.do.body.i.i_crit_edge: ; preds = %do.body.i.i.do.body.i.i_crit_edge, %cond.true.i
70 %pgocount711 = phi i64 [ %0, %do.body.i.i.do.body.i.i_crit_edge ], [ 0, %cond.true.i ]
71 %0 = add nuw nsw i64 %pgocount711, 1
72 br i1 undef, label %do.body.i.i.rdrand_int.exit.i_crit_edge, label %do.body.i.i.do.body.i.i_crit_edge
74 do.body.i.i.rdrand_int.exit.i_crit_edge: ; preds = %do.body.i.i.do.body.i.i_crit_edge
75 %1 = add i64 %0, undef
76 br i1 undef, label %for.end, label %for.inc
78 for.inc: ; preds = %do.body.i.i.rdrand_int.exit.i_crit_edge
81 for.end: ; preds = %do.body.i.i.rdrand_int.exit.i_crit_edge, %for.cond
82 %pgocount.promoted24 = phi i64 [ undef, %for.cond ], [ %1, %do.body.i.i.rdrand_int.exit.i_crit_edge ]