[Mesa-dev] [PATCH] r300g: Fix bug in build_loop_info()
Tom Stellard
tom at stellard.net
Wed Aug 13 12:52:06 PDT 2014
On Tue, Aug 05, 2014 at 07:06:51PM +0200, David Heidelberger wrote:
> fixes piglit glean "do-loop with continue and break" on RS690
>
> It's based on Tom Stellard patch and improved to handle CMP instruction.
>
> [v2] handle CMP instruction
>
> Signed-off-by: David Heidelberger <david.heidelberger at ixit.cz>
I've pushed this, thanks!
-Tom
> ---
> .../drivers/r300/compiler/radeon_emulate_loops.c | 34
> +++++++++++++++-------
> 1 file changed, 23 insertions(+), 11 deletions(-)
>
> diff --git
> a/src/gallium/drivers/r300/compiler/radeon_emulate_loops.c
> b/src/gallium/drivers/r300/compiler/radeon_emulate_loops.c
> index 91ed9d2..25512b3 100644
> --- a/src/gallium/drivers/r300/compiler/radeon_emulate_loops.c
> +++ b/src/gallium/drivers/r300/compiler/radeon_emulate_loops.c
> @@ -368,6 +368,8 @@ static int build_loop_info(struct
> radeon_compiler * c, struct loop_info * loop,
> break;
> }
> case RC_OPCODE_BRK:
> + {
> + struct rc_src_register *src;
> if(ptr->Next->U.I.Opcode != RC_OPCODE_ENDIF
> || ptr->Prev->U.I.Opcode != RC_OPCODE_IF
> || loop->Brk){
> @@ -376,20 +378,30 @@ static int build_loop_info(struct
> radeon_compiler * c, struct loop_info * loop,
> loop->Brk = ptr;
> loop->If = ptr->Prev;
> loop->EndIf = ptr->Next;
> - switch(loop->If->Prev->U.I.Opcode){
> - case RC_OPCODE_SLT:
> - case RC_OPCODE_SGE:
> - case RC_OPCODE_SGT:
> - case RC_OPCODE_SLE:
> - case RC_OPCODE_SEQ:
> - case RC_OPCODE_SNE:
> - break;
> - default:
> + src = &loop->If->U.I.SrcReg[0];
> +
> + for (loop->Cond = loop->If->Prev;
> + loop->Cond->U.I.Opcode != RC_OPCODE_BGNLOOP;
> + loop->Cond = loop->Cond->Prev) {
> +
> + const struct rc_dst_register *dst = &loop->Cond->U.I.DstReg;
> + if (dst->File == src->File &&
> + dst->Index == src->Index &&
> + dst->WriteMask & (rc_swizzle_to_writemask(src->Swizzle))) {
> + if (loop->Cond->U.I.Opcode == RC_OPCODE_CMP) {
> + src = &loop->Cond->U.I.SrcReg[0];
> + continue;
> + }
> + break;
> + }
> + }
> +
> + if (loop->Cond->U.I.Opcode == RC_OPCODE_BGNLOOP) {
> + rc_error(c, "%s: Cannot find condition for if\n", __FUNCTION__);
> return 0;
> }
> - loop->Cond = loop->If->Prev;
> break;
> -
> + }
> case RC_OPCODE_ENDLOOP:
> loop->EndLoop = ptr;
> break;
> --
> 2.0.0
> fixes piglit glean "do-loop with continue and break" on RS690
>
> It's based on Tom Stellard patch and improved to handle CMP instruction.
>
> [v2] handle CMP instruction
>
> Signed-off-by: David Heidelberger <david.heidelberger at ixit.cz>
> ---
> .../drivers/r300/compiler/radeon_emulate_loops.c | 34 +++++++++++++++-------
> 1 file changed, 23 insertions(+), 11 deletions(-)
>
> diff --git a/src/gallium/drivers/r300/compiler/radeon_emulate_loops.c b/src/gallium/drivers/r300/compiler/radeon_emulate_loops.c
> index 91ed9d2..25512b3 100644
> --- a/src/gallium/drivers/r300/compiler/radeon_emulate_loops.c
> +++ b/src/gallium/drivers/r300/compiler/radeon_emulate_loops.c
> @@ -368,6 +368,8 @@ static int build_loop_info(struct radeon_compiler * c, struct loop_info * loop,
> break;
> }
> case RC_OPCODE_BRK:
> + {
> + struct rc_src_register *src;
> if(ptr->Next->U.I.Opcode != RC_OPCODE_ENDIF
> || ptr->Prev->U.I.Opcode != RC_OPCODE_IF
> || loop->Brk){
> @@ -376,20 +378,30 @@ static int build_loop_info(struct radeon_compiler * c, struct loop_info * loop,
> loop->Brk = ptr;
> loop->If = ptr->Prev;
> loop->EndIf = ptr->Next;
> - switch(loop->If->Prev->U.I.Opcode){
> - case RC_OPCODE_SLT:
> - case RC_OPCODE_SGE:
> - case RC_OPCODE_SGT:
> - case RC_OPCODE_SLE:
> - case RC_OPCODE_SEQ:
> - case RC_OPCODE_SNE:
> - break;
> - default:
> + src = &loop->If->U.I.SrcReg[0];
> +
> + for (loop->Cond = loop->If->Prev;
> + loop->Cond->U.I.Opcode != RC_OPCODE_BGNLOOP;
> + loop->Cond = loop->Cond->Prev) {
> +
> + const struct rc_dst_register *dst = &loop->Cond->U.I.DstReg;
> + if (dst->File == src->File &&
> + dst->Index == src->Index &&
> + dst->WriteMask & (rc_swizzle_to_writemask(src->Swizzle))) {
> + if (loop->Cond->U.I.Opcode == RC_OPCODE_CMP) {
> + src = &loop->Cond->U.I.SrcReg[0];
> + continue;
> + }
> + break;
> + }
> + }
> +
> + if (loop->Cond->U.I.Opcode == RC_OPCODE_BGNLOOP) {
> + rc_error(c, "%s: Cannot find condition for if\n", __FUNCTION__);
> return 0;
> }
> - loop->Cond = loop->If->Prev;
> break;
> -
> + }
> case RC_OPCODE_ENDLOOP:
> loop->EndLoop = ptr;
> break;
> --
> 2.0.0
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
More information about the mesa-dev
mailing list