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 | |
| 17 | public class Main { |
| 18 | |
David Brazdil | 0d13fee | 2015-04-17 14:52:19 +0100 | [diff] [blame] | 19 | public static void assertBooleanEquals(boolean expected, boolean result) { |
| 20 | if (expected != result) { |
| 21 | throw new Error("Expected: " + expected + ", found: " + result); |
| 22 | } |
| 23 | } |
| 24 | |
Alexandre Rames | b2fd7bc | 2015-03-11 16:48:16 +0000 | [diff] [blame] | 25 | public static void assertIntEquals(int expected, int result) { |
| 26 | if (expected != result) { |
| 27 | throw new Error("Expected: " + expected + ", found: " + result); |
| 28 | } |
| 29 | } |
| 30 | |
| 31 | public static void assertLongEquals(long expected, long result) { |
| 32 | if (expected != result) { |
| 33 | throw new Error("Expected: " + expected + ", found: " + result); |
| 34 | } |
| 35 | } |
| 36 | |
Nicolas Geoffray | 0d22184 | 2015-04-27 08:53:46 +0000 | [diff] [blame] | 37 | public static void assertFloatEquals(float expected, float result) { |
| 38 | if (expected != result) { |
| 39 | throw new Error("Expected: " + expected + ", found: " + result); |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | public static void assertDoubleEquals(double expected, double result) { |
| 44 | if (expected != result) { |
| 45 | throw new Error("Expected: " + expected + ", found: " + result); |
| 46 | } |
| 47 | } |
| 48 | |
Alexandre Rames | b2fd7bc | 2015-03-11 16:48:16 +0000 | [diff] [blame] | 49 | /** |
| 50 | * Tiny programs exercising optimizations of arithmetic identities. |
| 51 | */ |
| 52 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 53 | /// CHECK-START: long Main.Add0(long) instruction_simplifier (before) |
| 54 | /// CHECK-DAG: <<Arg:j\d+>> ParameterValue |
| 55 | /// CHECK-DAG: <<Const0:j\d+>> LongConstant 0 |
| 56 | /// CHECK-DAG: <<Add:j\d+>> Add [<<Const0>>,<<Arg>>] |
| 57 | /// CHECK-DAG: Return [<<Add>>] |
Alexandre Rames | b2fd7bc | 2015-03-11 16:48:16 +0000 | [diff] [blame] | 58 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 59 | /// CHECK-START: long Main.Add0(long) instruction_simplifier (after) |
| 60 | /// CHECK-DAG: <<Arg:j\d+>> ParameterValue |
| 61 | /// CHECK-DAG: Return [<<Arg>>] |
David Brazdil | 0d13fee | 2015-04-17 14:52:19 +0100 | [diff] [blame] | 62 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 63 | /// CHECK-START: long Main.Add0(long) instruction_simplifier (after) |
| 64 | /// CHECK-NOT: Add |
Alexandre Rames | b2fd7bc | 2015-03-11 16:48:16 +0000 | [diff] [blame] | 65 | |
| 66 | public static long Add0(long arg) { |
| 67 | return 0 + arg; |
| 68 | } |
| 69 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 70 | /// CHECK-START: int Main.AndAllOnes(int) instruction_simplifier (before) |
| 71 | /// CHECK-DAG: <<Arg:i\d+>> ParameterValue |
| 72 | /// CHECK-DAG: <<ConstF:i\d+>> IntConstant -1 |
| 73 | /// CHECK-DAG: <<And:i\d+>> And [<<Arg>>,<<ConstF>>] |
| 74 | /// CHECK-DAG: Return [<<And>>] |
Alexandre Rames | b2fd7bc | 2015-03-11 16:48:16 +0000 | [diff] [blame] | 75 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 76 | /// CHECK-START: int Main.AndAllOnes(int) instruction_simplifier (after) |
| 77 | /// CHECK-DAG: <<Arg:i\d+>> ParameterValue |
| 78 | /// CHECK-DAG: Return [<<Arg>>] |
Alexandre Rames | b2fd7bc | 2015-03-11 16:48:16 +0000 | [diff] [blame] | 79 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 80 | /// CHECK-START: int Main.AndAllOnes(int) instruction_simplifier (after) |
| 81 | /// CHECK-NOT: And |
Alexandre Rames | 7441769 | 2015-04-09 15:21:41 +0100 | [diff] [blame] | 82 | |
Alexandre Rames | b2fd7bc | 2015-03-11 16:48:16 +0000 | [diff] [blame] | 83 | public static int AndAllOnes(int arg) { |
| 84 | return arg & -1; |
| 85 | } |
| 86 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 87 | /// CHECK-START: long Main.Div1(long) instruction_simplifier (before) |
| 88 | /// CHECK-DAG: <<Arg:j\d+>> ParameterValue |
| 89 | /// CHECK-DAG: <<Const1:j\d+>> LongConstant 1 |
| 90 | /// CHECK-DAG: <<Div:j\d+>> Div [<<Arg>>,<<Const1>>] |
| 91 | /// CHECK-DAG: Return [<<Div>>] |
Alexandre Rames | b2fd7bc | 2015-03-11 16:48:16 +0000 | [diff] [blame] | 92 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 93 | /// CHECK-START: long Main.Div1(long) instruction_simplifier (after) |
| 94 | /// CHECK-DAG: <<Arg:j\d+>> ParameterValue |
| 95 | /// CHECK-DAG: Return [<<Arg>>] |
Alexandre Rames | b2fd7bc | 2015-03-11 16:48:16 +0000 | [diff] [blame] | 96 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 97 | /// CHECK-START: long Main.Div1(long) instruction_simplifier (after) |
| 98 | /// CHECK-NOT: Div |
Alexandre Rames | 7441769 | 2015-04-09 15:21:41 +0100 | [diff] [blame] | 99 | |
Alexandre Rames | b2fd7bc | 2015-03-11 16:48:16 +0000 | [diff] [blame] | 100 | public static long Div1(long arg) { |
| 101 | return arg / 1; |
| 102 | } |
| 103 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 104 | /// CHECK-START: int Main.DivN1(int) instruction_simplifier (before) |
| 105 | /// CHECK-DAG: <<Arg:i\d+>> ParameterValue |
| 106 | /// CHECK-DAG: <<ConstN1:i\d+>> IntConstant -1 |
| 107 | /// CHECK-DAG: <<Div:i\d+>> Div [<<Arg>>,<<ConstN1>>] |
| 108 | /// CHECK-DAG: Return [<<Div>>] |
Alexandre Rames | b2fd7bc | 2015-03-11 16:48:16 +0000 | [diff] [blame] | 109 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 110 | /// CHECK-START: int Main.DivN1(int) instruction_simplifier (after) |
| 111 | /// CHECK-DAG: <<Arg:i\d+>> ParameterValue |
| 112 | /// CHECK-DAG: <<Neg:i\d+>> Neg [<<Arg>>] |
| 113 | /// CHECK-DAG: Return [<<Neg>>] |
Alexandre Rames | b2fd7bc | 2015-03-11 16:48:16 +0000 | [diff] [blame] | 114 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 115 | /// CHECK-START: int Main.DivN1(int) instruction_simplifier (after) |
| 116 | /// CHECK-NOT: Div |
Alexandre Rames | 7441769 | 2015-04-09 15:21:41 +0100 | [diff] [blame] | 117 | |
Alexandre Rames | b2fd7bc | 2015-03-11 16:48:16 +0000 | [diff] [blame] | 118 | public static int DivN1(int arg) { |
| 119 | return arg / -1; |
| 120 | } |
| 121 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 122 | /// CHECK-START: long Main.Mul1(long) instruction_simplifier (before) |
| 123 | /// CHECK-DAG: <<Arg:j\d+>> ParameterValue |
| 124 | /// CHECK-DAG: <<Const1:j\d+>> LongConstant 1 |
| 125 | /// CHECK-DAG: <<Mul:j\d+>> Mul [<<Arg>>,<<Const1>>] |
| 126 | /// CHECK-DAG: Return [<<Mul>>] |
Alexandre Rames | b2fd7bc | 2015-03-11 16:48:16 +0000 | [diff] [blame] | 127 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 128 | /// CHECK-START: long Main.Mul1(long) instruction_simplifier (after) |
| 129 | /// CHECK-DAG: <<Arg:j\d+>> ParameterValue |
| 130 | /// CHECK-DAG: Return [<<Arg>>] |
Alexandre Rames | b2fd7bc | 2015-03-11 16:48:16 +0000 | [diff] [blame] | 131 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 132 | /// CHECK-START: long Main.Mul1(long) instruction_simplifier (after) |
| 133 | /// CHECK-NOT: Mul |
Alexandre Rames | 7441769 | 2015-04-09 15:21:41 +0100 | [diff] [blame] | 134 | |
Alexandre Rames | b2fd7bc | 2015-03-11 16:48:16 +0000 | [diff] [blame] | 135 | public static long Mul1(long arg) { |
| 136 | return arg * 1; |
| 137 | } |
| 138 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 139 | /// CHECK-START: int Main.MulN1(int) instruction_simplifier (before) |
| 140 | /// CHECK-DAG: <<Arg:i\d+>> ParameterValue |
| 141 | /// CHECK-DAG: <<ConstN1:i\d+>> IntConstant -1 |
| 142 | /// CHECK-DAG: <<Mul:i\d+>> Mul [<<Arg>>,<<ConstN1>>] |
| 143 | /// CHECK-DAG: Return [<<Mul>>] |
Alexandre Rames | b2fd7bc | 2015-03-11 16:48:16 +0000 | [diff] [blame] | 144 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 145 | /// CHECK-START: int Main.MulN1(int) instruction_simplifier (after) |
| 146 | /// CHECK-DAG: <<Arg:i\d+>> ParameterValue |
| 147 | /// CHECK-DAG: <<Neg:i\d+>> Neg [<<Arg>>] |
| 148 | /// CHECK-DAG: Return [<<Neg>>] |
Alexandre Rames | b2fd7bc | 2015-03-11 16:48:16 +0000 | [diff] [blame] | 149 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 150 | /// CHECK-START: int Main.MulN1(int) instruction_simplifier (after) |
| 151 | /// CHECK-NOT: Mul |
Alexandre Rames | 7441769 | 2015-04-09 15:21:41 +0100 | [diff] [blame] | 152 | |
Alexandre Rames | b2fd7bc | 2015-03-11 16:48:16 +0000 | [diff] [blame] | 153 | public static int MulN1(int arg) { |
| 154 | return arg * -1; |
| 155 | } |
| 156 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 157 | /// CHECK-START: long Main.MulPowerOfTwo128(long) instruction_simplifier (before) |
| 158 | /// CHECK-DAG: <<Arg:j\d+>> ParameterValue |
| 159 | /// CHECK-DAG: <<Const128:j\d+>> LongConstant 128 |
| 160 | /// CHECK-DAG: <<Mul:j\d+>> Mul [<<Arg>>,<<Const128>>] |
| 161 | /// CHECK-DAG: Return [<<Mul>>] |
Alexandre Rames | b2fd7bc | 2015-03-11 16:48:16 +0000 | [diff] [blame] | 162 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 163 | /// CHECK-START: long Main.MulPowerOfTwo128(long) instruction_simplifier (after) |
| 164 | /// CHECK-DAG: <<Arg:j\d+>> ParameterValue |
| 165 | /// CHECK-DAG: <<Const7:i\d+>> IntConstant 7 |
| 166 | /// CHECK-DAG: <<Shl:j\d+>> Shl [<<Arg>>,<<Const7>>] |
| 167 | /// CHECK-DAG: Return [<<Shl>>] |
Alexandre Rames | b2fd7bc | 2015-03-11 16:48:16 +0000 | [diff] [blame] | 168 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 169 | /// CHECK-START: long Main.MulPowerOfTwo128(long) instruction_simplifier (after) |
| 170 | /// CHECK-NOT: Mul |
Alexandre Rames | 7441769 | 2015-04-09 15:21:41 +0100 | [diff] [blame] | 171 | |
Alexandre Rames | b2fd7bc | 2015-03-11 16:48:16 +0000 | [diff] [blame] | 172 | public static long MulPowerOfTwo128(long arg) { |
| 173 | return arg * 128; |
| 174 | } |
| 175 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 176 | /// CHECK-START: int Main.Or0(int) instruction_simplifier (before) |
| 177 | /// CHECK-DAG: <<Arg:i\d+>> ParameterValue |
| 178 | /// CHECK-DAG: <<Const0:i\d+>> IntConstant 0 |
| 179 | /// CHECK-DAG: <<Or:i\d+>> Or [<<Arg>>,<<Const0>>] |
| 180 | /// CHECK-DAG: Return [<<Or>>] |
Alexandre Rames | b2fd7bc | 2015-03-11 16:48:16 +0000 | [diff] [blame] | 181 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 182 | /// CHECK-START: int Main.Or0(int) instruction_simplifier (after) |
| 183 | /// CHECK-DAG: <<Arg:i\d+>> ParameterValue |
| 184 | /// CHECK-DAG: Return [<<Arg>>] |
Alexandre Rames | b2fd7bc | 2015-03-11 16:48:16 +0000 | [diff] [blame] | 185 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 186 | /// CHECK-START: int Main.Or0(int) instruction_simplifier (after) |
| 187 | /// CHECK-NOT: Or |
Alexandre Rames | 7441769 | 2015-04-09 15:21:41 +0100 | [diff] [blame] | 188 | |
Alexandre Rames | b2fd7bc | 2015-03-11 16:48:16 +0000 | [diff] [blame] | 189 | public static int Or0(int arg) { |
| 190 | return arg | 0; |
| 191 | } |
| 192 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 193 | /// CHECK-START: long Main.OrSame(long) instruction_simplifier (before) |
| 194 | /// CHECK-DAG: <<Arg:j\d+>> ParameterValue |
| 195 | /// CHECK-DAG: <<Or:j\d+>> Or [<<Arg>>,<<Arg>>] |
| 196 | /// CHECK-DAG: Return [<<Or>>] |
Alexandre Rames | b2fd7bc | 2015-03-11 16:48:16 +0000 | [diff] [blame] | 197 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 198 | /// CHECK-START: long Main.OrSame(long) instruction_simplifier (after) |
| 199 | /// CHECK-DAG: <<Arg:j\d+>> ParameterValue |
| 200 | /// CHECK-DAG: Return [<<Arg>>] |
Alexandre Rames | b2fd7bc | 2015-03-11 16:48:16 +0000 | [diff] [blame] | 201 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 202 | /// CHECK-START: long Main.OrSame(long) instruction_simplifier (after) |
| 203 | /// CHECK-NOT: Or |
Alexandre Rames | 7441769 | 2015-04-09 15:21:41 +0100 | [diff] [blame] | 204 | |
Alexandre Rames | b2fd7bc | 2015-03-11 16:48:16 +0000 | [diff] [blame] | 205 | public static long OrSame(long arg) { |
| 206 | return arg | arg; |
| 207 | } |
| 208 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 209 | /// CHECK-START: int Main.Shl0(int) instruction_simplifier (before) |
| 210 | /// CHECK-DAG: <<Arg:i\d+>> ParameterValue |
| 211 | /// CHECK-DAG: <<Const0:i\d+>> IntConstant 0 |
| 212 | /// CHECK-DAG: <<Shl:i\d+>> Shl [<<Arg>>,<<Const0>>] |
| 213 | /// CHECK-DAG: Return [<<Shl>>] |
Alexandre Rames | b2fd7bc | 2015-03-11 16:48:16 +0000 | [diff] [blame] | 214 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 215 | /// CHECK-START: int Main.Shl0(int) instruction_simplifier (after) |
| 216 | /// CHECK-DAG: <<Arg:i\d+>> ParameterValue |
| 217 | /// CHECK-DAG: Return [<<Arg>>] |
Alexandre Rames | b2fd7bc | 2015-03-11 16:48:16 +0000 | [diff] [blame] | 218 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 219 | /// CHECK-START: int Main.Shl0(int) instruction_simplifier (after) |
| 220 | /// CHECK-NOT: Shl |
Alexandre Rames | 7441769 | 2015-04-09 15:21:41 +0100 | [diff] [blame] | 221 | |
Alexandre Rames | b2fd7bc | 2015-03-11 16:48:16 +0000 | [diff] [blame] | 222 | public static int Shl0(int arg) { |
| 223 | return arg << 0; |
| 224 | } |
| 225 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 226 | /// CHECK-START: int Main.Shl1(int) instruction_simplifier (before) |
| 227 | /// CHECK-DAG: <<Arg:i\d+>> ParameterValue |
| 228 | /// CHECK-DAG: <<Const1:i\d+>> IntConstant 1 |
| 229 | /// CHECK-DAG: <<Shl:i\d+>> Shl [<<Arg>>,<<Const1>>] |
| 230 | /// CHECK-DAG: Return [<<Shl>>] |
Mark Mendell | ba56d06 | 2015-05-05 21:34:03 -0400 | [diff] [blame] | 231 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 232 | /// CHECK-START: int Main.Shl1(int) instruction_simplifier (after) |
| 233 | /// CHECK-DAG: <<Arg:i\d+>> ParameterValue |
| 234 | /// CHECK-DAG: <<Add:i\d+>> Add [<<Arg>>,<<Arg>>] |
| 235 | /// CHECK-DAG: Return [<<Add>>] |
Mark Mendell | ba56d06 | 2015-05-05 21:34:03 -0400 | [diff] [blame] | 236 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 237 | /// CHECK-START: int Main.Shl1(int) instruction_simplifier (after) |
| 238 | /// CHECK-NOT: Shl |
Mark Mendell | ba56d06 | 2015-05-05 21:34:03 -0400 | [diff] [blame] | 239 | |
| 240 | public static int Shl1(int arg) { |
| 241 | return arg << 1; |
| 242 | } |
| 243 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 244 | /// CHECK-START: long Main.Shr0(long) instruction_simplifier (before) |
| 245 | /// CHECK-DAG: <<Arg:j\d+>> ParameterValue |
| 246 | /// CHECK-DAG: <<Const0:i\d+>> IntConstant 0 |
| 247 | /// CHECK-DAG: <<Shr:j\d+>> Shr [<<Arg>>,<<Const0>>] |
| 248 | /// CHECK-DAG: Return [<<Shr>>] |
Alexandre Rames | b2fd7bc | 2015-03-11 16:48:16 +0000 | [diff] [blame] | 249 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 250 | /// CHECK-START: long Main.Shr0(long) instruction_simplifier (after) |
| 251 | /// CHECK-DAG: <<Arg:j\d+>> ParameterValue |
| 252 | /// CHECK-DAG: Return [<<Arg>>] |
Alexandre Rames | b2fd7bc | 2015-03-11 16:48:16 +0000 | [diff] [blame] | 253 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 254 | /// CHECK-START: long Main.Shr0(long) instruction_simplifier (after) |
| 255 | /// CHECK-NOT: Shr |
Alexandre Rames | 7441769 | 2015-04-09 15:21:41 +0100 | [diff] [blame] | 256 | |
Alexandre Rames | b2fd7bc | 2015-03-11 16:48:16 +0000 | [diff] [blame] | 257 | public static long Shr0(long arg) { |
| 258 | return arg >> 0; |
| 259 | } |
| 260 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 261 | /// CHECK-START: long Main.Sub0(long) instruction_simplifier (before) |
| 262 | /// CHECK-DAG: <<Arg:j\d+>> ParameterValue |
| 263 | /// CHECK-DAG: <<Const0:j\d+>> LongConstant 0 |
| 264 | /// CHECK-DAG: <<Sub:j\d+>> Sub [<<Arg>>,<<Const0>>] |
| 265 | /// CHECK-DAG: Return [<<Sub>>] |
Alexandre Rames | b2fd7bc | 2015-03-11 16:48:16 +0000 | [diff] [blame] | 266 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 267 | /// CHECK-START: long Main.Sub0(long) instruction_simplifier (after) |
| 268 | /// CHECK-DAG: <<Arg:j\d+>> ParameterValue |
| 269 | /// CHECK-DAG: Return [<<Arg>>] |
Alexandre Rames | b2fd7bc | 2015-03-11 16:48:16 +0000 | [diff] [blame] | 270 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 271 | /// CHECK-START: long Main.Sub0(long) instruction_simplifier (after) |
| 272 | /// CHECK-NOT: Sub |
Alexandre Rames | 7441769 | 2015-04-09 15:21:41 +0100 | [diff] [blame] | 273 | |
Alexandre Rames | b2fd7bc | 2015-03-11 16:48:16 +0000 | [diff] [blame] | 274 | public static long Sub0(long arg) { |
| 275 | return arg - 0; |
| 276 | } |
| 277 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 278 | /// CHECK-START: int Main.SubAliasNeg(int) instruction_simplifier (before) |
| 279 | /// CHECK-DAG: <<Arg:i\d+>> ParameterValue |
| 280 | /// CHECK-DAG: <<Const0:i\d+>> IntConstant 0 |
| 281 | /// CHECK-DAG: <<Sub:i\d+>> Sub [<<Const0>>,<<Arg>>] |
| 282 | /// CHECK-DAG: Return [<<Sub>>] |
Alexandre Rames | b2fd7bc | 2015-03-11 16:48:16 +0000 | [diff] [blame] | 283 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 284 | /// CHECK-START: int Main.SubAliasNeg(int) instruction_simplifier (after) |
| 285 | /// CHECK-DAG: <<Arg:i\d+>> ParameterValue |
| 286 | /// CHECK-DAG: <<Neg:i\d+>> Neg [<<Arg>>] |
| 287 | /// CHECK-DAG: Return [<<Neg>>] |
Alexandre Rames | b2fd7bc | 2015-03-11 16:48:16 +0000 | [diff] [blame] | 288 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 289 | /// CHECK-START: int Main.SubAliasNeg(int) instruction_simplifier (after) |
| 290 | /// CHECK-NOT: Sub |
Alexandre Rames | 7441769 | 2015-04-09 15:21:41 +0100 | [diff] [blame] | 291 | |
Alexandre Rames | b2fd7bc | 2015-03-11 16:48:16 +0000 | [diff] [blame] | 292 | public static int SubAliasNeg(int arg) { |
| 293 | return 0 - arg; |
| 294 | } |
| 295 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 296 | /// CHECK-START: long Main.UShr0(long) instruction_simplifier (before) |
| 297 | /// CHECK-DAG: <<Arg:j\d+>> ParameterValue |
| 298 | /// CHECK-DAG: <<Const0:i\d+>> IntConstant 0 |
| 299 | /// CHECK-DAG: <<UShr:j\d+>> UShr [<<Arg>>,<<Const0>>] |
| 300 | /// CHECK-DAG: Return [<<UShr>>] |
Alexandre Rames | b2fd7bc | 2015-03-11 16:48:16 +0000 | [diff] [blame] | 301 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 302 | /// CHECK-START: long Main.UShr0(long) instruction_simplifier (after) |
| 303 | /// CHECK-DAG: <<Arg:j\d+>> ParameterValue |
| 304 | /// CHECK-DAG: Return [<<Arg>>] |
Alexandre Rames | b2fd7bc | 2015-03-11 16:48:16 +0000 | [diff] [blame] | 305 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 306 | /// CHECK-START: long Main.UShr0(long) instruction_simplifier (after) |
| 307 | /// CHECK-NOT: UShr |
Alexandre Rames | 7441769 | 2015-04-09 15:21:41 +0100 | [diff] [blame] | 308 | |
Alexandre Rames | b2fd7bc | 2015-03-11 16:48:16 +0000 | [diff] [blame] | 309 | public static long UShr0(long arg) { |
| 310 | return arg >>> 0; |
| 311 | } |
| 312 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 313 | /// CHECK-START: int Main.Xor0(int) instruction_simplifier (before) |
| 314 | /// CHECK-DAG: <<Arg:i\d+>> ParameterValue |
| 315 | /// CHECK-DAG: <<Const0:i\d+>> IntConstant 0 |
| 316 | /// CHECK-DAG: <<Xor:i\d+>> Xor [<<Arg>>,<<Const0>>] |
| 317 | /// CHECK-DAG: Return [<<Xor>>] |
Alexandre Rames | b2fd7bc | 2015-03-11 16:48:16 +0000 | [diff] [blame] | 318 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 319 | /// CHECK-START: int Main.Xor0(int) instruction_simplifier (after) |
| 320 | /// CHECK-DAG: <<Arg:i\d+>> ParameterValue |
| 321 | /// CHECK-DAG: Return [<<Arg>>] |
Alexandre Rames | b2fd7bc | 2015-03-11 16:48:16 +0000 | [diff] [blame] | 322 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 323 | /// CHECK-START: int Main.Xor0(int) instruction_simplifier (after) |
| 324 | /// CHECK-NOT: Xor |
Alexandre Rames | 7441769 | 2015-04-09 15:21:41 +0100 | [diff] [blame] | 325 | |
Alexandre Rames | b2fd7bc | 2015-03-11 16:48:16 +0000 | [diff] [blame] | 326 | public static int Xor0(int arg) { |
| 327 | return arg ^ 0; |
| 328 | } |
| 329 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 330 | /// CHECK-START: int Main.XorAllOnes(int) instruction_simplifier (before) |
| 331 | /// CHECK-DAG: <<Arg:i\d+>> ParameterValue |
| 332 | /// CHECK-DAG: <<ConstF:i\d+>> IntConstant -1 |
| 333 | /// CHECK-DAG: <<Xor:i\d+>> Xor [<<Arg>>,<<ConstF>>] |
| 334 | /// CHECK-DAG: Return [<<Xor>>] |
Alexandre Rames | b2fd7bc | 2015-03-11 16:48:16 +0000 | [diff] [blame] | 335 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 336 | /// CHECK-START: int Main.XorAllOnes(int) instruction_simplifier (after) |
| 337 | /// CHECK-DAG: <<Arg:i\d+>> ParameterValue |
| 338 | /// CHECK-DAG: <<Not:i\d+>> Not [<<Arg>>] |
| 339 | /// CHECK-DAG: Return [<<Not>>] |
Alexandre Rames | b2fd7bc | 2015-03-11 16:48:16 +0000 | [diff] [blame] | 340 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 341 | /// CHECK-START: int Main.XorAllOnes(int) instruction_simplifier (after) |
| 342 | /// CHECK-NOT: Xor |
Alexandre Rames | 7441769 | 2015-04-09 15:21:41 +0100 | [diff] [blame] | 343 | |
Alexandre Rames | b2fd7bc | 2015-03-11 16:48:16 +0000 | [diff] [blame] | 344 | public static int XorAllOnes(int arg) { |
| 345 | return arg ^ -1; |
| 346 | } |
| 347 | |
Alexandre Rames | 188d431 | 2015-04-09 18:30:21 +0100 | [diff] [blame] | 348 | /** |
| 349 | * Test that addition or subtraction operation with both inputs negated are |
| 350 | * optimized to use a single negation after the operation. |
| 351 | * The transformation tested is implemented in |
| 352 | * `InstructionSimplifierVisitor::TryMoveNegOnInputsAfterBinop`. |
| 353 | */ |
| 354 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 355 | /// CHECK-START: int Main.AddNegs1(int, int) instruction_simplifier (before) |
| 356 | /// CHECK-DAG: <<Arg1:i\d+>> ParameterValue |
| 357 | /// CHECK-DAG: <<Arg2:i\d+>> ParameterValue |
| 358 | /// CHECK-DAG: <<Neg1:i\d+>> Neg [<<Arg1>>] |
| 359 | /// CHECK-DAG: <<Neg2:i\d+>> Neg [<<Arg2>>] |
| 360 | /// CHECK-DAG: <<Add:i\d+>> Add [<<Neg1>>,<<Neg2>>] |
| 361 | /// CHECK-DAG: Return [<<Add>>] |
Alexandre Rames | 188d431 | 2015-04-09 18:30:21 +0100 | [diff] [blame] | 362 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 363 | /// CHECK-START: int Main.AddNegs1(int, int) instruction_simplifier (after) |
| 364 | /// CHECK-DAG: <<Arg1:i\d+>> ParameterValue |
| 365 | /// CHECK-DAG: <<Arg2:i\d+>> ParameterValue |
| 366 | /// CHECK-NOT: Neg |
| 367 | /// CHECK-DAG: <<Add:i\d+>> Add [<<Arg1>>,<<Arg2>>] |
| 368 | /// CHECK-DAG: <<Neg:i\d+>> Neg [<<Add>>] |
| 369 | /// CHECK-DAG: Return [<<Neg>>] |
Alexandre Rames | 188d431 | 2015-04-09 18:30:21 +0100 | [diff] [blame] | 370 | |
| 371 | public static int AddNegs1(int arg1, int arg2) { |
| 372 | return -arg1 + -arg2; |
| 373 | } |
| 374 | |
| 375 | /** |
| 376 | * This is similar to the test-case AddNegs1, but the negations have |
| 377 | * multiple uses. |
| 378 | * The transformation tested is implemented in |
| 379 | * `InstructionSimplifierVisitor::TryMoveNegOnInputsAfterBinop`. |
| 380 | * The current code won't perform the previous optimization. The |
| 381 | * transformations do not look at other uses of their inputs. As they don't |
| 382 | * know what will happen with other uses, they do not take the risk of |
| 383 | * increasing the register pressure by creating or extending live ranges. |
| 384 | */ |
| 385 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 386 | /// CHECK-START: int Main.AddNegs2(int, int) instruction_simplifier (before) |
| 387 | /// CHECK-DAG: <<Arg1:i\d+>> ParameterValue |
| 388 | /// CHECK-DAG: <<Arg2:i\d+>> ParameterValue |
| 389 | /// CHECK-DAG: <<Neg1:i\d+>> Neg [<<Arg1>>] |
| 390 | /// CHECK-DAG: <<Neg2:i\d+>> Neg [<<Arg2>>] |
| 391 | /// CHECK-DAG: <<Add1:i\d+>> Add [<<Neg1>>,<<Neg2>>] |
| 392 | /// CHECK-DAG: <<Add2:i\d+>> Add [<<Neg1>>,<<Neg2>>] |
| 393 | /// CHECK-DAG: <<Or:i\d+>> Or [<<Add1>>,<<Add2>>] |
| 394 | /// CHECK-DAG: Return [<<Or>>] |
Alexandre Rames | 188d431 | 2015-04-09 18:30:21 +0100 | [diff] [blame] | 395 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 396 | /// CHECK-START: int Main.AddNegs2(int, int) instruction_simplifier (after) |
| 397 | /// CHECK-DAG: <<Arg1:i\d+>> ParameterValue |
| 398 | /// CHECK-DAG: <<Arg2:i\d+>> ParameterValue |
| 399 | /// CHECK-DAG: <<Neg1:i\d+>> Neg [<<Arg1>>] |
| 400 | /// CHECK-DAG: <<Neg2:i\d+>> Neg [<<Arg2>>] |
| 401 | /// CHECK-DAG: <<Add1:i\d+>> Add [<<Neg1>>,<<Neg2>>] |
| 402 | /// CHECK-DAG: <<Add2:i\d+>> Add [<<Neg1>>,<<Neg2>>] |
| 403 | /// CHECK-NOT: Neg |
| 404 | /// CHECK-DAG: <<Or:i\d+>> Or [<<Add1>>,<<Add2>>] |
| 405 | /// CHECK-DAG: Return [<<Or>>] |
Alexandre Rames | 188d431 | 2015-04-09 18:30:21 +0100 | [diff] [blame] | 406 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 407 | /// CHECK-START: int Main.AddNegs2(int, int) GVN (after) |
| 408 | /// CHECK-DAG: <<Arg1:i\d+>> ParameterValue |
| 409 | /// CHECK-DAG: <<Arg2:i\d+>> ParameterValue |
| 410 | /// CHECK-DAG: <<Neg1:i\d+>> Neg [<<Arg1>>] |
| 411 | /// CHECK-DAG: <<Neg2:i\d+>> Neg [<<Arg2>>] |
| 412 | /// CHECK-DAG: <<Add:i\d+>> Add [<<Neg1>>,<<Neg2>>] |
| 413 | /// CHECK-DAG: <<Or:i\d+>> Or [<<Add>>,<<Add>>] |
| 414 | /// CHECK-DAG: Return [<<Or>>] |
Alexandre Rames | b2a5847 | 2015-04-17 14:35:18 +0100 | [diff] [blame] | 415 | |
Alexandre Rames | 188d431 | 2015-04-09 18:30:21 +0100 | [diff] [blame] | 416 | public static int AddNegs2(int arg1, int arg2) { |
| 417 | int temp1 = -arg1; |
| 418 | int temp2 = -arg2; |
| 419 | return (temp1 + temp2) | (temp1 + temp2); |
| 420 | } |
| 421 | |
| 422 | /** |
| 423 | * This follows test-cases AddNegs1 and AddNegs2. |
| 424 | * The transformation tested is implemented in |
| 425 | * `InstructionSimplifierVisitor::TryMoveNegOnInputsAfterBinop`. |
| 426 | * The optimization should not happen if it moves an additional instruction in |
| 427 | * the loop. |
| 428 | */ |
| 429 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 430 | /// CHECK-START: long Main.AddNegs3(long, long) instruction_simplifier (before) |
| 431 | // -------------- Arguments and initial negation operations. |
| 432 | /// CHECK-DAG: <<Arg1:j\d+>> ParameterValue |
| 433 | /// CHECK-DAG: <<Arg2:j\d+>> ParameterValue |
| 434 | /// CHECK-DAG: <<Neg1:j\d+>> Neg [<<Arg1>>] |
| 435 | /// CHECK-DAG: <<Neg2:j\d+>> Neg [<<Arg2>>] |
| 436 | /// CHECK: Goto |
| 437 | // -------------- Loop |
| 438 | /// CHECK: SuspendCheck |
| 439 | /// CHECK: <<Add:j\d+>> Add [<<Neg1>>,<<Neg2>>] |
| 440 | /// CHECK: Goto |
Alexandre Rames | 188d431 | 2015-04-09 18:30:21 +0100 | [diff] [blame] | 441 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 442 | /// CHECK-START: long Main.AddNegs3(long, long) instruction_simplifier (after) |
| 443 | // -------------- Arguments and initial negation operations. |
| 444 | /// CHECK-DAG: <<Arg1:j\d+>> ParameterValue |
| 445 | /// CHECK-DAG: <<Arg2:j\d+>> ParameterValue |
| 446 | /// CHECK-DAG: <<Neg1:j\d+>> Neg [<<Arg1>>] |
| 447 | /// CHECK-DAG: <<Neg2:j\d+>> Neg [<<Arg2>>] |
| 448 | /// CHECK: Goto |
| 449 | // -------------- Loop |
| 450 | /// CHECK: SuspendCheck |
| 451 | /// CHECK: <<Add:j\d+>> Add [<<Neg1>>,<<Neg2>>] |
| 452 | /// CHECK-NOT: Neg |
| 453 | /// CHECK: Goto |
Alexandre Rames | 188d431 | 2015-04-09 18:30:21 +0100 | [diff] [blame] | 454 | |
| 455 | public static long AddNegs3(long arg1, long arg2) { |
| 456 | long res = 0; |
| 457 | long n_arg1 = -arg1; |
| 458 | long n_arg2 = -arg2; |
| 459 | for (long i = 0; i < 1; i++) { |
| 460 | res += n_arg1 + n_arg2 + i; |
| 461 | } |
| 462 | return res; |
| 463 | } |
| 464 | |
| 465 | /** |
| 466 | * Test the simplification of an addition with a negated argument into a |
| 467 | * subtraction. |
| 468 | * The transformation tested is implemented in `InstructionSimplifierVisitor::VisitAdd`. |
| 469 | */ |
| 470 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 471 | /// CHECK-START: long Main.AddNeg1(long, long) instruction_simplifier (before) |
| 472 | /// CHECK-DAG: <<Arg1:j\d+>> ParameterValue |
| 473 | /// CHECK-DAG: <<Arg2:j\d+>> ParameterValue |
| 474 | /// CHECK-DAG: <<Neg:j\d+>> Neg [<<Arg1>>] |
| 475 | /// CHECK-DAG: <<Add:j\d+>> Add [<<Neg>>,<<Arg2>>] |
| 476 | /// CHECK-DAG: Return [<<Add>>] |
Alexandre Rames | 188d431 | 2015-04-09 18:30:21 +0100 | [diff] [blame] | 477 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 478 | /// CHECK-START: long Main.AddNeg1(long, long) instruction_simplifier (after) |
| 479 | /// CHECK-DAG: <<Arg1:j\d+>> ParameterValue |
| 480 | /// CHECK-DAG: <<Arg2:j\d+>> ParameterValue |
| 481 | /// CHECK-DAG: <<Sub:j\d+>> Sub [<<Arg2>>,<<Arg1>>] |
| 482 | /// CHECK-DAG: Return [<<Sub>>] |
Alexandre Rames | 188d431 | 2015-04-09 18:30:21 +0100 | [diff] [blame] | 483 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 484 | /// CHECK-START: long Main.AddNeg1(long, long) instruction_simplifier (after) |
| 485 | /// CHECK-NOT: Neg |
| 486 | /// CHECK-NOT: Add |
Alexandre Rames | 188d431 | 2015-04-09 18:30:21 +0100 | [diff] [blame] | 487 | |
| 488 | public static long AddNeg1(long arg1, long arg2) { |
| 489 | return -arg1 + arg2; |
| 490 | } |
| 491 | |
| 492 | /** |
| 493 | * This is similar to the test-case AddNeg1, but the negation has two uses. |
| 494 | * The transformation tested is implemented in `InstructionSimplifierVisitor::VisitAdd`. |
| 495 | * The current code won't perform the previous optimization. The |
| 496 | * transformations do not look at other uses of their inputs. As they don't |
| 497 | * know what will happen with other uses, they do not take the risk of |
| 498 | * increasing the register pressure by creating or extending live ranges. |
| 499 | */ |
| 500 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 501 | /// CHECK-START: long Main.AddNeg2(long, long) instruction_simplifier (before) |
| 502 | /// CHECK-DAG: <<Arg1:j\d+>> ParameterValue |
| 503 | /// CHECK-DAG: <<Arg2:j\d+>> ParameterValue |
| 504 | /// CHECK-DAG: <<Neg:j\d+>> Neg [<<Arg2>>] |
| 505 | /// CHECK-DAG: <<Add1:j\d+>> Add [<<Arg1>>,<<Neg>>] |
| 506 | /// CHECK-DAG: <<Add2:j\d+>> Add [<<Arg1>>,<<Neg>>] |
| 507 | /// CHECK-DAG: <<Res:j\d+>> Or [<<Add1>>,<<Add2>>] |
| 508 | /// CHECK-DAG: Return [<<Res>>] |
Alexandre Rames | 188d431 | 2015-04-09 18:30:21 +0100 | [diff] [blame] | 509 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 510 | /// CHECK-START: long Main.AddNeg2(long, long) instruction_simplifier (after) |
| 511 | /// CHECK-DAG: <<Arg1:j\d+>> ParameterValue |
| 512 | /// CHECK-DAG: <<Arg2:j\d+>> ParameterValue |
| 513 | /// CHECK-DAG: <<Neg:j\d+>> Neg [<<Arg2>>] |
| 514 | /// CHECK-DAG: <<Add1:j\d+>> Add [<<Arg1>>,<<Neg>>] |
| 515 | /// CHECK-DAG: <<Add2:j\d+>> Add [<<Arg1>>,<<Neg>>] |
| 516 | /// CHECK-DAG: <<Res:j\d+>> Or [<<Add1>>,<<Add2>>] |
| 517 | /// CHECK-DAG: Return [<<Res>>] |
Alexandre Rames | 188d431 | 2015-04-09 18:30:21 +0100 | [diff] [blame] | 518 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 519 | /// CHECK-START: long Main.AddNeg2(long, long) instruction_simplifier (after) |
| 520 | /// CHECK-NOT: Sub |
Alexandre Rames | 188d431 | 2015-04-09 18:30:21 +0100 | [diff] [blame] | 521 | |
| 522 | public static long AddNeg2(long arg1, long arg2) { |
| 523 | long temp = -arg2; |
| 524 | return (arg1 + temp) | (arg1 + temp); |
| 525 | } |
| 526 | |
| 527 | /** |
| 528 | * Test simplification of the `-(-var)` pattern. |
| 529 | * The transformation tested is implemented in `InstructionSimplifierVisitor::VisitNeg`. |
| 530 | */ |
| 531 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 532 | /// CHECK-START: long Main.NegNeg1(long) instruction_simplifier (before) |
| 533 | /// CHECK-DAG: <<Arg:j\d+>> ParameterValue |
| 534 | /// CHECK-DAG: <<Neg1:j\d+>> Neg [<<Arg>>] |
| 535 | /// CHECK-DAG: <<Neg2:j\d+>> Neg [<<Neg1>>] |
| 536 | /// CHECK-DAG: Return [<<Neg2>>] |
Alexandre Rames | 188d431 | 2015-04-09 18:30:21 +0100 | [diff] [blame] | 537 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 538 | /// CHECK-START: long Main.NegNeg1(long) instruction_simplifier (after) |
| 539 | /// CHECK-DAG: <<Arg:j\d+>> ParameterValue |
| 540 | /// CHECK-DAG: Return [<<Arg>>] |
Alexandre Rames | 188d431 | 2015-04-09 18:30:21 +0100 | [diff] [blame] | 541 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 542 | /// CHECK-START: long Main.NegNeg1(long) instruction_simplifier (after) |
| 543 | /// CHECK-NOT: Neg |
Alexandre Rames | 188d431 | 2015-04-09 18:30:21 +0100 | [diff] [blame] | 544 | |
| 545 | public static long NegNeg1(long arg) { |
| 546 | return -(-arg); |
| 547 | } |
| 548 | |
| 549 | /** |
| 550 | * Test 'multi-step' simplification, where a first transformation yields a |
| 551 | * new simplification possibility for the current instruction. |
| 552 | * The transformations tested are implemented in `InstructionSimplifierVisitor::VisitNeg` |
| 553 | * and in `InstructionSimplifierVisitor::VisitAdd`. |
| 554 | */ |
| 555 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 556 | /// CHECK-START: int Main.NegNeg2(int) instruction_simplifier (before) |
| 557 | /// CHECK-DAG: <<Arg:i\d+>> ParameterValue |
| 558 | /// CHECK-DAG: <<Neg1:i\d+>> Neg [<<Arg>>] |
| 559 | /// CHECK-DAG: <<Neg2:i\d+>> Neg [<<Neg1>>] |
| 560 | /// CHECK-DAG: <<Add:i\d+>> Add [<<Neg1>>,<<Neg2>>] |
| 561 | /// CHECK-DAG: Return [<<Add>>] |
Alexandre Rames | 188d431 | 2015-04-09 18:30:21 +0100 | [diff] [blame] | 562 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 563 | /// CHECK-START: int Main.NegNeg2(int) instruction_simplifier (after) |
| 564 | /// CHECK-DAG: <<Arg:i\d+>> ParameterValue |
| 565 | /// CHECK-DAG: <<Sub:i\d+>> Sub [<<Arg>>,<<Arg>>] |
| 566 | /// CHECK-DAG: Return [<<Sub>>] |
Alexandre Rames | 188d431 | 2015-04-09 18:30:21 +0100 | [diff] [blame] | 567 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 568 | /// CHECK-START: int Main.NegNeg2(int) instruction_simplifier (after) |
| 569 | /// CHECK-NOT: Neg |
| 570 | /// CHECK-NOT: Add |
Alexandre Rames | 188d431 | 2015-04-09 18:30:21 +0100 | [diff] [blame] | 571 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 572 | /// CHECK-START: int Main.NegNeg2(int) constant_folding_after_inlining (after) |
| 573 | /// CHECK: <<Const0:i\d+>> IntConstant 0 |
| 574 | /// CHECK-NOT: Neg |
| 575 | /// CHECK-NOT: Add |
| 576 | /// CHECK: Return [<<Const0>>] |
Alexandre Rames | b2a5847 | 2015-04-17 14:35:18 +0100 | [diff] [blame] | 577 | |
Alexandre Rames | 188d431 | 2015-04-09 18:30:21 +0100 | [diff] [blame] | 578 | public static int NegNeg2(int arg) { |
| 579 | int temp = -arg; |
| 580 | return temp + -temp; |
| 581 | } |
| 582 | |
| 583 | /** |
| 584 | * Test another 'multi-step' simplification, where a first transformation |
| 585 | * yields a new simplification possibility for the current instruction. |
| 586 | * The transformations tested are implemented in `InstructionSimplifierVisitor::VisitNeg` |
| 587 | * and in `InstructionSimplifierVisitor::VisitSub`. |
| 588 | */ |
| 589 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 590 | /// CHECK-START: long Main.NegNeg3(long) instruction_simplifier (before) |
| 591 | /// CHECK-DAG: <<Arg:j\d+>> ParameterValue |
| 592 | /// CHECK-DAG: <<Const0:j\d+>> LongConstant 0 |
| 593 | /// CHECK-DAG: <<Neg:j\d+>> Neg [<<Arg>>] |
| 594 | /// CHECK-DAG: <<Sub:j\d+>> Sub [<<Const0>>,<<Neg>>] |
| 595 | /// CHECK-DAG: Return [<<Sub>>] |
Alexandre Rames | 188d431 | 2015-04-09 18:30:21 +0100 | [diff] [blame] | 596 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 597 | /// CHECK-START: long Main.NegNeg3(long) instruction_simplifier (after) |
| 598 | /// CHECK-DAG: <<Arg:j\d+>> ParameterValue |
| 599 | /// CHECK-DAG: Return [<<Arg>>] |
Alexandre Rames | 188d431 | 2015-04-09 18:30:21 +0100 | [diff] [blame] | 600 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 601 | /// CHECK-START: long Main.NegNeg3(long) instruction_simplifier (after) |
| 602 | /// CHECK-NOT: Neg |
| 603 | /// CHECK-NOT: Sub |
Alexandre Rames | 188d431 | 2015-04-09 18:30:21 +0100 | [diff] [blame] | 604 | |
| 605 | public static long NegNeg3(long arg) { |
| 606 | return 0 - -arg; |
| 607 | } |
| 608 | |
| 609 | /** |
| 610 | * Test that a negated subtraction is simplified to a subtraction with its |
| 611 | * arguments reversed. |
| 612 | * The transformation tested is implemented in `InstructionSimplifierVisitor::VisitNeg`. |
| 613 | */ |
| 614 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 615 | /// CHECK-START: int Main.NegSub1(int, int) instruction_simplifier (before) |
| 616 | /// CHECK-DAG: <<Arg1:i\d+>> ParameterValue |
| 617 | /// CHECK-DAG: <<Arg2:i\d+>> ParameterValue |
| 618 | /// CHECK-DAG: <<Sub:i\d+>> Sub [<<Arg1>>,<<Arg2>>] |
| 619 | /// CHECK-DAG: <<Neg:i\d+>> Neg [<<Sub>>] |
| 620 | /// CHECK-DAG: Return [<<Neg>>] |
Alexandre Rames | 188d431 | 2015-04-09 18:30:21 +0100 | [diff] [blame] | 621 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 622 | /// CHECK-START: int Main.NegSub1(int, int) instruction_simplifier (after) |
| 623 | /// CHECK-DAG: <<Arg1:i\d+>> ParameterValue |
| 624 | /// CHECK-DAG: <<Arg2:i\d+>> ParameterValue |
| 625 | /// CHECK-DAG: <<Sub:i\d+>> Sub [<<Arg2>>,<<Arg1>>] |
| 626 | /// CHECK-DAG: Return [<<Sub>>] |
Alexandre Rames | 188d431 | 2015-04-09 18:30:21 +0100 | [diff] [blame] | 627 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 628 | /// CHECK-START: int Main.NegSub1(int, int) instruction_simplifier (after) |
| 629 | /// CHECK-NOT: Neg |
Alexandre Rames | 188d431 | 2015-04-09 18:30:21 +0100 | [diff] [blame] | 630 | |
| 631 | public static int NegSub1(int arg1, int arg2) { |
| 632 | return -(arg1 - arg2); |
| 633 | } |
| 634 | |
| 635 | /** |
| 636 | * This is similar to the test-case NegSub1, but the subtraction has |
| 637 | * multiple uses. |
| 638 | * The transformation tested is implemented in `InstructionSimplifierVisitor::VisitNeg`. |
| 639 | * The current code won't perform the previous optimization. The |
| 640 | * transformations do not look at other uses of their inputs. As they don't |
| 641 | * know what will happen with other uses, they do not take the risk of |
| 642 | * increasing the register pressure by creating or extending live ranges. |
| 643 | */ |
| 644 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 645 | /// CHECK-START: int Main.NegSub2(int, int) instruction_simplifier (before) |
| 646 | /// CHECK-DAG: <<Arg1:i\d+>> ParameterValue |
| 647 | /// CHECK-DAG: <<Arg2:i\d+>> ParameterValue |
| 648 | /// CHECK-DAG: <<Sub:i\d+>> Sub [<<Arg1>>,<<Arg2>>] |
| 649 | /// CHECK-DAG: <<Neg1:i\d+>> Neg [<<Sub>>] |
| 650 | /// CHECK-DAG: <<Neg2:i\d+>> Neg [<<Sub>>] |
| 651 | /// CHECK-DAG: <<Or:i\d+>> Or [<<Neg1>>,<<Neg2>>] |
| 652 | /// CHECK-DAG: Return [<<Or>>] |
Alexandre Rames | 188d431 | 2015-04-09 18:30:21 +0100 | [diff] [blame] | 653 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 654 | /// CHECK-START: int Main.NegSub2(int, int) instruction_simplifier (after) |
| 655 | /// CHECK-DAG: <<Arg1:i\d+>> ParameterValue |
| 656 | /// CHECK-DAG: <<Arg2:i\d+>> ParameterValue |
| 657 | /// CHECK-DAG: <<Sub:i\d+>> Sub [<<Arg1>>,<<Arg2>>] |
| 658 | /// CHECK-DAG: <<Neg1:i\d+>> Neg [<<Sub>>] |
| 659 | /// CHECK-DAG: <<Neg2:i\d+>> Neg [<<Sub>>] |
| 660 | /// CHECK-DAG: <<Or:i\d+>> Or [<<Neg1>>,<<Neg2>>] |
| 661 | /// CHECK-DAG: Return [<<Or>>] |
Alexandre Rames | 188d431 | 2015-04-09 18:30:21 +0100 | [diff] [blame] | 662 | |
| 663 | public static int NegSub2(int arg1, int arg2) { |
| 664 | int temp = arg1 - arg2; |
| 665 | return -temp | -temp; |
| 666 | } |
| 667 | |
| 668 | /** |
| 669 | * Test simplification of the `~~var` pattern. |
| 670 | * The transformation tested is implemented in `InstructionSimplifierVisitor::VisitNot`. |
| 671 | */ |
| 672 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 673 | /// CHECK-START: long Main.NotNot1(long) instruction_simplifier (before) |
| 674 | /// CHECK-DAG: <<Arg:j\d+>> ParameterValue |
| 675 | /// CHECK-DAG: <<ConstF1:j\d+>> LongConstant -1 |
| 676 | /// CHECK-DAG: <<Xor1:j\d+>> Xor [<<Arg>>,<<ConstF1>>] |
| 677 | /// CHECK-DAG: <<Xor2:j\d+>> Xor [<<Xor1>>,<<ConstF1>>] |
| 678 | /// CHECK-DAG: Return [<<Xor2>>] |
Alexandre Rames | 188d431 | 2015-04-09 18:30:21 +0100 | [diff] [blame] | 679 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 680 | /// CHECK-START: long Main.NotNot1(long) instruction_simplifier (after) |
| 681 | /// CHECK-DAG: <<Arg:j\d+>> ParameterValue |
| 682 | /// CHECK-DAG: Return [<<Arg>>] |
Alexandre Rames | 188d431 | 2015-04-09 18:30:21 +0100 | [diff] [blame] | 683 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 684 | /// CHECK-START: long Main.NotNot1(long) instruction_simplifier (after) |
| 685 | /// CHECK-NOT: Xor |
Alexandre Rames | 188d431 | 2015-04-09 18:30:21 +0100 | [diff] [blame] | 686 | |
| 687 | public static long NotNot1(long arg) { |
| 688 | return ~~arg; |
| 689 | } |
| 690 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 691 | /// CHECK-START: int Main.NotNot2(int) instruction_simplifier (before) |
| 692 | /// CHECK-DAG: <<Arg:i\d+>> ParameterValue |
| 693 | /// CHECK-DAG: <<ConstF1:i\d+>> IntConstant -1 |
| 694 | /// CHECK-DAG: <<Xor1:i\d+>> Xor [<<Arg>>,<<ConstF1>>] |
| 695 | /// CHECK-DAG: <<Xor2:i\d+>> Xor [<<Xor1>>,<<ConstF1>>] |
| 696 | /// CHECK-DAG: <<Add:i\d+>> Add [<<Xor1>>,<<Xor2>>] |
| 697 | /// CHECK-DAG: Return [<<Add>>] |
Alexandre Rames | 188d431 | 2015-04-09 18:30:21 +0100 | [diff] [blame] | 698 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 699 | /// CHECK-START: int Main.NotNot2(int) instruction_simplifier (after) |
| 700 | /// CHECK-DAG: <<Arg:i\d+>> ParameterValue |
| 701 | /// CHECK-DAG: <<Not:i\d+>> Not [<<Arg>>] |
| 702 | /// CHECK-DAG: <<Add:i\d+>> Add [<<Not>>,<<Arg>>] |
| 703 | /// CHECK-DAG: Return [<<Add>>] |
Alexandre Rames | 188d431 | 2015-04-09 18:30:21 +0100 | [diff] [blame] | 704 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 705 | /// CHECK-START: int Main.NotNot2(int) instruction_simplifier (after) |
| 706 | /// CHECK-NOT: Xor |
Alexandre Rames | 188d431 | 2015-04-09 18:30:21 +0100 | [diff] [blame] | 707 | |
| 708 | public static int NotNot2(int arg) { |
| 709 | int temp = ~arg; |
| 710 | return temp + ~temp; |
| 711 | } |
| 712 | |
| 713 | /** |
| 714 | * Test the simplification of a subtraction with a negated argument. |
| 715 | * The transformation tested is implemented in `InstructionSimplifierVisitor::VisitSub`. |
| 716 | */ |
| 717 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 718 | /// CHECK-START: int Main.SubNeg1(int, int) instruction_simplifier (before) |
| 719 | /// CHECK-DAG: <<Arg1:i\d+>> ParameterValue |
| 720 | /// CHECK-DAG: <<Arg2:i\d+>> ParameterValue |
| 721 | /// CHECK-DAG: <<Neg:i\d+>> Neg [<<Arg1>>] |
| 722 | /// CHECK-DAG: <<Sub:i\d+>> Sub [<<Neg>>,<<Arg2>>] |
| 723 | /// CHECK-DAG: Return [<<Sub>>] |
Alexandre Rames | 188d431 | 2015-04-09 18:30:21 +0100 | [diff] [blame] | 724 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 725 | /// CHECK-START: int Main.SubNeg1(int, int) instruction_simplifier (after) |
| 726 | /// CHECK-DAG: <<Arg1:i\d+>> ParameterValue |
| 727 | /// CHECK-DAG: <<Arg2:i\d+>> ParameterValue |
| 728 | /// CHECK-DAG: <<Add:i\d+>> Add [<<Arg1>>,<<Arg2>>] |
| 729 | /// CHECK-DAG: <<Neg:i\d+>> Neg [<<Add>>] |
| 730 | /// CHECK-DAG: Return [<<Neg>>] |
Alexandre Rames | 188d431 | 2015-04-09 18:30:21 +0100 | [diff] [blame] | 731 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 732 | /// CHECK-START: int Main.SubNeg1(int, int) instruction_simplifier (after) |
| 733 | /// CHECK-NOT: Sub |
Alexandre Rames | 188d431 | 2015-04-09 18:30:21 +0100 | [diff] [blame] | 734 | |
| 735 | public static int SubNeg1(int arg1, int arg2) { |
| 736 | return -arg1 - arg2; |
| 737 | } |
| 738 | |
| 739 | /** |
| 740 | * This is similar to the test-case SubNeg1, but the negation has |
| 741 | * multiple uses. |
| 742 | * The transformation tested is implemented in `InstructionSimplifierVisitor::VisitSub`. |
| 743 | * The current code won't perform the previous optimization. The |
| 744 | * transformations do not look at other uses of their inputs. As they don't |
| 745 | * know what will happen with other uses, they do not take the risk of |
| 746 | * increasing the register pressure by creating or extending live ranges. |
| 747 | */ |
| 748 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 749 | /// CHECK-START: int Main.SubNeg2(int, int) instruction_simplifier (before) |
| 750 | /// CHECK-DAG: <<Arg1:i\d+>> ParameterValue |
| 751 | /// CHECK-DAG: <<Arg2:i\d+>> ParameterValue |
| 752 | /// CHECK-DAG: <<Neg:i\d+>> Neg [<<Arg1>>] |
| 753 | /// CHECK-DAG: <<Sub1:i\d+>> Sub [<<Neg>>,<<Arg2>>] |
| 754 | /// CHECK-DAG: <<Sub2:i\d+>> Sub [<<Neg>>,<<Arg2>>] |
| 755 | /// CHECK-DAG: <<Or:i\d+>> Or [<<Sub1>>,<<Sub2>>] |
| 756 | /// CHECK-DAG: Return [<<Or>>] |
Alexandre Rames | 188d431 | 2015-04-09 18:30:21 +0100 | [diff] [blame] | 757 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 758 | /// CHECK-START: int Main.SubNeg2(int, int) instruction_simplifier (after) |
| 759 | /// CHECK-DAG: <<Arg1:i\d+>> ParameterValue |
| 760 | /// CHECK-DAG: <<Arg2:i\d+>> ParameterValue |
| 761 | /// CHECK-DAG: <<Neg:i\d+>> Neg [<<Arg1>>] |
| 762 | /// CHECK-DAG: <<Sub1:i\d+>> Sub [<<Neg>>,<<Arg2>>] |
| 763 | /// CHECK-DAG: <<Sub2:i\d+>> Sub [<<Neg>>,<<Arg2>>] |
| 764 | /// CHECK-DAG: <<Or:i\d+>> Or [<<Sub1>>,<<Sub2>>] |
| 765 | /// CHECK-DAG: Return [<<Or>>] |
Alexandre Rames | 188d431 | 2015-04-09 18:30:21 +0100 | [diff] [blame] | 766 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 767 | /// CHECK-START: int Main.SubNeg2(int, int) instruction_simplifier (after) |
| 768 | /// CHECK-NOT: Add |
Alexandre Rames | 188d431 | 2015-04-09 18:30:21 +0100 | [diff] [blame] | 769 | |
| 770 | public static int SubNeg2(int arg1, int arg2) { |
| 771 | int temp = -arg1; |
| 772 | return (temp - arg2) | (temp - arg2); |
| 773 | } |
| 774 | |
| 775 | /** |
| 776 | * This follows test-cases SubNeg1 and SubNeg2. |
| 777 | * The transformation tested is implemented in `InstructionSimplifierVisitor::VisitSub`. |
| 778 | * The optimization should not happen if it moves an additional instruction in |
| 779 | * the loop. |
| 780 | */ |
| 781 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 782 | /// CHECK-START: long Main.SubNeg3(long, long) instruction_simplifier (before) |
| 783 | // -------------- Arguments and initial negation operation. |
| 784 | /// CHECK-DAG: <<Arg1:j\d+>> ParameterValue |
| 785 | /// CHECK-DAG: <<Arg2:j\d+>> ParameterValue |
| 786 | /// CHECK-DAG: <<Neg:j\d+>> Neg [<<Arg1>>] |
| 787 | /// CHECK: Goto |
| 788 | // -------------- Loop |
| 789 | /// CHECK: SuspendCheck |
| 790 | /// CHECK: <<Sub:j\d+>> Sub [<<Neg>>,<<Arg2>>] |
| 791 | /// CHECK: Goto |
Alexandre Rames | 188d431 | 2015-04-09 18:30:21 +0100 | [diff] [blame] | 792 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 793 | /// CHECK-START: long Main.SubNeg3(long, long) instruction_simplifier (after) |
| 794 | // -------------- Arguments and initial negation operation. |
| 795 | /// CHECK-DAG: <<Arg1:j\d+>> ParameterValue |
| 796 | /// CHECK-DAG: <<Arg2:j\d+>> ParameterValue |
| 797 | /// CHECK-DAG: <<Neg:j\d+>> Neg [<<Arg1>>] |
| 798 | /// CHECK-DAG: Goto |
| 799 | // -------------- Loop |
| 800 | /// CHECK: SuspendCheck |
| 801 | /// CHECK: <<Sub:j\d+>> Sub [<<Neg>>,<<Arg2>>] |
| 802 | /// CHECK-NOT: Neg |
| 803 | /// CHECK: Goto |
Alexandre Rames | 188d431 | 2015-04-09 18:30:21 +0100 | [diff] [blame] | 804 | |
| 805 | public static long SubNeg3(long arg1, long arg2) { |
| 806 | long res = 0; |
| 807 | long temp = -arg1; |
| 808 | for (long i = 0; i < 1; i++) { |
| 809 | res += temp - arg2 - i; |
| 810 | } |
| 811 | return res; |
| 812 | } |
| 813 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 814 | /// CHECK-START: int Main.EqualTrueRhs(boolean) instruction_simplifier (before) |
| 815 | /// CHECK-DAG: <<Arg:z\d+>> ParameterValue |
| 816 | /// CHECK-DAG: <<Const1:i\d+>> IntConstant 1 |
| 817 | /// CHECK-DAG: <<Cond:z\d+>> Equal [<<Arg>>,<<Const1>>] |
| 818 | /// CHECK-DAG: If [<<Cond>>] |
David Brazdil | 0d13fee | 2015-04-17 14:52:19 +0100 | [diff] [blame] | 819 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 820 | /// CHECK-START: int Main.EqualTrueRhs(boolean) instruction_simplifier (after) |
| 821 | /// CHECK-DAG: <<Arg:z\d+>> ParameterValue |
| 822 | /// CHECK-DAG: If [<<Arg>>] |
David Brazdil | 0d13fee | 2015-04-17 14:52:19 +0100 | [diff] [blame] | 823 | |
| 824 | public static int EqualTrueRhs(boolean arg) { |
| 825 | return (arg != true) ? 3 : 5; |
| 826 | } |
| 827 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 828 | /// CHECK-START: int Main.EqualTrueLhs(boolean) instruction_simplifier (before) |
| 829 | /// CHECK-DAG: <<Arg:z\d+>> ParameterValue |
| 830 | /// CHECK-DAG: <<Const1:i\d+>> IntConstant 1 |
| 831 | /// CHECK-DAG: <<Cond:z\d+>> Equal [<<Const1>>,<<Arg>>] |
| 832 | /// CHECK-DAG: If [<<Cond>>] |
David Brazdil | 0d13fee | 2015-04-17 14:52:19 +0100 | [diff] [blame] | 833 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 834 | /// CHECK-START: int Main.EqualTrueLhs(boolean) instruction_simplifier (after) |
| 835 | /// CHECK-DAG: <<Arg:z\d+>> ParameterValue |
| 836 | /// CHECK-DAG: If [<<Arg>>] |
David Brazdil | 0d13fee | 2015-04-17 14:52:19 +0100 | [diff] [blame] | 837 | |
| 838 | public static int EqualTrueLhs(boolean arg) { |
| 839 | return (true != arg) ? 3 : 5; |
| 840 | } |
| 841 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 842 | /// CHECK-START: int Main.EqualFalseRhs(boolean) instruction_simplifier (before) |
| 843 | /// CHECK-DAG: <<Arg:z\d+>> ParameterValue |
| 844 | /// CHECK-DAG: <<Const0:i\d+>> IntConstant 0 |
| 845 | /// CHECK-DAG: <<Cond:z\d+>> Equal [<<Arg>>,<<Const0>>] |
| 846 | /// CHECK-DAG: If [<<Cond>>] |
David Brazdil | 0d13fee | 2015-04-17 14:52:19 +0100 | [diff] [blame] | 847 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 848 | /// CHECK-START: int Main.EqualFalseRhs(boolean) instruction_simplifier (after) |
| 849 | /// CHECK-DAG: <<Arg:z\d+>> ParameterValue |
| 850 | /// CHECK-DAG: <<NotArg:z\d+>> BooleanNot [<<Arg>>] |
| 851 | /// CHECK-DAG: If [<<NotArg>>] |
David Brazdil | 0d13fee | 2015-04-17 14:52:19 +0100 | [diff] [blame] | 852 | |
| 853 | public static int EqualFalseRhs(boolean arg) { |
| 854 | return (arg != false) ? 3 : 5; |
| 855 | } |
| 856 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 857 | /// CHECK-START: int Main.EqualFalseLhs(boolean) instruction_simplifier (before) |
| 858 | /// CHECK-DAG: <<Arg:z\d+>> ParameterValue |
| 859 | /// CHECK-DAG: <<Const0:i\d+>> IntConstant 0 |
| 860 | /// CHECK-DAG: <<Cond:z\d+>> Equal [<<Const0>>,<<Arg>>] |
| 861 | /// CHECK-DAG: If [<<Cond>>] |
David Brazdil | 0d13fee | 2015-04-17 14:52:19 +0100 | [diff] [blame] | 862 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 863 | /// CHECK-START: int Main.EqualFalseLhs(boolean) instruction_simplifier (after) |
| 864 | /// CHECK-DAG: <<Arg:z\d+>> ParameterValue |
| 865 | /// CHECK-DAG: <<NotArg:z\d+>> BooleanNot [<<Arg>>] |
| 866 | /// CHECK-DAG: If [<<NotArg>>] |
David Brazdil | 0d13fee | 2015-04-17 14:52:19 +0100 | [diff] [blame] | 867 | |
| 868 | public static int EqualFalseLhs(boolean arg) { |
| 869 | return (false != arg) ? 3 : 5; |
| 870 | } |
| 871 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 872 | /// CHECK-START: int Main.NotEqualTrueRhs(boolean) instruction_simplifier (before) |
| 873 | /// CHECK-DAG: <<Arg:z\d+>> ParameterValue |
| 874 | /// CHECK-DAG: <<Const1:i\d+>> IntConstant 1 |
| 875 | /// CHECK-DAG: <<Cond:z\d+>> NotEqual [<<Arg>>,<<Const1>>] |
| 876 | /// CHECK-DAG: If [<<Cond>>] |
David Brazdil | 0d13fee | 2015-04-17 14:52:19 +0100 | [diff] [blame] | 877 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 878 | /// CHECK-START: int Main.NotEqualTrueRhs(boolean) instruction_simplifier (after) |
| 879 | /// CHECK-DAG: <<Arg:z\d+>> ParameterValue |
| 880 | /// CHECK-DAG: <<NotArg:z\d+>> BooleanNot [<<Arg>>] |
| 881 | /// CHECK-DAG: If [<<NotArg>>] |
David Brazdil | 0d13fee | 2015-04-17 14:52:19 +0100 | [diff] [blame] | 882 | |
| 883 | public static int NotEqualTrueRhs(boolean arg) { |
| 884 | return (arg == true) ? 3 : 5; |
| 885 | } |
| 886 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 887 | /// CHECK-START: int Main.NotEqualTrueLhs(boolean) instruction_simplifier (before) |
| 888 | /// CHECK-DAG: <<Arg:z\d+>> ParameterValue |
| 889 | /// CHECK-DAG: <<Const1:i\d+>> IntConstant 1 |
| 890 | /// CHECK-DAG: <<Cond:z\d+>> NotEqual [<<Const1>>,<<Arg>>] |
| 891 | /// CHECK-DAG: If [<<Cond>>] |
David Brazdil | 0d13fee | 2015-04-17 14:52:19 +0100 | [diff] [blame] | 892 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 893 | /// CHECK-START: int Main.NotEqualTrueLhs(boolean) instruction_simplifier (after) |
| 894 | /// CHECK-DAG: <<Arg:z\d+>> ParameterValue |
| 895 | /// CHECK-DAG: <<NotArg:z\d+>> BooleanNot [<<Arg>>] |
| 896 | /// CHECK-DAG: If [<<NotArg>>] |
David Brazdil | 0d13fee | 2015-04-17 14:52:19 +0100 | [diff] [blame] | 897 | |
| 898 | public static int NotEqualTrueLhs(boolean arg) { |
| 899 | return (true == arg) ? 3 : 5; |
| 900 | } |
| 901 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 902 | /// CHECK-START: int Main.NotEqualFalseRhs(boolean) instruction_simplifier (before) |
| 903 | /// CHECK-DAG: <<Arg:z\d+>> ParameterValue |
| 904 | /// CHECK-DAG: <<Const0:i\d+>> IntConstant 0 |
| 905 | /// CHECK-DAG: <<Cond:z\d+>> NotEqual [<<Arg>>,<<Const0>>] |
| 906 | /// CHECK-DAG: If [<<Cond>>] |
David Brazdil | 0d13fee | 2015-04-17 14:52:19 +0100 | [diff] [blame] | 907 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 908 | /// CHECK-START: int Main.NotEqualFalseRhs(boolean) instruction_simplifier (after) |
| 909 | /// CHECK-DAG: <<Arg:z\d+>> ParameterValue |
| 910 | /// CHECK-DAG: If [<<Arg>>] |
David Brazdil | 0d13fee | 2015-04-17 14:52:19 +0100 | [diff] [blame] | 911 | |
| 912 | public static int NotEqualFalseRhs(boolean arg) { |
| 913 | return (arg == false) ? 3 : 5; |
| 914 | } |
| 915 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 916 | /// CHECK-START: int Main.NotEqualFalseLhs(boolean) instruction_simplifier (before) |
| 917 | /// CHECK-DAG: <<Arg:z\d+>> ParameterValue |
| 918 | /// CHECK-DAG: <<Const0:i\d+>> IntConstant 0 |
| 919 | /// CHECK-DAG: <<Cond:z\d+>> NotEqual [<<Const0>>,<<Arg>>] |
| 920 | /// CHECK-DAG: If [<<Cond>>] |
David Brazdil | 0d13fee | 2015-04-17 14:52:19 +0100 | [diff] [blame] | 921 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 922 | /// CHECK-START: int Main.NotEqualFalseLhs(boolean) instruction_simplifier (after) |
| 923 | /// CHECK-DAG: <<Arg:z\d+>> ParameterValue |
| 924 | /// CHECK-DAG: If [<<Arg>>] |
David Brazdil | 0d13fee | 2015-04-17 14:52:19 +0100 | [diff] [blame] | 925 | |
| 926 | public static int NotEqualFalseLhs(boolean arg) { |
| 927 | return (false == arg) ? 3 : 5; |
| 928 | } |
| 929 | |
David Brazdil | 1e9ec05 | 2015-06-22 10:26:45 +0100 | [diff] [blame] | 930 | /// CHECK-START: boolean Main.EqualBoolVsIntConst(boolean) instruction_simplifier_after_bce (before) |
| 931 | /// CHECK-DAG: <<Arg:z\d+>> ParameterValue |
| 932 | /// CHECK-DAG: <<Const2:i\d+>> IntConstant 2 |
| 933 | /// CHECK-DAG: <<BoolNot:z\d+>> BooleanNot [<<Arg>>] |
| 934 | /// CHECK-DAG: <<Cond:z\d+>> Equal [<<BoolNot>>,<<Const2>>] |
| 935 | /// CHECK-DAG: Return [<<Cond>>] |
| 936 | |
| 937 | /// CHECK-START: boolean Main.EqualBoolVsIntConst(boolean) instruction_simplifier_after_bce (after) |
| 938 | /// CHECK-DAG: <<False:i\d+>> IntConstant 0 |
| 939 | /// CHECK-DAG: Return [<<False>>] |
| 940 | |
| 941 | public static boolean EqualBoolVsIntConst(boolean arg) { |
| 942 | return (arg ? 0 : 1) == 2; |
| 943 | } |
| 944 | |
| 945 | /// CHECK-START: boolean Main.NotEqualBoolVsIntConst(boolean) instruction_simplifier_after_bce (before) |
| 946 | /// CHECK-DAG: <<Arg:z\d+>> ParameterValue |
| 947 | /// CHECK-DAG: <<Const2:i\d+>> IntConstant 2 |
| 948 | /// CHECK-DAG: <<BoolNot:z\d+>> BooleanNot [<<Arg>>] |
| 949 | /// CHECK-DAG: <<Cond:z\d+>> NotEqual [<<BoolNot>>,<<Const2>>] |
| 950 | /// CHECK-DAG: Return [<<Cond>>] |
| 951 | |
| 952 | /// CHECK-START: boolean Main.NotEqualBoolVsIntConst(boolean) instruction_simplifier_after_bce (after) |
| 953 | /// CHECK-DAG: <<True:i\d+>> IntConstant 1 |
| 954 | /// CHECK-DAG: Return [<<True>>] |
| 955 | |
| 956 | public static boolean NotEqualBoolVsIntConst(boolean arg) { |
| 957 | return (arg ? 0 : 1) != 2; |
| 958 | } |
| 959 | |
David Brazdil | 0d13fee | 2015-04-17 14:52:19 +0100 | [diff] [blame] | 960 | /* |
| 961 | * Test simplification of double Boolean negation. Note that sometimes |
| 962 | * both negations can be removed but we only expect the simplifier to |
| 963 | * remove the second. |
| 964 | */ |
| 965 | |
Nicolas Geoffray | b2bdfce | 2015-06-18 15:46:47 +0100 | [diff] [blame] | 966 | /// CHECK-START: boolean Main.NotNotBool(boolean) instruction_simplifier_after_bce (before) |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 967 | /// CHECK-DAG: <<Arg:z\d+>> ParameterValue |
| 968 | /// CHECK-DAG: <<NotArg:z\d+>> BooleanNot [<<Arg>>] |
| 969 | /// CHECK-DAG: <<NotNotArg:z\d+>> BooleanNot [<<NotArg>>] |
| 970 | /// CHECK-DAG: Return [<<NotNotArg>>] |
David Brazdil | 0d13fee | 2015-04-17 14:52:19 +0100 | [diff] [blame] | 971 | |
Nicolas Geoffray | b2bdfce | 2015-06-18 15:46:47 +0100 | [diff] [blame] | 972 | /// CHECK-START: boolean Main.NotNotBool(boolean) instruction_simplifier_after_bce (after) |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 973 | /// CHECK-DAG: <<Arg:z\d+>> ParameterValue |
| 974 | /// CHECK-DAG: BooleanNot [<<Arg>>] |
| 975 | /// CHECK-DAG: Return [<<Arg>>] |
David Brazdil | 0d13fee | 2015-04-17 14:52:19 +0100 | [diff] [blame] | 976 | |
Nicolas Geoffray | b2bdfce | 2015-06-18 15:46:47 +0100 | [diff] [blame] | 977 | /// CHECK-START: boolean Main.NotNotBool(boolean) instruction_simplifier_after_bce (after) |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 978 | /// CHECK: BooleanNot |
| 979 | /// CHECK-NOT: BooleanNot |
David Brazdil | 0d13fee | 2015-04-17 14:52:19 +0100 | [diff] [blame] | 980 | |
David Brazdil | 769c9e5 | 2015-04-27 13:54:09 +0100 | [diff] [blame] | 981 | public static boolean NegateValue(boolean arg) { |
| 982 | return !arg; |
| 983 | } |
| 984 | |
David Brazdil | 0d13fee | 2015-04-17 14:52:19 +0100 | [diff] [blame] | 985 | public static boolean NotNotBool(boolean arg) { |
David Brazdil | 769c9e5 | 2015-04-27 13:54:09 +0100 | [diff] [blame] | 986 | return !(NegateValue(arg)); |
David Brazdil | 0d13fee | 2015-04-17 14:52:19 +0100 | [diff] [blame] | 987 | } |
| 988 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 989 | /// CHECK-START: float Main.Div2(float) instruction_simplifier (before) |
| 990 | /// CHECK-DAG: <<Arg:f\d+>> ParameterValue |
| 991 | /// CHECK-DAG: <<Const2:f\d+>> FloatConstant 2 |
| 992 | /// CHECK-DAG: <<Div:f\d+>> Div [<<Arg>>,<<Const2>>] |
| 993 | /// CHECK-DAG: Return [<<Div>>] |
Nicolas Geoffray | 0d22184 | 2015-04-27 08:53:46 +0000 | [diff] [blame] | 994 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 995 | /// CHECK-START: float Main.Div2(float) instruction_simplifier (after) |
| 996 | /// CHECK-DAG: <<Arg:f\d+>> ParameterValue |
| 997 | /// CHECK-DAG: <<ConstP5:f\d+>> FloatConstant 0.5 |
| 998 | /// CHECK-DAG: <<Mul:f\d+>> Mul [<<Arg>>,<<ConstP5>>] |
| 999 | /// CHECK-DAG: Return [<<Mul>>] |
Nicolas Geoffray | 0d22184 | 2015-04-27 08:53:46 +0000 | [diff] [blame] | 1000 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 1001 | /// CHECK-START: float Main.Div2(float) instruction_simplifier (after) |
| 1002 | /// CHECK-NOT: Div |
Nicolas Geoffray | 0d22184 | 2015-04-27 08:53:46 +0000 | [diff] [blame] | 1003 | |
| 1004 | public static float Div2(float arg) { |
| 1005 | return arg / 2.0f; |
| 1006 | } |
| 1007 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 1008 | /// CHECK-START: double Main.Div2(double) instruction_simplifier (before) |
| 1009 | /// CHECK-DAG: <<Arg:d\d+>> ParameterValue |
| 1010 | /// CHECK-DAG: <<Const2:d\d+>> DoubleConstant 2 |
| 1011 | /// CHECK-DAG: <<Div:d\d+>> Div [<<Arg>>,<<Const2>>] |
| 1012 | /// CHECK-DAG: Return [<<Div>>] |
Nicolas Geoffray | 0d22184 | 2015-04-27 08:53:46 +0000 | [diff] [blame] | 1013 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 1014 | /// CHECK-START: double Main.Div2(double) instruction_simplifier (after) |
| 1015 | /// CHECK-DAG: <<Arg:d\d+>> ParameterValue |
| 1016 | /// CHECK-DAG: <<ConstP5:d\d+>> DoubleConstant 0.5 |
| 1017 | /// CHECK-DAG: <<Mul:d\d+>> Mul [<<Arg>>,<<ConstP5>>] |
| 1018 | /// CHECK-DAG: Return [<<Mul>>] |
Nicolas Geoffray | 0d22184 | 2015-04-27 08:53:46 +0000 | [diff] [blame] | 1019 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 1020 | /// CHECK-START: double Main.Div2(double) instruction_simplifier (after) |
| 1021 | /// CHECK-NOT: Div |
Nicolas Geoffray | 0d22184 | 2015-04-27 08:53:46 +0000 | [diff] [blame] | 1022 | public static double Div2(double arg) { |
| 1023 | return arg / 2.0; |
| 1024 | } |
| 1025 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 1026 | /// CHECK-START: float Main.DivMP25(float) instruction_simplifier (before) |
| 1027 | /// CHECK-DAG: <<Arg:f\d+>> ParameterValue |
| 1028 | /// CHECK-DAG: <<ConstMP25:f\d+>> FloatConstant -0.25 |
| 1029 | /// CHECK-DAG: <<Div:f\d+>> Div [<<Arg>>,<<ConstMP25>>] |
| 1030 | /// CHECK-DAG: Return [<<Div>>] |
Nicolas Geoffray | 0d22184 | 2015-04-27 08:53:46 +0000 | [diff] [blame] | 1031 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 1032 | /// CHECK-START: float Main.DivMP25(float) instruction_simplifier (after) |
| 1033 | /// CHECK-DAG: <<Arg:f\d+>> ParameterValue |
| 1034 | /// CHECK-DAG: <<ConstM4:f\d+>> FloatConstant -4 |
| 1035 | /// CHECK-DAG: <<Mul:f\d+>> Mul [<<Arg>>,<<ConstM4>>] |
| 1036 | /// CHECK-DAG: Return [<<Mul>>] |
Nicolas Geoffray | 0d22184 | 2015-04-27 08:53:46 +0000 | [diff] [blame] | 1037 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 1038 | /// CHECK-START: float Main.DivMP25(float) instruction_simplifier (after) |
| 1039 | /// CHECK-NOT: Div |
Nicolas Geoffray | 0d22184 | 2015-04-27 08:53:46 +0000 | [diff] [blame] | 1040 | |
| 1041 | public static float DivMP25(float arg) { |
| 1042 | return arg / -0.25f; |
| 1043 | } |
| 1044 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 1045 | /// CHECK-START: double Main.DivMP25(double) instruction_simplifier (before) |
| 1046 | /// CHECK-DAG: <<Arg:d\d+>> ParameterValue |
| 1047 | /// CHECK-DAG: <<ConstMP25:d\d+>> DoubleConstant -0.25 |
| 1048 | /// CHECK-DAG: <<Div:d\d+>> Div [<<Arg>>,<<ConstMP25>>] |
| 1049 | /// CHECK-DAG: Return [<<Div>>] |
Nicolas Geoffray | 0d22184 | 2015-04-27 08:53:46 +0000 | [diff] [blame] | 1050 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 1051 | /// CHECK-START: double Main.DivMP25(double) instruction_simplifier (after) |
| 1052 | /// CHECK-DAG: <<Arg:d\d+>> ParameterValue |
| 1053 | /// CHECK-DAG: <<ConstM4:d\d+>> DoubleConstant -4 |
| 1054 | /// CHECK-DAG: <<Mul:d\d+>> Mul [<<Arg>>,<<ConstM4>>] |
| 1055 | /// CHECK-DAG: Return [<<Mul>>] |
Nicolas Geoffray | 0d22184 | 2015-04-27 08:53:46 +0000 | [diff] [blame] | 1056 | |
David Brazdil | a06d66a | 2015-05-28 11:14:54 +0100 | [diff] [blame] | 1057 | /// CHECK-START: double Main.DivMP25(double) instruction_simplifier (after) |
| 1058 | /// CHECK-NOT: Div |
Nicolas Geoffray | 0d22184 | 2015-04-27 08:53:46 +0000 | [diff] [blame] | 1059 | public static double DivMP25(double arg) { |
| 1060 | return arg / -0.25f; |
| 1061 | } |
| 1062 | |
Alexandre Rames | b2fd7bc | 2015-03-11 16:48:16 +0000 | [diff] [blame] | 1063 | public static void main(String[] args) { |
| 1064 | int arg = 123456; |
| 1065 | |
| 1066 | assertLongEquals(Add0(arg), arg); |
| 1067 | assertIntEquals(AndAllOnes(arg), arg); |
| 1068 | assertLongEquals(Div1(arg), arg); |
| 1069 | assertIntEquals(DivN1(arg), -arg); |
| 1070 | assertLongEquals(Mul1(arg), arg); |
| 1071 | assertIntEquals(MulN1(arg), -arg); |
| 1072 | assertLongEquals(MulPowerOfTwo128(arg), (128 * arg)); |
| 1073 | assertIntEquals(Or0(arg), arg); |
| 1074 | assertLongEquals(OrSame(arg), arg); |
| 1075 | assertIntEquals(Shl0(arg), arg); |
| 1076 | assertLongEquals(Shr0(arg), arg); |
| 1077 | assertLongEquals(Sub0(arg), arg); |
| 1078 | assertIntEquals(SubAliasNeg(arg), -arg); |
| 1079 | assertLongEquals(UShr0(arg), arg); |
| 1080 | assertIntEquals(Xor0(arg), arg); |
| 1081 | assertIntEquals(XorAllOnes(arg), ~arg); |
Alexandre Rames | 188d431 | 2015-04-09 18:30:21 +0100 | [diff] [blame] | 1082 | assertIntEquals(AddNegs1(arg, arg + 1), -(arg + arg + 1)); |
| 1083 | assertIntEquals(AddNegs2(arg, arg + 1), -(arg + arg + 1)); |
| 1084 | assertLongEquals(AddNegs3(arg, arg + 1), -(2 * arg + 1)); |
| 1085 | assertLongEquals(AddNeg1(arg, arg + 1), 1); |
| 1086 | assertLongEquals(AddNeg2(arg, arg + 1), -1); |
| 1087 | assertLongEquals(NegNeg1(arg), arg); |
| 1088 | assertIntEquals(NegNeg2(arg), 0); |
| 1089 | assertLongEquals(NegNeg3(arg), arg); |
| 1090 | assertIntEquals(NegSub1(arg, arg + 1), 1); |
| 1091 | assertIntEquals(NegSub2(arg, arg + 1), 1); |
| 1092 | assertLongEquals(NotNot1(arg), arg); |
| 1093 | assertIntEquals(NotNot2(arg), -1); |
| 1094 | assertIntEquals(SubNeg1(arg, arg + 1), -(arg + arg + 1)); |
| 1095 | assertIntEquals(SubNeg2(arg, arg + 1), -(arg + arg + 1)); |
| 1096 | assertLongEquals(SubNeg3(arg, arg + 1), -(2 * arg + 1)); |
David Brazdil | 0d13fee | 2015-04-17 14:52:19 +0100 | [diff] [blame] | 1097 | assertIntEquals(EqualTrueRhs(true), 5); |
| 1098 | assertIntEquals(EqualTrueLhs(true), 5); |
| 1099 | assertIntEquals(EqualFalseRhs(true), 3); |
| 1100 | assertIntEquals(EqualFalseLhs(true), 3); |
| 1101 | assertIntEquals(NotEqualTrueRhs(true), 3); |
| 1102 | assertIntEquals(NotEqualTrueLhs(true), 3); |
| 1103 | assertIntEquals(NotEqualFalseRhs(true), 5); |
| 1104 | assertIntEquals(NotEqualFalseLhs(true), 5); |
| 1105 | assertBooleanEquals(NotNotBool(true), true); |
| 1106 | assertBooleanEquals(NotNotBool(false), false); |
Nicolas Geoffray | 0d22184 | 2015-04-27 08:53:46 +0000 | [diff] [blame] | 1107 | assertFloatEquals(Div2(100.0f), 50.0f); |
| 1108 | assertDoubleEquals(Div2(150.0), 75.0); |
| 1109 | assertFloatEquals(DivMP25(100.0f), -400.0f); |
| 1110 | assertDoubleEquals(DivMP25(150.0), -600.0); |
Mark Mendell | ba56d06 | 2015-05-05 21:34:03 -0400 | [diff] [blame] | 1111 | assertLongEquals(Shl1(100), 200); |
Alexandre Rames | b2fd7bc | 2015-03-11 16:48:16 +0000 | [diff] [blame] | 1112 | } |
| 1113 | } |