mirror of
https://github.com/odin-lang/Odin.git
synced 2026-01-05 04:27:51 +00:00
Fixed an issue with SIMD vector equality.
Comparing SIMD vectors with `==` was checking that the mask of elements that matched was not 0, meaning it succeeded if *any* element was equal, rather than if *all* elements were equal.
This commit is contained in:
@@ -3004,7 +3004,16 @@ gb_internal lbValue lb_emit_comp(lbProcedure *p, TokenKind op_kind, lbValue left
|
||||
|
||||
LLVMTypeRef mask_int_type = LLVMIntTypeInContext(p->module->ctx, cast(unsigned)(8*type_size_of(a)));
|
||||
LLVMValueRef mask_int = LLVMBuildBitCast(p->builder, mask, mask_int_type, "");
|
||||
res.value = LLVMBuildICmp(p->builder, LLVMIntNE, mask_int, LLVMConstNull(LLVMTypeOf(mask_int)), "");
|
||||
|
||||
switch (op_kind) {
|
||||
case Token_CmpEq:
|
||||
res.value = LLVMBuildICmp(p->builder, LLVMIntEQ, mask_int, LLVMConstInt(mask_int_type, U64_MAX, true), "");
|
||||
break;
|
||||
case Token_NotEq:
|
||||
res.value = LLVMBuildICmp(p->builder, LLVMIntNE, mask_int, LLVMConstNull(mask_int_type), "");
|
||||
break;
|
||||
}
|
||||
|
||||
return res;
|
||||
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user