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) {
649
649
return factory ().createInt (r );
650
650
}
651
651
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" })
653
664
PInt doPIntLong (PInt left , long right ) {
654
665
return factory ().createInt (mul (left .getValue (), BigInteger .valueOf (right )));
655
666
}
@@ -661,7 +672,7 @@ PInt doPIntPInt(PInt left, PInt right) {
661
672
662
673
@ TruffleBoundary
663
674
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 )) {
665
676
return bigIntegerShift (a , b .getLowestSetBit ());
666
677
} else {
667
678
return bigIntegerMul (a , b );
You can’t perform that action at this time.
0 commit comments