< prev index next >

src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.nodes/src/org/graalvm/compiler/nodes/calc/UnsignedRightShiftNode.java

Print this page

        

*** 1,7 **** /* ! * Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. --- 1,7 ---- /* ! * Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation.
*** 22,31 **** --- 22,32 ---- */ package org.graalvm.compiler.nodes.calc; + import jdk.vm.ci.code.CodeUtil; import org.graalvm.compiler.core.common.type.ArithmeticOpTable; import org.graalvm.compiler.core.common.type.ArithmeticOpTable.ShiftOp.UShr; import org.graalvm.compiler.core.common.type.IntegerStamp; import org.graalvm.compiler.core.common.type.Stamp; import org.graalvm.compiler.graph.NodeClass;
*** 82,95 **** } Stamp xStampGeneric = forX.stamp(view); if (xStampGeneric instanceof IntegerStamp) { IntegerStamp xStamp = (IntegerStamp) xStampGeneric; ! if (xStamp.lowerBound() >>> amount == xStamp.upperBound() >>> amount) { // The result of the shift is constant. ! return ConstantNode.forIntegerKind(stamp.getStackKind(), xStamp.lowerBound() >>> amount); } if (amount == xStamp.getBits() - 1 && xStamp.lowerBound() == -1 && xStamp.upperBound() == 0) { // Shift is equivalent to a negation, i.e., turns -1 into 1 and keeps 0 at 0. return NegateNode.create(forX, view); --- 83,99 ---- } Stamp xStampGeneric = forX.stamp(view); if (xStampGeneric instanceof IntegerStamp) { IntegerStamp xStamp = (IntegerStamp) xStampGeneric; + long xMask = CodeUtil.mask(xStamp.getBits()); + long xLowerBound = xStamp.lowerBound() & xMask; + long xUpperBound = xStamp.upperBound() & xMask; ! if (xLowerBound >>> amount == xUpperBound >>> amount) { // The result of the shift is constant. ! return ConstantNode.forIntegerKind(stamp.getStackKind(), xLowerBound >>> amount); } if (amount == xStamp.getBits() - 1 && xStamp.lowerBound() == -1 && xStamp.upperBound() == 0) { // Shift is equivalent to a negation, i.e., turns -1 into 1 and keeps 0 at 0. return NegateNode.create(forX, view);
< prev index next >