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 where liveness analysis produces linear order where loop blocks are 19# not adjacent. 20 21## CHECK-START: int IrreducibleLoop.liveness(boolean, boolean, boolean, int) builder (after) 22## CHECK-DAG: Add loop:none 23## CHECK-DAG: Mul loop:<<Loop:B\d+>> 24## CHECK-DAG: Not loop:<<Loop>> 25 26## CHECK-START: int IrreducibleLoop.liveness(boolean, boolean, boolean, int) liveness (after) 27## CHECK-DAG: Add liveness:<<LPreEntry:\d+>> 28## CHECK-DAG: Mul liveness:<<LHeader:\d+>> 29## CHECK-DAG: Not liveness:<<LBackEdge:\d+>> 30## CHECK-EVAL: (<<LHeader>> < <<LPreEntry>>) and (<<LPreEntry>> < <<LBackEdge>>) 31 32.method public static liveness(ZZZI)I 33 .registers 10 34 const/16 v0, 42 35 36 if-eqz p0, :header 37 38 :pre_entry 39 add-int/2addr p3, p3 40 invoke-static {v0}, Ljava/lang/System;->exit(I)V 41 goto :body1 42 43 # Trivially dead code to ensure linear order verification skips removed blocks (b/28252537). 44 :dead_code 45 nop 46 goto :dead_code 47 48 :header 49 mul-int/2addr p3, p3 50 if-eqz p1, :body2 51 52 :body1 53 goto :body_merge 54 55 :body2 56 invoke-static {v0}, Ljava/lang/System;->exit(I)V 57 goto :body_merge 58 59 :body_merge 60 if-eqz p2, :exit 61 62 :back_edge 63 not-int p3, p3 64 goto :header 65 66 :exit 67 return p3 68 69.end method 70 71## CHECK-START: int IrreducibleLoop.liveness2(boolean, boolean, boolean, int) builder (after) 72## CHECK-DAG: Mul loop:<<Loop:B\d+>> 73## CHECK-DAG: Not loop:<<Loop>> 74 75## CHECK-START: int IrreducibleLoop.liveness2(boolean, boolean, boolean, int) liveness (after) 76## CHECK-DAG: Mul liveness:<<LPreEntry2:\d+>> 77## CHECK-DAG: Not liveness:<<LBackEdge1:\d+>> 78## CHECK-EVAL: <<LBackEdge1>> < <<LPreEntry2>> 79 80.method public liveness2(ZZZI)I 81 .registers 10 82 83 const v1, 1 84 85 :header1 86 if-eqz p0, :body1 87 88 :exit 89 return p3 90 91 :body1 92 # The test will generate an incorrect linear order when the following IF swaps 93 # its successors. To do that, load a boolean value and compare NotEqual to 1. 94 sget-boolean v2, LIrreducibleLoop;->f:Z 95 const v3, 1 96 if-ne v2, v3, :pre_header2 97 98 :pre_entry2 99 # This constant has a use in a phi in :back_edge2 and a back edge use in 100 # :back_edge1. Because the linear order is wrong, the back edge use has 101 # a lower liveness than the phi use. 102 const v0, 42 103 mul-int/2addr p3, p3 104 goto :back_edge2 105 106 :back_edge2 107 add-int/2addr p3, v0 108 add-int/2addr v0, v1 109 goto :header2 110 111 :header2 112 if-eqz p2, :back_edge2 113 114 :back_edge1 115 not-int p3, p3 116 goto :header1 117 118 :pre_header2 119 const v0, 42 120 goto :header2 121.end method 122 123.field public static f:Z 124