HELLO·Android
系统源代码
IT资讯
技术文章
我的收藏
注册
登录
-
我收藏的文章
创建代码块
我的代码块
我的账号
Android 10
|
10.0.0_r6
下载
查看原文件
收藏
根目录
art
test
679-checker-minmax
src
Main.java
/* * Copyright (C) 2018 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * Functional tests for detecting min/max. */ public class Main { // // Direct intrinsics. // /// CHECK-START: int Main.minI(int) instruction_simplifier (before) /// CHECK-DAG: <
> ParameterValue /// CHECK-DAG: <
> IntConstant 20 /// CHECK-DAG: <
> InvokeStaticOrDirect [<
>,<
>] intrinsic:MathMinIntInt /// CHECK-DAG: Return [<
>] // /// CHECK-START: int Main.minI(int) instruction_simplifier (after) /// CHECK-DAG: <
> ParameterValue /// CHECK-DAG: <
> IntConstant 20 /// CHECK-DAG: <
> Min [<
>,<
>] /// CHECK-DAG: Return [<
>] // /// CHECK-START: int Main.minI(int) instruction_simplifier (after) /// CHECK-NOT: InvokeStaticOrDirect // /// CHECK-START-ARM64: int Main.minI(int) disassembly (after) /// CHECK-NOT: mov {{w\d+}}, #0x14 /// CHECK: cmp {{w\d+}}, #0x14 // Check that the constant generation was handled by VIXL. /// CHECK: mov w16, #0x14 /// CHECK: csel {{w\d+}}, {{w\d+}}, w16, lt public static int minI(int a) { return Math.min(a, 20); } /// CHECK-START: long Main.minL(long) instruction_simplifier (before) /// CHECK-DAG: <
> ParameterValue /// CHECK-DAG: <
> LongConstant 20 /// CHECK-DAG: <
> InvokeStaticOrDirect [<
>,<
>] intrinsic:MathMinLongLong /// CHECK-DAG: Return [<
>] // /// CHECK-START: long Main.minL(long) instruction_simplifier (after) /// CHECK-DAG: <
> ParameterValue /// CHECK-DAG: <
> LongConstant 20 /// CHECK-DAG: <
> Min [<
>,<
>] /// CHECK-DAG: Return [<
>] // /// CHECK-START: long Main.minL(long) instruction_simplifier (after) /// CHECK-NOT: InvokeStaticOrDirect // /// CHECK-START-ARM64: long Main.minL(long) disassembly (after) /// CHECK-NOT: mov {{x\d+}}, #0x14 /// CHECK: cmp {{x\d+}}, #0x14 // Check that the constant generation was handled by VIXL. /// CHECK: mov x16, #0x14 /// CHECK: csel {{x\d+}}, {{x\d+}}, x16, lt public static long minL(long a) { return Math.min(a, 20L); } /// CHECK-START: int Main.maxI(int) instruction_simplifier (before) /// CHECK-DAG: <
> ParameterValue /// CHECK-DAG: <
> IntConstant 20 /// CHECK-DAG: <
> InvokeStaticOrDirect [<
>,<
>] intrinsic:MathMaxIntInt /// CHECK-DAG: Return [<
>] // /// CHECK-START: int Main.maxI(int) instruction_simplifier (after) /// CHECK-DAG: <
> ParameterValue /// CHECK-DAG: <
> IntConstant 20 /// CHECK-DAG: <
> Max [<
>,<
>] /// CHECK-DAG: Return [<
>] // /// CHECK-START: int Main.maxI(int) instruction_simplifier (after) /// CHECK-NOT: InvokeStaticOrDirect // /// CHECK-START-ARM64: int Main.maxI(int) disassembly (after) /// CHECK-NOT: mov {{w\d+}}, #0x14 /// CHECK: cmp {{w\d+}}, #0x14 // Check that the constant generation was handled by VIXL. /// CHECK: mov w16, #0x14 /// CHECK: csel {{w\d+}}, {{w\d+}}, w16, gt public static int maxI(int a) { return Math.max(a, 20); } /// CHECK-START: long Main.maxL(long) instruction_simplifier (before) /// CHECK-DAG: <
> ParameterValue /// CHECK-DAG: <
> LongConstant 20 /// CHECK-DAG: <
> InvokeStaticOrDirect [<
>,<
>] intrinsic:MathMaxLongLong /// CHECK-DAG: Return [<
>] // /// CHECK-START: long Main.maxL(long) instruction_simplifier (after) /// CHECK-DAG: <
> ParameterValue /// CHECK-DAG: <
> LongConstant 20 /// CHECK-DAG: <
> Max [<
>,<
>] /// CHECK-DAG: Return [<
>] // /// CHECK-START: long Main.maxL(long) instruction_simplifier (after) /// CHECK-NOT: InvokeStaticOrDirect // /// CHECK-START-ARM64: long Main.maxL(long) disassembly (after) /// CHECK-NOT: mov {{x\d+}}, #0x14 /// CHECK: cmp {{x\d+}}, #0x14 // Check that the constant generation was handled by VIXL. /// CHECK: mov x16, #0x14 /// CHECK: csel {{x\d+}}, {{x\d+}}, x16, gt public static long maxL(long a) { return Math.max(a, 20L); } // // Special Cases // /// CHECK-START-ARM64: int Main.minIntConstantZero(int) disassembly (after) /// CHECK-NOT: InvokeStaticOrDirect /// CHECK-NOT: mov {{w\d+}}, #0x0 /// CHECK: cmp {{w\d+}}, #0x0 (0) /// CHECK: csel {{w\d+}}, {{w\d+}}, wzr, lt /// CHECK: ret public static int minIntConstantZero(int a) { return Math.min(a, 0); } /// CHECK-START-ARM64: int Main.minIntConstantOne(int) disassembly (after) /// CHECK-NOT: InvokeStaticOrDirect /// CHECK-NOT: mov {{w\d+}}, #0x1 /// CHECK: cmp {{w\d+}}, #0x1 (1) /// CHECK: csinc {{w\d+}}, {{w\d+}}, wzr, lt /// CHECK: ret public static int minIntConstantOne(int a) { return Math.min(a, 1); } /// CHECK-START-ARM64: int Main.minIntConstantMinusOne(int) disassembly (after) /// CHECK-NOT: InvokeStaticOrDirect /// CHECK-NOT: mov {{w\d+}}, #0xffffffff /// CHECK: cmn {{w\d+}}, #0x1 (1) /// CHECK: csinv {{w\d+}}, {{w\d+}}, wzr, lt /// CHECK: ret public static int minIntConstantMinusOne(int a) { return Math.min(a, -1); } /// CHECK-START-ARM64: long Main.minLongConstantZero(long) disassembly (after) /// CHECK-NOT: InvokeStaticOrDirect /// CHECK-NOT: mov {{x\d+}}, #0x0 /// CHECK: cmp {{x\d+}}, #0x0 (0) /// CHECK: csel {{x\d+}}, {{x\d+}}, xzr, lt /// CHECK: ret public static long minLongConstantZero(long a) { return Math.min(a, 0L); } /// CHECK-START-ARM64: long Main.minLongConstantOne(long) disassembly (after) /// CHECK-NOT: InvokeStaticOrDirect /// CHECK-NOT: mov {{x\d+}}, #0x1 /// CHECK: cmp {{x\d+}}, #0x1 (1) /// CHECK: csinc {{x\d+}}, {{x\d+}}, xzr, lt /// CHECK: ret public static long minLongConstantOne(long a) { return Math.min(a, 1L); } /// CHECK-START-ARM64: long Main.minLongConstantMinusOne(long) disassembly (after) /// CHECK-NOT: InvokeStaticOrDirect /// CHECK-NOT: mov {{x\d+}}, #0xffffffffffffffff /// CHECK: cmn {{x\d+}}, #0x1 (1) /// CHECK: csinv {{x\d+}}, {{x\d+}}, xzr, lt /// CHECK: ret public static long minLongConstantMinusOne(long a) { return Math.min(a, -1L); } /// CHECK-START-ARM64: int Main.maxIntConstantZero(int) disassembly (after) /// CHECK-NOT: InvokeStaticOrDirect /// CHECK-NOT: mov {{w\d+}}, #0x0 /// CHECK: cmp {{w\d+}}, #0x0 (0) /// CHECK: csel {{w\d+}}, {{w\d+}}, wzr, gt /// CHECK: ret public static int maxIntConstantZero(int a) { return Math.max(a, 0); } /// CHECK-START-ARM64: int Main.maxIntConstantOne(int) disassembly (after) /// CHECK-NOT: InvokeStaticOrDirect /// CHECK-NOT: mov {{w\d+}}, #0x1 /// CHECK: cmp {{w\d+}}, #0x1 (1) /// CHECK: csinc {{w\d+}}, {{w\d+}}, wzr, gt /// CHECK: ret public static int maxIntConstantOne(int a) { return Math.max(a, 1); } /// CHECK-START-ARM64: int Main.maxIntConstantMinusOne(int) disassembly (after) /// CHECK-NOT: InvokeStaticOrDirect /// CHECK-NOT: mov {{w\d+}}, #0xffffffff /// CHECK: cmn {{w\d+}}, #0x1 (1) /// CHECK: csinv {{w\d+}}, {{w\d+}}, wzr, gt /// CHECK: ret public static int maxIntConstantMinusOne(int a) { return Math.max(a, -1); } /// CHECK-START-ARM64: int Main.maxIntLargeConstant(int) disassembly (after) /// CHECK-NOT: InvokeStaticOrDirect /// CHECK: mov {{w\d+}}, #0x2001 /// CHECK: cmp {{w\d+}}, {{w\d+}} // Check that constant generation was not handled by VIXL. /// CHECK-NOT: mov {{w\d+}}, #0x2001 /// CHECK: csel {{w\d+}}, {{w\d+}}, {{w\d+}}, gt /// CHECK: ret public static int maxIntLargeConstant(int a) { return Math.max(a, 8193); } /// CHECK-START-ARM64: long Main.maxLongConstantZero(long) disassembly (after) /// CHECK-NOT: InvokeStaticOrDirect /// CHECK-NOT: mov {{x\d+}}, #0x0 /// CHECK: cmp {{x\d+}}, #0x0 (0) /// CHECK: csel {{x\d+}}, {{x\d+}}, xzr, gt /// CHECK: ret public static long maxLongConstantZero(long a) { return Math.max(a, 0L); } /// CHECK-START-ARM64: long Main.maxLongConstantOne(long) disassembly (after) /// CHECK-NOT: InvokeStaticOrDirect /// CHECK-NOT: mov {{x\d+}}, #0x1 /// CHECK: cmp {{x\d+}}, #0x1 (1) /// CHECK: csinc {{x\d+}}, {{x\d+}}, xzr, gt /// CHECK: ret public static long maxLongConstantOne(long a) { return Math.max(a, 1L); } /// CHECK-START-ARM64: long Main.maxLongConstantMinusOne(long) disassembly (after) /// CHECK-NOT: InvokeStaticOrDirect /// CHECK-NOT: mov {{x\d+}}, #0xffffffffffffffff /// CHECK: cmn {{x\d+}}, #0x1 (1) /// CHECK: csinv {{x\d+}}, {{x\d+}}, xzr, gt /// CHECK: ret public static long maxLongConstantMinusOne(long a) { return Math.max(a, -1L); } /// CHECK-START-ARM64: long Main.maxLongLargeConstant(long) disassembly (after) /// CHECK-NOT: InvokeStaticOrDirect /// CHECK: mov {{x\d+}}, #0x2001 /// CHECK: cmp {{x\d+}}, {{x\d+}} // Check that constant generation was not handled by VIXL. /// CHECK-NOT: mov {{x\d+}}, #0x2001 /// CHECK: csel {{x\d+}}, {{x\d+}}, {{x\d+}}, gt /// CHECK: ret public static long maxLongLargeConstant(long a) { return Math.max(a, 8193L); } // // Different types. // /// CHECK-START: int Main.min1(int, int) instruction_simplifier$after_gvn (before) /// CHECK-DAG: <
> GreaterThanOrEqual [<
>,<
>] /// CHECK-DAG: <
> Select [<
>,<
>,<
>] /// CHECK-DAG: Return [<
>] // /// CHECK-START: int Main.min1(int, int) instruction_simplifier$after_gvn (after) /// CHECK-DAG: <
> Min /// CHECK-DAG: Return [<
>] // /// CHECK-START: int Main.min1(int, int) instruction_simplifier$after_gvn (after) /// CHECK-NOT: Select public static int min1(int a, int b) { return a < b ? a : b; } /// CHECK-START: int Main.min2(int, int) instruction_simplifier$after_gvn (before) /// CHECK-DAG: <
> GreaterThan [<
>,<
>] /// CHECK-DAG: <
> Select [<
>,<
>,<
>] /// CHECK-DAG: Return [<
>] // /// CHECK-START: int Main.min2(int, int) instruction_simplifier$after_gvn (after) /// CHECK-DAG: <
> Min /// CHECK-DAG: Return [<
>] // /// CHECK-START: int Main.min2(int, int) instruction_simplifier$after_gvn (after) /// CHECK-NOT: Select public static int min2(int a, int b) { return a <= b ? a : b; } /// CHECK-START: int Main.min3(int, int) instruction_simplifier$after_gvn (before) /// CHECK-DAG: <
> LessThanOrEqual [<
>,<
>] /// CHECK-DAG: <
> Select [<
>,<
>,<
>] /// CHECK-DAG: Return [<
>] // /// CHECK-START: int Main.min3(int, int) instruction_simplifier$after_gvn (after) /// CHECK-DAG: <
> Min /// CHECK-DAG: Return [<
>] // /// CHECK-START: int Main.min3(int, int) instruction_simplifier$after_gvn (after) /// CHECK-NOT: Select public static int min3(int a, int b) { return a > b ? b : a; } /// CHECK-START: int Main.min4(int, int) instruction_simplifier$after_gvn (before) /// CHECK-DAG: <
> LessThan [<
>,<
>] /// CHECK-DAG: <
> Select [<
>,<
>,<
>] /// CHECK-DAG: Return [<
>] // /// CHECK-START: int Main.min4(int, int) instruction_simplifier$after_gvn (after) /// CHECK-DAG: <
> Min /// CHECK-DAG: Return [<
>] // /// CHECK-START: int Main.min4(int, int) instruction_simplifier$after_gvn (after) /// CHECK-NOT: Select public static int min4(int a, int b) { return a >= b ? b : a; } /// CHECK-START: int Main.min5(short, short) instruction_simplifier$after_gvn (before) /// CHECK-DAG: <
> LessThan [<
>,<
>] /// CHECK-DAG: <
> Select [<
>,<
>,<
>] /// CHECK-DAG: Return [<
>] // /// CHECK-START: int Main.min5(short, short) instruction_simplifier$after_gvn (after) /// CHECK-DAG: <
> Min /// CHECK-DAG: Return [<
>] // /// CHECK-START: int Main.min5(short, short) instruction_simplifier$after_gvn (after) /// CHECK-NOT: Select public static int min5(short a, short b) { return a >= b ? b : a; } /// CHECK-START: int Main.min6(byte, byte) instruction_simplifier$after_gvn (before) /// CHECK-DAG: <
> LessThan [<
>,<
>] /// CHECK-DAG: <
> Select [<
>,<
>,<
>] /// CHECK-DAG: Return [<
>] // /// CHECK-START: int Main.min6(byte, byte) instruction_simplifier$after_gvn (after) /// CHECK-DAG: <
> Min /// CHECK-DAG: Return [<
>] // /// CHECK-START: int Main.min6(byte, byte) instruction_simplifier$after_gvn (after) /// CHECK-NOT: Select public static int min6(byte a, byte b) { return a >= b ? b : a; } /// CHECK-START: long Main.min7(long, long) instruction_simplifier$after_gvn (before) /// CHECK-DAG: <
> LessThan [<
>,<
>] /// CHECK-DAG: <
> Select [<
>,<
>,<
>] /// CHECK-DAG: Return [<
>] // /// CHECK-START: long Main.min7(long, long) instruction_simplifier$after_gvn (after) /// CHECK-DAG: <
> Min /// CHECK-DAG: Return [<
>] // /// CHECK-START: long Main.min7(long, long) instruction_simplifier$after_gvn (after) /// CHECK-NOT: Select public static long min7(long a, long b) { return a >= b ? b : a; } /// CHECK-START: int Main.max1(int, int) instruction_simplifier$after_gvn (before) /// CHECK-DAG: <
> GreaterThanOrEqual [<
>,<
>] /// CHECK-DAG: <
> Select [<
>,<
>,<
>] /// CHECK-DAG: Return [<
>] // /// CHECK-START: int Main.max1(int, int) instruction_simplifier$after_gvn (after) /// CHECK-DAG: <
> Max /// CHECK-DAG: Return [<
>] // /// CHECK-START: int Main.max1(int, int) instruction_simplifier$after_gvn (after) /// CHECK-NOT: Select public static int max1(int a, int b) { return a < b ? b : a; } /// CHECK-START: int Main.max2(int, int) instruction_simplifier$after_gvn (before) /// CHECK-DAG: <
> GreaterThan [<
>,<
>] /// CHECK-DAG: <
> Select [<
>,<
>,<
>] /// CHECK-DAG: Return [<
>] // /// CHECK-START: int Main.max2(int, int) instruction_simplifier$after_gvn (after) /// CHECK-DAG: <
> Max /// CHECK-DAG: Return [<
>] // /// CHECK-START: int Main.max2(int, int) instruction_simplifier$after_gvn (after) /// CHECK-NOT: Select public static int max2(int a, int b) { return a <= b ? b : a; } /// CHECK-START: int Main.max3(int, int) instruction_simplifier$after_gvn (before) /// CHECK-DAG: <
> LessThanOrEqual [<
>,<
>] /// CHECK-DAG: <
> Select [<
>,<
>,<
>] /// CHECK-DAG: Return [<
>] // /// CHECK-START: int Main.max3(int, int) instruction_simplifier$after_gvn (after) /// CHECK-DAG: <
> Max /// CHECK-DAG: Return [<
>] // /// CHECK-START: int Main.max3(int, int) instruction_simplifier$after_gvn (after) /// CHECK-NOT: Select public static int max3(int a, int b) { return a > b ? a : b; } /// CHECK-START: int Main.max4(int, int) instruction_simplifier$after_gvn (before) /// CHECK-DAG: <
> LessThan [<
>,<
>] /// CHECK-DAG: <
> Select [<
>,<
>,<
>] /// CHECK-DAG: Return [<
>] // /// CHECK-START: int Main.max4(int, int) instruction_simplifier$after_gvn (after) /// CHECK-DAG: <
> Max /// CHECK-DAG: Return [<
>] // /// CHECK-START: int Main.max4(int, int) instruction_simplifier$after_gvn (after) /// CHECK-NOT: Select public static int max4(int a, int b) { return a >= b ? a : b; } /// CHECK-START: int Main.max5(short, short) instruction_simplifier$after_gvn (before) /// CHECK-DAG: <
> LessThan [<
>,<
>] /// CHECK-DAG: <
> Select [<
>,<
>,<
>] /// CHECK-DAG: Return [<
>] // /// CHECK-START: int Main.max5(short, short) instruction_simplifier$after_gvn (after) /// CHECK-DAG: <
> Max /// CHECK-DAG: Return [<
>] // /// CHECK-START: int Main.max5(short, short) instruction_simplifier$after_gvn (after) /// CHECK-NOT: Select public static int max5(short a, short b) { return a >= b ? a : b; } /// CHECK-START: int Main.max6(byte, byte) instruction_simplifier$after_gvn (before) /// CHECK-DAG: <
> LessThan [<
>,<
>] /// CHECK-DAG: <
> Select [<
>,<
>,<
>] /// CHECK-DAG: Return [<
>] // /// CHECK-START: int Main.max6(byte, byte) instruction_simplifier$after_gvn (after) /// CHECK-DAG: <
> Max /// CHECK-DAG: Return [<
>] // /// CHECK-START: int Main.max6(byte, byte) instruction_simplifier$after_gvn (after) /// CHECK-NOT: Select public static int max6(byte a, byte b) { return a >= b ? a : b; } /// CHECK-START: long Main.max7(long, long) instruction_simplifier$after_gvn (before) /// CHECK-DAG: <
> LessThan [<
>,<
>] /// CHECK-DAG: <
> Select [<
>,<
>,<
>] /// CHECK-DAG: Return [<
>] // /// CHECK-START: long Main.max7(long, long) instruction_simplifier$after_gvn (after) /// CHECK-DAG: <
> Max /// CHECK-DAG: Return [<
>] // /// CHECK-START: long Main.max7(long, long) instruction_simplifier$after_gvn (after) /// CHECK-NOT: Select public static long max7(long a, long b) { return a >= b ? a : b; } // // Complications. // /// CHECK-START: int Main.min0(int[], int[]) instruction_simplifier$after_gvn (before) /// CHECK-DAG: <
> ArrayGet [{{l\d+}},{{i\d+}}] /// CHECK-DAG: <
> ArrayGet [{{l\d+}},{{i\d+}}] /// CHECK-DAG: <
> GreaterThan [<
>,<
>] /// CHECK-DAG: <
> Select [<
>,<
>,<
>] /// CHECK-DAG: Return [<
>] // /// CHECK-START: int Main.min0(int[], int[]) instruction_simplifier$after_gvn (after) /// CHECK-DAG: <
> Min /// CHECK-DAG: Return [<
>] // /// CHECK-START: int Main.min0(int[], int[]) instruction_simplifier$after_gvn (after) /// CHECK-NOT: Select public static int min0(int[] a, int[] b) { // Repeat of array references needs finding the common subexpressions // prior to doing the select and min/max recognition. return a[0] <= b[0] ? a[0] : b[0]; } /// CHECK-START: int Main.max0(int[], int[]) instruction_simplifier$after_gvn (before) /// CHECK-DAG: <
> ArrayGet [{{l\d+}},{{i\d+}}] /// CHECK-DAG: <
> ArrayGet [{{l\d+}},{{i\d+}}] /// CHECK-DAG: <
> LessThan [<
>,<
>] /// CHECK-DAG: <
> Select [<
>,<
>,<
>] /// CHECK-DAG: Return [<
>] // /// CHECK-START: int Main.max0(int[], int[]) instruction_simplifier$after_gvn (after) /// CHECK-DAG: <
> Max /// CHECK-DAG: Return [<
>] // /// CHECK-START: int Main.max0(int[], int[]) instruction_simplifier$after_gvn (after) /// CHECK-NOT: Select public static int max0(int[] a, int[] b) { // Repeat of array references needs finding the common subexpressions // prior to doing the select and min/max recognition. return a[0] >= b[0] ? a[0] : b[0]; } /// CHECK-START: int Main.minmax1(int) instruction_simplifier$after_gvn (before) /// CHECK-DAG: <
> ParameterValue /// CHECK-DAG: <
> IntConstant 100 /// CHECK-DAG: <
> IntConstant -100 /// CHECK-DAG: <
> LessThanOrEqual [<
>,<
>] /// CHECK-DAG: <
> Select [<
>,<
>,<
>] /// CHECK-DAG: <
> GreaterThanOrEqual [<
>,<
>] /// CHECK-DAG: <
> Select [<
>,<
>,<
>] /// CHECK-DAG: Return [<
>] // /// CHECK-START: int Main.minmax1(int) instruction_simplifier$after_gvn (after) /// CHECK-DAG: <
> ParameterValue /// CHECK-DAG: <
> IntConstant 100 /// CHECK-DAG: <
> IntConstant -100 /// CHECK-DAG: <
> Min [<
>,<
>] /// CHECK-DAG: <
> Max [<
>,<
>] /// CHECK-DAG: Return [<
>] // /// CHECK-START: int Main.minmax1(int) instruction_simplifier$after_gvn (after) /// CHECK-NOT: Select public static int minmax1(int x) { // Simple if-if gives clean select sequence. if (x > 100) { x = 100; } if (x < -100) { x = -100; } return x; } /// CHECK-START: int Main.minmax2(int) instruction_simplifier$after_gvn (before) /// CHECK-DAG: <
> ParameterValue /// CHECK-DAG: <
> IntConstant 100 /// CHECK-DAG: <
> IntConstant -100 /// CHECK-DAG: <
> LessThanOrEqual [<
>,<
>] /// CHECK-DAG: <
> GreaterThanOrEqual [<
>,<
>] /// CHECK-DAG: <
> Select [<
>,<
>,<
>] /// CHECK-DAG: <