mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-07 08:08:50 +00:00
Use XOR directly rather than (~x) & mask
This commit is contained in:
@@ -182,11 +182,12 @@ gb_internal lbValue lb_emit_unary_arith(lbProcedure *p, TokenKind op, lbValue x,
|
|||||||
if (op == Token_Xor) {
|
if (op == Token_Xor) {
|
||||||
lbValue cmp = {};
|
lbValue cmp = {};
|
||||||
cmp.type = x.type;
|
cmp.type = x.type;
|
||||||
cmp.value = LLVMBuildNot(p->builder, x.value, "");
|
|
||||||
if (is_type_bit_set(x.type)) {
|
if (is_type_bit_set(x.type)) {
|
||||||
ExactValue ev_mask = exact_bit_set_all_set_mask(x.type);
|
ExactValue ev_mask = exact_bit_set_all_set_mask(x.type);
|
||||||
lbValue mask = lb_const_value(p->module, x.type, ev_mask);
|
lbValue mask = lb_const_value(p->module, x.type, ev_mask);
|
||||||
cmp.value = LLVMBuildAnd(p->builder, cmp.value, mask.value, "");
|
cmp.value = LLVMBuildXor(p->builder, x.value, mask.value, "");
|
||||||
|
} else {
|
||||||
|
cmp.value = LLVMBuildNot(p->builder, x.value, "");
|
||||||
}
|
}
|
||||||
return lb_emit_conv(p, cmp, type);
|
return lb_emit_conv(p, cmp, type);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user