[Mesa-dev] [PATCH] freedreno/ir3: avoid using shr.b for immediate offset inputs

Ilia Mirkin imirkin at alum.mit.edu
Sun Nov 26 17:08:57 UTC 2017


Since this is all happening as a post-optimization fixup, and offsets
are generally immediates, we can just do the calculation directly.

Signed-off-by: Ilia Mirkin <imirkin at alum.mit.edu>
---

Only very mildly tested. Noticed it when looking closely at our shaders, thinking
why it tries to shift 0 by a constant. This is why.

 src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c b/src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c
index c97df4f1d63..ab326c24aa7 100644
--- a/src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c
+++ b/src/gallium/drivers/freedreno/ir3/ir3_compiler_nir.c
@@ -1351,6 +1351,7 @@ emit_intrinsic_atomic_ssbo(struct ir3_context *ctx, nir_intrinsic_instr *intr)
 	ssbo = create_immed(b, const_offset->u32[0]);
 
 	offset = get_src(ctx, &intr->src[1])[0];
+	const_offset = nir_src_as_const_value(intr->src[1]);
 
 	/* src0 is data (or uvec2(data, compare))
 	 * src1 is offset
@@ -1359,7 +1360,10 @@ emit_intrinsic_atomic_ssbo(struct ir3_context *ctx, nir_intrinsic_instr *intr)
 	 * Note that nir already multiplies the offset by four
 	 */
 	src0 = get_src(ctx, &intr->src[2])[0];
-	src1 = ir3_SHR_B(b, offset, 0, create_immed(b, 2), 0);
+	if (const_offset)
+		src1 = create_immed(b, const_offset->u32[0] >> 2);
+	else
+		src1 = ir3_SHR_B(b, offset, 0, create_immed(b, 2), 0);
 	src2 = create_collect(b, (struct ir3_instruction*[]){
 		offset,
 		create_immed(b, 0),
-- 
2.13.6



More information about the mesa-dev mailing list