xref: /aosp_15_r20/art/test/551-checker-shifter-operand/src/Main.java (revision 795d594fd825385562da6b089ea9b2033f3abf5a)
1*795d594fSAndroid Build Coastguard Worker /*
2*795d594fSAndroid Build Coastguard Worker  * Copyright (C) 2015 The Android Open Source Project
3*795d594fSAndroid Build Coastguard Worker  *
4*795d594fSAndroid Build Coastguard Worker  * Licensed under the Apache License, Version 2.0 (the "License");
5*795d594fSAndroid Build Coastguard Worker  * you may not use this file except in compliance with the License.
6*795d594fSAndroid Build Coastguard Worker  * You may obtain a copy of the License at
7*795d594fSAndroid Build Coastguard Worker  *
8*795d594fSAndroid Build Coastguard Worker  *      http://www.apache.org/licenses/LICENSE-2.0
9*795d594fSAndroid Build Coastguard Worker  *
10*795d594fSAndroid Build Coastguard Worker  * Unless required by applicable law or agreed to in writing, software
11*795d594fSAndroid Build Coastguard Worker  * distributed under the License is distributed on an "AS IS" BASIS,
12*795d594fSAndroid Build Coastguard Worker  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13*795d594fSAndroid Build Coastguard Worker  * See the License for the specific language governing permissions and
14*795d594fSAndroid Build Coastguard Worker  * limitations under the License.
15*795d594fSAndroid Build Coastguard Worker  */
16*795d594fSAndroid Build Coastguard Worker 
17*795d594fSAndroid Build Coastguard Worker public class Main {
18*795d594fSAndroid Build Coastguard Worker 
assertByteEquals(byte expected, byte result)19*795d594fSAndroid Build Coastguard Worker   public static void assertByteEquals(byte expected, byte result) {
20*795d594fSAndroid Build Coastguard Worker     if (expected != result) {
21*795d594fSAndroid Build Coastguard Worker       throw new Error("Expected: " + expected + ", found: " + result);
22*795d594fSAndroid Build Coastguard Worker     }
23*795d594fSAndroid Build Coastguard Worker   }
24*795d594fSAndroid Build Coastguard Worker 
assertCharEquals(char expected, char result)25*795d594fSAndroid Build Coastguard Worker   public static void assertCharEquals(char expected, char result) {
26*795d594fSAndroid Build Coastguard Worker     if (expected != result) {
27*795d594fSAndroid Build Coastguard Worker       throw new Error("Expected: " + expected + ", found: " + result);
28*795d594fSAndroid Build Coastguard Worker     }
29*795d594fSAndroid Build Coastguard Worker   }
30*795d594fSAndroid Build Coastguard Worker 
assertShortEquals(short expected, short result)31*795d594fSAndroid Build Coastguard Worker   public static void assertShortEquals(short expected, short result) {
32*795d594fSAndroid Build Coastguard Worker     if (expected != result) {
33*795d594fSAndroid Build Coastguard Worker       throw new Error("Expected: " + expected + ", found: " + result);
34*795d594fSAndroid Build Coastguard Worker     }
35*795d594fSAndroid Build Coastguard Worker   }
36*795d594fSAndroid Build Coastguard Worker 
assertIntEquals(int expected, int result)37*795d594fSAndroid Build Coastguard Worker   public static void assertIntEquals(int expected, int result) {
38*795d594fSAndroid Build Coastguard Worker     if (expected != result) {
39*795d594fSAndroid Build Coastguard Worker       throw new Error("Expected: " + expected + ", found: " + result);
40*795d594fSAndroid Build Coastguard Worker     }
41*795d594fSAndroid Build Coastguard Worker   }
42*795d594fSAndroid Build Coastguard Worker 
assertLongEquals(long expected, long result)43*795d594fSAndroid Build Coastguard Worker   public static void assertLongEquals(long expected, long result) {
44*795d594fSAndroid Build Coastguard Worker     if (expected != result) {
45*795d594fSAndroid Build Coastguard Worker       throw new Error("Expected: " + expected + ", found: " + result);
46*795d594fSAndroid Build Coastguard Worker     }
47*795d594fSAndroid Build Coastguard Worker   }
48*795d594fSAndroid Build Coastguard Worker 
49*795d594fSAndroid Build Coastguard Worker   // Non-inlinable type-casting helpers.
$noinline$byteToChar(byte v)50*795d594fSAndroid Build Coastguard Worker   static  char $noinline$byteToChar   (byte v) { return  (char)v; }
$noinline$byteToShort(byte v)51*795d594fSAndroid Build Coastguard Worker   static short $noinline$byteToShort  (byte v) { return (short)v; }
$noinline$byteToInt(byte v)52*795d594fSAndroid Build Coastguard Worker   static   int $noinline$byteToInt    (byte v) { return   (int)v; }
$noinline$byteToLong(byte v)53*795d594fSAndroid Build Coastguard Worker   static  long $noinline$byteToLong   (byte v) { return  (long)v; }
$noinline$charToByte(char v)54*795d594fSAndroid Build Coastguard Worker   static  byte $noinline$charToByte   (char v) { return  (byte)v; }
$noinline$charToShort(char v)55*795d594fSAndroid Build Coastguard Worker   static short $noinline$charToShort  (char v) { return (short)v; }
$noinline$charToInt(char v)56*795d594fSAndroid Build Coastguard Worker   static   int $noinline$charToInt    (char v) { return   (int)v; }
$noinline$charToLong(char v)57*795d594fSAndroid Build Coastguard Worker   static  long $noinline$charToLong   (char v) { return  (long)v; }
$noinline$shortToByte(short v)58*795d594fSAndroid Build Coastguard Worker   static  byte $noinline$shortToByte (short v) { return  (byte)v; }
$noinline$shortToChar(short v)59*795d594fSAndroid Build Coastguard Worker   static  char $noinline$shortToChar (short v) { return  (char)v; }
$noinline$shortToInt(short v)60*795d594fSAndroid Build Coastguard Worker   static   int $noinline$shortToInt  (short v) { return   (int)v; }
$noinline$shortToLong(short v)61*795d594fSAndroid Build Coastguard Worker   static  long $noinline$shortToLong (short v) { return  (long)v; }
$noinline$intToByte(int v)62*795d594fSAndroid Build Coastguard Worker   static  byte $noinline$intToByte     (int v) { return  (byte)v; }
$noinline$intToChar(int v)63*795d594fSAndroid Build Coastguard Worker   static  char $noinline$intToChar     (int v) { return  (char)v; }
$noinline$intToShort(int v)64*795d594fSAndroid Build Coastguard Worker   static short $noinline$intToShort    (int v) { return (short)v; }
$noinline$intToLong(int v)65*795d594fSAndroid Build Coastguard Worker   static  long $noinline$intToLong     (int v) { return  (long)v; }
$noinline$longToByte(long v)66*795d594fSAndroid Build Coastguard Worker   static  byte $noinline$longToByte   (long v) { return  (byte)v; }
$noinline$longToChar(long v)67*795d594fSAndroid Build Coastguard Worker   static  char $noinline$longToChar   (long v) { return  (char)v; }
$noinline$longToShort(long v)68*795d594fSAndroid Build Coastguard Worker   static short $noinline$longToShort  (long v) { return (short)v; }
$noinline$longToInt(long v)69*795d594fSAndroid Build Coastguard Worker   static   int $noinline$longToInt    (long v) { return   (int)v; }
70*795d594fSAndroid Build Coastguard Worker 
71*795d594fSAndroid Build Coastguard Worker   /**
72*795d594fSAndroid Build Coastguard Worker    * Basic test merging a bitfield move operation (here a type conversion) into
73*795d594fSAndroid Build Coastguard Worker    * the shifter operand.
74*795d594fSAndroid Build Coastguard Worker    */
75*795d594fSAndroid Build Coastguard Worker 
76*795d594fSAndroid Build Coastguard Worker   /// CHECK-START-ARM: long Main.$opt$noinline$translate(long, byte) instruction_simplifier_arm (before)
77*795d594fSAndroid Build Coastguard Worker   /// CHECK-DAG:   <<l:j\d+>>           ParameterValue
78*795d594fSAndroid Build Coastguard Worker   /// CHECK-DAG:   <<b:b\d+>>           ParameterValue
79*795d594fSAndroid Build Coastguard Worker   /// CHECK:       <<tmp:j\d+>>         TypeConversion [<<b>>]
80*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            Sub [<<l>>,<<tmp>>]
81*795d594fSAndroid Build Coastguard Worker 
82*795d594fSAndroid Build Coastguard Worker   /// CHECK-START-ARM: long Main.$opt$noinline$translate(long, byte) instruction_simplifier_arm (after)
83*795d594fSAndroid Build Coastguard Worker   /// CHECK-DAG:   <<l:j\d+>>           ParameterValue
84*795d594fSAndroid Build Coastguard Worker   /// CHECK-DAG:   <<b:b\d+>>           ParameterValue
85*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp [<<l>>,<<b>>] kind:Sub+SXTB
86*795d594fSAndroid Build Coastguard Worker 
87*795d594fSAndroid Build Coastguard Worker   /// CHECK-START-ARM: long Main.$opt$noinline$translate(long, byte) instruction_simplifier_arm (after)
88*795d594fSAndroid Build Coastguard Worker   /// CHECK-NOT:                        TypeConversion
89*795d594fSAndroid Build Coastguard Worker   /// CHECK-NOT:                        Sub
90*795d594fSAndroid Build Coastguard Worker 
91*795d594fSAndroid Build Coastguard Worker   /// CHECK-START-ARM: long Main.$opt$noinline$translate(long, byte) disassembly (after)
92*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            subs r{{\d+}}, r{{\d+}}, r{{\d+}}
93*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            sbc r{{\d+}}, r{{\d+}}, r{{\d+}}, asr #31
94*795d594fSAndroid Build Coastguard Worker 
95*795d594fSAndroid Build Coastguard Worker   /// CHECK-START-ARM64: long Main.$opt$noinline$translate(long, byte) instruction_simplifier_arm64 (before)
96*795d594fSAndroid Build Coastguard Worker   /// CHECK-DAG:   <<l:j\d+>>           ParameterValue
97*795d594fSAndroid Build Coastguard Worker   /// CHECK-DAG:   <<b:b\d+>>           ParameterValue
98*795d594fSAndroid Build Coastguard Worker   /// CHECK:       <<tmp:j\d+>>         TypeConversion [<<b>>]
99*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            Sub [<<l>>,<<tmp>>]
100*795d594fSAndroid Build Coastguard Worker 
101*795d594fSAndroid Build Coastguard Worker   /// CHECK-START-ARM64: long Main.$opt$noinline$translate(long, byte) instruction_simplifier_arm64 (after)
102*795d594fSAndroid Build Coastguard Worker   /// CHECK-DAG:   <<l:j\d+>>           ParameterValue
103*795d594fSAndroid Build Coastguard Worker   /// CHECK-DAG:   <<b:b\d+>>           ParameterValue
104*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp [<<l>>,<<b>>] kind:Sub+SXTB
105*795d594fSAndroid Build Coastguard Worker 
106*795d594fSAndroid Build Coastguard Worker   /// CHECK-START-ARM64: long Main.$opt$noinline$translate(long, byte) instruction_simplifier_arm64 (after)
107*795d594fSAndroid Build Coastguard Worker   /// CHECK-NOT:                        TypeConversion
108*795d594fSAndroid Build Coastguard Worker   /// CHECK-NOT:                        Sub
109*795d594fSAndroid Build Coastguard Worker 
110*795d594fSAndroid Build Coastguard Worker   /// CHECK-START-ARM64: long Main.$opt$noinline$translate(long, byte) disassembly (after)
111*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            sub x{{\d+}}, x{{\d+}}, w{{\d+}}, sxtb
112*795d594fSAndroid Build Coastguard Worker 
$opt$noinline$translate(long l, byte b)113*795d594fSAndroid Build Coastguard Worker   public static long $opt$noinline$translate(long l, byte b) {
114*795d594fSAndroid Build Coastguard Worker     long tmp = (long)b;
115*795d594fSAndroid Build Coastguard Worker     return l - tmp;
116*795d594fSAndroid Build Coastguard Worker   }
117*795d594fSAndroid Build Coastguard Worker 
118*795d594fSAndroid Build Coastguard Worker 
119*795d594fSAndroid Build Coastguard Worker   /**
120*795d594fSAndroid Build Coastguard Worker    * Test that we do not merge into the shifter operand when the left and right
121*795d594fSAndroid Build Coastguard Worker    * inputs are the the IR.
122*795d594fSAndroid Build Coastguard Worker    */
123*795d594fSAndroid Build Coastguard Worker 
124*795d594fSAndroid Build Coastguard Worker   /// CHECK-START-ARM: int Main.$opt$noinline$sameInput(int) instruction_simplifier_arm (before)
125*795d594fSAndroid Build Coastguard Worker   /// CHECK:       <<a:i\d+>>           ParameterValue
126*795d594fSAndroid Build Coastguard Worker   /// CHECK:       <<Const2:i\d+>>      IntConstant 2
127*795d594fSAndroid Build Coastguard Worker   /// CHECK:       <<tmp:i\d+>>         Shl [<<a>>,<<Const2>>]
128*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            Add [<<tmp>>,<<tmp>>]
129*795d594fSAndroid Build Coastguard Worker 
130*795d594fSAndroid Build Coastguard Worker   /// CHECK-START-ARM: int Main.$opt$noinline$sameInput(int) instruction_simplifier_arm (after)
131*795d594fSAndroid Build Coastguard Worker   /// CHECK-DAG:   <<a:i\d+>>           ParameterValue
132*795d594fSAndroid Build Coastguard Worker   /// CHECK-DAG:   <<Const2:i\d+>>      IntConstant 2
133*795d594fSAndroid Build Coastguard Worker   /// CHECK:       <<Shl:i\d+>>         Shl [<<a>>,<<Const2>>]
134*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            Add [<<Shl>>,<<Shl>>]
135*795d594fSAndroid Build Coastguard Worker 
136*795d594fSAndroid Build Coastguard Worker   /// CHECK-START-ARM: int Main.$opt$noinline$sameInput(int) instruction_simplifier_arm (after)
137*795d594fSAndroid Build Coastguard Worker   /// CHECK-NOT:                        DataProcWithShifterOp
138*795d594fSAndroid Build Coastguard Worker 
139*795d594fSAndroid Build Coastguard Worker   /// CHECK-START-ARM64: int Main.$opt$noinline$sameInput(int) instruction_simplifier_arm64 (before)
140*795d594fSAndroid Build Coastguard Worker   /// CHECK:       <<a:i\d+>>           ParameterValue
141*795d594fSAndroid Build Coastguard Worker   /// CHECK:       <<Const2:i\d+>>      IntConstant 2
142*795d594fSAndroid Build Coastguard Worker   /// CHECK:       <<tmp:i\d+>>         Shl [<<a>>,<<Const2>>]
143*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            Add [<<tmp>>,<<tmp>>]
144*795d594fSAndroid Build Coastguard Worker 
145*795d594fSAndroid Build Coastguard Worker   /// CHECK-START-ARM64: int Main.$opt$noinline$sameInput(int) instruction_simplifier_arm64 (after)
146*795d594fSAndroid Build Coastguard Worker   /// CHECK-DAG:   <<a:i\d+>>           ParameterValue
147*795d594fSAndroid Build Coastguard Worker   /// CHECK-DAG:   <<Const2:i\d+>>      IntConstant 2
148*795d594fSAndroid Build Coastguard Worker   /// CHECK:       <<Shl:i\d+>>         Shl [<<a>>,<<Const2>>]
149*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            Add [<<Shl>>,<<Shl>>]
150*795d594fSAndroid Build Coastguard Worker 
151*795d594fSAndroid Build Coastguard Worker   /// CHECK-START-ARM64: int Main.$opt$noinline$sameInput(int) instruction_simplifier_arm64 (after)
152*795d594fSAndroid Build Coastguard Worker   /// CHECK-NOT:                        DataProcWithShifterOp
153*795d594fSAndroid Build Coastguard Worker 
$opt$noinline$sameInput(int a)154*795d594fSAndroid Build Coastguard Worker   public static int $opt$noinline$sameInput(int a) {
155*795d594fSAndroid Build Coastguard Worker     int tmp = a << 2;
156*795d594fSAndroid Build Coastguard Worker     return tmp + tmp;
157*795d594fSAndroid Build Coastguard Worker   }
158*795d594fSAndroid Build Coastguard Worker 
159*795d594fSAndroid Build Coastguard Worker   /**
160*795d594fSAndroid Build Coastguard Worker    * Check that we perform the merge for multiple uses.
161*795d594fSAndroid Build Coastguard Worker    */
162*795d594fSAndroid Build Coastguard Worker 
163*795d594fSAndroid Build Coastguard Worker   /// CHECK-START-ARM: int Main.$opt$noinline$multipleUses(int) instruction_simplifier_arm (before)
164*795d594fSAndroid Build Coastguard Worker   /// CHECK:       <<arg:i\d+>>         ParameterValue
165*795d594fSAndroid Build Coastguard Worker   /// CHECK:       <<Const23:i\d+>>     IntConstant 23
166*795d594fSAndroid Build Coastguard Worker   /// CHECK:       <<tmp:i\d+>>         Shl [<<arg>>,<<Const23>>]
167*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            Add [<<tmp>>,{{i\d+}}]
168*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            Add [<<tmp>>,{{i\d+}}]
169*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            Add [<<tmp>>,{{i\d+}}]
170*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            Add [<<tmp>>,{{i\d+}}]
171*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            Add [<<tmp>>,{{i\d+}}]
172*795d594fSAndroid Build Coastguard Worker 
173*795d594fSAndroid Build Coastguard Worker   /// CHECK-START-ARM: int Main.$opt$noinline$multipleUses(int) instruction_simplifier_arm (after)
174*795d594fSAndroid Build Coastguard Worker   /// CHECK:       <<arg:i\d+>>         ParameterValue
175*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp [{{i\d+}},<<arg>>] kind:Add+LSL shift:23
176*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp [{{i\d+}},<<arg>>] kind:Add+LSL shift:23
177*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp [{{i\d+}},<<arg>>] kind:Add+LSL shift:23
178*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp [{{i\d+}},<<arg>>] kind:Add+LSL shift:23
179*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp [{{i\d+}},<<arg>>] kind:Add+LSL shift:23
180*795d594fSAndroid Build Coastguard Worker 
181*795d594fSAndroid Build Coastguard Worker   /// CHECK-START-ARM: int Main.$opt$noinline$multipleUses(int) instruction_simplifier_arm (after)
182*795d594fSAndroid Build Coastguard Worker   /// CHECK-NOT:                        Shl
183*795d594fSAndroid Build Coastguard Worker   /// CHECK-NOT:                        Add
184*795d594fSAndroid Build Coastguard Worker 
185*795d594fSAndroid Build Coastguard Worker   /// CHECK-START-ARM64: int Main.$opt$noinline$multipleUses(int) instruction_simplifier_arm64 (before)
186*795d594fSAndroid Build Coastguard Worker   /// CHECK:       <<arg:i\d+>>         ParameterValue
187*795d594fSAndroid Build Coastguard Worker   /// CHECK:       <<Const23:i\d+>>     IntConstant 23
188*795d594fSAndroid Build Coastguard Worker   /// CHECK:       <<tmp:i\d+>>         Shl [<<arg>>,<<Const23>>]
189*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            Add [<<tmp>>,{{i\d+}}]
190*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            Add [<<tmp>>,{{i\d+}}]
191*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            Add [<<tmp>>,{{i\d+}}]
192*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            Add [<<tmp>>,{{i\d+}}]
193*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            Add [<<tmp>>,{{i\d+}}]
194*795d594fSAndroid Build Coastguard Worker 
195*795d594fSAndroid Build Coastguard Worker   /// CHECK-START-ARM64: int Main.$opt$noinline$multipleUses(int) instruction_simplifier_arm64 (after)
196*795d594fSAndroid Build Coastguard Worker   /// CHECK:       <<arg:i\d+>>         ParameterValue
197*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp [{{i\d+}},<<arg>>] kind:Add+LSL shift:23
198*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp [{{i\d+}},<<arg>>] kind:Add+LSL shift:23
199*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp [{{i\d+}},<<arg>>] kind:Add+LSL shift:23
200*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp [{{i\d+}},<<arg>>] kind:Add+LSL shift:23
201*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp [{{i\d+}},<<arg>>] kind:Add+LSL shift:23
202*795d594fSAndroid Build Coastguard Worker 
203*795d594fSAndroid Build Coastguard Worker   /// CHECK-START-ARM64: int Main.$opt$noinline$multipleUses(int) instruction_simplifier_arm64 (after)
204*795d594fSAndroid Build Coastguard Worker   /// CHECK-NOT:                        Shl
205*795d594fSAndroid Build Coastguard Worker   /// CHECK-NOT:                        Add
206*795d594fSAndroid Build Coastguard Worker 
$opt$noinline$multipleUses(int arg)207*795d594fSAndroid Build Coastguard Worker   public static int $opt$noinline$multipleUses(int arg) {
208*795d594fSAndroid Build Coastguard Worker     int tmp = arg << 23;
209*795d594fSAndroid Build Coastguard Worker     switch (arg) {
210*795d594fSAndroid Build Coastguard Worker       case 1:  return (arg | 1) + tmp;
211*795d594fSAndroid Build Coastguard Worker       case 2:  return (arg | 2) + tmp;
212*795d594fSAndroid Build Coastguard Worker       case 3:  return (arg | 3) + tmp;
213*795d594fSAndroid Build Coastguard Worker       case 4:  return (arg | 4) + tmp;
214*795d594fSAndroid Build Coastguard Worker       case (1 << 20):  return (arg | 5) + tmp;
215*795d594fSAndroid Build Coastguard Worker       default: return 0;
216*795d594fSAndroid Build Coastguard Worker     }
217*795d594fSAndroid Build Coastguard Worker   }
218*795d594fSAndroid Build Coastguard Worker 
219*795d594fSAndroid Build Coastguard Worker   /**
220*795d594fSAndroid Build Coastguard Worker    * Logical instructions cannot take 'extend' operations into the shift
221*795d594fSAndroid Build Coastguard Worker    * operand, so test that only the shifts are merged.
222*795d594fSAndroid Build Coastguard Worker    */
223*795d594fSAndroid Build Coastguard Worker 
224*795d594fSAndroid Build Coastguard Worker   /// CHECK-START-ARM: void Main.$opt$noinline$testAnd(long, long) instruction_simplifier_arm (after)
225*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
226*795d594fSAndroid Build Coastguard Worker   /// CHECK-NOT:                        DataProcWithShifterOp
227*795d594fSAndroid Build Coastguard Worker 
228*795d594fSAndroid Build Coastguard Worker   /// CHECK-START-ARM: void Main.$opt$noinline$testAnd(long, long) disassembly (after)
229*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            and lsl
230*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            sbfx
231*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            asr{{s?}}
232*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            and{{s?}}
233*795d594fSAndroid Build Coastguard Worker 
234*795d594fSAndroid Build Coastguard Worker   /// CHECK-START-ARM64: void Main.$opt$noinline$testAnd(long, long) instruction_simplifier_arm64 (after)
235*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
236*795d594fSAndroid Build Coastguard Worker   /// CHECK-NOT:                        DataProcWithShifterOp
237*795d594fSAndroid Build Coastguard Worker 
238*795d594fSAndroid Build Coastguard Worker   /// CHECK-START-ARM64: void Main.$opt$noinline$testAnd(long, long) disassembly (after)
239*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            and lsl
240*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            sxtb
241*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            and
242*795d594fSAndroid Build Coastguard Worker 
$opt$noinline$testAnd(long a, long b)243*795d594fSAndroid Build Coastguard Worker   static void $opt$noinline$testAnd(long a, long b) {
244*795d594fSAndroid Build Coastguard Worker     assertLongEquals((a & $noinline$LongShl(b, 5)) | (a & $noinline$longToByte(b)),
245*795d594fSAndroid Build Coastguard Worker                      (a & (b << 5)) | (a & (byte)b));
246*795d594fSAndroid Build Coastguard Worker   }
247*795d594fSAndroid Build Coastguard Worker 
248*795d594fSAndroid Build Coastguard Worker   /// CHECK-START-ARM: void Main.$opt$noinline$testOr(int, int) instruction_simplifier_arm (after)
249*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
250*795d594fSAndroid Build Coastguard Worker   /// CHECK-NOT:                        DataProcWithShifterOp
251*795d594fSAndroid Build Coastguard Worker 
252*795d594fSAndroid Build Coastguard Worker   /// CHECK-START-ARM: void Main.$opt$noinline$testOr(int, int) disassembly (after)
253*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            orr asr
254*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            ubfx
255*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            orr{{s?}}
256*795d594fSAndroid Build Coastguard Worker 
257*795d594fSAndroid Build Coastguard Worker   /// CHECK-START-ARM64: void Main.$opt$noinline$testOr(int, int) instruction_simplifier_arm64 (after)
258*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
259*795d594fSAndroid Build Coastguard Worker   /// CHECK-NOT:                        DataProcWithShifterOp
260*795d594fSAndroid Build Coastguard Worker 
261*795d594fSAndroid Build Coastguard Worker   /// CHECK-START-ARM64: void Main.$opt$noinline$testOr(int, int) disassembly (after)
262*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            orr asr
263*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            uxth
264*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            orr
265*795d594fSAndroid Build Coastguard Worker 
$opt$noinline$testOr(int a, int b)266*795d594fSAndroid Build Coastguard Worker   static void $opt$noinline$testOr(int a, int b) {
267*795d594fSAndroid Build Coastguard Worker     assertIntEquals((a | $noinline$IntShr(b, 6)) | (a | $noinline$intToChar(b)),
268*795d594fSAndroid Build Coastguard Worker                     (a | (b >> 6)) | (a | (char)b));
269*795d594fSAndroid Build Coastguard Worker   }
270*795d594fSAndroid Build Coastguard Worker 
271*795d594fSAndroid Build Coastguard Worker   /// CHECK-START-ARM: void Main.$opt$noinline$testXor(long, long) instruction_simplifier_arm (after)
272*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
273*795d594fSAndroid Build Coastguard Worker   /// CHECK-NOT:                        DataProcWithShifterOp
274*795d594fSAndroid Build Coastguard Worker 
275*795d594fSAndroid Build Coastguard Worker   /// CHECK-START-ARM: void Main.$opt$noinline$testXor(long, long) disassembly (after)
276*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            eor lsr
277*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            asr{{s?}}
278*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            eor{{s?}}
279*795d594fSAndroid Build Coastguard Worker 
280*795d594fSAndroid Build Coastguard Worker   /// CHECK-START-ARM64: void Main.$opt$noinline$testXor(long, long) instruction_simplifier_arm64 (after)
281*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
282*795d594fSAndroid Build Coastguard Worker   /// CHECK-NOT:                        DataProcWithShifterOp
283*795d594fSAndroid Build Coastguard Worker 
284*795d594fSAndroid Build Coastguard Worker   /// CHECK-START-ARM64: void Main.$opt$noinline$testXor(long, long) disassembly (after)
285*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            eor lsr
286*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            sxtw
287*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            eor
288*795d594fSAndroid Build Coastguard Worker 
$opt$noinline$testXor(long a, long b)289*795d594fSAndroid Build Coastguard Worker   static void $opt$noinline$testXor(long a, long b) {
290*795d594fSAndroid Build Coastguard Worker     assertLongEquals((a ^ $noinline$LongUshr(b, 7)) | (a ^ $noinline$longToInt(b)),
291*795d594fSAndroid Build Coastguard Worker                      (a ^ (b >>> 7)) | (a ^ (int)b));
292*795d594fSAndroid Build Coastguard Worker   }
293*795d594fSAndroid Build Coastguard Worker 
294*795d594fSAndroid Build Coastguard Worker   /// CHECK-START-ARM: void Main.$opt$noinline$testNeg(int) instruction_simplifier_arm (after)
295*795d594fSAndroid Build Coastguard Worker   /// CHECK-NOT:                            DataProcWithShifterOp
296*795d594fSAndroid Build Coastguard Worker 
297*795d594fSAndroid Build Coastguard Worker   /// CHECK-START-ARM64: void Main.$opt$noinline$testNeg(int) instruction_simplifier_arm64 (after)
298*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
299*795d594fSAndroid Build Coastguard Worker   /// CHECK-NOT:                        DataProcWithShifterOp
300*795d594fSAndroid Build Coastguard Worker 
301*795d594fSAndroid Build Coastguard Worker   /// CHECK-START-ARM64: void Main.$opt$noinline$testNeg(int) disassembly (after)
302*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            neg lsl
303*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            sxth
304*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            neg
305*795d594fSAndroid Build Coastguard Worker 
$opt$noinline$testNeg(int a)306*795d594fSAndroid Build Coastguard Worker   static void $opt$noinline$testNeg(int a) {
307*795d594fSAndroid Build Coastguard Worker     assertIntEquals(-$noinline$IntShl(a, 8) | -$noinline$intToShort(a),
308*795d594fSAndroid Build Coastguard Worker                     (-(a << 8)) | (-(short)a));
309*795d594fSAndroid Build Coastguard Worker   }
310*795d594fSAndroid Build Coastguard Worker 
311*795d594fSAndroid Build Coastguard Worker   /**
312*795d594fSAndroid Build Coastguard Worker    * The functions below are used to compare the result of optimized operations
313*795d594fSAndroid Build Coastguard Worker    * to non-optimized operations.
314*795d594fSAndroid Build Coastguard Worker    * On the left-hand side we use a non-inlined function call to ensure the
315*795d594fSAndroid Build Coastguard Worker    * optimization does not occur. The checker tests ensure that the optimization
316*795d594fSAndroid Build Coastguard Worker    * does occur on the right-hand.
317*795d594fSAndroid Build Coastguard Worker    */
318*795d594fSAndroid Build Coastguard Worker 
319*795d594fSAndroid Build Coastguard Worker   /// CHECK-START-ARM: void Main.$opt$validateExtendByteInt1(int, byte) instruction_simplifier_arm (after)
320*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
321*795d594fSAndroid Build Coastguard Worker   /// CHECK-NOT:                        DataProcWithShifterOp
322*795d594fSAndroid Build Coastguard Worker 
323*795d594fSAndroid Build Coastguard Worker   /// CHECK-START-ARM64: void Main.$opt$validateExtendByteInt1(int, byte) instruction_simplifier_arm64 (after)
324*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
325*795d594fSAndroid Build Coastguard Worker   /// CHECK-NOT:                        DataProcWithShifterOp
326*795d594fSAndroid Build Coastguard Worker 
327*795d594fSAndroid Build Coastguard Worker   /// CHECK-START-ARM64: void Main.$opt$validateExtendByteInt1(int, byte) instruction_simplifier_arm64 (after)
328*795d594fSAndroid Build Coastguard Worker   /// CHECK-NOT:                        TypeConversion
329*795d594fSAndroid Build Coastguard Worker 
$opt$validateExtendByteInt1(int a, byte b)330*795d594fSAndroid Build Coastguard Worker   public static void $opt$validateExtendByteInt1(int a, byte b) {
331*795d594fSAndroid Build Coastguard Worker     assertIntEquals(a + $noinline$byteToChar (b), a +  (char)b);
332*795d594fSAndroid Build Coastguard Worker     // Conversions byte->short and short->int are implicit; nothing to merge.
333*795d594fSAndroid Build Coastguard Worker     assertIntEquals(a + $noinline$byteToShort(b), a + (short)b);
334*795d594fSAndroid Build Coastguard Worker   }
335*795d594fSAndroid Build Coastguard Worker 
336*795d594fSAndroid Build Coastguard Worker   /// CHECK-START-ARM: void Main.$opt$validateExtendByteInt2(int, byte) instruction_simplifier_arm (after)
337*795d594fSAndroid Build Coastguard Worker   /// CHECK-NOT:                        DataProcWithShifterOp
338*795d594fSAndroid Build Coastguard Worker 
339*795d594fSAndroid Build Coastguard Worker   /// CHECK-START-ARM64: void Main.$opt$validateExtendByteInt2(int, byte) instruction_simplifier_arm64 (after)
340*795d594fSAndroid Build Coastguard Worker   /// CHECK-NOT:                        DataProcWithShifterOp
341*795d594fSAndroid Build Coastguard Worker 
$opt$validateExtendByteInt2(int a, byte b)342*795d594fSAndroid Build Coastguard Worker   public static void $opt$validateExtendByteInt2(int a, byte b) {
343*795d594fSAndroid Build Coastguard Worker     // The conversion to `int` has been optimized away, so there is nothing to merge.
344*795d594fSAndroid Build Coastguard Worker     assertIntEquals (a + $noinline$byteToInt (b), a +  (int)b);
345*795d594fSAndroid Build Coastguard Worker     // There is an environment use for `(long)b`, preventing the merge.
346*795d594fSAndroid Build Coastguard Worker     assertLongEquals(a + $noinline$byteToLong(b), a + (long)b);
347*795d594fSAndroid Build Coastguard Worker   }
348*795d594fSAndroid Build Coastguard Worker 
349*795d594fSAndroid Build Coastguard Worker   /// CHECK-START-ARM: void Main.$opt$validateExtendByteLong(long, byte) instruction_simplifier_arm (after)
350*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
351*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
352*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
353*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
354*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
355*795d594fSAndroid Build Coastguard Worker   /// CHECK-NOT:                        DataProcWithShifterOp
356*795d594fSAndroid Build Coastguard Worker 
357*795d594fSAndroid Build Coastguard Worker   /// CHECK-START-ARM: void Main.$opt$validateExtendByteLong(long, byte) instruction_simplifier_arm (after)
358*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            TypeConversion
359*795d594fSAndroid Build Coastguard Worker   /// CHECK-NOT:                        TypeConversion
360*795d594fSAndroid Build Coastguard Worker 
361*795d594fSAndroid Build Coastguard Worker   /// CHECK-START-ARM64: void Main.$opt$validateExtendByteLong(long, byte) instruction_simplifier_arm64 (after)
362*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
363*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
364*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
365*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
366*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
367*795d594fSAndroid Build Coastguard Worker   /// CHECK-NOT:                        DataProcWithShifterOp
368*795d594fSAndroid Build Coastguard Worker 
369*795d594fSAndroid Build Coastguard Worker   /// CHECK-START-ARM64: void Main.$opt$validateExtendByteLong(long, byte) instruction_simplifier_arm64 (after)
370*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            TypeConversion
371*795d594fSAndroid Build Coastguard Worker   /// CHECK-NOT:                        TypeConversion
372*795d594fSAndroid Build Coastguard Worker 
$opt$validateExtendByteLong(long a, byte b)373*795d594fSAndroid Build Coastguard Worker   public static void $opt$validateExtendByteLong(long a, byte b) {
374*795d594fSAndroid Build Coastguard Worker     // In each of the following tests, there will be a merge on the LHS.
375*795d594fSAndroid Build Coastguard Worker 
376*795d594fSAndroid Build Coastguard Worker     // The first test has an explicit byte->char conversion on RHS,
377*795d594fSAndroid Build Coastguard Worker     // followed by a conversion that is merged with the Add.
378*795d594fSAndroid Build Coastguard Worker     assertLongEquals(a + $noinline$byteToChar (b), a +  (char)b);
379*795d594fSAndroid Build Coastguard Worker     // Since conversions byte->short and byte->int are implicit, the RHS
380*795d594fSAndroid Build Coastguard Worker     // for the two tests below is the same and one is eliminated by GVN.
381*795d594fSAndroid Build Coastguard Worker     // The other is then merged to a shifter operand instruction.
382*795d594fSAndroid Build Coastguard Worker     assertLongEquals(a + $noinline$byteToShort(b), a + (short)b);
383*795d594fSAndroid Build Coastguard Worker     assertLongEquals(a + $noinline$byteToInt  (b), a +  (int)b);
384*795d594fSAndroid Build Coastguard Worker   }
385*795d594fSAndroid Build Coastguard Worker 
$opt$validateExtendByte(long a, byte b)386*795d594fSAndroid Build Coastguard Worker   public static void $opt$validateExtendByte(long a, byte b) {
387*795d594fSAndroid Build Coastguard Worker     $opt$validateExtendByteInt1((int)a, b);
388*795d594fSAndroid Build Coastguard Worker     $opt$validateExtendByteInt2((int)a, b);
389*795d594fSAndroid Build Coastguard Worker     $opt$validateExtendByteLong(a, b);
390*795d594fSAndroid Build Coastguard Worker   }
391*795d594fSAndroid Build Coastguard Worker 
392*795d594fSAndroid Build Coastguard Worker   /// CHECK-START-ARM: void Main.$opt$validateExtendCharInt1(int, char) instruction_simplifier_arm (after)
393*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
394*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
395*795d594fSAndroid Build Coastguard Worker   /// CHECK-NOT:                        DataProcWithShifterOp
396*795d594fSAndroid Build Coastguard Worker 
397*795d594fSAndroid Build Coastguard Worker   /// CHECK-START-ARM64: void Main.$opt$validateExtendCharInt1(int, char) instruction_simplifier_arm64 (after)
398*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
399*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
400*795d594fSAndroid Build Coastguard Worker 
401*795d594fSAndroid Build Coastguard Worker   /// CHECK-START-ARM64: void Main.$opt$validateExtendCharInt1(int, char) instruction_simplifier_arm64 (after)
402*795d594fSAndroid Build Coastguard Worker   /// CHECK-NOT:                        TypeConversion
403*795d594fSAndroid Build Coastguard Worker 
$opt$validateExtendCharInt1(int a, char b)404*795d594fSAndroid Build Coastguard Worker   public static void $opt$validateExtendCharInt1(int a, char b) {
405*795d594fSAndroid Build Coastguard Worker     assertIntEquals(a + $noinline$charToByte (b), a +  (byte)b);
406*795d594fSAndroid Build Coastguard Worker     assertIntEquals(a + $noinline$charToShort(b), a + (short)b);
407*795d594fSAndroid Build Coastguard Worker   }
408*795d594fSAndroid Build Coastguard Worker 
409*795d594fSAndroid Build Coastguard Worker   /// CHECK-START-ARM: void Main.$opt$validateExtendCharInt2(int, char) instruction_simplifier_arm (after)
410*795d594fSAndroid Build Coastguard Worker   /// CHECK-NOT:                        DataProcWithShifterOp
411*795d594fSAndroid Build Coastguard Worker 
412*795d594fSAndroid Build Coastguard Worker   /// CHECK-START-ARM64: void Main.$opt$validateExtendCharInt2(int, char) instruction_simplifier_arm64 (after)
413*795d594fSAndroid Build Coastguard Worker   /// CHECK-NOT:                        DataProcWithShifterOp
414*795d594fSAndroid Build Coastguard Worker 
$opt$validateExtendCharInt2(int a, char b)415*795d594fSAndroid Build Coastguard Worker   public static void $opt$validateExtendCharInt2(int a, char b) {
416*795d594fSAndroid Build Coastguard Worker     // The conversion to `int` has been optimized away, so there is nothing to merge.
417*795d594fSAndroid Build Coastguard Worker     assertIntEquals (a + $noinline$charToInt (b), a +  (int)b);
418*795d594fSAndroid Build Coastguard Worker     // There is an environment use for `(long)b` and the implicit `(long)a`, preventing the merge.
419*795d594fSAndroid Build Coastguard Worker     assertLongEquals(a + $noinline$charToLong(b), a + (long)b);
420*795d594fSAndroid Build Coastguard Worker   }
421*795d594fSAndroid Build Coastguard Worker 
422*795d594fSAndroid Build Coastguard Worker   /// CHECK-START-ARM: void Main.$opt$validateExtendCharLong(long, char) instruction_simplifier_arm (after)
423*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
424*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
425*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
426*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
427*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
428*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
429*795d594fSAndroid Build Coastguard Worker   /// CHECK-NOT:                        DataProcWithShifterOp
430*795d594fSAndroid Build Coastguard Worker 
431*795d594fSAndroid Build Coastguard Worker   /// CHECK-START-ARM: void Main.$opt$validateExtendCharLong(long, char) instruction_simplifier_arm (after)
432*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            TypeConversion
433*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            TypeConversion
434*795d594fSAndroid Build Coastguard Worker   /// CHECK-NOT:                        TypeConversion
435*795d594fSAndroid Build Coastguard Worker 
436*795d594fSAndroid Build Coastguard Worker   /// CHECK-START-ARM64: void Main.$opt$validateExtendCharLong(long, char) instruction_simplifier_arm64 (after)
437*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
438*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
439*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
440*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
441*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
442*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
443*795d594fSAndroid Build Coastguard Worker   /// CHECK-NOT:                        DataProcWithShifterOp
444*795d594fSAndroid Build Coastguard Worker 
445*795d594fSAndroid Build Coastguard Worker   /// CHECK-START-ARM64: void Main.$opt$validateExtendCharLong(long, char) instruction_simplifier_arm64 (after)
446*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            TypeConversion
447*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            TypeConversion
448*795d594fSAndroid Build Coastguard Worker   /// CHECK-NOT:                        TypeConversion
449*795d594fSAndroid Build Coastguard Worker 
$opt$validateExtendCharLong(long a, char b)450*795d594fSAndroid Build Coastguard Worker   public static void $opt$validateExtendCharLong(long a, char b) {
451*795d594fSAndroid Build Coastguard Worker     // The first two tests have a type conversion.
452*795d594fSAndroid Build Coastguard Worker     assertLongEquals(a + $noinline$charToByte (b), a +  (byte)b);
453*795d594fSAndroid Build Coastguard Worker     assertLongEquals(a + $noinline$charToShort(b), a + (short)b);
454*795d594fSAndroid Build Coastguard Worker     // On ARM64 this test does not because the conversion to `int` is optimized away.
455*795d594fSAndroid Build Coastguard Worker     assertLongEquals(a + $noinline$charToInt  (b), a +   (int)b);
456*795d594fSAndroid Build Coastguard Worker   }
457*795d594fSAndroid Build Coastguard Worker 
$opt$validateExtendChar(long a, char b)458*795d594fSAndroid Build Coastguard Worker   public static void $opt$validateExtendChar(long a, char b) {
459*795d594fSAndroid Build Coastguard Worker     $opt$validateExtendCharInt1((int)a, b);
460*795d594fSAndroid Build Coastguard Worker     $opt$validateExtendCharInt2((int)a, b);
461*795d594fSAndroid Build Coastguard Worker     $opt$validateExtendCharLong(a, b);
462*795d594fSAndroid Build Coastguard Worker   }
463*795d594fSAndroid Build Coastguard Worker 
464*795d594fSAndroid Build Coastguard Worker   /// CHECK-START-ARM: void Main.$opt$validateExtendShortInt1(int, short) instruction_simplifier_arm (after)
465*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
466*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
467*795d594fSAndroid Build Coastguard Worker   /// CHECK-NOT:                        DataProcWithShifterOp
468*795d594fSAndroid Build Coastguard Worker 
469*795d594fSAndroid Build Coastguard Worker   /// CHECK-START-ARM64: void Main.$opt$validateExtendShortInt1(int, short) instruction_simplifier_arm64 (after)
470*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
471*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
472*795d594fSAndroid Build Coastguard Worker 
473*795d594fSAndroid Build Coastguard Worker   /// CHECK-START-ARM64: void Main.$opt$validateExtendShortInt1(int, short) instruction_simplifier_arm64 (after)
474*795d594fSAndroid Build Coastguard Worker   /// CHECK-NOT:                        TypeConversion
475*795d594fSAndroid Build Coastguard Worker 
$opt$validateExtendShortInt1(int a, short b)476*795d594fSAndroid Build Coastguard Worker   public static void $opt$validateExtendShortInt1(int a, short b) {
477*795d594fSAndroid Build Coastguard Worker     assertIntEquals(a + $noinline$shortToByte (b), a + (byte)b);
478*795d594fSAndroid Build Coastguard Worker     assertIntEquals(a + $noinline$shortToChar (b), a + (char)b);
479*795d594fSAndroid Build Coastguard Worker   }
480*795d594fSAndroid Build Coastguard Worker 
481*795d594fSAndroid Build Coastguard Worker   /// CHECK-START-ARM: void Main.$opt$validateExtendShortInt2(int, short) instruction_simplifier_arm (after)
482*795d594fSAndroid Build Coastguard Worker   /// CHECK-NOT:                        DataProcWithShifterOp
483*795d594fSAndroid Build Coastguard Worker 
484*795d594fSAndroid Build Coastguard Worker   /// CHECK-START-ARM64: void Main.$opt$validateExtendShortInt2(int, short) instruction_simplifier_arm64 (after)
485*795d594fSAndroid Build Coastguard Worker   /// CHECK-NOT:                        DataProcWithShifterOp
486*795d594fSAndroid Build Coastguard Worker 
$opt$validateExtendShortInt2(int a, short b)487*795d594fSAndroid Build Coastguard Worker   public static void $opt$validateExtendShortInt2(int a, short b) {
488*795d594fSAndroid Build Coastguard Worker     // The conversion to `int` has been optimized away, so there is nothing to merge.
489*795d594fSAndroid Build Coastguard Worker     assertIntEquals (a + $noinline$shortToInt  (b), a +  (int)b);
490*795d594fSAndroid Build Coastguard Worker     // There is an environment use for `(long)b` and the implicit `(long)a`, preventing the merge.
491*795d594fSAndroid Build Coastguard Worker     assertLongEquals(a + $noinline$shortToLong (b), a + (long)b);
492*795d594fSAndroid Build Coastguard Worker   }
493*795d594fSAndroid Build Coastguard Worker 
494*795d594fSAndroid Build Coastguard Worker   /// CHECK-START-ARM: void Main.$opt$validateExtendShortLong(long, short) instruction_simplifier_arm (after)
495*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
496*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
497*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
498*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
499*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
500*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
501*795d594fSAndroid Build Coastguard Worker   /// CHECK-NOT:                        DataProcWithShifterOp
502*795d594fSAndroid Build Coastguard Worker 
503*795d594fSAndroid Build Coastguard Worker   /// CHECK-START-ARM: void Main.$opt$validateExtendShortLong(long, short) instruction_simplifier_arm (after)
504*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            TypeConversion
505*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            TypeConversion
506*795d594fSAndroid Build Coastguard Worker   /// CHECK-NOT:                        TypeConversion
507*795d594fSAndroid Build Coastguard Worker 
508*795d594fSAndroid Build Coastguard Worker   /// CHECK-START-ARM64: void Main.$opt$validateExtendShortLong(long, short) instruction_simplifier_arm64 (after)
509*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
510*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
511*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
512*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
513*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
514*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
515*795d594fSAndroid Build Coastguard Worker   /// CHECK-NOT:                        DataProcWithShifterOp
516*795d594fSAndroid Build Coastguard Worker 
517*795d594fSAndroid Build Coastguard Worker   /// CHECK-START-ARM64: void Main.$opt$validateExtendShortLong(long, short) instruction_simplifier_arm64 (after)
518*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            TypeConversion
519*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            TypeConversion
520*795d594fSAndroid Build Coastguard Worker   /// CHECK-NOT:                        TypeConversion
521*795d594fSAndroid Build Coastguard Worker 
$opt$validateExtendShortLong(long a, short b)522*795d594fSAndroid Build Coastguard Worker   public static void $opt$validateExtendShortLong(long a, short b) {
523*795d594fSAndroid Build Coastguard Worker     // The first two tests have a type conversion.
524*795d594fSAndroid Build Coastguard Worker     assertLongEquals(a + $noinline$shortToByte(b), a + (byte)b);
525*795d594fSAndroid Build Coastguard Worker     assertLongEquals(a + $noinline$shortToChar(b), a + (char)b);
526*795d594fSAndroid Build Coastguard Worker     // On ARM64 this test does not because the conversion to `int` is optimized away.
527*795d594fSAndroid Build Coastguard Worker     assertLongEquals(a + $noinline$shortToInt (b), a +  (int)b);
528*795d594fSAndroid Build Coastguard Worker   }
529*795d594fSAndroid Build Coastguard Worker 
$opt$validateExtendShort(long a, short b)530*795d594fSAndroid Build Coastguard Worker   public static void $opt$validateExtendShort(long a, short b) {
531*795d594fSAndroid Build Coastguard Worker     $opt$validateExtendShortInt1((int)a, b);
532*795d594fSAndroid Build Coastguard Worker     $opt$validateExtendShortInt2((int)a, b);
533*795d594fSAndroid Build Coastguard Worker     $opt$validateExtendShortLong(a, b);
534*795d594fSAndroid Build Coastguard Worker   }
535*795d594fSAndroid Build Coastguard Worker 
536*795d594fSAndroid Build Coastguard Worker   /// CHECK-START-ARM: void Main.$opt$validateExtendInt(long, int) instruction_simplifier_arm (after)
537*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
538*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
539*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
540*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
541*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
542*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
543*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
544*795d594fSAndroid Build Coastguard Worker   /// CHECK-NOT:                        DataProcWithShifterOp
545*795d594fSAndroid Build Coastguard Worker 
546*795d594fSAndroid Build Coastguard Worker   /// CHECK-START-ARM: void Main.$opt$validateExtendInt(long, int) instruction_simplifier_arm (after)
547*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            TypeConversion
548*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            TypeConversion
549*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            TypeConversion
550*795d594fSAndroid Build Coastguard Worker   /// CHECK-NOT:                        TypeConversion
551*795d594fSAndroid Build Coastguard Worker 
552*795d594fSAndroid Build Coastguard Worker   /// CHECK-START-ARM64: void Main.$opt$validateExtendInt(long, int) instruction_simplifier_arm64 (after)
553*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
554*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
555*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
556*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
557*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
558*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
559*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
560*795d594fSAndroid Build Coastguard Worker   /// CHECK-NOT:                        DataProcWithShifterOp
561*795d594fSAndroid Build Coastguard Worker 
562*795d594fSAndroid Build Coastguard Worker   /// CHECK-START-ARM64: void Main.$opt$validateExtendInt(long, int) instruction_simplifier_arm64 (after)
563*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            TypeConversion
564*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            TypeConversion
565*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            TypeConversion
566*795d594fSAndroid Build Coastguard Worker   /// CHECK-NOT:                        TypeConversion
567*795d594fSAndroid Build Coastguard Worker 
$opt$validateExtendInt(long a, int b)568*795d594fSAndroid Build Coastguard Worker   public static void $opt$validateExtendInt(long a, int b) {
569*795d594fSAndroid Build Coastguard Worker     // All tests have a conversion to `long`. The first three tests also have a
570*795d594fSAndroid Build Coastguard Worker     // conversion from `int` to the specified type. For each test the conversion
571*795d594fSAndroid Build Coastguard Worker     // to `long` is merged into the shifter operand.
572*795d594fSAndroid Build Coastguard Worker     assertLongEquals(a + $noinline$intToByte (b), a +  (byte)b);
573*795d594fSAndroid Build Coastguard Worker     assertLongEquals(a + $noinline$intToChar (b), a +  (char)b);
574*795d594fSAndroid Build Coastguard Worker     assertLongEquals(a + $noinline$intToShort(b), a + (short)b);
575*795d594fSAndroid Build Coastguard Worker     assertLongEquals(a + $noinline$intToLong (b), a +  (long)b);
576*795d594fSAndroid Build Coastguard Worker   }
577*795d594fSAndroid Build Coastguard Worker 
578*795d594fSAndroid Build Coastguard Worker   /// CHECK-START-ARM: void Main.$opt$validateExtendLong(long, long) instruction_simplifier_arm (after)
579*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
580*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
581*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
582*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
583*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
584*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
585*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
586*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
587*795d594fSAndroid Build Coastguard Worker   /// CHECK-NOT:                        DataProcWithShifterOp
588*795d594fSAndroid Build Coastguard Worker 
589*795d594fSAndroid Build Coastguard Worker   /// CHECK-START-ARM: void Main.$opt$validateExtendLong(long, long) instruction_simplifier_arm (after)
590*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            TypeConversion
591*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            TypeConversion
592*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            TypeConversion
593*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            TypeConversion
594*795d594fSAndroid Build Coastguard Worker   /// CHECK-NOT:                        TypeConversion
595*795d594fSAndroid Build Coastguard Worker 
596*795d594fSAndroid Build Coastguard Worker   /// CHECK-START-ARM64: void Main.$opt$validateExtendLong(long, long) instruction_simplifier_arm64 (after)
597*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
598*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
599*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
600*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
601*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
602*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
603*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
604*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
605*795d594fSAndroid Build Coastguard Worker   /// CHECK-NOT:                        DataProcWithShifterOp
606*795d594fSAndroid Build Coastguard Worker 
607*795d594fSAndroid Build Coastguard Worker   /// CHECK-START-ARM64: void Main.$opt$validateExtendLong(long, long) instruction_simplifier_arm64 (after)
608*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            TypeConversion
609*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            TypeConversion
610*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            TypeConversion
611*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            TypeConversion
612*795d594fSAndroid Build Coastguard Worker   /// CHECK-NOT:                        TypeConversion
613*795d594fSAndroid Build Coastguard Worker 
$opt$validateExtendLong(long a, long b)614*795d594fSAndroid Build Coastguard Worker   public static void $opt$validateExtendLong(long a, long b) {
615*795d594fSAndroid Build Coastguard Worker     // Each test has two conversions, from `long` and then back to `long`. The
616*795d594fSAndroid Build Coastguard Worker     // conversions to `long` are merged.
617*795d594fSAndroid Build Coastguard Worker     assertLongEquals(a + $noinline$longToByte (b), a +  (byte)b);
618*795d594fSAndroid Build Coastguard Worker     assertLongEquals(a + $noinline$longToChar (b), a +  (char)b);
619*795d594fSAndroid Build Coastguard Worker     assertLongEquals(a + $noinline$longToShort(b), a + (short)b);
620*795d594fSAndroid Build Coastguard Worker     assertLongEquals(a + $noinline$longToInt  (b), a +   (int)b);
621*795d594fSAndroid Build Coastguard Worker   }
622*795d594fSAndroid Build Coastguard Worker 
623*795d594fSAndroid Build Coastguard Worker 
$noinline$IntShl(int b, int c)624*795d594fSAndroid Build Coastguard Worker   static int $noinline$IntShl(int b, int c) {
625*795d594fSAndroid Build Coastguard Worker     return b << c;
626*795d594fSAndroid Build Coastguard Worker   }
$noinline$IntShr(int b, int c)627*795d594fSAndroid Build Coastguard Worker   static int $noinline$IntShr(int b, int c) {
628*795d594fSAndroid Build Coastguard Worker     return b >> c;
629*795d594fSAndroid Build Coastguard Worker   }
$noinline$IntUshr(int b, int c)630*795d594fSAndroid Build Coastguard Worker   static int $noinline$IntUshr(int b, int c) {
631*795d594fSAndroid Build Coastguard Worker     return b >>> c;
632*795d594fSAndroid Build Coastguard Worker   }
633*795d594fSAndroid Build Coastguard Worker 
634*795d594fSAndroid Build Coastguard Worker 
635*795d594fSAndroid Build Coastguard Worker   // Each test line below should see one merge.
636*795d594fSAndroid Build Coastguard Worker   //
637*795d594fSAndroid Build Coastguard Worker   /// CHECK-START: void Main.$opt$validateShiftInt(int, int) instruction_simplifier$after_inlining (before)
638*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            Shl
639*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            Shl
640*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            Shl
641*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            Shl
642*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            Shl
643*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            Shl
644*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            Shl
645*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            Shl
646*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            Shl
647*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            Shl
648*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            Shl
649*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            Shl
650*795d594fSAndroid Build Coastguard Worker   /// CHECK-NOT:                        Shl
651*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            Shr
652*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            Shr
653*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            Shr
654*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            Shr
655*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            Shr
656*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            Shr
657*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            Shr
658*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            Shr
659*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            Shr
660*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            Shr
661*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            Shr
662*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            Shr
663*795d594fSAndroid Build Coastguard Worker   /// CHECK-NOT:                        Shl
664*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            UShr
665*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            UShr
666*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            UShr
667*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            UShr
668*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            UShr
669*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            UShr
670*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            UShr
671*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            UShr
672*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            UShr
673*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            UShr
674*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            UShr
675*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            UShr
676*795d594fSAndroid Build Coastguard Worker   /// CHECK-NOT:                        UShr
677*795d594fSAndroid Build Coastguard Worker   //
678*795d594fSAndroid Build Coastguard Worker   // Note: simplification after inlining removes `b << 32`, `b >> 32` and `b >>> 32`.
679*795d594fSAndroid Build Coastguard Worker   //
680*795d594fSAndroid Build Coastguard Worker   /// CHECK-START: void Main.$opt$validateShiftInt(int, int) instruction_simplifier$after_inlining (after)
681*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            Shl
682*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            Shl
683*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            Shl
684*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            Shl
685*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            Shl
686*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            Shl
687*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            Shl
688*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            Shl
689*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            Shl
690*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            Shl
691*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            Shl
692*795d594fSAndroid Build Coastguard Worker   /// CHECK-NOT:                        Shl
693*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            Shr
694*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            Shr
695*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            Shr
696*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            Shr
697*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            Shr
698*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            Shr
699*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            Shr
700*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            Shr
701*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            Shr
702*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            Shr
703*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            Shr
704*795d594fSAndroid Build Coastguard Worker   /// CHECK-NOT:                        Shl
705*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            UShr
706*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            UShr
707*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            UShr
708*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            UShr
709*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            UShr
710*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            UShr
711*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            UShr
712*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            UShr
713*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            UShr
714*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            UShr
715*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            UShr
716*795d594fSAndroid Build Coastguard Worker   /// CHECK-NOT:                        UShr
717*795d594fSAndroid Build Coastguard Worker   //
718*795d594fSAndroid Build Coastguard Worker   // Note: running extra simplification after inlining and before GVN exposes the common
719*795d594fSAndroid Build Coastguard Worker   // subexpressions between shifts with larger distance `b << 62`, `b << 63` etc.
720*795d594fSAndroid Build Coastguard Worker   // and the equivalent smaller distances.
721*795d594fSAndroid Build Coastguard Worker   //
722*795d594fSAndroid Build Coastguard Worker   /// CHECK-START: void Main.$opt$validateShiftInt(int, int) GVN (after)
723*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            Shl
724*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            Shl
725*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            Shl
726*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            Shl
727*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            Shl
728*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            Shl
729*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            Shl
730*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            Shl
731*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            Shl
732*795d594fSAndroid Build Coastguard Worker   /// CHECK-NOT:                        Shl
733*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            Shr
734*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            Shr
735*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            Shr
736*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            Shr
737*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            Shr
738*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            Shr
739*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            Shr
740*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            Shr
741*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            Shr
742*795d594fSAndroid Build Coastguard Worker   /// CHECK-NOT:                        Shl
743*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            UShr
744*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            UShr
745*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            UShr
746*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            UShr
747*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            UShr
748*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            UShr
749*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            UShr
750*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            UShr
751*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            UShr
752*795d594fSAndroid Build Coastguard Worker   /// CHECK-NOT:                        UShr
753*795d594fSAndroid Build Coastguard Worker   //
754*795d594fSAndroid Build Coastguard Worker   /// CHECK-START-ARM: void Main.$opt$validateShiftInt(int, int) instruction_simplifier_arm (after)
755*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
756*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
757*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
758*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
759*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
760*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
761*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
762*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
763*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
764*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
765*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
766*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
767*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
768*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
769*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
770*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
771*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
772*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
773*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
774*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
775*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
776*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
777*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
778*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
779*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
780*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
781*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
782*795d594fSAndroid Build Coastguard Worker   /// CHECK-NOT:                        DataProcWithShifterOp
783*795d594fSAndroid Build Coastguard Worker 
784*795d594fSAndroid Build Coastguard Worker   /// CHECK-START-ARM: void Main.$opt$validateShiftInt(int, int) instruction_simplifier_arm (after)
785*795d594fSAndroid Build Coastguard Worker   /// CHECK-NOT:                        Shl
786*795d594fSAndroid Build Coastguard Worker   /// CHECK-NOT:                        Shr
787*795d594fSAndroid Build Coastguard Worker   /// CHECK-NOT:                        UShr
788*795d594fSAndroid Build Coastguard Worker 
789*795d594fSAndroid Build Coastguard Worker   /// CHECK-START-ARM64: void Main.$opt$validateShiftInt(int, int) instruction_simplifier_arm64 (after)
790*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
791*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
792*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
793*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
794*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
795*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
796*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
797*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
798*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
799*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
800*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
801*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
802*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
803*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
804*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
805*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
806*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
807*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
808*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
809*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
810*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
811*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
812*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
813*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
814*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
815*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
816*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
817*795d594fSAndroid Build Coastguard Worker   /// CHECK-NOT:                        DataProcWithShifterOp
818*795d594fSAndroid Build Coastguard Worker 
819*795d594fSAndroid Build Coastguard Worker   /// CHECK-START-ARM64: void Main.$opt$validateShiftInt(int, int) instruction_simplifier_arm64 (after)
820*795d594fSAndroid Build Coastguard Worker   /// CHECK-NOT:                        Shl
821*795d594fSAndroid Build Coastguard Worker   /// CHECK-NOT:                        Shr
822*795d594fSAndroid Build Coastguard Worker   /// CHECK-NOT:                        UShr
823*795d594fSAndroid Build Coastguard Worker 
$opt$validateShiftInt(int a, int b)824*795d594fSAndroid Build Coastguard Worker   public static void $opt$validateShiftInt(int a, int b) {
825*795d594fSAndroid Build Coastguard Worker     assertIntEquals(a + $noinline$IntShl(b, 1),   a + (b <<  1));
826*795d594fSAndroid Build Coastguard Worker     assertIntEquals(a + $noinline$IntShl(b, 6),   a + (b <<  6));
827*795d594fSAndroid Build Coastguard Worker     assertIntEquals(a + $noinline$IntShl(b, 7),   a + (b <<  7));
828*795d594fSAndroid Build Coastguard Worker     assertIntEquals(a + $noinline$IntShl(b, 8),   a + (b <<  8));
829*795d594fSAndroid Build Coastguard Worker     assertIntEquals(a + $noinline$IntShl(b, 14),  a + (b << 14));
830*795d594fSAndroid Build Coastguard Worker     assertIntEquals(a + $noinline$IntShl(b, 15),  a + (b << 15));
831*795d594fSAndroid Build Coastguard Worker     assertIntEquals(a + $noinline$IntShl(b, 16),  a + (b << 16));
832*795d594fSAndroid Build Coastguard Worker     assertIntEquals(a + $noinline$IntShl(b, 30),  a + (b << 30));
833*795d594fSAndroid Build Coastguard Worker     assertIntEquals(a + $noinline$IntShl(b, 31),  a + (b << 31));
834*795d594fSAndroid Build Coastguard Worker     assertIntEquals(a + $noinline$IntShl(b, 32),  a + (b << $opt$inline$IntConstant32()));
835*795d594fSAndroid Build Coastguard Worker     assertIntEquals(a + $noinline$IntShl(b, 62),  a + (b << $opt$inline$IntConstant62()));
836*795d594fSAndroid Build Coastguard Worker     assertIntEquals(a + $noinline$IntShl(b, 63),  a + (b << $opt$inline$IntConstant63()));
837*795d594fSAndroid Build Coastguard Worker 
838*795d594fSAndroid Build Coastguard Worker     assertIntEquals(a - $noinline$IntShr(b, 1),   a - (b >>  1));
839*795d594fSAndroid Build Coastguard Worker     assertIntEquals(a - $noinline$IntShr(b, 6),   a - (b >>  6));
840*795d594fSAndroid Build Coastguard Worker     assertIntEquals(a - $noinline$IntShr(b, 7),   a - (b >>  7));
841*795d594fSAndroid Build Coastguard Worker     assertIntEquals(a - $noinline$IntShr(b, 8),   a - (b >>  8));
842*795d594fSAndroid Build Coastguard Worker     assertIntEquals(a - $noinline$IntShr(b, 14),  a - (b >> 14));
843*795d594fSAndroid Build Coastguard Worker     assertIntEquals(a - $noinline$IntShr(b, 15),  a - (b >> 15));
844*795d594fSAndroid Build Coastguard Worker     assertIntEquals(a - $noinline$IntShr(b, 16),  a - (b >> 16));
845*795d594fSAndroid Build Coastguard Worker     assertIntEquals(a - $noinline$IntShr(b, 30),  a - (b >> 30));
846*795d594fSAndroid Build Coastguard Worker     assertIntEquals(a - $noinline$IntShr(b, 31),  a - (b >> 31));
847*795d594fSAndroid Build Coastguard Worker     assertIntEquals(a - $noinline$IntShr(b, 32),  a - (b >> $opt$inline$IntConstant32()));
848*795d594fSAndroid Build Coastguard Worker     assertIntEquals(a - $noinline$IntShr(b, 62),  a - (b >> $opt$inline$IntConstant62()));
849*795d594fSAndroid Build Coastguard Worker     assertIntEquals(a - $noinline$IntShr(b, 63),  a - (b >> $opt$inline$IntConstant63()));
850*795d594fSAndroid Build Coastguard Worker 
851*795d594fSAndroid Build Coastguard Worker     assertIntEquals(a ^ $noinline$IntUshr(b, 1),   a ^ (b >>>  1));
852*795d594fSAndroid Build Coastguard Worker     assertIntEquals(a ^ $noinline$IntUshr(b, 6),   a ^ (b >>>  6));
853*795d594fSAndroid Build Coastguard Worker     assertIntEquals(a ^ $noinline$IntUshr(b, 7),   a ^ (b >>>  7));
854*795d594fSAndroid Build Coastguard Worker     assertIntEquals(a ^ $noinline$IntUshr(b, 8),   a ^ (b >>>  8));
855*795d594fSAndroid Build Coastguard Worker     assertIntEquals(a ^ $noinline$IntUshr(b, 14),  a ^ (b >>> 14));
856*795d594fSAndroid Build Coastguard Worker     assertIntEquals(a ^ $noinline$IntUshr(b, 15),  a ^ (b >>> 15));
857*795d594fSAndroid Build Coastguard Worker     assertIntEquals(a ^ $noinline$IntUshr(b, 16),  a ^ (b >>> 16));
858*795d594fSAndroid Build Coastguard Worker     assertIntEquals(a ^ $noinline$IntUshr(b, 30),  a ^ (b >>> 30));
859*795d594fSAndroid Build Coastguard Worker     assertIntEquals(a ^ $noinline$IntUshr(b, 31),  a ^ (b >>> 31));
860*795d594fSAndroid Build Coastguard Worker     assertIntEquals(a ^ $noinline$IntUshr(b, 32),  a ^ (b >>> $opt$inline$IntConstant32()));
861*795d594fSAndroid Build Coastguard Worker     assertIntEquals(a ^ $noinline$IntUshr(b, 62),  a ^ (b >>> $opt$inline$IntConstant62()));
862*795d594fSAndroid Build Coastguard Worker     assertIntEquals(a ^ $noinline$IntUshr(b, 63),  a ^ (b >>> $opt$inline$IntConstant63()));
863*795d594fSAndroid Build Coastguard Worker   }
864*795d594fSAndroid Build Coastguard Worker 
865*795d594fSAndroid Build Coastguard Worker   // Hiding constants outside the range [0, 32) used for int shifts from Jack.
866*795d594fSAndroid Build Coastguard Worker   // (Jack extracts only the low 5 bits.)
$opt$inline$IntConstant32()867*795d594fSAndroid Build Coastguard Worker   public static int $opt$inline$IntConstant32() { return 32; }
$opt$inline$IntConstant62()868*795d594fSAndroid Build Coastguard Worker   public static int $opt$inline$IntConstant62() { return 62; }
$opt$inline$IntConstant63()869*795d594fSAndroid Build Coastguard Worker   public static int $opt$inline$IntConstant63() { return 63; }
870*795d594fSAndroid Build Coastguard Worker 
871*795d594fSAndroid Build Coastguard Worker 
$noinline$LongShl(long b, long c)872*795d594fSAndroid Build Coastguard Worker   static long $noinline$LongShl(long b, long c) {
873*795d594fSAndroid Build Coastguard Worker     return b << c;
874*795d594fSAndroid Build Coastguard Worker   }
$noinline$LongShr(long b, long c)875*795d594fSAndroid Build Coastguard Worker   static long $noinline$LongShr(long b, long c) {
876*795d594fSAndroid Build Coastguard Worker     return b >> c;
877*795d594fSAndroid Build Coastguard Worker   }
$noinline$LongUshr(long b, long c)878*795d594fSAndroid Build Coastguard Worker   static long $noinline$LongUshr(long b, long c) {
879*795d594fSAndroid Build Coastguard Worker     return b >>> c;
880*795d594fSAndroid Build Coastguard Worker   }
881*795d594fSAndroid Build Coastguard Worker 
882*795d594fSAndroid Build Coastguard Worker   // Each test line below should see one merge.
883*795d594fSAndroid Build Coastguard Worker   /// CHECK-START-ARM: long[] Main.$opt$validateShiftLong(long, long) instruction_simplifier_arm (after)
884*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
885*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
886*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
887*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
888*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
889*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
890*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
891*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
892*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
893*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
894*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
895*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
896*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
897*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
898*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
899*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
900*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
901*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
902*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
903*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
904*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
905*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
906*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
907*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
908*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
909*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
910*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
911*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
912*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
913*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
914*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
915*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
916*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
917*795d594fSAndroid Build Coastguard Worker   /// CHECK-NOT:                        DataProcWithShifterOp
918*795d594fSAndroid Build Coastguard Worker 
919*795d594fSAndroid Build Coastguard Worker   // On ARM shifts by 1 are not merged.
920*795d594fSAndroid Build Coastguard Worker   /// CHECK-START-ARM: long[] Main.$opt$validateShiftLong(long, long) instruction_simplifier_arm (after)
921*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            Shl
922*795d594fSAndroid Build Coastguard Worker   /// CHECK-NOT:                        Shl
923*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            Shr
924*795d594fSAndroid Build Coastguard Worker   /// CHECK-NOT:                        Shr
925*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            UShr
926*795d594fSAndroid Build Coastguard Worker   /// CHECK-NOT:                        UShr
927*795d594fSAndroid Build Coastguard Worker 
928*795d594fSAndroid Build Coastguard Worker   /// CHECK-START-ARM64: long[] Main.$opt$validateShiftLong(long, long) instruction_simplifier_arm64 (after)
929*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
930*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
931*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
932*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
933*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
934*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
935*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
936*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
937*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
938*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
939*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
940*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
941*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
942*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
943*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
944*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
945*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
946*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
947*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
948*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
949*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
950*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
951*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
952*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
953*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
954*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
955*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
956*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
957*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
958*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
959*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
960*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
961*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
962*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
963*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
964*795d594fSAndroid Build Coastguard Worker   /// CHECK:                            DataProcWithShifterOp
965*795d594fSAndroid Build Coastguard Worker   /// CHECK-NOT:                        DataProcWithShifterOp
966*795d594fSAndroid Build Coastguard Worker 
967*795d594fSAndroid Build Coastguard Worker   /// CHECK-START-ARM64: long[] Main.$opt$validateShiftLong(long, long) instruction_simplifier_arm64 (after)
968*795d594fSAndroid Build Coastguard Worker   /// CHECK-NOT:                        Shl
969*795d594fSAndroid Build Coastguard Worker   /// CHECK-NOT:                        Shr
970*795d594fSAndroid Build Coastguard Worker   /// CHECK-NOT:                        UShr
971*795d594fSAndroid Build Coastguard Worker 
$opt$validateShiftLong(long a, long b)972*795d594fSAndroid Build Coastguard Worker   public static long[] $opt$validateShiftLong(long a, long b) {
973*795d594fSAndroid Build Coastguard Worker     long[] results = new long[36];
974*795d594fSAndroid Build Coastguard Worker 
975*795d594fSAndroid Build Coastguard Worker     results[0] = a + (b <<  1);
976*795d594fSAndroid Build Coastguard Worker     results[1] = a + (b <<  6);
977*795d594fSAndroid Build Coastguard Worker     results[2] = a + (b <<  7);
978*795d594fSAndroid Build Coastguard Worker     results[3] = a + (b <<  8);
979*795d594fSAndroid Build Coastguard Worker     results[4] = a + (b << 14);
980*795d594fSAndroid Build Coastguard Worker     results[5] = a + (b << 15);
981*795d594fSAndroid Build Coastguard Worker     results[6] = a + (b << 16);
982*795d594fSAndroid Build Coastguard Worker     results[7] = a + (b << 30);
983*795d594fSAndroid Build Coastguard Worker     results[8] = a + (b << 31);
984*795d594fSAndroid Build Coastguard Worker     results[9] = a + (b << 32);
985*795d594fSAndroid Build Coastguard Worker     results[10] = a + (b << 62);
986*795d594fSAndroid Build Coastguard Worker     results[11] = a + (b << 63);
987*795d594fSAndroid Build Coastguard Worker 
988*795d594fSAndroid Build Coastguard Worker     results[12] = a - (b >>  1);
989*795d594fSAndroid Build Coastguard Worker     results[13] = a - (b >>  6);
990*795d594fSAndroid Build Coastguard Worker     results[14] = a - (b >>  7);
991*795d594fSAndroid Build Coastguard Worker     results[15] = a - (b >>  8);
992*795d594fSAndroid Build Coastguard Worker     results[16] = a - (b >> 14);
993*795d594fSAndroid Build Coastguard Worker     results[17] = a - (b >> 15);
994*795d594fSAndroid Build Coastguard Worker     results[18] = a - (b >> 16);
995*795d594fSAndroid Build Coastguard Worker     results[19] = a - (b >> 30);
996*795d594fSAndroid Build Coastguard Worker     results[20] = a - (b >> 31);
997*795d594fSAndroid Build Coastguard Worker     results[21] = a - (b >> 32);
998*795d594fSAndroid Build Coastguard Worker     results[22] = a - (b >> 62);
999*795d594fSAndroid Build Coastguard Worker     results[23] = a - (b >> 63);
1000*795d594fSAndroid Build Coastguard Worker 
1001*795d594fSAndroid Build Coastguard Worker     results[24] = a ^ (b >>>  1);
1002*795d594fSAndroid Build Coastguard Worker     results[25] = a ^ (b >>>  6);
1003*795d594fSAndroid Build Coastguard Worker     results[26] = a ^ (b >>>  7);
1004*795d594fSAndroid Build Coastguard Worker     results[27] = a ^ (b >>>  8);
1005*795d594fSAndroid Build Coastguard Worker     results[28] = a ^ (b >>> 14);
1006*795d594fSAndroid Build Coastguard Worker     results[29] = a ^ (b >>> 15);
1007*795d594fSAndroid Build Coastguard Worker     results[30] = a ^ (b >>> 16);
1008*795d594fSAndroid Build Coastguard Worker     results[31] = a ^ (b >>> 30);
1009*795d594fSAndroid Build Coastguard Worker     results[32] = a ^ (b >>> 31);
1010*795d594fSAndroid Build Coastguard Worker     results[33] = a ^ (b >>> 32);
1011*795d594fSAndroid Build Coastguard Worker     results[34] = a ^ (b >>> 62);
1012*795d594fSAndroid Build Coastguard Worker     results[35] = a ^ (b >>> 63);
1013*795d594fSAndroid Build Coastguard Worker 
1014*795d594fSAndroid Build Coastguard Worker     return results;
1015*795d594fSAndroid Build Coastguard Worker   }
1016*795d594fSAndroid Build Coastguard Worker 
$opt$validateShiftLongAsserts(long a, long b)1017*795d594fSAndroid Build Coastguard Worker   public static void $opt$validateShiftLongAsserts(long a, long b) {
1018*795d594fSAndroid Build Coastguard Worker     long[] results = $opt$validateShiftLong(a, b);
1019*795d594fSAndroid Build Coastguard Worker     assertIntEquals(3 * 12, results.length);
1020*795d594fSAndroid Build Coastguard Worker 
1021*795d594fSAndroid Build Coastguard Worker     assertLongEquals(a + $noinline$LongShl(b, 1),  results[0]);
1022*795d594fSAndroid Build Coastguard Worker     assertLongEquals(a + $noinline$LongShl(b, 6),  results[1]);
1023*795d594fSAndroid Build Coastguard Worker     assertLongEquals(a + $noinline$LongShl(b, 7),  results[2]);
1024*795d594fSAndroid Build Coastguard Worker     assertLongEquals(a + $noinline$LongShl(b, 8),  results[3]);
1025*795d594fSAndroid Build Coastguard Worker     assertLongEquals(a + $noinline$LongShl(b, 14), results[4]);
1026*795d594fSAndroid Build Coastguard Worker     assertLongEquals(a + $noinline$LongShl(b, 15), results[5]);
1027*795d594fSAndroid Build Coastguard Worker     assertLongEquals(a + $noinline$LongShl(b, 16), results[6]);
1028*795d594fSAndroid Build Coastguard Worker     assertLongEquals(a + $noinline$LongShl(b, 30), results[7]);
1029*795d594fSAndroid Build Coastguard Worker     assertLongEquals(a + $noinline$LongShl(b, 31), results[8]);
1030*795d594fSAndroid Build Coastguard Worker     assertLongEquals(a + $noinline$LongShl(b, 32), results[9]);
1031*795d594fSAndroid Build Coastguard Worker     assertLongEquals(a + $noinline$LongShl(b, 62), results[10]);
1032*795d594fSAndroid Build Coastguard Worker     assertLongEquals(a + $noinline$LongShl(b, 63), results[11]);
1033*795d594fSAndroid Build Coastguard Worker 
1034*795d594fSAndroid Build Coastguard Worker     assertLongEquals(a - $noinline$LongShr(b, 1),  results[12]);
1035*795d594fSAndroid Build Coastguard Worker     assertLongEquals(a - $noinline$LongShr(b, 6),  results[13]);
1036*795d594fSAndroid Build Coastguard Worker     assertLongEquals(a - $noinline$LongShr(b, 7),  results[14]);
1037*795d594fSAndroid Build Coastguard Worker     assertLongEquals(a - $noinline$LongShr(b, 8),  results[15]);
1038*795d594fSAndroid Build Coastguard Worker     assertLongEquals(a - $noinline$LongShr(b, 14), results[16]);
1039*795d594fSAndroid Build Coastguard Worker     assertLongEquals(a - $noinline$LongShr(b, 15), results[17]);
1040*795d594fSAndroid Build Coastguard Worker     assertLongEquals(a - $noinline$LongShr(b, 16), results[18]);
1041*795d594fSAndroid Build Coastguard Worker     assertLongEquals(a - $noinline$LongShr(b, 30), results[19]);
1042*795d594fSAndroid Build Coastguard Worker     assertLongEquals(a - $noinline$LongShr(b, 31), results[20]);
1043*795d594fSAndroid Build Coastguard Worker     assertLongEquals(a - $noinline$LongShr(b, 32), results[21]);
1044*795d594fSAndroid Build Coastguard Worker     assertLongEquals(a - $noinline$LongShr(b, 62), results[22]);
1045*795d594fSAndroid Build Coastguard Worker     assertLongEquals(a - $noinline$LongShr(b, 63), results[23]);
1046*795d594fSAndroid Build Coastguard Worker 
1047*795d594fSAndroid Build Coastguard Worker     assertLongEquals(a ^ $noinline$LongUshr(b, 1),  results[24]);
1048*795d594fSAndroid Build Coastguard Worker     assertLongEquals(a ^ $noinline$LongUshr(b, 6),  results[25]);
1049*795d594fSAndroid Build Coastguard Worker     assertLongEquals(a ^ $noinline$LongUshr(b, 7),  results[26]);
1050*795d594fSAndroid Build Coastguard Worker     assertLongEquals(a ^ $noinline$LongUshr(b, 8),  results[27]);
1051*795d594fSAndroid Build Coastguard Worker     assertLongEquals(a ^ $noinline$LongUshr(b, 14), results[28]);
1052*795d594fSAndroid Build Coastguard Worker     assertLongEquals(a ^ $noinline$LongUshr(b, 15), results[29]);
1053*795d594fSAndroid Build Coastguard Worker     assertLongEquals(a ^ $noinline$LongUshr(b, 16), results[30]);
1054*795d594fSAndroid Build Coastguard Worker     assertLongEquals(a ^ $noinline$LongUshr(b, 30), results[31]);
1055*795d594fSAndroid Build Coastguard Worker     assertLongEquals(a ^ $noinline$LongUshr(b, 31), results[32]);
1056*795d594fSAndroid Build Coastguard Worker     assertLongEquals(a ^ $noinline$LongUshr(b, 32), results[33]);
1057*795d594fSAndroid Build Coastguard Worker     assertLongEquals(a ^ $noinline$LongUshr(b, 62), results[34]);
1058*795d594fSAndroid Build Coastguard Worker     assertLongEquals(a ^ $noinline$LongUshr(b, 63), results[35]);
1059*795d594fSAndroid Build Coastguard Worker   }
1060*795d594fSAndroid Build Coastguard Worker 
1061*795d594fSAndroid Build Coastguard Worker 
main(String[] args)1062*795d594fSAndroid Build Coastguard Worker   public static void main(String[] args) {
1063*795d594fSAndroid Build Coastguard Worker     assertLongEquals(10000L - 3L, $opt$noinline$translate(10000L, (byte)3));
1064*795d594fSAndroid Build Coastguard Worker     assertLongEquals(-10000L - -3L, $opt$noinline$translate(-10000L, (byte)-3));
1065*795d594fSAndroid Build Coastguard Worker 
1066*795d594fSAndroid Build Coastguard Worker     assertIntEquals(4096, $opt$noinline$sameInput(512));
1067*795d594fSAndroid Build Coastguard Worker     assertIntEquals(-8192, $opt$noinline$sameInput(-1024));
1068*795d594fSAndroid Build Coastguard Worker 
1069*795d594fSAndroid Build Coastguard Worker     assertIntEquals(((1 << 23) | 1), $opt$noinline$multipleUses(1));
1070*795d594fSAndroid Build Coastguard Worker     assertIntEquals(((1 << 20) | 5), $opt$noinline$multipleUses(1 << 20));
1071*795d594fSAndroid Build Coastguard Worker 
1072*795d594fSAndroid Build Coastguard Worker     long inputs[] = {
1073*795d594fSAndroid Build Coastguard Worker       -((1L <<  7) - 1L), -((1L <<  7)), -((1L <<  7) + 1L),
1074*795d594fSAndroid Build Coastguard Worker       -((1L << 15) - 1L), -((1L << 15)), -((1L << 15) + 1L),
1075*795d594fSAndroid Build Coastguard Worker       -((1L << 16) - 1L), -((1L << 16)), -((1L << 16) + 1L),
1076*795d594fSAndroid Build Coastguard Worker       -((1L << 31) - 1L), -((1L << 31)), -((1L << 31) + 1L),
1077*795d594fSAndroid Build Coastguard Worker       -((1L << 32) - 1L), -((1L << 32)), -((1L << 32) + 1L),
1078*795d594fSAndroid Build Coastguard Worker       -((1L << 63) - 1L), -((1L << 63)), -((1L << 63) + 1L),
1079*795d594fSAndroid Build Coastguard Worker       -42L, -314L, -2718281828L, -0x123456789L, -0x987654321L,
1080*795d594fSAndroid Build Coastguard Worker       -1L, -20L, -300L, -4000L, -50000L, -600000L, -7000000L, -80000000L,
1081*795d594fSAndroid Build Coastguard Worker       0L,
1082*795d594fSAndroid Build Coastguard Worker       1L, 20L, 300L, 4000L, 50000L, 600000L, 7000000L, 80000000L,
1083*795d594fSAndroid Build Coastguard Worker       42L,  314L,  2718281828L,  0x123456789L,  0x987654321L,
1084*795d594fSAndroid Build Coastguard Worker       (1L <<  7) - 1L, (1L <<  7), (1L <<  7) + 1L,
1085*795d594fSAndroid Build Coastguard Worker       (1L <<  8) - 1L, (1L <<  8), (1L <<  8) + 1L,
1086*795d594fSAndroid Build Coastguard Worker       (1L << 15) - 1L, (1L << 15), (1L << 15) + 1L,
1087*795d594fSAndroid Build Coastguard Worker       (1L << 16) - 1L, (1L << 16), (1L << 16) + 1L,
1088*795d594fSAndroid Build Coastguard Worker       (1L << 31) - 1L, (1L << 31), (1L << 31) + 1L,
1089*795d594fSAndroid Build Coastguard Worker       (1L << 32) - 1L, (1L << 32), (1L << 32) + 1L,
1090*795d594fSAndroid Build Coastguard Worker       (1L << 63) - 1L, (1L << 63), (1L << 63) + 1L,
1091*795d594fSAndroid Build Coastguard Worker       Long.MIN_VALUE, Long.MAX_VALUE
1092*795d594fSAndroid Build Coastguard Worker     };
1093*795d594fSAndroid Build Coastguard Worker     for (int i = 0; i < inputs.length; i++) {
1094*795d594fSAndroid Build Coastguard Worker       $opt$noinline$testNeg((int)inputs[i]);
1095*795d594fSAndroid Build Coastguard Worker       for (int j = 0; j < inputs.length; j++) {
1096*795d594fSAndroid Build Coastguard Worker         $opt$noinline$testAnd(inputs[i], inputs[j]);
1097*795d594fSAndroid Build Coastguard Worker         $opt$noinline$testOr((int)inputs[i], (int)inputs[j]);
1098*795d594fSAndroid Build Coastguard Worker         $opt$noinline$testXor(inputs[i], inputs[j]);
1099*795d594fSAndroid Build Coastguard Worker 
1100*795d594fSAndroid Build Coastguard Worker         $opt$validateExtendByte(inputs[i], (byte)inputs[j]);
1101*795d594fSAndroid Build Coastguard Worker         $opt$validateExtendChar(inputs[i], (char)inputs[j]);
1102*795d594fSAndroid Build Coastguard Worker         $opt$validateExtendShort(inputs[i], (short)inputs[j]);
1103*795d594fSAndroid Build Coastguard Worker         $opt$validateExtendInt(inputs[i], (int)inputs[j]);
1104*795d594fSAndroid Build Coastguard Worker         $opt$validateExtendLong(inputs[i], inputs[j]);
1105*795d594fSAndroid Build Coastguard Worker 
1106*795d594fSAndroid Build Coastguard Worker         $opt$validateShiftInt((int)inputs[i], (int)inputs[j]);
1107*795d594fSAndroid Build Coastguard Worker         $opt$validateShiftLongAsserts(inputs[i], inputs[j]);
1108*795d594fSAndroid Build Coastguard Worker       }
1109*795d594fSAndroid Build Coastguard Worker     }
1110*795d594fSAndroid Build Coastguard Worker 
1111*795d594fSAndroid Build Coastguard Worker   }
1112*795d594fSAndroid Build Coastguard Worker }
1113