1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2; REQUIRES: asserts
3; RUN: opt -S -enable-loop-simplifycfg-term-folding=true -loop-simplifycfg -debug-only=loop-simplifycfg -verify-loop-info -verify-dom-info -verify-loop-lcssa 2>&1 < %s | FileCheck %s
4; RUN: opt -S -enable-loop-simplifycfg-term-folding=true -passes='require<domtree>,loop(loop-simplifycfg)' -debug-only=loop-simplifycfg -verify-loop-info -verify-dom-info -verify-loop-lcssa 2>&1 < %s | FileCheck %s
5; RUN: opt -S -enable-loop-simplifycfg-term-folding=true -loop-simplifycfg -enable-mssa-loop-dependency=true -verify-memoryssa -debug-only=loop-simplifycfg -verify-loop-info -verify-dom-info -verify-loop-lcssa 2>&1 < %s | FileCheck %s
6
7target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128-ni:1"
8
9; This test has irreducible CFG, and RPO may be the following:
10; Header, Dead, Irreducible2, Latch, Irreducible3, Irreducible1.
11; As result, we will process Irreducible2 before its predecessor Irreducible1.
12; The current algorithm gets confused in this case. We may support irreducible
13; CFG in the future.
14define void @irreducible_cfg(i1 %cond) {
15; CHECK-LABEL: @irreducible_cfg(
16; CHECK-NEXT:  entry:
17; CHECK-NEXT:    br label [[HEADER:%.*]]
18; CHECK:       header:
19; CHECK-NEXT:    br i1 false, label [[DEAD:%.*]], label [[IRREDUCIBLE1:%.*]]
20; CHECK:       dead:
21; CHECK-NEXT:    br label [[IRREDUCIBLE2:%.*]]
22; CHECK:       irreducible2:
23; CHECK-NEXT:    br i1 [[COND:%.*]], label [[LATCH:%.*]], label [[IRREDUCIBLE3:%.*]]
24; CHECK:       latch:
25; CHECK-NEXT:    br label [[HEADER]]
26; CHECK:       irreducible3:
27; CHECK-NEXT:    br label [[IRREDUCIBLE1]]
28; CHECK:       irreducible1:
29; CHECK-NEXT:    br label [[IRREDUCIBLE2]]
30;
31entry:
32  br label %header
33
34header:                                             ; preds = %latch, %entry
35  br i1 false, label %dead, label %irreducible1
36
37dead:                                          ; preds = %header
38  br label %irreducible2
39
40irreducible2:                                             ; preds = %irreducible1, %dead
41  br i1 %cond, label %latch, label %irreducible3
42
43latch:                                         ; preds = %irreducible2
44  br label %header
45
46irreducible3:                                           ; preds = %irreducible2
47  br label %irreducible1
48
49irreducible1:                                          ; preds = %irreducible3, %header
50  br label %irreducible2
51}
52