1# Copyright (C) 2017 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 LSmaliTests;
16.super Ljava/lang/Object;
17
18# A very particular set of operations that caused a double removal by the
19#  ARM64 simplifier doing "forward" removals (b/27851582).
20
21## CHECK-START-ARM: int SmaliTests.operations() instruction_simplifier_arm (before)
22## CHECK-DAG: <<Get:i\d+>> ArrayGet
23## CHECK-DAG: <<Not:i\d+>> Not [<<Get>>]
24## CHECK-DAG: <<Shl:i\d+>> Shl [<<Get>>,i{{\d+}}]
25## CHECK-DAG:              And [<<Not>>,<<Shl>>]
26
27## CHECK-START-ARM: int SmaliTests.operations() instruction_simplifier_arm (after)
28## CHECK-DAG: <<Get:i\d+>> ArrayGet
29## CHECK-DAG: <<Not:i\d+>> Not [<<Get>>]
30## CHECK-DAG:              DataProcWithShifterOp [<<Not>>,<<Get>>] kind:And+LSL shift:2
31
32## CHECK-START-ARM64: int SmaliTests.operations() instruction_simplifier_arm64 (before)
33## CHECK-DAG: <<Get:i\d+>> ArrayGet
34## CHECK-DAG: <<Not:i\d+>> Not [<<Get>>]
35## CHECK-DAG: <<Shl:i\d+>> Shl [<<Get>>,i{{\d+}}]
36## CHECK-DAG:              And [<<Not>>,<<Shl>>]
37
38## CHECK-START-ARM64: int SmaliTests.operations() instruction_simplifier_arm64 (after)
39## CHECK-DAG: <<Get:i\d+>> ArrayGet
40## CHECK-DAG: <<Not:i\d+>> Not [<<Get>>]
41## CHECK-DAG:              DataProcWithShifterOp [<<Not>>,<<Get>>] kind:And+LSL shift:2
42.method public static operations()I
43    .registers 6
44    .prologue
45
46    # int r = a[0];
47    sget-object v4, LMain;->a:[I
48    const/4 v5, 0x0
49    aget v2, v4, v5
50    # int n = ~r;
51    not-int v1, v2
52    # int s = r << 2;
53    shl-int/lit8 v3, v2, 0x2
54    # int a = s & n;
55    and-int v0, v3, v1
56    # return a
57    return v0
58.end method
59