src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.test/src/org/graalvm/compiler/core/test/DeMorganCanonicalizationTest.java
changeset 58877 aec7bf35d6f5
parent 52910 583fd71c47d6
equal deleted inserted replaced
58876:1a8d65e71a66 58877:aec7bf35d6f5
     1 /*
     1 /*
     2  * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2017, 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.
    27 import org.graalvm.compiler.nodes.StructuredGraph;
    27 import org.graalvm.compiler.nodes.StructuredGraph;
    28 import org.graalvm.compiler.nodes.StructuredGraph.AllowAssumptions;
    28 import org.graalvm.compiler.nodes.StructuredGraph.AllowAssumptions;
    29 import org.graalvm.compiler.nodes.calc.AndNode;
    29 import org.graalvm.compiler.nodes.calc.AndNode;
    30 import org.graalvm.compiler.nodes.calc.NotNode;
    30 import org.graalvm.compiler.nodes.calc.NotNode;
    31 import org.graalvm.compiler.nodes.calc.OrNode;
    31 import org.graalvm.compiler.nodes.calc.OrNode;
    32 import org.graalvm.compiler.phases.common.CanonicalizerPhase;
       
    33 import org.junit.Assert;
    32 import org.junit.Assert;
    34 import org.junit.Test;
    33 import org.junit.Test;
    35 
    34 
    36 public class DeMorganCanonicalizationTest extends GraalCompilerTest {
    35 public class DeMorganCanonicalizationTest extends GraalCompilerTest {
    37 
    36 
    44     }
    43     }
    45 
    44 
    46     @Test
    45     @Test
    47     public void testAnd() {
    46     public void testAnd() {
    48         StructuredGraph g = parseEager("and", AllowAssumptions.NO, getInitialOptions());
    47         StructuredGraph g = parseEager("and", AllowAssumptions.NO, getInitialOptions());
    49         new CanonicalizerPhase().apply(g, getDefaultHighTierContext());
    48         createCanonicalizerPhase().apply(g, getDefaultHighTierContext());
    50         Assert.assertEquals(1, g.getNodes().filter(OrNode.class).count());
    49         Assert.assertEquals(1, g.getNodes().filter(OrNode.class).count());
    51         Assert.assertEquals(1, g.getNodes().filter(NotNode.class).count());
    50         Assert.assertEquals(1, g.getNodes().filter(NotNode.class).count());
    52 
    51 
    53         testAgainstExpected(g.method(), new Result(and(-1, 17), null), (Object) null, -1, 17);
    52         testAgainstExpected(g.method(), new Result(and(-1, 17), null), (Object) null, -1, 17);
    54         testAgainstExpected(g.method(), new Result(and(-1, 1), null), (Object) null, -1, 1);
    53         testAgainstExpected(g.method(), new Result(and(-1, 1), null), (Object) null, -1, 1);
    57     }
    56     }
    58 
    57 
    59     @Test
    58     @Test
    60     public void testOr() {
    59     public void testOr() {
    61         StructuredGraph g = parseEager("or", AllowAssumptions.NO, getInitialOptions());
    60         StructuredGraph g = parseEager("or", AllowAssumptions.NO, getInitialOptions());
    62         new CanonicalizerPhase().apply(g, getDefaultHighTierContext());
    61         createCanonicalizerPhase().apply(g, getDefaultHighTierContext());
    63         Assert.assertEquals(1, g.getNodes().filter(AndNode.class).count());
    62         Assert.assertEquals(1, g.getNodes().filter(AndNode.class).count());
    64         Assert.assertEquals(1, g.getNodes().filter(NotNode.class).count());
    63         Assert.assertEquals(1, g.getNodes().filter(NotNode.class).count());
    65 
    64 
    66         testAgainstExpected(g.method(), new Result(or(-1, 17), null), (Object) null, -1, 17);
    65         testAgainstExpected(g.method(), new Result(or(-1, 17), null), (Object) null, -1, 17);
    67         testAgainstExpected(g.method(), new Result(or(-1, 1), null), (Object) null, -1, 1);
    66         testAgainstExpected(g.method(), new Result(or(-1, 1), null), (Object) null, -1, 1);