| ... | ... | @@ -8177,18 +8177,25 @@ static TypeTableEntry *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp |
| 8177 | 8177 | if (is_int && is_signed) { |
| 8178 | 8178 | bool ok = false; |
| 8179 | 8179 | if (instr_is_comptime(op1) && instr_is_comptime(op2)) { |
| 8180 | | BigNum trunc_result; |
| 8181 | | BigNum floor_result; |
| 8182 | | if (bignum_div_trunc(&trunc_result, &op1->value.data.x_bignum, &op2->value.data.x_bignum)) { |
| 8183 | | zig_unreachable(); |
| 8184 | | } |
| 8185 | | if (bignum_div_floor(&floor_result, &op1->value.data.x_bignum, &op2->value.data.x_bignum)) { |
| 8186 | | zig_unreachable(); |
| 8187 | | } |
| 8188 | | if (bignum_cmp_eq(&trunc_result, &floor_result)) { |
| 8189 | | ok = true; |
| 8180 | 				if (op2->value.data.x_bignum.data.x_uint == 0) { |
| 8181 | // the division by zero error will be caught later, but we don't have a |
| 8182 | // division function ambiguity problem. |
| 8190 | 8183 | op_id = IrBinOpDivTrunc; |
| 8191 | | } |
| 8184 | 					ok = true; |
| 8185 | 				} else { |
| 8186 | 					BigNum trunc_result; |
| 8187 | 					BigNum floor_result; |
| 8188 | 					if (bignum_div_trunc(&trunc_result, &op1->value.data.x_bignum, &op2->value.data.x_bignum)) { |
| 8189 | 						zig_unreachable(); |
| 8190 | 					} |
| 8191 | 					if (bignum_div_floor(&floor_result, &op1->value.data.x_bignum, &op2->value.data.x_bignum)) { |
| 8192 | 						zig_unreachable(); |
| 8193 | 					} |
| 8194 | 					if (bignum_cmp_eq(&trunc_result, &floor_result)) { |
| 8195 | 						ok = true; |
| 8196 | 						op_id = IrBinOpDivTrunc; |
| 8197 | 					} |
| 8198 | 				} |
| 8192 | 8199 | } |
| 8193 | 8200 | if (!ok) { |
| 8194 | 8201 | ir_add_error(ira, &bin_op_instruction->base, |
| ... | ... | @@ -8204,15 +8211,23 @@ static TypeTableEntry *ir_analyze_bin_op_math(IrAnalyze *ira, IrInstructionBinOp |
| 8204 | 8211 | if (is_signed) { |
| 8205 | 8212 | bool ok = false; |
| 8206 | 8213 | if (instr_is_comptime(op1) && instr_is_comptime(op2)) { |
| 8207 | | BigNum rem_result; |
| 8208 | | BigNum mod_result; |
| 8209 | | if (bignum_rem(&rem_result, &op1->value.data.x_bignum, &op2->value.data.x_bignum)) { |
| 8210 | | zig_unreachable(); |
| 8211 | | } |
| 8212 | | if (bignum_mod(&mod_result, &op1->value.data.x_bignum, &op2->value.data.x_bignum)) { |
| 8213 | | zig_unreachable(); |
| 8214 | if ((is_int && op2->value.data.x_bignum.data.x_uint == 0) || |
| 8215 | (!is_int && op2->value.data.x_bignum.data.x_float == 0.0)) |
| 8216 | { |
| 8217 | // the division by zero error will be caught later, but we don't |
| 8218 | // have a remainder function ambiguity problem |
| 8219 | ok = true; |
| 8220 | } else { |
| 8221 | BigNum rem_result; |
| 8222 | BigNum mod_result; |
| 8223 | if (bignum_rem(&rem_result, &op1->value.data.x_bignum, &op2->value.data.x_bignum)) { |
| 8224 | zig_unreachable(); |
| 8225 | } |
| 8226 | if (bignum_mod(&mod_result, &op1->value.data.x_bignum, &op2->value.data.x_bignum)) { |
| 8227 | zig_unreachable(); |
| 8228 | } |
| 8229 | ok = bignum_cmp_eq(&rem_result, &mod_result); |
| 8214 | 8230 | } |
| 8215 | | ok = bignum_cmp_eq(&rem_result, &mod_result); |
| 8216 | 8231 | } |
| 8217 | 8232 | if (!ok) { |
| 8218 | 8233 | ir_add_error(ira, &bin_op_instruction->base, |