cgen: omit "x ~mod+= y ~mod* 0"

This commit is contained in:
Nigel Tao committed 2026-06-19 20:28:56 +10:00
1 parent 1f3df26c7f
commit 40f39a3ba3
5 files changed
+22 -235

No files matched your search

+7 -1
View File
@@ -1777,7 +1777,13 @@ func (q *checker) bcheckExprBinaryOp1(op t.ID, lhs *a.Expr, lb bounds, rhs *a.Ex
}, nil
}
case t.IDXBinaryTildeModPlus, t.IDXBinaryTildeModMinus, t.IDXBinaryTildeModStar:
case t.IDXBinaryTildeModStar:
if (lb.IsJustZero() || rb.IsJustZero()) && lhs.Effect().Pure() && rhs.Effect().Pure() {
return bounds{zero, zero}, nil
}
fallthrough
case t.IDXBinaryTildeModPlus, t.IDXBinaryTildeModMinus:
typ := lhs.MType()
if typ.IsIdeal() {
typ = rhs.MType()