/* * Copyright (C) 2015 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import java.lang.reflect.Method; public class Main { public static void assertBooleanEquals(boolean expected, boolean result) { if (expected != result) { throw new Error("Expected: " + expected + ", found: " + result); } } public static void assertIntEquals(int expected, int result) { if (expected != result) { throw new Error("Expected: " + expected + ", found: " + result); } } public static void assertLongEquals(long expected, long result) { if (expected != result) { throw new Error("Expected: " + expected + ", found: " + result); } } public static void assertFloatEquals(float expected, float result) { if (expected != result) { throw new Error("Expected: " + expected + ", found: " + result); } } public static void assertDoubleEquals(double expected, double result) { if (expected != result) { throw new Error("Expected: " + expected + ", found: " + result); } } public static void assertStringEquals(String expected, String result) { if (expected == null ? result != null : !expected.equals(result)) { throw new Error("Expected: " + expected + ", found: " + result); } } /** * Tiny programs exercising optimizations of arithmetic identities. */ /// CHECK-START: long Main.$noinline$Add0(long) instruction_simplifier (before) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> LongConstant 0 /// CHECK-DAG: <> Add [<>,<>] /// CHECK-DAG: Return [<>] /// CHECK-START: long Main.$noinline$Add0(long) instruction_simplifier (after) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: Return [<>] /// CHECK-START: long Main.$noinline$Add0(long) instruction_simplifier (after) /// CHECK-NOT: Add public static long $noinline$Add0(long arg) { return 0 + arg; } /// CHECK-START: int Main.$noinline$AddAddSubAddConst(int) instruction_simplifier (before) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> IntConstant 1 /// CHECK-DAG: <> IntConstant 2 /// CHECK-DAG: <> IntConstant -3 /// CHECK-DAG: <> IntConstant 4 /// CHECK-DAG: <> Add [<>,<>] /// CHECK-DAG: <> Add [<>,<>] /// CHECK-DAG: <> Add [<>,<>] /// CHECK-DAG: <> Add [<>,<>] /// CHECK-DAG: Return [<>] /// CHECK-START: int Main.$noinline$AddAddSubAddConst(int) instruction_simplifier (after) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> IntConstant 4 /// CHECK-DAG: <> Add [<>,<>] /// CHECK-DAG: Return [<>] public static int $noinline$AddAddSubAddConst(int arg) { return arg + 1 + 2 - 3 + 4; } /// CHECK-START: int Main.$noinline$AndAllOnes(int) instruction_simplifier (before) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> IntConstant -1 /// CHECK-DAG: <> And [<>,<>] /// CHECK-DAG: Return [<>] /// CHECK-START: int Main.$noinline$AndAllOnes(int) instruction_simplifier (after) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: Return [<>] /// CHECK-START: int Main.$noinline$AndAllOnes(int) instruction_simplifier (after) /// CHECK-NOT: And public static int $noinline$AndAllOnes(int arg) { return arg & -1; } /// CHECK-START: int Main.$noinline$UShr28And15(int) instruction_simplifier (before) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> IntConstant 28 /// CHECK-DAG: <> IntConstant 15 /// CHECK-DAG: <> UShr [<>,<>] /// CHECK-DAG: <> And [<>,<>] /// CHECK-DAG: Return [<>] /// CHECK-START: int Main.$noinline$UShr28And15(int) instruction_simplifier (after) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> IntConstant 28 /// CHECK-DAG: <> UShr [<>,<>] /// CHECK-DAG: Return [<>] /// CHECK-START: int Main.$noinline$UShr28And15(int) instruction_simplifier (after) /// CHECK-NOT: And public static int $noinline$UShr28And15(int arg) { return (arg >>> 28) & 15; } /// CHECK-START: long Main.$noinline$UShr60And15(long) instruction_simplifier (before) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> IntConstant 60 /// CHECK-DAG: <> LongConstant 15 /// CHECK-DAG: <> UShr [<>,<>] /// CHECK-DAG: <> And [<>,<>] /// CHECK-DAG: Return [<>] /// CHECK-START: long Main.$noinline$UShr60And15(long) instruction_simplifier (after) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> IntConstant 60 /// CHECK-DAG: <> UShr [<>,<>] /// CHECK-DAG: Return [<>] /// CHECK-START: long Main.$noinline$UShr60And15(long) instruction_simplifier (after) /// CHECK-NOT: And public static long $noinline$UShr60And15(long arg) { return (arg >>> 60) & 15; } /// CHECK-START: int Main.$noinline$UShr28And7(int) instruction_simplifier (before) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> IntConstant 28 /// CHECK-DAG: <> IntConstant 7 /// CHECK-DAG: <> UShr [<>,<>] /// CHECK-DAG: <> And [<>,<>] /// CHECK-DAG: Return [<>] /// CHECK-START: int Main.$noinline$UShr28And7(int) instruction_simplifier (after) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> IntConstant 28 /// CHECK-DAG: <> IntConstant 7 /// CHECK-DAG: <> UShr [<>,<>] /// CHECK-DAG: <> And [<>,<>] /// CHECK-DAG: Return [<>] public static int $noinline$UShr28And7(int arg) { return (arg >>> 28) & 7; } /// CHECK-START: long Main.$noinline$UShr60And7(long) instruction_simplifier (before) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> IntConstant 60 /// CHECK-DAG: <> LongConstant 7 /// CHECK-DAG: <> UShr [<>,<>] /// CHECK-DAG: <> And [<>,<>] /// CHECK-DAG: Return [<>] /// CHECK-START: long Main.$noinline$UShr60And7(long) instruction_simplifier (after) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> IntConstant 60 /// CHECK-DAG: <> LongConstant 7 /// CHECK-DAG: <> UShr [<>,<>] /// CHECK-DAG: <> And [<>,<>] /// CHECK-DAG: Return [<>] public static long $noinline$UShr60And7(long arg) { return (arg >>> 60) & 7; } /// CHECK-START: int Main.$noinline$Shr24And255(int) instruction_simplifier (before) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> IntConstant 24 /// CHECK-DAG: <> IntConstant 255 /// CHECK-DAG: <> Shr [<>,<>] /// CHECK-DAG: <> And [<>,<>] /// CHECK-DAG: Return [<>] /// CHECK-START: int Main.$noinline$Shr24And255(int) instruction_simplifier (after) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> IntConstant 24 /// CHECK-DAG: <> UShr [<>,<>] /// CHECK-DAG: Return [<>] /// CHECK-START: int Main.$noinline$Shr24And255(int) instruction_simplifier (after) /// CHECK-NOT: Shr /// CHECK-NOT: And public static int $noinline$Shr24And255(int arg) { return (arg >> 24) & 255; } /// CHECK-START: int Main.$noinline$Shr25And127(int) instruction_simplifier (before) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> IntConstant 25 /// CHECK-DAG: <> IntConstant 127 /// CHECK-DAG: <> Shr [<>,<>] /// CHECK-DAG: <> And [<>,<>] /// CHECK-DAG: Return [<>] /// CHECK-START: int Main.$noinline$Shr25And127(int) instruction_simplifier (after) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> IntConstant 25 /// CHECK-DAG: <> UShr [<>,<>] /// CHECK-DAG: Return [<>] /// CHECK-START: int Main.$noinline$Shr25And127(int) instruction_simplifier (after) /// CHECK-NOT: Shr /// CHECK-NOT: And public static int $noinline$Shr25And127(int arg) { return (arg >> 25) & 127; } /// CHECK-START: long Main.$noinline$Shr56And255(long) instruction_simplifier (before) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> IntConstant 56 /// CHECK-DAG: <> LongConstant 255 /// CHECK-DAG: <> Shr [<>,<>] /// CHECK-DAG: <> And [<>,<>] /// CHECK-DAG: Return [<>] /// CHECK-START: long Main.$noinline$Shr56And255(long) instruction_simplifier (after) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> IntConstant 56 /// CHECK-DAG: <> UShr [<>,<>] /// CHECK-DAG: Return [<>] /// CHECK-START: long Main.$noinline$Shr56And255(long) instruction_simplifier (after) /// CHECK-NOT: Shr /// CHECK-NOT: And public static long $noinline$Shr56And255(long arg) { return (arg >> 56) & 255; } /// CHECK-START: long Main.$noinline$Shr57And127(long) instruction_simplifier (before) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> IntConstant 57 /// CHECK-DAG: <> LongConstant 127 /// CHECK-DAG: <> Shr [<>,<>] /// CHECK-DAG: <> And [<>,<>] /// CHECK-DAG: Return [<>] /// CHECK-START: long Main.$noinline$Shr57And127(long) instruction_simplifier (after) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> IntConstant 57 /// CHECK-DAG: <> UShr [<>,<>] /// CHECK-DAG: Return [<>] /// CHECK-START: long Main.$noinline$Shr57And127(long) instruction_simplifier (after) /// CHECK-NOT: Shr /// CHECK-NOT: And public static long $noinline$Shr57And127(long arg) { return (arg >> 57) & 127; } /// CHECK-START: int Main.$noinline$Shr24And127(int) instruction_simplifier (before) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> IntConstant 24 /// CHECK-DAG: <> IntConstant 127 /// CHECK-DAG: <> Shr [<>,<>] /// CHECK-DAG: <> And [<>,<>] /// CHECK-DAG: Return [<>] /// CHECK-START: int Main.$noinline$Shr24And127(int) instruction_simplifier (after) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> IntConstant 24 /// CHECK-DAG: <> IntConstant 127 /// CHECK-DAG: <> Shr [<>,<>] /// CHECK-DAG: <> And [<>,<>] /// CHECK-DAG: Return [<>] public static int $noinline$Shr24And127(int arg) { return (arg >> 24) & 127; } /// CHECK-START: long Main.$noinline$Shr56And127(long) instruction_simplifier (before) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> IntConstant 56 /// CHECK-DAG: <> LongConstant 127 /// CHECK-DAG: <> Shr [<>,<>] /// CHECK-DAG: <> And [<>,<>] /// CHECK-DAG: Return [<>] /// CHECK-START: long Main.$noinline$Shr56And127(long) instruction_simplifier (after) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> IntConstant 56 /// CHECK-DAG: <> LongConstant 127 /// CHECK-DAG: <> Shr [<>,<>] /// CHECK-DAG: <> And [<>,<>] /// CHECK-DAG: Return [<>] public static long $noinline$Shr56And127(long arg) { return (arg >> 56) & 127; } /// CHECK-START: long Main.$noinline$Div1(long) instruction_simplifier (before) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> LongConstant 1 /// CHECK-DAG: <> Div [<>,<>] /// CHECK-DAG: Return [<
>] /// CHECK-START: long Main.$noinline$Div1(long) instruction_simplifier (after) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: Return [<>] /// CHECK-START: long Main.$noinline$Div1(long) instruction_simplifier (after) /// CHECK-NOT: Div public static long $noinline$Div1(long arg) { return arg / 1; } /// CHECK-START: int Main.$noinline$DivN1(int) instruction_simplifier (before) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> IntConstant -1 /// CHECK-DAG: <> Div [<>,<>] /// CHECK-DAG: Return [<
>] /// CHECK-START: int Main.$noinline$DivN1(int) instruction_simplifier (after) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> Neg [<>] /// CHECK-DAG: Return [<>] /// CHECK-START: int Main.$noinline$DivN1(int) instruction_simplifier (after) /// CHECK-NOT: Div public static int $noinline$DivN1(int arg) { return arg / -1; } /// CHECK-START: long Main.$noinline$Mul1(long) instruction_simplifier (before) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> LongConstant 1 /// CHECK-DAG: <> Mul [<>,<>] /// CHECK-DAG: Return [<>] /// CHECK-START: long Main.$noinline$Mul1(long) instruction_simplifier (after) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: Return [<>] /// CHECK-START: long Main.$noinline$Mul1(long) instruction_simplifier (after) /// CHECK-NOT: Mul public static long $noinline$Mul1(long arg) { return arg * 1; } /// CHECK-START: int Main.$noinline$MulN1(int) instruction_simplifier (before) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> IntConstant -1 /// CHECK-DAG: <> Mul [<>,<>] /// CHECK-DAG: Return [<>] /// CHECK-START: int Main.$noinline$MulN1(int) instruction_simplifier (after) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> Neg [<>] /// CHECK-DAG: Return [<>] /// CHECK-START: int Main.$noinline$MulN1(int) instruction_simplifier (after) /// CHECK-NOT: Mul public static int $noinline$MulN1(int arg) { return arg * -1; } /// CHECK-START: long Main.$noinline$MulPowerOfTwo128(long) instruction_simplifier (before) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> LongConstant 128 /// CHECK-DAG: <> Mul [<>,<>] /// CHECK-DAG: Return [<>] /// CHECK-START: long Main.$noinline$MulPowerOfTwo128(long) instruction_simplifier (after) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> IntConstant 7 /// CHECK-DAG: <> Shl [<>,<>] /// CHECK-DAG: Return [<>] /// CHECK-START: long Main.$noinline$MulPowerOfTwo128(long) instruction_simplifier (after) /// CHECK-NOT: Mul public static long $noinline$MulPowerOfTwo128(long arg) { return arg * 128; } /// CHECK-START: long Main.$noinline$MulMulMulConst(long) instruction_simplifier (before) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> LongConstant 10 /// CHECK-DAG: <> LongConstant 11 /// CHECK-DAG: <> LongConstant 12 /// CHECK-DAG: <> Mul [<>,<>] /// CHECK-DAG: <> Mul [<>,<>] /// CHECK-DAG: <> Mul [<>,<>] /// CHECK-DAG: Return [<>] /// CHECK-START: long Main.$noinline$MulMulMulConst(long) instruction_simplifier (after) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> LongConstant 1320 /// CHECK-DAG: <> Mul [<>,<>] /// CHECK-DAG: Return [<>] public static long $noinline$MulMulMulConst(long arg) { return 10 * arg * 11 * 12; } /// CHECK-START: int Main.$noinline$Or0(int) instruction_simplifier (before) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> IntConstant 0 /// CHECK-DAG: <> Or [<>,<>] /// CHECK-DAG: Return [<>] /// CHECK-START: int Main.$noinline$Or0(int) instruction_simplifier (after) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: Return [<>] /// CHECK-START: int Main.$noinline$Or0(int) instruction_simplifier (after) /// CHECK-NOT: Or public static int $noinline$Or0(int arg) { return arg | 0; } /// CHECK-START: long Main.$noinline$OrSame(long) instruction_simplifier (before) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> Or [<>,<>] /// CHECK-DAG: Return [<>] /// CHECK-START: long Main.$noinline$OrSame(long) instruction_simplifier (after) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: Return [<>] /// CHECK-START: long Main.$noinline$OrSame(long) instruction_simplifier (after) /// CHECK-NOT: Or public static long $noinline$OrSame(long arg) { return arg | arg; } /// CHECK-START: int Main.$noinline$Shl0(int) instruction_simplifier (before) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> IntConstant 0 /// CHECK-DAG: <> Shl [<>,<>] /// CHECK-DAG: Return [<>] /// CHECK-START: int Main.$noinline$Shl0(int) instruction_simplifier (after) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: Return [<>] /// CHECK-START: int Main.$noinline$Shl0(int) instruction_simplifier (after) /// CHECK-NOT: Shl public static int $noinline$Shl0(int arg) { return arg << 0; } /// CHECK-START: long Main.$noinline$Shr0(long) instruction_simplifier (before) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> IntConstant 0 /// CHECK-DAG: <> Shr [<>,<>] /// CHECK-DAG: Return [<>] /// CHECK-START: long Main.$noinline$Shr0(long) instruction_simplifier (after) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: Return [<>] /// CHECK-START: long Main.$noinline$Shr0(long) instruction_simplifier (after) /// CHECK-NOT: Shr public static long $noinline$Shr0(long arg) { return arg >> 0; } /// CHECK-START: long Main.$noinline$Shr64(long) instruction_simplifier (before) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> IntConstant 64 /// CHECK-DAG: <> Shr [<>,<>] /// CHECK-DAG: Return [<>] /// CHECK-START: long Main.$noinline$Shr64(long) instruction_simplifier (after) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: Return [<>] /// CHECK-START: long Main.$noinline$Shr64(long) instruction_simplifier (after) /// CHECK-NOT: Shr public static long $noinline$Shr64(long arg) { return arg >> 64; } /// CHECK-START: long Main.$noinline$Sub0(long) instruction_simplifier (before) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> LongConstant 0 /// CHECK-DAG: <> Sub [<>,<>] /// CHECK-DAG: Return [<>] /// CHECK-START: long Main.$noinline$Sub0(long) instruction_simplifier (after) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: Return [<>] /// CHECK-START: long Main.$noinline$Sub0(long) instruction_simplifier (after) /// CHECK-NOT: Sub public static long $noinline$Sub0(long arg) { return arg - 0; } /// CHECK-START: int Main.$noinline$SubAliasNeg(int) instruction_simplifier (before) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> IntConstant 0 /// CHECK-DAG: <> Sub [<>,<>] /// CHECK-DAG: Return [<>] /// CHECK-START: int Main.$noinline$SubAliasNeg(int) instruction_simplifier (after) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> Neg [<>] /// CHECK-DAG: Return [<>] /// CHECK-START: int Main.$noinline$SubAliasNeg(int) instruction_simplifier (after) /// CHECK-NOT: Sub public static int $noinline$SubAliasNeg(int arg) { return 0 - arg; } /// CHECK-START: int Main.$noinline$SubAddConst1(int) instruction_simplifier (before) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> IntConstant 5 /// CHECK-DAG: <> IntConstant 6 /// CHECK-DAG: <> Sub [<>,<>] /// CHECK-DAG: <> Add [<>,<>] /// CHECK-DAG: Return [<>] /// CHECK-START: int Main.$noinline$SubAddConst1(int) instruction_simplifier (after) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> IntConstant 11 /// CHECK-DAG: <> Sub [<>,<>] /// CHECK-DAG: Return [<>] public static int $noinline$SubAddConst1(int arg) { return 5 - arg + 6; } /// CHECK-START: int Main.$noinline$SubAddConst2(int) instruction_simplifier (before) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> IntConstant 14 /// CHECK-DAG: <> IntConstant 13 /// CHECK-DAG: <> Add [<>,<>] /// CHECK-DAG: <> Sub [<>,<>] /// CHECK-DAG: Return [<>] /// CHECK-START: int Main.$noinline$SubAddConst2(int) instruction_simplifier (after) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> IntConstant 1 /// CHECK-DAG: <> Sub [<>,<>] /// CHECK-DAG: Return [<>] public static int $noinline$SubAddConst2(int arg) { return 14 - (arg + 13); } /// CHECK-START: long Main.$noinline$SubSubConst(long) instruction_simplifier (before) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> LongConstant 17 /// CHECK-DAG: <> LongConstant 18 /// CHECK-DAG: <> Sub [<>,<>] /// CHECK-DAG: <> Sub [<>,<>] /// CHECK-DAG: Return [<>] /// CHECK-START: long Main.$noinline$SubSubConst(long) instruction_simplifier (after) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> LongConstant -1 /// CHECK-DAG: <> Add [<>,<>] /// CHECK-DAG: Return [<>] public static long $noinline$SubSubConst(long arg) { return 17 - (18 - arg); } /// CHECK-START: long Main.$noinline$UShr0(long) instruction_simplifier (before) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> IntConstant 0 /// CHECK-DAG: <> UShr [<>,<>] /// CHECK-DAG: Return [<>] /// CHECK-START: long Main.$noinline$UShr0(long) instruction_simplifier (after) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: Return [<>] /// CHECK-START: long Main.$noinline$UShr0(long) instruction_simplifier (after) /// CHECK-NOT: UShr public static long $noinline$UShr0(long arg) { return arg >>> 0; } /// CHECK-START: int Main.$noinline$Xor0(int) instruction_simplifier (before) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> IntConstant 0 /// CHECK-DAG: <> Xor [<>,<>] /// CHECK-DAG: Return [<>] /// CHECK-START: int Main.$noinline$Xor0(int) instruction_simplifier (after) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: Return [<>] /// CHECK-START: int Main.$noinline$Xor0(int) instruction_simplifier (after) /// CHECK-NOT: Xor public static int $noinline$Xor0(int arg) { return arg ^ 0; } /** * Test that addition or subtraction operation with both inputs negated are * optimized to use a single negation after the operation. * The transformation tested is implemented in * `InstructionSimplifierVisitor::TryMoveNegOnInputsAfterBinop`. */ /// CHECK-START: int Main.$noinline$AddNegs1(int, int) instruction_simplifier (before) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> Neg [<>] /// CHECK-DAG: <> Neg [<>] /// CHECK-DAG: <> Add [<>,<>] /// CHECK-DAG: Return [<>] /// CHECK-START: int Main.$noinline$AddNegs1(int, int) instruction_simplifier (after) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> ParameterValue /// CHECK-NOT: Neg /// CHECK-DAG: <> Add [<>,<>] /// CHECK-DAG: <> Neg [<>] /// CHECK-DAG: Return [<>] public static int $noinline$AddNegs1(int arg1, int arg2) { return -arg1 + -arg2; } /** * This is similar to the test-case AddNegs1, but the negations have * multiple uses. * The transformation tested is implemented in * `InstructionSimplifierVisitor::TryMoveNegOnInputsAfterBinop`. * The current code won't perform the previous optimization. The * transformations do not look at other uses of their inputs. As they don't * know what will happen with other uses, they do not take the risk of * increasing the register pressure by creating or extending live ranges. */ /// CHECK-START: int Main.$noinline$AddNegs2(int, int) instruction_simplifier (before) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> Neg [<>] /// CHECK-DAG: <> Neg [<>] /// CHECK-DAG: <> Add [<>,<>] /// CHECK-DAG: <> Add [<>,<>] /// CHECK-DAG: <> Or [<>,<>] /// CHECK-DAG: Return [<>] /// CHECK-START: int Main.$noinline$AddNegs2(int, int) instruction_simplifier (after) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> Neg [<>] /// CHECK-DAG: <> Neg [<>] /// CHECK-DAG: <> Add [<>,<>] /// CHECK-DAG: <> Add [<>,<>] /// CHECK-NOT: Neg /// CHECK-DAG: <> Or [<>,<>] /// CHECK-DAG: Return [<>] /// CHECK-START: int Main.$noinline$AddNegs2(int, int) GVN (after) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> Neg [<>] /// CHECK-DAG: <> Neg [<>] /// CHECK-DAG: <> Add [<>,<>] /// CHECK-DAG: <> Or [<>,<>] /// CHECK-DAG: Return [<>] public static int $noinline$AddNegs2(int arg1, int arg2) { int temp1 = -arg1; int temp2 = -arg2; return (temp1 + temp2) | (temp1 + temp2); } /** * This follows test-cases AddNegs1 and AddNegs2. * The transformation tested is implemented in * `InstructionSimplifierVisitor::TryMoveNegOnInputsAfterBinop`. * The optimization should not happen if it moves an additional instruction in * the loop. */ /// CHECK-START: long Main.$noinline$AddNegs3(long, long) instruction_simplifier (before) // -------------- Arguments and initial negation operations. /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> Neg [<>] /// CHECK-DAG: <> Neg [<>] /// CHECK: Goto // -------------- Loop /// CHECK: SuspendCheck /// CHECK: <> Add [<>,<>] /// CHECK: Goto /// CHECK-START: long Main.$noinline$AddNegs3(long, long) instruction_simplifier (after) // -------------- Arguments and initial negation operations. /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> Neg [<>] /// CHECK-DAG: <> Neg [<>] /// CHECK: Goto // -------------- Loop /// CHECK: SuspendCheck /// CHECK: <> Add [<>,<>] /// CHECK-NOT: Neg /// CHECK: Goto public static long $noinline$AddNegs3(long arg1, long arg2) { long res = 0; long n_arg1 = -arg1; long n_arg2 = -arg2; for (long i = 0; i < 1; i++) { res += n_arg1 + n_arg2 + i; } return res; } /** * Test the simplification of an addition with a negated argument into a * subtraction. * The transformation tested is implemented in `InstructionSimplifierVisitor::VisitAdd`. */ /// CHECK-START: long Main.$noinline$AddNeg1(long, long) instruction_simplifier (before) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> Neg [<>] /// CHECK-DAG: <> Add [<>,<>] /// CHECK-DAG: Return [<>] /// CHECK-START: long Main.$noinline$AddNeg1(long, long) instruction_simplifier (after) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> Sub [<>,<>] /// CHECK-DAG: Return [<>] /// CHECK-START: long Main.$noinline$AddNeg1(long, long) instruction_simplifier (after) /// CHECK-NOT: Neg /// CHECK-NOT: Add public static long $noinline$AddNeg1(long arg1, long arg2) { return -arg1 + arg2; } /** * This is similar to the test-case AddNeg1, but the negation has two uses. * The transformation tested is implemented in `InstructionSimplifierVisitor::VisitAdd`. * The current code won't perform the previous optimization. The * transformations do not look at other uses of their inputs. As they don't * know what will happen with other uses, they do not take the risk of * increasing the register pressure by creating or extending live ranges. */ /// CHECK-START: long Main.$noinline$AddNeg2(long, long) instruction_simplifier (before) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> Neg [<>] /// CHECK-DAG: <> Add [<>,<>] /// CHECK-DAG: <> Add [<>,<>] /// CHECK-DAG: <> Or [<>,<>] /// CHECK-DAG: Return [<>] /// CHECK-START: long Main.$noinline$AddNeg2(long, long) instruction_simplifier (after) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> Neg [<>] /// CHECK-DAG: <> Add [<>,<>] /// CHECK-DAG: <> Add [<>,<>] /// CHECK-DAG: <> Or [<>,<>] /// CHECK-DAG: Return [<>] /// CHECK-START: long Main.$noinline$AddNeg2(long, long) instruction_simplifier (after) /// CHECK-NOT: Sub public static long $noinline$AddNeg2(long arg1, long arg2) { long temp = -arg2; return (arg1 + temp) | (arg1 + temp); } /** * Test simplification of the `-(-var)` pattern. * The transformation tested is implemented in `InstructionSimplifierVisitor::VisitNeg`. */ /// CHECK-START: long Main.$noinline$NegNeg1(long) instruction_simplifier (before) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> Neg [<>] /// CHECK-DAG: <> Neg [<>] /// CHECK-DAG: Return [<>] /// CHECK-START: long Main.$noinline$NegNeg1(long) instruction_simplifier (after) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: Return [<>] /// CHECK-START: long Main.$noinline$NegNeg1(long) instruction_simplifier (after) /// CHECK-NOT: Neg public static long $noinline$NegNeg1(long arg) { return -(-arg); } /** * Test 'multi-step' simplification, where a first transformation yields a * new simplification possibility for the current instruction. * The transformations tested are implemented in `InstructionSimplifierVisitor::VisitNeg` * and in `InstructionSimplifierVisitor::VisitAdd`. */ /// CHECK-START: int Main.$noinline$NegNeg2(int) instruction_simplifier (before) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> Neg [<>] /// CHECK-DAG: <> Neg [<>] /// CHECK-DAG: <> Add [<>,<>] /// CHECK-DAG: Return [<>] /// CHECK-START: int Main.$noinline$NegNeg2(int) instruction_simplifier (after) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> Sub [<>,<>] /// CHECK-DAG: Return [<>] /// CHECK-START: int Main.$noinline$NegNeg2(int) instruction_simplifier (after) /// CHECK-NOT: Neg /// CHECK-NOT: Add /// CHECK-START: int Main.$noinline$NegNeg2(int) constant_folding$after_gvn (after) /// CHECK: <> IntConstant 0 /// CHECK-NOT: Neg /// CHECK-NOT: Add /// CHECK: Return [<>] public static int $noinline$NegNeg2(int arg) { int temp = -arg; return temp + -temp; } /** * Test another 'multi-step' simplification, where a first transformation * yields a new simplification possibility for the current instruction. * The transformations tested are implemented in `InstructionSimplifierVisitor::VisitNeg` * and in `InstructionSimplifierVisitor::VisitSub`. */ /// CHECK-START: long Main.$noinline$NegNeg3(long) instruction_simplifier (before) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> LongConstant 0 /// CHECK-DAG: <> Neg [<>] /// CHECK-DAG: <> Sub [<>,<>] /// CHECK-DAG: Return [<>] /// CHECK-START: long Main.$noinline$NegNeg3(long) instruction_simplifier (after) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: Return [<>] /// CHECK-START: long Main.$noinline$NegNeg3(long) instruction_simplifier (after) /// CHECK-NOT: Neg /// CHECK-NOT: Sub public static long $noinline$NegNeg3(long arg) { return 0 - -arg; } /** * Test that a negated subtraction is simplified to a subtraction with its * arguments reversed. * The transformation tested is implemented in `InstructionSimplifierVisitor::VisitNeg`. */ /// CHECK-START: int Main.$noinline$NegSub1(int, int) instruction_simplifier (before) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> Sub [<>,<>] /// CHECK-DAG: <> Neg [<>] /// CHECK-DAG: Return [<>] /// CHECK-START: int Main.$noinline$NegSub1(int, int) instruction_simplifier (after) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> Sub [<>,<>] /// CHECK-DAG: Return [<>] /// CHECK-START: int Main.$noinline$NegSub1(int, int) instruction_simplifier (after) /// CHECK-NOT: Neg public static int $noinline$NegSub1(int arg1, int arg2) { return -(arg1 - arg2); } /** * This is similar to the test-case NegSub1, but the subtraction has * multiple uses. * The transformation tested is implemented in `InstructionSimplifierVisitor::VisitNeg`. * The current code won't perform the previous optimization. The * transformations do not look at other uses of their inputs. As they don't * know what will happen with other uses, they do not take the risk of * increasing the register pressure by creating or extending live ranges. */ /// CHECK-START: int Main.$noinline$NegSub2(int, int) instruction_simplifier (before) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> Sub [<>,<>] /// CHECK-DAG: <> Neg [<>] /// CHECK-DAG: <> Neg [<>] /// CHECK-DAG: <> Or [<>,<>] /// CHECK-DAG: Return [<>] /// CHECK-START: int Main.$noinline$NegSub2(int, int) instruction_simplifier (after) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> Sub [<>,<>] /// CHECK-DAG: <> Neg [<>] /// CHECK-DAG: <> Neg [<>] /// CHECK-DAG: <> Or [<>,<>] /// CHECK-DAG: Return [<>] public static int $noinline$NegSub2(int arg1, int arg2) { int temp = arg1 - arg2; return -temp | -temp; } /** * Test the simplification of a subtraction with a negated argument. * The transformation tested is implemented in `InstructionSimplifierVisitor::VisitSub`. */ /// CHECK-START: int Main.$noinline$SubNeg1(int, int) instruction_simplifier (before) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> Neg [<>] /// CHECK-DAG: <> Sub [<>,<>] /// CHECK-DAG: Return [<>] /// CHECK-START: int Main.$noinline$SubNeg1(int, int) instruction_simplifier (after) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> Add [<>,<>] /// CHECK-DAG: <> Neg [<>] /// CHECK-DAG: Return [<>] /// CHECK-START: int Main.$noinline$SubNeg1(int, int) instruction_simplifier (after) /// CHECK-NOT: Sub public static int $noinline$SubNeg1(int arg1, int arg2) { return -arg1 - arg2; } /** * This is similar to the test-case SubNeg1, but the negation has * multiple uses. * The transformation tested is implemented in `InstructionSimplifierVisitor::VisitSub`. * The current code won't perform the previous optimization. The * transformations do not look at other uses of their inputs. As they don't * know what will happen with other uses, they do not take the risk of * increasing the register pressure by creating or extending live ranges. */ /// CHECK-START: int Main.$noinline$SubNeg2(int, int) instruction_simplifier (before) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> Neg [<>] /// CHECK-DAG: <> Sub [<>,<>] /// CHECK-DAG: <> Sub [<>,<>] /// CHECK-DAG: <> Or [<>,<>] /// CHECK-DAG: Return [<>] /// CHECK-START: int Main.$noinline$SubNeg2(int, int) instruction_simplifier (after) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> Neg [<>] /// CHECK-DAG: <> Sub [<>,<>] /// CHECK-DAG: <> Sub [<>,<>] /// CHECK-DAG: <> Or [<>,<>] /// CHECK-DAG: Return [<>] /// CHECK-START: int Main.$noinline$SubNeg2(int, int) instruction_simplifier (after) /// CHECK-NOT: Add public static int $noinline$SubNeg2(int arg1, int arg2) { int temp = -arg1; return (temp - arg2) | (temp - arg2); } /** * This follows test-cases SubNeg1 and SubNeg2. * The transformation tested is implemented in `InstructionSimplifierVisitor::VisitSub`. * The optimization should not happen if it moves an additional instruction in * the loop. */ /// CHECK-START: long Main.$noinline$SubNeg3(long, long) instruction_simplifier (before) // -------------- Arguments and initial negation operation. /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> Neg [<>] /// CHECK: Goto // -------------- Loop /// CHECK: SuspendCheck /// CHECK: <> Sub [<>,<>] /// CHECK: Goto /// CHECK-START: long Main.$noinline$SubNeg3(long, long) instruction_simplifier (after) // -------------- Arguments and initial negation operation. /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> Neg [<>] /// CHECK-DAG: Goto // -------------- Loop /// CHECK: SuspendCheck /// CHECK: <> Sub [<>,<>] /// CHECK-NOT: Neg /// CHECK: Goto public static long $noinline$SubNeg3(long arg1, long arg2) { long res = 0; long temp = -arg1; for (long i = 0; i < 1; i++) { res += temp - arg2 - i; } return res; } /// CHECK-START: boolean Main.$noinline$EqualBoolVsIntConst(boolean) dead_code_elimination$after_inlining (before) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> IntConstant 0 /// CHECK-DAG: <> IntConstant 1 /// CHECK-DAG: <> IntConstant 2 /// CHECK-DAG: If [<>] /// CHECK-DAG: <> Phi [<>,<>] /// CHECK-DAG: <> Equal [<>,<>] /// CHECK-DAG: If [<>] /// CHECK-DAG: <> Phi [<>,<>] /// CHECK-DAG: Return [<>] /// CHECK-START: boolean Main.$noinline$EqualBoolVsIntConst(boolean) dead_code_elimination$after_inlining (after) /// CHECK-DAG: <> IntConstant 1 /// CHECK-DAG: Return [<>] public static boolean $noinline$EqualBoolVsIntConst(boolean arg) { // Make calls that will be inlined to make sure the instruction simplifier // sees the simplification (dead code elimination will also try to simplify it). return (arg ? $inline$ReturnArg(0) : $inline$ReturnArg(1)) != 2; } public static int $inline$ReturnArg(int arg) { return arg; } /// CHECK-START: boolean Main.$noinline$NotEqualBoolVsIntConst(boolean) instruction_simplifier$after_inlining (before) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> IntConstant 0 /// CHECK-DAG: <> IntConstant 1 /// CHECK-DAG: <> IntConstant 2 /// CHECK-DAG: If [<>] /// CHECK-DAG: <> Phi [<>,<>] /// CHECK-DAG: <> NotEqual [<>,<>] /// CHECK-DAG: If [<>] /// CHECK-DAG: <> Phi [<>,<>] /// CHECK-DAG: Return [<>] /// CHECK-START: boolean Main.$noinline$NotEqualBoolVsIntConst(boolean) dead_code_elimination$after_inlining (after) /// CHECK-DAG: <> IntConstant 0 /// CHECK-DAG: Return [<>] public static boolean $noinline$NotEqualBoolVsIntConst(boolean arg) { // Make calls that will be inlined to make sure the instruction simplifier // sees the simplification (dead code elimination will also try to simplify it). return (arg ? $inline$ReturnArg(0) : $inline$ReturnArg(1)) == 2; } /// CHECK-START: float Main.$noinline$Div2(float) instruction_simplifier (before) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> FloatConstant 2 /// CHECK-DAG: <> Div [<>,<>] /// CHECK-DAG: Return [<
>] /// CHECK-START: float Main.$noinline$Div2(float) instruction_simplifier (after) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> FloatConstant 0.5 /// CHECK-DAG: <> Mul [<>,<>] /// CHECK-DAG: Return [<>] /// CHECK-START: float Main.$noinline$Div2(float) instruction_simplifier (after) /// CHECK-NOT: Div public static float $noinline$Div2(float arg) { return arg / 2.0f; } /// CHECK-START: double Main.$noinline$Div2(double) instruction_simplifier (before) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> DoubleConstant 2 /// CHECK-DAG: <> Div [<>,<>] /// CHECK-DAG: Return [<
>] /// CHECK-START: double Main.$noinline$Div2(double) instruction_simplifier (after) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> DoubleConstant 0.5 /// CHECK-DAG: <> Mul [<>,<>] /// CHECK-DAG: Return [<>] /// CHECK-START: double Main.$noinline$Div2(double) instruction_simplifier (after) /// CHECK-NOT: Div public static double $noinline$Div2(double arg) { return arg / 2.0; } /// CHECK-START: float Main.$noinline$DivMP25(float) instruction_simplifier (before) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> FloatConstant -0.25 /// CHECK-DAG: <> Div [<>,<>] /// CHECK-DAG: Return [<
>] /// CHECK-START: float Main.$noinline$DivMP25(float) instruction_simplifier (after) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> FloatConstant -4 /// CHECK-DAG: <> Mul [<>,<>] /// CHECK-DAG: Return [<>] /// CHECK-START: float Main.$noinline$DivMP25(float) instruction_simplifier (after) /// CHECK-NOT: Div public static float $noinline$DivMP25(float arg) { return arg / -0.25f; } /// CHECK-START: double Main.$noinline$DivMP25(double) instruction_simplifier (before) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> DoubleConstant -0.25 /// CHECK-DAG: <> Div [<>,<>] /// CHECK-DAG: Return [<
>] /// CHECK-START: double Main.$noinline$DivMP25(double) instruction_simplifier (after) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> DoubleConstant -4 /// CHECK-DAG: <> Mul [<>,<>] /// CHECK-DAG: Return [<>] /// CHECK-START: double Main.$noinline$DivMP25(double) instruction_simplifier (after) /// CHECK-NOT: Div public static double $noinline$DivMP25(double arg) { return arg / -0.25f; } /** * Test strength reduction of factors of the form (2^n + 1). */ /// CHECK-START: int Main.$noinline$mulPow2Plus1(int) instruction_simplifier (before) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> IntConstant 9 /// CHECK: Mul [<>,<>] /// CHECK-START: int Main.$noinline$mulPow2Plus1(int) instruction_simplifier (after) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> IntConstant 3 /// CHECK: <> Shl [<>,<>] /// CHECK-NEXT: Add [<>,<>] public static int $noinline$mulPow2Plus1(int arg) { return arg * 9; } /** * Test strength reduction of factors of the form (2^n - 1). */ /// CHECK-START: long Main.$noinline$mulPow2Minus1(long) instruction_simplifier (before) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> LongConstant 31 /// CHECK: Mul [<>,<>] /// CHECK-START: long Main.$noinline$mulPow2Minus1(long) instruction_simplifier (after) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> IntConstant 5 /// CHECK: <> Shl [<>,<>] /// CHECK-NEXT: Sub [<>,<>] public static long $noinline$mulPow2Minus1(long arg) { return arg * 31; } /// CHECK-START: int Main.$noinline$booleanFieldNotEqualOne() instruction_simplifier$after_inlining (before) /// CHECK-DAG: <> IntConstant 1 /// CHECK-DAG: <> IntConstant 13 /// CHECK-DAG: <> IntConstant 54 /// CHECK-DAG: <> StaticFieldGet /// CHECK-DAG: <> NotEqual [<>,<>] /// CHECK-DAG: If [<>] /// CHECK-DAG: <> Phi [<>,<>] /// CHECK-DAG: Return [<>] /// CHECK-START: int Main.$noinline$booleanFieldNotEqualOne() select_generator (after) /// CHECK-DAG: <> StaticFieldGet /// CHECK-DAG: <> IntConstant 13 /// CHECK-DAG: <> IntConstant 54 /// CHECK-DAG: <> Select [<>,<>,<>] /// CHECK-DAG: Return [<>] public static int $noinline$booleanFieldEqualZero() { return (booleanField != $inline$false()) ? 13 : 54; } /// CHECK-START: int Main.$noinline$intConditionNotEqualOne(int) instruction_simplifier$after_inlining (before) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> IntConstant 0 /// CHECK-DAG: <> IntConstant 1 /// CHECK-DAG: <> IntConstant 13 /// CHECK-DAG: <> IntConstant 42 /// CHECK-DAG: <> IntConstant 54 /// CHECK-DAG: <> LessThanOrEqual [<>,<>] /// CHECK-DAG: If [<>] /// CHECK-DAG: <> Phi [<>,<>] /// CHECK-DAG: <> NotEqual [<>,<>] /// CHECK-DAG: If [<>] /// CHECK-DAG: <> Phi [<>,<>] /// CHECK-DAG: Return [<>] /// CHECK-START: int Main.$noinline$intConditionNotEqualOne(int) select_generator (after) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> IntConstant 13 /// CHECK-DAG: <> IntConstant 42 /// CHECK-DAG: <> IntConstant 54 /// CHECK-DAG: <> LessThanOrEqual [<>,<>] /// CHECK-DAG: <> Select [<>,<>,<>] /// CHECK-DAG: Return [<>] // Note that we match `LE` from Select because there are two identical // LessThanOrEqual instructions. public static int $noinline$intConditionNotEqualOne(int i) { return ((i > 42) == $inline$true()) ? 13 : 54; } /// CHECK-START: int Main.$noinline$intConditionEqualZero(int) instruction_simplifier$after_inlining (before) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> IntConstant 0 /// CHECK-DAG: <> IntConstant 1 /// CHECK-DAG: <> IntConstant 13 /// CHECK-DAG: <> IntConstant 42 /// CHECK-DAG: <> IntConstant 54 /// CHECK-DAG: <> LessThanOrEqual [<>,<>] /// CHECK-DAG: If [<>] /// CHECK-DAG: <> Phi [<>,<>] /// CHECK-DAG: <> Equal [<>,<>] /// CHECK-DAG: If [<>] /// CHECK-DAG: <> Phi [<>,<>] /// CHECK-DAG: Return [<>] /// CHECK-START: int Main.$noinline$intConditionEqualZero(int) select_generator (after) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> IntConstant 13 /// CHECK-DAG: <> IntConstant 42 /// CHECK-DAG: <> IntConstant 54 /// CHECK-DAG: <> LessThanOrEqual [<>,<>] /// CHECK-DAG: <> Select [<>,<>,<>] /// CHECK-DAG: Return [<>] // Note that we match `LE` from Select because there are two identical // LessThanOrEqual instructions. public static int $noinline$intConditionEqualZero(int i) { return ((i > 42) != $inline$false()) ? 13 : 54; } // Test that conditions on float/double are not flipped. /// CHECK-START: int Main.$noinline$floatConditionNotEqualOne(float) builder (after) /// CHECK: LessThanOrEqual /// CHECK-START: int Main.$noinline$floatConditionNotEqualOne(float) instruction_simplifier$before_codegen (after) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> IntConstant 13 /// CHECK-DAG: <> IntConstant 54 /// CHECK-DAG: <> FloatConstant 42 /// CHECK-DAG: <> LessThanOrEqual [<>,<>] /// CHECK-DAG: <> Select [<>,<>,<>] /// CHECK-DAG: Return [<>] public static int $noinline$doubleConditionEqualZero(double d) { return ((d > 42.0) != false) ? 13 : 54; } /// CHECK-START: int Main.$noinline$intToDoubleToInt(int) instruction_simplifier (before) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> TypeConversion [<>] /// CHECK-DAG: <> TypeConversion [<>] /// CHECK-DAG: Return [<>] /// CHECK-START: int Main.$noinline$intToDoubleToInt(int) instruction_simplifier (after) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: Return [<>] /// CHECK-START: int Main.$noinline$intToDoubleToInt(int) instruction_simplifier (after) /// CHECK-NOT: TypeConversion public static int $noinline$intToDoubleToInt(int value) { // Lossless conversion followed by a conversion back. return (int) (double) value; } /// CHECK-START: java.lang.String Main.$noinline$intToDoubleToIntPrint(int) instruction_simplifier (before) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> TypeConversion [<>] /// CHECK-DAG: {{i\d+}} TypeConversion [<>] /// CHECK-START: java.lang.String Main.$noinline$intToDoubleToIntPrint(int) instruction_simplifier (after) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: {{d\d+}} TypeConversion [<>] /// CHECK-START: java.lang.String Main.$noinline$intToDoubleToIntPrint(int) instruction_simplifier (after) /// CHECK-DAG: TypeConversion /// CHECK-NOT: TypeConversion public static String $noinline$intToDoubleToIntPrint(int value) { // Lossless conversion followed by a conversion back // with another use of the intermediate result. double d = (double) value; int i = (int) d; return "d=" + d + ", i=" + i; } /// CHECK-START: int Main.$noinline$byteToDoubleToInt(byte) instruction_simplifier (before) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> TypeConversion [<>] /// CHECK-DAG: <> TypeConversion [<>] /// CHECK-DAG: Return [<>] /// CHECK-START: int Main.$noinline$byteToDoubleToInt(byte) instruction_simplifier (after) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: Return [<>] /// CHECK-START: int Main.$noinline$byteToDoubleToInt(byte) instruction_simplifier (after) /// CHECK-NOT: TypeConversion public static int $noinline$byteToDoubleToInt(byte value) { // Lossless conversion followed by another conversion, use implicit conversion. return (int) (double) value; } /// CHECK-START: int Main.$noinline$floatToDoubleToInt(float) instruction_simplifier (before) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> TypeConversion [<>] /// CHECK-DAG: <> TypeConversion [<>] /// CHECK-DAG: Return [<>] /// CHECK-START: int Main.$noinline$floatToDoubleToInt(float) instruction_simplifier (after) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> TypeConversion [<>] /// CHECK-DAG: Return [<>] /// CHECK-START: int Main.$noinline$floatToDoubleToInt(float) instruction_simplifier (after) /// CHECK-DAG: TypeConversion /// CHECK-NOT: TypeConversion public static int $noinline$floatToDoubleToInt(float value) { // Lossless conversion followed by another conversion. return (int) (double) value; } /// CHECK-START: java.lang.String Main.$noinline$floatToDoubleToIntPrint(float) instruction_simplifier (before) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> TypeConversion [<>] /// CHECK-DAG: {{i\d+}} TypeConversion [<>] /// CHECK-START: java.lang.String Main.$noinline$floatToDoubleToIntPrint(float) instruction_simplifier (after) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> TypeConversion [<>] /// CHECK-DAG: {{i\d+}} TypeConversion [<>] public static String $noinline$floatToDoubleToIntPrint(float value) { // Lossless conversion followed by another conversion with // an extra use of the intermediate result. double d = (double) value; int i = (int) d; return "d=" + d + ", i=" + i; } /// CHECK-START: short Main.$noinline$byteToDoubleToShort(byte) instruction_simplifier (before) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> TypeConversion [<>] /// CHECK-DAG: <> TypeConversion [<>] /// CHECK-DAG: <> TypeConversion [<>] /// CHECK-DAG: Return [<>] /// CHECK-START: short Main.$noinline$byteToDoubleToShort(byte) instruction_simplifier (after) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: Return [<>] /// CHECK-START: short Main.$noinline$byteToDoubleToShort(byte) instruction_simplifier (after) /// CHECK-NOT: TypeConversion public static short $noinline$byteToDoubleToShort(byte value) { // Originally, this is byte->double->int->short. The first conversion is lossless, // so we merge this with the second one to byte->int which we omit as it's an implicit // conversion. Then we eliminate the resulting byte->short as an implicit conversion. return (short) (double) value; } /// CHECK-START: short Main.$noinline$charToDoubleToShort(char) instruction_simplifier (before) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> TypeConversion [<>] /// CHECK-DAG: <> TypeConversion [<>] /// CHECK-DAG: <> TypeConversion [<>] /// CHECK-DAG: Return [<>] /// CHECK-START: short Main.$noinline$charToDoubleToShort(char) instruction_simplifier (after) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> TypeConversion [<>] /// CHECK-DAG: Return [<>] /// CHECK-START: short Main.$noinline$charToDoubleToShort(char) instruction_simplifier (after) /// CHECK-DAG: TypeConversion /// CHECK-NOT: TypeConversion public static short $noinline$charToDoubleToShort(char value) { // Originally, this is char->double->int->short. The first conversion is lossless, // so we merge this with the second one to char->int which we omit as it's an implicit // conversion. Then we are left with the resulting char->short conversion. return (short) (double) value; } /// CHECK-START: short Main.$noinline$floatToIntToShort(float) instruction_simplifier (before) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> TypeConversion [<>] /// CHECK-DAG: <> TypeConversion [<>] /// CHECK-DAG: Return [<>] /// CHECK-START: short Main.$noinline$floatToIntToShort(float) instruction_simplifier (after) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> TypeConversion [<>] /// CHECK-DAG: <> TypeConversion [<>] /// CHECK-DAG: Return [<>] public static short $noinline$floatToIntToShort(float value) { // Lossy FP to integral conversion followed by another conversion: no simplification. return (short) value; } /// CHECK-START: int Main.$noinline$intToFloatToInt(int) instruction_simplifier (before) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> TypeConversion [<>] /// CHECK-DAG: <> TypeConversion [<>] /// CHECK-DAG: Return [<>] /// CHECK-START: int Main.$noinline$intToFloatToInt(int) instruction_simplifier (after) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> TypeConversion [<>] /// CHECK-DAG: <> TypeConversion [<>] /// CHECK-DAG: Return [<>] public static int $noinline$intToFloatToInt(int value) { // Lossy integral to FP conversion followed another conversion: no simplification. return (int) (float) value; } /// CHECK-START: double Main.$noinline$longToIntToDouble(long) instruction_simplifier (before) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> TypeConversion [<>] /// CHECK-DAG: <> TypeConversion [<>] /// CHECK-DAG: Return [<>] /// CHECK-START: double Main.$noinline$longToIntToDouble(long) instruction_simplifier (after) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> TypeConversion [<>] /// CHECK-DAG: <> TypeConversion [<>] /// CHECK-DAG: Return [<>] public static double $noinline$longToIntToDouble(long value) { // Lossy long-to-int conversion followed an integral to FP conversion: no simplification. return (double) (int) value; } /// CHECK-START: long Main.$noinline$longToIntToLong(long) instruction_simplifier (before) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> TypeConversion [<>] /// CHECK-DAG: <> TypeConversion [<>] /// CHECK-DAG: Return [<>] /// CHECK-START: long Main.$noinline$longToIntToLong(long) instruction_simplifier (after) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> TypeConversion [<>] /// CHECK-DAG: <> TypeConversion [<>] /// CHECK-DAG: Return [<>] public static long $noinline$longToIntToLong(long value) { // Lossy long-to-int conversion followed an int-to-long conversion: no simplification. return (long) (int) value; } /// CHECK-START: short Main.$noinline$shortToCharToShort(short) instruction_simplifier (before) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> TypeConversion [<>] /// CHECK-DAG: <> TypeConversion [<>] /// CHECK-DAG: Return [<>] /// CHECK-START: short Main.$noinline$shortToCharToShort(short) instruction_simplifier (after) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: Return [<>] public static short $noinline$shortToCharToShort(short value) { // Integral conversion followed by non-widening integral conversion to original type. return (short) (char) value; } /// CHECK-START: int Main.$noinline$shortToLongToInt(short) instruction_simplifier (before) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> TypeConversion [<>] /// CHECK-DAG: <> TypeConversion [<>] /// CHECK-DAG: Return [<>] /// CHECK-START: int Main.$noinline$shortToLongToInt(short) instruction_simplifier (after) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: Return [<>] public static int $noinline$shortToLongToInt(short value) { // Integral conversion followed by non-widening integral conversion, use implicit conversion. return (int) (long) value; } /// CHECK-START: byte Main.$noinline$shortToCharToByte(short) instruction_simplifier (before) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> TypeConversion [<>] /// CHECK-DAG: <> TypeConversion [<>] /// CHECK-DAG: Return [<>] /// CHECK-START: byte Main.$noinline$shortToCharToByte(short) instruction_simplifier (after) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> TypeConversion [<>] /// CHECK-DAG: Return [<>] public static byte $noinline$shortToCharToByte(short value) { // Integral conversion followed by non-widening integral conversion losing bits // from the original type. Simplify to use only one conversion. return (byte) (char) value; } /// CHECK-START: java.lang.String Main.$noinline$shortToCharToBytePrint(short) instruction_simplifier (before) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> TypeConversion [<>] /// CHECK-DAG: {{b\d+}} TypeConversion [<>] /// CHECK-START: java.lang.String Main.$noinline$shortToCharToBytePrint(short) instruction_simplifier (after) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> TypeConversion [<>] /// CHECK-DAG: {{b\d+}} TypeConversion [<>] public static String $noinline$shortToCharToBytePrint(short value) { // Integral conversion followed by non-widening integral conversion losing bits // from the original type with an extra use of the intermediate result. char c = (char) value; byte b = (byte) c; return "c=" + ((int) c) + ", b=" + ((int) b); // implicit conversions. } /// CHECK-START: long Main.$noinline$intAndSmallLongConstant(int) instruction_simplifier (before) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> LongConstant -12345678 /// CHECK-DAG: <> TypeConversion [<>] /// CHECK-DAG: <> And [<>,<>] /// CHECK-DAG: Return [<>] /// CHECK-START: long Main.$noinline$intAndSmallLongConstant(int) instruction_simplifier (after) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> IntConstant -12345678 /// CHECK-DAG: <> And [<>,<>] /// CHECK-DAG: <> TypeConversion [<>] /// CHECK-DAG: Return [<>] public static long $noinline$intAndSmallLongConstant(int value) { return value & -12345678L; // Shall be simplified (constant is 32-bit). } /// CHECK-START: long Main.$noinline$intAndLargeLongConstant(int) instruction_simplifier (before) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> LongConstant 9876543210 /// CHECK-DAG: <> TypeConversion [<>] /// CHECK-DAG: <> And [<>,<>] /// CHECK-DAG: Return [<>] /// CHECK-START: long Main.$noinline$intAndLargeLongConstant(int) instruction_simplifier (after) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> LongConstant 9876543210 /// CHECK-DAG: <> TypeConversion [<>] /// CHECK-DAG: <> And [<>,<>] /// CHECK-DAG: Return [<>] public static long $noinline$intAndLargeLongConstant(int value) { return value & 9876543210L; // Shall not be simplified (constant is not 32-bit). } /// CHECK-START: long Main.$noinline$intShr28And15L(int) instruction_simplifier (before) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> IntConstant 28 /// CHECK-DAG: <> LongConstant 15 /// CHECK-DAG: <> Shr [<>,<>] /// CHECK-DAG: <> TypeConversion [<>] /// CHECK-DAG: <> And [<>,<>] /// CHECK-DAG: Return [<>] /// CHECK-START: long Main.$noinline$intShr28And15L(int) instruction_simplifier (after) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> IntConstant 28 /// CHECK-DAG: <> UShr [<>,<>] /// CHECK-DAG: <> TypeConversion [<>] /// CHECK-DAG: Return [<>] public static long $noinline$intShr28And15L(int value) { return (value >> 28) & 15L; } /// CHECK-START: byte Main.$noinline$longAnd0xffToByte(long) instruction_simplifier (before) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> LongConstant 255 /// CHECK-DAG: <> And [<>,<>] /// CHECK-DAG: <> TypeConversion [<>] /// CHECK-DAG: <> TypeConversion [<>] /// CHECK-DAG: Return [<>] /// CHECK-START: byte Main.$noinline$longAnd0xffToByte(long) instruction_simplifier (after) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> TypeConversion [<>] /// CHECK-DAG: Return [<>] /// CHECK-START: byte Main.$noinline$longAnd0xffToByte(long) instruction_simplifier (after) /// CHECK-NOT: And public static byte $noinline$longAnd0xffToByte(long value) { return (byte) (value & 0xff); } /// CHECK-START: char Main.$noinline$intAnd0x1ffffToChar(int) instruction_simplifier (before) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> IntConstant 131071 /// CHECK-DAG: <> And [<>,<>] /// CHECK-DAG: <> TypeConversion [<>] /// CHECK-DAG: Return [<>] /// CHECK-START: char Main.$noinline$intAnd0x1ffffToChar(int) instruction_simplifier (after) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> TypeConversion [<>] /// CHECK-DAG: Return [<>] /// CHECK-START: char Main.$noinline$intAnd0x1ffffToChar(int) instruction_simplifier (after) /// CHECK-NOT: And public static char $noinline$intAnd0x1ffffToChar(int value) { // Keeping all significant bits and one more. return (char) (value & 0x1ffff); } /// CHECK-START: short Main.$noinline$intAnd0x17fffToShort(int) instruction_simplifier (before) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> IntConstant 98303 /// CHECK-DAG: <> And [<>,<>] /// CHECK-DAG: <> TypeConversion [<>] /// CHECK-DAG: Return [<>] /// CHECK-START: short Main.$noinline$intAnd0x17fffToShort(int) instruction_simplifier (after) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> IntConstant 98303 /// CHECK-DAG: <> And [<>,<>] /// CHECK-DAG: <> TypeConversion [<>] /// CHECK-DAG: Return [<>] public static short $noinline$intAnd0x17fffToShort(int value) { // No simplification: clearing a significant bit. return (short) (value & 0x17fff); } /// CHECK-START: double Main.$noinline$shortAnd0xffffToShortToDouble(short) instruction_simplifier (before) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> IntConstant 65535 /// CHECK-DAG: <> And [<>,<>] /// CHECK-DAG: <> TypeConversion [<>] /// CHECK-DAG: <> TypeConversion [<>] /// CHECK-DAG: Return [<>] /// CHECK-START: double Main.$noinline$shortAnd0xffffToShortToDouble(short) instruction_simplifier (after) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> TypeConversion [<>] /// CHECK-DAG: Return [<>] public static double $noinline$shortAnd0xffffToShortToDouble(short value) { short same = (short) (value & 0xffff); return (double) same; } /// CHECK-START: int Main.$noinline$intReverseCondition(int) instruction_simplifier (before) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> IntConstant 42 /// CHECK-DAG: <> LessThanOrEqual [<>,<>] /// CHECK-START: int Main.$noinline$intReverseCondition(int) instruction_simplifier (after) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> IntConstant 42 /// CHECK-DAG: <> GreaterThanOrEqual [<>,<>] public static int $noinline$intReverseCondition(int i) { return (42 > i) ? 13 : 54; } /// CHECK-START: int Main.$noinline$intReverseConditionNaN(int) instruction_simplifier (before) /// CHECK-DAG: <> DoubleConstant 42 /// CHECK-DAG: <> InvokeStaticOrDirect /// CHECK-DAG: <> Compare [<>,<>] /// CHECK-START: int Main.$noinline$intReverseConditionNaN(int) instruction_simplifier (after) /// CHECK-DAG: <> DoubleConstant 42 /// CHECK-DAG: <> InvokeStaticOrDirect /// CHECK-DAG: <> Equal [<>,<>] public static int $noinline$intReverseConditionNaN(int i) { return (42 != Math.sqrt(i)) ? 13 : 54; } public static int $noinline$runSmaliTest(String name, boolean input) { try { Class c = Class.forName("SmaliTests"); Method m = c.getMethod(name, boolean.class); return (Integer) m.invoke(null, input); } catch (Exception ex) { throw new Error(ex); } } public static boolean $noinline$runSmaliTest2Boolean(String name, boolean input) { try { Class c = Class.forName("SmaliTests2"); Method m = c.getMethod(name, boolean.class); return (Boolean) m.invoke(null, input); } catch (Exception ex) { throw new Error(ex); } } public static int $noinline$runSmaliTestInt(String postfix, String name, int arg) { try { Class c = Class.forName("SmaliTests" + postfix); Method m = c.getMethod(name, int.class); return (Integer) m.invoke(null, arg); } catch (Exception ex) { throw new Error(ex); } } public static int $noinline$runSmaliTestInt(String name, int arg) { return $noinline$runSmaliTestInt("", name, arg); } public static long $noinline$runSmaliTest2Long(String name, long arg) { try { Class c = Class.forName("SmaliTests2"); Method m = c.getMethod(name, long.class); return (Long) m.invoke(null, arg); } catch (Exception ex) { throw new Error(ex); } } /// CHECK-START: int Main.$noinline$intUnnecessaryShiftMasking(int, int) instruction_simplifier (before) /// CHECK: <> ParameterValue /// CHECK: <> ParameterValue /// CHECK-DAG: <> IntConstant 31 /// CHECK-DAG: <> And [<>,<>] /// CHECK-DAG: <> Shl [<>,<>] /// CHECK-DAG: Return [<>] /// CHECK-START: int Main.$noinline$intUnnecessaryShiftMasking(int, int) instruction_simplifier (after) /// CHECK: <> ParameterValue /// CHECK: <> ParameterValue /// CHECK-DAG: <> Shl [<>,<>] /// CHECK-DAG: Return [<>] public static int $noinline$intUnnecessaryShiftMasking(int value, int shift) { return value << (shift & 31); } /// CHECK-START: long Main.$noinline$longUnnecessaryShiftMasking(long, int) instruction_simplifier (before) /// CHECK: <> ParameterValue /// CHECK: <> ParameterValue /// CHECK-DAG: <> IntConstant 63 /// CHECK-DAG: <> And [<>,<>] /// CHECK-DAG: <> Shr [<>,<>] /// CHECK-DAG: Return [<>] /// CHECK-START: long Main.$noinline$longUnnecessaryShiftMasking(long, int) instruction_simplifier (after) /// CHECK: <> ParameterValue /// CHECK: <> ParameterValue /// CHECK-DAG: <> Shr [<>,<>] /// CHECK-DAG: Return [<>] public static long $noinline$longUnnecessaryShiftMasking(long value, int shift) { return value >> (shift & 63); } /// CHECK-START: int Main.$noinline$intUnnecessaryWiderShiftMasking(int, int) instruction_simplifier (before) /// CHECK: <> ParameterValue /// CHECK: <> ParameterValue /// CHECK-DAG: <> IntConstant 255 /// CHECK-DAG: <> And [<>,<>] /// CHECK-DAG: <> UShr [<>,<>] /// CHECK-DAG: Return [<>] /// CHECK-START: int Main.$noinline$intUnnecessaryWiderShiftMasking(int, int) instruction_simplifier (after) /// CHECK: <> ParameterValue /// CHECK: <> ParameterValue /// CHECK-DAG: <> UShr [<>,<>] /// CHECK-DAG: Return [<>] public static int $noinline$intUnnecessaryWiderShiftMasking(int value, int shift) { return value >>> (shift & 0xff); } /// CHECK-START: long Main.$noinline$longSmallerShiftMasking(long, int) instruction_simplifier (before) /// CHECK: <> ParameterValue /// CHECK: <> ParameterValue /// CHECK-DAG: <> IntConstant 3 /// CHECK-DAG: <> And [<>,<>] /// CHECK-DAG: <> Shl [<>,<>] /// CHECK-DAG: Return [<>] /// CHECK-START: long Main.$noinline$longSmallerShiftMasking(long, int) instruction_simplifier (after) /// CHECK: <> ParameterValue /// CHECK: <> ParameterValue /// CHECK-DAG: <> IntConstant 3 /// CHECK-DAG: <> And [<>,<>] /// CHECK-DAG: <> Shl [<>,<>] /// CHECK-DAG: Return [<>] public static long $noinline$longSmallerShiftMasking(long value, int shift) { return value << (shift & 3); } /// CHECK-START: int Main.$noinline$otherUseOfUnnecessaryShiftMasking(int, int) instruction_simplifier (before) /// CHECK: <> ParameterValue /// CHECK: <> ParameterValue /// CHECK-DAG: <> IntConstant 31 /// CHECK-DAG: <> And [<>,<>] /// CHECK-DAG: <> Shr [<>,<>] /// CHECK-DAG: <> Add [<>,<>] /// CHECK-DAG: Return [<>] /// CHECK-START: int Main.$noinline$otherUseOfUnnecessaryShiftMasking(int, int) instruction_simplifier (after) /// CHECK: <> ParameterValue /// CHECK: <> ParameterValue /// CHECK-DAG: <> IntConstant 31 /// CHECK-DAG: <> And [<>,<>] /// CHECK-DAG: <> Shr [<>,<>] /// CHECK-DAG: <> Add [<>,<>] /// CHECK-DAG: Return [<>] public static int $noinline$otherUseOfUnnecessaryShiftMasking(int value, int shift) { int temp = shift & 31; return (value >> temp) + temp; } /// CHECK-START: int Main.$noinline$intUnnecessaryShiftModifications(int, int) instruction_simplifier (before) /// CHECK: <> ParameterValue /// CHECK: <> ParameterValue /// CHECK-DAG: <> IntConstant 32 /// CHECK-DAG: <> IntConstant 64 /// CHECK-DAG: <> IntConstant 96 /// CHECK-DAG: <> IntConstant 128 /// CHECK-DAG: <> Or [<>,<>] /// CHECK-DAG: <> Xor [<>,<>] /// CHECK-DAG: <> Add [<>,<>] /// CHECK-DAG: <> Sub [<>,<>] /// CHECK-DAG: <> TypeConversion [<>] /// CHECK-DAG: Shl [<>,<>] /// CHECK-DAG: Shr [<>,<>] /// CHECK-DAG: UShr [<>,<>] /// CHECK-DAG: Shl [<>,<>] /// CHECK-DAG: Shr [<>,<>] /// CHECK-START: int Main.$noinline$intUnnecessaryShiftModifications(int, int) instruction_simplifier (after) /// CHECK: <> ParameterValue /// CHECK: <> ParameterValue /// CHECK-DAG: Shl [<>,<>] /// CHECK-DAG: Shr [<>,<>] /// CHECK-DAG: UShr [<>,<>] /// CHECK-DAG: Shl [<>,<>] /// CHECK-DAG: Shr [<>,<>] public static int $noinline$intUnnecessaryShiftModifications(int value, int shift) { int c128 = 128; return (value << (shift | 32)) + (value >> (shift ^ 64)) + (value >>> (shift + 96)) + (value << (shift - c128)) + // Needs a named constant to generate Sub. (value >> ((byte) shift)); } /// CHECK-START: int Main.$noinline$intNecessaryShiftModifications(int, int) instruction_simplifier (before) /// CHECK: <> ParameterValue /// CHECK: <> ParameterValue /// CHECK-DAG: <> IntConstant 33 /// CHECK-DAG: <> IntConstant 65 /// CHECK-DAG: <> IntConstant 97 /// CHECK-DAG: <> IntConstant 129 /// CHECK-DAG: <> Or [<>,<>] /// CHECK-DAG: <> Xor [<>,<>] /// CHECK-DAG: <> Add [<>,<>] /// CHECK-DAG: <> Sub [<>,<>] /// CHECK-DAG: Shl [<>,<>] /// CHECK-DAG: Shr [<>,<>] /// CHECK-DAG: UShr [<>,<>] /// CHECK-DAG: Shl [<>,<>] /// CHECK-START: int Main.$noinline$intNecessaryShiftModifications(int, int) instruction_simplifier (after) /// CHECK: <> ParameterValue /// CHECK: <> ParameterValue /// CHECK-DAG: <> IntConstant 33 /// CHECK-DAG: <> IntConstant 65 /// CHECK-DAG: <> IntConstant 97 /// CHECK-DAG: <> IntConstant 129 /// CHECK-DAG: <> Or [<>,<>] /// CHECK-DAG: <> Xor [<>,<>] /// CHECK-DAG: <> Add [<>,<>] /// CHECK-DAG: <> Sub [<>,<>] /// CHECK-DAG: Shl [<>,<>] /// CHECK-DAG: Shr [<>,<>] /// CHECK-DAG: UShr [<>,<>] /// CHECK-DAG: Shl [<>,<>] public static int $noinline$intNecessaryShiftModifications(int value, int shift) { int c129 = 129; return (value << (shift | 33)) + (value >> (shift ^ 65)) + (value >>> (shift + 97)) + (value << (shift - c129)); // Needs a named constant to generate Sub. } /// CHECK-START: int Main.$noinline$intAddSubSimplifyArg1(int, int) instruction_simplifier (before) /// CHECK: <> ParameterValue /// CHECK: <> ParameterValue /// CHECK-DAG: <> Add [<>,<>] /// CHECK-DAG: <> Sub [<>,<>] /// CHECK-DAG: Return [<>] /// CHECK-START: int Main.$noinline$intAddSubSimplifyArg1(int, int) instruction_simplifier (after) /// CHECK: <> ParameterValue /// CHECK: <> ParameterValue /// CHECK-DAG: <> Add [<>,<>] /// CHECK-DAG: Return [<>] public static int $noinline$intAddSubSimplifyArg1(int x, int y) { int sum = x + y; return sum - x; } /// CHECK-START: int Main.$noinline$intAddSubSimplifyArg2(int, int) instruction_simplifier (before) /// CHECK: <> ParameterValue /// CHECK: <> ParameterValue /// CHECK-DAG: <> Add [<>,<>] /// CHECK-DAG: <> Sub [<>,<>] /// CHECK-DAG: Return [<>] /// CHECK-START: int Main.$noinline$intAddSubSimplifyArg2(int, int) instruction_simplifier (after) /// CHECK: <> ParameterValue /// CHECK: <> ParameterValue /// CHECK-DAG: <> Add [<>,<>] /// CHECK-DAG: Return [<>] public static int $noinline$intAddSubSimplifyArg2(int x, int y) { int sum = x + y; return sum - y; } /// CHECK-START: int Main.$noinline$intSubAddSimplifyLeft(int, int) instruction_simplifier (before) /// CHECK: <> ParameterValue /// CHECK: <> ParameterValue /// CHECK-DAG: <> Sub [<>,<>] /// CHECK-DAG: <> Add [<>,<>] /// CHECK-DAG: Return [<>] /// CHECK-START: int Main.$noinline$intSubAddSimplifyLeft(int, int) instruction_simplifier (after) /// CHECK: <> ParameterValue /// CHECK: <> ParameterValue /// CHECK-DAG: <> Sub [<>,<>] /// CHECK-DAG: Return [<>] public static int $noinline$intSubAddSimplifyLeft(int x, int y) { int sub = x - y; return sub + y; } /// CHECK-START: int Main.$noinline$intSubAddSimplifyRight(int, int) instruction_simplifier (before) /// CHECK: <> ParameterValue /// CHECK: <> ParameterValue /// CHECK-DAG: <> Sub [<>,<>] /// CHECK-DAG: <> Add [<>,<>] /// CHECK-DAG: Return [<>] /// CHECK-START: int Main.$noinline$intSubAddSimplifyRight(int, int) instruction_simplifier (after) /// CHECK: <> ParameterValue /// CHECK: <> ParameterValue /// CHECK-DAG: <> Sub [<>,<>] /// CHECK-DAG: Return [<>] public static int $noinline$intSubAddSimplifyRight(int x, int y) { int sub = x - y; return y + sub; } /// CHECK-START: float Main.$noinline$floatAddSubSimplifyArg1(float, float) instruction_simplifier (before) /// CHECK: <> ParameterValue /// CHECK: <> ParameterValue /// CHECK-DAG: <> Add [<>,<>] /// CHECK-DAG: <> Sub [<>,<>] /// CHECK-DAG: Return [<>] /// CHECK-START: float Main.$noinline$floatAddSubSimplifyArg1(float, float) instruction_simplifier (after) /// CHECK: <> ParameterValue /// CHECK: <> ParameterValue /// CHECK-DAG: <> Add [<>,<>] /// CHECK-DAG: <> Sub [<>,<>] /// CHECK-DAG: Return [<>] public static float $noinline$floatAddSubSimplifyArg1(float x, float y) { float sum = x + y; return sum - x; } /// CHECK-START: float Main.$noinline$floatAddSubSimplifyArg2(float, float) instruction_simplifier (before) /// CHECK: <> ParameterValue /// CHECK: <> ParameterValue /// CHECK-DAG: <> Add [<>,<>] /// CHECK-DAG: <> Sub [<>,<>] /// CHECK-DAG: Return [<>] /// CHECK-START: float Main.$noinline$floatAddSubSimplifyArg2(float, float) instruction_simplifier (after) /// CHECK: <> ParameterValue /// CHECK: <> ParameterValue /// CHECK-DAG: <> Add [<>,<>] /// CHECK-DAG: <> Sub [<>,<>] /// CHECK-DAG: Return [<>] public static float $noinline$floatAddSubSimplifyArg2(float x, float y) { float sum = x + y; return sum - y; } /// CHECK-START: float Main.$noinline$floatSubAddSimplifyLeft(float, float) instruction_simplifier (before) /// CHECK: <> ParameterValue /// CHECK: <> ParameterValue /// CHECK-DAG: <> Sub [<>,<>] /// CHECK-DAG: <> Add [<>,<>] /// CHECK-DAG: Return [<>] /// CHECK-START: float Main.$noinline$floatSubAddSimplifyLeft(float, float) instruction_simplifier (after) /// CHECK: <> ParameterValue /// CHECK: <> ParameterValue /// CHECK-DAG: <> Sub [<>,<>] /// CHECK-DAG: <> Add [<>,<>] /// CHECK-DAG: Return [<>] public static float $noinline$floatSubAddSimplifyLeft(float x, float y) { float sub = x - y; return sub + y; } /// CHECK-START: float Main.$noinline$floatSubAddSimplifyRight(float, float) instruction_simplifier (before) /// CHECK: <> ParameterValue /// CHECK: <> ParameterValue /// CHECK-DAG: <> Sub [<>,<>] /// CHECK-DAG: <> Add [<>,<>] /// CHECK-DAG: Return [<>] /// CHECK-START: float Main.$noinline$floatSubAddSimplifyRight(float, float) instruction_simplifier (after) /// CHECK: <> ParameterValue /// CHECK: <> ParameterValue /// CHECK-DAG: <> Sub [<>,<>] /// CHECK-DAG: <> Add [<>,<>] /// CHECK-DAG: Return [<>] public static float $noinline$floatSubAddSimplifyRight(float x, float y) { float sub = x - y; return y + sub; } /// CHECK-START: int Main.$noinline$getUint8FromInstanceByteField(Main) instruction_simplifier (before) /// CHECK-DAG: <> IntConstant 255 /// CHECK-DAG: <> InstanceFieldGet /// CHECK-DAG: <> And [<>,<>] /// CHECK-DAG: Return [<>] /// CHECK-START: int Main.$noinline$getUint8FromInstanceByteField(Main) instruction_simplifier (after) /// CHECK-DAG: <> InstanceFieldGet /// CHECK-DAG: Return [<>] /// CHECK-START: int Main.$noinline$getUint8FromInstanceByteField(Main) instruction_simplifier (after) /// CHECK-NOT: And /// CHECK-NOT: TypeConversion public static int $noinline$getUint8FromInstanceByteField(Main m) { return m.instanceByteField & 0xff; } /// CHECK-START: int Main.$noinline$getUint8FromStaticByteField() instruction_simplifier (before) /// CHECK-DAG: <> IntConstant 255 /// CHECK-DAG: <> StaticFieldGet /// CHECK-DAG: <> And [<>,<>] /// CHECK-DAG: Return [<>] /// CHECK-START: int Main.$noinline$getUint8FromStaticByteField() instruction_simplifier (after) /// CHECK-DAG: <> StaticFieldGet /// CHECK-DAG: Return [<>] /// CHECK-START: int Main.$noinline$getUint8FromStaticByteField() instruction_simplifier (after) /// CHECK-NOT: And /// CHECK-NOT: TypeConversion public static int $noinline$getUint8FromStaticByteField() { return staticByteField & 0xff; } /// CHECK-START: int Main.$noinline$getUint8FromByteArray(byte[]) instruction_simplifier (before) /// CHECK-DAG: <> IntConstant 255 /// CHECK-DAG: <> ArrayGet /// CHECK-DAG: <> And [<>,<>] /// CHECK-DAG: Return [<>] /// CHECK-START: int Main.$noinline$getUint8FromByteArray(byte[]) instruction_simplifier (after) /// CHECK-DAG: <> ArrayGet /// CHECK-DAG: Return [<>] /// CHECK-START: int Main.$noinline$getUint8FromByteArray(byte[]) instruction_simplifier (after) /// CHECK-NOT: And /// CHECK-NOT: TypeConversion public static int $noinline$getUint8FromByteArray(byte[] a) { return a[0] & 0xff; } /// CHECK-START: int Main.$noinline$getUint16FromInstanceShortField(Main) instruction_simplifier (before) /// CHECK-DAG: <> IntConstant 65535 /// CHECK-DAG: <> InstanceFieldGet /// CHECK-DAG: <> And [<>,<>] /// CHECK-DAG: Return [<>] /// CHECK-START: int Main.$noinline$getUint16FromInstanceShortField(Main) instruction_simplifier (after) /// CHECK-DAG: <> InstanceFieldGet /// CHECK-DAG: Return [<>] /// CHECK-START: int Main.$noinline$getUint16FromInstanceShortField(Main) instruction_simplifier (after) /// CHECK-NOT: And /// CHECK-NOT: TypeConversion public static int $noinline$getUint16FromInstanceShortField(Main m) { return m.instanceShortField & 0xffff; } /// CHECK-START: int Main.$noinline$getUint16FromStaticShortField() instruction_simplifier (before) /// CHECK-DAG: <> IntConstant 65535 /// CHECK-DAG: <> StaticFieldGet /// CHECK-DAG: <> And [<>,<>] /// CHECK-DAG: Return [<>] /// CHECK-START: int Main.$noinline$getUint16FromStaticShortField() instruction_simplifier (after) /// CHECK-DAG: <> StaticFieldGet /// CHECK-DAG: Return [<>] /// CHECK-START: int Main.$noinline$getUint16FromStaticShortField() instruction_simplifier (after) /// CHECK-NOT: And /// CHECK-NOT: TypeConversion public static int $noinline$getUint16FromStaticShortField() { return staticShortField & 0xffff; } /// CHECK-START: int Main.$noinline$getUint16FromShortArray(short[]) instruction_simplifier (before) /// CHECK-DAG: <> IntConstant 65535 /// CHECK-DAG: <> ArrayGet /// CHECK-DAG: <> And [<>,<>] /// CHECK-DAG: Return [<>] /// CHECK-START: int Main.$noinline$getUint16FromShortArray(short[]) instruction_simplifier (after) /// CHECK-DAG: <> ArrayGet /// CHECK-DAG: Return [<>] /// CHECK-START: int Main.$noinline$getUint16FromShortArray(short[]) instruction_simplifier (after) /// CHECK-NOT: And /// CHECK-NOT: TypeConversion public static int $noinline$getUint16FromShortArray(short[] a) { return a[0] & 0xffff; } /// CHECK-START: int Main.$noinline$getInt16FromInstanceCharField(Main) instruction_simplifier (before) /// CHECK-DAG: <> InstanceFieldGet /// CHECK-DAG: <> TypeConversion [<>] /// CHECK-DAG: Return [<>] /// CHECK-START: int Main.$noinline$getInt16FromInstanceCharField(Main) instruction_simplifier (after) /// CHECK-DAG: <> InstanceFieldGet /// CHECK-DAG: Return [<>] /// CHECK-START: int Main.$noinline$getInt16FromInstanceCharField(Main) instruction_simplifier (after) /// CHECK-NOT: And /// CHECK-NOT: TypeConversion public static int $noinline$getInt16FromInstanceCharField(Main m) { return (short) m.instanceCharField; } /// CHECK-START: int Main.$noinline$getInt16FromStaticCharField() instruction_simplifier (before) /// CHECK-DAG: <> StaticFieldGet /// CHECK-DAG: <> TypeConversion [<>] /// CHECK-DAG: Return [<>] /// CHECK-START: int Main.$noinline$getInt16FromStaticCharField() instruction_simplifier (after) /// CHECK-DAG: <> StaticFieldGet /// CHECK-DAG: Return [<>] /// CHECK-START: int Main.$noinline$getInt16FromStaticCharField() instruction_simplifier (after) /// CHECK-NOT: And /// CHECK-NOT: TypeConversion public static int $noinline$getInt16FromStaticCharField() { return (short) staticCharField; } /// CHECK-START: int Main.$noinline$getInt16FromCharArray(char[]) instruction_simplifier (before) /// CHECK-DAG: <> ArrayGet /// CHECK-DAG: <> TypeConversion [<>] /// CHECK-DAG: Return [<>] /// CHECK-START: int Main.$noinline$getInt16FromCharArray(char[]) instruction_simplifier (after) /// CHECK-DAG: <> ArrayGet /// CHECK-DAG: Return [<>] /// CHECK-START: int Main.$noinline$getInt16FromCharArray(char[]) instruction_simplifier (after) /// CHECK-NOT: And /// CHECK-NOT: TypeConversion public static int $noinline$getInt16FromCharArray(char[] a) { return (short) a[0]; } /// CHECK-START: int Main.$noinline$byteToUint8AndBack() instruction_simplifier (before) /// CHECK-DAG: <> IntConstant 255 /// CHECK-DAG: <> StaticFieldGet /// CHECK-DAG: <> And [<>,<>] /// CHECK-DAG: <> InvokeStaticOrDirect [<>{{(,[ij]\d+)?}}] /// CHECK-DAG: Return [<>] /// CHECK-START: int Main.$noinline$byteToUint8AndBack() instruction_simplifier (after) /// CHECK-DAG: <> StaticFieldGet /// CHECK-DAG: <> InvokeStaticOrDirect [<>{{(,[ij]\d+)?}}] /// CHECK-DAG: Return [<>] /// CHECK-START: int Main.$noinline$byteToUint8AndBack() instruction_simplifier$after_inlining (before) /// CHECK-DAG: <> StaticFieldGet /// CHECK-DAG: <> TypeConversion [<>] /// CHECK-DAG: Return [<>] /// CHECK-START: int Main.$noinline$byteToUint8AndBack() instruction_simplifier$after_inlining (after) /// CHECK-DAG: <> StaticFieldGet /// CHECK-DAG: Return [<>] public static int $noinline$byteToUint8AndBack() { return $inline$toByte(staticByteField & 0xff); } public static int $inline$toByte(int value) { return (byte) value; } /// CHECK-START: int Main.$noinline$getStaticCharFieldAnd0xff() instruction_simplifier (before) /// CHECK-DAG: <> IntConstant 255 /// CHECK-DAG: <> StaticFieldGet /// CHECK-DAG: <> And [<>,<>] /// CHECK-DAG: Return [<>] /// CHECK-START: int Main.$noinline$getStaticCharFieldAnd0xff() instruction_simplifier (after) /// CHECK-DAG: <> IntConstant 255 /// CHECK-DAG: <> StaticFieldGet /// CHECK-DAG: <> TypeConversion [<>] /// CHECK-DAG: Return [<>] /// CHECK-START: int Main.$noinline$getStaticCharFieldAnd0xff() instruction_simplifier (after) /// CHECK-NOT: {{a\d+}} StaticFieldGet public static int $noinline$getStaticCharFieldAnd0xff() { return staticCharField & 0xff; } /// CHECK-START: int Main.$noinline$getUint8FromInstanceByteFieldWithAnotherUse(Main) instruction_simplifier (before) /// CHECK-DAG: <> IntConstant 8 /// CHECK-DAG: <> IntConstant 255 /// CHECK-DAG: <> InstanceFieldGet /// CHECK-DAG: <> And [<>,<>] /// CHECK-DAG: <> Shl [<>,<>] /// CHECK-DAG: <> Add [<>,<>] /// CHECK-DAG: Return [<>] /// CHECK-START: int Main.$noinline$getUint8FromInstanceByteFieldWithAnotherUse(Main) instruction_simplifier (after) /// CHECK-DAG: <> IntConstant 8 /// CHECK-DAG: <> IntConstant 255 /// CHECK-DAG: <> InstanceFieldGet /// CHECK-DAG: <> TypeConversion [<>] /// CHECK-DAG: <> Shl [<>,<>] /// CHECK-DAG: <> Add [<>,<>] /// CHECK-DAG: Return [<>] /// CHECK-START: int Main.$noinline$getUint8FromInstanceByteFieldWithAnotherUse(Main) instruction_simplifier (after) /// CHECK-NOT: {{a\d+}} InstanceFieldGet public static int $noinline$getUint8FromInstanceByteFieldWithAnotherUse(Main m) { byte b = m.instanceByteField; int v1 = b & 0xff; int v2 = (b << 8); return v1 + v2; } /// CHECK-START: int Main.$noinline$intAnd0xffToChar(int) instruction_simplifier (before) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> IntConstant 255 /// CHECK-DAG: <> And [<>,<>] /// CHECK-DAG: <> TypeConversion [<>] /// CHECK-DAG: Return [<>] /// CHECK-START: int Main.$noinline$intAnd0xffToChar(int) instruction_simplifier (after) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> TypeConversion [<>] /// CHECK-DAG: Return [<>] public static int $noinline$intAnd0xffToChar(int value) { return (char) (value & 0xff); } /// CHECK-START: int Main.$noinline$intAnd0x1ffToChar(int) instruction_simplifier (before) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> IntConstant 511 /// CHECK-DAG: <> And [<>,<>] /// CHECK-DAG: <> TypeConversion [<>] /// CHECK-DAG: Return [<>] // TODO: Simplify this. Unlike the $noinline$intAnd0xffToChar(), the TypeConversion // to `char` is not eliminated despite the result of the And being within the `char` range. // CHECK-START: int Main.$noinline$intAnd0x1ffToChar(int) instruction_simplifier (after) // CHECK-DAG: <> ParameterValue // CHECK-DAG: <> IntConstant 511 // CHECK-DAG: <> And [<>,<>] // CHECK-DAG: Return [<>] public static int $noinline$intAnd0x1ffToChar(int value) { return (char) (value & 0x1ff); } /// CHECK-START: int Main.$noinline$getInstanceCharFieldAnd0x1ffff(Main) instruction_simplifier (before) /// CHECK-DAG: <> IntConstant 131071 /// CHECK-DAG: <> InstanceFieldGet /// CHECK-DAG: <> And [<>,<>] /// CHECK-DAG: Return [<>] /// CHECK-START: int Main.$noinline$getInstanceCharFieldAnd0x1ffff(Main) instruction_simplifier (after) /// CHECK-DAG: <> InstanceFieldGet /// CHECK-DAG: Return [<>] public static int $noinline$getInstanceCharFieldAnd0x1ffff(Main m) { return m.instanceCharField & 0x1ffff; } /// CHECK-START: int Main.$noinline$bug68142795Byte(byte) instruction_simplifier (before) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> IntConstant 255 /// CHECK-DAG: <> And [<>,<>] /// CHECK-DAG: <> And [<>,<>] /// CHECK-DAG: <> TypeConversion [<>] /// CHECK-DAG: Return [<>] /// CHECK-START: int Main.$noinline$bug68142795Byte(byte) instruction_simplifier (after) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: Return [<>] public static int $noinline$bug68142795Byte(byte b) { return (byte)(0xff & (b & 0xff)); } /// CHECK-START: int Main.$noinline$bug68142795Elaborate(byte) instruction_simplifier (before) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> IntConstant 255 /// CHECK-DAG: <> LongConstant 255 /// CHECK-DAG: <> And [<>,<>] /// CHECK-DAG: <> TypeConversion [<>] /// CHECK-DAG: <> And [<>,<>] /// CHECK-DAG: <> TypeConversion [<>] /// CHECK-DAG: <> TypeConversion [<>] /// CHECK-DAG: Return [<>] /// CHECK-START: int Main.$noinline$bug68142795Elaborate(byte) instruction_simplifier (after) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: Return [<>] public static int $noinline$bug68142795Elaborate(byte b) { return (byte)((int)(((long)(b & 0xff)) & 255L)); } /// CHECK-START: int Main.$noinline$emptyStringIndexOf(int) instruction_simplifier (before) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> LoadString /// CHECK-DAG: <> InvokeVirtual [<>,<>] intrinsic:StringIndexOf /// CHECK-DAG: Return [<>] /// CHECK-START: int Main.$noinline$emptyStringIndexOf(int) instruction_simplifier (after) /// CHECK-NOT: InvokeVirtual /// CHECK-START: int Main.$noinline$emptyStringIndexOf(int) instruction_simplifier (after) /// CHECK-DAG: <> IntConstant -1 /// CHECK-DAG: Return [<>] public static int $noinline$emptyStringIndexOf(int ch) { return "".indexOf(ch); } /// CHECK-START: int Main.$noinline$emptyStringIndexOfAfter(int, int) instruction_simplifier (before) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> LoadString /// CHECK-DAG: <> InvokeVirtual [<>,<>,<>] intrinsic:StringIndexOfAfter /// CHECK-DAG: Return [<>] /// CHECK-START: int Main.$noinline$emptyStringIndexOfAfter(int, int) instruction_simplifier (after) /// CHECK-NOT: InvokeVirtual /// CHECK-START: int Main.$noinline$emptyStringIndexOfAfter(int, int) instruction_simplifier (after) /// CHECK-DAG: <> IntConstant -1 /// CHECK-DAG: Return [<>] public static int $noinline$emptyStringIndexOfAfter(int ch, int fromIndex) { return "".indexOf(ch, fromIndex); } /// CHECK-START: int Main.$noinline$singleCharStringIndexOf(int) instruction_simplifier (before) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> LoadString /// CHECK-DAG: <> InvokeVirtual [<>,<>] intrinsic:StringIndexOf /// CHECK-DAG: Return [<>] /// CHECK-START: int Main.$noinline$singleCharStringIndexOf(int) instruction_simplifier (after) /// CHECK-NOT: InvokeVirtual /// CHECK-START: int Main.$noinline$singleCharStringIndexOf(int) instruction_simplifier (after) /// CHECK-DAG: <> ParameterValue /// CHECK-DAG: <> IntConstant 120 /// CHECK-DAG: <> IntConstant 0 /// CHECK-DAG: <> IntConstant -1 /// CHECK-DAG: <> Equal [<>,<>] /// CHECK-DAG: <> Select [<>,<>,<>] /// CHECK-DAG: Return [<