@@ -16715,16 +16715,12 @@ static IrInstGen *ir_analyze_bin_op_cmp_numeric(IrAnalyze *ira, IrInst *source_i
16715
16715
}
16716
16716
ZigType *dest_float_type = nullptr;
16717
16717
uint32_t op1_bits;
16718
- if (instr_is_comptime(op1)) {
16718
+ if (instr_is_comptime(op1) && result_type->id != ZigTypeIdVector ) {
16719
16719
ZigValue *op1_val = ir_resolve_const(ira, op1, UndefOk);
16720
16720
if (op1_val == nullptr)
16721
16721
return ira->codegen->invalid_inst_gen;
16722
16722
if (op1_val->special == ConstValSpecialUndef)
16723
16723
return ir_const_undef(ira, source_instr, ira->codegen->builtin_types.entry_bool);
16724
- if (result_type->id == ZigTypeIdVector) {
16725
- ir_add_error(ira, &op1->base, buf_sprintf("compiler bug: TODO: support comptime vector here"));
16726
- return ira->codegen->invalid_inst_gen;
16727
- }
16728
16724
bool is_unsigned;
16729
16725
if (op1_is_float) {
16730
16726
BigInt bigint = {};
@@ -16750,6 +16746,7 @@ static IrInstGen *ir_analyze_bin_op_cmp_numeric(IrAnalyze *ira, IrInst *source_i
16750
16746
op1_bits += 1;
16751
16747
}
16752
16748
} else if (op1_is_float) {
16749
+ ir_assert(op1_scalar_type->id == ZigTypeIdFloat, source_instr);
16753
16750
dest_float_type = op1_scalar_type;
16754
16751
} else {
16755
16752
ir_assert(op1_scalar_type->id == ZigTypeIdInt, source_instr);
@@ -16759,16 +16756,12 @@ static IrInstGen *ir_analyze_bin_op_cmp_numeric(IrAnalyze *ira, IrInst *source_i
16759
16756
}
16760
16757
}
16761
16758
uint32_t op2_bits;
16762
- if (instr_is_comptime(op2)) {
16759
+ if (instr_is_comptime(op2) && result_type->id != ZigTypeIdVector ) {
16763
16760
ZigValue *op2_val = ir_resolve_const(ira, op2, UndefOk);
16764
16761
if (op2_val == nullptr)
16765
16762
return ira->codegen->invalid_inst_gen;
16766
16763
if (op2_val->special == ConstValSpecialUndef)
16767
16764
return ir_const_undef(ira, source_instr, ira->codegen->builtin_types.entry_bool);
16768
- if (result_type->id == ZigTypeIdVector) {
16769
- ir_add_error(ira, &op2->base, buf_sprintf("compiler bug: TODO: support comptime vector here"));
16770
- return ira->codegen->invalid_inst_gen;
16771
- }
16772
16765
bool is_unsigned;
16773
16766
if (op2_is_float) {
16774
16767
BigInt bigint = {};
@@ -16794,6 +16787,7 @@ static IrInstGen *ir_analyze_bin_op_cmp_numeric(IrAnalyze *ira, IrInst *source_i
16794
16787
op2_bits += 1;
16795
16788
}
16796
16789
} else if (op2_is_float) {
16790
+ ir_assert(op2_scalar_type->id == ZigTypeIdFloat, source_instr);
16797
16791
dest_float_type = op2_scalar_type;
16798
16792
} else {
16799
16793
ir_assert(op2_scalar_type->id == ZigTypeIdInt, source_instr);
@@ -21934,7 +21928,17 @@ static IrInstGen *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstSrcElemP
21934
21928
return ira->codegen->invalid_inst_gen;
21935
21929
}
21936
21930
safety_check_on = false;
21931
+ } else if (array_type->id == ZigTypeIdVector) {
21932
+ uint64_t vector_len = array_type->data.vector.len;
21933
+ if (index >= vector_len) {
21934
+ ir_add_error_node(ira, elem_ptr_instruction->base.base.source_node,
21935
+ buf_sprintf("index %" ZIG_PRI_u64 " outside vector of size %" ZIG_PRI_u64,
21936
+ index, vector_len));
21937
+ return ira->codegen->invalid_inst_gen;
21938
+ }
21939
+ safety_check_on = false;
21937
21940
}
21941
+
21938
21942
if (array_type->id == ZigTypeIdVector) {
21939
21943
ZigType *elem_type = array_type->data.vector.elem_type;
21940
21944
uint32_t host_vec_len = array_type->data.vector.len;
0 commit comments