From 8d4602ec61f432616ae9db5316a25fd6f3522c23 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Wed, 17 May 2023 01:09:31 +0900 Subject: [PATCH] [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. --- tools/qfcc/source/expr.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tools/qfcc/source/expr.c b/tools/qfcc/source/expr.c index dbbee0ff8..130294ba7 100644 --- a/tools/qfcc/source/expr.c +++ b/tools/qfcc/source/expr.c @@ -2503,6 +2503,11 @@ array_expr (expr_t *array, expr_t *index) base = new_int_expr (0); } else { 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); } scale = new_int_expr (type_size (ele_type));