<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Fri, Mar 16, 2018 at 5:50 AM, Daniel Schürmann <span dir="ltr"><<a href="mailto:daniel.schuermann@campus.tu-berlin.de" target="_blank">daniel.schuermann@campus.tu-<wbr>berlin.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Signed-off-by: Daniel Schürmann <<a href="mailto:daniel.schuermann@campus.tu-berlin.de" target="_blank">daniel.schuermann@campus.tu-b<wbr>erlin.de</a>><br>
---<br>
src/amd/common/ac_llvm_build.<wbr>c | 33 ++++++++++++++++++++++++------<wbr>---<br>
1 file changed, 24 insertions(+), 9 deletions(-)<br>
<br>
diff --git a/src/amd/common/ac_llvm_build<wbr>.c b/src/amd/common/ac_llvm_build<wbr>.c<br>
index 1ae2b9dd17..67d15d5cb3 100644<br>
--- a/src/amd/common/ac_llvm_build<wbr>.c<br>
+++ b/src/amd/common/ac_llvm_build<wbr>.c<br>
@@ -407,8 +407,7 @@ ac_build_ballot(struct ac_llvm_context *ctx,<br>
*/<br>
ac_build_optimization_barrier(<wbr>ctx, &args[0]);<br>
<br>
- if (LLVMTypeOf(args[0]) != ctx->i32)<br>
- args[0] = LLVMBuildBitCast(ctx->builder, args[0], ctx->i32, "");<br>
+ args[0] = ac_to_integer(ctx, args[0]);<br>
<br>
return ac_build_intrinsic(ctx,<br>
"llvm.amdgcn.icmp.i32",<br>
@@ -1267,23 +1266,39 @@ ac_build_umsb(struct ac_llvm_context *ctx,<br>
LLVMValueRef arg,<br>
LLVMTypeRef dst_type)<br>
{<br>
- LLVMValueRef args[2] = {<br>
+ const char *intrin_name;<br>
+ LLVMTypeRef type;<br>
+ LLVMValueRef highest_bit;<br>
+ LLVMValueRef zero;<br></blockquote><div><br></div><div>add an empty line after declarations<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+ if (ac_get_elem_bits(ctx, LLVMTypeOf(arg)) == 64) {<br>
+ intrin_name = "llvm.ctlz.i64";<br>
+ type = ctx->i64;<br>
+ highest_bit = LLVMConstInt(ctx->i64, 63, false);<br>
+ zero = ctx->i64_0;<br>
+ } else {<br>
+ intrin_name = "llvm.ctlz.i32";<br>
+ type = ctx->i32;<br>
+ highest_bit = LLVMConstInt(ctx->i32, 31, false);<br>
+ zero = ctx->i32_0;<br>
+ }<br>
+<br>
+ LLVMValueRef params[2] = {<br>
arg,<br>
ctx->i1true,<br>
};<br>
- LLVMValueRef msb = ac_build_intrinsic(ctx, "llvm.ctlz.i32",<br>
- dst_type, args, ARRAY_SIZE(args),<br>
+<br>
+ LLVMValueRef msb = ac_build_intrinsic(ctx, intrin_name, type,<br>
+ params, 2,<br>
AC_FUNC_ATTR_READNONE);<br>
<br>
/* The HW returns the last bit index from MSB, but TGSI/NIR wants<br>
* the index from LSB. Invert it by doing "31 - msb". */<br>
- msb = LLVMBuildSub(ctx->builder, LLVMConstInt(ctx->i32, 31, false),<br>
- msb, "");<br>
+ msb = LLVMBuildSub(ctx->builder, highest_bit, msb, "");<br>
+ msb = LLVMBuildTruncOrBitCast(ctx->b<wbr>uilder, msb, ctx->i32, "");<br>
<br>
/* check for zero */<br>
return LLVMBuildSelect(ctx->builder,<br>
- LLVMBuildICmp(ctx->builder, LLVMIntEQ, arg,<br>
- LLVMConstInt(ctx->i32, 0, 0), ""),<br>
+ LLVMBuildICmp(ctx->builder, LLVMIntEQ, arg, zero, ""),<br>
LLVMConstInt(ctx->i32, -1, true), msb, "");<br>
}<br>
<span class="m_3609397981923354228HOEnZb"><font color="#888888"><br>
--<br>
2.14.1<br>
<br>
______________________________<wbr>_________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org" target="_blank">mesa-dev@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/<wbr>mailman/listinfo/mesa-dev</a><br>
</font></span></blockquote></div><br></div></div>