Mesa (main): r300: Fix mis-optimization turning -1 - x into 1 - x.

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Dec 7 01:18:19 UTC 2021


Module: Mesa
Branch: main
Commit: 65e343dda38a00b10715731e02938df776ef0000
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=65e343dda38a00b10715731e02938df776ef0000

Author: Emma Anholt <emma at anholt.net>
Date:   Mon Dec  6 14:03:37 2021 -0800

r300: Fix mis-optimization turning -1 - x into 1 - x.

Cc: mesa-stable

Reviewed-by: Marek Olšák <marek.olsak at amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14092>

---

 src/gallium/drivers/r300/ci/r300-rv515-fails.txt    | 21 ---------------------
 src/gallium/drivers/r300/compiler/radeon_optimize.c |  7 ++++---
 2 files changed, 4 insertions(+), 24 deletions(-)

diff --git a/src/gallium/drivers/r300/ci/r300-rv515-fails.txt b/src/gallium/drivers/r300/ci/r300-rv515-fails.txt
index db61e7abfbd..ccac7f2c53c 100644
--- a/src/gallium/drivers/r300/ci/r300-rv515-fails.txt
+++ b/src/gallium/drivers/r300/ci/r300-rv515-fails.txt
@@ -36,24 +36,6 @@ dEQP-GLES2.functional.rasterization.primitives.lines_wide,Fail
 dEQP-GLES2.functional.rasterization.primitives.line_strip_wide,Fail,Fail
 dEQP-GLES2.functional.rasterization.primitives.line_loop_wide,Fail
 
-dEQP-GLES2.functional.shaders.constant_expressions.builtin_functions.geometric.faceforward_float_fragment,Fail
-dEQP-GLES2.functional.shaders.constant_expressions.builtin_functions.geometric.faceforward_vec2_fragment,Fail
-dEQP-GLES2.functional.shaders.constant_expressions.builtin_functions.geometric.faceforward_vec3_fragment,Fail
-dEQP-GLES2.functional.shaders.constant_expressions.builtin_functions.geometric.faceforward_vec4_fragment,Fail
-dEQP-GLES2.functional.shaders.constant_expressions.builtin_functions.geometric.reflect_float_fragment,Fail
-dEQP-GLES2.functional.shaders.constant_expressions.builtin_functions.geometric.reflect_vec2_fragment,Fail
-dEQP-GLES2.functional.shaders.constant_expressions.builtin_functions.geometric.reflect_vec3_fragment,Fail
-dEQP-GLES2.functional.shaders.constant_expressions.builtin_functions.geometric.reflect_vec4_fragment,Fail
-dEQP-GLES2.functional.shaders.constant_expressions.builtin_functions.geometric.refract_float_fragment,Fail
-dEQP-GLES2.functional.shaders.constant_expressions.builtin_functions.geometric.refract_vec2_fragment,Fail
-dEQP-GLES2.functional.shaders.constant_expressions.builtin_functions.geometric.refract_vec3_fragment,Fail
-dEQP-GLES2.functional.shaders.constant_expressions.builtin_functions.geometric.refract_vec4_fragment,Fail
-
-dEQP-GLES2.functional.shaders.constant_expressions.builtin_functions.common.sign_float_fragment,Fail
-dEQP-GLES2.functional.shaders.constant_expressions.builtin_functions.common.sign_vec2_fragment,Fail
-dEQP-GLES2.functional.shaders.constant_expressions.builtin_functions.common.sign_vec3_fragment,Fail
-dEQP-GLES2.functional.shaders.constant_expressions.builtin_functions.common.sign_vec4_fragment,Fail
-
 # "Unknown opcode IF"
 dEQP-GLES2.functional.shaders.functions.control_flow.mixed_return_break_continue_vertex,Fail
 dEQP-GLES2.functional.shaders.functions.control_flow.return_in_nested_loop_vertex,Fail
@@ -205,9 +187,6 @@ dEQP-GLES2.functional.shaders.operator.exponential.pow.mediump_vec2_vertex,Fail
 dEQP-GLES2.functional.shaders.operator.exponential.pow.mediump_vec3_vertex,Fail
 dEQP-GLES2.functional.shaders.operator.exponential.pow.mediump_vec4_vertex,Fail
 
-dEQP-GLES2.functional.shaders.preprocessor.basic.empty_function_fragment,Fail
-dEQP-GLES2.functional.shaders.preprocessor.basic.empty_object_fragment,Fail
-
 # "No free temporary to use for predicate stack counter."
 dEQP-GLES2.functional.shaders.struct.local.dynamic_loop_struct_array_vertex,Fail
 dEQP-GLES2.functional.shaders.struct.local.dynamic_loop_nested_struct_array_vertex,Fail
diff --git a/src/gallium/drivers/r300/compiler/radeon_optimize.c b/src/gallium/drivers/r300/compiler/radeon_optimize.c
index df95684fcf7..c106d8d74e6 100644
--- a/src/gallium/drivers/r300/compiler/radeon_optimize.c
+++ b/src/gallium/drivers/r300/compiler/radeon_optimize.c
@@ -657,11 +657,12 @@ static int peephole_add_presub_inv(
 	/* XXX It would be nice to use is_src_uniform_constant here, but that
 	 * function only works if the register's file is RC_FILE_NONE */
 	for(i = 0; i < 4; i++ ) {
+		if (!(inst_add->U.I.DstReg.WriteMask & (1 << i)))
+			continue;
+
 		swz = GET_SWZ(inst_add->U.I.SrcReg[0].Swizzle, i);
-		if(((1 << i) & inst_add->U.I.DstReg.WriteMask)
-						&& swz != RC_SWIZZLE_ONE) {
+		if (swz != RC_SWIZZLE_ONE || inst_add->U.I.SrcReg[0].Negate & (1 << i))
 			return 0;
-		}
 	}
 
 	/* Check src1. */



More information about the mesa-commit mailing list