Search in sources :

Example 11 with Condition

use of org.graalvm.compiler.core.common.calc.Condition in project graal by oracle.

the class ConditionTest method testJoin.

@Test
public void testJoin() {
    Random rand = new Random(13);
    for (Condition c1 : Condition.values()) {
        for (Condition c2 : Condition.values()) {
            Condition join = c1.join(c2);
            assertEquals(join, c2.join(c1));
            if (join != null) {
                for (int i = 0; i < 1000; i++) {
                    JavaConstant a = JavaConstant.forInt(rand.nextInt());
                    JavaConstant b = JavaConstant.forInt(i < 100 ? a.asInt() : rand.nextInt());
                    boolean result1 = c1.foldCondition(a, b, null, false);
                    boolean result2 = c2.foldCondition(a, b, null, false);
                    boolean resultJoin = join.foldCondition(a, b, null, false);
                    if (result1 && result2) {
                        assertTrue(resultJoin);
                    } else {
                        assertFalse(resultJoin);
                    }
                }
            }
        }
    }
}
Also used : Condition(org.graalvm.compiler.core.common.calc.Condition) Random(java.util.Random) JavaConstant(jdk.vm.ci.meta.JavaConstant) Test(org.junit.Test)

Example 12 with Condition

use of org.graalvm.compiler.core.common.calc.Condition in project graal by oracle.

the class ConditionTest method testImplies.

@Test
public void testImplies() {
    Random rand = new Random(13);
    for (Condition c1 : Condition.values()) {
        for (Condition c2 : Condition.values()) {
            boolean implies = c1.implies(c2);
            if (implies) {
                for (int i = 0; i < 1000; i++) {
                    JavaConstant a = JavaConstant.forInt(rand.nextInt());
                    JavaConstant b = JavaConstant.forInt(i < 100 ? a.asInt() : rand.nextInt());
                    boolean result1 = c1.foldCondition(a, b, null, false);
                    boolean result2 = c2.foldCondition(a, b, null, false);
                    if (result1) {
                        assertTrue(result2);
                    }
                }
            }
        }
    }
}
Also used : Condition(org.graalvm.compiler.core.common.calc.Condition) Random(java.util.Random) JavaConstant(jdk.vm.ci.meta.JavaConstant) Test(org.junit.Test)

Aggregations

Condition (org.graalvm.compiler.core.common.calc.Condition)12 JavaConstant (jdk.vm.ci.meta.JavaConstant)6 Value (jdk.vm.ci.meta.Value)5 AllocatableValue (jdk.vm.ci.meta.AllocatableValue)4 Random (java.util.Random)3 CanonicalCondition (org.graalvm.compiler.core.common.calc.CanonicalCondition)3 AMD64AddressValue (org.graalvm.compiler.lir.amd64.AMD64AddressValue)3 IfNode (org.graalvm.compiler.nodes.IfNode)3 ValueNode (org.graalvm.compiler.nodes.ValueNode)3 CompareNode (org.graalvm.compiler.nodes.calc.CompareNode)3 AMD64Kind (jdk.vm.ci.amd64.AMD64Kind)2 SPARCKind (jdk.vm.ci.sparc.SPARCKind)2 ConditionFlag (org.graalvm.compiler.asm.aarch64.AArch64Assembler.ConditionFlag)2 LIRKind (org.graalvm.compiler.core.common.LIRKind)2 ComplexMatchResult (org.graalvm.compiler.core.match.ComplexMatchResult)2 LabelRef (org.graalvm.compiler.lir.LabelRef)2 SPARCAddressValue (org.graalvm.compiler.lir.sparc.SPARCAddressValue)2 Test (org.junit.Test)2 AMD64 (jdk.vm.ci.amd64.AMD64)1 CPUFeature (jdk.vm.ci.amd64.AMD64.CPUFeature)1