1 /*
2  * Copyright (C) 2016 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #include "scheduler.h"
18 
19 #include "base/arena_allocator.h"
20 #include "builder.h"
21 #include "codegen_test_utils.h"
22 #include "common_compiler_test.h"
23 #include "load_store_analysis.h"
24 #include "nodes.h"
25 #include "optimizing_unit_test.h"
26 #include "pc_relative_fixups_x86.h"
27 #include "register_allocator.h"
28 
29 #ifdef ART_ENABLE_CODEGEN_arm64
30 #include "scheduler_arm64.h"
31 #endif
32 
33 #ifdef ART_ENABLE_CODEGEN_arm
34 #include "scheduler_arm.h"
35 #endif
36 
37 namespace art {
38 
39 // Return all combinations of ISA and code generator that are executable on
40 // hardware, or on simulator, and that we'd like to test.
GetTargetConfigs()41 static ::std::vector<CodegenTargetConfig> GetTargetConfigs() {
42   ::std::vector<CodegenTargetConfig> v;
43   ::std::vector<CodegenTargetConfig> test_config_candidates = {
44 #ifdef ART_ENABLE_CODEGEN_arm
45     // TODO: Should't this be `kThumb2` instead of `kArm` here?
46     CodegenTargetConfig(InstructionSet::kArm, create_codegen_arm_vixl32),
47 #endif
48 #ifdef ART_ENABLE_CODEGEN_arm64
49     CodegenTargetConfig(InstructionSet::kArm64, create_codegen_arm64),
50 #endif
51 #ifdef ART_ENABLE_CODEGEN_x86
52     CodegenTargetConfig(InstructionSet::kX86, create_codegen_x86),
53 #endif
54 #ifdef ART_ENABLE_CODEGEN_x86_64
55     CodegenTargetConfig(InstructionSet::kX86_64, create_codegen_x86_64),
56 #endif
57   };
58 
59   for (const CodegenTargetConfig& test_config : test_config_candidates) {
60     if (CanExecute(test_config.GetInstructionSet())) {
61       v.push_back(test_config);
62     }
63   }
64 
65   return v;
66 }
67 
68 class SchedulerTest : public OptimizingUnitTest {
69  public:
SchedulerTest()70   SchedulerTest() : graph_(CreateGraph()) { }
71 
72   // Build scheduling graph, and run target specific scheduling on it.
TestBuildDependencyGraphAndSchedule(HScheduler * scheduler)73   void TestBuildDependencyGraphAndSchedule(HScheduler* scheduler) {
74     HBasicBlock* entry = new (GetAllocator()) HBasicBlock(graph_);
75     HBasicBlock* block1 = new (GetAllocator()) HBasicBlock(graph_);
76     graph_->AddBlock(entry);
77     graph_->AddBlock(block1);
78     graph_->SetEntryBlock(entry);
79 
80     // entry:
81     // array         ParameterValue
82     // c1            IntConstant
83     // c2            IntConstant
84     // block1:
85     // add1          Add [c1, c2]
86     // add2          Add [add1, c2]
87     // mul           Mul [add1, add2]
88     // div_check     DivZeroCheck [add2] (env: add2, mul)
89     // div           Div [add1, div_check]
90     // array_get1    ArrayGet [array, add1]
91     // array_set1    ArraySet [array, add1, add2]
92     // array_get2    ArrayGet [array, add1]
93     // array_set2    ArraySet [array, add1, add2]
94 
95     HInstruction* array = new (GetAllocator()) HParameterValue(graph_->GetDexFile(),
96                                                            dex::TypeIndex(0),
97                                                            0,
98                                                            DataType::Type::kReference);
99     HInstruction* c1 = graph_->GetIntConstant(1);
100     HInstruction* c2 = graph_->GetIntConstant(10);
101     HInstruction* add1 = new (GetAllocator()) HAdd(DataType::Type::kInt32, c1, c2);
102     HInstruction* add2 = new (GetAllocator()) HAdd(DataType::Type::kInt32, add1, c2);
103     HInstruction* mul = new (GetAllocator()) HMul(DataType::Type::kInt32, add1, add2);
104     HInstruction* div_check = new (GetAllocator()) HDivZeroCheck(add2, 0);
105     HInstruction* div = new (GetAllocator()) HDiv(DataType::Type::kInt32, add1, div_check, 0);
106     HInstruction* array_get1 =
107         new (GetAllocator()) HArrayGet(array, add1, DataType::Type::kInt32, 0);
108     HInstruction* array_set1 =
109         new (GetAllocator()) HArraySet(array, add1, add2, DataType::Type::kInt32, 0);
110     HInstruction* array_get2 =
111         new (GetAllocator()) HArrayGet(array, add1, DataType::Type::kInt32, 0);
112     HInstruction* array_set2 =
113         new (GetAllocator()) HArraySet(array, add1, add2, DataType::Type::kInt32, 0);
114 
115     DCHECK(div_check->CanThrow());
116 
117     entry->AddInstruction(array);
118 
119     HInstruction* block_instructions[] = {add1,
120                                           add2,
121                                           mul,
122                                           div_check,
123                                           div,
124                                           array_get1,
125                                           array_set1,
126                                           array_get2,
127                                           array_set2};
128     for (HInstruction* instr : block_instructions) {
129       block1->AddInstruction(instr);
130     }
131 
132     HEnvironment* environment = new (GetAllocator()) HEnvironment(GetAllocator(),
133                                                                   2,
134                                                                   graph_->GetArtMethod(),
135                                                                   0,
136                                                                   div_check);
137     div_check->SetRawEnvironment(environment);
138     environment->SetRawEnvAt(0, add2);
139     add2->AddEnvUseAt(div_check->GetEnvironment(), 0);
140     environment->SetRawEnvAt(1, mul);
141     mul->AddEnvUseAt(div_check->GetEnvironment(), 1);
142 
143     TestSchedulingGraph scheduling_graph(GetScopedAllocator());
144     // Instructions must be inserted in reverse order into the scheduling graph.
145     for (HInstruction* instr : ReverseRange(block_instructions)) {
146       scheduling_graph.AddNode(instr);
147     }
148 
149     // Should not have dependencies cross basic blocks.
150     ASSERT_FALSE(scheduling_graph.HasImmediateDataDependency(add1, c1));
151     ASSERT_FALSE(scheduling_graph.HasImmediateDataDependency(add2, c2));
152 
153     // Define-use dependency.
154     ASSERT_TRUE(scheduling_graph.HasImmediateDataDependency(add2, add1));
155     ASSERT_FALSE(scheduling_graph.HasImmediateDataDependency(add1, add2));
156     ASSERT_TRUE(scheduling_graph.HasImmediateDataDependency(div_check, add2));
157     ASSERT_FALSE(scheduling_graph.HasImmediateDataDependency(div_check, add1));
158     ASSERT_TRUE(scheduling_graph.HasImmediateDataDependency(div, div_check));
159     ASSERT_TRUE(scheduling_graph.HasImmediateDataDependency(array_set1, add1));
160     ASSERT_TRUE(scheduling_graph.HasImmediateDataDependency(array_set1, add2));
161 
162     // Read and write dependencies
163     ASSERT_TRUE(scheduling_graph.HasImmediateOtherDependency(array_set1, array_get1));
164     ASSERT_TRUE(scheduling_graph.HasImmediateOtherDependency(array_set2, array_get2));
165     ASSERT_TRUE(scheduling_graph.HasImmediateOtherDependency(array_get2, array_set1));
166     // Unnecessary dependency is not stored, we rely on transitive dependencies.
167     // The array_set2 -> array_get2 -> array_set1 dependencies are tested above.
168     ASSERT_FALSE(scheduling_graph.HasImmediateOtherDependency(array_set2, array_set1));
169 
170     // Env dependency.
171     ASSERT_TRUE(scheduling_graph.HasImmediateOtherDependency(div_check, mul));
172     ASSERT_FALSE(scheduling_graph.HasImmediateOtherDependency(mul, div_check));
173 
174     // CanThrow.
175     ASSERT_TRUE(scheduling_graph.HasImmediateOtherDependency(array_set1, div_check));
176 
177     // Exercise the code path of target specific scheduler and SchedulingLatencyVisitor.
178     scheduler->Schedule(graph_);
179   }
180 
CompileWithRandomSchedulerAndRun(const std::vector<uint16_t> & data,bool has_result,int expected)181   void CompileWithRandomSchedulerAndRun(const std::vector<uint16_t>& data,
182                                         bool has_result,
183                                         int expected) {
184     for (CodegenTargetConfig target_config : GetTargetConfigs()) {
185       HGraph* graph = CreateCFG(data);
186 
187       // Schedule the graph randomly.
188       HInstructionScheduling scheduling(graph, target_config.GetInstructionSet());
189       scheduling.Run(/*only_optimize_loop_blocks*/ false, /*schedule_randomly*/ true);
190 
191       OverrideInstructionSetFeatures(target_config.GetInstructionSet(), "default");
192       RunCode(target_config,
193               *compiler_options_,
194               graph,
195               [](HGraph* graph_arg) { RemoveSuspendChecks(graph_arg); },
196               has_result, expected);
197     }
198   }
199 
TestDependencyGraphOnAliasingArrayAccesses(HScheduler * scheduler)200   void TestDependencyGraphOnAliasingArrayAccesses(HScheduler* scheduler) {
201     HBasicBlock* entry = new (GetAllocator()) HBasicBlock(graph_);
202     graph_->AddBlock(entry);
203     graph_->SetEntryBlock(entry);
204     graph_->BuildDominatorTree();
205 
206     HInstruction* arr = new (GetAllocator()) HParameterValue(graph_->GetDexFile(),
207                                                              dex::TypeIndex(0),
208                                                              0,
209                                                              DataType::Type::kReference);
210     HInstruction* i = new (GetAllocator()) HParameterValue(graph_->GetDexFile(),
211                                                            dex::TypeIndex(1),
212                                                            1,
213                                                            DataType::Type::kInt32);
214     HInstruction* j = new (GetAllocator()) HParameterValue(graph_->GetDexFile(),
215                                                            dex::TypeIndex(1),
216                                                            1,
217                                                            DataType::Type::kInt32);
218     HInstruction* object = new (GetAllocator()) HParameterValue(graph_->GetDexFile(),
219                                                                 dex::TypeIndex(0),
220                                                                 0,
221                                                                 DataType::Type::kReference);
222     HInstruction* c0 = graph_->GetIntConstant(0);
223     HInstruction* c1 = graph_->GetIntConstant(1);
224     HInstruction* add0 = new (GetAllocator()) HAdd(DataType::Type::kInt32, i, c0);
225     HInstruction* add1 = new (GetAllocator()) HAdd(DataType::Type::kInt32, i, c1);
226     HInstruction* sub0 = new (GetAllocator()) HSub(DataType::Type::kInt32, i, c0);
227     HInstruction* sub1 = new (GetAllocator()) HSub(DataType::Type::kInt32, i, c1);
228     HInstruction* arr_set_0 =
229         new (GetAllocator()) HArraySet(arr, c0, c0, DataType::Type::kInt32, 0);
230     HInstruction* arr_set_1 =
231         new (GetAllocator()) HArraySet(arr, c1, c0, DataType::Type::kInt32, 0);
232     HInstruction* arr_set_i = new (GetAllocator()) HArraySet(arr, i, c0, DataType::Type::kInt32, 0);
233     HInstruction* arr_set_add0 =
234         new (GetAllocator()) HArraySet(arr, add0, c0, DataType::Type::kInt32, 0);
235     HInstruction* arr_set_add1 =
236         new (GetAllocator()) HArraySet(arr, add1, c0, DataType::Type::kInt32, 0);
237     HInstruction* arr_set_sub0 =
238         new (GetAllocator()) HArraySet(arr, sub0, c0, DataType::Type::kInt32, 0);
239     HInstruction* arr_set_sub1 =
240         new (GetAllocator()) HArraySet(arr, sub1, c0, DataType::Type::kInt32, 0);
241     HInstruction* arr_set_j = new (GetAllocator()) HArraySet(arr, j, c0, DataType::Type::kInt32, 0);
242     HInstanceFieldSet* set_field10 = new (GetAllocator()) HInstanceFieldSet(object,
243                                                                             c1,
244                                                                             nullptr,
245                                                                             DataType::Type::kInt32,
246                                                                             MemberOffset(10),
247                                                                             false,
248                                                                             kUnknownFieldIndex,
249                                                                             kUnknownClassDefIndex,
250                                                                             graph_->GetDexFile(),
251                                                                             0);
252 
253     HInstruction* block_instructions[] = {arr,
254                                           i,
255                                           j,
256                                           object,
257                                           add0,
258                                           add1,
259                                           sub0,
260                                           sub1,
261                                           arr_set_0,
262                                           arr_set_1,
263                                           arr_set_i,
264                                           arr_set_add0,
265                                           arr_set_add1,
266                                           arr_set_sub0,
267                                           arr_set_sub1,
268                                           arr_set_j,
269                                           set_field10};
270 
271     for (HInstruction* instr : block_instructions) {
272       entry->AddInstruction(instr);
273     }
274 
275     HeapLocationCollector heap_location_collector(graph_);
276     heap_location_collector.VisitBasicBlock(entry);
277     heap_location_collector.BuildAliasingMatrix();
278     TestSchedulingGraph scheduling_graph(GetScopedAllocator(), &heap_location_collector);
279 
280     for (HInstruction* instr : ReverseRange(block_instructions)) {
281       // Build scheduling graph with memory access aliasing information
282       // from LSA/heap_location_collector.
283       scheduling_graph.AddNode(instr);
284     }
285 
286     // LSA/HeapLocationCollector should see those ArraySet instructions.
287     ASSERT_EQ(heap_location_collector.GetNumberOfHeapLocations(), 9U);
288     ASSERT_TRUE(heap_location_collector.HasHeapStores());
289 
290     // Test queries on HeapLocationCollector's aliasing matrix after load store analysis.
291     // HeapLocationCollector and SchedulingGraph should report consistent relationships.
292     size_t loc1 = HeapLocationCollector::kHeapLocationNotFound;
293     size_t loc2 = HeapLocationCollector::kHeapLocationNotFound;
294 
295     // Test side effect dependency: array[0] and array[1]
296     loc1 = heap_location_collector.GetArrayHeapLocation(arr_set_0);
297     loc2 = heap_location_collector.GetArrayHeapLocation(arr_set_1);
298     ASSERT_FALSE(heap_location_collector.MayAlias(loc1, loc2));
299     ASSERT_FALSE(scheduling_graph.HasImmediateOtherDependency(arr_set_1, arr_set_0));
300 
301     // Test side effect dependency based on LSA analysis: array[i] and array[j]
302     loc1 = heap_location_collector.GetArrayHeapLocation(arr_set_i);
303     loc2 = heap_location_collector.GetArrayHeapLocation(arr_set_j);
304     ASSERT_TRUE(heap_location_collector.MayAlias(loc1, loc2));
305     // Unnecessary dependency is not stored, we rely on transitive dependencies.
306     // The arr_set_j -> arr_set_sub0 -> arr_set_add0 -> arr_set_i dependencies are tested below.
307     ASSERT_FALSE(scheduling_graph.HasImmediateOtherDependency(arr_set_j, arr_set_i));
308 
309     // Test side effect dependency based on LSA analysis: array[i] and array[i+0]
310     loc1 = heap_location_collector.GetArrayHeapLocation(arr_set_i);
311     loc2 = heap_location_collector.GetArrayHeapLocation(arr_set_add0);
312     ASSERT_TRUE(heap_location_collector.MayAlias(loc1, loc2));
313     ASSERT_TRUE(scheduling_graph.HasImmediateOtherDependency(arr_set_add0, arr_set_i));
314 
315     // Test side effect dependency based on LSA analysis: array[i] and array[i-0]
316     loc1 = heap_location_collector.GetArrayHeapLocation(arr_set_i);
317     loc2 = heap_location_collector.GetArrayHeapLocation(arr_set_sub0);
318     ASSERT_TRUE(heap_location_collector.MayAlias(loc1, loc2));
319     // Unnecessary dependency is not stored, we rely on transitive dependencies.
320     ASSERT_FALSE(scheduling_graph.HasImmediateOtherDependency(arr_set_sub0, arr_set_i));
321     // Instead, we rely on arr_set_sub0 -> arr_set_add0 -> arr_set_i, the latter is tested above.
322     ASSERT_TRUE(scheduling_graph.HasImmediateOtherDependency(arr_set_sub0, arr_set_add0));
323 
324     // Test side effect dependency based on LSA analysis: array[i] and array[i+1]
325     loc1 = heap_location_collector.GetArrayHeapLocation(arr_set_i);
326     loc2 = heap_location_collector.GetArrayHeapLocation(arr_set_add1);
327     ASSERT_FALSE(heap_location_collector.MayAlias(loc1, loc2));
328     ASSERT_FALSE(scheduling_graph.HasImmediateOtherDependency(arr_set_add1, arr_set_i));
329 
330     // Test side effect dependency based on LSA analysis: array[i+1] and array[i-1]
331     loc1 = heap_location_collector.GetArrayHeapLocation(arr_set_add1);
332     loc2 = heap_location_collector.GetArrayHeapLocation(arr_set_sub1);
333     ASSERT_FALSE(heap_location_collector.MayAlias(loc1, loc2));
334     ASSERT_FALSE(scheduling_graph.HasImmediateOtherDependency(arr_set_sub1, arr_set_add1));
335 
336     // Test side effect dependency based on LSA analysis: array[j] and all others array accesses
337     ASSERT_TRUE(scheduling_graph.HasImmediateOtherDependency(arr_set_j, arr_set_sub0));
338     ASSERT_TRUE(scheduling_graph.HasImmediateOtherDependency(arr_set_j, arr_set_add1));
339     ASSERT_TRUE(scheduling_graph.HasImmediateOtherDependency(arr_set_j, arr_set_sub1));
340     // Unnecessary dependencies are not stored, we rely on transitive dependencies.
341     ASSERT_FALSE(scheduling_graph.HasImmediateOtherDependency(arr_set_j, arr_set_i));
342     ASSERT_FALSE(scheduling_graph.HasImmediateOtherDependency(arr_set_j, arr_set_add0));
343 
344     // Test that ArraySet and FieldSet should not have side effect dependency
345     ASSERT_FALSE(scheduling_graph.HasImmediateOtherDependency(arr_set_i, set_field10));
346     ASSERT_FALSE(scheduling_graph.HasImmediateOtherDependency(arr_set_j, set_field10));
347 
348     // Exercise target specific scheduler and SchedulingLatencyVisitor.
349     scheduler->Schedule(graph_);
350   }
351 
352   class TestSchedulingGraph : public SchedulingGraph {
353    public:
TestSchedulingGraph(ScopedArenaAllocator * allocator,const HeapLocationCollector * heap_location_collector=nullptr)354     explicit TestSchedulingGraph(ScopedArenaAllocator* allocator,
355                                  const HeapLocationCollector *heap_location_collector = nullptr)
356         : SchedulingGraph(allocator, heap_location_collector) {}
357 
HasImmediateDataDependency(const HInstruction * instruction,const HInstruction * other_instruction) const358     bool HasImmediateDataDependency(const HInstruction* instruction,
359                                     const HInstruction* other_instruction) const {
360       const SchedulingNode* node = GetNode(instruction);
361       const SchedulingNode* other = GetNode(other_instruction);
362       if (node == nullptr || other == nullptr) {
363         // Both instructions must be in current basic block, i.e. the SchedulingGraph can see their
364         // corresponding SchedulingNode in the graph, and tell whether there is a dependency.
365         // Otherwise there is no dependency from SchedulingGraph's perspective, for example,
366         // instruction and other_instruction are in different basic blocks.
367         return false;
368       }
369       return node->HasDataDependency(other);
370     }
371 
HasImmediateOtherDependency(const HInstruction * instruction,const HInstruction * other_instruction) const372     bool HasImmediateOtherDependency(const HInstruction* instruction,
373                                      const HInstruction* other_instruction) const {
374       const SchedulingNode* node = GetNode(instruction);
375       const SchedulingNode* other = GetNode(other_instruction);
376       if (node == nullptr || other == nullptr) {
377         // Both instructions must be in current basic block, i.e. the SchedulingGraph can see their
378         // corresponding SchedulingNode in the graph, and tell whether there is a dependency.
379         // Otherwise there is no dependency from SchedulingGraph's perspective, for example,
380         // instruction and other_instruction are in different basic blocks.
381         return false;
382       }
383       return node->HasOtherDependency(other);
384     }
385   };
386 
387   HGraph* graph_;
388 };
389 
390 #if defined(ART_ENABLE_CODEGEN_arm64)
TEST_F(SchedulerTest,DependencyGraphAndSchedulerARM64)391 TEST_F(SchedulerTest, DependencyGraphAndSchedulerARM64) {
392   CriticalPathSchedulingNodeSelector critical_path_selector;
393   arm64::HSchedulerARM64 scheduler(&critical_path_selector);
394   TestBuildDependencyGraphAndSchedule(&scheduler);
395 }
396 
TEST_F(SchedulerTest,ArrayAccessAliasingARM64)397 TEST_F(SchedulerTest, ArrayAccessAliasingARM64) {
398   CriticalPathSchedulingNodeSelector critical_path_selector;
399   arm64::HSchedulerARM64 scheduler(&critical_path_selector);
400   TestDependencyGraphOnAliasingArrayAccesses(&scheduler);
401 }
402 #endif
403 
404 #if defined(ART_ENABLE_CODEGEN_arm)
TEST_F(SchedulerTest,DependencyGraphAndSchedulerARM)405 TEST_F(SchedulerTest, DependencyGraphAndSchedulerARM) {
406   CriticalPathSchedulingNodeSelector critical_path_selector;
407   arm::SchedulingLatencyVisitorARM arm_latency_visitor(/*CodeGenerator*/ nullptr);
408   arm::HSchedulerARM scheduler(&critical_path_selector, &arm_latency_visitor);
409   TestBuildDependencyGraphAndSchedule(&scheduler);
410 }
411 
TEST_F(SchedulerTest,ArrayAccessAliasingARM)412 TEST_F(SchedulerTest, ArrayAccessAliasingARM) {
413   CriticalPathSchedulingNodeSelector critical_path_selector;
414   arm::SchedulingLatencyVisitorARM arm_latency_visitor(/*CodeGenerator*/ nullptr);
415   arm::HSchedulerARM scheduler(&critical_path_selector, &arm_latency_visitor);
416   TestDependencyGraphOnAliasingArrayAccesses(&scheduler);
417 }
418 #endif
419 
TEST_F(SchedulerTest,RandomScheduling)420 TEST_F(SchedulerTest, RandomScheduling) {
421   //
422   // Java source: crafted code to make sure (random) scheduling should get correct result.
423   //
424   //  int result = 0;
425   //  float fr = 10.0f;
426   //  for (int i = 1; i < 10; i++) {
427   //    fr ++;
428   //    int t1 = result >> i;
429   //    int t2 = result * i;
430   //    result = result + t1 - t2;
431   //    fr = fr / i;
432   //    result += (int)fr;
433   //  }
434   //  return result;
435   //
436   const std::vector<uint16_t> data = SIX_REGISTERS_CODE_ITEM(
437     Instruction::CONST_4 | 0 << 12 | 2 << 8,          // const/4 v2, #int 0
438     Instruction::CONST_HIGH16 | 0 << 8, 0x4120,       // const/high16 v0, #float 10.0 // #41200000
439     Instruction::CONST_4 | 1 << 12 | 1 << 8,          // const/4 v1, #int 1
440     Instruction::CONST_16 | 5 << 8, 0x000a,           // const/16 v5, #int 10
441     Instruction::IF_GE | 5 << 12 | 1 << 8, 0x0014,    // if-ge v1, v5, 001a // +0014
442     Instruction::CONST_HIGH16 | 5 << 8, 0x3f80,       // const/high16 v5, #float 1.0 // #3f800000
443     Instruction::ADD_FLOAT_2ADDR | 5 << 12 | 0 << 8,  // add-float/2addr v0, v5
444     Instruction::SHR_INT | 3 << 8, 1 << 8 | 2 ,       // shr-int v3, v2, v1
445     Instruction::MUL_INT | 4 << 8, 1 << 8 | 2,        // mul-int v4, v2, v1
446     Instruction::ADD_INT | 5 << 8, 3 << 8 | 2,        // add-int v5, v2, v3
447     Instruction::SUB_INT | 2 << 8, 4 << 8 | 5,        // sub-int v2, v5, v4
448     Instruction::INT_TO_FLOAT | 1 << 12 | 5 << 8,     // int-to-float v5, v1
449     Instruction::DIV_FLOAT_2ADDR | 5 << 12 | 0 << 8,  // div-float/2addr v0, v5
450     Instruction::FLOAT_TO_INT | 0 << 12 | 5 << 8,     // float-to-int v5, v0
451     Instruction::ADD_INT_2ADDR | 5 << 12 | 2 << 8,    // add-int/2addr v2, v5
452     Instruction::ADD_INT_LIT8 | 1 << 8, 1 << 8 | 1,   // add-int/lit8 v1, v1, #int 1 // #01
453     Instruction::GOTO | 0xeb << 8,                    // goto 0004 // -0015
454     Instruction::RETURN | 2 << 8);                    // return v2
455 
456   constexpr int kNumberOfRuns = 10;
457   for (int i = 0; i < kNumberOfRuns; ++i) {
458     CompileWithRandomSchedulerAndRun(data, true, 138774);
459   }
460 }
461 
462 }  // namespace art
463