@@ -12,6 +12,7 @@ import io.ksmt.expr.KBvNotExpr
12
12
import io.ksmt.expr.KBvOrExpr
13
13
import io.ksmt.expr.KBvShiftLeftExpr
14
14
import io.ksmt.expr.KBvXorExpr
15
+ import io.ksmt.expr.KBvZeroExtensionExpr
15
16
import io.ksmt.expr.KExpr
16
17
import io.ksmt.expr.KIteExpr
17
18
import io.ksmt.sort.KBoolSort
@@ -826,15 +827,22 @@ inline fun <T : KBvSort> KContext.simplifyBvLogicalShiftRightExprLight(
826
827
shift : KExpr <T >,
827
828
cont : (KExpr <T >, KExpr <T >) -> KExpr <T >
828
829
): KExpr <T > {
830
+ val sizeBits = shift.sort.sizeBits
831
+
829
832
if (shift is KBitVecValue <T >) {
830
833
// (x >>> 0) ==> x
831
834
if (shift.isBvZero()) {
832
835
return lhs
833
836
}
834
837
835
838
// (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)
838
846
}
839
847
840
848
if (lhs is KBitVecValue <T >) {
@@ -844,7 +852,7 @@ inline fun <T : KBvSort> KContext.simplifyBvLogicalShiftRightExprLight(
844
852
845
853
// (x >>> x) ==> 0
846
854
if (lhs == shift) {
847
- return bvZero(shift.sort. sizeBits)
855
+ return bvZero(sizeBits)
848
856
}
849
857
850
858
return cont(lhs, shift)
0 commit comments