< 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 +1,7 @@
 /*
- * Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
+ * 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,10 +22,11 @@
  */
 
 
 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,14 +83,17 @@
             }
 
             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 (xStamp.lowerBound() >>> amount == xStamp.upperBound() >>> amount) {
+                if (xLowerBound >>> amount == xUpperBound >>> amount) {
                     // The result of the shift is constant.
-                    return ConstantNode.forIntegerKind(stamp.getStackKind(), xStamp.lowerBound() >>> amount);
+                    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 >