[qfcc] Fix indexed pointer vector indexing

The array access code was loading the vector, modifying the element,
then forgetting to write the modified vector back to whence it came.
However, that would be rather sub-optimal, so now when the vector is
accessed by a pointer, the array code switches to field access to get at
the vector element thus avoiding the need to copy the whole vector.
This commit is contained in:
Bill Currie 2023-05-17 01:09:31 +09:00
parent 0d78a865c6
commit 8d4602ec61

View file

@ -2503,6 +2503,11 @@ array_expr (expr_t *array, expr_t *index)
base = new_int_expr (0); base = new_int_expr (0);
} else { } else {
ele_type = ev_types[array_type->type]; ele_type = ev_types[array_type->type];
if (array->type == ex_uexpr && array->e.expr.op == '.') {
expr_t *vec = offset_pointer_expr (array->e.expr.e1, index);
vec = cast_expr (pointer_type (ele_type), vec);
return unary_expr ('.', vec);
}
base = new_int_expr (0); base = new_int_expr (0);
} }
scale = new_int_expr (type_size (ele_type)); scale = new_int_expr (type_size (ele_type));