summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/radeonsi/si_shader.c
diff options
context:
space:
mode:
authorNicolai Hähnle <nicolai.haehnle@amd.com>2016-08-08 23:52:06 +0200
committerNicolai Hähnle <nicolai.haehnle@amd.com>2016-08-17 12:11:24 +0200
commitea283779be851a9bea60a0a4f2e979706d72230a (patch)
tree787b81a7524f412aeff2941e16cbba35a0fe615b /src/gallium/drivers/radeonsi/si_shader.c
parent8916d1e2fae61c532e1e2013f0f76122ed1916b7 (diff)
downloadexternal_mesa3d-ea283779be851a9bea60a0a4f2e979706d72230a.zip
external_mesa3d-ea283779be851a9bea60a0a4f2e979706d72230a.tar.gz
external_mesa3d-ea283779be851a9bea60a0a4f2e979706d72230a.tar.bz2
gallium/radeon: add radeon_llvm_bound_index for bounds checking
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Diffstat (limited to 'src/gallium/drivers/radeonsi/si_shader.c')
-rw-r--r--src/gallium/drivers/radeonsi/si_shader.c19
1 files changed, 1 insertions, 18 deletions
diff --git a/src/gallium/drivers/radeonsi/si_shader.c b/src/gallium/drivers/radeonsi/si_shader.c
index 06b5c9c..a5b566e 100644
--- a/src/gallium/drivers/radeonsi/si_shader.c
+++ b/src/gallium/drivers/radeonsi/si_shader.c
@@ -565,11 +565,7 @@ static LLVMValueRef get_bounded_indirect_index(struct si_shader_context *ctx,
const struct tgsi_ind_register *ind,
int rel_index, unsigned num)
{
- struct gallivm_state *gallivm = &ctx->radeon_bld.gallivm;
- LLVMBuilderRef builder = gallivm->builder;
LLVMValueRef result = get_indirect_index(ctx, ind, rel_index);
- LLVMValueRef c_max = LLVMConstInt(ctx->i32, num - 1, 0);
- LLVMValueRef cc;
/* LLVM 3.8: If indirect resource indexing is used:
* - SI & CIK hang
@@ -578,20 +574,7 @@ static LLVMValueRef get_bounded_indirect_index(struct si_shader_context *ctx,
if (HAVE_LLVM <= 0x0308)
return LLVMGetUndef(ctx->i32);
- if (util_is_power_of_two(num)) {
- result = LLVMBuildAnd(builder, result, c_max, "");
- } else {
- /* In theory, this MAX pattern should result in code that is
- * as good as the bit-wise AND above.
- *
- * In practice, LLVM generates worse code (at the time of
- * writing), because its value tracking is not strong enough.
- */
- cc = LLVMBuildICmp(builder, LLVMIntULE, result, c_max, "");
- result = LLVMBuildSelect(builder, cc, result, c_max, "");
- }
-
- return result;
+ return radeon_llvm_bound_index(&ctx->radeon_bld, result, num);
}