nv50/ir: manually optimize multiplication expansion logic
authorIlia Mirkin <imirkin@alum.mit.edu>
Fri, 11 Dec 2015 05:40:15 +0000 (00:40 -0500)
committerIlia Mirkin <imirkin@alum.mit.edu>
Sat, 12 Dec 2015 23:10:16 +0000 (18:10 -0500)
commitdbca0f3eba632125904ded6298a87fefdde66d76
treea8e521d0aad34d3a4c87b4e6c5a8cc5815bd0db2
parent3af83c4bc7863e007ce47f6eb3606a1c59d14719
nv50/ir: manually optimize multiplication expansion logic

The conversion of 32-bit integer multiplies into 16-bit ones happens
after the regular optimization loop. However it's fairly common to
multiply by a small integer, rendering some of the expansion pointless.

Firstly, propagate immediates when possible into mul ops, secondly just
remove the ops when they are unnecessary.

Including the change to generate imad immediates, the effect is:

total instructions in shared programs : 6365463 -> 6351898 (-0.21%)
total gprs used in shared programs    : 728684 -> 728684 (0.00%)
total local used in shared programs   : 9904 -> 9904 (0.00%)
total bytes used in shared programs   : 44001576 -> 44036120 (0.08%)

                local        gpr       inst      bytes
    helped           0           0        3288           4
      hurt           0           0           0         842

It's easy for this to hurt bytes since we end up always generating the
8-byte form, while we can't always get rid of the immediate in question.

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
src/gallium/drivers/nouveau/codegen/nv50_ir_lowering_nv50.cpp