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 LMain2;
16.super Ljava/lang/Object;
17
18## CHECK-START: int Main2.signBoolean(boolean) builder (after)
19## CHECK-DAG:     <<Zero:i\d+>>   IntConstant 0
20## CHECK-DAG:     <<One:i\d+>>    IntConstant 1
21## CHECK-DAG:     <<Phi:i\d+>>    Phi [<<One>>,<<Zero>>]
22## CHECK-DAG:     <<Result:i\d+>> InvokeStaticOrDirect [<<Phi>>{{(,[ij]\d+)?}}] intrinsic:IntegerSignum
23## CHECK-DAG:                     Return [<<Result>>]
24
25## CHECK-START: int Main2.signBoolean(boolean) instruction_simplifier (after)
26## CHECK-DAG:     <<Zero:i\d+>>   IntConstant 0
27## CHECK-DAG:     <<One:i\d+>>    IntConstant 1
28## CHECK-DAG:     <<Phi:i\d+>>    Phi [<<One>>,<<Zero>>]
29## CHECK-DAG:     <<Result:i\d+>> Compare [<<Phi>>,<<Zero>>]
30## CHECK-DAG:                     Return [<<Result>>]
31
32## CHECK-START: int Main2.signBoolean(boolean) instruction_simplifier (after)
33## CHECK-NOT:                     InvokeStaticOrDirect
34
35## CHECK-START: int Main2.signBoolean(boolean) select_generator (after)
36## CHECK-DAG:     <<Arg:z\d+>>    ParameterValue
37## CHECK-DAG:     <<Zero:i\d+>>   IntConstant 0
38## CHECK-DAG:     <<One:i\d+>>    IntConstant 1
39## CHECK-DAG:     <<Sel:i\d+>>    Select [<<Zero>>,<<One>>,<<Arg>>]
40## CHECK-DAG:     <<Result:i\d+>> Compare [<<Sel>>,<<Zero>>]
41## CHECK-DAG:                     Return [<<Result>>]
42
43## CHECK-START: int Main2.signBoolean(boolean) select_generator (after)
44## CHECK-NOT:                     Phi
45
46## CHECK-START: int Main2.signBoolean(boolean) instruction_simplifier$after_bce (after)
47## CHECK-DAG:     <<Arg:z\d+>>    ParameterValue
48## CHECK-DAG:     <<Zero:i\d+>>   IntConstant 0
49## CHECK-DAG:     <<Result:i\d+>> Compare [<<Arg>>,<<Zero>>]
50## CHECK-DAG:                     Return [<<Result>>]
51
52## CHECK-START: int Main2.signBoolean(boolean) instruction_simplifier$after_bce (after)
53## CHECK-NOT:                     Select
54
55# Original java source:
56#
57#     private static int signBoolean(boolean x) {
58#       return Integer.signum(x ? 1 : 0);
59#     }
60
61.method public static signBoolean(Z)I
62    .registers 2
63    .param p0, "x"    # Z
64
65    .prologue
66    .line 58
67    if-eqz p0, :cond_8
68
69    const/4 v0, 0x1
70
71    :goto_3
72    invoke-static {v0}, Ljava/lang/Integer;->signum(I)I
73
74    move-result v0
75
76    return v0
77
78    :cond_8
79    const/4 v0, 0x0
80
81    goto :goto_3
82.end method
83