• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2016 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 public class Main {
18 
19   private static int[] a = { 10 };
20 
21   // A very particular set of operations that caused a double removal by the
22   // ARM64 simplifier doing "forward" removals (b/27851582).
23 
24   /// CHECK-START-ARM64: int Main.operations() instruction_simplifier_arm64 (before)
25   /// CHECK-DAG: <<Get:i\d+>> ArrayGet
26   /// CHECK-DAG: <<Not:i\d+>> Not [<<Get>>]
27   /// CHECK-DAG: <<Shl:i\d+>> Shl [<<Get>>,i{{\d+}}]
28   /// CHECK-DAG:              And [<<Not>>,<<Shl>>]
29   //
30   /// CHECK-START-ARM64: int Main.operations() instruction_simplifier_arm64 (after)
31   /// CHECK-DAG: <<Get:i\d+>> ArrayGet
32   /// CHECK-DAG: <<Not:i\d+>> Not [<<Get>>]
33   /// CHECK-DAG:              Arm64DataProcWithShifterOp [<<Not>>,<<Get>>] kind:And+LSL shift:2
operations()34   private static int operations() {
35      int r = a[0];
36      int n = ~r;
37      int s = r << 2;
38      int a = s & n;
39      return a;
40   }
41 
main(String[] args)42   public static void main(String[] args) {
43     if (operations() != 32) {
44       System.out.println("failed");
45     } else {
46       System.out.println("passed");
47     }
48   }
49 }
50