aco: don't value-number instructions from within a loop with ones after the loop.
authorDaniel Schürmann <daniel@schuermann.dev>
Tue, 26 Nov 2019 14:28:54 +0000 (15:28 +0100)
committerRhys Perry <pendingchaos02@gmail.com>
Tue, 26 Nov 2019 14:39:27 +0000 (14:39 +0000)
Fixes:
Wolfenstein:Youngblood (w/o shader_ballot)
dEQP-VK.descriptor_indexing.combined_image_sampler_in_loop_with_lod

Reviewed-by: Rhys Perry <pendingchaos02@gmail.com>
src/amd/compiler/aco_opt_value_numbering.cpp

index 40823da3c3633bee2cba48d2e33759e7f6924783..6b4eaa8b5f0a6c9e369ae16879036d2b5aba551e 100644 (file)
@@ -256,9 +256,14 @@ struct vn_ctx {
    vn_ctx(Program* program) : program(program) {}
 };
 
+
+/* dominates() returns true if the parent block dominates the child block and
+ * if the parent block is part of the same loop or has a smaller loop nest depth.
+ */
 bool dominates(vn_ctx& ctx, uint32_t parent, uint32_t child)
 {
-   while (parent < child)
+   unsigned parent_loop_nest_depth = ctx.program->blocks[parent].loop_nest_depth;
+   while (parent < child && parent_loop_nest_depth <= ctx.program->blocks[child].loop_nest_depth)
       child = ctx.program->blocks[child].logical_idom;
 
    return parent == child;