File tree Expand file tree Collapse file tree 1 file changed +13
-2
lines changed
graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/ints Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -649,7 +649,18 @@ PInt doLLOvf(long x, long y) {
649649 return factory ().createInt (r );
650650 }
651651
652- @ Specialization
652+ @ Specialization (guards = "right == 0" )
653+ int doPIntLongZero (@ SuppressWarnings ("unused" ) PInt left , @ SuppressWarnings ("unused" ) long right ) {
654+ return 0 ;
655+ }
656+
657+ @ Specialization (guards = "right == 1" )
658+ PInt doPIntLongOne (PInt left , @ SuppressWarnings ("unused" ) long right ) {
659+ // we must return a new object with the same value
660+ return factory ().createInt (left .getValue ());
661+ }
662+
663+ @ Specialization (guards = {"right != 0" , "right != 1" })
653664 PInt doPIntLong (PInt left , long right ) {
654665 return factory ().createInt (mul (left .getValue (), BigInteger .valueOf (right )));
655666 }
@@ -661,7 +672,7 @@ PInt doPIntPInt(PInt left, PInt right) {
661672
662673 @ TruffleBoundary
663674 BigInteger mul (BigInteger a , BigInteger b ) {
664- if (b .and (b .subtract (BigInteger .ONE )).equals (BigInteger .ZERO )) {
675+ if (! BigInteger . ZERO . equals ( b ) && b .and (b .subtract (BigInteger .ONE )).equals (BigInteger .ZERO )) {
665676 return bigIntegerShift (a , b .getLowestSetBit ());
666677 } else {
667678 return bigIntegerMul (a , b );
You can’t perform that action at this time.
0 commit comments