Mesa (master): freedreno/ir3/cf: use ssa-uses
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Sat Apr 4 00:24:57 UTC 2020
Module: Mesa
Branch: master
Commit: 629c0cee0a4c05e7096189c6bcd8b3d7d164f5f2
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=629c0cee0a4c05e7096189c6bcd8b3d7d164f5f2
Author: Rob Clark <robdclark at chromium.org>
Date: Mon Mar 16 15:34:08 2020 -0700
freedreno/ir3/cf: use ssa-uses
Signed-off-by: Rob Clark <robdclark at chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4423>
---
src/freedreno/ir3/ir3_cf.c | 48 ++++++++++++++++++++++------------------------
1 file changed, 23 insertions(+), 25 deletions(-)
diff --git a/src/freedreno/ir3/ir3_cf.c b/src/freedreno/ir3/ir3_cf.c
index b9035706131..ad65a5ce187 100644
--- a/src/freedreno/ir3/ir3_cf.c
+++ b/src/freedreno/ir3/ir3_cf.c
@@ -21,6 +21,8 @@
* SOFTWARE.
*/
+#include "util/ralloc.h"
+
#include "ir3.h"
static bool
@@ -55,38 +57,28 @@ is_fp16_conv(struct ir3_instruction *instr)
}
static bool
-all_uses_fp16_conv(struct ir3 *ir, struct ir3_instruction *conv_src)
+all_uses_fp16_conv(struct ir3_instruction *conv_src)
{
- foreach_block (block, &ir->block_list) {
- foreach_instr (instr, &block->instr_list) {
- struct ir3_instruction *src;
- foreach_ssa_src (src, instr) {
- if (src == conv_src && !is_fp16_conv(instr))
- return false;
- }
- }
- }
-
+ foreach_ssa_use (use, conv_src)
+ if (!is_fp16_conv(use))
+ return false;
return true;
}
static void
-rewrite_uses(struct ir3 *ir, struct ir3_instruction *conv,
- struct ir3_instruction *replace)
+rewrite_uses(struct ir3_instruction *conv, struct ir3_instruction *replace)
{
- foreach_block (block, &ir->block_list) {
- foreach_instr (instr, &block->instr_list) {
- struct ir3_instruction *src;
- foreach_ssa_src_n (src, n, instr) {
- if (src == conv)
- instr->regs[n]->instr = replace;
- }
+ foreach_ssa_use (use, conv) {
+ struct ir3_instruction *src;
+ foreach_ssa_src_n (src, n, use) {
+ if (src == conv)
+ use->regs[n]->instr = replace;
}
}
}
static void
-try_conversion_folding(struct ir3 *ir, struct ir3_instruction *conv)
+try_conversion_folding(struct ir3_instruction *conv)
{
struct ir3_instruction *src;
@@ -115,7 +107,7 @@ try_conversion_folding(struct ir3 *ir, struct ir3_instruction *conv)
break;
}
- if (!all_uses_fp16_conv(ir, src))
+ if (!all_uses_fp16_conv(src))
return;
if (src->opc == OPC_MOV) {
@@ -141,15 +133,21 @@ try_conversion_folding(struct ir3 *ir, struct ir3_instruction *conv)
src->regs[0]->flags &= ~IR3_REG_HALF;
}
- rewrite_uses(ir, conv, src);
+ rewrite_uses(conv, src);
}
void
ir3_cf(struct ir3 *ir)
{
- foreach_block_safe (block, &ir->block_list) {
+ void *mem_ctx = ralloc_context(NULL);
+
+ ir3_find_ssa_uses(ir, mem_ctx);
+
+ foreach_block (block, &ir->block_list) {
foreach_instr_safe (instr, &block->instr_list) {
- try_conversion_folding(ir, instr);
+ try_conversion_folding(instr);
}
}
+
+ ralloc_free(mem_ctx);
}
More information about the mesa-commit
mailing list