nir: Teach loop unrolling about 64-bit instruction lowering

The lowering we do for 64-bit instructions can cause a single NIR ALU
instruction to blow up into hundreds or thousands of instructions
potentially with control flow.  If loop unrolling isn't aware of this,
it can unroll a loop 20 times which contains a nir_op_fsqrt which we
then lower to a full software implementation based on integer math.
Those 20 invocations suddenly get a lot more expensive than NIR loop
unrolling currently expects.  By giving it an approximate estimate
function, we can prevent loop unrolling from going to town when it
shouldn't.

Reviewed-by: Matt Turner <mattst88@gmail.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
This commit is contained in:
Jason Ekstrand
2019-03-03 09:24:12 -06:00
committed by Jason Ekstrand
parent ebb3695376
commit 9314084237
3 changed files with 79 additions and 13 deletions

View File

@@ -1915,8 +1915,8 @@ typedef struct {
} nir_loop_terminator;
typedef struct {
/* Number of instructions in the loop */
unsigned num_instructions;
/* Estimated cost (in number of instructions) of the loop */
unsigned instr_cost;
/* Maximum number of times the loop is run (if known) */
unsigned max_trip_count;