src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.nodes.test/src/org/graalvm/compiler/nodes/test/LoopPhiCanonicalizerTest.java
branchdatagramsocketimpl-branch
changeset 58678 9cf78a70fa4f
parent 52910 583fd71c47d6
child 58679 9c3209ff7550
equal deleted inserted replaced
58677:13588c901957 58678:9cf78a70fa4f
     1 /*
     1 /*
     2  * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2013, 2019, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
    22  */
    22  */
    23 
    23 
    24 
    24 
    25 package org.graalvm.compiler.nodes.test;
    25 package org.graalvm.compiler.nodes.test;
    26 
    26 
    27 import org.junit.Assert;
       
    28 import org.junit.BeforeClass;
       
    29 import org.junit.Test;
       
    30 
       
    31 import org.graalvm.compiler.core.test.GraalCompilerTest;
    27 import org.graalvm.compiler.core.test.GraalCompilerTest;
    32 import org.graalvm.compiler.graph.iterators.NodePredicate;
    28 import org.graalvm.compiler.graph.iterators.NodePredicate;
    33 import org.graalvm.compiler.nodes.LoopBeginNode;
    29 import org.graalvm.compiler.nodes.LoopBeginNode;
    34 import org.graalvm.compiler.nodes.PhiNode;
    30 import org.graalvm.compiler.nodes.PhiNode;
    35 import org.graalvm.compiler.nodes.StructuredGraph;
    31 import org.graalvm.compiler.nodes.StructuredGraph;
    36 import org.graalvm.compiler.nodes.StructuredGraph.AllowAssumptions;
    32 import org.graalvm.compiler.nodes.StructuredGraph.AllowAssumptions;
       
    33 import org.graalvm.compiler.nodes.spi.CoreProviders;
    37 import org.graalvm.compiler.phases.common.CanonicalizerPhase;
    34 import org.graalvm.compiler.phases.common.CanonicalizerPhase;
    38 import org.graalvm.compiler.phases.tiers.PhaseContext;
    35 import org.junit.Assert;
       
    36 import org.junit.BeforeClass;
       
    37 import org.junit.Test;
    39 
    38 
    40 public class LoopPhiCanonicalizerTest extends GraalCompilerTest {
    39 public class LoopPhiCanonicalizerTest extends GraalCompilerTest {
    41 
    40 
    42     private static int[] array = new int[1000];
    41     private static int[] array = new int[1000];
    43 
    42 
    64     @Test
    63     @Test
    65     public void test() {
    64     public void test() {
    66         StructuredGraph graph = parseEager("loopSnippet", AllowAssumptions.YES);
    65         StructuredGraph graph = parseEager("loopSnippet", AllowAssumptions.YES);
    67         NodePredicate loopPhis = node -> node instanceof PhiNode && ((PhiNode) node).merge() instanceof LoopBeginNode;
    66         NodePredicate loopPhis = node -> node instanceof PhiNode && ((PhiNode) node).merge() instanceof LoopBeginNode;
    68 
    67 
    69         PhaseContext context = new PhaseContext(getProviders());
    68         CoreProviders context = getProviders();
    70         Assert.assertEquals(5, graph.getNodes().filter(loopPhis).count());
    69         Assert.assertEquals(5, graph.getNodes().filter(loopPhis).count());
    71         new CanonicalizerPhase().apply(graph, context);
    70         new CanonicalizerPhase().apply(graph, context);
    72         Assert.assertEquals(2, graph.getNodes().filter(loopPhis).count());
    71         Assert.assertEquals(2, graph.getNodes().filter(loopPhis).count());
    73 
    72 
    74         test("loopSnippet");
    73         test("loopSnippet");