Alexandre Rames | b2fd7bc | 2015-03-11 16:48:16 +0000 | [diff] [blame] | 1 | /* |
Roland Levillain | 6a92a03 | 2015-07-23 12:15:01 +0100 | [diff] [blame] | 2 | * Copyright (C) 2015 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 | */ |
Alexandre Rames | b2fd7bc | 2015-03-11 16:48:16 +0000 | [diff] [blame] | 16 | |
David Brazdil | f02c3cf | 2016-02-29 09:14:51 +0000 | [diff] [blame] | 17 | import java.lang.reflect.Method; |
| 18 | |
Alexandre Rames | b2fd7bc | 2015-03-11 16:48:16 +0000 | [diff] [blame] | 19 | public class Main { |
| 20 | |
David Brazdil | 0d13fee | 2015-04-17 14:52:19 +0100 | [diff] [blame] | 21 | public static void assertBooleanEquals(boolean expected, boolean result) { |
| 22 | if (expected != result) { |
| 23 | throw new Error("Expected: " + expected + ", found: " + result); |
| 24 | } |
| 25 | } |
| 26 | |
Alexandre Rames | b2fd7bc | 2015-03-11 16:48:16 +0000 | [diff] [blame] | 27 | public static void assertIntEquals(int expected, int result) { |
| 28 | if (expected != result) { |
| 29 | throw new Error("Expected: " + expected + ", found: " + result); |
| 30 | } |
| 31 | } |
| 32 | |
| 33 | public static void assertLongEquals(long expected, long result) { |
| 34 | if (expected != result) { |
| 35 | throw new Error("Expected: " + expected + ", found: " + result); |
| 36 | } |
| 37 | } |
| 38 | |
Nicolas Geoffray | 0d22184 | 2015-04-27 08:53:46 +0000 | [diff] [blame] | 39 | public static void assertFloatEquals(float expected, float result) { |
| 40 | if (expected != result) { |
| 41 | throw new Error("Expected: " + expected + ", found: " + result); |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | public static void assertDoubleEquals(double expected, double result) { |
| 46 | if (expected != result) { |
| 47 | throw new Error("Expected: " + expected + ", found: " + result); |
| 48 | } |
| 49 | } |
| 50 | |
Vladimir Marko | b52bbde | 2016-02-12 12:06:05 +0000 | [diff] [blame] | 51 | public static void assertStringEquals(String expected, String result) { |
| 52 | if (expected == null ? result != null : !expected.equals(result)) { |
| 53 | throw new Error("Expected: " + expected + ", found: " + result); |
| 54 | } |
| 55 | } |
| 56 | |
Alexandre Rames | b2fd7bc | 2015-03-11 16:48:16 +0000 | [diff] [blame] | 57 | /** |
| 58 | * Tiny programs exercising optimizations of arithmetic identities. |
| 59 | */ |
| 60 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 61 | /// CHECK-START: long Main.$noinline$Add0(long) instruction_simplifier (before) |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 62 | /// CHECK-DAG: <<Arg:j\d+>> ParameterValue |
| 63 | /// CHECK-DAG: <<Const0:j\d+>> LongConstant 0 |
| 64 | /// CHECK-DAG: <<Add:j\d+>> Add [<<Const0>>,<<Arg>>] |
| 65 | /// CHECK-DAG: Return [<<Add>>] |
Alexandre Rames | b2fd7bc | 2015-03-11 16:48:16 +0000 | [diff] [blame] | 66 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 67 | /// CHECK-START: long Main.$noinline$Add0(long) instruction_simplifier (after) |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 68 | /// CHECK-DAG: <<Arg:j\d+>> ParameterValue |
| 69 | /// CHECK-DAG: Return [<<Arg>>] |
David Brazdil | 0d13fee | 2015-04-17 14:52:19 +0100 | [diff] [blame] | 70 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 71 | /// CHECK-START: long Main.$noinline$Add0(long) instruction_simplifier (after) |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 72 | /// CHECK-NOT: Add |
Alexandre Rames | b2fd7bc | 2015-03-11 16:48:16 +0000 | [diff] [blame] | 73 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 74 | public static long $noinline$Add0(long arg) { |
Alexandre Rames | b2fd7bc | 2015-03-11 16:48:16 +0000 | [diff] [blame] | 75 | return 0 + arg; |
| 76 | } |
| 77 | |
Anton Kirilov | e14dc86 | 2016-05-13 17:56:15 +0100 | [diff] [blame] | 78 | /// CHECK-START: int Main.$noinline$AddAddSubAddConst(int) instruction_simplifier (before) |
| 79 | /// CHECK-DAG: <<ArgValue:i\d+>> ParameterValue |
| 80 | /// CHECK-DAG: <<Const1:i\d+>> IntConstant 1 |
| 81 | /// CHECK-DAG: <<Const2:i\d+>> IntConstant 2 |
| 82 | /// CHECK-DAG: <<ConstM3:i\d+>> IntConstant -3 |
| 83 | /// CHECK-DAG: <<Const4:i\d+>> IntConstant 4 |
| 84 | /// CHECK-DAG: <<Add1:i\d+>> Add [<<ArgValue>>,<<Const1>>] |
| 85 | /// CHECK-DAG: <<Add2:i\d+>> Add [<<Add1>>,<<Const2>>] |
| 86 | /// CHECK-DAG: <<Add3:i\d+>> Add [<<Add2>>,<<ConstM3>>] |
| 87 | /// CHECK-DAG: <<Add4:i\d+>> Add [<<Add3>>,<<Const4>>] |
| 88 | /// CHECK-DAG: Return [<<Add4>>] |
| 89 | |
| 90 | /// CHECK-START: int Main.$noinline$AddAddSubAddConst(int) instruction_simplifier (after) |
| 91 | /// CHECK-DAG: <<ArgValue:i\d+>> ParameterValue |
| 92 | /// CHECK-DAG: <<Const4:i\d+>> IntConstant 4 |
| 93 | /// CHECK-DAG: <<Add:i\d+>> Add [<<ArgValue>>,<<Const4>>] |
| 94 | /// CHECK-DAG: Return [<<Add>>] |
| 95 | |
| 96 | public static int $noinline$AddAddSubAddConst(int arg) { |
Anton Kirilov | e14dc86 | 2016-05-13 17:56:15 +0100 | [diff] [blame] | 97 | return arg + 1 + 2 - 3 + 4; |
| 98 | } |
| 99 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 100 | /// CHECK-START: int Main.$noinline$AndAllOnes(int) instruction_simplifier (before) |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 101 | /// CHECK-DAG: <<Arg:i\d+>> ParameterValue |
| 102 | /// CHECK-DAG: <<ConstF:i\d+>> IntConstant -1 |
| 103 | /// CHECK-DAG: <<And:i\d+>> And [<<Arg>>,<<ConstF>>] |
| 104 | /// CHECK-DAG: Return [<<And>>] |
Alexandre Rames | b2fd7bc | 2015-03-11 16:48:16 +0000 | [diff] [blame] | 105 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 106 | /// CHECK-START: int Main.$noinline$AndAllOnes(int) instruction_simplifier (after) |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 107 | /// CHECK-DAG: <<Arg:i\d+>> ParameterValue |
| 108 | /// CHECK-DAG: Return [<<Arg>>] |
Alexandre Rames | b2fd7bc | 2015-03-11 16:48:16 +0000 | [diff] [blame] | 109 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 110 | /// CHECK-START: int Main.$noinline$AndAllOnes(int) instruction_simplifier (after) |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 111 | /// CHECK-NOT: And |
Alexandre Rames | 7441769 | 2015-04-09 15:21:41 +0100 | [diff] [blame] | 112 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 113 | public static int $noinline$AndAllOnes(int arg) { |
Alexandre Rames | b2fd7bc | 2015-03-11 16:48:16 +0000 | [diff] [blame] | 114 | return arg & -1; |
| 115 | } |
| 116 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 117 | /// CHECK-START: int Main.$noinline$UShr28And15(int) instruction_simplifier (before) |
Vladimir Marko | 452c1b6 | 2015-09-25 14:44:17 +0100 | [diff] [blame] | 118 | /// CHECK-DAG: <<Arg:i\d+>> ParameterValue |
| 119 | /// CHECK-DAG: <<Const28:i\d+>> IntConstant 28 |
| 120 | /// CHECK-DAG: <<Const15:i\d+>> IntConstant 15 |
| 121 | /// CHECK-DAG: <<UShr:i\d+>> UShr [<<Arg>>,<<Const28>>] |
| 122 | /// CHECK-DAG: <<And:i\d+>> And [<<UShr>>,<<Const15>>] |
| 123 | /// CHECK-DAG: Return [<<And>>] |
| 124 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 125 | /// CHECK-START: int Main.$noinline$UShr28And15(int) instruction_simplifier (after) |
Vladimir Marko | 452c1b6 | 2015-09-25 14:44:17 +0100 | [diff] [blame] | 126 | /// CHECK-DAG: <<Arg:i\d+>> ParameterValue |
| 127 | /// CHECK-DAG: <<Const28:i\d+>> IntConstant 28 |
| 128 | /// CHECK-DAG: <<UShr:i\d+>> UShr [<<Arg>>,<<Const28>>] |
| 129 | /// CHECK-DAG: Return [<<UShr>>] |
| 130 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 131 | /// CHECK-START: int Main.$noinline$UShr28And15(int) instruction_simplifier (after) |
Vladimir Marko | 452c1b6 | 2015-09-25 14:44:17 +0100 | [diff] [blame] | 132 | /// CHECK-NOT: And |
| 133 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 134 | public static int $noinline$UShr28And15(int arg) { |
Vladimir Marko | 452c1b6 | 2015-09-25 14:44:17 +0100 | [diff] [blame] | 135 | return (arg >>> 28) & 15; |
| 136 | } |
| 137 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 138 | /// CHECK-START: long Main.$noinline$UShr60And15(long) instruction_simplifier (before) |
Vladimir Marko | 452c1b6 | 2015-09-25 14:44:17 +0100 | [diff] [blame] | 139 | /// CHECK-DAG: <<Arg:j\d+>> ParameterValue |
| 140 | /// CHECK-DAG: <<Const60:i\d+>> IntConstant 60 |
| 141 | /// CHECK-DAG: <<Const15:j\d+>> LongConstant 15 |
| 142 | /// CHECK-DAG: <<UShr:j\d+>> UShr [<<Arg>>,<<Const60>>] |
| 143 | /// CHECK-DAG: <<And:j\d+>> And [<<UShr>>,<<Const15>>] |
| 144 | /// CHECK-DAG: Return [<<And>>] |
| 145 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 146 | /// CHECK-START: long Main.$noinline$UShr60And15(long) instruction_simplifier (after) |
Vladimir Marko | 452c1b6 | 2015-09-25 14:44:17 +0100 | [diff] [blame] | 147 | /// CHECK-DAG: <<Arg:j\d+>> ParameterValue |
| 148 | /// CHECK-DAG: <<Const60:i\d+>> IntConstant 60 |
| 149 | /// CHECK-DAG: <<UShr:j\d+>> UShr [<<Arg>>,<<Const60>>] |
| 150 | /// CHECK-DAG: Return [<<UShr>>] |
| 151 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 152 | /// CHECK-START: long Main.$noinline$UShr60And15(long) instruction_simplifier (after) |
Vladimir Marko | 452c1b6 | 2015-09-25 14:44:17 +0100 | [diff] [blame] | 153 | /// CHECK-NOT: And |
| 154 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 155 | public static long $noinline$UShr60And15(long arg) { |
Vladimir Marko | 452c1b6 | 2015-09-25 14:44:17 +0100 | [diff] [blame] | 156 | return (arg >>> 60) & 15; |
| 157 | } |
| 158 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 159 | /// CHECK-START: int Main.$noinline$UShr28And7(int) instruction_simplifier (before) |
Vladimir Marko | 452c1b6 | 2015-09-25 14:44:17 +0100 | [diff] [blame] | 160 | /// CHECK-DAG: <<Arg:i\d+>> ParameterValue |
| 161 | /// CHECK-DAG: <<Const28:i\d+>> IntConstant 28 |
| 162 | /// CHECK-DAG: <<Const7:i\d+>> IntConstant 7 |
| 163 | /// CHECK-DAG: <<UShr:i\d+>> UShr [<<Arg>>,<<Const28>>] |
| 164 | /// CHECK-DAG: <<And:i\d+>> And [<<UShr>>,<<Const7>>] |
| 165 | /// CHECK-DAG: Return [<<And>>] |
| 166 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 167 | /// CHECK-START: int Main.$noinline$UShr28And7(int) instruction_simplifier (after) |
Vladimir Marko | 452c1b6 | 2015-09-25 14:44:17 +0100 | [diff] [blame] | 168 | /// CHECK-DAG: <<Arg:i\d+>> ParameterValue |
| 169 | /// CHECK-DAG: <<Const28:i\d+>> IntConstant 28 |
| 170 | /// CHECK-DAG: <<Const7:i\d+>> IntConstant 7 |
| 171 | /// CHECK-DAG: <<UShr:i\d+>> UShr [<<Arg>>,<<Const28>>] |
| 172 | /// CHECK-DAG: <<And:i\d+>> And [<<UShr>>,<<Const7>>] |
| 173 | /// CHECK-DAG: Return [<<And>>] |
| 174 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 175 | public static int $noinline$UShr28And7(int arg) { |
Vladimir Marko | 452c1b6 | 2015-09-25 14:44:17 +0100 | [diff] [blame] | 176 | return (arg >>> 28) & 7; |
| 177 | } |
| 178 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 179 | /// CHECK-START: long Main.$noinline$UShr60And7(long) instruction_simplifier (before) |
Vladimir Marko | 452c1b6 | 2015-09-25 14:44:17 +0100 | [diff] [blame] | 180 | /// CHECK-DAG: <<Arg:j\d+>> ParameterValue |
| 181 | /// CHECK-DAG: <<Const60:i\d+>> IntConstant 60 |
| 182 | /// CHECK-DAG: <<Const7:j\d+>> LongConstant 7 |
| 183 | /// CHECK-DAG: <<UShr:j\d+>> UShr [<<Arg>>,<<Const60>>] |
| 184 | /// CHECK-DAG: <<And:j\d+>> And [<<UShr>>,<<Const7>>] |
| 185 | /// CHECK-DAG: Return [<<And>>] |
| 186 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 187 | /// CHECK-START: long Main.$noinline$UShr60And7(long) instruction_simplifier (after) |
Vladimir Marko | 452c1b6 | 2015-09-25 14:44:17 +0100 | [diff] [blame] | 188 | /// CHECK-DAG: <<Arg:j\d+>> ParameterValue |
| 189 | /// CHECK-DAG: <<Const60:i\d+>> IntConstant 60 |
| 190 | /// CHECK-DAG: <<Const7:j\d+>> LongConstant 7 |
| 191 | /// CHECK-DAG: <<UShr:j\d+>> UShr [<<Arg>>,<<Const60>>] |
| 192 | /// CHECK-DAG: <<And:j\d+>> And [<<UShr>>,<<Const7>>] |
| 193 | /// CHECK-DAG: Return [<<And>>] |
| 194 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 195 | public static long $noinline$UShr60And7(long arg) { |
Vladimir Marko | 452c1b6 | 2015-09-25 14:44:17 +0100 | [diff] [blame] | 196 | return (arg >>> 60) & 7; |
| 197 | } |
| 198 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 199 | /// CHECK-START: int Main.$noinline$Shr24And255(int) instruction_simplifier (before) |
Vladimir Marko | 452c1b6 | 2015-09-25 14:44:17 +0100 | [diff] [blame] | 200 | /// CHECK-DAG: <<Arg:i\d+>> ParameterValue |
| 201 | /// CHECK-DAG: <<Const24:i\d+>> IntConstant 24 |
| 202 | /// CHECK-DAG: <<Const255:i\d+>> IntConstant 255 |
| 203 | /// CHECK-DAG: <<Shr:i\d+>> Shr [<<Arg>>,<<Const24>>] |
| 204 | /// CHECK-DAG: <<And:i\d+>> And [<<Shr>>,<<Const255>>] |
| 205 | /// CHECK-DAG: Return [<<And>>] |
| 206 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 207 | /// CHECK-START: int Main.$noinline$Shr24And255(int) instruction_simplifier (after) |
Vladimir Marko | 452c1b6 | 2015-09-25 14:44:17 +0100 | [diff] [blame] | 208 | /// CHECK-DAG: <<Arg:i\d+>> ParameterValue |
| 209 | /// CHECK-DAG: <<Const24:i\d+>> IntConstant 24 |
| 210 | /// CHECK-DAG: <<UShr:i\d+>> UShr [<<Arg>>,<<Const24>>] |
| 211 | /// CHECK-DAG: Return [<<UShr>>] |
| 212 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 213 | /// CHECK-START: int Main.$noinline$Shr24And255(int) instruction_simplifier (after) |
Vladimir Marko | 452c1b6 | 2015-09-25 14:44:17 +0100 | [diff] [blame] | 214 | /// CHECK-NOT: Shr |
| 215 | /// CHECK-NOT: And |
| 216 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 217 | public static int $noinline$Shr24And255(int arg) { |
Vladimir Marko | 452c1b6 | 2015-09-25 14:44:17 +0100 | [diff] [blame] | 218 | return (arg >> 24) & 255; |
| 219 | } |
| 220 | |
Vladimir Marko | 61b9228 | 2017-10-11 13:23:17 +0100 | [diff] [blame^] | 221 | /// CHECK-START: int Main.$noinline$Shr25And127(int) instruction_simplifier (before) |
| 222 | /// CHECK-DAG: <<Arg:i\d+>> ParameterValue |
| 223 | /// CHECK-DAG: <<Const25:i\d+>> IntConstant 25 |
| 224 | /// CHECK-DAG: <<Const127:i\d+>> IntConstant 127 |
| 225 | /// CHECK-DAG: <<Shr:i\d+>> Shr [<<Arg>>,<<Const25>>] |
| 226 | /// CHECK-DAG: <<And:i\d+>> And [<<Shr>>,<<Const127>>] |
| 227 | /// CHECK-DAG: Return [<<And>>] |
| 228 | |
| 229 | /// CHECK-START: int Main.$noinline$Shr25And127(int) instruction_simplifier (after) |
| 230 | /// CHECK-DAG: <<Arg:i\d+>> ParameterValue |
| 231 | /// CHECK-DAG: <<Const25:i\d+>> IntConstant 25 |
| 232 | /// CHECK-DAG: <<UShr:i\d+>> UShr [<<Arg>>,<<Const25>>] |
| 233 | /// CHECK-DAG: Return [<<UShr>>] |
| 234 | |
| 235 | /// CHECK-START: int Main.$noinline$Shr25And127(int) instruction_simplifier (after) |
| 236 | /// CHECK-NOT: Shr |
| 237 | /// CHECK-NOT: And |
| 238 | |
| 239 | public static int $noinline$Shr25And127(int arg) { |
| 240 | return (arg >> 25) & 127; |
| 241 | } |
| 242 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 243 | /// CHECK-START: long Main.$noinline$Shr56And255(long) instruction_simplifier (before) |
Vladimir Marko | 452c1b6 | 2015-09-25 14:44:17 +0100 | [diff] [blame] | 244 | /// CHECK-DAG: <<Arg:j\d+>> ParameterValue |
| 245 | /// CHECK-DAG: <<Const56:i\d+>> IntConstant 56 |
| 246 | /// CHECK-DAG: <<Const255:j\d+>> LongConstant 255 |
| 247 | /// CHECK-DAG: <<Shr:j\d+>> Shr [<<Arg>>,<<Const56>>] |
| 248 | /// CHECK-DAG: <<And:j\d+>> And [<<Shr>>,<<Const255>>] |
| 249 | /// CHECK-DAG: Return [<<And>>] |
| 250 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 251 | /// CHECK-START: long Main.$noinline$Shr56And255(long) instruction_simplifier (after) |
Vladimir Marko | 452c1b6 | 2015-09-25 14:44:17 +0100 | [diff] [blame] | 252 | /// CHECK-DAG: <<Arg:j\d+>> ParameterValue |
| 253 | /// CHECK-DAG: <<Const56:i\d+>> IntConstant 56 |
| 254 | /// CHECK-DAG: <<UShr:j\d+>> UShr [<<Arg>>,<<Const56>>] |
| 255 | /// CHECK-DAG: Return [<<UShr>>] |
| 256 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 257 | /// CHECK-START: long Main.$noinline$Shr56And255(long) instruction_simplifier (after) |
Vladimir Marko | 452c1b6 | 2015-09-25 14:44:17 +0100 | [diff] [blame] | 258 | /// CHECK-NOT: Shr |
| 259 | /// CHECK-NOT: And |
| 260 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 261 | public static long $noinline$Shr56And255(long arg) { |
Vladimir Marko | 452c1b6 | 2015-09-25 14:44:17 +0100 | [diff] [blame] | 262 | return (arg >> 56) & 255; |
| 263 | } |
| 264 | |
Vladimir Marko | 61b9228 | 2017-10-11 13:23:17 +0100 | [diff] [blame^] | 265 | /// CHECK-START: long Main.$noinline$Shr57And127(long) instruction_simplifier (before) |
| 266 | /// CHECK-DAG: <<Arg:j\d+>> ParameterValue |
| 267 | /// CHECK-DAG: <<Const57:i\d+>> IntConstant 57 |
| 268 | /// CHECK-DAG: <<Const127:j\d+>> LongConstant 127 |
| 269 | /// CHECK-DAG: <<Shr:j\d+>> Shr [<<Arg>>,<<Const57>>] |
| 270 | /// CHECK-DAG: <<And:j\d+>> And [<<Shr>>,<<Const127>>] |
| 271 | /// CHECK-DAG: Return [<<And>>] |
| 272 | |
| 273 | /// CHECK-START: long Main.$noinline$Shr57And127(long) instruction_simplifier (after) |
| 274 | /// CHECK-DAG: <<Arg:j\d+>> ParameterValue |
| 275 | /// CHECK-DAG: <<Const57:i\d+>> IntConstant 57 |
| 276 | /// CHECK-DAG: <<UShr:j\d+>> UShr [<<Arg>>,<<Const57>>] |
| 277 | /// CHECK-DAG: Return [<<UShr>>] |
| 278 | |
| 279 | /// CHECK-START: long Main.$noinline$Shr57And127(long) instruction_simplifier (after) |
| 280 | /// CHECK-NOT: Shr |
| 281 | /// CHECK-NOT: And |
| 282 | |
| 283 | public static long $noinline$Shr57And127(long arg) { |
| 284 | return (arg >> 57) & 127; |
| 285 | } |
| 286 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 287 | /// CHECK-START: int Main.$noinline$Shr24And127(int) instruction_simplifier (before) |
Vladimir Marko | 452c1b6 | 2015-09-25 14:44:17 +0100 | [diff] [blame] | 288 | /// CHECK-DAG: <<Arg:i\d+>> ParameterValue |
| 289 | /// CHECK-DAG: <<Const24:i\d+>> IntConstant 24 |
| 290 | /// CHECK-DAG: <<Const127:i\d+>> IntConstant 127 |
| 291 | /// CHECK-DAG: <<Shr:i\d+>> Shr [<<Arg>>,<<Const24>>] |
| 292 | /// CHECK-DAG: <<And:i\d+>> And [<<Shr>>,<<Const127>>] |
| 293 | /// CHECK-DAG: Return [<<And>>] |
| 294 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 295 | /// CHECK-START: int Main.$noinline$Shr24And127(int) instruction_simplifier (after) |
Vladimir Marko | 452c1b6 | 2015-09-25 14:44:17 +0100 | [diff] [blame] | 296 | /// CHECK-DAG: <<Arg:i\d+>> ParameterValue |
| 297 | /// CHECK-DAG: <<Const24:i\d+>> IntConstant 24 |
| 298 | /// CHECK-DAG: <<Const127:i\d+>> IntConstant 127 |
| 299 | /// CHECK-DAG: <<Shr:i\d+>> Shr [<<Arg>>,<<Const24>>] |
| 300 | /// CHECK-DAG: <<And:i\d+>> And [<<Shr>>,<<Const127>>] |
| 301 | /// CHECK-DAG: Return [<<And>>] |
| 302 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 303 | public static int $noinline$Shr24And127(int arg) { |
Vladimir Marko | 452c1b6 | 2015-09-25 14:44:17 +0100 | [diff] [blame] | 304 | return (arg >> 24) & 127; |
| 305 | } |
| 306 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 307 | /// CHECK-START: long Main.$noinline$Shr56And127(long) instruction_simplifier (before) |
Vladimir Marko | 452c1b6 | 2015-09-25 14:44:17 +0100 | [diff] [blame] | 308 | /// CHECK-DAG: <<Arg:j\d+>> ParameterValue |
| 309 | /// CHECK-DAG: <<Const56:i\d+>> IntConstant 56 |
| 310 | /// CHECK-DAG: <<Const127:j\d+>> LongConstant 127 |
| 311 | /// CHECK-DAG: <<Shr:j\d+>> Shr [<<Arg>>,<<Const56>>] |
| 312 | /// CHECK-DAG: <<And:j\d+>> And [<<Shr>>,<<Const127>>] |
| 313 | /// CHECK-DAG: Return [<<And>>] |
| 314 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 315 | /// CHECK-START: long Main.$noinline$Shr56And127(long) instruction_simplifier (after) |
Vladimir Marko | 452c1b6 | 2015-09-25 14:44:17 +0100 | [diff] [blame] | 316 | /// CHECK-DAG: <<Arg:j\d+>> ParameterValue |
| 317 | /// CHECK-DAG: <<Const56:i\d+>> IntConstant 56 |
| 318 | /// CHECK-DAG: <<Const127:j\d+>> LongConstant 127 |
| 319 | /// CHECK-DAG: <<Shr:j\d+>> Shr [<<Arg>>,<<Const56>>] |
| 320 | /// CHECK-DAG: <<And:j\d+>> And [<<Shr>>,<<Const127>>] |
| 321 | /// CHECK-DAG: Return [<<And>>] |
| 322 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 323 | public static long $noinline$Shr56And127(long arg) { |
Vladimir Marko | 452c1b6 | 2015-09-25 14:44:17 +0100 | [diff] [blame] | 324 | return (arg >> 56) & 127; |
| 325 | } |
| 326 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 327 | /// CHECK-START: long Main.$noinline$Div1(long) instruction_simplifier (before) |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 328 | /// CHECK-DAG: <<Arg:j\d+>> ParameterValue |
| 329 | /// CHECK-DAG: <<Const1:j\d+>> LongConstant 1 |
| 330 | /// CHECK-DAG: <<Div:j\d+>> Div [<<Arg>>,<<Const1>>] |
| 331 | /// CHECK-DAG: Return [<<Div>>] |
Alexandre Rames | b2fd7bc | 2015-03-11 16:48:16 +0000 | [diff] [blame] | 332 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 333 | /// CHECK-START: long Main.$noinline$Div1(long) instruction_simplifier (after) |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 334 | /// CHECK-DAG: <<Arg:j\d+>> ParameterValue |
| 335 | /// CHECK-DAG: Return [<<Arg>>] |
Alexandre Rames | b2fd7bc | 2015-03-11 16:48:16 +0000 | [diff] [blame] | 336 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 337 | /// CHECK-START: long Main.$noinline$Div1(long) instruction_simplifier (after) |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 338 | /// CHECK-NOT: Div |
Alexandre Rames | 7441769 | 2015-04-09 15:21:41 +0100 | [diff] [blame] | 339 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 340 | public static long $noinline$Div1(long arg) { |
Alexandre Rames | b2fd7bc | 2015-03-11 16:48:16 +0000 | [diff] [blame] | 341 | return arg / 1; |
| 342 | } |
| 343 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 344 | /// CHECK-START: int Main.$noinline$DivN1(int) instruction_simplifier (before) |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 345 | /// CHECK-DAG: <<Arg:i\d+>> ParameterValue |
| 346 | /// CHECK-DAG: <<ConstN1:i\d+>> IntConstant -1 |
| 347 | /// CHECK-DAG: <<Div:i\d+>> Div [<<Arg>>,<<ConstN1>>] |
| 348 | /// CHECK-DAG: Return [<<Div>>] |
Alexandre Rames | b2fd7bc | 2015-03-11 16:48:16 +0000 | [diff] [blame] | 349 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 350 | /// CHECK-START: int Main.$noinline$DivN1(int) instruction_simplifier (after) |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 351 | /// CHECK-DAG: <<Arg:i\d+>> ParameterValue |
| 352 | /// CHECK-DAG: <<Neg:i\d+>> Neg [<<Arg>>] |
| 353 | /// CHECK-DAG: Return [<<Neg>>] |
Alexandre Rames | b2fd7bc | 2015-03-11 16:48:16 +0000 | [diff] [blame] | 354 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 355 | /// CHECK-START: int Main.$noinline$DivN1(int) instruction_simplifier (after) |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 356 | /// CHECK-NOT: Div |
Alexandre Rames | 7441769 | 2015-04-09 15:21:41 +0100 | [diff] [blame] | 357 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 358 | public static int $noinline$DivN1(int arg) { |
Alexandre Rames | b2fd7bc | 2015-03-11 16:48:16 +0000 | [diff] [blame] | 359 | return arg / -1; |
| 360 | } |
| 361 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 362 | /// CHECK-START: long Main.$noinline$Mul1(long) instruction_simplifier (before) |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 363 | /// CHECK-DAG: <<Arg:j\d+>> ParameterValue |
| 364 | /// CHECK-DAG: <<Const1:j\d+>> LongConstant 1 |
David Brazdil | 57e863c | 2016-01-11 10:27:13 +0000 | [diff] [blame] | 365 | /// CHECK-DAG: <<Mul:j\d+>> Mul [<<Const1>>,<<Arg>>] |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 366 | /// CHECK-DAG: Return [<<Mul>>] |
Alexandre Rames | b2fd7bc | 2015-03-11 16:48:16 +0000 | [diff] [blame] | 367 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 368 | /// CHECK-START: long Main.$noinline$Mul1(long) instruction_simplifier (after) |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 369 | /// CHECK-DAG: <<Arg:j\d+>> ParameterValue |
| 370 | /// CHECK-DAG: Return [<<Arg>>] |
Alexandre Rames | b2fd7bc | 2015-03-11 16:48:16 +0000 | [diff] [blame] | 371 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 372 | /// CHECK-START: long Main.$noinline$Mul1(long) instruction_simplifier (after) |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 373 | /// CHECK-NOT: Mul |
Alexandre Rames | 7441769 | 2015-04-09 15:21:41 +0100 | [diff] [blame] | 374 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 375 | public static long $noinline$Mul1(long arg) { |
Alexandre Rames | b2fd7bc | 2015-03-11 16:48:16 +0000 | [diff] [blame] | 376 | return arg * 1; |
| 377 | } |
| 378 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 379 | /// CHECK-START: int Main.$noinline$MulN1(int) instruction_simplifier (before) |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 380 | /// CHECK-DAG: <<Arg:i\d+>> ParameterValue |
| 381 | /// CHECK-DAG: <<ConstN1:i\d+>> IntConstant -1 |
| 382 | /// CHECK-DAG: <<Mul:i\d+>> Mul [<<Arg>>,<<ConstN1>>] |
| 383 | /// CHECK-DAG: Return [<<Mul>>] |
Alexandre Rames | b2fd7bc | 2015-03-11 16:48:16 +0000 | [diff] [blame] | 384 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 385 | /// CHECK-START: int Main.$noinline$MulN1(int) instruction_simplifier (after) |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 386 | /// CHECK-DAG: <<Arg:i\d+>> ParameterValue |
| 387 | /// CHECK-DAG: <<Neg:i\d+>> Neg [<<Arg>>] |
| 388 | /// CHECK-DAG: Return [<<Neg>>] |
Alexandre Rames | b2fd7bc | 2015-03-11 16:48:16 +0000 | [diff] [blame] | 389 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 390 | /// CHECK-START: int Main.$noinline$MulN1(int) instruction_simplifier (after) |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 391 | /// CHECK-NOT: Mul |
Alexandre Rames | 7441769 | 2015-04-09 15:21:41 +0100 | [diff] [blame] | 392 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 393 | public static int $noinline$MulN1(int arg) { |
Alexandre Rames | b2fd7bc | 2015-03-11 16:48:16 +0000 | [diff] [blame] | 394 | return arg * -1; |
| 395 | } |
| 396 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 397 | /// CHECK-START: long Main.$noinline$MulPowerOfTwo128(long) instruction_simplifier (before) |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 398 | /// CHECK-DAG: <<Arg:j\d+>> ParameterValue |
| 399 | /// CHECK-DAG: <<Const128:j\d+>> LongConstant 128 |
David Brazdil | 57e863c | 2016-01-11 10:27:13 +0000 | [diff] [blame] | 400 | /// CHECK-DAG: <<Mul:j\d+>> Mul [<<Const128>>,<<Arg>>] |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 401 | /// CHECK-DAG: Return [<<Mul>>] |
Alexandre Rames | b2fd7bc | 2015-03-11 16:48:16 +0000 | [diff] [blame] | 402 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 403 | /// CHECK-START: long Main.$noinline$MulPowerOfTwo128(long) instruction_simplifier (after) |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 404 | /// CHECK-DAG: <<Arg:j\d+>> ParameterValue |
| 405 | /// CHECK-DAG: <<Const7:i\d+>> IntConstant 7 |
| 406 | /// CHECK-DAG: <<Shl:j\d+>> Shl [<<Arg>>,<<Const7>>] |
| 407 | /// CHECK-DAG: Return [<<Shl>>] |
Alexandre Rames | b2fd7bc | 2015-03-11 16:48:16 +0000 | [diff] [blame] | 408 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 409 | /// CHECK-START: long Main.$noinline$MulPowerOfTwo128(long) instruction_simplifier (after) |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 410 | /// CHECK-NOT: Mul |
Alexandre Rames | 7441769 | 2015-04-09 15:21:41 +0100 | [diff] [blame] | 411 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 412 | public static long $noinline$MulPowerOfTwo128(long arg) { |
Alexandre Rames | b2fd7bc | 2015-03-11 16:48:16 +0000 | [diff] [blame] | 413 | return arg * 128; |
| 414 | } |
| 415 | |
Anton Kirilov | e14dc86 | 2016-05-13 17:56:15 +0100 | [diff] [blame] | 416 | /// CHECK-START: long Main.$noinline$MulMulMulConst(long) instruction_simplifier (before) |
| 417 | /// CHECK-DAG: <<ArgValue:j\d+>> ParameterValue |
| 418 | /// CHECK-DAG: <<Const10:j\d+>> LongConstant 10 |
| 419 | /// CHECK-DAG: <<Const11:j\d+>> LongConstant 11 |
| 420 | /// CHECK-DAG: <<Const12:j\d+>> LongConstant 12 |
| 421 | /// CHECK-DAG: <<Mul1:j\d+>> Mul [<<Const10>>,<<ArgValue>>] |
| 422 | /// CHECK-DAG: <<Mul2:j\d+>> Mul [<<Mul1>>,<<Const11>>] |
| 423 | /// CHECK-DAG: <<Mul3:j\d+>> Mul [<<Mul2>>,<<Const12>>] |
| 424 | /// CHECK-DAG: Return [<<Mul3>>] |
| 425 | |
| 426 | /// CHECK-START: long Main.$noinline$MulMulMulConst(long) instruction_simplifier (after) |
| 427 | /// CHECK-DAG: <<ArgValue:j\d+>> ParameterValue |
| 428 | /// CHECK-DAG: <<Const1320:j\d+>> LongConstant 1320 |
| 429 | /// CHECK-DAG: <<Mul:j\d+>> Mul [<<ArgValue>>,<<Const1320>>] |
| 430 | /// CHECK-DAG: Return [<<Mul>>] |
| 431 | |
| 432 | public static long $noinline$MulMulMulConst(long arg) { |
Anton Kirilov | e14dc86 | 2016-05-13 17:56:15 +0100 | [diff] [blame] | 433 | return 10 * arg * 11 * 12; |
| 434 | } |
| 435 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 436 | /// CHECK-START: int Main.$noinline$Or0(int) instruction_simplifier (before) |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 437 | /// CHECK-DAG: <<Arg:i\d+>> ParameterValue |
| 438 | /// CHECK-DAG: <<Const0:i\d+>> IntConstant 0 |
| 439 | /// CHECK-DAG: <<Or:i\d+>> Or [<<Arg>>,<<Const0>>] |
| 440 | /// CHECK-DAG: Return [<<Or>>] |
Alexandre Rames | b2fd7bc | 2015-03-11 16:48:16 +0000 | [diff] [blame] | 441 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 442 | /// CHECK-START: int Main.$noinline$Or0(int) instruction_simplifier (after) |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 443 | /// CHECK-DAG: <<Arg:i\d+>> ParameterValue |
| 444 | /// CHECK-DAG: Return [<<Arg>>] |
Alexandre Rames | b2fd7bc | 2015-03-11 16:48:16 +0000 | [diff] [blame] | 445 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 446 | /// CHECK-START: int Main.$noinline$Or0(int) instruction_simplifier (after) |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 447 | /// CHECK-NOT: Or |
Alexandre Rames | 7441769 | 2015-04-09 15:21:41 +0100 | [diff] [blame] | 448 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 449 | public static int $noinline$Or0(int arg) { |
Alexandre Rames | b2fd7bc | 2015-03-11 16:48:16 +0000 | [diff] [blame] | 450 | return arg | 0; |
| 451 | } |
| 452 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 453 | /// CHECK-START: long Main.$noinline$OrSame(long) instruction_simplifier (before) |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 454 | /// CHECK-DAG: <<Arg:j\d+>> ParameterValue |
| 455 | /// CHECK-DAG: <<Or:j\d+>> Or [<<Arg>>,<<Arg>>] |
| 456 | /// CHECK-DAG: Return [<<Or>>] |
Alexandre Rames | b2fd7bc | 2015-03-11 16:48:16 +0000 | [diff] [blame] | 457 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 458 | /// CHECK-START: long Main.$noinline$OrSame(long) instruction_simplifier (after) |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 459 | /// CHECK-DAG: <<Arg:j\d+>> ParameterValue |
| 460 | /// CHECK-DAG: Return [<<Arg>>] |
Alexandre Rames | b2fd7bc | 2015-03-11 16:48:16 +0000 | [diff] [blame] | 461 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 462 | /// CHECK-START: long Main.$noinline$OrSame(long) instruction_simplifier (after) |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 463 | /// CHECK-NOT: Or |
Alexandre Rames | 7441769 | 2015-04-09 15:21:41 +0100 | [diff] [blame] | 464 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 465 | public static long $noinline$OrSame(long arg) { |
Alexandre Rames | b2fd7bc | 2015-03-11 16:48:16 +0000 | [diff] [blame] | 466 | return arg | arg; |
| 467 | } |
| 468 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 469 | /// CHECK-START: int Main.$noinline$Shl0(int) instruction_simplifier (before) |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 470 | /// CHECK-DAG: <<Arg:i\d+>> ParameterValue |
| 471 | /// CHECK-DAG: <<Const0:i\d+>> IntConstant 0 |
| 472 | /// CHECK-DAG: <<Shl:i\d+>> Shl [<<Arg>>,<<Const0>>] |
| 473 | /// CHECK-DAG: Return [<<Shl>>] |
Alexandre Rames | b2fd7bc | 2015-03-11 16:48:16 +0000 | [diff] [blame] | 474 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 475 | /// CHECK-START: int Main.$noinline$Shl0(int) instruction_simplifier (after) |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 476 | /// CHECK-DAG: <<Arg:i\d+>> ParameterValue |
| 477 | /// CHECK-DAG: Return [<<Arg>>] |
Alexandre Rames | b2fd7bc | 2015-03-11 16:48:16 +0000 | [diff] [blame] | 478 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 479 | /// CHECK-START: int Main.$noinline$Shl0(int) instruction_simplifier (after) |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 480 | /// CHECK-NOT: Shl |
Alexandre Rames | 7441769 | 2015-04-09 15:21:41 +0100 | [diff] [blame] | 481 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 482 | public static int $noinline$Shl0(int arg) { |
Alexandre Rames | b2fd7bc | 2015-03-11 16:48:16 +0000 | [diff] [blame] | 483 | return arg << 0; |
| 484 | } |
| 485 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 486 | /// CHECK-START: long Main.$noinline$Shr0(long) instruction_simplifier (before) |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 487 | /// CHECK-DAG: <<Arg:j\d+>> ParameterValue |
| 488 | /// CHECK-DAG: <<Const0:i\d+>> IntConstant 0 |
| 489 | /// CHECK-DAG: <<Shr:j\d+>> Shr [<<Arg>>,<<Const0>>] |
| 490 | /// CHECK-DAG: Return [<<Shr>>] |
Alexandre Rames | b2fd7bc | 2015-03-11 16:48:16 +0000 | [diff] [blame] | 491 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 492 | /// CHECK-START: long Main.$noinline$Shr0(long) instruction_simplifier (after) |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 493 | /// CHECK-DAG: <<Arg:j\d+>> ParameterValue |
| 494 | /// CHECK-DAG: Return [<<Arg>>] |
Alexandre Rames | b2fd7bc | 2015-03-11 16:48:16 +0000 | [diff] [blame] | 495 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 496 | /// CHECK-START: long Main.$noinline$Shr0(long) instruction_simplifier (after) |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 497 | /// CHECK-NOT: Shr |
Alexandre Rames | 7441769 | 2015-04-09 15:21:41 +0100 | [diff] [blame] | 498 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 499 | public static long $noinline$Shr0(long arg) { |
Alexandre Rames | b2fd7bc | 2015-03-11 16:48:16 +0000 | [diff] [blame] | 500 | return arg >> 0; |
| 501 | } |
| 502 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 503 | /// CHECK-START: long Main.$noinline$Shr64(long) instruction_simplifier (before) |
Vladimir Marko | 164306e | 2016-03-15 14:57:32 +0000 | [diff] [blame] | 504 | /// CHECK-DAG: <<Arg:j\d+>> ParameterValue |
| 505 | /// CHECK-DAG: <<Const64:i\d+>> IntConstant 64 |
| 506 | /// CHECK-DAG: <<Shr:j\d+>> Shr [<<Arg>>,<<Const64>>] |
| 507 | /// CHECK-DAG: Return [<<Shr>>] |
| 508 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 509 | /// CHECK-START: long Main.$noinline$Shr64(long) instruction_simplifier (after) |
Vladimir Marko | 164306e | 2016-03-15 14:57:32 +0000 | [diff] [blame] | 510 | /// CHECK-DAG: <<Arg:j\d+>> ParameterValue |
| 511 | /// CHECK-DAG: Return [<<Arg>>] |
| 512 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 513 | /// CHECK-START: long Main.$noinline$Shr64(long) instruction_simplifier (after) |
Vladimir Marko | 164306e | 2016-03-15 14:57:32 +0000 | [diff] [blame] | 514 | /// CHECK-NOT: Shr |
| 515 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 516 | public static long $noinline$Shr64(long arg) { |
Vladimir Marko | 164306e | 2016-03-15 14:57:32 +0000 | [diff] [blame] | 517 | return arg >> 64; |
| 518 | } |
| 519 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 520 | /// CHECK-START: long Main.$noinline$Sub0(long) instruction_simplifier (before) |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 521 | /// CHECK-DAG: <<Arg:j\d+>> ParameterValue |
| 522 | /// CHECK-DAG: <<Const0:j\d+>> LongConstant 0 |
| 523 | /// CHECK-DAG: <<Sub:j\d+>> Sub [<<Arg>>,<<Const0>>] |
| 524 | /// CHECK-DAG: Return [<<Sub>>] |
Alexandre Rames | b2fd7bc | 2015-03-11 16:48:16 +0000 | [diff] [blame] | 525 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 526 | /// CHECK-START: long Main.$noinline$Sub0(long) instruction_simplifier (after) |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 527 | /// CHECK-DAG: <<Arg:j\d+>> ParameterValue |
| 528 | /// CHECK-DAG: Return [<<Arg>>] |
Alexandre Rames | b2fd7bc | 2015-03-11 16:48:16 +0000 | [diff] [blame] | 529 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 530 | /// CHECK-START: long Main.$noinline$Sub0(long) instruction_simplifier (after) |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 531 | /// CHECK-NOT: Sub |
Alexandre Rames | 7441769 | 2015-04-09 15:21:41 +0100 | [diff] [blame] | 532 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 533 | public static long $noinline$Sub0(long arg) { |
Alexandre Rames | b2fd7bc | 2015-03-11 16:48:16 +0000 | [diff] [blame] | 534 | return arg - 0; |
| 535 | } |
| 536 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 537 | /// CHECK-START: int Main.$noinline$SubAliasNeg(int) instruction_simplifier (before) |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 538 | /// CHECK-DAG: <<Arg:i\d+>> ParameterValue |
| 539 | /// CHECK-DAG: <<Const0:i\d+>> IntConstant 0 |
| 540 | /// CHECK-DAG: <<Sub:i\d+>> Sub [<<Const0>>,<<Arg>>] |
| 541 | /// CHECK-DAG: Return [<<Sub>>] |
Alexandre Rames | b2fd7bc | 2015-03-11 16:48:16 +0000 | [diff] [blame] | 542 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 543 | /// CHECK-START: int Main.$noinline$SubAliasNeg(int) instruction_simplifier (after) |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 544 | /// CHECK-DAG: <<Arg:i\d+>> ParameterValue |
| 545 | /// CHECK-DAG: <<Neg:i\d+>> Neg [<<Arg>>] |
| 546 | /// CHECK-DAG: Return [<<Neg>>] |
Alexandre Rames | b2fd7bc | 2015-03-11 16:48:16 +0000 | [diff] [blame] | 547 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 548 | /// CHECK-START: int Main.$noinline$SubAliasNeg(int) instruction_simplifier (after) |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 549 | /// CHECK-NOT: Sub |
Alexandre Rames | 7441769 | 2015-04-09 15:21:41 +0100 | [diff] [blame] | 550 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 551 | public static int $noinline$SubAliasNeg(int arg) { |
Alexandre Rames | b2fd7bc | 2015-03-11 16:48:16 +0000 | [diff] [blame] | 552 | return 0 - arg; |
| 553 | } |
| 554 | |
Anton Kirilov | e14dc86 | 2016-05-13 17:56:15 +0100 | [diff] [blame] | 555 | /// CHECK-START: int Main.$noinline$SubAddConst1(int) instruction_simplifier (before) |
| 556 | /// CHECK-DAG: <<ArgValue:i\d+>> ParameterValue |
| 557 | /// CHECK-DAG: <<Const5:i\d+>> IntConstant 5 |
| 558 | /// CHECK-DAG: <<Const6:i\d+>> IntConstant 6 |
| 559 | /// CHECK-DAG: <<Sub:i\d+>> Sub [<<Const5>>,<<ArgValue>>] |
| 560 | /// CHECK-DAG: <<Add:i\d+>> Add [<<Sub>>,<<Const6>>] |
| 561 | /// CHECK-DAG: Return [<<Add>>] |
| 562 | |
| 563 | /// CHECK-START: int Main.$noinline$SubAddConst1(int) instruction_simplifier (after) |
| 564 | /// CHECK-DAG: <<ArgValue:i\d+>> ParameterValue |
| 565 | /// CHECK-DAG: <<Const11:i\d+>> IntConstant 11 |
| 566 | /// CHECK-DAG: <<Sub:i\d+>> Sub [<<Const11>>,<<ArgValue>>] |
| 567 | /// CHECK-DAG: Return [<<Sub>>] |
| 568 | |
| 569 | public static int $noinline$SubAddConst1(int arg) { |
Anton Kirilov | e14dc86 | 2016-05-13 17:56:15 +0100 | [diff] [blame] | 570 | return 5 - arg + 6; |
| 571 | } |
| 572 | |
| 573 | /// CHECK-START: int Main.$noinline$SubAddConst2(int) instruction_simplifier (before) |
| 574 | /// CHECK-DAG: <<ArgValue:i\d+>> ParameterValue |
| 575 | /// CHECK-DAG: <<Const14:i\d+>> IntConstant 14 |
| 576 | /// CHECK-DAG: <<Const13:i\d+>> IntConstant 13 |
| 577 | /// CHECK-DAG: <<Add:i\d+>> Add [<<ArgValue>>,<<Const13>>] |
| 578 | /// CHECK-DAG: <<Sub:i\d+>> Sub [<<Const14>>,<<Add>>] |
| 579 | /// CHECK-DAG: Return [<<Sub>>] |
| 580 | |
| 581 | /// CHECK-START: int Main.$noinline$SubAddConst2(int) instruction_simplifier (after) |
| 582 | /// CHECK-DAG: <<ArgValue:i\d+>> ParameterValue |
| 583 | /// CHECK-DAG: <<Const1:i\d+>> IntConstant 1 |
| 584 | /// CHECK-DAG: <<Sub:i\d+>> Sub [<<Const1>>,<<ArgValue>>] |
| 585 | /// CHECK-DAG: Return [<<Sub>>] |
| 586 | |
| 587 | public static int $noinline$SubAddConst2(int arg) { |
Anton Kirilov | e14dc86 | 2016-05-13 17:56:15 +0100 | [diff] [blame] | 588 | return 14 - (arg + 13); |
| 589 | } |
| 590 | |
| 591 | /// CHECK-START: long Main.$noinline$SubSubConst(long) instruction_simplifier (before) |
| 592 | /// CHECK-DAG: <<ArgValue:j\d+>> ParameterValue |
| 593 | /// CHECK-DAG: <<Const17:j\d+>> LongConstant 17 |
| 594 | /// CHECK-DAG: <<Const18:j\d+>> LongConstant 18 |
| 595 | /// CHECK-DAG: <<Sub1:j\d+>> Sub [<<Const18>>,<<ArgValue>>] |
| 596 | /// CHECK-DAG: <<Sub2:j\d+>> Sub [<<Const17>>,<<Sub1>>] |
| 597 | /// CHECK-DAG: Return [<<Sub2>>] |
| 598 | |
| 599 | /// CHECK-START: long Main.$noinline$SubSubConst(long) instruction_simplifier (after) |
| 600 | /// CHECK-DAG: <<ArgValue:j\d+>> ParameterValue |
| 601 | /// CHECK-DAG: <<ConstM1:j\d+>> LongConstant -1 |
| 602 | /// CHECK-DAG: <<Add:j\d+>> Add [<<ArgValue>>,<<ConstM1>>] |
| 603 | /// CHECK-DAG: Return [<<Add>>] |
| 604 | |
| 605 | public static long $noinline$SubSubConst(long arg) { |
Anton Kirilov | e14dc86 | 2016-05-13 17:56:15 +0100 | [diff] [blame] | 606 | return 17 - (18 - arg); |
| 607 | } |
| 608 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 609 | /// CHECK-START: long Main.$noinline$UShr0(long) instruction_simplifier (before) |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 610 | /// CHECK-DAG: <<Arg:j\d+>> ParameterValue |
| 611 | /// CHECK-DAG: <<Const0:i\d+>> IntConstant 0 |
| 612 | /// CHECK-DAG: <<UShr:j\d+>> UShr [<<Arg>>,<<Const0>>] |
| 613 | /// CHECK-DAG: Return [<<UShr>>] |
Alexandre Rames | b2fd7bc | 2015-03-11 16:48:16 +0000 | [diff] [blame] | 614 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 615 | /// CHECK-START: long Main.$noinline$UShr0(long) instruction_simplifier (after) |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 616 | /// CHECK-DAG: <<Arg:j\d+>> ParameterValue |
| 617 | /// CHECK-DAG: Return [<<Arg>>] |
Alexandre Rames | b2fd7bc | 2015-03-11 16:48:16 +0000 | [diff] [blame] | 618 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 619 | /// CHECK-START: long Main.$noinline$UShr0(long) instruction_simplifier (after) |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 620 | /// CHECK-NOT: UShr |
Alexandre Rames | 7441769 | 2015-04-09 15:21:41 +0100 | [diff] [blame] | 621 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 622 | public static long $noinline$UShr0(long arg) { |
Alexandre Rames | b2fd7bc | 2015-03-11 16:48:16 +0000 | [diff] [blame] | 623 | return arg >>> 0; |
| 624 | } |
| 625 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 626 | /// CHECK-START: int Main.$noinline$Xor0(int) instruction_simplifier (before) |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 627 | /// CHECK-DAG: <<Arg:i\d+>> ParameterValue |
| 628 | /// CHECK-DAG: <<Const0:i\d+>> IntConstant 0 |
| 629 | /// CHECK-DAG: <<Xor:i\d+>> Xor [<<Arg>>,<<Const0>>] |
| 630 | /// CHECK-DAG: Return [<<Xor>>] |
Alexandre Rames | b2fd7bc | 2015-03-11 16:48:16 +0000 | [diff] [blame] | 631 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 632 | /// CHECK-START: int Main.$noinline$Xor0(int) instruction_simplifier (after) |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 633 | /// CHECK-DAG: <<Arg:i\d+>> ParameterValue |
| 634 | /// CHECK-DAG: Return [<<Arg>>] |
Alexandre Rames | b2fd7bc | 2015-03-11 16:48:16 +0000 | [diff] [blame] | 635 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 636 | /// CHECK-START: int Main.$noinline$Xor0(int) instruction_simplifier (after) |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 637 | /// CHECK-NOT: Xor |
Alexandre Rames | 7441769 | 2015-04-09 15:21:41 +0100 | [diff] [blame] | 638 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 639 | public static int $noinline$Xor0(int arg) { |
Alexandre Rames | b2fd7bc | 2015-03-11 16:48:16 +0000 | [diff] [blame] | 640 | return arg ^ 0; |
| 641 | } |
| 642 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 643 | /// CHECK-START: int Main.$noinline$XorAllOnes(int) instruction_simplifier (before) |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 644 | /// CHECK-DAG: <<Arg:i\d+>> ParameterValue |
| 645 | /// CHECK-DAG: <<ConstF:i\d+>> IntConstant -1 |
| 646 | /// CHECK-DAG: <<Xor:i\d+>> Xor [<<Arg>>,<<ConstF>>] |
| 647 | /// CHECK-DAG: Return [<<Xor>>] |
Alexandre Rames | b2fd7bc | 2015-03-11 16:48:16 +0000 | [diff] [blame] | 648 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 649 | /// CHECK-START: int Main.$noinline$XorAllOnes(int) instruction_simplifier (after) |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 650 | /// CHECK-DAG: <<Arg:i\d+>> ParameterValue |
| 651 | /// CHECK-DAG: <<Not:i\d+>> Not [<<Arg>>] |
| 652 | /// CHECK-DAG: Return [<<Not>>] |
Alexandre Rames | b2fd7bc | 2015-03-11 16:48:16 +0000 | [diff] [blame] | 653 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 654 | /// CHECK-START: int Main.$noinline$XorAllOnes(int) instruction_simplifier (after) |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 655 | /// CHECK-NOT: Xor |
Alexandre Rames | 7441769 | 2015-04-09 15:21:41 +0100 | [diff] [blame] | 656 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 657 | public static int $noinline$XorAllOnes(int arg) { |
Alexandre Rames | b2fd7bc | 2015-03-11 16:48:16 +0000 | [diff] [blame] | 658 | return arg ^ -1; |
| 659 | } |
| 660 | |
Alexandre Rames | 188d431 | 2015-04-09 18:30:21 +0100 | [diff] [blame] | 661 | /** |
| 662 | * Test that addition or subtraction operation with both inputs negated are |
| 663 | * optimized to use a single negation after the operation. |
| 664 | * The transformation tested is implemented in |
| 665 | * `InstructionSimplifierVisitor::TryMoveNegOnInputsAfterBinop`. |
| 666 | */ |
| 667 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 668 | /// CHECK-START: int Main.$noinline$AddNegs1(int, int) instruction_simplifier (before) |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 669 | /// CHECK-DAG: <<Arg1:i\d+>> ParameterValue |
| 670 | /// CHECK-DAG: <<Arg2:i\d+>> ParameterValue |
| 671 | /// CHECK-DAG: <<Neg1:i\d+>> Neg [<<Arg1>>] |
| 672 | /// CHECK-DAG: <<Neg2:i\d+>> Neg [<<Arg2>>] |
| 673 | /// CHECK-DAG: <<Add:i\d+>> Add [<<Neg1>>,<<Neg2>>] |
| 674 | /// CHECK-DAG: Return [<<Add>>] |
Alexandre Rames | 188d431 | 2015-04-09 18:30:21 +0100 | [diff] [blame] | 675 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 676 | /// CHECK-START: int Main.$noinline$AddNegs1(int, int) instruction_simplifier (after) |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 677 | /// CHECK-DAG: <<Arg1:i\d+>> ParameterValue |
| 678 | /// CHECK-DAG: <<Arg2:i\d+>> ParameterValue |
| 679 | /// CHECK-NOT: Neg |
| 680 | /// CHECK-DAG: <<Add:i\d+>> Add [<<Arg1>>,<<Arg2>>] |
| 681 | /// CHECK-DAG: <<Neg:i\d+>> Neg [<<Add>>] |
| 682 | /// CHECK-DAG: Return [<<Neg>>] |
Alexandre Rames | 188d431 | 2015-04-09 18:30:21 +0100 | [diff] [blame] | 683 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 684 | public static int $noinline$AddNegs1(int arg1, int arg2) { |
Alexandre Rames | 188d431 | 2015-04-09 18:30:21 +0100 | [diff] [blame] | 685 | return -arg1 + -arg2; |
| 686 | } |
| 687 | |
| 688 | /** |
| 689 | * This is similar to the test-case AddNegs1, but the negations have |
| 690 | * multiple uses. |
| 691 | * The transformation tested is implemented in |
| 692 | * `InstructionSimplifierVisitor::TryMoveNegOnInputsAfterBinop`. |
| 693 | * The current code won't perform the previous optimization. The |
| 694 | * transformations do not look at other uses of their inputs. As they don't |
| 695 | * know what will happen with other uses, they do not take the risk of |
| 696 | * increasing the register pressure by creating or extending live ranges. |
| 697 | */ |
| 698 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 699 | /// CHECK-START: int Main.$noinline$AddNegs2(int, int) instruction_simplifier (before) |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 700 | /// CHECK-DAG: <<Arg1:i\d+>> ParameterValue |
| 701 | /// CHECK-DAG: <<Arg2:i\d+>> ParameterValue |
| 702 | /// CHECK-DAG: <<Neg1:i\d+>> Neg [<<Arg1>>] |
| 703 | /// CHECK-DAG: <<Neg2:i\d+>> Neg [<<Arg2>>] |
| 704 | /// CHECK-DAG: <<Add1:i\d+>> Add [<<Neg1>>,<<Neg2>>] |
| 705 | /// CHECK-DAG: <<Add2:i\d+>> Add [<<Neg1>>,<<Neg2>>] |
| 706 | /// CHECK-DAG: <<Or:i\d+>> Or [<<Add1>>,<<Add2>>] |
| 707 | /// CHECK-DAG: Return [<<Or>>] |
Alexandre Rames | 188d431 | 2015-04-09 18:30:21 +0100 | [diff] [blame] | 708 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 709 | /// CHECK-START: int Main.$noinline$AddNegs2(int, int) instruction_simplifier (after) |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 710 | /// CHECK-DAG: <<Arg1:i\d+>> ParameterValue |
| 711 | /// CHECK-DAG: <<Arg2:i\d+>> ParameterValue |
| 712 | /// CHECK-DAG: <<Neg1:i\d+>> Neg [<<Arg1>>] |
| 713 | /// CHECK-DAG: <<Neg2:i\d+>> Neg [<<Arg2>>] |
| 714 | /// CHECK-DAG: <<Add1:i\d+>> Add [<<Neg1>>,<<Neg2>>] |
| 715 | /// CHECK-DAG: <<Add2:i\d+>> Add [<<Neg1>>,<<Neg2>>] |
| 716 | /// CHECK-NOT: Neg |
| 717 | /// CHECK-DAG: <<Or:i\d+>> Or [<<Add1>>,<<Add2>>] |
| 718 | /// CHECK-DAG: Return [<<Or>>] |
Alexandre Rames | 188d431 | 2015-04-09 18:30:21 +0100 | [diff] [blame] | 719 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 720 | /// CHECK-START: int Main.$noinline$AddNegs2(int, int) GVN (after) |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 721 | /// CHECK-DAG: <<Arg1:i\d+>> ParameterValue |
| 722 | /// CHECK-DAG: <<Arg2:i\d+>> ParameterValue |
| 723 | /// CHECK-DAG: <<Neg1:i\d+>> Neg [<<Arg1>>] |
| 724 | /// CHECK-DAG: <<Neg2:i\d+>> Neg [<<Arg2>>] |
| 725 | /// CHECK-DAG: <<Add:i\d+>> Add [<<Neg1>>,<<Neg2>>] |
| 726 | /// CHECK-DAG: <<Or:i\d+>> Or [<<Add>>,<<Add>>] |
| 727 | /// CHECK-DAG: Return [<<Or>>] |
Alexandre Rames | b2a5847 | 2015-04-17 14:35:18 +0100 | [diff] [blame] | 728 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 729 | public static int $noinline$AddNegs2(int arg1, int arg2) { |
Alexandre Rames | 188d431 | 2015-04-09 18:30:21 +0100 | [diff] [blame] | 730 | int temp1 = -arg1; |
| 731 | int temp2 = -arg2; |
| 732 | return (temp1 + temp2) | (temp1 + temp2); |
| 733 | } |
| 734 | |
| 735 | /** |
| 736 | * This follows test-cases AddNegs1 and AddNegs2. |
| 737 | * The transformation tested is implemented in |
| 738 | * `InstructionSimplifierVisitor::TryMoveNegOnInputsAfterBinop`. |
| 739 | * The optimization should not happen if it moves an additional instruction in |
| 740 | * the loop. |
| 741 | */ |
| 742 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 743 | /// CHECK-START: long Main.$noinline$AddNegs3(long, long) instruction_simplifier (before) |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 744 | // -------------- Arguments and initial negation operations. |
| 745 | /// CHECK-DAG: <<Arg1:j\d+>> ParameterValue |
| 746 | /// CHECK-DAG: <<Arg2:j\d+>> ParameterValue |
| 747 | /// CHECK-DAG: <<Neg1:j\d+>> Neg [<<Arg1>>] |
| 748 | /// CHECK-DAG: <<Neg2:j\d+>> Neg [<<Arg2>>] |
| 749 | /// CHECK: Goto |
| 750 | // -------------- Loop |
| 751 | /// CHECK: SuspendCheck |
| 752 | /// CHECK: <<Add:j\d+>> Add [<<Neg1>>,<<Neg2>>] |
| 753 | /// CHECK: Goto |
Alexandre Rames | 188d431 | 2015-04-09 18:30:21 +0100 | [diff] [blame] | 754 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 755 | /// CHECK-START: long Main.$noinline$AddNegs3(long, long) instruction_simplifier (after) |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 756 | // -------------- Arguments and initial negation operations. |
| 757 | /// CHECK-DAG: <<Arg1:j\d+>> ParameterValue |
| 758 | /// CHECK-DAG: <<Arg2:j\d+>> ParameterValue |
| 759 | /// CHECK-DAG: <<Neg1:j\d+>> Neg [<<Arg1>>] |
| 760 | /// CHECK-DAG: <<Neg2:j\d+>> Neg [<<Arg2>>] |
| 761 | /// CHECK: Goto |
| 762 | // -------------- Loop |
| 763 | /// CHECK: SuspendCheck |
| 764 | /// CHECK: <<Add:j\d+>> Add [<<Neg1>>,<<Neg2>>] |
| 765 | /// CHECK-NOT: Neg |
| 766 | /// CHECK: Goto |
Alexandre Rames | 188d431 | 2015-04-09 18:30:21 +0100 | [diff] [blame] | 767 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 768 | public static long $noinline$AddNegs3(long arg1, long arg2) { |
Alexandre Rames | 188d431 | 2015-04-09 18:30:21 +0100 | [diff] [blame] | 769 | long res = 0; |
| 770 | long n_arg1 = -arg1; |
| 771 | long n_arg2 = -arg2; |
| 772 | for (long i = 0; i < 1; i++) { |
| 773 | res += n_arg1 + n_arg2 + i; |
| 774 | } |
| 775 | return res; |
| 776 | } |
| 777 | |
| 778 | /** |
| 779 | * Test the simplification of an addition with a negated argument into a |
| 780 | * subtraction. |
| 781 | * The transformation tested is implemented in `InstructionSimplifierVisitor::VisitAdd`. |
| 782 | */ |
| 783 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 784 | /// CHECK-START: long Main.$noinline$AddNeg1(long, long) instruction_simplifier (before) |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 785 | /// CHECK-DAG: <<Arg1:j\d+>> ParameterValue |
| 786 | /// CHECK-DAG: <<Arg2:j\d+>> ParameterValue |
| 787 | /// CHECK-DAG: <<Neg:j\d+>> Neg [<<Arg1>>] |
| 788 | /// CHECK-DAG: <<Add:j\d+>> Add [<<Neg>>,<<Arg2>>] |
| 789 | /// CHECK-DAG: Return [<<Add>>] |
Alexandre Rames | 188d431 | 2015-04-09 18:30:21 +0100 | [diff] [blame] | 790 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 791 | /// CHECK-START: long Main.$noinline$AddNeg1(long, long) instruction_simplifier (after) |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 792 | /// CHECK-DAG: <<Arg1:j\d+>> ParameterValue |
| 793 | /// CHECK-DAG: <<Arg2:j\d+>> ParameterValue |
| 794 | /// CHECK-DAG: <<Sub:j\d+>> Sub [<<Arg2>>,<<Arg1>>] |
| 795 | /// CHECK-DAG: Return [<<Sub>>] |
Alexandre Rames | 188d431 | 2015-04-09 18:30:21 +0100 | [diff] [blame] | 796 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 797 | /// CHECK-START: long Main.$noinline$AddNeg1(long, long) instruction_simplifier (after) |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 798 | /// CHECK-NOT: Neg |
| 799 | /// CHECK-NOT: Add |
Alexandre Rames | 188d431 | 2015-04-09 18:30:21 +0100 | [diff] [blame] | 800 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 801 | public static long $noinline$AddNeg1(long arg1, long arg2) { |
Alexandre Rames | 188d431 | 2015-04-09 18:30:21 +0100 | [diff] [blame] | 802 | return -arg1 + arg2; |
| 803 | } |
| 804 | |
| 805 | /** |
| 806 | * This is similar to the test-case AddNeg1, but the negation has two uses. |
| 807 | * The transformation tested is implemented in `InstructionSimplifierVisitor::VisitAdd`. |
| 808 | * The current code won't perform the previous optimization. The |
| 809 | * transformations do not look at other uses of their inputs. As they don't |
| 810 | * know what will happen with other uses, they do not take the risk of |
| 811 | * increasing the register pressure by creating or extending live ranges. |
| 812 | */ |
| 813 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 814 | /// CHECK-START: long Main.$noinline$AddNeg2(long, long) instruction_simplifier (before) |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 815 | /// CHECK-DAG: <<Arg1:j\d+>> ParameterValue |
| 816 | /// CHECK-DAG: <<Arg2:j\d+>> ParameterValue |
| 817 | /// CHECK-DAG: <<Neg:j\d+>> Neg [<<Arg2>>] |
| 818 | /// CHECK-DAG: <<Add1:j\d+>> Add [<<Arg1>>,<<Neg>>] |
| 819 | /// CHECK-DAG: <<Add2:j\d+>> Add [<<Arg1>>,<<Neg>>] |
| 820 | /// CHECK-DAG: <<Res:j\d+>> Or [<<Add1>>,<<Add2>>] |
| 821 | /// CHECK-DAG: Return [<<Res>>] |
Alexandre Rames | 188d431 | 2015-04-09 18:30:21 +0100 | [diff] [blame] | 822 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 823 | /// CHECK-START: long Main.$noinline$AddNeg2(long, long) instruction_simplifier (after) |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 824 | /// CHECK-DAG: <<Arg1:j\d+>> ParameterValue |
| 825 | /// CHECK-DAG: <<Arg2:j\d+>> ParameterValue |
| 826 | /// CHECK-DAG: <<Neg:j\d+>> Neg [<<Arg2>>] |
| 827 | /// CHECK-DAG: <<Add1:j\d+>> Add [<<Arg1>>,<<Neg>>] |
| 828 | /// CHECK-DAG: <<Add2:j\d+>> Add [<<Arg1>>,<<Neg>>] |
| 829 | /// CHECK-DAG: <<Res:j\d+>> Or [<<Add1>>,<<Add2>>] |
| 830 | /// CHECK-DAG: Return [<<Res>>] |
Alexandre Rames | 188d431 | 2015-04-09 18:30:21 +0100 | [diff] [blame] | 831 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 832 | /// CHECK-START: long Main.$noinline$AddNeg2(long, long) instruction_simplifier (after) |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 833 | /// CHECK-NOT: Sub |
Alexandre Rames | 188d431 | 2015-04-09 18:30:21 +0100 | [diff] [blame] | 834 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 835 | public static long $noinline$AddNeg2(long arg1, long arg2) { |
Alexandre Rames | 188d431 | 2015-04-09 18:30:21 +0100 | [diff] [blame] | 836 | long temp = -arg2; |
| 837 | return (arg1 + temp) | (arg1 + temp); |
| 838 | } |
| 839 | |
| 840 | /** |
| 841 | * Test simplification of the `-(-var)` pattern. |
| 842 | * The transformation tested is implemented in `InstructionSimplifierVisitor::VisitNeg`. |
| 843 | */ |
| 844 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 845 | /// CHECK-START: long Main.$noinline$NegNeg1(long) instruction_simplifier (before) |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 846 | /// CHECK-DAG: <<Arg:j\d+>> ParameterValue |
| 847 | /// CHECK-DAG: <<Neg1:j\d+>> Neg [<<Arg>>] |
| 848 | /// CHECK-DAG: <<Neg2:j\d+>> Neg [<<Neg1>>] |
| 849 | /// CHECK-DAG: Return [<<Neg2>>] |
Alexandre Rames | 188d431 | 2015-04-09 18:30:21 +0100 | [diff] [blame] | 850 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 851 | /// CHECK-START: long Main.$noinline$NegNeg1(long) instruction_simplifier (after) |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 852 | /// CHECK-DAG: <<Arg:j\d+>> ParameterValue |
| 853 | /// CHECK-DAG: Return [<<Arg>>] |
Alexandre Rames | 188d431 | 2015-04-09 18:30:21 +0100 | [diff] [blame] | 854 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 855 | /// CHECK-START: long Main.$noinline$NegNeg1(long) instruction_simplifier (after) |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 856 | /// CHECK-NOT: Neg |
Alexandre Rames | 188d431 | 2015-04-09 18:30:21 +0100 | [diff] [blame] | 857 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 858 | public static long $noinline$NegNeg1(long arg) { |
Alexandre Rames | 188d431 | 2015-04-09 18:30:21 +0100 | [diff] [blame] | 859 | return -(-arg); |
| 860 | } |
| 861 | |
| 862 | /** |
| 863 | * Test 'multi-step' simplification, where a first transformation yields a |
| 864 | * new simplification possibility for the current instruction. |
| 865 | * The transformations tested are implemented in `InstructionSimplifierVisitor::VisitNeg` |
| 866 | * and in `InstructionSimplifierVisitor::VisitAdd`. |
| 867 | */ |
| 868 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 869 | /// CHECK-START: int Main.$noinline$NegNeg2(int) instruction_simplifier (before) |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 870 | /// CHECK-DAG: <<Arg:i\d+>> ParameterValue |
| 871 | /// CHECK-DAG: <<Neg1:i\d+>> Neg [<<Arg>>] |
| 872 | /// CHECK-DAG: <<Neg2:i\d+>> Neg [<<Neg1>>] |
David Brazdil | 57e863c | 2016-01-11 10:27:13 +0000 | [diff] [blame] | 873 | /// CHECK-DAG: <<Add:i\d+>> Add [<<Neg2>>,<<Neg1>>] |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 874 | /// CHECK-DAG: Return [<<Add>>] |
Alexandre Rames | 188d431 | 2015-04-09 18:30:21 +0100 | [diff] [blame] | 875 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 876 | /// CHECK-START: int Main.$noinline$NegNeg2(int) instruction_simplifier (after) |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 877 | /// CHECK-DAG: <<Arg:i\d+>> ParameterValue |
| 878 | /// CHECK-DAG: <<Sub:i\d+>> Sub [<<Arg>>,<<Arg>>] |
| 879 | /// CHECK-DAG: Return [<<Sub>>] |
Alexandre Rames | 188d431 | 2015-04-09 18:30:21 +0100 | [diff] [blame] | 880 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 881 | /// CHECK-START: int Main.$noinline$NegNeg2(int) instruction_simplifier (after) |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 882 | /// CHECK-NOT: Neg |
| 883 | /// CHECK-NOT: Add |
Alexandre Rames | 188d431 | 2015-04-09 18:30:21 +0100 | [diff] [blame] | 884 | |
Wojciech Staszkiewicz | 5319d3c | 2016-08-01 17:48:59 -0700 | [diff] [blame] | 885 | /// CHECK-START: int Main.$noinline$NegNeg2(int) constant_folding$after_inlining (after) |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 886 | /// CHECK: <<Const0:i\d+>> IntConstant 0 |
| 887 | /// CHECK-NOT: Neg |
| 888 | /// CHECK-NOT: Add |
| 889 | /// CHECK: Return [<<Const0>>] |
Alexandre Rames | b2a5847 | 2015-04-17 14:35:18 +0100 | [diff] [blame] | 890 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 891 | public static int $noinline$NegNeg2(int arg) { |
Alexandre Rames | 188d431 | 2015-04-09 18:30:21 +0100 | [diff] [blame] | 892 | int temp = -arg; |
| 893 | return temp + -temp; |
| 894 | } |
| 895 | |
| 896 | /** |
| 897 | * Test another 'multi-step' simplification, where a first transformation |
| 898 | * yields a new simplification possibility for the current instruction. |
| 899 | * The transformations tested are implemented in `InstructionSimplifierVisitor::VisitNeg` |
| 900 | * and in `InstructionSimplifierVisitor::VisitSub`. |
| 901 | */ |
| 902 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 903 | /// CHECK-START: long Main.$noinline$NegNeg3(long) instruction_simplifier (before) |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 904 | /// CHECK-DAG: <<Arg:j\d+>> ParameterValue |
| 905 | /// CHECK-DAG: <<Const0:j\d+>> LongConstant 0 |
| 906 | /// CHECK-DAG: <<Neg:j\d+>> Neg [<<Arg>>] |
| 907 | /// CHECK-DAG: <<Sub:j\d+>> Sub [<<Const0>>,<<Neg>>] |
| 908 | /// CHECK-DAG: Return [<<Sub>>] |
Alexandre Rames | 188d431 | 2015-04-09 18:30:21 +0100 | [diff] [blame] | 909 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 910 | /// CHECK-START: long Main.$noinline$NegNeg3(long) instruction_simplifier (after) |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 911 | /// CHECK-DAG: <<Arg:j\d+>> ParameterValue |
| 912 | /// CHECK-DAG: Return [<<Arg>>] |
Alexandre Rames | 188d431 | 2015-04-09 18:30:21 +0100 | [diff] [blame] | 913 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 914 | /// CHECK-START: long Main.$noinline$NegNeg3(long) instruction_simplifier (after) |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 915 | /// CHECK-NOT: Neg |
| 916 | /// CHECK-NOT: Sub |
Alexandre Rames | 188d431 | 2015-04-09 18:30:21 +0100 | [diff] [blame] | 917 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 918 | public static long $noinline$NegNeg3(long arg) { |
Alexandre Rames | 188d431 | 2015-04-09 18:30:21 +0100 | [diff] [blame] | 919 | return 0 - -arg; |
| 920 | } |
| 921 | |
| 922 | /** |
| 923 | * Test that a negated subtraction is simplified to a subtraction with its |
| 924 | * arguments reversed. |
| 925 | * The transformation tested is implemented in `InstructionSimplifierVisitor::VisitNeg`. |
| 926 | */ |
| 927 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 928 | /// CHECK-START: int Main.$noinline$NegSub1(int, int) instruction_simplifier (before) |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 929 | /// CHECK-DAG: <<Arg1:i\d+>> ParameterValue |
| 930 | /// CHECK-DAG: <<Arg2:i\d+>> ParameterValue |
| 931 | /// CHECK-DAG: <<Sub:i\d+>> Sub [<<Arg1>>,<<Arg2>>] |
| 932 | /// CHECK-DAG: <<Neg:i\d+>> Neg [<<Sub>>] |
| 933 | /// CHECK-DAG: Return [<<Neg>>] |
Alexandre Rames | 188d431 | 2015-04-09 18:30:21 +0100 | [diff] [blame] | 934 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 935 | /// CHECK-START: int Main.$noinline$NegSub1(int, int) instruction_simplifier (after) |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 936 | /// CHECK-DAG: <<Arg1:i\d+>> ParameterValue |
| 937 | /// CHECK-DAG: <<Arg2:i\d+>> ParameterValue |
| 938 | /// CHECK-DAG: <<Sub:i\d+>> Sub [<<Arg2>>,<<Arg1>>] |
| 939 | /// CHECK-DAG: Return [<<Sub>>] |
Alexandre Rames | 188d431 | 2015-04-09 18:30:21 +0100 | [diff] [blame] | 940 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 941 | /// CHECK-START: int Main.$noinline$NegSub1(int, int) instruction_simplifier (after) |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 942 | /// CHECK-NOT: Neg |
Alexandre Rames | 188d431 | 2015-04-09 18:30:21 +0100 | [diff] [blame] | 943 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 944 | public static int $noinline$NegSub1(int arg1, int arg2) { |
Alexandre Rames | 188d431 | 2015-04-09 18:30:21 +0100 | [diff] [blame] | 945 | return -(arg1 - arg2); |
| 946 | } |
| 947 | |
| 948 | /** |
| 949 | * This is similar to the test-case NegSub1, but the subtraction has |
| 950 | * multiple uses. |
| 951 | * The transformation tested is implemented in `InstructionSimplifierVisitor::VisitNeg`. |
| 952 | * The current code won't perform the previous optimization. The |
| 953 | * transformations do not look at other uses of their inputs. As they don't |
| 954 | * know what will happen with other uses, they do not take the risk of |
| 955 | * increasing the register pressure by creating or extending live ranges. |
| 956 | */ |
| 957 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 958 | /// CHECK-START: int Main.$noinline$NegSub2(int, int) instruction_simplifier (before) |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 959 | /// CHECK-DAG: <<Arg1:i\d+>> ParameterValue |
| 960 | /// CHECK-DAG: <<Arg2:i\d+>> ParameterValue |
| 961 | /// CHECK-DAG: <<Sub:i\d+>> Sub [<<Arg1>>,<<Arg2>>] |
| 962 | /// CHECK-DAG: <<Neg1:i\d+>> Neg [<<Sub>>] |
| 963 | /// CHECK-DAG: <<Neg2:i\d+>> Neg [<<Sub>>] |
| 964 | /// CHECK-DAG: <<Or:i\d+>> Or [<<Neg1>>,<<Neg2>>] |
| 965 | /// CHECK-DAG: Return [<<Or>>] |
Alexandre Rames | 188d431 | 2015-04-09 18:30:21 +0100 | [diff] [blame] | 966 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 967 | /// CHECK-START: int Main.$noinline$NegSub2(int, int) instruction_simplifier (after) |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 968 | /// CHECK-DAG: <<Arg1:i\d+>> ParameterValue |
| 969 | /// CHECK-DAG: <<Arg2:i\d+>> ParameterValue |
| 970 | /// CHECK-DAG: <<Sub:i\d+>> Sub [<<Arg1>>,<<Arg2>>] |
| 971 | /// CHECK-DAG: <<Neg1:i\d+>> Neg [<<Sub>>] |
| 972 | /// CHECK-DAG: <<Neg2:i\d+>> Neg [<<Sub>>] |
| 973 | /// CHECK-DAG: <<Or:i\d+>> Or [<<Neg1>>,<<Neg2>>] |
| 974 | /// CHECK-DAG: Return [<<Or>>] |
Alexandre Rames | 188d431 | 2015-04-09 18:30:21 +0100 | [diff] [blame] | 975 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 976 | public static int $noinline$NegSub2(int arg1, int arg2) { |
Alexandre Rames | 188d431 | 2015-04-09 18:30:21 +0100 | [diff] [blame] | 977 | int temp = arg1 - arg2; |
| 978 | return -temp | -temp; |
| 979 | } |
| 980 | |
| 981 | /** |
| 982 | * Test simplification of the `~~var` pattern. |
| 983 | * The transformation tested is implemented in `InstructionSimplifierVisitor::VisitNot`. |
| 984 | */ |
| 985 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 986 | /// CHECK-START: long Main.$noinline$NotNot1(long) instruction_simplifier (before) |
Igor Murashkin | 4269173 | 2017-06-26 15:57:31 -0700 | [diff] [blame] | 987 | /// CHECK-DAG: <<Arg:j\d+>> ParameterValue |
| 988 | /// CHECK-DAG: <<ConstNeg1:j\d+>> LongConstant -1 |
| 989 | /// CHECK-DAG: <<Not1:j\d+>> Xor [<<Arg>>,<<ConstNeg1>>] |
| 990 | /// CHECK-DAG: <<Not2:j\d+>> Xor [<<Not1>>,<<ConstNeg1>>] |
| 991 | /// CHECK-DAG: Return [<<Not2>>] |
Alexandre Rames | 188d431 | 2015-04-09 18:30:21 +0100 | [diff] [blame] | 992 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 993 | /// CHECK-START: long Main.$noinline$NotNot1(long) instruction_simplifier (after) |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 994 | /// CHECK-DAG: <<Arg:j\d+>> ParameterValue |
| 995 | /// CHECK-DAG: Return [<<Arg>>] |
Alexandre Rames | 188d431 | 2015-04-09 18:30:21 +0100 | [diff] [blame] | 996 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 997 | /// CHECK-START: long Main.$noinline$NotNot1(long) instruction_simplifier (after) |
Igor Murashkin | 4269173 | 2017-06-26 15:57:31 -0700 | [diff] [blame] | 998 | /// CHECK-NOT: Xor |
Alexandre Rames | 188d431 | 2015-04-09 18:30:21 +0100 | [diff] [blame] | 999 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1000 | public static long $noinline$NotNot1(long arg) { |
Alexandre Rames | 188d431 | 2015-04-09 18:30:21 +0100 | [diff] [blame] | 1001 | return ~~arg; |
| 1002 | } |
| 1003 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1004 | /// CHECK-START: int Main.$noinline$NotNot2(int) instruction_simplifier (before) |
Igor Murashkin | 4269173 | 2017-06-26 15:57:31 -0700 | [diff] [blame] | 1005 | /// CHECK-DAG: <<Arg:i\d+>> ParameterValue |
| 1006 | /// CHECK-DAG: <<ConstNeg1:i\d+>> IntConstant -1 |
| 1007 | /// CHECK-DAG: <<Not1:i\d+>> Xor [<<Arg>>,<<ConstNeg1>>] |
| 1008 | /// CHECK-DAG: <<Not2:i\d+>> Xor [<<Not1>>,<<ConstNeg1>>] |
| 1009 | /// CHECK-DAG: <<Add:i\d+>> Add [<<Not2>>,<<Not1>>] |
| 1010 | /// CHECK-DAG: Return [<<Add>>] |
Alexandre Rames | 188d431 | 2015-04-09 18:30:21 +0100 | [diff] [blame] | 1011 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1012 | /// CHECK-START: int Main.$noinline$NotNot2(int) instruction_simplifier (after) |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 1013 | /// CHECK-DAG: <<Arg:i\d+>> ParameterValue |
| 1014 | /// CHECK-DAG: <<Not:i\d+>> Not [<<Arg>>] |
David Brazdil | 57e863c | 2016-01-11 10:27:13 +0000 | [diff] [blame] | 1015 | /// CHECK-DAG: <<Add:i\d+>> Add [<<Arg>>,<<Not>>] |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 1016 | /// CHECK-DAG: Return [<<Add>>] |
Alexandre Rames | 188d431 | 2015-04-09 18:30:21 +0100 | [diff] [blame] | 1017 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1018 | /// CHECK-START: int Main.$noinline$NotNot2(int) instruction_simplifier (after) |
David Brazdil | f02c3cf | 2016-02-29 09:14:51 +0000 | [diff] [blame] | 1019 | /// CHECK: Not |
| 1020 | /// CHECK-NOT: Not |
Alexandre Rames | 188d431 | 2015-04-09 18:30:21 +0100 | [diff] [blame] | 1021 | |
Igor Murashkin | 4269173 | 2017-06-26 15:57:31 -0700 | [diff] [blame] | 1022 | /// CHECK-START: int Main.$noinline$NotNot2(int) instruction_simplifier (after) |
| 1023 | /// CHECK-NOT: Xor |
| 1024 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1025 | public static int $noinline$NotNot2(int arg) { |
Alexandre Rames | 188d431 | 2015-04-09 18:30:21 +0100 | [diff] [blame] | 1026 | int temp = ~arg; |
| 1027 | return temp + ~temp; |
| 1028 | } |
| 1029 | |
| 1030 | /** |
| 1031 | * Test the simplification of a subtraction with a negated argument. |
| 1032 | * The transformation tested is implemented in `InstructionSimplifierVisitor::VisitSub`. |
| 1033 | */ |
| 1034 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1035 | /// CHECK-START: int Main.$noinline$SubNeg1(int, int) instruction_simplifier (before) |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 1036 | /// CHECK-DAG: <<Arg1:i\d+>> ParameterValue |
| 1037 | /// CHECK-DAG: <<Arg2:i\d+>> ParameterValue |
| 1038 | /// CHECK-DAG: <<Neg:i\d+>> Neg [<<Arg1>>] |
| 1039 | /// CHECK-DAG: <<Sub:i\d+>> Sub [<<Neg>>,<<Arg2>>] |
| 1040 | /// CHECK-DAG: Return [<<Sub>>] |
Alexandre Rames | 188d431 | 2015-04-09 18:30:21 +0100 | [diff] [blame] | 1041 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1042 | /// CHECK-START: int Main.$noinline$SubNeg1(int, int) instruction_simplifier (after) |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 1043 | /// CHECK-DAG: <<Arg1:i\d+>> ParameterValue |
| 1044 | /// CHECK-DAG: <<Arg2:i\d+>> ParameterValue |
| 1045 | /// CHECK-DAG: <<Add:i\d+>> Add [<<Arg1>>,<<Arg2>>] |
| 1046 | /// CHECK-DAG: <<Neg:i\d+>> Neg [<<Add>>] |
| 1047 | /// CHECK-DAG: Return [<<Neg>>] |
Alexandre Rames | 188d431 | 2015-04-09 18:30:21 +0100 | [diff] [blame] | 1048 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1049 | /// CHECK-START: int Main.$noinline$SubNeg1(int, int) instruction_simplifier (after) |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 1050 | /// CHECK-NOT: Sub |
Alexandre Rames | 188d431 | 2015-04-09 18:30:21 +0100 | [diff] [blame] | 1051 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1052 | public static int $noinline$SubNeg1(int arg1, int arg2) { |
Alexandre Rames | 188d431 | 2015-04-09 18:30:21 +0100 | [diff] [blame] | 1053 | return -arg1 - arg2; |
| 1054 | } |
| 1055 | |
| 1056 | /** |
| 1057 | * This is similar to the test-case SubNeg1, but the negation has |
| 1058 | * multiple uses. |
| 1059 | * The transformation tested is implemented in `InstructionSimplifierVisitor::VisitSub`. |
| 1060 | * The current code won't perform the previous optimization. The |
| 1061 | * transformations do not look at other uses of their inputs. As they don't |
| 1062 | * know what will happen with other uses, they do not take the risk of |
| 1063 | * increasing the register pressure by creating or extending live ranges. |
| 1064 | */ |
| 1065 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1066 | /// CHECK-START: int Main.$noinline$SubNeg2(int, int) instruction_simplifier (before) |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 1067 | /// CHECK-DAG: <<Arg1:i\d+>> ParameterValue |
| 1068 | /// CHECK-DAG: <<Arg2:i\d+>> ParameterValue |
| 1069 | /// CHECK-DAG: <<Neg:i\d+>> Neg [<<Arg1>>] |
| 1070 | /// CHECK-DAG: <<Sub1:i\d+>> Sub [<<Neg>>,<<Arg2>>] |
| 1071 | /// CHECK-DAG: <<Sub2:i\d+>> Sub [<<Neg>>,<<Arg2>>] |
| 1072 | /// CHECK-DAG: <<Or:i\d+>> Or [<<Sub1>>,<<Sub2>>] |
| 1073 | /// CHECK-DAG: Return [<<Or>>] |
Alexandre Rames | 188d431 | 2015-04-09 18:30:21 +0100 | [diff] [blame] | 1074 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1075 | /// CHECK-START: int Main.$noinline$SubNeg2(int, int) instruction_simplifier (after) |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 1076 | /// CHECK-DAG: <<Arg1:i\d+>> ParameterValue |
| 1077 | /// CHECK-DAG: <<Arg2:i\d+>> ParameterValue |
| 1078 | /// CHECK-DAG: <<Neg:i\d+>> Neg [<<Arg1>>] |
| 1079 | /// CHECK-DAG: <<Sub1:i\d+>> Sub [<<Neg>>,<<Arg2>>] |
| 1080 | /// CHECK-DAG: <<Sub2:i\d+>> Sub [<<Neg>>,<<Arg2>>] |
| 1081 | /// CHECK-DAG: <<Or:i\d+>> Or [<<Sub1>>,<<Sub2>>] |
| 1082 | /// CHECK-DAG: Return [<<Or>>] |
Alexandre Rames | 188d431 | 2015-04-09 18:30:21 +0100 | [diff] [blame] | 1083 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1084 | /// CHECK-START: int Main.$noinline$SubNeg2(int, int) instruction_simplifier (after) |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 1085 | /// CHECK-NOT: Add |
Alexandre Rames | 188d431 | 2015-04-09 18:30:21 +0100 | [diff] [blame] | 1086 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1087 | public static int $noinline$SubNeg2(int arg1, int arg2) { |
Alexandre Rames | 188d431 | 2015-04-09 18:30:21 +0100 | [diff] [blame] | 1088 | int temp = -arg1; |
| 1089 | return (temp - arg2) | (temp - arg2); |
| 1090 | } |
| 1091 | |
| 1092 | /** |
| 1093 | * This follows test-cases SubNeg1 and SubNeg2. |
| 1094 | * The transformation tested is implemented in `InstructionSimplifierVisitor::VisitSub`. |
| 1095 | * The optimization should not happen if it moves an additional instruction in |
| 1096 | * the loop. |
| 1097 | */ |
| 1098 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1099 | /// CHECK-START: long Main.$noinline$SubNeg3(long, long) instruction_simplifier (before) |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 1100 | // -------------- Arguments and initial negation operation. |
| 1101 | /// CHECK-DAG: <<Arg1:j\d+>> ParameterValue |
| 1102 | /// CHECK-DAG: <<Arg2:j\d+>> ParameterValue |
| 1103 | /// CHECK-DAG: <<Neg:j\d+>> Neg [<<Arg1>>] |
| 1104 | /// CHECK: Goto |
| 1105 | // -------------- Loop |
| 1106 | /// CHECK: SuspendCheck |
| 1107 | /// CHECK: <<Sub:j\d+>> Sub [<<Neg>>,<<Arg2>>] |
| 1108 | /// CHECK: Goto |
Alexandre Rames | 188d431 | 2015-04-09 18:30:21 +0100 | [diff] [blame] | 1109 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1110 | /// CHECK-START: long Main.$noinline$SubNeg3(long, long) instruction_simplifier (after) |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 1111 | // -------------- Arguments and initial negation operation. |
| 1112 | /// CHECK-DAG: <<Arg1:j\d+>> ParameterValue |
| 1113 | /// CHECK-DAG: <<Arg2:j\d+>> ParameterValue |
| 1114 | /// CHECK-DAG: <<Neg:j\d+>> Neg [<<Arg1>>] |
| 1115 | /// CHECK-DAG: Goto |
| 1116 | // -------------- Loop |
| 1117 | /// CHECK: SuspendCheck |
| 1118 | /// CHECK: <<Sub:j\d+>> Sub [<<Neg>>,<<Arg2>>] |
| 1119 | /// CHECK-NOT: Neg |
| 1120 | /// CHECK: Goto |
Alexandre Rames | 188d431 | 2015-04-09 18:30:21 +0100 | [diff] [blame] | 1121 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1122 | public static long $noinline$SubNeg3(long arg1, long arg2) { |
Alexandre Rames | 188d431 | 2015-04-09 18:30:21 +0100 | [diff] [blame] | 1123 | long res = 0; |
| 1124 | long temp = -arg1; |
| 1125 | for (long i = 0; i < 1; i++) { |
| 1126 | res += temp - arg2 - i; |
| 1127 | } |
| 1128 | return res; |
| 1129 | } |
| 1130 | |
Aart Bik | 639cc8c | 2016-10-18 13:03:31 -0700 | [diff] [blame] | 1131 | /// CHECK-START: boolean Main.$noinline$EqualBoolVsIntConst(boolean) instruction_simplifier$after_inlining (before) |
David Brazdil | 1e9ec05 | 2015-06-22 10:26:45 +0100 | [diff] [blame] | 1132 | /// CHECK-DAG: <<Arg:z\d+>> ParameterValue |
David Brazdil | 74eb1b2 | 2015-12-14 11:44:01 +0000 | [diff] [blame] | 1133 | /// CHECK-DAG: <<Const0:i\d+>> IntConstant 0 |
| 1134 | /// CHECK-DAG: <<Const1:i\d+>> IntConstant 1 |
David Brazdil | 1e9ec05 | 2015-06-22 10:26:45 +0100 | [diff] [blame] | 1135 | /// CHECK-DAG: <<Const2:i\d+>> IntConstant 2 |
David Brazdil | 74eb1b2 | 2015-12-14 11:44:01 +0000 | [diff] [blame] | 1136 | /// CHECK-DAG: <<NotArg:i\d+>> Select [<<Const1>>,<<Const0>>,<<Arg>>] |
| 1137 | /// CHECK-DAG: <<Cond:z\d+>> Equal [<<NotArg>>,<<Const2>>] |
| 1138 | /// CHECK-DAG: <<NotCond:i\d+>> Select [<<Const1>>,<<Const0>>,<<Cond>>] |
| 1139 | /// CHECK-DAG: Return [<<NotCond>>] |
David Brazdil | 1e9ec05 | 2015-06-22 10:26:45 +0100 | [diff] [blame] | 1140 | |
Aart Bik | 639cc8c | 2016-10-18 13:03:31 -0700 | [diff] [blame] | 1141 | /// CHECK-START: boolean Main.$noinline$EqualBoolVsIntConst(boolean) instruction_simplifier$after_inlining (after) |
David Brazdil | 74eb1b2 | 2015-12-14 11:44:01 +0000 | [diff] [blame] | 1142 | /// CHECK-DAG: <<True:i\d+>> IntConstant 1 |
| 1143 | /// CHECK-DAG: Return [<<True>>] |
David Brazdil | 1e9ec05 | 2015-06-22 10:26:45 +0100 | [diff] [blame] | 1144 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1145 | public static boolean $noinline$EqualBoolVsIntConst(boolean arg) { |
Nicolas Geoffray | dac9b19 | 2016-07-15 10:46:17 +0100 | [diff] [blame] | 1146 | // Make calls that will be inlined to make sure the instruction simplifier |
| 1147 | // sees the simplification (dead code elimination will also try to simplify it). |
| 1148 | return (arg ? $inline$ReturnArg(0) : $inline$ReturnArg(1)) != 2; |
| 1149 | } |
| 1150 | |
| 1151 | public static int $inline$ReturnArg(int arg) { |
| 1152 | return arg; |
David Brazdil | 1e9ec05 | 2015-06-22 10:26:45 +0100 | [diff] [blame] | 1153 | } |
| 1154 | |
Aart Bik | 639cc8c | 2016-10-18 13:03:31 -0700 | [diff] [blame] | 1155 | /// CHECK-START: boolean Main.$noinline$NotEqualBoolVsIntConst(boolean) instruction_simplifier$after_inlining (before) |
David Brazdil | 1e9ec05 | 2015-06-22 10:26:45 +0100 | [diff] [blame] | 1156 | /// CHECK-DAG: <<Arg:z\d+>> ParameterValue |
David Brazdil | 74eb1b2 | 2015-12-14 11:44:01 +0000 | [diff] [blame] | 1157 | /// CHECK-DAG: <<Const0:i\d+>> IntConstant 0 |
| 1158 | /// CHECK-DAG: <<Const1:i\d+>> IntConstant 1 |
David Brazdil | 1e9ec05 | 2015-06-22 10:26:45 +0100 | [diff] [blame] | 1159 | /// CHECK-DAG: <<Const2:i\d+>> IntConstant 2 |
David Brazdil | 74eb1b2 | 2015-12-14 11:44:01 +0000 | [diff] [blame] | 1160 | /// CHECK-DAG: <<NotArg:i\d+>> Select [<<Const1>>,<<Const0>>,<<Arg>>] |
| 1161 | /// CHECK-DAG: <<Cond:z\d+>> NotEqual [<<NotArg>>,<<Const2>>] |
| 1162 | /// CHECK-DAG: <<NotCond:i\d+>> Select [<<Const1>>,<<Const0>>,<<Cond>>] |
| 1163 | /// CHECK-DAG: Return [<<NotCond>>] |
David Brazdil | 1e9ec05 | 2015-06-22 10:26:45 +0100 | [diff] [blame] | 1164 | |
Aart Bik | 639cc8c | 2016-10-18 13:03:31 -0700 | [diff] [blame] | 1165 | /// CHECK-START: boolean Main.$noinline$NotEqualBoolVsIntConst(boolean) instruction_simplifier$after_inlining (after) |
David Brazdil | 74eb1b2 | 2015-12-14 11:44:01 +0000 | [diff] [blame] | 1166 | /// CHECK-DAG: <<False:i\d+>> IntConstant 0 |
| 1167 | /// CHECK-DAG: Return [<<False>>] |
David Brazdil | 1e9ec05 | 2015-06-22 10:26:45 +0100 | [diff] [blame] | 1168 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1169 | public static boolean $noinline$NotEqualBoolVsIntConst(boolean arg) { |
Nicolas Geoffray | dac9b19 | 2016-07-15 10:46:17 +0100 | [diff] [blame] | 1170 | // Make calls that will be inlined to make sure the instruction simplifier |
| 1171 | // sees the simplification (dead code elimination will also try to simplify it). |
| 1172 | return (arg ? $inline$ReturnArg(0) : $inline$ReturnArg(1)) == 2; |
David Brazdil | 1e9ec05 | 2015-06-22 10:26:45 +0100 | [diff] [blame] | 1173 | } |
| 1174 | |
David Brazdil | 0d13fee | 2015-04-17 14:52:19 +0100 | [diff] [blame] | 1175 | /* |
| 1176 | * Test simplification of double Boolean negation. Note that sometimes |
| 1177 | * both negations can be removed but we only expect the simplifier to |
| 1178 | * remove the second. |
| 1179 | */ |
| 1180 | |
Sebastien Hertz | 9837caf | 2016-08-01 11:09:50 +0200 | [diff] [blame] | 1181 | /// CHECK-START: boolean Main.$noinline$NotNotBool(boolean) instruction_simplifier (before) |
| 1182 | /// CHECK-DAG: <<Arg:z\d+>> ParameterValue |
Igor Murashkin | 4269173 | 2017-06-26 15:57:31 -0700 | [diff] [blame] | 1183 | /// CHECK-DAG: <<Const1:i\d+>> IntConstant 0 |
| 1184 | /// CHECK-DAG: <<Result:z\d+>> InvokeStaticOrDirect method_name:Main.NegateValue |
| 1185 | /// CHECK-DAG: <<NotResult:z\d+>> NotEqual [<<Result>>,<<Const1>>] |
| 1186 | /// CHECK-DAG: If [<<NotResult>>] |
| 1187 | |
| 1188 | /// CHECK-START: boolean Main.$noinline$NotNotBool(boolean) instruction_simplifier (after) |
| 1189 | /// CHECK-NOT: NotEqual |
Sebastien Hertz | 9837caf | 2016-08-01 11:09:50 +0200 | [diff] [blame] | 1190 | |
| 1191 | /// CHECK-START: boolean Main.$noinline$NotNotBool(boolean) instruction_simplifier (after) |
| 1192 | /// CHECK-DAG: <<Arg:z\d+>> ParameterValue |
Igor Murashkin | 4269173 | 2017-06-26 15:57:31 -0700 | [diff] [blame] | 1193 | /// CHECK-DAG: <<Result:z\d+>> InvokeStaticOrDirect method_name:Main.NegateValue |
| 1194 | /// CHECK-DAG: <<Const0:i\d+>> IntConstant 0 |
| 1195 | /// CHECK-DAG: <<Const1:i\d+>> IntConstant 1 |
| 1196 | /// CHECK-DAG: <<Phi:i\d+>> Phi [<<Const1>>,<<Const0>>] |
| 1197 | /// CHECK-DAG: Return [<<Phi>>] |
Sebastien Hertz | 9837caf | 2016-08-01 11:09:50 +0200 | [diff] [blame] | 1198 | |
Aart Bik | 639cc8c | 2016-10-18 13:03:31 -0700 | [diff] [blame] | 1199 | /// CHECK-START: boolean Main.$noinline$NotNotBool(boolean) instruction_simplifier$after_inlining (before) |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 1200 | /// CHECK-DAG: <<Arg:z\d+>> ParameterValue |
Igor Murashkin | 4269173 | 2017-06-26 15:57:31 -0700 | [diff] [blame] | 1201 | /// CHECK-NOT: BooleanNot [<<Arg>>] |
| 1202 | /// CHECK-NOT: Phi |
| 1203 | |
| 1204 | /// CHECK-START: boolean Main.$noinline$NotNotBool(boolean) instruction_simplifier$after_inlining (before) |
| 1205 | /// CHECK-DAG: <<Arg:z\d+>> ParameterValue |
| 1206 | /// CHECK-DAG: <<Const0:i\d+>> IntConstant 0 |
| 1207 | /// CHECK-DAG: <<Const1:i\d+>> IntConstant 1 |
| 1208 | /// CHECK-DAG: <<Sel:i\d+>> Select [<<Const1>>,<<Const0>>,<<Arg>>] |
| 1209 | /// CHECK-DAG: <<Sel2:i\d+>> Select [<<Const1>>,<<Const0>>,<<Sel>>] |
| 1210 | /// CHECK-DAG: Return [<<Sel2>>] |
David Brazdil | 0d13fee | 2015-04-17 14:52:19 +0100 | [diff] [blame] | 1211 | |
Aart Bik | 639cc8c | 2016-10-18 13:03:31 -0700 | [diff] [blame] | 1212 | /// CHECK-START: boolean Main.$noinline$NotNotBool(boolean) instruction_simplifier$after_inlining (after) |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 1213 | /// CHECK-DAG: <<Arg:z\d+>> ParameterValue |
Igor Murashkin | 4269173 | 2017-06-26 15:57:31 -0700 | [diff] [blame] | 1214 | /// CHECK: BooleanNot [<<Arg>>] |
| 1215 | /// CHECK-NEXT: Goto |
| 1216 | |
| 1217 | /// CHECK-START: boolean Main.$noinline$NotNotBool(boolean) instruction_simplifier$after_inlining (after) |
| 1218 | /// CHECK-NOT: Select |
David Brazdil | 0d13fee | 2015-04-17 14:52:19 +0100 | [diff] [blame] | 1219 | |
Sebastien Hertz | 55418e1 | 2016-09-23 16:51:42 +0200 | [diff] [blame] | 1220 | /// CHECK-START: boolean Main.$noinline$NotNotBool(boolean) dead_code_elimination$final (after) |
| 1221 | /// CHECK-DAG: <<Arg:z\d+>> ParameterValue |
Igor Murashkin | 4269173 | 2017-06-26 15:57:31 -0700 | [diff] [blame] | 1222 | /// CHECK-NOT: BooleanNot [<<Arg>>] |
Sebastien Hertz | 55418e1 | 2016-09-23 16:51:42 +0200 | [diff] [blame] | 1223 | /// CHECK-DAG: Return [<<Arg>>] |
| 1224 | |
David Brazdil | 769c9e5 | 2015-04-27 13:54:09 +0100 | [diff] [blame] | 1225 | public static boolean NegateValue(boolean arg) { |
| 1226 | return !arg; |
| 1227 | } |
| 1228 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1229 | public static boolean $noinline$NotNotBool(boolean arg) { |
David Brazdil | 769c9e5 | 2015-04-27 13:54:09 +0100 | [diff] [blame] | 1230 | return !(NegateValue(arg)); |
David Brazdil | 0d13fee | 2015-04-17 14:52:19 +0100 | [diff] [blame] | 1231 | } |
| 1232 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1233 | /// CHECK-START: float Main.$noinline$Div2(float) instruction_simplifier (before) |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 1234 | /// CHECK-DAG: <<Arg:f\d+>> ParameterValue |
| 1235 | /// CHECK-DAG: <<Const2:f\d+>> FloatConstant 2 |
| 1236 | /// CHECK-DAG: <<Div:f\d+>> Div [<<Arg>>,<<Const2>>] |
| 1237 | /// CHECK-DAG: Return [<<Div>>] |
Nicolas Geoffray | 0d22184 | 2015-04-27 08:53:46 +0000 | [diff] [blame] | 1238 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1239 | /// CHECK-START: float Main.$noinline$Div2(float) instruction_simplifier (after) |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 1240 | /// CHECK-DAG: <<Arg:f\d+>> ParameterValue |
| 1241 | /// CHECK-DAG: <<ConstP5:f\d+>> FloatConstant 0.5 |
| 1242 | /// CHECK-DAG: <<Mul:f\d+>> Mul [<<Arg>>,<<ConstP5>>] |
| 1243 | /// CHECK-DAG: Return [<<Mul>>] |
Nicolas Geoffray | 0d22184 | 2015-04-27 08:53:46 +0000 | [diff] [blame] | 1244 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1245 | /// CHECK-START: float Main.$noinline$Div2(float) instruction_simplifier (after) |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 1246 | /// CHECK-NOT: Div |
Nicolas Geoffray | 0d22184 | 2015-04-27 08:53:46 +0000 | [diff] [blame] | 1247 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1248 | public static float $noinline$Div2(float arg) { |
Nicolas Geoffray | 0d22184 | 2015-04-27 08:53:46 +0000 | [diff] [blame] | 1249 | return arg / 2.0f; |
| 1250 | } |
| 1251 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1252 | /// CHECK-START: double Main.$noinline$Div2(double) instruction_simplifier (before) |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 1253 | /// CHECK-DAG: <<Arg:d\d+>> ParameterValue |
| 1254 | /// CHECK-DAG: <<Const2:d\d+>> DoubleConstant 2 |
| 1255 | /// CHECK-DAG: <<Div:d\d+>> Div [<<Arg>>,<<Const2>>] |
| 1256 | /// CHECK-DAG: Return [<<Div>>] |
Nicolas Geoffray | 0d22184 | 2015-04-27 08:53:46 +0000 | [diff] [blame] | 1257 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1258 | /// CHECK-START: double Main.$noinline$Div2(double) instruction_simplifier (after) |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 1259 | /// CHECK-DAG: <<Arg:d\d+>> ParameterValue |
| 1260 | /// CHECK-DAG: <<ConstP5:d\d+>> DoubleConstant 0.5 |
| 1261 | /// CHECK-DAG: <<Mul:d\d+>> Mul [<<Arg>>,<<ConstP5>>] |
| 1262 | /// CHECK-DAG: Return [<<Mul>>] |
Nicolas Geoffray | 0d22184 | 2015-04-27 08:53:46 +0000 | [diff] [blame] | 1263 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1264 | /// CHECK-START: double Main.$noinline$Div2(double) instruction_simplifier (after) |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 1265 | /// CHECK-NOT: Div |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1266 | public static double $noinline$Div2(double arg) { |
Nicolas Geoffray | 0d22184 | 2015-04-27 08:53:46 +0000 | [diff] [blame] | 1267 | return arg / 2.0; |
| 1268 | } |
| 1269 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1270 | /// CHECK-START: float Main.$noinline$DivMP25(float) instruction_simplifier (before) |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 1271 | /// CHECK-DAG: <<Arg:f\d+>> ParameterValue |
| 1272 | /// CHECK-DAG: <<ConstMP25:f\d+>> FloatConstant -0.25 |
| 1273 | /// CHECK-DAG: <<Div:f\d+>> Div [<<Arg>>,<<ConstMP25>>] |
| 1274 | /// CHECK-DAG: Return [<<Div>>] |
Nicolas Geoffray | 0d22184 | 2015-04-27 08:53:46 +0000 | [diff] [blame] | 1275 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1276 | /// CHECK-START: float Main.$noinline$DivMP25(float) instruction_simplifier (after) |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 1277 | /// CHECK-DAG: <<Arg:f\d+>> ParameterValue |
| 1278 | /// CHECK-DAG: <<ConstM4:f\d+>> FloatConstant -4 |
| 1279 | /// CHECK-DAG: <<Mul:f\d+>> Mul [<<Arg>>,<<ConstM4>>] |
| 1280 | /// CHECK-DAG: Return [<<Mul>>] |
Nicolas Geoffray | 0d22184 | 2015-04-27 08:53:46 +0000 | [diff] [blame] | 1281 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1282 | /// CHECK-START: float Main.$noinline$DivMP25(float) instruction_simplifier (after) |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 1283 | /// CHECK-NOT: Div |
Nicolas Geoffray | 0d22184 | 2015-04-27 08:53:46 +0000 | [diff] [blame] | 1284 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1285 | public static float $noinline$DivMP25(float arg) { |
Nicolas Geoffray | 0d22184 | 2015-04-27 08:53:46 +0000 | [diff] [blame] | 1286 | return arg / -0.25f; |
| 1287 | } |
| 1288 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1289 | /// CHECK-START: double Main.$noinline$DivMP25(double) instruction_simplifier (before) |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 1290 | /// CHECK-DAG: <<Arg:d\d+>> ParameterValue |
| 1291 | /// CHECK-DAG: <<ConstMP25:d\d+>> DoubleConstant -0.25 |
| 1292 | /// CHECK-DAG: <<Div:d\d+>> Div [<<Arg>>,<<ConstMP25>>] |
| 1293 | /// CHECK-DAG: Return [<<Div>>] |
Nicolas Geoffray | 0d22184 | 2015-04-27 08:53:46 +0000 | [diff] [blame] | 1294 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1295 | /// CHECK-START: double Main.$noinline$DivMP25(double) instruction_simplifier (after) |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 1296 | /// CHECK-DAG: <<Arg:d\d+>> ParameterValue |
| 1297 | /// CHECK-DAG: <<ConstM4:d\d+>> DoubleConstant -4 |
| 1298 | /// CHECK-DAG: <<Mul:d\d+>> Mul [<<Arg>>,<<ConstM4>>] |
| 1299 | /// CHECK-DAG: Return [<<Mul>>] |
Nicolas Geoffray | 0d22184 | 2015-04-27 08:53:46 +0000 | [diff] [blame] | 1300 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1301 | /// CHECK-START: double Main.$noinline$DivMP25(double) instruction_simplifier (after) |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 1302 | /// CHECK-NOT: Div |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1303 | public static double $noinline$DivMP25(double arg) { |
Nicolas Geoffray | 0d22184 | 2015-04-27 08:53:46 +0000 | [diff] [blame] | 1304 | return arg / -0.25f; |
| 1305 | } |
| 1306 | |
Alexandre Rames | 38db785 | 2015-11-20 15:02:45 +0000 | [diff] [blame] | 1307 | /** |
| 1308 | * Test strength reduction of factors of the form (2^n + 1). |
| 1309 | */ |
| 1310 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1311 | /// CHECK-START: int Main.$noinline$mulPow2Plus1(int) instruction_simplifier (before) |
Alexandre Rames | 38db785 | 2015-11-20 15:02:45 +0000 | [diff] [blame] | 1312 | /// CHECK-DAG: <<Arg:i\d+>> ParameterValue |
| 1313 | /// CHECK-DAG: <<Const9:i\d+>> IntConstant 9 |
| 1314 | /// CHECK: Mul [<<Arg>>,<<Const9>>] |
| 1315 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1316 | /// CHECK-START: int Main.$noinline$mulPow2Plus1(int) instruction_simplifier (after) |
Alexandre Rames | 38db785 | 2015-11-20 15:02:45 +0000 | [diff] [blame] | 1317 | /// CHECK-DAG: <<Arg:i\d+>> ParameterValue |
| 1318 | /// CHECK-DAG: <<Const3:i\d+>> IntConstant 3 |
| 1319 | /// CHECK: <<Shift:i\d+>> Shl [<<Arg>>,<<Const3>>] |
| 1320 | /// CHECK-NEXT: Add [<<Arg>>,<<Shift>>] |
| 1321 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1322 | public static int $noinline$mulPow2Plus1(int arg) { |
Alexandre Rames | 38db785 | 2015-11-20 15:02:45 +0000 | [diff] [blame] | 1323 | return arg * 9; |
| 1324 | } |
| 1325 | |
Alexandre Rames | 38db785 | 2015-11-20 15:02:45 +0000 | [diff] [blame] | 1326 | /** |
| 1327 | * Test strength reduction of factors of the form (2^n - 1). |
| 1328 | */ |
| 1329 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1330 | /// CHECK-START: long Main.$noinline$mulPow2Minus1(long) instruction_simplifier (before) |
Alexandre Rames | 38db785 | 2015-11-20 15:02:45 +0000 | [diff] [blame] | 1331 | /// CHECK-DAG: <<Arg:j\d+>> ParameterValue |
| 1332 | /// CHECK-DAG: <<Const31:j\d+>> LongConstant 31 |
David Brazdil | 57e863c | 2016-01-11 10:27:13 +0000 | [diff] [blame] | 1333 | /// CHECK: Mul [<<Const31>>,<<Arg>>] |
Alexandre Rames | 38db785 | 2015-11-20 15:02:45 +0000 | [diff] [blame] | 1334 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1335 | /// CHECK-START: long Main.$noinline$mulPow2Minus1(long) instruction_simplifier (after) |
Alexandre Rames | 38db785 | 2015-11-20 15:02:45 +0000 | [diff] [blame] | 1336 | /// CHECK-DAG: <<Arg:j\d+>> ParameterValue |
| 1337 | /// CHECK-DAG: <<Const5:i\d+>> IntConstant 5 |
| 1338 | /// CHECK: <<Shift:j\d+>> Shl [<<Arg>>,<<Const5>>] |
| 1339 | /// CHECK-NEXT: Sub [<<Shift>>,<<Arg>>] |
| 1340 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1341 | public static long $noinline$mulPow2Minus1(long arg) { |
Alexandre Rames | 38db785 | 2015-11-20 15:02:45 +0000 | [diff] [blame] | 1342 | return arg * 31; |
| 1343 | } |
| 1344 | |
Aart Bik | 639cc8c | 2016-10-18 13:03:31 -0700 | [diff] [blame] | 1345 | /// CHECK-START: int Main.$noinline$booleanFieldNotEqualOne() instruction_simplifier$after_inlining (before) |
Mark Mendell | f652917 | 2015-11-17 11:16:56 -0500 | [diff] [blame] | 1346 | /// CHECK-DAG: <<Const1:i\d+>> IntConstant 1 |
David Brazdil | f02c3cf | 2016-02-29 09:14:51 +0000 | [diff] [blame] | 1347 | /// CHECK-DAG: <<Const13:i\d+>> IntConstant 13 |
| 1348 | /// CHECK-DAG: <<Const54:i\d+>> IntConstant 54 |
Mark Mendell | f652917 | 2015-11-17 11:16:56 -0500 | [diff] [blame] | 1349 | /// CHECK-DAG: <<Field:z\d+>> StaticFieldGet |
| 1350 | /// CHECK-DAG: <<NE:z\d+>> NotEqual [<<Field>>,<<Const1>>] |
David Brazdil | f02c3cf | 2016-02-29 09:14:51 +0000 | [diff] [blame] | 1351 | /// CHECK-DAG: <<Select:i\d+>> Select [<<Const13>>,<<Const54>>,<<NE>>] |
| 1352 | /// CHECK-DAG: Return [<<Select>>] |
Mark Mendell | f652917 | 2015-11-17 11:16:56 -0500 | [diff] [blame] | 1353 | |
Aart Bik | 639cc8c | 2016-10-18 13:03:31 -0700 | [diff] [blame] | 1354 | /// CHECK-START: int Main.$noinline$booleanFieldNotEqualOne() instruction_simplifier$after_inlining (after) |
David Brazdil | 74eb1b2 | 2015-12-14 11:44:01 +0000 | [diff] [blame] | 1355 | /// CHECK-DAG: <<Field:z\d+>> StaticFieldGet |
| 1356 | /// CHECK-DAG: <<Const13:i\d+>> IntConstant 13 |
| 1357 | /// CHECK-DAG: <<Const54:i\d+>> IntConstant 54 |
| 1358 | /// CHECK-DAG: <<Select:i\d+>> Select [<<Const54>>,<<Const13>>,<<Field>>] |
| 1359 | /// CHECK-DAG: Return [<<Select>>] |
Mark Mendell | f652917 | 2015-11-17 11:16:56 -0500 | [diff] [blame] | 1360 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1361 | public static int $noinline$booleanFieldNotEqualOne() { |
David Brazdil | f02c3cf | 2016-02-29 09:14:51 +0000 | [diff] [blame] | 1362 | return (booleanField == $inline$true()) ? 13 : 54; |
Mark Mendell | f652917 | 2015-11-17 11:16:56 -0500 | [diff] [blame] | 1363 | } |
| 1364 | |
Aart Bik | 639cc8c | 2016-10-18 13:03:31 -0700 | [diff] [blame] | 1365 | /// CHECK-START: int Main.$noinline$booleanFieldEqualZero() instruction_simplifier$after_inlining (before) |
Mark Mendell | f652917 | 2015-11-17 11:16:56 -0500 | [diff] [blame] | 1366 | /// CHECK-DAG: <<Const0:i\d+>> IntConstant 0 |
David Brazdil | f02c3cf | 2016-02-29 09:14:51 +0000 | [diff] [blame] | 1367 | /// CHECK-DAG: <<Const13:i\d+>> IntConstant 13 |
| 1368 | /// CHECK-DAG: <<Const54:i\d+>> IntConstant 54 |
Mark Mendell | f652917 | 2015-11-17 11:16:56 -0500 | [diff] [blame] | 1369 | /// CHECK-DAG: <<Field:z\d+>> StaticFieldGet |
David Brazdil | f02c3cf | 2016-02-29 09:14:51 +0000 | [diff] [blame] | 1370 | /// CHECK-DAG: <<NE:z\d+>> Equal [<<Field>>,<<Const0>>] |
| 1371 | /// CHECK-DAG: <<Select:i\d+>> Select [<<Const13>>,<<Const54>>,<<NE>>] |
| 1372 | /// CHECK-DAG: Return [<<Select>>] |
Mark Mendell | f652917 | 2015-11-17 11:16:56 -0500 | [diff] [blame] | 1373 | |
Aart Bik | 639cc8c | 2016-10-18 13:03:31 -0700 | [diff] [blame] | 1374 | /// CHECK-START: int Main.$noinline$booleanFieldEqualZero() instruction_simplifier$after_inlining (after) |
David Brazdil | 74eb1b2 | 2015-12-14 11:44:01 +0000 | [diff] [blame] | 1375 | /// CHECK-DAG: <<Field:z\d+>> StaticFieldGet |
| 1376 | /// CHECK-DAG: <<Const13:i\d+>> IntConstant 13 |
| 1377 | /// CHECK-DAG: <<Const54:i\d+>> IntConstant 54 |
| 1378 | /// CHECK-DAG: <<Select:i\d+>> Select [<<Const54>>,<<Const13>>,<<Field>>] |
| 1379 | /// CHECK-DAG: Return [<<Select>>] |
Mark Mendell | f652917 | 2015-11-17 11:16:56 -0500 | [diff] [blame] | 1380 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1381 | public static int $noinline$booleanFieldEqualZero() { |
David Brazdil | f02c3cf | 2016-02-29 09:14:51 +0000 | [diff] [blame] | 1382 | return (booleanField != $inline$false()) ? 13 : 54; |
Mark Mendell | f652917 | 2015-11-17 11:16:56 -0500 | [diff] [blame] | 1383 | } |
| 1384 | |
Aart Bik | 639cc8c | 2016-10-18 13:03:31 -0700 | [diff] [blame] | 1385 | /// CHECK-START: int Main.$noinline$intConditionNotEqualOne(int) instruction_simplifier$after_inlining (before) |
Mark Mendell | f652917 | 2015-11-17 11:16:56 -0500 | [diff] [blame] | 1386 | /// CHECK-DAG: <<Arg:i\d+>> ParameterValue |
David Brazdil | 74eb1b2 | 2015-12-14 11:44:01 +0000 | [diff] [blame] | 1387 | /// CHECK-DAG: <<Const0:i\d+>> IntConstant 0 |
Mark Mendell | f652917 | 2015-11-17 11:16:56 -0500 | [diff] [blame] | 1388 | /// CHECK-DAG: <<Const1:i\d+>> IntConstant 1 |
David Brazdil | 74eb1b2 | 2015-12-14 11:44:01 +0000 | [diff] [blame] | 1389 | /// CHECK-DAG: <<Const13:i\d+>> IntConstant 13 |
Mark Mendell | f652917 | 2015-11-17 11:16:56 -0500 | [diff] [blame] | 1390 | /// CHECK-DAG: <<Const42:i\d+>> IntConstant 42 |
David Brazdil | 74eb1b2 | 2015-12-14 11:44:01 +0000 | [diff] [blame] | 1391 | /// CHECK-DAG: <<Const54:i\d+>> IntConstant 54 |
| 1392 | /// CHECK-DAG: <<LE:z\d+>> LessThanOrEqual [<<Arg>>,<<Const42>>] |
| 1393 | /// CHECK-DAG: <<GT:i\d+>> Select [<<Const1>>,<<Const0>>,<<LE>>] |
Mark Mendell | f652917 | 2015-11-17 11:16:56 -0500 | [diff] [blame] | 1394 | /// CHECK-DAG: <<NE:z\d+>> NotEqual [<<GT>>,<<Const1>>] |
David Brazdil | 74eb1b2 | 2015-12-14 11:44:01 +0000 | [diff] [blame] | 1395 | /// CHECK-DAG: <<Result:i\d+>> Select [<<Const13>>,<<Const54>>,<<NE>>] |
| 1396 | /// CHECK-DAG: Return [<<Result>>] |
Mark Mendell | f652917 | 2015-11-17 11:16:56 -0500 | [diff] [blame] | 1397 | |
Aart Bik | 639cc8c | 2016-10-18 13:03:31 -0700 | [diff] [blame] | 1398 | /// CHECK-START: int Main.$noinline$intConditionNotEqualOne(int) instruction_simplifier$after_inlining (after) |
Mark Mendell | f652917 | 2015-11-17 11:16:56 -0500 | [diff] [blame] | 1399 | /// CHECK-DAG: <<Arg:i\d+>> ParameterValue |
David Brazdil | 74eb1b2 | 2015-12-14 11:44:01 +0000 | [diff] [blame] | 1400 | /// CHECK-DAG: <<Const13:i\d+>> IntConstant 13 |
Mark Mendell | f652917 | 2015-11-17 11:16:56 -0500 | [diff] [blame] | 1401 | /// CHECK-DAG: <<Const42:i\d+>> IntConstant 42 |
David Brazdil | 74eb1b2 | 2015-12-14 11:44:01 +0000 | [diff] [blame] | 1402 | /// CHECK-DAG: <<Const54:i\d+>> IntConstant 54 |
| 1403 | /// CHECK-DAG: <<Result:i\d+>> Select [<<Const13>>,<<Const54>>,<<LE:z\d+>>] |
Mark Mendell | f652917 | 2015-11-17 11:16:56 -0500 | [diff] [blame] | 1404 | /// CHECK-DAG: <<LE>> LessThanOrEqual [<<Arg>>,<<Const42>>] |
David Brazdil | 74eb1b2 | 2015-12-14 11:44:01 +0000 | [diff] [blame] | 1405 | /// CHECK-DAG: Return [<<Result>>] |
| 1406 | // Note that we match `LE` from Select because there are two identical |
| 1407 | // LessThanOrEqual instructions. |
Mark Mendell | f652917 | 2015-11-17 11:16:56 -0500 | [diff] [blame] | 1408 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1409 | public static int $noinline$intConditionNotEqualOne(int i) { |
David Brazdil | f02c3cf | 2016-02-29 09:14:51 +0000 | [diff] [blame] | 1410 | return ((i > 42) == $inline$true()) ? 13 : 54; |
Mark Mendell | f652917 | 2015-11-17 11:16:56 -0500 | [diff] [blame] | 1411 | } |
| 1412 | |
Aart Bik | 639cc8c | 2016-10-18 13:03:31 -0700 | [diff] [blame] | 1413 | /// CHECK-START: int Main.$noinline$intConditionEqualZero(int) instruction_simplifier$after_inlining (before) |
Mark Mendell | f652917 | 2015-11-17 11:16:56 -0500 | [diff] [blame] | 1414 | /// CHECK-DAG: <<Arg:i\d+>> ParameterValue |
| 1415 | /// CHECK-DAG: <<Const0:i\d+>> IntConstant 0 |
David Brazdil | 74eb1b2 | 2015-12-14 11:44:01 +0000 | [diff] [blame] | 1416 | /// CHECK-DAG: <<Const1:i\d+>> IntConstant 1 |
| 1417 | /// CHECK-DAG: <<Const13:i\d+>> IntConstant 13 |
Mark Mendell | f652917 | 2015-11-17 11:16:56 -0500 | [diff] [blame] | 1418 | /// CHECK-DAG: <<Const42:i\d+>> IntConstant 42 |
David Brazdil | 74eb1b2 | 2015-12-14 11:44:01 +0000 | [diff] [blame] | 1419 | /// CHECK-DAG: <<Const54:i\d+>> IntConstant 54 |
| 1420 | /// CHECK-DAG: <<LE:z\d+>> LessThanOrEqual [<<Arg>>,<<Const42>>] |
| 1421 | /// CHECK-DAG: <<GT:i\d+>> Select [<<Const1>>,<<Const0>>,<<LE>>] |
| 1422 | /// CHECK-DAG: <<NE:z\d+>> Equal [<<GT>>,<<Const0>>] |
| 1423 | /// CHECK-DAG: <<Result:i\d+>> Select [<<Const13>>,<<Const54>>,<<NE>>] |
| 1424 | /// CHECK-DAG: Return [<<Result>>] |
Mark Mendell | f652917 | 2015-11-17 11:16:56 -0500 | [diff] [blame] | 1425 | |
Aart Bik | 639cc8c | 2016-10-18 13:03:31 -0700 | [diff] [blame] | 1426 | /// CHECK-START: int Main.$noinline$intConditionEqualZero(int) instruction_simplifier$after_inlining (after) |
Mark Mendell | f652917 | 2015-11-17 11:16:56 -0500 | [diff] [blame] | 1427 | /// CHECK-DAG: <<Arg:i\d+>> ParameterValue |
David Brazdil | 74eb1b2 | 2015-12-14 11:44:01 +0000 | [diff] [blame] | 1428 | /// CHECK-DAG: <<Const13:i\d+>> IntConstant 13 |
Mark Mendell | f652917 | 2015-11-17 11:16:56 -0500 | [diff] [blame] | 1429 | /// CHECK-DAG: <<Const42:i\d+>> IntConstant 42 |
David Brazdil | 74eb1b2 | 2015-12-14 11:44:01 +0000 | [diff] [blame] | 1430 | /// CHECK-DAG: <<Const54:i\d+>> IntConstant 54 |
| 1431 | /// CHECK-DAG: <<Result:i\d+>> Select [<<Const13>>,<<Const54>>,<<LE:z\d+>>] |
Mark Mendell | f652917 | 2015-11-17 11:16:56 -0500 | [diff] [blame] | 1432 | /// CHECK-DAG: <<LE>> LessThanOrEqual [<<Arg>>,<<Const42>>] |
David Brazdil | 74eb1b2 | 2015-12-14 11:44:01 +0000 | [diff] [blame] | 1433 | /// CHECK-DAG: Return [<<Result>>] |
| 1434 | // Note that we match `LE` from Select because there are two identical |
| 1435 | // LessThanOrEqual instructions. |
Mark Mendell | f652917 | 2015-11-17 11:16:56 -0500 | [diff] [blame] | 1436 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1437 | public static int $noinline$intConditionEqualZero(int i) { |
David Brazdil | f02c3cf | 2016-02-29 09:14:51 +0000 | [diff] [blame] | 1438 | return ((i > 42) != $inline$false()) ? 13 : 54; |
Mark Mendell | f652917 | 2015-11-17 11:16:56 -0500 | [diff] [blame] | 1439 | } |
| 1440 | |
| 1441 | // Test that conditions on float/double are not flipped. |
| 1442 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1443 | /// CHECK-START: int Main.$noinline$floatConditionNotEqualOne(float) builder (after) |
David Brazdil | 74eb1b2 | 2015-12-14 11:44:01 +0000 | [diff] [blame] | 1444 | /// CHECK: LessThanOrEqual |
| 1445 | |
Wojciech Staszkiewicz | 5319d3c | 2016-08-01 17:48:59 -0700 | [diff] [blame] | 1446 | /// CHECK-START: int Main.$noinline$floatConditionNotEqualOne(float) instruction_simplifier$before_codegen (after) |
David Brazdil | 74eb1b2 | 2015-12-14 11:44:01 +0000 | [diff] [blame] | 1447 | /// CHECK-DAG: <<Arg:f\d+>> ParameterValue |
| 1448 | /// CHECK-DAG: <<Const13:i\d+>> IntConstant 13 |
| 1449 | /// CHECK-DAG: <<Const54:i\d+>> IntConstant 54 |
| 1450 | /// CHECK-DAG: <<Const42:f\d+>> FloatConstant 42 |
| 1451 | /// CHECK-DAG: <<LE:z\d+>> LessThanOrEqual [<<Arg>>,<<Const42>>] |
| 1452 | /// CHECK-DAG: <<Select:i\d+>> Select [<<Const13>>,<<Const54>>,<<LE>>] |
| 1453 | /// CHECK-DAG: Return [<<Select>>] |
Mark Mendell | f652917 | 2015-11-17 11:16:56 -0500 | [diff] [blame] | 1454 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1455 | public static int $noinline$floatConditionNotEqualOne(float f) { |
Mark Mendell | f652917 | 2015-11-17 11:16:56 -0500 | [diff] [blame] | 1456 | return ((f > 42.0f) == true) ? 13 : 54; |
| 1457 | } |
| 1458 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1459 | /// CHECK-START: int Main.$noinline$doubleConditionEqualZero(double) builder (after) |
David Brazdil | 74eb1b2 | 2015-12-14 11:44:01 +0000 | [diff] [blame] | 1460 | /// CHECK: LessThanOrEqual |
| 1461 | |
Wojciech Staszkiewicz | 5319d3c | 2016-08-01 17:48:59 -0700 | [diff] [blame] | 1462 | /// CHECK-START: int Main.$noinline$doubleConditionEqualZero(double) instruction_simplifier$before_codegen (after) |
David Brazdil | 74eb1b2 | 2015-12-14 11:44:01 +0000 | [diff] [blame] | 1463 | /// CHECK-DAG: <<Arg:d\d+>> ParameterValue |
| 1464 | /// CHECK-DAG: <<Const13:i\d+>> IntConstant 13 |
| 1465 | /// CHECK-DAG: <<Const54:i\d+>> IntConstant 54 |
| 1466 | /// CHECK-DAG: <<Const42:d\d+>> DoubleConstant 42 |
| 1467 | /// CHECK-DAG: <<LE:z\d+>> LessThanOrEqual [<<Arg>>,<<Const42>>] |
| 1468 | /// CHECK-DAG: <<Select:i\d+>> Select [<<Const13>>,<<Const54>>,<<LE>>] |
| 1469 | /// CHECK-DAG: Return [<<Select>>] |
Mark Mendell | f652917 | 2015-11-17 11:16:56 -0500 | [diff] [blame] | 1470 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1471 | public static int $noinline$doubleConditionEqualZero(double d) { |
Mark Mendell | f652917 | 2015-11-17 11:16:56 -0500 | [diff] [blame] | 1472 | return ((d > 42.0) != false) ? 13 : 54; |
| 1473 | } |
Alexandre Rames | 38db785 | 2015-11-20 15:02:45 +0000 | [diff] [blame] | 1474 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1475 | /// CHECK-START: int Main.$noinline$intToDoubleToInt(int) instruction_simplifier (before) |
Vladimir Marko | b52bbde | 2016-02-12 12:06:05 +0000 | [diff] [blame] | 1476 | /// CHECK-DAG: <<Arg:i\d+>> ParameterValue |
| 1477 | /// CHECK-DAG: <<Double:d\d+>> TypeConversion [<<Arg>>] |
| 1478 | /// CHECK-DAG: <<Int:i\d+>> TypeConversion [<<Double>>] |
| 1479 | /// CHECK-DAG: Return [<<Int>>] |
| 1480 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1481 | /// CHECK-START: int Main.$noinline$intToDoubleToInt(int) instruction_simplifier (after) |
Vladimir Marko | b52bbde | 2016-02-12 12:06:05 +0000 | [diff] [blame] | 1482 | /// CHECK-DAG: <<Arg:i\d+>> ParameterValue |
| 1483 | /// CHECK-DAG: Return [<<Arg>>] |
| 1484 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1485 | /// CHECK-START: int Main.$noinline$intToDoubleToInt(int) instruction_simplifier (after) |
Vladimir Marko | b52bbde | 2016-02-12 12:06:05 +0000 | [diff] [blame] | 1486 | /// CHECK-NOT: TypeConversion |
| 1487 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1488 | public static int $noinline$intToDoubleToInt(int value) { |
Vladimir Marko | b52bbde | 2016-02-12 12:06:05 +0000 | [diff] [blame] | 1489 | // Lossless conversion followed by a conversion back. |
| 1490 | return (int) (double) value; |
| 1491 | } |
| 1492 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1493 | /// CHECK-START: java.lang.String Main.$noinline$intToDoubleToIntPrint(int) instruction_simplifier (before) |
Vladimir Marko | b52bbde | 2016-02-12 12:06:05 +0000 | [diff] [blame] | 1494 | /// CHECK-DAG: <<Arg:i\d+>> ParameterValue |
| 1495 | /// CHECK-DAG: <<Double:d\d+>> TypeConversion [<<Arg>>] |
| 1496 | /// CHECK-DAG: {{i\d+}} TypeConversion [<<Double>>] |
| 1497 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1498 | /// CHECK-START: java.lang.String Main.$noinline$intToDoubleToIntPrint(int) instruction_simplifier (after) |
Vladimir Marko | b52bbde | 2016-02-12 12:06:05 +0000 | [diff] [blame] | 1499 | /// CHECK-DAG: <<Arg:i\d+>> ParameterValue |
| 1500 | /// CHECK-DAG: {{d\d+}} TypeConversion [<<Arg>>] |
| 1501 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1502 | /// CHECK-START: java.lang.String Main.$noinline$intToDoubleToIntPrint(int) instruction_simplifier (after) |
Vladimir Marko | b52bbde | 2016-02-12 12:06:05 +0000 | [diff] [blame] | 1503 | /// CHECK-DAG: TypeConversion |
| 1504 | /// CHECK-NOT: TypeConversion |
| 1505 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1506 | public static String $noinline$intToDoubleToIntPrint(int value) { |
Vladimir Marko | b52bbde | 2016-02-12 12:06:05 +0000 | [diff] [blame] | 1507 | // Lossless conversion followed by a conversion back |
| 1508 | // with another use of the intermediate result. |
| 1509 | double d = (double) value; |
| 1510 | int i = (int) d; |
| 1511 | return "d=" + d + ", i=" + i; |
| 1512 | } |
| 1513 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1514 | /// CHECK-START: int Main.$noinline$byteToDoubleToInt(byte) instruction_simplifier (before) |
Vladimir Marko | b52bbde | 2016-02-12 12:06:05 +0000 | [diff] [blame] | 1515 | /// CHECK-DAG: <<Arg:b\d+>> ParameterValue |
| 1516 | /// CHECK-DAG: <<Double:d\d+>> TypeConversion [<<Arg>>] |
| 1517 | /// CHECK-DAG: <<Int:i\d+>> TypeConversion [<<Double>>] |
| 1518 | /// CHECK-DAG: Return [<<Int>>] |
| 1519 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1520 | /// CHECK-START: int Main.$noinline$byteToDoubleToInt(byte) instruction_simplifier (after) |
Vladimir Marko | b52bbde | 2016-02-12 12:06:05 +0000 | [diff] [blame] | 1521 | /// CHECK-DAG: <<Arg:b\d+>> ParameterValue |
| 1522 | /// CHECK-DAG: Return [<<Arg>>] |
| 1523 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1524 | /// CHECK-START: int Main.$noinline$byteToDoubleToInt(byte) instruction_simplifier (after) |
Vladimir Marko | b52bbde | 2016-02-12 12:06:05 +0000 | [diff] [blame] | 1525 | /// CHECK-NOT: TypeConversion |
| 1526 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1527 | public static int $noinline$byteToDoubleToInt(byte value) { |
Vladimir Marko | b52bbde | 2016-02-12 12:06:05 +0000 | [diff] [blame] | 1528 | // Lossless conversion followed by another conversion, use implicit conversion. |
| 1529 | return (int) (double) value; |
| 1530 | } |
| 1531 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1532 | /// CHECK-START: int Main.$noinline$floatToDoubleToInt(float) instruction_simplifier (before) |
Vladimir Marko | b52bbde | 2016-02-12 12:06:05 +0000 | [diff] [blame] | 1533 | /// CHECK-DAG: <<Arg:f\d+>> ParameterValue |
| 1534 | /// CHECK-DAG: <<Double:d\d+>> TypeConversion [<<Arg>>] |
| 1535 | /// CHECK-DAG: <<Int:i\d+>> TypeConversion [<<Double>>] |
| 1536 | /// CHECK-DAG: Return [<<Int>>] |
| 1537 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1538 | /// CHECK-START: int Main.$noinline$floatToDoubleToInt(float) instruction_simplifier (after) |
Vladimir Marko | b52bbde | 2016-02-12 12:06:05 +0000 | [diff] [blame] | 1539 | /// CHECK-DAG: <<Arg:f\d+>> ParameterValue |
| 1540 | /// CHECK-DAG: <<Int:i\d+>> TypeConversion [<<Arg>>] |
| 1541 | /// CHECK-DAG: Return [<<Int>>] |
| 1542 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1543 | /// CHECK-START: int Main.$noinline$floatToDoubleToInt(float) instruction_simplifier (after) |
Vladimir Marko | b52bbde | 2016-02-12 12:06:05 +0000 | [diff] [blame] | 1544 | /// CHECK-DAG: TypeConversion |
| 1545 | /// CHECK-NOT: TypeConversion |
| 1546 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1547 | public static int $noinline$floatToDoubleToInt(float value) { |
Vladimir Marko | b52bbde | 2016-02-12 12:06:05 +0000 | [diff] [blame] | 1548 | // Lossless conversion followed by another conversion. |
| 1549 | return (int) (double) value; |
| 1550 | } |
| 1551 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1552 | /// CHECK-START: java.lang.String Main.$noinline$floatToDoubleToIntPrint(float) instruction_simplifier (before) |
Vladimir Marko | b52bbde | 2016-02-12 12:06:05 +0000 | [diff] [blame] | 1553 | /// CHECK-DAG: <<Arg:f\d+>> ParameterValue |
| 1554 | /// CHECK-DAG: <<Double:d\d+>> TypeConversion [<<Arg>>] |
| 1555 | /// CHECK-DAG: {{i\d+}} TypeConversion [<<Double>>] |
| 1556 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1557 | /// CHECK-START: java.lang.String Main.$noinline$floatToDoubleToIntPrint(float) instruction_simplifier (after) |
Vladimir Marko | b52bbde | 2016-02-12 12:06:05 +0000 | [diff] [blame] | 1558 | /// CHECK-DAG: <<Arg:f\d+>> ParameterValue |
| 1559 | /// CHECK-DAG: <<Double:d\d+>> TypeConversion [<<Arg>>] |
| 1560 | /// CHECK-DAG: {{i\d+}} TypeConversion [<<Double>>] |
| 1561 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1562 | public static String $noinline$floatToDoubleToIntPrint(float value) { |
Vladimir Marko | b52bbde | 2016-02-12 12:06:05 +0000 | [diff] [blame] | 1563 | // Lossless conversion followed by another conversion with |
| 1564 | // an extra use of the intermediate result. |
| 1565 | double d = (double) value; |
| 1566 | int i = (int) d; |
| 1567 | return "d=" + d + ", i=" + i; |
| 1568 | } |
| 1569 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1570 | /// CHECK-START: short Main.$noinline$byteToDoubleToShort(byte) instruction_simplifier (before) |
Vladimir Marko | b52bbde | 2016-02-12 12:06:05 +0000 | [diff] [blame] | 1571 | /// CHECK-DAG: <<Arg:b\d+>> ParameterValue |
| 1572 | /// CHECK-DAG: <<Double:d\d+>> TypeConversion [<<Arg>>] |
| 1573 | /// CHECK-DAG: <<Int:i\d+>> TypeConversion [<<Double>>] |
| 1574 | /// CHECK-DAG: <<Short:s\d+>> TypeConversion [<<Int>>] |
| 1575 | /// CHECK-DAG: Return [<<Short>>] |
| 1576 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1577 | /// CHECK-START: short Main.$noinline$byteToDoubleToShort(byte) instruction_simplifier (after) |
Vladimir Marko | b52bbde | 2016-02-12 12:06:05 +0000 | [diff] [blame] | 1578 | /// CHECK-DAG: <<Arg:b\d+>> ParameterValue |
| 1579 | /// CHECK-DAG: Return [<<Arg>>] |
| 1580 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1581 | /// CHECK-START: short Main.$noinline$byteToDoubleToShort(byte) instruction_simplifier (after) |
Vladimir Marko | b52bbde | 2016-02-12 12:06:05 +0000 | [diff] [blame] | 1582 | /// CHECK-NOT: TypeConversion |
| 1583 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1584 | public static short $noinline$byteToDoubleToShort(byte value) { |
Vladimir Marko | b52bbde | 2016-02-12 12:06:05 +0000 | [diff] [blame] | 1585 | // Originally, this is byte->double->int->short. The first conversion is lossless, |
| 1586 | // so we merge this with the second one to byte->int which we omit as it's an implicit |
| 1587 | // conversion. Then we eliminate the resulting byte->short as an implicit conversion. |
| 1588 | return (short) (double) value; |
| 1589 | } |
| 1590 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1591 | /// CHECK-START: short Main.$noinline$charToDoubleToShort(char) instruction_simplifier (before) |
Vladimir Marko | b52bbde | 2016-02-12 12:06:05 +0000 | [diff] [blame] | 1592 | /// CHECK-DAG: <<Arg:c\d+>> ParameterValue |
| 1593 | /// CHECK-DAG: <<Double:d\d+>> TypeConversion [<<Arg>>] |
| 1594 | /// CHECK-DAG: <<Int:i\d+>> TypeConversion [<<Double>>] |
| 1595 | /// CHECK-DAG: <<Short:s\d+>> TypeConversion [<<Int>>] |
| 1596 | /// CHECK-DAG: Return [<<Short>>] |
| 1597 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1598 | /// CHECK-START: short Main.$noinline$charToDoubleToShort(char) instruction_simplifier (after) |
Vladimir Marko | b52bbde | 2016-02-12 12:06:05 +0000 | [diff] [blame] | 1599 | /// CHECK-DAG: <<Arg:c\d+>> ParameterValue |
| 1600 | /// CHECK-DAG: <<Short:s\d+>> TypeConversion [<<Arg>>] |
| 1601 | /// CHECK-DAG: Return [<<Short>>] |
| 1602 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1603 | /// CHECK-START: short Main.$noinline$charToDoubleToShort(char) instruction_simplifier (after) |
Vladimir Marko | b52bbde | 2016-02-12 12:06:05 +0000 | [diff] [blame] | 1604 | /// CHECK-DAG: TypeConversion |
| 1605 | /// CHECK-NOT: TypeConversion |
| 1606 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1607 | public static short $noinline$charToDoubleToShort(char value) { |
Vladimir Marko | b52bbde | 2016-02-12 12:06:05 +0000 | [diff] [blame] | 1608 | // Originally, this is char->double->int->short. The first conversion is lossless, |
| 1609 | // so we merge this with the second one to char->int which we omit as it's an implicit |
| 1610 | // conversion. Then we are left with the resulting char->short conversion. |
| 1611 | return (short) (double) value; |
| 1612 | } |
| 1613 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1614 | /// CHECK-START: short Main.$noinline$floatToIntToShort(float) instruction_simplifier (before) |
Vladimir Marko | b52bbde | 2016-02-12 12:06:05 +0000 | [diff] [blame] | 1615 | /// CHECK-DAG: <<Arg:f\d+>> ParameterValue |
| 1616 | /// CHECK-DAG: <<Int:i\d+>> TypeConversion [<<Arg>>] |
| 1617 | /// CHECK-DAG: <<Short:s\d+>> TypeConversion [<<Int>>] |
| 1618 | /// CHECK-DAG: Return [<<Short>>] |
| 1619 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1620 | /// CHECK-START: short Main.$noinline$floatToIntToShort(float) instruction_simplifier (after) |
Vladimir Marko | b52bbde | 2016-02-12 12:06:05 +0000 | [diff] [blame] | 1621 | /// CHECK-DAG: <<Arg:f\d+>> ParameterValue |
| 1622 | /// CHECK-DAG: <<Int:i\d+>> TypeConversion [<<Arg>>] |
| 1623 | /// CHECK-DAG: <<Short:s\d+>> TypeConversion [<<Int>>] |
| 1624 | /// CHECK-DAG: Return [<<Short>>] |
| 1625 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1626 | public static short $noinline$floatToIntToShort(float value) { |
Vladimir Marko | b52bbde | 2016-02-12 12:06:05 +0000 | [diff] [blame] | 1627 | // Lossy FP to integral conversion followed by another conversion: no simplification. |
| 1628 | return (short) value; |
| 1629 | } |
| 1630 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1631 | /// CHECK-START: int Main.$noinline$intToFloatToInt(int) instruction_simplifier (before) |
Vladimir Marko | b52bbde | 2016-02-12 12:06:05 +0000 | [diff] [blame] | 1632 | /// CHECK-DAG: <<Arg:i\d+>> ParameterValue |
| 1633 | /// CHECK-DAG: <<Float:f\d+>> TypeConversion [<<Arg>>] |
| 1634 | /// CHECK-DAG: <<Int:i\d+>> TypeConversion [<<Float>>] |
| 1635 | /// CHECK-DAG: Return [<<Int>>] |
| 1636 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1637 | /// CHECK-START: int Main.$noinline$intToFloatToInt(int) instruction_simplifier (after) |
Vladimir Marko | b52bbde | 2016-02-12 12:06:05 +0000 | [diff] [blame] | 1638 | /// CHECK-DAG: <<Arg:i\d+>> ParameterValue |
| 1639 | /// CHECK-DAG: <<Float:f\d+>> TypeConversion [<<Arg>>] |
| 1640 | /// CHECK-DAG: <<Int:i\d+>> TypeConversion [<<Float>>] |
| 1641 | /// CHECK-DAG: Return [<<Int>>] |
| 1642 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1643 | public static int $noinline$intToFloatToInt(int value) { |
Vladimir Marko | b52bbde | 2016-02-12 12:06:05 +0000 | [diff] [blame] | 1644 | // Lossy integral to FP conversion followed another conversion: no simplification. |
| 1645 | return (int) (float) value; |
| 1646 | } |
| 1647 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1648 | /// CHECK-START: double Main.$noinline$longToIntToDouble(long) instruction_simplifier (before) |
Vladimir Marko | b52bbde | 2016-02-12 12:06:05 +0000 | [diff] [blame] | 1649 | /// CHECK-DAG: <<Arg:j\d+>> ParameterValue |
| 1650 | /// CHECK-DAG: <<Int:i\d+>> TypeConversion [<<Arg>>] |
| 1651 | /// CHECK-DAG: <<Double:d\d+>> TypeConversion [<<Int>>] |
| 1652 | /// CHECK-DAG: Return [<<Double>>] |
| 1653 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1654 | /// CHECK-START: double Main.$noinline$longToIntToDouble(long) instruction_simplifier (after) |
Vladimir Marko | b52bbde | 2016-02-12 12:06:05 +0000 | [diff] [blame] | 1655 | /// CHECK-DAG: <<Arg:j\d+>> ParameterValue |
| 1656 | /// CHECK-DAG: <<Int:i\d+>> TypeConversion [<<Arg>>] |
| 1657 | /// CHECK-DAG: <<Double:d\d+>> TypeConversion [<<Int>>] |
| 1658 | /// CHECK-DAG: Return [<<Double>>] |
| 1659 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1660 | public static double $noinline$longToIntToDouble(long value) { |
Vladimir Marko | b52bbde | 2016-02-12 12:06:05 +0000 | [diff] [blame] | 1661 | // Lossy long-to-int conversion followed an integral to FP conversion: no simplification. |
| 1662 | return (double) (int) value; |
| 1663 | } |
| 1664 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1665 | /// CHECK-START: long Main.$noinline$longToIntToLong(long) instruction_simplifier (before) |
Vladimir Marko | b52bbde | 2016-02-12 12:06:05 +0000 | [diff] [blame] | 1666 | /// CHECK-DAG: <<Arg:j\d+>> ParameterValue |
| 1667 | /// CHECK-DAG: <<Int:i\d+>> TypeConversion [<<Arg>>] |
| 1668 | /// CHECK-DAG: <<Long:j\d+>> TypeConversion [<<Int>>] |
| 1669 | /// CHECK-DAG: Return [<<Long>>] |
| 1670 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1671 | /// CHECK-START: long Main.$noinline$longToIntToLong(long) instruction_simplifier (after) |
Vladimir Marko | b52bbde | 2016-02-12 12:06:05 +0000 | [diff] [blame] | 1672 | /// CHECK-DAG: <<Arg:j\d+>> ParameterValue |
| 1673 | /// CHECK-DAG: <<Int:i\d+>> TypeConversion [<<Arg>>] |
| 1674 | /// CHECK-DAG: <<Long:j\d+>> TypeConversion [<<Int>>] |
| 1675 | /// CHECK-DAG: Return [<<Long>>] |
| 1676 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1677 | public static long $noinline$longToIntToLong(long value) { |
Vladimir Marko | b52bbde | 2016-02-12 12:06:05 +0000 | [diff] [blame] | 1678 | // Lossy long-to-int conversion followed an int-to-long conversion: no simplification. |
| 1679 | return (long) (int) value; |
| 1680 | } |
| 1681 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1682 | /// CHECK-START: short Main.$noinline$shortToCharToShort(short) instruction_simplifier (before) |
Vladimir Marko | b52bbde | 2016-02-12 12:06:05 +0000 | [diff] [blame] | 1683 | /// CHECK-DAG: <<Arg:s\d+>> ParameterValue |
| 1684 | /// CHECK-DAG: <<Char:c\d+>> TypeConversion [<<Arg>>] |
| 1685 | /// CHECK-DAG: <<Short:s\d+>> TypeConversion [<<Char>>] |
| 1686 | /// CHECK-DAG: Return [<<Short>>] |
| 1687 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1688 | /// CHECK-START: short Main.$noinline$shortToCharToShort(short) instruction_simplifier (after) |
Vladimir Marko | b52bbde | 2016-02-12 12:06:05 +0000 | [diff] [blame] | 1689 | /// CHECK-DAG: <<Arg:s\d+>> ParameterValue |
| 1690 | /// CHECK-DAG: Return [<<Arg>>] |
| 1691 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1692 | public static short $noinline$shortToCharToShort(short value) { |
Vladimir Marko | b52bbde | 2016-02-12 12:06:05 +0000 | [diff] [blame] | 1693 | // Integral conversion followed by non-widening integral conversion to original type. |
| 1694 | return (short) (char) value; |
| 1695 | } |
| 1696 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1697 | /// CHECK-START: int Main.$noinline$shortToLongToInt(short) instruction_simplifier (before) |
Vladimir Marko | b52bbde | 2016-02-12 12:06:05 +0000 | [diff] [blame] | 1698 | /// CHECK-DAG: <<Arg:s\d+>> ParameterValue |
| 1699 | /// CHECK-DAG: <<Long:j\d+>> TypeConversion [<<Arg>>] |
| 1700 | /// CHECK-DAG: <<Int:i\d+>> TypeConversion [<<Long>>] |
| 1701 | /// CHECK-DAG: Return [<<Int>>] |
| 1702 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1703 | /// CHECK-START: int Main.$noinline$shortToLongToInt(short) instruction_simplifier (after) |
Vladimir Marko | b52bbde | 2016-02-12 12:06:05 +0000 | [diff] [blame] | 1704 | /// CHECK-DAG: <<Arg:s\d+>> ParameterValue |
| 1705 | /// CHECK-DAG: Return [<<Arg>>] |
| 1706 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1707 | public static int $noinline$shortToLongToInt(short value) { |
Vladimir Marko | b52bbde | 2016-02-12 12:06:05 +0000 | [diff] [blame] | 1708 | // Integral conversion followed by non-widening integral conversion, use implicit conversion. |
| 1709 | return (int) (long) value; |
| 1710 | } |
| 1711 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1712 | /// CHECK-START: byte Main.$noinline$shortToCharToByte(short) instruction_simplifier (before) |
Vladimir Marko | b52bbde | 2016-02-12 12:06:05 +0000 | [diff] [blame] | 1713 | /// CHECK-DAG: <<Arg:s\d+>> ParameterValue |
| 1714 | /// CHECK-DAG: <<Char:c\d+>> TypeConversion [<<Arg>>] |
| 1715 | /// CHECK-DAG: <<Byte:b\d+>> TypeConversion [<<Char>>] |
| 1716 | /// CHECK-DAG: Return [<<Byte>>] |
| 1717 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1718 | /// CHECK-START: byte Main.$noinline$shortToCharToByte(short) instruction_simplifier (after) |
Vladimir Marko | b52bbde | 2016-02-12 12:06:05 +0000 | [diff] [blame] | 1719 | /// CHECK-DAG: <<Arg:s\d+>> ParameterValue |
| 1720 | /// CHECK-DAG: <<Byte:b\d+>> TypeConversion [<<Arg>>] |
| 1721 | /// CHECK-DAG: Return [<<Byte>>] |
| 1722 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1723 | public static byte $noinline$shortToCharToByte(short value) { |
Vladimir Marko | b52bbde | 2016-02-12 12:06:05 +0000 | [diff] [blame] | 1724 | // Integral conversion followed by non-widening integral conversion losing bits |
| 1725 | // from the original type. Simplify to use only one conversion. |
| 1726 | return (byte) (char) value; |
| 1727 | } |
| 1728 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1729 | /// CHECK-START: java.lang.String Main.$noinline$shortToCharToBytePrint(short) instruction_simplifier (before) |
Vladimir Marko | b52bbde | 2016-02-12 12:06:05 +0000 | [diff] [blame] | 1730 | /// CHECK-DAG: <<Arg:s\d+>> ParameterValue |
| 1731 | /// CHECK-DAG: <<Char:c\d+>> TypeConversion [<<Arg>>] |
| 1732 | /// CHECK-DAG: {{b\d+}} TypeConversion [<<Char>>] |
| 1733 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1734 | /// CHECK-START: java.lang.String Main.$noinline$shortToCharToBytePrint(short) instruction_simplifier (after) |
Vladimir Marko | b52bbde | 2016-02-12 12:06:05 +0000 | [diff] [blame] | 1735 | /// CHECK-DAG: <<Arg:s\d+>> ParameterValue |
| 1736 | /// CHECK-DAG: <<Char:c\d+>> TypeConversion [<<Arg>>] |
| 1737 | /// CHECK-DAG: {{b\d+}} TypeConversion [<<Char>>] |
| 1738 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1739 | public static String $noinline$shortToCharToBytePrint(short value) { |
Vladimir Marko | b52bbde | 2016-02-12 12:06:05 +0000 | [diff] [blame] | 1740 | // Integral conversion followed by non-widening integral conversion losing bits |
| 1741 | // from the original type with an extra use of the intermediate result. |
| 1742 | char c = (char) value; |
| 1743 | byte b = (byte) c; |
| 1744 | return "c=" + ((int) c) + ", b=" + ((int) b); // implicit conversions. |
| 1745 | } |
| 1746 | |
Vladimir Marko | c8fb211 | 2017-10-03 11:37:52 +0100 | [diff] [blame] | 1747 | /// CHECK-START: long Main.$noinline$intAndSmallLongConstant(int) instruction_simplifier (before) |
| 1748 | /// CHECK-DAG: <<Arg:i\d+>> ParameterValue |
| 1749 | /// CHECK-DAG: <<Mask:j\d+>> LongConstant -12345678 |
| 1750 | /// CHECK-DAG: <<Long:j\d+>> TypeConversion [<<Arg>>] |
| 1751 | /// CHECK-DAG: <<And:j\d+>> And [<<Long>>,<<Mask>>] |
| 1752 | /// CHECK-DAG: Return [<<And>>] |
| 1753 | |
| 1754 | /// CHECK-START: long Main.$noinline$intAndSmallLongConstant(int) instruction_simplifier (after) |
| 1755 | /// CHECK-DAG: <<Arg:i\d+>> ParameterValue |
| 1756 | /// CHECK-DAG: <<Mask:i\d+>> IntConstant -12345678 |
| 1757 | /// CHECK-DAG: <<And:i\d+>> And [<<Arg>>,<<Mask>>] |
| 1758 | /// CHECK-DAG: <<Long:j\d+>> TypeConversion [<<And>>] |
| 1759 | /// CHECK-DAG: Return [<<Long>>] |
| 1760 | |
| 1761 | public static long $noinline$intAndSmallLongConstant(int value) { |
| 1762 | return value & -12345678L; // Shall be simplified (constant is 32-bit). |
| 1763 | } |
| 1764 | |
| 1765 | /// CHECK-START: long Main.$noinline$intAndLargeLongConstant(int) instruction_simplifier (before) |
| 1766 | /// CHECK-DAG: <<Arg:i\d+>> ParameterValue |
| 1767 | /// CHECK-DAG: <<Mask:j\d+>> LongConstant 9876543210 |
| 1768 | /// CHECK-DAG: <<Long:j\d+>> TypeConversion [<<Arg>>] |
| 1769 | /// CHECK-DAG: <<And:j\d+>> And [<<Long>>,<<Mask>>] |
| 1770 | /// CHECK-DAG: Return [<<And>>] |
| 1771 | |
| 1772 | /// CHECK-START: long Main.$noinline$intAndLargeLongConstant(int) instruction_simplifier (after) |
| 1773 | /// CHECK-DAG: <<Arg:i\d+>> ParameterValue |
| 1774 | /// CHECK-DAG: <<Mask:j\d+>> LongConstant 9876543210 |
| 1775 | /// CHECK-DAG: <<Long:j\d+>> TypeConversion [<<Arg>>] |
| 1776 | /// CHECK-DAG: <<And:j\d+>> And [<<Long>>,<<Mask>>] |
| 1777 | /// CHECK-DAG: Return [<<And>>] |
| 1778 | |
| 1779 | public static long $noinline$intAndLargeLongConstant(int value) { |
| 1780 | return value & 9876543210L; // Shall not be simplified (constant is not 32-bit). |
| 1781 | } |
| 1782 | |
| 1783 | /// CHECK-START: long Main.$noinline$intShr28And15L(int) instruction_simplifier (before) |
| 1784 | /// CHECK-DAG: <<Arg:i\d+>> ParameterValue |
| 1785 | /// CHECK-DAG: <<Shift:i\d+>> IntConstant 28 |
| 1786 | /// CHECK-DAG: <<Mask:j\d+>> LongConstant 15 |
| 1787 | /// CHECK-DAG: <<Shifted:i\d+>> Shr [<<Arg>>,<<Shift>>] |
| 1788 | /// CHECK-DAG: <<Long:j\d+>> TypeConversion [<<Shifted>>] |
| 1789 | /// CHECK-DAG: <<And:j\d+>> And [<<Long>>,<<Mask>>] |
| 1790 | /// CHECK-DAG: Return [<<And>>] |
| 1791 | |
| 1792 | /// CHECK-START: long Main.$noinline$intShr28And15L(int) instruction_simplifier (after) |
| 1793 | /// CHECK-DAG: <<Arg:i\d+>> ParameterValue |
| 1794 | /// CHECK-DAG: <<Shift:i\d+>> IntConstant 28 |
| 1795 | /// CHECK-DAG: <<Shifted:i\d+>> UShr [<<Arg>>,<<Shift>>] |
| 1796 | /// CHECK-DAG: <<Long:j\d+>> TypeConversion [<<Shifted>>] |
| 1797 | /// CHECK-DAG: Return [<<Long>>] |
| 1798 | |
| 1799 | public static long $noinline$intShr28And15L(int value) { |
| 1800 | return (value >> 28) & 15L; |
| 1801 | } |
| 1802 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1803 | /// CHECK-START: byte Main.$noinline$longAnd0xffToByte(long) instruction_simplifier (before) |
Vladimir Marko | 8428bd3 | 2016-02-12 16:53:57 +0000 | [diff] [blame] | 1804 | /// CHECK-DAG: <<Arg:j\d+>> ParameterValue |
| 1805 | /// CHECK-DAG: <<Mask:j\d+>> LongConstant 255 |
| 1806 | /// CHECK-DAG: <<And:j\d+>> And [<<Mask>>,<<Arg>>] |
| 1807 | /// CHECK-DAG: <<Int:i\d+>> TypeConversion [<<And>>] |
| 1808 | /// CHECK-DAG: <<Byte:b\d+>> TypeConversion [<<Int>>] |
| 1809 | /// CHECK-DAG: Return [<<Byte>>] |
| 1810 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1811 | /// CHECK-START: byte Main.$noinline$longAnd0xffToByte(long) instruction_simplifier (after) |
Vladimir Marko | 8428bd3 | 2016-02-12 16:53:57 +0000 | [diff] [blame] | 1812 | /// CHECK-DAG: <<Arg:j\d+>> ParameterValue |
| 1813 | /// CHECK-DAG: <<Byte:b\d+>> TypeConversion [<<Arg>>] |
| 1814 | /// CHECK-DAG: Return [<<Byte>>] |
| 1815 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1816 | /// CHECK-START: byte Main.$noinline$longAnd0xffToByte(long) instruction_simplifier (after) |
Vladimir Marko | 8428bd3 | 2016-02-12 16:53:57 +0000 | [diff] [blame] | 1817 | /// CHECK-NOT: And |
| 1818 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1819 | public static byte $noinline$longAnd0xffToByte(long value) { |
Vladimir Marko | 8428bd3 | 2016-02-12 16:53:57 +0000 | [diff] [blame] | 1820 | return (byte) (value & 0xff); |
| 1821 | } |
| 1822 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1823 | /// CHECK-START: char Main.$noinline$intAnd0x1ffffToChar(int) instruction_simplifier (before) |
Vladimir Marko | 8428bd3 | 2016-02-12 16:53:57 +0000 | [diff] [blame] | 1824 | /// CHECK-DAG: <<Arg:i\d+>> ParameterValue |
| 1825 | /// CHECK-DAG: <<Mask:i\d+>> IntConstant 131071 |
| 1826 | /// CHECK-DAG: <<And:i\d+>> And [<<Mask>>,<<Arg>>] |
| 1827 | /// CHECK-DAG: <<Char:c\d+>> TypeConversion [<<And>>] |
| 1828 | /// CHECK-DAG: Return [<<Char>>] |
| 1829 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1830 | /// CHECK-START: char Main.$noinline$intAnd0x1ffffToChar(int) instruction_simplifier (after) |
Vladimir Marko | 8428bd3 | 2016-02-12 16:53:57 +0000 | [diff] [blame] | 1831 | /// CHECK-DAG: <<Arg:i\d+>> ParameterValue |
| 1832 | /// CHECK-DAG: <<Char:c\d+>> TypeConversion [<<Arg>>] |
| 1833 | /// CHECK-DAG: Return [<<Char>>] |
| 1834 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1835 | /// CHECK-START: char Main.$noinline$intAnd0x1ffffToChar(int) instruction_simplifier (after) |
Vladimir Marko | 8428bd3 | 2016-02-12 16:53:57 +0000 | [diff] [blame] | 1836 | /// CHECK-NOT: And |
| 1837 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1838 | public static char $noinline$intAnd0x1ffffToChar(int value) { |
Vladimir Marko | 8428bd3 | 2016-02-12 16:53:57 +0000 | [diff] [blame] | 1839 | // Keeping all significant bits and one more. |
| 1840 | return (char) (value & 0x1ffff); |
| 1841 | } |
| 1842 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1843 | /// CHECK-START: short Main.$noinline$intAnd0x17fffToShort(int) instruction_simplifier (before) |
Vladimir Marko | 8428bd3 | 2016-02-12 16:53:57 +0000 | [diff] [blame] | 1844 | /// CHECK-DAG: <<Arg:i\d+>> ParameterValue |
| 1845 | /// CHECK-DAG: <<Mask:i\d+>> IntConstant 98303 |
| 1846 | /// CHECK-DAG: <<And:i\d+>> And [<<Mask>>,<<Arg>>] |
| 1847 | /// CHECK-DAG: <<Short:s\d+>> TypeConversion [<<And>>] |
| 1848 | /// CHECK-DAG: Return [<<Short>>] |
| 1849 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1850 | /// CHECK-START: short Main.$noinline$intAnd0x17fffToShort(int) instruction_simplifier (after) |
Vladimir Marko | 8428bd3 | 2016-02-12 16:53:57 +0000 | [diff] [blame] | 1851 | /// CHECK-DAG: <<Arg:i\d+>> ParameterValue |
| 1852 | /// CHECK-DAG: <<Mask:i\d+>> IntConstant 98303 |
| 1853 | /// CHECK-DAG: <<And:i\d+>> And [<<Mask>>,<<Arg>>] |
| 1854 | /// CHECK-DAG: <<Short:s\d+>> TypeConversion [<<And>>] |
| 1855 | /// CHECK-DAG: Return [<<Short>>] |
| 1856 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1857 | public static short $noinline$intAnd0x17fffToShort(int value) { |
Vladimir Marko | 8428bd3 | 2016-02-12 16:53:57 +0000 | [diff] [blame] | 1858 | // No simplification: clearing a significant bit. |
| 1859 | return (short) (value & 0x17fff); |
| 1860 | } |
| 1861 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1862 | /// CHECK-START: double Main.$noinline$shortAnd0xffffToShortToDouble(short) instruction_simplifier (before) |
Vladimir Marko | 625090f | 2016-03-14 18:00:05 +0000 | [diff] [blame] | 1863 | /// CHECK-DAG: <<Arg:s\d+>> ParameterValue |
| 1864 | /// CHECK-DAG: <<Mask:i\d+>> IntConstant 65535 |
| 1865 | /// CHECK-DAG: <<And:i\d+>> And [<<Mask>>,<<Arg>>] |
| 1866 | /// CHECK-DAG: <<Same:s\d+>> TypeConversion [<<And>>] |
| 1867 | /// CHECK-DAG: <<Double:d\d+>> TypeConversion [<<Same>>] |
| 1868 | /// CHECK-DAG: Return [<<Double>>] |
| 1869 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1870 | /// CHECK-START: double Main.$noinline$shortAnd0xffffToShortToDouble(short) instruction_simplifier (after) |
Vladimir Marko | 625090f | 2016-03-14 18:00:05 +0000 | [diff] [blame] | 1871 | /// CHECK-DAG: <<Arg:s\d+>> ParameterValue |
| 1872 | /// CHECK-DAG: <<Double:d\d+>> TypeConversion [<<Arg>>] |
| 1873 | /// CHECK-DAG: Return [<<Double>>] |
| 1874 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1875 | public static double $noinline$shortAnd0xffffToShortToDouble(short value) { |
Vladimir Marko | 625090f | 2016-03-14 18:00:05 +0000 | [diff] [blame] | 1876 | short same = (short) (value & 0xffff); |
| 1877 | return (double) same; |
| 1878 | } |
| 1879 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1880 | /// CHECK-START: int Main.$noinline$intReverseCondition(int) instruction_simplifier (before) |
Anton Shamin | bdd7935 | 2016-02-15 12:48:36 +0600 | [diff] [blame] | 1881 | /// CHECK-DAG: <<Arg:i\d+>> ParameterValue |
| 1882 | /// CHECK-DAG: <<Const42:i\d+>> IntConstant 42 |
| 1883 | /// CHECK-DAG: <<LE:z\d+>> LessThanOrEqual [<<Const42>>,<<Arg>>] |
| 1884 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1885 | /// CHECK-START: int Main.$noinline$intReverseCondition(int) instruction_simplifier (after) |
Anton Shamin | bdd7935 | 2016-02-15 12:48:36 +0600 | [diff] [blame] | 1886 | /// CHECK-DAG: <<Arg:i\d+>> ParameterValue |
| 1887 | /// CHECK-DAG: <<Const42:i\d+>> IntConstant 42 |
| 1888 | /// CHECK-DAG: <<GE:z\d+>> GreaterThanOrEqual [<<Arg>>,<<Const42>>] |
| 1889 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1890 | public static int $noinline$intReverseCondition(int i) { |
Anton Shamin | bdd7935 | 2016-02-15 12:48:36 +0600 | [diff] [blame] | 1891 | return (42 > i) ? 13 : 54; |
| 1892 | } |
| 1893 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1894 | /// CHECK-START: int Main.$noinline$intReverseConditionNaN(int) instruction_simplifier (before) |
Anton Shamin | bdd7935 | 2016-02-15 12:48:36 +0600 | [diff] [blame] | 1895 | /// CHECK-DAG: <<Const42:d\d+>> DoubleConstant 42 |
| 1896 | /// CHECK-DAG: <<Result:d\d+>> InvokeStaticOrDirect |
| 1897 | /// CHECK-DAG: <<CMP:i\d+>> Compare [<<Const42>>,<<Result>>] |
| 1898 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1899 | /// CHECK-START: int Main.$noinline$intReverseConditionNaN(int) instruction_simplifier (after) |
Anton Shamin | bdd7935 | 2016-02-15 12:48:36 +0600 | [diff] [blame] | 1900 | /// CHECK-DAG: <<Const42:d\d+>> DoubleConstant 42 |
| 1901 | /// CHECK-DAG: <<Result:d\d+>> InvokeStaticOrDirect |
| 1902 | /// CHECK-DAG: <<EQ:z\d+>> Equal [<<Result>>,<<Const42>>] |
| 1903 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1904 | public static int $noinline$intReverseConditionNaN(int i) { |
Anton Shamin | bdd7935 | 2016-02-15 12:48:36 +0600 | [diff] [blame] | 1905 | return (42 != Math.sqrt(i)) ? 13 : 54; |
| 1906 | } |
| 1907 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 1908 | public static int $noinline$runSmaliTest(String name, boolean input) { |
David Brazdil | f02c3cf | 2016-02-29 09:14:51 +0000 | [diff] [blame] | 1909 | try { |
| 1910 | Class<?> c = Class.forName("SmaliTests"); |
Andreas Gampe | 166aaee | 2016-07-18 08:27:23 -0700 | [diff] [blame] | 1911 | Method m = c.getMethod(name, boolean.class); |
David Brazdil | f02c3cf | 2016-02-29 09:14:51 +0000 | [diff] [blame] | 1912 | return (Integer) m.invoke(null, input); |
| 1913 | } catch (Exception ex) { |
| 1914 | throw new Error(ex); |
| 1915 | } |
| 1916 | } |
| 1917 | |
Igor Murashkin | 4269173 | 2017-06-26 15:57:31 -0700 | [diff] [blame] | 1918 | public static boolean $noinline$runSmaliTestBoolean(String name, boolean input) { |
Igor Murashkin | 4269173 | 2017-06-26 15:57:31 -0700 | [diff] [blame] | 1919 | try { |
| 1920 | Class<?> c = Class.forName("SmaliTests"); |
| 1921 | Method m = c.getMethod(name, boolean.class); |
| 1922 | return (Boolean) m.invoke(null, input); |
| 1923 | } catch (Exception ex) { |
| 1924 | throw new Error(ex); |
| 1925 | } |
| 1926 | } |
| 1927 | |
| 1928 | public static int $noinline$runSmaliTestInt(String name, int arg) { |
Anton Kirilov | e14dc86 | 2016-05-13 17:56:15 +0100 | [diff] [blame] | 1929 | try { |
| 1930 | Class<?> c = Class.forName("SmaliTests"); |
| 1931 | Method m = c.getMethod(name, int.class); |
| 1932 | return (Integer) m.invoke(null, arg); |
| 1933 | } catch (Exception ex) { |
| 1934 | throw new Error(ex); |
| 1935 | } |
| 1936 | } |
| 1937 | |
Igor Murashkin | 4269173 | 2017-06-26 15:57:31 -0700 | [diff] [blame] | 1938 | public static long $noinline$runSmaliTestLong(String name, long arg) { |
Igor Murashkin | 4269173 | 2017-06-26 15:57:31 -0700 | [diff] [blame] | 1939 | try { |
| 1940 | Class<?> c = Class.forName("SmaliTests"); |
| 1941 | Method m = c.getMethod(name, long.class); |
| 1942 | return (Long) m.invoke(null, arg); |
| 1943 | } catch (Exception ex) { |
| 1944 | throw new Error(ex); |
| 1945 | } |
| 1946 | } |
| 1947 | |
Alexandre Rames | 5051844 | 2016-06-27 11:39:19 +0100 | [diff] [blame] | 1948 | /// CHECK-START: int Main.$noinline$intUnnecessaryShiftMasking(int, int) instruction_simplifier (before) |
| 1949 | /// CHECK: <<Value:i\d+>> ParameterValue |
| 1950 | /// CHECK: <<Shift:i\d+>> ParameterValue |
| 1951 | /// CHECK-DAG: <<Const31:i\d+>> IntConstant 31 |
| 1952 | /// CHECK-DAG: <<And:i\d+>> And [<<Shift>>,<<Const31>>] |
| 1953 | /// CHECK-DAG: <<Shl:i\d+>> Shl [<<Value>>,<<And>>] |
| 1954 | /// CHECK-DAG: Return [<<Shl>>] |
| 1955 | |
| 1956 | /// CHECK-START: int Main.$noinline$intUnnecessaryShiftMasking(int, int) instruction_simplifier (after) |
| 1957 | /// CHECK: <<Value:i\d+>> ParameterValue |
| 1958 | /// CHECK: <<Shift:i\d+>> ParameterValue |
| 1959 | /// CHECK-DAG: <<Shl:i\d+>> Shl [<<Value>>,<<Shift>>] |
| 1960 | /// CHECK-DAG: Return [<<Shl>>] |
| 1961 | |
| 1962 | public static int $noinline$intUnnecessaryShiftMasking(int value, int shift) { |
Alexandre Rames | 5051844 | 2016-06-27 11:39:19 +0100 | [diff] [blame] | 1963 | return value << (shift & 31); |
| 1964 | } |
| 1965 | |
| 1966 | /// CHECK-START: long Main.$noinline$longUnnecessaryShiftMasking(long, int) instruction_simplifier (before) |
| 1967 | /// CHECK: <<Value:j\d+>> ParameterValue |
| 1968 | /// CHECK: <<Shift:i\d+>> ParameterValue |
| 1969 | /// CHECK-DAG: <<Const63:i\d+>> IntConstant 63 |
| 1970 | /// CHECK-DAG: <<And:i\d+>> And [<<Shift>>,<<Const63>>] |
| 1971 | /// CHECK-DAG: <<Shr:j\d+>> Shr [<<Value>>,<<And>>] |
| 1972 | /// CHECK-DAG: Return [<<Shr>>] |
| 1973 | |
| 1974 | /// CHECK-START: long Main.$noinline$longUnnecessaryShiftMasking(long, int) instruction_simplifier (after) |
| 1975 | /// CHECK: <<Value:j\d+>> ParameterValue |
| 1976 | /// CHECK: <<Shift:i\d+>> ParameterValue |
| 1977 | /// CHECK-DAG: <<Shr:j\d+>> Shr [<<Value>>,<<Shift>>] |
| 1978 | /// CHECK-DAG: Return [<<Shr>>] |
| 1979 | |
| 1980 | public static long $noinline$longUnnecessaryShiftMasking(long value, int shift) { |
Alexandre Rames | 5051844 | 2016-06-27 11:39:19 +0100 | [diff] [blame] | 1981 | return value >> (shift & 63); |
| 1982 | } |
| 1983 | |
| 1984 | /// CHECK-START: int Main.$noinline$intUnnecessaryWiderShiftMasking(int, int) instruction_simplifier (before) |
| 1985 | /// CHECK: <<Value:i\d+>> ParameterValue |
| 1986 | /// CHECK: <<Shift:i\d+>> ParameterValue |
| 1987 | /// CHECK-DAG: <<Const255:i\d+>> IntConstant 255 |
| 1988 | /// CHECK-DAG: <<And:i\d+>> And [<<Shift>>,<<Const255>>] |
| 1989 | /// CHECK-DAG: <<UShr:i\d+>> UShr [<<Value>>,<<And>>] |
| 1990 | /// CHECK-DAG: Return [<<UShr>>] |
| 1991 | |
| 1992 | /// CHECK-START: int Main.$noinline$intUnnecessaryWiderShiftMasking(int, int) instruction_simplifier (after) |
| 1993 | /// CHECK: <<Value:i\d+>> ParameterValue |
| 1994 | /// CHECK: <<Shift:i\d+>> ParameterValue |
| 1995 | /// CHECK-DAG: <<UShr:i\d+>> UShr [<<Value>>,<<Shift>>] |
| 1996 | /// CHECK-DAG: Return [<<UShr>>] |
| 1997 | |
| 1998 | public static int $noinline$intUnnecessaryWiderShiftMasking(int value, int shift) { |
Alexandre Rames | 5051844 | 2016-06-27 11:39:19 +0100 | [diff] [blame] | 1999 | return value >>> (shift & 0xff); |
| 2000 | } |
| 2001 | |
| 2002 | /// CHECK-START: long Main.$noinline$longSmallerShiftMasking(long, int) instruction_simplifier (before) |
| 2003 | /// CHECK: <<Value:j\d+>> ParameterValue |
| 2004 | /// CHECK: <<Shift:i\d+>> ParameterValue |
| 2005 | /// CHECK-DAG: <<Const3:i\d+>> IntConstant 3 |
| 2006 | /// CHECK-DAG: <<And:i\d+>> And [<<Shift>>,<<Const3>>] |
| 2007 | /// CHECK-DAG: <<Shl:j\d+>> Shl [<<Value>>,<<And>>] |
| 2008 | /// CHECK-DAG: Return [<<Shl>>] |
| 2009 | |
| 2010 | /// CHECK-START: long Main.$noinline$longSmallerShiftMasking(long, int) instruction_simplifier (after) |
| 2011 | /// CHECK: <<Value:j\d+>> ParameterValue |
| 2012 | /// CHECK: <<Shift:i\d+>> ParameterValue |
| 2013 | /// CHECK-DAG: <<Const3:i\d+>> IntConstant 3 |
| 2014 | /// CHECK-DAG: <<And:i\d+>> And [<<Shift>>,<<Const3>>] |
| 2015 | /// CHECK-DAG: <<Shl:j\d+>> Shl [<<Value>>,<<And>>] |
| 2016 | /// CHECK-DAG: Return [<<Shl>>] |
| 2017 | |
| 2018 | public static long $noinline$longSmallerShiftMasking(long value, int shift) { |
Alexandre Rames | 5051844 | 2016-06-27 11:39:19 +0100 | [diff] [blame] | 2019 | return value << (shift & 3); |
| 2020 | } |
| 2021 | |
| 2022 | /// CHECK-START: int Main.$noinline$otherUseOfUnnecessaryShiftMasking(int, int) instruction_simplifier (before) |
| 2023 | /// CHECK: <<Value:i\d+>> ParameterValue |
| 2024 | /// CHECK: <<Shift:i\d+>> ParameterValue |
| 2025 | /// CHECK-DAG: <<Const31:i\d+>> IntConstant 31 |
| 2026 | /// CHECK-DAG: <<And:i\d+>> And [<<Shift>>,<<Const31>>] |
| 2027 | /// CHECK-DAG: <<Shr:i\d+>> Shr [<<Value>>,<<And>>] |
| 2028 | /// CHECK-DAG: <<Add:i\d+>> Add [<<Shr>>,<<And>>] |
| 2029 | /// CHECK-DAG: Return [<<Add>>] |
| 2030 | |
| 2031 | /// CHECK-START: int Main.$noinline$otherUseOfUnnecessaryShiftMasking(int, int) instruction_simplifier (after) |
| 2032 | /// CHECK: <<Value:i\d+>> ParameterValue |
| 2033 | /// CHECK: <<Shift:i\d+>> ParameterValue |
| 2034 | /// CHECK-DAG: <<Const31:i\d+>> IntConstant 31 |
| 2035 | /// CHECK-DAG: <<And:i\d+>> And [<<Shift>>,<<Const31>>] |
| 2036 | /// CHECK-DAG: <<Shr:i\d+>> Shr [<<Value>>,<<Shift>>] |
| 2037 | /// CHECK-DAG: <<Add:i\d+>> Add [<<Shr>>,<<And>>] |
| 2038 | /// CHECK-DAG: Return [<<Add>>] |
| 2039 | |
| 2040 | public static int $noinline$otherUseOfUnnecessaryShiftMasking(int value, int shift) { |
Alexandre Rames | 5051844 | 2016-06-27 11:39:19 +0100 | [diff] [blame] | 2041 | int temp = shift & 31; |
| 2042 | return (value >> temp) + temp; |
| 2043 | } |
| 2044 | |
Vladimir Marko | 7033d49 | 2017-09-28 16:32:24 +0100 | [diff] [blame] | 2045 | /// CHECK-START: int Main.$noinline$intUnnecessaryShiftModifications(int, int) instruction_simplifier (before) |
| 2046 | /// CHECK: <<Value:i\d+>> ParameterValue |
| 2047 | /// CHECK: <<Shift:i\d+>> ParameterValue |
| 2048 | /// CHECK-DAG: <<Const32:i\d+>> IntConstant 32 |
| 2049 | /// CHECK-DAG: <<Const64:i\d+>> IntConstant 64 |
| 2050 | /// CHECK-DAG: <<Const96:i\d+>> IntConstant 96 |
| 2051 | /// CHECK-DAG: <<Const128:i\d+>> IntConstant 128 |
| 2052 | /// CHECK-DAG: <<Or:i\d+>> Or [<<Shift>>,<<Const32>>] |
| 2053 | /// CHECK-DAG: <<Xor:i\d+>> Xor [<<Shift>>,<<Const64>>] |
| 2054 | /// CHECK-DAG: <<Add:i\d+>> Add [<<Shift>>,<<Const96>>] |
| 2055 | /// CHECK-DAG: <<Sub:i\d+>> Sub [<<Shift>>,<<Const128>>] |
| 2056 | /// CHECK-DAG: <<Conv:b\d+>> TypeConversion [<<Shift>>] |
| 2057 | /// CHECK-DAG: Shl [<<Value>>,<<Or>>] |
| 2058 | /// CHECK-DAG: Shr [<<Value>>,<<Xor>>] |
| 2059 | /// CHECK-DAG: UShr [<<Value>>,<<Add>>] |
| 2060 | /// CHECK-DAG: Shl [<<Value>>,<<Sub>>] |
| 2061 | /// CHECK-DAG: Shr [<<Value>>,<<Conv>>] |
| 2062 | |
| 2063 | /// CHECK-START: int Main.$noinline$intUnnecessaryShiftModifications(int, int) instruction_simplifier (after) |
| 2064 | /// CHECK: <<Value:i\d+>> ParameterValue |
| 2065 | /// CHECK: <<Shift:i\d+>> ParameterValue |
| 2066 | /// CHECK-DAG: Shl [<<Value>>,<<Shift>>] |
| 2067 | /// CHECK-DAG: Shr [<<Value>>,<<Shift>>] |
| 2068 | /// CHECK-DAG: UShr [<<Value>>,<<Shift>>] |
| 2069 | /// CHECK-DAG: Shl [<<Value>>,<<Shift>>] |
| 2070 | /// CHECK-DAG: Shr [<<Value>>,<<Shift>>] |
| 2071 | |
| 2072 | public static int $noinline$intUnnecessaryShiftModifications(int value, int shift) { |
Vladimir Marko | 7033d49 | 2017-09-28 16:32:24 +0100 | [diff] [blame] | 2073 | int c128 = 128; |
| 2074 | return (value << (shift | 32)) + |
| 2075 | (value >> (shift ^ 64)) + |
| 2076 | (value >>> (shift + 96)) + |
| 2077 | (value << (shift - c128)) + // Needs a named constant to generate Sub. |
| 2078 | (value >> ((byte) shift)); |
| 2079 | } |
| 2080 | |
| 2081 | /// CHECK-START: int Main.$noinline$intNecessaryShiftModifications(int, int) instruction_simplifier (before) |
| 2082 | /// CHECK: <<Value:i\d+>> ParameterValue |
| 2083 | /// CHECK: <<Shift:i\d+>> ParameterValue |
| 2084 | /// CHECK-DAG: <<Const33:i\d+>> IntConstant 33 |
| 2085 | /// CHECK-DAG: <<Const65:i\d+>> IntConstant 65 |
| 2086 | /// CHECK-DAG: <<Const97:i\d+>> IntConstant 97 |
| 2087 | /// CHECK-DAG: <<Const129:i\d+>> IntConstant 129 |
| 2088 | /// CHECK-DAG: <<Or:i\d+>> Or [<<Shift>>,<<Const33>>] |
| 2089 | /// CHECK-DAG: <<Xor:i\d+>> Xor [<<Shift>>,<<Const65>>] |
| 2090 | /// CHECK-DAG: <<Add:i\d+>> Add [<<Shift>>,<<Const97>>] |
| 2091 | /// CHECK-DAG: <<Sub:i\d+>> Sub [<<Shift>>,<<Const129>>] |
| 2092 | /// CHECK-DAG: Shl [<<Value>>,<<Or>>] |
| 2093 | /// CHECK-DAG: Shr [<<Value>>,<<Xor>>] |
| 2094 | /// CHECK-DAG: UShr [<<Value>>,<<Add>>] |
| 2095 | /// CHECK-DAG: Shl [<<Value>>,<<Sub>>] |
| 2096 | |
| 2097 | /// CHECK-START: int Main.$noinline$intNecessaryShiftModifications(int, int) instruction_simplifier (after) |
| 2098 | /// CHECK: <<Value:i\d+>> ParameterValue |
| 2099 | /// CHECK: <<Shift:i\d+>> ParameterValue |
| 2100 | /// CHECK-DAG: <<Const33:i\d+>> IntConstant 33 |
| 2101 | /// CHECK-DAG: <<Const65:i\d+>> IntConstant 65 |
| 2102 | /// CHECK-DAG: <<Const97:i\d+>> IntConstant 97 |
| 2103 | /// CHECK-DAG: <<Const129:i\d+>> IntConstant 129 |
| 2104 | /// CHECK-DAG: <<Or:i\d+>> Or [<<Shift>>,<<Const33>>] |
| 2105 | /// CHECK-DAG: <<Xor:i\d+>> Xor [<<Shift>>,<<Const65>>] |
| 2106 | /// CHECK-DAG: <<Add:i\d+>> Add [<<Shift>>,<<Const97>>] |
| 2107 | /// CHECK-DAG: <<Sub:i\d+>> Sub [<<Shift>>,<<Const129>>] |
| 2108 | /// CHECK-DAG: Shl [<<Value>>,<<Or>>] |
| 2109 | /// CHECK-DAG: Shr [<<Value>>,<<Xor>>] |
| 2110 | /// CHECK-DAG: UShr [<<Value>>,<<Add>>] |
| 2111 | /// CHECK-DAG: Shl [<<Value>>,<<Sub>>] |
| 2112 | |
| 2113 | public static int $noinline$intNecessaryShiftModifications(int value, int shift) { |
Vladimir Marko | 7033d49 | 2017-09-28 16:32:24 +0100 | [diff] [blame] | 2114 | int c129 = 129; |
| 2115 | return (value << (shift | 33)) + |
| 2116 | (value >> (shift ^ 65)) + |
| 2117 | (value >>> (shift + 97)) + |
| 2118 | (value << (shift - c129)); // Needs a named constant to generate Sub. |
| 2119 | } |
| 2120 | |
Maxim Kazantsev | d3278bd | 2016-07-12 15:55:33 +0600 | [diff] [blame] | 2121 | /// CHECK-START: int Main.$noinline$intAddSubSimplifyArg1(int, int) instruction_simplifier (before) |
| 2122 | /// CHECK: <<X:i\d+>> ParameterValue |
| 2123 | /// CHECK: <<Y:i\d+>> ParameterValue |
| 2124 | /// CHECK-DAG: <<Sum:i\d+>> Add [<<X>>,<<Y>>] |
| 2125 | /// CHECK-DAG: <<Res:i\d+>> Sub [<<Sum>>,<<X>>] |
| 2126 | /// CHECK-DAG: Return [<<Res>>] |
| 2127 | |
| 2128 | /// CHECK-START: int Main.$noinline$intAddSubSimplifyArg1(int, int) instruction_simplifier (after) |
| 2129 | /// CHECK: <<X:i\d+>> ParameterValue |
| 2130 | /// CHECK: <<Y:i\d+>> ParameterValue |
| 2131 | /// CHECK-DAG: <<Sum:i\d+>> Add [<<X>>,<<Y>>] |
| 2132 | /// CHECK-DAG: Return [<<Y>>] |
| 2133 | |
| 2134 | public static int $noinline$intAddSubSimplifyArg1(int x, int y) { |
Maxim Kazantsev | d3278bd | 2016-07-12 15:55:33 +0600 | [diff] [blame] | 2135 | int sum = x + y; |
| 2136 | return sum - x; |
| 2137 | } |
| 2138 | |
| 2139 | /// CHECK-START: int Main.$noinline$intAddSubSimplifyArg2(int, int) instruction_simplifier (before) |
| 2140 | /// CHECK: <<X:i\d+>> ParameterValue |
| 2141 | /// CHECK: <<Y:i\d+>> ParameterValue |
| 2142 | /// CHECK-DAG: <<Sum:i\d+>> Add [<<X>>,<<Y>>] |
| 2143 | /// CHECK-DAG: <<Res:i\d+>> Sub [<<Sum>>,<<Y>>] |
| 2144 | /// CHECK-DAG: Return [<<Res>>] |
| 2145 | |
| 2146 | /// CHECK-START: int Main.$noinline$intAddSubSimplifyArg2(int, int) instruction_simplifier (after) |
| 2147 | /// CHECK: <<X:i\d+>> ParameterValue |
| 2148 | /// CHECK: <<Y:i\d+>> ParameterValue |
| 2149 | /// CHECK-DAG: <<Sum:i\d+>> Add [<<X>>,<<Y>>] |
| 2150 | /// CHECK-DAG: Return [<<X>>] |
| 2151 | |
| 2152 | public static int $noinline$intAddSubSimplifyArg2(int x, int y) { |
Maxim Kazantsev | d3278bd | 2016-07-12 15:55:33 +0600 | [diff] [blame] | 2153 | int sum = x + y; |
| 2154 | return sum - y; |
| 2155 | } |
| 2156 | |
| 2157 | /// CHECK-START: int Main.$noinline$intSubAddSimplifyLeft(int, int) instruction_simplifier (before) |
| 2158 | /// CHECK: <<X:i\d+>> ParameterValue |
| 2159 | /// CHECK: <<Y:i\d+>> ParameterValue |
| 2160 | /// CHECK-DAG: <<Sub:i\d+>> Sub [<<X>>,<<Y>>] |
| 2161 | /// CHECK-DAG: <<Res:i\d+>> Add [<<Sub>>,<<Y>>] |
| 2162 | /// CHECK-DAG: Return [<<Res>>] |
| 2163 | |
| 2164 | /// CHECK-START: int Main.$noinline$intSubAddSimplifyLeft(int, int) instruction_simplifier (after) |
| 2165 | /// CHECK: <<X:i\d+>> ParameterValue |
| 2166 | /// CHECK: <<Y:i\d+>> ParameterValue |
| 2167 | /// CHECK-DAG: <<Sub:i\d+>> Sub [<<X>>,<<Y>>] |
| 2168 | /// CHECK-DAG: Return [<<X>>] |
| 2169 | |
| 2170 | public static int $noinline$intSubAddSimplifyLeft(int x, int y) { |
Maxim Kazantsev | d3278bd | 2016-07-12 15:55:33 +0600 | [diff] [blame] | 2171 | int sub = x - y; |
| 2172 | return sub + y; |
| 2173 | } |
| 2174 | |
| 2175 | /// CHECK-START: int Main.$noinline$intSubAddSimplifyRight(int, int) instruction_simplifier (before) |
| 2176 | /// CHECK: <<X:i\d+>> ParameterValue |
| 2177 | /// CHECK: <<Y:i\d+>> ParameterValue |
| 2178 | /// CHECK-DAG: <<Sub:i\d+>> Sub [<<X>>,<<Y>>] |
| 2179 | /// CHECK-DAG: <<Res:i\d+>> Add [<<Y>>,<<Sub>>] |
| 2180 | /// CHECK-DAG: Return [<<Res>>] |
| 2181 | |
| 2182 | /// CHECK-START: int Main.$noinline$intSubAddSimplifyRight(int, int) instruction_simplifier (after) |
| 2183 | /// CHECK: <<X:i\d+>> ParameterValue |
| 2184 | /// CHECK: <<Y:i\d+>> ParameterValue |
| 2185 | /// CHECK-DAG: <<Sub:i\d+>> Sub [<<X>>,<<Y>>] |
| 2186 | /// CHECK-DAG: Return [<<X>>] |
| 2187 | |
| 2188 | public static int $noinline$intSubAddSimplifyRight(int x, int y) { |
Maxim Kazantsev | d3278bd | 2016-07-12 15:55:33 +0600 | [diff] [blame] | 2189 | int sub = x - y; |
| 2190 | return y + sub; |
| 2191 | } |
| 2192 | |
| 2193 | /// CHECK-START: float Main.$noinline$floatAddSubSimplifyArg1(float, float) instruction_simplifier (before) |
| 2194 | /// CHECK: <<X:f\d+>> ParameterValue |
| 2195 | /// CHECK: <<Y:f\d+>> ParameterValue |
| 2196 | /// CHECK-DAG: <<Sum:f\d+>> Add [<<X>>,<<Y>>] |
| 2197 | /// CHECK-DAG: <<Res:f\d+>> Sub [<<Sum>>,<<X>>] |
| 2198 | /// CHECK-DAG: Return [<<Res>>] |
| 2199 | |
| 2200 | /// CHECK-START: float Main.$noinline$floatAddSubSimplifyArg1(float, float) instruction_simplifier (after) |
| 2201 | /// CHECK: <<X:f\d+>> ParameterValue |
| 2202 | /// CHECK: <<Y:f\d+>> ParameterValue |
| 2203 | /// CHECK-DAG: <<Sum:f\d+>> Add [<<X>>,<<Y>>] |
| 2204 | /// CHECK-DAG: <<Res:f\d+>> Sub [<<Sum>>,<<X>>] |
| 2205 | /// CHECK-DAG: Return [<<Res>>] |
| 2206 | |
| 2207 | public static float $noinline$floatAddSubSimplifyArg1(float x, float y) { |
Maxim Kazantsev | d3278bd | 2016-07-12 15:55:33 +0600 | [diff] [blame] | 2208 | float sum = x + y; |
| 2209 | return sum - x; |
| 2210 | } |
| 2211 | |
| 2212 | /// CHECK-START: float Main.$noinline$floatAddSubSimplifyArg2(float, float) instruction_simplifier (before) |
| 2213 | /// CHECK: <<X:f\d+>> ParameterValue |
| 2214 | /// CHECK: <<Y:f\d+>> ParameterValue |
| 2215 | /// CHECK-DAG: <<Sum:f\d+>> Add [<<X>>,<<Y>>] |
| 2216 | /// CHECK-DAG: <<Res:f\d+>> Sub [<<Sum>>,<<Y>>] |
| 2217 | /// CHECK-DAG: Return [<<Res>>] |
| 2218 | |
| 2219 | /// CHECK-START: float Main.$noinline$floatAddSubSimplifyArg2(float, float) instruction_simplifier (after) |
| 2220 | /// CHECK: <<X:f\d+>> ParameterValue |
| 2221 | /// CHECK: <<Y:f\d+>> ParameterValue |
| 2222 | /// CHECK-DAG: <<Sum:f\d+>> Add [<<X>>,<<Y>>] |
| 2223 | /// CHECK-DAG: <<Res:f\d+>> Sub [<<Sum>>,<<Y>>] |
| 2224 | /// CHECK-DAG: Return [<<Res>>] |
| 2225 | |
| 2226 | public static float $noinline$floatAddSubSimplifyArg2(float x, float y) { |
Maxim Kazantsev | d3278bd | 2016-07-12 15:55:33 +0600 | [diff] [blame] | 2227 | float sum = x + y; |
| 2228 | return sum - y; |
| 2229 | } |
| 2230 | |
| 2231 | /// CHECK-START: float Main.$noinline$floatSubAddSimplifyLeft(float, float) instruction_simplifier (before) |
| 2232 | /// CHECK: <<X:f\d+>> ParameterValue |
| 2233 | /// CHECK: <<Y:f\d+>> ParameterValue |
| 2234 | /// CHECK-DAG: <<Sub:f\d+>> Sub [<<X>>,<<Y>>] |
| 2235 | /// CHECK-DAG: <<Res:f\d+>> Add [<<Sub>>,<<Y>>] |
| 2236 | /// CHECK-DAG: Return [<<Res>>] |
| 2237 | |
| 2238 | /// CHECK-START: float Main.$noinline$floatSubAddSimplifyLeft(float, float) instruction_simplifier (after) |
| 2239 | /// CHECK: <<X:f\d+>> ParameterValue |
| 2240 | /// CHECK: <<Y:f\d+>> ParameterValue |
| 2241 | /// CHECK-DAG: <<Sub:f\d+>> Sub [<<X>>,<<Y>>] |
| 2242 | /// CHECK-DAG: <<Res:f\d+>> Add [<<Sub>>,<<Y>>] |
| 2243 | /// CHECK-DAG: Return [<<Res>>] |
| 2244 | |
| 2245 | public static float $noinline$floatSubAddSimplifyLeft(float x, float y) { |
Maxim Kazantsev | d3278bd | 2016-07-12 15:55:33 +0600 | [diff] [blame] | 2246 | float sub = x - y; |
| 2247 | return sub + y; |
| 2248 | } |
| 2249 | |
| 2250 | /// CHECK-START: float Main.$noinline$floatSubAddSimplifyRight(float, float) instruction_simplifier (before) |
| 2251 | /// CHECK: <<X:f\d+>> ParameterValue |
| 2252 | /// CHECK: <<Y:f\d+>> ParameterValue |
| 2253 | /// CHECK-DAG: <<Sub:f\d+>> Sub [<<X>>,<<Y>>] |
| 2254 | /// CHECK-DAG: <<Res:f\d+>> Add [<<Y>>,<<Sub>>] |
| 2255 | /// CHECK-DAG: Return [<<Res>>] |
| 2256 | |
| 2257 | /// CHECK-START: float Main.$noinline$floatSubAddSimplifyRight(float, float) instruction_simplifier (after) |
| 2258 | /// CHECK: <<X:f\d+>> ParameterValue |
| 2259 | /// CHECK: <<Y:f\d+>> ParameterValue |
| 2260 | /// CHECK-DAG: <<Sub:f\d+>> Sub [<<X>>,<<Y>>] |
| 2261 | /// CHECK-DAG: <<Res:f\d+>> Add [<<Y>>,<<Sub>>] |
| 2262 | /// CHECK-DAG: Return [<<Res>>] |
| 2263 | |
| 2264 | public static float $noinline$floatSubAddSimplifyRight(float x, float y) { |
Maxim Kazantsev | d3278bd | 2016-07-12 15:55:33 +0600 | [diff] [blame] | 2265 | float sub = x - y; |
| 2266 | return y + sub; |
| 2267 | } |
| 2268 | |
Vladimir Marko | 61b9228 | 2017-10-11 13:23:17 +0100 | [diff] [blame^] | 2269 | /// CHECK-START: int Main.$noinline$getUint8FromInstanceByteField(Main) instruction_simplifier (before) |
| 2270 | /// CHECK-DAG: <<Const255:i\d+>> IntConstant 255 |
| 2271 | /// CHECK-DAG: <<Get:b\d+>> InstanceFieldGet |
| 2272 | /// CHECK-DAG: <<And:i\d+>> And [<<Get>>,<<Const255>>] |
| 2273 | /// CHECK-DAG: Return [<<And>>] |
| 2274 | |
| 2275 | /// CHECK-START: int Main.$noinline$getUint8FromInstanceByteField(Main) instruction_simplifier (after) |
| 2276 | /// CHECK-DAG: <<Get:a\d+>> InstanceFieldGet |
| 2277 | /// CHECK-DAG: Return [<<Get>>] |
| 2278 | |
| 2279 | /// CHECK-START: int Main.$noinline$getUint8FromInstanceByteField(Main) instruction_simplifier (after) |
| 2280 | /// CHECK-NOT: And |
| 2281 | /// CHECK-NOT: TypeConversion |
| 2282 | public static int $noinline$getUint8FromInstanceByteField(Main m) { |
| 2283 | return m.instanceByteField & 0xff; |
| 2284 | } |
| 2285 | |
| 2286 | /// CHECK-START: int Main.$noinline$getUint8FromStaticByteField() instruction_simplifier (before) |
| 2287 | /// CHECK-DAG: <<Const255:i\d+>> IntConstant 255 |
| 2288 | /// CHECK-DAG: <<Get:b\d+>> StaticFieldGet |
| 2289 | /// CHECK-DAG: <<And:i\d+>> And [<<Get>>,<<Const255>>] |
| 2290 | /// CHECK-DAG: Return [<<And>>] |
| 2291 | |
| 2292 | /// CHECK-START: int Main.$noinline$getUint8FromStaticByteField() instruction_simplifier (after) |
| 2293 | /// CHECK-DAG: <<Get:a\d+>> StaticFieldGet |
| 2294 | /// CHECK-DAG: Return [<<Get>>] |
| 2295 | |
| 2296 | /// CHECK-START: int Main.$noinline$getUint8FromStaticByteField() instruction_simplifier (after) |
| 2297 | /// CHECK-NOT: And |
| 2298 | /// CHECK-NOT: TypeConversion |
| 2299 | public static int $noinline$getUint8FromStaticByteField() { |
| 2300 | return staticByteField & 0xff; |
| 2301 | } |
| 2302 | |
| 2303 | /// CHECK-START: int Main.$noinline$getUint8FromByteArray(byte[]) instruction_simplifier (before) |
| 2304 | /// CHECK-DAG: <<Const255:i\d+>> IntConstant 255 |
| 2305 | /// CHECK-DAG: <<Get:b\d+>> ArrayGet |
| 2306 | /// CHECK-DAG: <<And:i\d+>> And [<<Get>>,<<Const255>>] |
| 2307 | /// CHECK-DAG: Return [<<And>>] |
| 2308 | |
| 2309 | /// CHECK-START: int Main.$noinline$getUint8FromByteArray(byte[]) instruction_simplifier (after) |
| 2310 | /// CHECK-DAG: <<Get:a\d+>> ArrayGet |
| 2311 | /// CHECK-DAG: Return [<<Get>>] |
| 2312 | |
| 2313 | /// CHECK-START: int Main.$noinline$getUint8FromByteArray(byte[]) instruction_simplifier (after) |
| 2314 | /// CHECK-NOT: And |
| 2315 | /// CHECK-NOT: TypeConversion |
| 2316 | public static int $noinline$getUint8FromByteArray(byte[] a) { |
| 2317 | return a[0] & 0xff; |
| 2318 | } |
| 2319 | |
| 2320 | /// CHECK-START: int Main.$noinline$getUint16FromInstanceShortField(Main) instruction_simplifier (before) |
| 2321 | /// CHECK-DAG: <<Cst65535:i\d+>> IntConstant 65535 |
| 2322 | /// CHECK-DAG: <<Get:s\d+>> InstanceFieldGet |
| 2323 | /// CHECK-DAG: <<And:i\d+>> And [<<Get>>,<<Cst65535>>] |
| 2324 | /// CHECK-DAG: Return [<<And>>] |
| 2325 | |
| 2326 | /// CHECK-START: int Main.$noinline$getUint16FromInstanceShortField(Main) instruction_simplifier (after) |
| 2327 | /// CHECK-DAG: <<Get:c\d+>> InstanceFieldGet |
| 2328 | /// CHECK-DAG: Return [<<Get>>] |
| 2329 | |
| 2330 | /// CHECK-START: int Main.$noinline$getUint16FromInstanceShortField(Main) instruction_simplifier (after) |
| 2331 | /// CHECK-NOT: And |
| 2332 | /// CHECK-NOT: TypeConversion |
| 2333 | public static int $noinline$getUint16FromInstanceShortField(Main m) { |
| 2334 | return m.instanceShortField & 0xffff; |
| 2335 | } |
| 2336 | |
| 2337 | /// CHECK-START: int Main.$noinline$getUint16FromStaticShortField() instruction_simplifier (before) |
| 2338 | /// CHECK-DAG: <<Cst65535:i\d+>> IntConstant 65535 |
| 2339 | /// CHECK-DAG: <<Get:s\d+>> StaticFieldGet |
| 2340 | /// CHECK-DAG: <<And:i\d+>> And [<<Get>>,<<Cst65535>>] |
| 2341 | /// CHECK-DAG: Return [<<And>>] |
| 2342 | |
| 2343 | /// CHECK-START: int Main.$noinline$getUint16FromStaticShortField() instruction_simplifier (after) |
| 2344 | /// CHECK-DAG: <<Get:c\d+>> StaticFieldGet |
| 2345 | /// CHECK-DAG: Return [<<Get>>] |
| 2346 | |
| 2347 | /// CHECK-START: int Main.$noinline$getUint16FromStaticShortField() instruction_simplifier (after) |
| 2348 | /// CHECK-NOT: And |
| 2349 | /// CHECK-NOT: TypeConversion |
| 2350 | public static int $noinline$getUint16FromStaticShortField() { |
| 2351 | return staticShortField & 0xffff; |
| 2352 | } |
| 2353 | |
| 2354 | /// CHECK-START: int Main.$noinline$getUint16FromShortArray(short[]) instruction_simplifier (before) |
| 2355 | /// CHECK-DAG: <<Cst65535:i\d+>> IntConstant 65535 |
| 2356 | /// CHECK-DAG: <<Get:s\d+>> ArrayGet |
| 2357 | /// CHECK-DAG: <<And:i\d+>> And [<<Get>>,<<Cst65535>>] |
| 2358 | /// CHECK-DAG: Return [<<And>>] |
| 2359 | |
| 2360 | /// CHECK-START: int Main.$noinline$getUint16FromShortArray(short[]) instruction_simplifier (after) |
| 2361 | /// CHECK-DAG: <<Get:c\d+>> ArrayGet |
| 2362 | /// CHECK-DAG: Return [<<Get>>] |
| 2363 | |
| 2364 | /// CHECK-START: int Main.$noinline$getUint16FromShortArray(short[]) instruction_simplifier (after) |
| 2365 | /// CHECK-NOT: And |
| 2366 | /// CHECK-NOT: TypeConversion |
| 2367 | public static int $noinline$getUint16FromShortArray(short[] a) { |
| 2368 | return a[0] & 0xffff; |
| 2369 | } |
| 2370 | |
| 2371 | /// CHECK-START: int Main.$noinline$getInt16FromInstanceCharField(Main) instruction_simplifier (before) |
| 2372 | /// CHECK-DAG: <<Get:c\d+>> InstanceFieldGet |
| 2373 | /// CHECK-DAG: <<Conv:s\d+>> TypeConversion [<<Get>>] |
| 2374 | /// CHECK-DAG: Return [<<Conv>>] |
| 2375 | |
| 2376 | /// CHECK-START: int Main.$noinline$getInt16FromInstanceCharField(Main) instruction_simplifier (after) |
| 2377 | /// CHECK-DAG: <<Get:s\d+>> InstanceFieldGet |
| 2378 | /// CHECK-DAG: Return [<<Get>>] |
| 2379 | |
| 2380 | /// CHECK-START: int Main.$noinline$getInt16FromInstanceCharField(Main) instruction_simplifier (after) |
| 2381 | /// CHECK-NOT: And |
| 2382 | /// CHECK-NOT: TypeConversion |
| 2383 | public static int $noinline$getInt16FromInstanceCharField(Main m) { |
| 2384 | return (short) m.instanceCharField; |
| 2385 | } |
| 2386 | |
| 2387 | /// CHECK-START: int Main.$noinline$getInt16FromStaticCharField() instruction_simplifier (before) |
| 2388 | /// CHECK-DAG: <<Get:c\d+>> StaticFieldGet |
| 2389 | /// CHECK-DAG: <<Conv:s\d+>> TypeConversion [<<Get>>] |
| 2390 | /// CHECK-DAG: Return [<<Conv>>] |
| 2391 | |
| 2392 | /// CHECK-START: int Main.$noinline$getInt16FromStaticCharField() instruction_simplifier (after) |
| 2393 | /// CHECK-DAG: <<Get:s\d+>> StaticFieldGet |
| 2394 | /// CHECK-DAG: Return [<<Get>>] |
| 2395 | |
| 2396 | /// CHECK-START: int Main.$noinline$getInt16FromStaticCharField() instruction_simplifier (after) |
| 2397 | /// CHECK-NOT: And |
| 2398 | /// CHECK-NOT: TypeConversion |
| 2399 | public static int $noinline$getInt16FromStaticCharField() { |
| 2400 | return (short) staticCharField; |
| 2401 | } |
| 2402 | |
| 2403 | /// CHECK-START: int Main.$noinline$getInt16FromCharArray(char[]) instruction_simplifier (before) |
| 2404 | /// CHECK-DAG: <<Get:c\d+>> ArrayGet |
| 2405 | /// CHECK-DAG: <<Conv:s\d+>> TypeConversion [<<Get>>] |
| 2406 | /// CHECK-DAG: Return [<<Conv>>] |
| 2407 | |
| 2408 | /// CHECK-START: int Main.$noinline$getInt16FromCharArray(char[]) instruction_simplifier (after) |
| 2409 | /// CHECK-DAG: <<Get:s\d+>> ArrayGet |
| 2410 | /// CHECK-DAG: Return [<<Get>>] |
| 2411 | |
| 2412 | /// CHECK-START: int Main.$noinline$getInt16FromCharArray(char[]) instruction_simplifier (after) |
| 2413 | /// CHECK-NOT: And |
| 2414 | /// CHECK-NOT: TypeConversion |
| 2415 | public static int $noinline$getInt16FromCharArray(char[] a) { |
| 2416 | return (short) a[0]; |
| 2417 | } |
| 2418 | |
| 2419 | /// CHECK-START: int Main.$noinline$byteToUint8AndBack() instruction_simplifier (before) |
| 2420 | /// CHECK-DAG: <<Const255:i\d+>> IntConstant 255 |
| 2421 | /// CHECK-DAG: <<Get:b\d+>> StaticFieldGet |
| 2422 | /// CHECK-DAG: <<And:i\d+>> And [<<Get>>,<<Const255>>] |
| 2423 | /// CHECK-DAG: <<Invoke:i\d+>> InvokeStaticOrDirect [<<And>>{{(,[ij]\d+)?}}] |
| 2424 | /// CHECK-DAG: Return [<<Invoke>>] |
| 2425 | |
| 2426 | /// CHECK-START: int Main.$noinline$byteToUint8AndBack() instruction_simplifier (after) |
| 2427 | /// CHECK-DAG: <<Get:a\d+>> StaticFieldGet |
| 2428 | /// CHECK-DAG: <<Invoke:i\d+>> InvokeStaticOrDirect [<<Get>>{{(,[ij]\d+)?}}] |
| 2429 | /// CHECK-DAG: Return [<<Invoke>>] |
| 2430 | |
| 2431 | /// CHECK-START: int Main.$noinline$byteToUint8AndBack() instruction_simplifier$after_inlining (before) |
| 2432 | /// CHECK-DAG: <<Get:a\d+>> StaticFieldGet |
| 2433 | /// CHECK-DAG: <<Conv:b\d+>> TypeConversion [<<Get>>] |
| 2434 | /// CHECK-DAG: Return [<<Conv>>] |
| 2435 | |
| 2436 | /// CHECK-START: int Main.$noinline$byteToUint8AndBack() instruction_simplifier$after_inlining (after) |
| 2437 | /// CHECK-DAG: <<Get:b\d+>> StaticFieldGet |
| 2438 | /// CHECK-DAG: Return [<<Get>>] |
| 2439 | public static int $noinline$byteToUint8AndBack() { |
| 2440 | return $inline$toByte(staticByteField & 0xff); |
| 2441 | } |
| 2442 | |
| 2443 | public static int $inline$toByte(int value) { |
| 2444 | return (byte) value; |
| 2445 | } |
| 2446 | |
| 2447 | /// CHECK-START: int Main.$noinline$getStaticCharFieldAnd0xff() instruction_simplifier (before) |
| 2448 | /// CHECK-DAG: <<Const255:i\d+>> IntConstant 255 |
| 2449 | /// CHECK-DAG: <<Get:c\d+>> StaticFieldGet |
| 2450 | /// CHECK-DAG: <<And:i\d+>> And [<<Get>>,<<Const255>>] |
| 2451 | /// CHECK-DAG: Return [<<And>>] |
| 2452 | |
| 2453 | /// CHECK-START: int Main.$noinline$getStaticCharFieldAnd0xff() instruction_simplifier (after) |
| 2454 | /// CHECK-DAG: <<Const255:i\d+>> IntConstant 255 |
| 2455 | /// CHECK-DAG: <<Get:c\d+>> StaticFieldGet |
| 2456 | /// CHECK-DAG: <<Cnv:a\d+>> TypeConversion [<<Get>>] |
| 2457 | /// CHECK-DAG: Return [<<Cnv>>] |
| 2458 | |
| 2459 | /// CHECK-START: int Main.$noinline$getStaticCharFieldAnd0xff() instruction_simplifier (after) |
| 2460 | /// CHECK-NOT: {{a\d+}} StaticFieldGet |
| 2461 | public static int $noinline$getStaticCharFieldAnd0xff() { |
| 2462 | return staticCharField & 0xff; |
| 2463 | } |
| 2464 | |
| 2465 | /// CHECK-START: int Main.$noinline$getUint8FromInstanceByteFieldWithAnotherUse(Main) instruction_simplifier (before) |
| 2466 | /// CHECK-DAG: <<Const8:i\d+>> IntConstant 8 |
| 2467 | /// CHECK-DAG: <<Const255:i\d+>> IntConstant 255 |
| 2468 | /// CHECK-DAG: <<Get:b\d+>> InstanceFieldGet |
| 2469 | /// CHECK-DAG: <<And:i\d+>> And [<<Get>>,<<Const255>>] |
| 2470 | /// CHECK-DAG: <<Shl:i\d+>> Shl [<<Get>>,<<Const8>>] |
| 2471 | /// CHECK-DAG: <<Add:i\d+>> Add [<<And>>,<<Shl>>] |
| 2472 | /// CHECK-DAG: Return [<<Add>>] |
| 2473 | |
| 2474 | /// CHECK-START: int Main.$noinline$getUint8FromInstanceByteFieldWithAnotherUse(Main) instruction_simplifier (after) |
| 2475 | /// CHECK-DAG: <<Const8:i\d+>> IntConstant 8 |
| 2476 | /// CHECK-DAG: <<Const255:i\d+>> IntConstant 255 |
| 2477 | /// CHECK-DAG: <<Get:b\d+>> InstanceFieldGet |
| 2478 | /// CHECK-DAG: <<Cnv:a\d+>> TypeConversion [<<Get>>] |
| 2479 | /// CHECK-DAG: <<Shl:i\d+>> Shl [<<Get>>,<<Const8>>] |
| 2480 | /// CHECK-DAG: <<Add:i\d+>> Add [<<Cnv>>,<<Shl>>] |
| 2481 | /// CHECK-DAG: Return [<<Add>>] |
| 2482 | |
| 2483 | /// CHECK-START: int Main.$noinline$getUint8FromInstanceByteFieldWithAnotherUse(Main) instruction_simplifier (after) |
| 2484 | /// CHECK-NOT: {{a\d+}} InstanceFieldGet |
| 2485 | public static int $noinline$getUint8FromInstanceByteFieldWithAnotherUse(Main m) { |
| 2486 | byte b = m.instanceByteField; |
| 2487 | int v1 = b & 0xff; |
| 2488 | int v2 = (b << 8); |
| 2489 | return v1 + v2; |
| 2490 | } |
| 2491 | |
| 2492 | /// CHECK-START: int Main.$noinline$intAnd0xffToChar(int) instruction_simplifier (before) |
| 2493 | /// CHECK-DAG: <<Arg:i\d+>> ParameterValue |
| 2494 | /// CHECK-DAG: <<Const255:i\d+>> IntConstant 255 |
| 2495 | /// CHECK-DAG: <<And:i\d+>> And [<<Arg>>,<<Const255>>] |
| 2496 | /// CHECK-DAG: <<Conv:c\d+>> TypeConversion [<<And>>] |
| 2497 | /// CHECK-DAG: Return [<<Conv>>] |
| 2498 | |
| 2499 | /// CHECK-START: int Main.$noinline$intAnd0xffToChar(int) instruction_simplifier (after) |
| 2500 | /// CHECK-DAG: <<Arg:i\d+>> ParameterValue |
| 2501 | /// CHECK-DAG: <<Conv:a\d+>> TypeConversion [<<Arg>>] |
| 2502 | /// CHECK-DAG: Return [<<Conv>>] |
| 2503 | public static int $noinline$intAnd0xffToChar(int value) { |
| 2504 | return (char) (value & 0xff); |
| 2505 | } |
| 2506 | |
| 2507 | /// CHECK-START: int Main.$noinline$intAnd0x1ffToChar(int) instruction_simplifier (before) |
| 2508 | /// CHECK-DAG: <<Arg:i\d+>> ParameterValue |
| 2509 | /// CHECK-DAG: <<Const511:i\d+>> IntConstant 511 |
| 2510 | /// CHECK-DAG: <<And:i\d+>> And [<<Arg>>,<<Const511>>] |
| 2511 | /// CHECK-DAG: <<Conv:c\d+>> TypeConversion [<<And>>] |
| 2512 | /// CHECK-DAG: Return [<<Conv>>] |
| 2513 | |
| 2514 | // TODO: Simplify this. Unlike the $noinline$intAnd0xffToChar(), the TypeConversion |
| 2515 | // to `char` is not eliminated despite the result of the And being within the `char` range. |
| 2516 | |
| 2517 | // CHECK-START: int Main.$noinline$intAnd0x1ffToChar(int) instruction_simplifier (after) |
| 2518 | // CHECK-DAG: <<Arg:i\d+>> ParameterValue |
| 2519 | // CHECK-DAG: <<Const511:i\d+>> IntConstant 511 |
| 2520 | // CHECK-DAG: <<And:i\d+>> And [<<Arg>>,<<Const511>>] |
| 2521 | // CHECK-DAG: Return [<<And>>] |
| 2522 | public static int $noinline$intAnd0x1ffToChar(int value) { |
| 2523 | return (char) (value & 0x1ff); |
| 2524 | } |
| 2525 | |
| 2526 | /// CHECK-START: int Main.$noinline$getInstanceCharFieldAnd0x1ffff(Main) instruction_simplifier (before) |
| 2527 | /// CHECK-DAG: <<Cst1ffff:i\d+>> IntConstant 131071 |
| 2528 | /// CHECK-DAG: <<Get:c\d+>> InstanceFieldGet |
| 2529 | /// CHECK-DAG: <<And:i\d+>> And [<<Get>>,<<Cst1ffff>>] |
| 2530 | /// CHECK-DAG: Return [<<And>>] |
| 2531 | |
| 2532 | // TODO: Simplify this. The And is useless. |
| 2533 | |
| 2534 | // CHECK-START: int Main.$noinline$getInstanceCharFieldAnd0x1ffff(Main) instruction_simplifier (after) |
| 2535 | // CHECK-DAG: <<Get:c\d+>> InstanceFieldGet |
| 2536 | // CHECK-DAG: Return [<<Get>>] |
| 2537 | public static int $noinline$getInstanceCharFieldAnd0x1ffff(Main m) { |
| 2538 | return m.instanceCharField & 0x1ffff; |
| 2539 | } |
| 2540 | |
| 2541 | public static void main(String[] args) { |
Alexandre Rames | b2fd7bc | 2015-03-11 16:48:16 +0000 | [diff] [blame] | 2542 | int arg = 123456; |
Maxim Kazantsev | d3278bd | 2016-07-12 15:55:33 +0600 | [diff] [blame] | 2543 | float floatArg = 123456.125f; |
Alexandre Rames | b2fd7bc | 2015-03-11 16:48:16 +0000 | [diff] [blame] | 2544 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 2545 | assertLongEquals(arg, $noinline$Add0(arg)); |
Anton Kirilov | e14dc86 | 2016-05-13 17:56:15 +0100 | [diff] [blame] | 2546 | assertIntEquals(5, $noinline$AddAddSubAddConst(1)); |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 2547 | assertIntEquals(arg, $noinline$AndAllOnes(arg)); |
| 2548 | assertLongEquals(arg, $noinline$Div1(arg)); |
| 2549 | assertIntEquals(-arg, $noinline$DivN1(arg)); |
| 2550 | assertLongEquals(arg, $noinline$Mul1(arg)); |
| 2551 | assertIntEquals(-arg, $noinline$MulN1(arg)); |
| 2552 | assertLongEquals((128 * arg), $noinline$MulPowerOfTwo128(arg)); |
Anton Kirilov | e14dc86 | 2016-05-13 17:56:15 +0100 | [diff] [blame] | 2553 | assertLongEquals(2640, $noinline$MulMulMulConst(2)); |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 2554 | assertIntEquals(arg, $noinline$Or0(arg)); |
| 2555 | assertLongEquals(arg, $noinline$OrSame(arg)); |
| 2556 | assertIntEquals(arg, $noinline$Shl0(arg)); |
| 2557 | assertLongEquals(arg, $noinline$Shr0(arg)); |
| 2558 | assertLongEquals(arg, $noinline$Shr64(arg)); |
| 2559 | assertLongEquals(arg, $noinline$Sub0(arg)); |
| 2560 | assertIntEquals(-arg, $noinline$SubAliasNeg(arg)); |
Anton Kirilov | e14dc86 | 2016-05-13 17:56:15 +0100 | [diff] [blame] | 2561 | assertIntEquals(9, $noinline$SubAddConst1(2)); |
| 2562 | assertIntEquals(-2, $noinline$SubAddConst2(3)); |
| 2563 | assertLongEquals(3, $noinline$SubSubConst(4)); |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 2564 | assertLongEquals(arg, $noinline$UShr0(arg)); |
| 2565 | assertIntEquals(arg, $noinline$Xor0(arg)); |
| 2566 | assertIntEquals(~arg, $noinline$XorAllOnes(arg)); |
| 2567 | assertIntEquals(-(arg + arg + 1), $noinline$AddNegs1(arg, arg + 1)); |
| 2568 | assertIntEquals(-(arg + arg + 1), $noinline$AddNegs2(arg, arg + 1)); |
| 2569 | assertLongEquals(-(2 * arg + 1), $noinline$AddNegs3(arg, arg + 1)); |
| 2570 | assertLongEquals(1, $noinline$AddNeg1(arg, arg + 1)); |
| 2571 | assertLongEquals(-1, $noinline$AddNeg2(arg, arg + 1)); |
| 2572 | assertLongEquals(arg, $noinline$NegNeg1(arg)); |
| 2573 | assertIntEquals(0, $noinline$NegNeg2(arg)); |
| 2574 | assertLongEquals(arg, $noinline$NegNeg3(arg)); |
| 2575 | assertIntEquals(1, $noinline$NegSub1(arg, arg + 1)); |
| 2576 | assertIntEquals(1, $noinline$NegSub2(arg, arg + 1)); |
| 2577 | assertLongEquals(arg, $noinline$NotNot1(arg)); |
Vladimir Marko | c8fb211 | 2017-10-03 11:37:52 +0100 | [diff] [blame] | 2578 | assertLongEquals(arg, $noinline$runSmaliTestLong("$noinline$NotNot1", arg)); |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 2579 | assertIntEquals(-1, $noinline$NotNot2(arg)); |
Vladimir Marko | c8fb211 | 2017-10-03 11:37:52 +0100 | [diff] [blame] | 2580 | assertIntEquals(-1, $noinline$runSmaliTestInt("$noinline$NotNot2", arg)); |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 2581 | assertIntEquals(-(arg + arg + 1), $noinline$SubNeg1(arg, arg + 1)); |
| 2582 | assertIntEquals(-(arg + arg + 1), $noinline$SubNeg2(arg, arg + 1)); |
| 2583 | assertLongEquals(-(2 * arg + 1), $noinline$SubNeg3(arg, arg + 1)); |
| 2584 | assertBooleanEquals(true, $noinline$EqualBoolVsIntConst(true)); |
| 2585 | assertBooleanEquals(true, $noinline$EqualBoolVsIntConst(true)); |
| 2586 | assertBooleanEquals(false, $noinline$NotEqualBoolVsIntConst(false)); |
| 2587 | assertBooleanEquals(false, $noinline$NotEqualBoolVsIntConst(false)); |
| 2588 | assertBooleanEquals(true, $noinline$NotNotBool(true)); |
Vladimir Marko | c8fb211 | 2017-10-03 11:37:52 +0100 | [diff] [blame] | 2589 | assertBooleanEquals(true, $noinline$runSmaliTestBoolean("$noinline$NotNotBool", true)); |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 2590 | assertBooleanEquals(false, $noinline$NotNotBool(false)); |
Vladimir Marko | c8fb211 | 2017-10-03 11:37:52 +0100 | [diff] [blame] | 2591 | assertBooleanEquals(false, $noinline$runSmaliTestBoolean("$noinline$NotNotBool", false)); |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 2592 | assertFloatEquals(50.0f, $noinline$Div2(100.0f)); |
| 2593 | assertDoubleEquals(75.0, $noinline$Div2(150.0)); |
| 2594 | assertFloatEquals(-400.0f, $noinline$DivMP25(100.0f)); |
| 2595 | assertDoubleEquals(-600.0, $noinline$DivMP25(150.0)); |
| 2596 | assertIntEquals(0xc, $noinline$UShr28And15(0xc1234567)); |
| 2597 | assertLongEquals(0xcL, $noinline$UShr60And15(0xc123456787654321L)); |
| 2598 | assertIntEquals(0x4, $noinline$UShr28And7(0xc1234567)); |
| 2599 | assertLongEquals(0x4L, $noinline$UShr60And7(0xc123456787654321L)); |
| 2600 | assertIntEquals(0xc1, $noinline$Shr24And255(0xc1234567)); |
Vladimir Marko | 61b9228 | 2017-10-11 13:23:17 +0100 | [diff] [blame^] | 2601 | assertIntEquals(0x60, $noinline$Shr25And127(0xc1234567)); |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 2602 | assertLongEquals(0xc1L, $noinline$Shr56And255(0xc123456787654321L)); |
Vladimir Marko | 61b9228 | 2017-10-11 13:23:17 +0100 | [diff] [blame^] | 2603 | assertLongEquals(0x60L, $noinline$Shr57And127(0xc123456787654321L)); |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 2604 | assertIntEquals(0x41, $noinline$Shr24And127(0xc1234567)); |
| 2605 | assertLongEquals(0x41L, $noinline$Shr56And127(0xc123456787654321L)); |
| 2606 | assertIntEquals(0, $noinline$mulPow2Plus1(0)); |
| 2607 | assertIntEquals(9, $noinline$mulPow2Plus1(1)); |
| 2608 | assertIntEquals(18, $noinline$mulPow2Plus1(2)); |
| 2609 | assertIntEquals(900, $noinline$mulPow2Plus1(100)); |
| 2610 | assertIntEquals(111105, $noinline$mulPow2Plus1(12345)); |
| 2611 | assertLongEquals(0, $noinline$mulPow2Minus1(0)); |
| 2612 | assertLongEquals(31, $noinline$mulPow2Minus1(1)); |
| 2613 | assertLongEquals(62, $noinline$mulPow2Minus1(2)); |
| 2614 | assertLongEquals(3100, $noinline$mulPow2Minus1(100)); |
| 2615 | assertLongEquals(382695, $noinline$mulPow2Minus1(12345)); |
Mark Mendell | f652917 | 2015-11-17 11:16:56 -0500 | [diff] [blame] | 2616 | |
| 2617 | booleanField = false; |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 2618 | assertIntEquals($noinline$booleanFieldNotEqualOne(), 54); |
| 2619 | assertIntEquals($noinline$booleanFieldEqualZero(), 54); |
Mark Mendell | f652917 | 2015-11-17 11:16:56 -0500 | [diff] [blame] | 2620 | booleanField = true; |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 2621 | assertIntEquals(13, $noinline$booleanFieldNotEqualOne()); |
| 2622 | assertIntEquals(13, $noinline$booleanFieldEqualZero()); |
| 2623 | assertIntEquals(54, $noinline$intConditionNotEqualOne(6)); |
| 2624 | assertIntEquals(13, $noinline$intConditionNotEqualOne(43)); |
| 2625 | assertIntEquals(54, $noinline$intConditionEqualZero(6)); |
| 2626 | assertIntEquals(13, $noinline$intConditionEqualZero(43)); |
| 2627 | assertIntEquals(54, $noinline$floatConditionNotEqualOne(6.0f)); |
| 2628 | assertIntEquals(13, $noinline$floatConditionNotEqualOne(43.0f)); |
| 2629 | assertIntEquals(54, $noinline$doubleConditionEqualZero(6.0)); |
| 2630 | assertIntEquals(13, $noinline$doubleConditionEqualZero(43.0)); |
Vladimir Marko | b52bbde | 2016-02-12 12:06:05 +0000 | [diff] [blame] | 2631 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 2632 | assertIntEquals(1234567, $noinline$intToDoubleToInt(1234567)); |
| 2633 | assertIntEquals(Integer.MIN_VALUE, $noinline$intToDoubleToInt(Integer.MIN_VALUE)); |
| 2634 | assertIntEquals(Integer.MAX_VALUE, $noinline$intToDoubleToInt(Integer.MAX_VALUE)); |
| 2635 | assertStringEquals("d=7654321.0, i=7654321", $noinline$intToDoubleToIntPrint(7654321)); |
| 2636 | assertIntEquals(12, $noinline$byteToDoubleToInt((byte) 12)); |
| 2637 | assertIntEquals(Byte.MIN_VALUE, $noinline$byteToDoubleToInt(Byte.MIN_VALUE)); |
| 2638 | assertIntEquals(Byte.MAX_VALUE, $noinline$byteToDoubleToInt(Byte.MAX_VALUE)); |
| 2639 | assertIntEquals(11, $noinline$floatToDoubleToInt(11.3f)); |
| 2640 | assertStringEquals("d=12.25, i=12", $noinline$floatToDoubleToIntPrint(12.25f)); |
| 2641 | assertIntEquals(123, $noinline$byteToDoubleToShort((byte) 123)); |
| 2642 | assertIntEquals(Byte.MIN_VALUE, $noinline$byteToDoubleToShort(Byte.MIN_VALUE)); |
| 2643 | assertIntEquals(Byte.MAX_VALUE, $noinline$byteToDoubleToShort(Byte.MAX_VALUE)); |
| 2644 | assertIntEquals(1234, $noinline$charToDoubleToShort((char) 1234)); |
| 2645 | assertIntEquals(Character.MIN_VALUE, $noinline$charToDoubleToShort(Character.MIN_VALUE)); |
| 2646 | assertIntEquals(/* sign-extended */ -1, $noinline$charToDoubleToShort(Character.MAX_VALUE)); |
| 2647 | assertIntEquals(12345, $noinline$floatToIntToShort(12345.75f)); |
| 2648 | assertIntEquals(Short.MAX_VALUE, $noinline$floatToIntToShort((float)(Short.MIN_VALUE - 1))); |
| 2649 | assertIntEquals(Short.MIN_VALUE, $noinline$floatToIntToShort((float)(Short.MAX_VALUE + 1))); |
| 2650 | assertIntEquals(-54321, $noinline$intToFloatToInt(-54321)); |
| 2651 | assertDoubleEquals((double) 0x12345678, $noinline$longToIntToDouble(0x1234567812345678L)); |
| 2652 | assertDoubleEquals(0.0, $noinline$longToIntToDouble(Long.MIN_VALUE)); |
| 2653 | assertDoubleEquals(-1.0, $noinline$longToIntToDouble(Long.MAX_VALUE)); |
| 2654 | assertLongEquals(0x0000000012345678L, $noinline$longToIntToLong(0x1234567812345678L)); |
| 2655 | assertLongEquals(0xffffffff87654321L, $noinline$longToIntToLong(0x1234567887654321L)); |
| 2656 | assertLongEquals(0L, $noinline$longToIntToLong(Long.MIN_VALUE)); |
| 2657 | assertLongEquals(-1L, $noinline$longToIntToLong(Long.MAX_VALUE)); |
| 2658 | assertIntEquals((short) -5678, $noinline$shortToCharToShort((short) -5678)); |
| 2659 | assertIntEquals(Short.MIN_VALUE, $noinline$shortToCharToShort(Short.MIN_VALUE)); |
| 2660 | assertIntEquals(Short.MAX_VALUE, $noinline$shortToCharToShort(Short.MAX_VALUE)); |
| 2661 | assertIntEquals(5678, $noinline$shortToLongToInt((short) 5678)); |
| 2662 | assertIntEquals(Short.MIN_VALUE, $noinline$shortToLongToInt(Short.MIN_VALUE)); |
| 2663 | assertIntEquals(Short.MAX_VALUE, $noinline$shortToLongToInt(Short.MAX_VALUE)); |
| 2664 | assertIntEquals(0x34, $noinline$shortToCharToByte((short) 0x1234)); |
| 2665 | assertIntEquals(-0x10, $noinline$shortToCharToByte((short) 0x12f0)); |
| 2666 | assertIntEquals(0, $noinline$shortToCharToByte(Short.MIN_VALUE)); |
| 2667 | assertIntEquals(-1, $noinline$shortToCharToByte(Short.MAX_VALUE)); |
| 2668 | assertStringEquals("c=1025, b=1", $noinline$shortToCharToBytePrint((short) 1025)); |
| 2669 | assertStringEquals("c=1023, b=-1", $noinline$shortToCharToBytePrint((short) 1023)); |
| 2670 | assertStringEquals("c=65535, b=-1", $noinline$shortToCharToBytePrint((short) -1)); |
Vladimir Marko | 8428bd3 | 2016-02-12 16:53:57 +0000 | [diff] [blame] | 2671 | |
Vladimir Marko | c8fb211 | 2017-10-03 11:37:52 +0100 | [diff] [blame] | 2672 | assertLongEquals(0x55411410L, $noinline$intAndSmallLongConstant(0x55555555)); |
| 2673 | assertLongEquals(0xffffffffaa028aa2L, $noinline$intAndSmallLongConstant(0xaaaaaaaa)); |
| 2674 | assertLongEquals(0x44101440L, $noinline$intAndLargeLongConstant(0x55555555)); |
| 2675 | assertLongEquals(0x208a002aaL, $noinline$intAndLargeLongConstant(0xaaaaaaaa)); |
| 2676 | assertLongEquals(7L, $noinline$intShr28And15L(0x76543210)); |
| 2677 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 2678 | assertIntEquals(0x21, $noinline$longAnd0xffToByte(0x1234432112344321L)); |
| 2679 | assertIntEquals(0, $noinline$longAnd0xffToByte(Long.MIN_VALUE)); |
| 2680 | assertIntEquals(-1, $noinline$longAnd0xffToByte(Long.MAX_VALUE)); |
| 2681 | assertIntEquals(0x1234, $noinline$intAnd0x1ffffToChar(0x43211234)); |
| 2682 | assertIntEquals(0, $noinline$intAnd0x1ffffToChar(Integer.MIN_VALUE)); |
| 2683 | assertIntEquals(Character.MAX_VALUE, $noinline$intAnd0x1ffffToChar(Integer.MAX_VALUE)); |
| 2684 | assertIntEquals(0x4321, $noinline$intAnd0x17fffToShort(0x87654321)); |
| 2685 | assertIntEquals(0x0888, $noinline$intAnd0x17fffToShort(0x88888888)); |
| 2686 | assertIntEquals(0, $noinline$intAnd0x17fffToShort(Integer.MIN_VALUE)); |
| 2687 | assertIntEquals(Short.MAX_VALUE, $noinline$intAnd0x17fffToShort(Integer.MAX_VALUE)); |
Vladimir Marko | 625090f | 2016-03-14 18:00:05 +0000 | [diff] [blame] | 2688 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 2689 | assertDoubleEquals(0.0, $noinline$shortAnd0xffffToShortToDouble((short) 0)); |
| 2690 | assertDoubleEquals(1.0, $noinline$shortAnd0xffffToShortToDouble((short) 1)); |
| 2691 | assertDoubleEquals(-2.0, $noinline$shortAnd0xffffToShortToDouble((short) -2)); |
| 2692 | assertDoubleEquals(12345.0, $noinline$shortAnd0xffffToShortToDouble((short) 12345)); |
| 2693 | assertDoubleEquals((double)Short.MAX_VALUE, |
| 2694 | $noinline$shortAnd0xffffToShortToDouble(Short.MAX_VALUE)); |
| 2695 | assertDoubleEquals((double)Short.MIN_VALUE, |
| 2696 | $noinline$shortAnd0xffffToShortToDouble(Short.MIN_VALUE)); |
David Brazdil | f02c3cf | 2016-02-29 09:14:51 +0000 | [diff] [blame] | 2697 | |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 2698 | assertIntEquals(13, $noinline$intReverseCondition(41)); |
| 2699 | assertIntEquals(13, $noinline$intReverseConditionNaN(-5)); |
Anton Shamin | bdd7935 | 2016-02-15 12:48:36 +0600 | [diff] [blame] | 2700 | |
David Brazdil | f02c3cf | 2016-02-29 09:14:51 +0000 | [diff] [blame] | 2701 | for (String condition : new String[] { "Equal", "NotEqual" }) { |
| 2702 | for (String constant : new String[] { "True", "False" }) { |
| 2703 | for (String side : new String[] { "Rhs", "Lhs" }) { |
| 2704 | String name = condition + constant + side; |
Alexandre Rames | a975dcc | 2016-06-27 11:13:34 +0100 | [diff] [blame] | 2705 | assertIntEquals(5, $noinline$runSmaliTest(name, true)); |
| 2706 | assertIntEquals(3, $noinline$runSmaliTest(name, false)); |
David Brazdil | f02c3cf | 2016-02-29 09:14:51 +0000 | [diff] [blame] | 2707 | } |
| 2708 | } |
| 2709 | } |
Alexandre Rames | 5051844 | 2016-06-27 11:39:19 +0100 | [diff] [blame] | 2710 | |
Igor Murashkin | 4269173 | 2017-06-26 15:57:31 -0700 | [diff] [blame] | 2711 | assertIntEquals(0, $noinline$runSmaliTestInt("AddSubConst", 1)); |
| 2712 | assertIntEquals(3, $noinline$runSmaliTestInt("SubAddConst", 2)); |
| 2713 | assertIntEquals(-16, $noinline$runSmaliTestInt("SubSubConst1", 3)); |
| 2714 | assertIntEquals(-5, $noinline$runSmaliTestInt("SubSubConst2", 4)); |
| 2715 | assertIntEquals(26, $noinline$runSmaliTestInt("SubSubConst3", 5)); |
Alexandre Rames | 5051844 | 2016-06-27 11:39:19 +0100 | [diff] [blame] | 2716 | assertIntEquals(0x5e6f7808, $noinline$intUnnecessaryShiftMasking(0xabcdef01, 3)); |
| 2717 | assertIntEquals(0x5e6f7808, $noinline$intUnnecessaryShiftMasking(0xabcdef01, 3 + 32)); |
Vladimir Marko | 7033d49 | 2017-09-28 16:32:24 +0100 | [diff] [blame] | 2718 | assertLongEquals(0xffffffffffffeaf3L, |
| 2719 | $noinline$longUnnecessaryShiftMasking(0xabcdef0123456789L, 50)); |
| 2720 | assertLongEquals(0xffffffffffffeaf3L, |
| 2721 | $noinline$longUnnecessaryShiftMasking(0xabcdef0123456789L, 50 + 64)); |
Alexandre Rames | 5051844 | 2016-06-27 11:39:19 +0100 | [diff] [blame] | 2722 | assertIntEquals(0x2af37b, $noinline$intUnnecessaryWiderShiftMasking(0xabcdef01, 10)); |
| 2723 | assertIntEquals(0x2af37b, $noinline$intUnnecessaryWiderShiftMasking(0xabcdef01, 10 + 128)); |
Vladimir Marko | 7033d49 | 2017-09-28 16:32:24 +0100 | [diff] [blame] | 2724 | assertLongEquals(0xaf37bc048d159e24L, |
| 2725 | $noinline$longSmallerShiftMasking(0xabcdef0123456789L, 2)); |
| 2726 | assertLongEquals(0xaf37bc048d159e24L, |
| 2727 | $noinline$longSmallerShiftMasking(0xabcdef0123456789L, 2 + 256)); |
Alexandre Rames | 5051844 | 2016-06-27 11:39:19 +0100 | [diff] [blame] | 2728 | assertIntEquals(0xfffd5e7c, $noinline$otherUseOfUnnecessaryShiftMasking(0xabcdef01, 13)); |
| 2729 | assertIntEquals(0xfffd5e7c, $noinline$otherUseOfUnnecessaryShiftMasking(0xabcdef01, 13 + 512)); |
Vladimir Marko | 7033d49 | 2017-09-28 16:32:24 +0100 | [diff] [blame] | 2730 | assertIntEquals(0x5f49eb48, $noinline$intUnnecessaryShiftModifications(0xabcdef01, 2)); |
| 2731 | assertIntEquals(0xbd4c29b0, $noinline$intUnnecessaryShiftModifications(0xabcdef01, 3)); |
| 2732 | assertIntEquals(0xc0fed1ca, $noinline$intNecessaryShiftModifications(0xabcdef01, 2)); |
| 2733 | assertIntEquals(0x03578ebc, $noinline$intNecessaryShiftModifications(0xabcdef01, 3)); |
Maxim Kazantsev | d3278bd | 2016-07-12 15:55:33 +0600 | [diff] [blame] | 2734 | |
| 2735 | assertIntEquals(654321, $noinline$intAddSubSimplifyArg1(arg, 654321)); |
| 2736 | assertIntEquals(arg, $noinline$intAddSubSimplifyArg2(arg, 654321)); |
| 2737 | assertIntEquals(arg, $noinline$intSubAddSimplifyLeft(arg, 654321)); |
| 2738 | assertIntEquals(arg, $noinline$intSubAddSimplifyRight(arg, 654321)); |
| 2739 | assertFloatEquals(654321.125f, $noinline$floatAddSubSimplifyArg1(floatArg, 654321.125f)); |
| 2740 | assertFloatEquals(floatArg, $noinline$floatAddSubSimplifyArg2(floatArg, 654321.125f)); |
| 2741 | assertFloatEquals(floatArg, $noinline$floatSubAddSimplifyLeft(floatArg, 654321.125f)); |
| 2742 | assertFloatEquals(floatArg, $noinline$floatSubAddSimplifyRight(floatArg, 654321.125f)); |
Vladimir Marko | 61b9228 | 2017-10-11 13:23:17 +0100 | [diff] [blame^] | 2743 | |
| 2744 | Main m = new Main(); |
| 2745 | m.instanceByteField = -1; |
| 2746 | assertIntEquals(0xff, $noinline$getUint8FromInstanceByteField(m)); |
| 2747 | staticByteField = -2; |
| 2748 | assertIntEquals(0xfe, $noinline$getUint8FromStaticByteField()); |
| 2749 | assertIntEquals(0xfd, $noinline$getUint8FromByteArray(new byte[] { -3 })); |
| 2750 | m.instanceShortField = -4; |
| 2751 | assertIntEquals(0xfffc, $noinline$getUint16FromInstanceShortField(m)); |
| 2752 | staticShortField = -5; |
| 2753 | assertIntEquals(0xfffb, $noinline$getUint16FromStaticShortField()); |
| 2754 | assertIntEquals(0xfffa, $noinline$getUint16FromShortArray(new short[] { -6 })); |
| 2755 | m.instanceCharField = 0xfff9; |
| 2756 | assertIntEquals(-7, $noinline$getInt16FromInstanceCharField(m)); |
| 2757 | staticCharField = 0xfff8; |
| 2758 | assertIntEquals(-8, $noinline$getInt16FromStaticCharField()); |
| 2759 | assertIntEquals(-9, $noinline$getInt16FromCharArray(new char[] { 0xfff7 })); |
| 2760 | |
| 2761 | staticCharField = 0xfff6; |
| 2762 | assertIntEquals(0xf6, $noinline$getStaticCharFieldAnd0xff()); |
| 2763 | |
| 2764 | staticByteField = -11; |
| 2765 | assertIntEquals(-11, $noinline$byteToUint8AndBack()); |
| 2766 | |
| 2767 | m.instanceByteField = -12; |
| 2768 | assertIntEquals(0xfffff4f4, $noinline$getUint8FromInstanceByteFieldWithAnotherUse(m)); |
| 2769 | |
| 2770 | assertIntEquals(0x21, $noinline$intAnd0xffToChar(0x87654321)); |
| 2771 | assertIntEquals(0x121, $noinline$intAnd0x1ffToChar(0x87654321)); |
| 2772 | |
| 2773 | m.instanceCharField = 'x'; |
| 2774 | assertIntEquals('x', $noinline$getInstanceCharFieldAnd0x1ffff(m)); |
Alexandre Rames | b2fd7bc | 2015-03-11 16:48:16 +0000 | [diff] [blame] | 2775 | } |
Mark Mendell | f652917 | 2015-11-17 11:16:56 -0500 | [diff] [blame] | 2776 | |
David Brazdil | f02c3cf | 2016-02-29 09:14:51 +0000 | [diff] [blame] | 2777 | private static boolean $inline$true() { return true; } |
| 2778 | private static boolean $inline$false() { return false; } |
| 2779 | |
Mark Mendell | f652917 | 2015-11-17 11:16:56 -0500 | [diff] [blame] | 2780 | public static boolean booleanField; |
Vladimir Marko | 61b9228 | 2017-10-11 13:23:17 +0100 | [diff] [blame^] | 2781 | |
| 2782 | public static byte staticByteField; |
| 2783 | public static char staticCharField; |
| 2784 | public static short staticShortField; |
| 2785 | |
| 2786 | public byte instanceByteField; |
| 2787 | public char instanceCharField; |
| 2788 | public short instanceShortField; |
Alexandre Rames | b2fd7bc | 2015-03-11 16:48:16 +0000 | [diff] [blame] | 2789 | } |