xref: /aosp_15_r20/art/test/593-checker-shift-and-simplifier/smali/SmaliTests.smali (revision 795d594fd825385562da6b089ea9b2033f3abf5a)
1*795d594fSAndroid Build Coastguard Worker# Copyright (C) 2017 The Android Open Source Project
2*795d594fSAndroid Build Coastguard Worker#
3*795d594fSAndroid Build Coastguard Worker# Licensed under the Apache License, Version 2.0 (the "License");
4*795d594fSAndroid Build Coastguard Worker# you may not use this file except in compliance with the License.
5*795d594fSAndroid Build Coastguard Worker# You may obtain a copy of the License at
6*795d594fSAndroid Build Coastguard Worker#
7*795d594fSAndroid Build Coastguard Worker#      http://www.apache.org/licenses/LICENSE-2.0
8*795d594fSAndroid Build Coastguard Worker#
9*795d594fSAndroid Build Coastguard Worker# Unless required by applicable law or agreed to in writing, software
10*795d594fSAndroid Build Coastguard Worker# distributed under the License is distributed on an "AS IS" BASIS,
11*795d594fSAndroid Build Coastguard Worker# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12*795d594fSAndroid Build Coastguard Worker# See the License for the specific language governing permissions and
13*795d594fSAndroid Build Coastguard Worker# limitations under the License.
14*795d594fSAndroid Build Coastguard Worker
15*795d594fSAndroid Build Coastguard Worker.class public LSmaliTests;
16*795d594fSAndroid Build Coastguard Worker.super Ljava/lang/Object;
17*795d594fSAndroid Build Coastguard Worker
18*795d594fSAndroid Build Coastguard Worker# A very particular set of operations that caused a double removal by the
19*795d594fSAndroid Build Coastguard Worker#  ARM64 simplifier doing "forward" removals (b/27851582).
20*795d594fSAndroid Build Coastguard Worker
21*795d594fSAndroid Build Coastguard Worker## CHECK-START-ARM: int SmaliTests.operations() instruction_simplifier_arm (before)
22*795d594fSAndroid Build Coastguard Worker## CHECK-DAG: <<Get:i\d+>> ArrayGet
23*795d594fSAndroid Build Coastguard Worker## CHECK-DAG: <<Not:i\d+>> Not [<<Get>>]
24*795d594fSAndroid Build Coastguard Worker## CHECK-DAG: <<Shl:i\d+>> Shl [<<Get>>,i{{\d+}}]
25*795d594fSAndroid Build Coastguard Worker## CHECK-DAG:              And [<<Not>>,<<Shl>>]
26*795d594fSAndroid Build Coastguard Worker
27*795d594fSAndroid Build Coastguard Worker## CHECK-START-ARM: int SmaliTests.operations() instruction_simplifier_arm (after)
28*795d594fSAndroid Build Coastguard Worker## CHECK-DAG: <<Get:i\d+>> ArrayGet
29*795d594fSAndroid Build Coastguard Worker## CHECK-DAG: <<Not:i\d+>> Not [<<Get>>]
30*795d594fSAndroid Build Coastguard Worker## CHECK-DAG:              DataProcWithShifterOp [<<Not>>,<<Get>>] kind:And+LSL shift:2
31*795d594fSAndroid Build Coastguard Worker
32*795d594fSAndroid Build Coastguard Worker## CHECK-START-ARM64: int SmaliTests.operations() instruction_simplifier_arm64 (before)
33*795d594fSAndroid Build Coastguard Worker## CHECK-DAG: <<Get:i\d+>> ArrayGet
34*795d594fSAndroid Build Coastguard Worker## CHECK-DAG: <<Not:i\d+>> Not [<<Get>>]
35*795d594fSAndroid Build Coastguard Worker## CHECK-DAG: <<Shl:i\d+>> Shl [<<Get>>,i{{\d+}}]
36*795d594fSAndroid Build Coastguard Worker## CHECK-DAG:              And [<<Not>>,<<Shl>>]
37*795d594fSAndroid Build Coastguard Worker
38*795d594fSAndroid Build Coastguard Worker## CHECK-START-ARM64: int SmaliTests.operations() instruction_simplifier_arm64 (after)
39*795d594fSAndroid Build Coastguard Worker## CHECK-DAG: <<Get:i\d+>> ArrayGet
40*795d594fSAndroid Build Coastguard Worker## CHECK-DAG: <<Not:i\d+>> Not [<<Get>>]
41*795d594fSAndroid Build Coastguard Worker## CHECK-DAG:              DataProcWithShifterOp [<<Not>>,<<Get>>] kind:And+LSL shift:2
42*795d594fSAndroid Build Coastguard Worker.method public static operations()I
43*795d594fSAndroid Build Coastguard Worker    .registers 6
44*795d594fSAndroid Build Coastguard Worker    .prologue
45*795d594fSAndroid Build Coastguard Worker
46*795d594fSAndroid Build Coastguard Worker    # int r = a[0];
47*795d594fSAndroid Build Coastguard Worker    sget-object v4, LMain;->a:[I
48*795d594fSAndroid Build Coastguard Worker    const/4 v5, 0x0
49*795d594fSAndroid Build Coastguard Worker    aget v2, v4, v5
50*795d594fSAndroid Build Coastguard Worker    # int n = ~r;
51*795d594fSAndroid Build Coastguard Worker    not-int v1, v2
52*795d594fSAndroid Build Coastguard Worker    # int s = r << 2;
53*795d594fSAndroid Build Coastguard Worker    shl-int/lit8 v3, v2, 0x2
54*795d594fSAndroid Build Coastguard Worker    # int a = s & n;
55*795d594fSAndroid Build Coastguard Worker    and-int v0, v3, v1
56*795d594fSAndroid Build Coastguard Worker    # return a
57*795d594fSAndroid Build Coastguard Worker    return v0
58*795d594fSAndroid Build Coastguard Worker.end method
59