#include "lp_bld_debug.h"
#include "lp_bld_const.h"
#include "lp_bld_bitarit.h"
-
+#include "lp_bld_intr.h"
/**
* Return (a | b)
assert(imm < bld->type.width);
return lp_build_shr(bld, a, b);
}
+
+LLVMValueRef
+lp_build_popcount(struct lp_build_context *bld, LLVMValueRef a)
+{
+ LLVMBuilderRef builder = bld->gallivm->builder;
+ LLVMValueRef result;
+ char intr_str[256];
+
+ lp_format_intrinsic(intr_str, sizeof(intr_str), "llvm.ctpop", bld->vec_type);
+ result = lp_build_intrinsic_unary(builder, intr_str, bld->vec_type, a);
+ return result;
+}