1# Copyright (C) 2016 The Android Open Source Project
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#      http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15.class public LIrreducibleLoop;
16.super Ljava/lang/Object;
17
18# Test case in which `inner_back_edge` is not dominated by `inner_header` and
19# causes `outer_back_edge` to not be dominated by `outer_header`. HGraphBuilder
20# not do a fix-point iteration and would miss the path to `outer_back_edge`
21# through `inner_back_edge` and incorrectly label the outer loop non-irreducible.
22
23## CHECK-START: int IrreducibleLoop.dominance(int) builder (after)
24## CHECK:         Add irreducible:true
25
26.method public static dominance(I)I
27    .registers 2
28
29    if-eqz p0, :outer_header
30    goto :inner_back_edge
31
32    :outer_header
33    if-eqz p0, :inner_header
34
35    :outer_branch_exit
36    if-eqz p0, :outer_merge
37    return p0
38
39    :inner_header
40    goto :outer_merge
41
42    :inner_back_edge
43    goto :inner_header
44
45    :outer_merge
46    if-eqz p0, :inner_back_edge
47
48    :outer_back_edge
49    add-int/2addr p0, p0
50    goto :outer_header
51
52.end method
53