Search in sources :

Example 6 with UnsignedLong

use of org.graalvm.compiler.core.common.util.UnsignedLong in project graal by oracle.

the class UnsignedLongTest method testWrappingPlus.

@Test
public void testWrappingPlus() {
    UnsignedLong fortyTwo = new UnsignedLong(42);
    Assert.assertEquals(0x1a, fortyTwo.wrappingPlus(0xffff_ffff_ffff_fff0L).asLong());
    UnsignedLong longUnsigned = new UnsignedLong(0xffff_ffff_ffff_fff0L);
    Assert.assertEquals(0x1a, longUnsigned.wrappingPlus(42).asLong());
}
Also used : UnsignedLong(org.graalvm.compiler.core.common.util.UnsignedLong) Test(org.junit.Test)

Example 7 with UnsignedLong

use of org.graalvm.compiler.core.common.util.UnsignedLong in project graal by oracle.

the class DefaultLoopPolicies method shouldFullUnroll.

@Override
public boolean shouldFullUnroll(LoopEx loop) {
    if (!loop.isCounted() || !loop.counted().isConstantMaxTripCount()) {
        return false;
    }
    OptionValues options = loop.entryPoint().getOptions();
    CountedLoopInfo counted = loop.counted();
    UnsignedLong maxTrips = counted.constantMaxTripCount();
    if (maxTrips.equals(0)) {
        return loop.canDuplicateLoop();
    }
    int maxNodes = (counted.isExactTripCount() && counted.isConstantExactTripCount()) ? Options.ExactFullUnrollMaxNodes.getValue(options) : Options.FullUnrollMaxNodes.getValue(options);
    maxNodes = Math.min(maxNodes, Math.max(0, MaximumDesiredSize.getValue(options) - loop.loopBegin().graph().getNodeCount()));
    int size = Math.max(1, loop.size() - 1 - loop.loopBegin().phis().count());
    /* @formatter:off
         * The check below should not throw ArithmeticException because:
         * maxTrips is guaranteed to be >= 1 by the check above
         * - maxTrips * size can not overfow because:
         *   - maxTrips <= FullUnrollMaxIterations <= Integer.MAX_VALUE
         *   - 1 <= size <= Integer.MAX_VALUE
         * @formatter:on
         */
    if (maxTrips.isLessOrEqualTo(Options.FullUnrollMaxIterations.getValue(options)) && maxTrips.minus(1).times(size).isLessOrEqualTo(maxNodes)) {
        // check whether we're allowed to unroll this loop
        return loop.canDuplicateLoop();
    } else {
        return false;
    }
}
Also used : OptionValues(org.graalvm.compiler.options.OptionValues) UnsignedLong(org.graalvm.compiler.core.common.util.UnsignedLong)

Example 8 with UnsignedLong

use of org.graalvm.compiler.core.common.util.UnsignedLong in project graal by oracle.

the class UnsignedLongTest method testEquals.

@Test
public void testEquals() {
    UnsignedLong fortyTwo = new UnsignedLong(42);
    Assert.assertTrue(fortyTwo.equals(42));
    Assert.assertFalse(fortyTwo.equals(99));
    UnsignedLong longFortyTwo = new UnsignedLong(0x42_0000_8888L);
    Assert.assertTrue(longFortyTwo.equals(0x42_0000_8888L));
    Assert.assertFalse(longFortyTwo.equals(0x99_0000_8888L));
    UnsignedLong longUnsigned = new UnsignedLong(0x8000_7777_0000_8888L);
    Assert.assertTrue(longUnsigned.equals(0x8000_7777_0000_8888L));
    Assert.assertFalse(longUnsigned.equals(0xf000_7777_0000_8888L));
}
Also used : UnsignedLong(org.graalvm.compiler.core.common.util.UnsignedLong) Test(org.junit.Test)

Example 9 with UnsignedLong

use of org.graalvm.compiler.core.common.util.UnsignedLong in project graal by oracle.

the class UnsignedLongTest method testMinusException2.

@Test(expected = ArithmeticException.class)
public void testMinusException2() {
    UnsignedLong longUnsigned = new UnsignedLong(0xffff_ffff_ffff_fff0L);
    longUnsigned.minus(0xffff_ffff_ffff_fff1L);
}
Also used : UnsignedLong(org.graalvm.compiler.core.common.util.UnsignedLong) Test(org.junit.Test)

Example 10 with UnsignedLong

use of org.graalvm.compiler.core.common.util.UnsignedLong in project graal by oracle.

the class UnsignedLongTest method testMinusException.

@Test(expected = ArithmeticException.class)
public void testMinusException() {
    UnsignedLong fortyTwo = new UnsignedLong(42);
    fortyTwo.minus(43);
}
Also used : UnsignedLong(org.graalvm.compiler.core.common.util.UnsignedLong) Test(org.junit.Test)

Aggregations

UnsignedLong (org.graalvm.compiler.core.common.util.UnsignedLong)14 Test (org.junit.Test)13 OptionValues (org.graalvm.compiler.options.OptionValues)1