@@ -9504,6 +9504,10 @@ static TypeTableEntry *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp
95049504 TypeTableEntry *resolved_type = ir_resolve_peer_types(ira, bin_op_instruction->base.source_node, instructions, 2);
95059505 if (type_is_invalid(resolved_type))
95069506 return resolved_type;
9507+ type_ensure_zero_bits_known(ira->codegen, resolved_type);
9508+ if (type_is_invalid(resolved_type))
9509+ return resolved_type;
9510+
95079511
95089512 AstNode *source_node = bin_op_instruction->base.source_node;
95099513 switch (resolved_type->id) {
@@ -9568,7 +9572,8 @@ static TypeTableEntry *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp
95689572
95699573 ConstExprValue *op1_val = &casted_op1->value;
95709574 ConstExprValue *op2_val = &casted_op2->value;
9571- if ((value_is_comptime(op1_val) && value_is_comptime(op2_val)) || resolved_type->id == TypeTableEntryIdVoid) {
9575+ bool one_possible_value = !type_requires_comptime(resolved_type) && !type_has_bits(resolved_type);
9576+ if (one_possible_value || (value_is_comptime(op1_val) && value_is_comptime(op2_val))) {
95729577 bool answer;
95739578 if (resolved_type->id == TypeTableEntryIdNumLitFloat || resolved_type->id == TypeTableEntryIdFloat) {
95749579 Cmp cmp_result = float_cmp(op1_val, op2_val);
@@ -9577,7 +9582,7 @@ static TypeTableEntry *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp
95779582 Cmp cmp_result = bigint_cmp(&op1_val->data.x_bigint, &op2_val->data.x_bigint);
95789583 answer = resolve_cmp_op_id(op_id, cmp_result);
95799584 } else {
9580- bool are_equal = resolved_type->id == TypeTableEntryIdVoid || const_values_equal(op1_val, op2_val);
9585+ bool are_equal = one_possible_value || const_values_equal(op1_val, op2_val);
95819586 if (op_id == IrBinOpCmpEq) {
95829587 answer = are_equal;
95839588 } else if (op_id == IrBinOpCmpNotEq) {
0 commit comments