@@ -415,10 +415,42 @@ long doLL(long left, long right) {
415415 return Math .floorDiv (left , right );
416416 }
417417
418+ @ Specialization (rewriteOn = ArithmeticException .class )
419+ int doLPi (int left , PInt right ) throws ArithmeticException {
420+ raiseDivisionByZero (right .isZero ());
421+ return Math .floorDiv (left , right .intValueExact ());
422+ }
423+
418424 @ Specialization
419- PInt doLPi ( long left , PInt right ) {
425+ int doLPiOvf ( int left , PInt right ) {
420426 raiseDivisionByZero (right .isZero ());
421- return factory ().createInt (op (BigInteger .valueOf (left ), right .getValue ()));
427+ try {
428+ return Math .floorDiv (left , right .intValueExact ());
429+ } catch (ArithmeticException e ) {
430+ return 0 ;
431+ }
432+ }
433+
434+ @ Specialization (rewriteOn = ArithmeticException .class )
435+ long doLPi (long left , PInt right ) throws ArithmeticException {
436+ raiseDivisionByZero (right .isZero ());
437+ return Math .floorDiv (left , right .longValueExact ());
438+ }
439+
440+ @ Specialization
441+ long doLPiOvf (long left , PInt right ) {
442+ raiseDivisionByZero (right .isZero ());
443+ try {
444+ return Math .floorDiv (left , right .longValueExact ());
445+ } catch (ArithmeticException e ) {
446+ return 0 ;
447+ }
448+ }
449+
450+ @ Specialization
451+ PInt doPiL (PInt left , int right ) {
452+ raiseDivisionByZero (right == 0 );
453+ return factory ().createInt (op (left .getValue (), BigInteger .valueOf (right )));
422454 }
423455
424456 @ Specialization
0 commit comments