Browse Source

Fix `simd_shuffle`

gingerBill 3 years ago
parent
commit
b95ca80f85
1 changed files with 2 additions and 1 deletions
  1. 2 1
      src/llvm_backend_proc.cpp

+ 2 - 1
src/llvm_backend_proc.cpp

@@ -1289,9 +1289,10 @@ lbValue lb_build_builtin_simd_proc(lbProcedure *p, Ast *expr, TypeAndValue const
 
 
 			i64 indices_count = ce->args.count-2;
 			i64 indices_count = ce->args.count-2;
 			i64 max_count = vt->SimdVector.count*2;
 			i64 max_count = vt->SimdVector.count*2;
+			GB_ASSERT(indices_count <= max_count);
 
 
 			LLVMValueRef *values = gb_alloc_array(temporary_allocator(), LLVMValueRef, indices_count);
 			LLVMValueRef *values = gb_alloc_array(temporary_allocator(), LLVMValueRef, indices_count);
-			for (isize i = 0; i < max_count; i++) {
+			for (isize i = 0; i < indices_count; i++) {
 				lbValue idx = lb_build_expr(p, ce->args[i+2]);
 				lbValue idx = lb_build_expr(p, ce->args[i+2]);
 				GB_ASSERT(LLVMIsConstant(idx.value));
 				GB_ASSERT(LLVMIsConstant(idx.value));
 				values[i] = idx.value;
 				values[i] = idx.value;