@@ -12,6 +12,7 @@ import io.ksmt.expr.KBvNotExpr
1212import io.ksmt.expr.KBvOrExpr
1313import io.ksmt.expr.KBvShiftLeftExpr
1414import io.ksmt.expr.KBvXorExpr
15+ import io.ksmt.expr.KBvZeroExtensionExpr
1516import io.ksmt.expr.KExpr
1617import io.ksmt.expr.KIteExpr
1718import io.ksmt.sort.KBoolSort
@@ -826,15 +827,22 @@ inline fun <T : KBvSort> KContext.simplifyBvLogicalShiftRightExprLight(
826827 shift : KExpr <T >,
827828 cont : (KExpr <T >, KExpr <T >) -> KExpr <T >
828829): KExpr <T > {
830+ val sizeBits = shift.sort.sizeBits
831+
829832 if (shift is KBitVecValue <T >) {
830833 // (x >>> 0) ==> x
831834 if (shift.isBvZero()) {
832835 return lhs
833836 }
834837
835838 // (x >>> shift), shift >= size ==> 0
836- if (shift.signedGreaterOrEqual(shift.sort.sizeBits.toInt())) {
837- return bvZero(shift.sort.sizeBits)
839+ if (shift.signedGreaterOrEqual(sizeBits.toInt())) {
840+ return bvZero(sizeBits)
841+ }
842+
843+ // ((zero-ext x E) >>> shift), shift >= sizeOf(x) ==> 0
844+ if (lhs is KBvZeroExtensionExpr && shift.signedGreaterOrEqual(lhs.value.sort.sizeBits.toInt())) {
845+ return bvZero(sizeBits)
838846 }
839847
840848 if (lhs is KBitVecValue <T >) {
@@ -844,7 +852,7 @@ inline fun <T : KBvSort> KContext.simplifyBvLogicalShiftRightExprLight(
844852
845853 // (x >>> x) ==> 0
846854 if (lhs == shift) {
847- return bvZero(shift.sort. sizeBits)
855+ return bvZero(sizeBits)
848856 }
849857
850858 return cont(lhs, shift)
0 commit comments