aboutsummaryrefslogtreecommitdiff
path: root/src/llvm_backend.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2021-06-05 17:33:42 +0100
committergingerBill <bill@gingerbill.org>2021-06-05 17:33:42 +0100
commita2f2041aa68295a3e7d5c28d338b2bda7dfd1e57 (patch)
treeec66892cd0450a6805f6f9116ae4a122fbeb72a5 /src/llvm_backend.cpp
parent599d18f26f25ca29e704190f25adcaa0bb9ed4f5 (diff)
Fix `lb_build_assign_stmt_array` for `lbAddr_Swizzle`
Diffstat (limited to 'src/llvm_backend.cpp')
-rw-r--r--src/llvm_backend.cpp29
1 files changed, 28 insertions, 1 deletions
diff --git a/src/llvm_backend.cpp b/src/llvm_backend.cpp
index c77590294..7a52b298f 100644
--- a/src/llvm_backend.cpp
+++ b/src/llvm_backend.cpp
@@ -5319,9 +5319,36 @@ void lb_build_assign_stmt_array(lbProcedure *p, TokenKind op, lbAddr const &lhs,
lbValue rhs = lb_emit_conv(p, value, lhs_type);
+ bool inline_array_arith = type_size_of(array_type) <= build_context.max_align;
+
+
+ if (lhs.kind == lbAddr_Swizzle) {
+ GB_ASSERT(is_type_array(lhs_type));
+ bool indices_handled[4] = {};
+
+ // TODO(bill): Inline array arith optimization for swizzles
+ {
+ for (u8 i = 0; i < lhs.swizzle.count; i++) {
+ u8 index = lhs.swizzle.indices[i];
+ if (indices_handled[index]) {
+ continue;
+ }
+ indices_handled[index] = true;
+ lbValue lhs_ptr = lb_emit_array_epi(p, lhs.addr, index);
+ lbValue x_load = lb_emit_load(p, lhs_ptr);
+ lbValue y_load = {};
+ y_load.value = LLVMBuildExtractValue(p->builder, rhs.value, i, "");
+ y_load.type = elem_type;
+ lbValue op_value = lb_emit_arith(p, op, x_load, y_load, elem_type);
+ lb_emit_store(p, lhs_ptr, op_value);
+ }
+ }
+ return;
+ }
+
+
lbValue x = lb_addr_get_ptr(p, lhs);
- bool inline_array_arith = type_size_of(array_type) <= build_context.max_align;
if (inline_array_arith) {
#if 1