HELLO·Android
系统源代码
IT资讯
技术文章
我的收藏
注册
登录
-
我收藏的文章
创建代码块
我的代码块
我的账号
Android 10
|
10.0.0_r6
下载
查看原文件
收藏
根目录
art
test
646-checker-hadd-byte
src
Main.java
/* * Copyright (C) 2017 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. */ /** * Tests for halving-add idiomatic vectorization. */ public class Main { private static final int N = 256; private static final int M = N * N + 15; static byte[] sB1 = new byte[M]; static byte[] sB2 = new byte[M]; static byte[] sBo = new byte[M]; /// CHECK-START: void Main.halving_add_signed(byte[], byte[], byte[]) loop_optimization (before) /// CHECK-DAG: <
> IntConstant 1 loop:none /// CHECK-DAG: <
> Phi loop:<
> outer_loop:none /// CHECK-DAG: <
> ArrayGet loop:<
> outer_loop:none /// CHECK-DAG: <
> ArrayGet loop:<
> outer_loop:none /// CHECK-DAG: <
> Add [<
>,<
>] loop:<
> outer_loop:none /// CHECK-DAG: <
> Shr [<
>,<
>] loop:<
> outer_loop:none /// CHECK-DAG: <
> TypeConversion [<
>] loop:<
> outer_loop:none /// CHECK-DAG: ArraySet [{{l\d+}},<
>,<
>] loop:<
> outer_loop:none // /// CHECK-START-{ARM,ARM64,MIPS64}: void Main.halving_add_signed(byte[], byte[], byte[]) loop_optimization (after) /// CHECK-DAG: <
> VecLoad loop:<
> outer_loop:none /// CHECK-DAG: <
> VecLoad loop:<
> outer_loop:none /// CHECK-DAG: <
> VecHalvingAdd [<
>,<
>] packed_type:Int8 rounded:false loop:<
> outer_loop:none /// CHECK-DAG: VecStore [{{l\d+}},{{i\d+}},<
>] loop:<
> outer_loop:none private static void halving_add_signed(byte[] b1, byte[] b2, byte[] bo) { int min_length = Math.min(bo.length, Math.min(b1.length, b2.length)); for (int i = 0; i < min_length; i++) { bo[i] = (byte) ((b1[i] + b2[i]) >> 1); } } /// CHECK-START: void Main.halving_add_unsigned(byte[], byte[], byte[]) instruction_simplifier (before) /// CHECK-DAG: <
> IntConstant 1 loop:none /// CHECK-DAG: <
> IntConstant 255 loop:none /// CHECK-DAG: <
> Phi loop:<
> outer_loop:none /// CHECK-DAG: <
> ArrayGet loop:<
> outer_loop:none /// CHECK-DAG: <
> ArrayGet loop:<
> outer_loop:none /// CHECK-DAG: <
> And [<
>,<
>] loop:<
> outer_loop:none /// CHECK-DAG: <
> And [<
>,<
>] loop:<
> outer_loop:none /// CHECK-DAG: <
> Add [<
>,<
>] loop:<
> outer_loop:none /// CHECK-DAG: <
> Shr [<
>,<
>] loop:<
> outer_loop:none /// CHECK-DAG: <
> TypeConversion [<
>] loop:<
> outer_loop:none /// CHECK-DAG: ArraySet [{{l\d+}},{{i\d+}},<
>] loop:<
> outer_loop:none // /// CHECK-START: void Main.halving_add_unsigned(byte[], byte[], byte[]) loop_optimization (before) /// CHECK-DAG: <
> IntConstant 1 loop:none /// CHECK-DAG: <
> Phi loop:<
> outer_loop:none /// CHECK-DAG: <
> ArrayGet loop:<
> outer_loop:none /// CHECK-DAG: <
> ArrayGet loop:<
> outer_loop:none /// CHECK-DAG: <
> Add [<
>,<
>] loop:<
> outer_loop:none /// CHECK-DAG: <
> Shr [<
>,<
>] loop:<
> outer_loop:none /// CHECK-DAG: <
> TypeConversion [<
>] loop:<
> outer_loop:none /// CHECK-DAG: ArraySet [{{l\d+}},<
>,<
>] loop:<
> outer_loop:none // /// CHECK-START-{ARM,ARM64,MIPS64}: void Main.halving_add_unsigned(byte[], byte[], byte[]) loop_optimization (after) /// CHECK-DAG: <
> VecLoad loop:<
> outer_loop:none /// CHECK-DAG: <
> VecLoad loop:<
> outer_loop:none /// CHECK-DAG: <
> VecHalvingAdd [<
>,<
>] packed_type:Uint8 rounded:false loop:<
> outer_loop:none /// CHECK-DAG: VecStore [{{l\d+}},{{i\d+}},<
>] loop:<
> outer_loop:none private static void halving_add_unsigned(byte[] b1, byte[] b2, byte[] bo) { int min_length = Math.min(bo.length, Math.min(b1.length, b2.length)); for (int i = 0; i < min_length; i++) { bo[i] = (byte) (((b1[i] & 0xff) + (b2[i] & 0xff)) >> 1); } } /// CHECK-START: void Main.rounding_halving_add_signed(byte[], byte[], byte[]) loop_optimization (before) /// CHECK-DAG: <
> IntConstant 1 loop:none /// CHECK-DAG: <
> Phi loop:<
> outer_loop:none /// CHECK-DAG: <
> ArrayGet loop:<
> outer_loop:none /// CHECK-DAG: <
> ArrayGet loop:<
> outer_loop:none /// CHECK-DAG: <
> Add [<
>,<
>] loop:<
> outer_loop:none /// CHECK-DAG: <
> Add [<
>,<
>] loop:<
> outer_loop:none /// CHECK-DAG: <
> Shr [<
>,<
>] loop:<
> outer_loop:none /// CHECK-DAG: <
> TypeConversion [<
>] loop:<
> outer_loop:none /// CHECK-DAG: ArraySet [{{l\d+}},<
>,<
>] loop:<
> outer_loop:none // /// CHECK-START-{ARM,ARM64,MIPS64}: void Main.rounding_halving_add_signed(byte[], byte[], byte[]) loop_optimization (after) /// CHECK-DAG: <
> VecLoad loop:<
> outer_loop:none /// CHECK-DAG: <
> VecLoad loop:<
> outer_loop:none /// CHECK-DAG: <
> VecHalvingAdd [<
>,<
>] packed_type:Int8 rounded:true loop:<
> outer_loop:none /// CHECK-DAG: VecStore [{{l\d+}},{{i\d+}},<
>] loop:<
> outer_loop:none private static void rounding_halving_add_signed(byte[] b1, byte[] b2, byte[] bo) { int min_length = Math.min(bo.length, Math.min(b1.length, b2.length)); for (int i = 0; i < min_length; i++) { bo[i] = (byte) ((b1[i] + b2[i] + 1) >> 1); } } /// CHECK-START: void Main.rounding_halving_add_unsigned(byte[], byte[], byte[]) instruction_simplifier (before) /// CHECK-DAG: <
> IntConstant 1 loop:none /// CHECK-DAG: <
> IntConstant 255 loop:none /// CHECK-DAG: <
> Phi loop:<
> outer_loop:none /// CHECK-DAG: <
> ArrayGet loop:<
> outer_loop:none /// CHECK-DAG: <
> ArrayGet loop:<
> outer_loop:none /// CHECK-DAG: <
> And [<
>,<
>] loop:<
> outer_loop:none /// CHECK-DAG: <
> And [<
>,<
>] loop:<
> outer_loop:none /// CHECK-DAG: <
> Add [<
>,<
>] loop:<
> outer_loop:none /// CHECK-DAG: <
> Add [<
>,<
>] loop:<
> outer_loop:none /// CHECK-DAG: <
> Shr [<
>,<
>] loop:<
> outer_loop:none /// CHECK-DAG: <
> TypeConversion [<
>] loop:<
> outer_loop:none /// CHECK-DAG: ArraySet [{{l\d+}},{{i\d+}},<
>] loop:<
> outer_loop:none // /// CHECK-START: void Main.rounding_halving_add_unsigned(byte[], byte[], byte[]) loop_optimization (before) /// CHECK-DAG: <
> IntConstant 1 loop:none /// CHECK-DAG: <
> Phi loop:<
> outer_loop:none /// CHECK-DAG: <
> ArrayGet loop:<
> outer_loop:none /// CHECK-DAG: <
> ArrayGet loop:<
> outer_loop:none /// CHECK-DAG: <
> Add [<
>,<
>] loop:<
> outer_loop:none /// CHECK-DAG: <
> Add [<
>,<
>] loop:<
> outer_loop:none /// CHECK-DAG: <
> Shr [<
>,<
>] loop:<
> outer_loop:none /// CHECK-DAG: <
> TypeConversion [<
>] loop:<
> outer_loop:none /// CHECK-DAG: ArraySet [{{l\d+}},<
>,<
>] loop:<
> outer_loop:none // /// CHECK-START-{ARM,ARM64,MIPS64}: void Main.rounding_halving_add_unsigned(byte[], byte[], byte[]) loop_optimization (after) /// CHECK-DAG: <
> VecLoad loop:<
> outer_loop:none /// CHECK-DAG: <
> VecLoad loop:<
> outer_loop:none /// CHECK-DAG: <
> VecHalvingAdd [<
>,<
>] packed_type:Uint8 rounded:true loop:<
> outer_loop:none /// CHECK-DAG: VecStore [{{l\d+}},{{i\d+}},<
>] loop:<
> outer_loop:none private static void rounding_halving_add_unsigned(byte[] b1, byte[] b2, byte[] bo) { int min_length = Math.min(bo.length, Math.min(b1.length, b2.length)); for (int i = 0; i < min_length; i++) { bo[i] = (byte) (((b1[i] & 0xff) + (b2[i] & 0xff) + 1) >> 1); } } /// CHECK-START: void Main.halving_add_signed_constant(byte[], byte[]) loop_optimization (before) /// CHECK-DAG: <
> IntConstant 1 loop:none /// CHECK-DAG: <
> IntConstant 127 loop:none /// CHECK-DAG: <
> Phi loop:<
> outer_loop:none /// CHECK-DAG: <
> ArrayGet loop:<
> outer_loop:none /// CHECK-DAG: <
> Add [<
>,<
>] loop:<
> outer_loop:none /// CHECK-DAG: <
> Shr [<
>,<
>] loop:<
> outer_loop:none /// CHECK-DAG: <
> TypeConversion [<
>] loop:<
> outer_loop:none /// CHECK-DAG: ArraySet [{{l\d+}},<
>,<
>] loop:<
> outer_loop:none // /// CHECK-START-{ARM,ARM64,MIPS64}: void Main.halving_add_signed_constant(byte[], byte[]) loop_optimization (after) /// CHECK-DAG: <
> IntConstant 127 loop:none /// CHECK-DAG: <
> VecReplicateScalar [<
>] loop:none /// CHECK-DAG: <
> VecLoad loop:<
> outer_loop:none /// CHECK-DAG: <
> VecHalvingAdd [<
>,<
>] packed_type:Int8 rounded:false loop:<
> outer_loop:none /// CHECK-DAG: VecStore [{{l\d+}},{{i\d+}},<
>] loop:<
> outer_loop:none private static void halving_add_signed_constant(byte[] b1, byte[] bo) { int min_length = Math.min(bo.length, b1.length); for (int i = 0; i < min_length; i++) { bo[i] = (byte) ((b1[i] + 0x7f) >> 1); } } /// CHECK-START: void Main.halving_add_unsigned_constant(byte[], byte[]) instruction_simplifier (before) /// CHECK-DAG: <
> IntConstant 1 loop:none /// CHECK-DAG: <
> IntConstant 255 loop:none /// CHECK-DAG: <
> Phi loop:<
> outer_loop:none /// CHECK-DAG: <
> ArrayGet loop:<
> outer_loop:none /// CHECK-DAG: <
> And [<
>,<
>] loop:<
> outer_loop:none /// CHECK-DAG: <
> Add [<
>,<
>] loop:<
> outer_loop:none /// CHECK-DAG: <
> Shr [<
>,<
>] loop:<
> outer_loop:none /// CHECK-DAG: <
> TypeConversion [<
>] loop:<
> outer_loop:none /// CHECK-DAG: ArraySet [{{l\d+}},{{i\d+}},<
>] loop:<
> outer_loop:none // /// CHECK-START: void Main.halving_add_unsigned_constant(byte[], byte[]) loop_optimization (before) /// CHECK-DAG: <
> IntConstant 1 loop:none /// CHECK-DAG: <
> IntConstant 255 loop:none /// CHECK-DAG: <
> Phi loop:<
> outer_loop:none /// CHECK-DAG: <
> ArrayGet loop:<