| ... | @@ -13247,6 +13247,21 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp * | ... | @@ -13247,6 +13247,21 @@ static IrInstruction *ir_analyze_bin_op_cmp(IrAnalyze *ira, IrInstructionBinOp * |
| 13247 | if (type_is_invalid(casted_val->value.type)) | 13247 | if (type_is_invalid(casted_val->value.type)) |
| 13248 | return ira->codegen->invalid_instruction; | 13248 | return ira->codegen->invalid_instruction; |
| 13249 | | 13249 | |
| | 13250 | if (instr_is_comptime(casted_union)) { |
| | 13251 | ConstExprValue *const_union_val = ir_resolve_const(ira, casted_union, UndefBad); |
| | 13252 | if (!const_union_val) |
| | 13253 | return ira->codegen->invalid_instruction; |
| | 13254 | |
| | 13255 | ConstExprValue *const_enum_val = ir_resolve_const(ira, casted_val, UndefBad); |
| | 13256 | if (!const_enum_val) |
| | 13257 | return ira->codegen->invalid_instruction; |
| | 13258 | |
| | 13259 | Cmp cmp_result = bigint_cmp(&const_union_val->data.x_union.tag, &const_enum_val->data.x_enum_tag); |
| | 13260 | bool bool_result = (op_id == IrBinOpCmpEq) ? cmp_result == CmpEQ : cmp_result != CmpEQ; |
| | 13261 | |
| | 13262 | return ir_const_bool(ira, &bin_op_instruction->base, bool_result); |
| | 13263 | } |
| | 13264 | |
| 13250 | IrInstruction *result = ir_build_bin_op(&ira->new_irb, | 13265 | IrInstruction *result = ir_build_bin_op(&ira->new_irb, |
| 13251 | bin_op_instruction->base.scope, bin_op_instruction->base.source_node, | 13266 | bin_op_instruction->base.scope, bin_op_instruction->base.source_node, |
| 13252 | op_id, casted_union, casted_val, bin_op_instruction->safety_check_on); | 13267 | op_id, casted_union, casted_val, bin_op_instruction->safety_check_on); |