mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-04 00:30:11 +01:00
ac/nir: fix lsb emission
This makes it match radeonsi. The LLVM backend itself will emit the correct instruction, but LLVM might do incorrect optimizations since it thinks the output is undefined when the input is 0, even though it's not supposed to be. We really need a new intrinsic, or for the backend to become smarter and recognize this pattern. Cc: mesa-stable@lists.freedesktop.org Reviewed-by: Bas Nieuwenhuizen <basni@google.com>
This commit is contained in:
parent
de91461575
commit
6d731c5651
1 changed files with 11 additions and 1 deletions
|
|
@ -1187,7 +1187,17 @@ static LLVMValueRef emit_find_lsb(struct ac_llvm_context *ctx,
|
|||
*/
|
||||
LLVMConstInt(ctx->i1, 1, false),
|
||||
};
|
||||
return ac_build_intrinsic(ctx, "llvm.cttz.i32", ctx->i32, params, 2, AC_FUNC_ATTR_READNONE);
|
||||
|
||||
LLVMValueRef lsb = ac_build_intrinsic(ctx, "llvm.cttz.i32", ctx->i32,
|
||||
params, 2,
|
||||
AC_FUNC_ATTR_READNONE);
|
||||
|
||||
/* TODO: We need an intrinsic to skip this conditional. */
|
||||
/* Check for zero: */
|
||||
return LLVMBuildSelect(ctx->builder, LLVMBuildICmp(ctx->builder,
|
||||
LLVMIntEQ, src0,
|
||||
ctx->i32_0, ""),
|
||||
LLVMConstInt(ctx->i32, -1, 0), lsb, "");
|
||||
}
|
||||
|
||||
static LLVMValueRef emit_ifind_msb(struct ac_llvm_context *ctx,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue