Skip to content

Commit

Permalink
stage1: Fix caching of LLVM builtin fns
Browse files Browse the repository at this point in the history
The cache entry must take into account the fact some functions operate on scalar types and some other on vectors of scalar types.

Fixes ziglang#10147
  • Loading branch information
LemonBoy committed Nov 15, 2021
1 parent d3135f7 commit 9130502
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/stage1/codegen.cpp
Expand Up @@ -5175,11 +5175,13 @@ static LLVMValueRef get_int_builtin_fn(CodeGen *g, ZigType *expr_type, BuiltinFn
n_args = 2;
key.id = ZigLLVMFnIdCtz;
key.data.ctz.bit_count = (uint32_t)int_type->data.integral.bit_count;
key.data.ctz.vector_len = vector_len;
} else if (fn_id == BuiltinFnIdClz) {
fn_name = "ctlz";
n_args = 2;
key.id = ZigLLVMFnIdClz;
key.data.clz.bit_count = (uint32_t)int_type->data.integral.bit_count;
key.data.clz.vector_len = vector_len;
} else if (fn_id == BuiltinFnIdPopCount) {
fn_name = "ctpop";
n_args = 1;
Expand All @@ -5197,6 +5199,7 @@ static LLVMValueRef get_int_builtin_fn(CodeGen *g, ZigType *expr_type, BuiltinFn
n_args = 1;
key.id = ZigLLVMFnIdBitReverse;
key.data.bit_reverse.bit_count = (uint32_t)int_type->data.integral.bit_count;
key.data.bit_reverse.vector_len = vector_len;
} else {
zig_unreachable();
}
Expand Down

0 comments on commit 9130502

Please sign in to comment.