[Mesa-stable] [PATCH] nv50/ir: skip optimizing ADD+SHL to SHLADD when src(1) is 0

Samuel Pitoiset samuel.pitoiset at gmail.com
Sat Apr 29 16:01:15 UTC 2017


Doing '(a << b) + c' when b is 0 is dumb, ADD should be used
instead.

This fixes a compilation error with Alien Isolation because
src(1) is expected to be an immediate value, and the
replaceZero logic will transform 0 to $r63 (or $r255).

Signed-off-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
Cc: "13.0 17.0 17.1" <mesa-stable at lists.freedesktop.org>
---
 src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
index 4c92a1efb5..015def0391 100644
--- a/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
+++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
@@ -2224,6 +2224,9 @@ LateAlgebraicOpt::tryADDToSHLADD(Instruction *add)
    if (!shl->src(1).getImmediate(imm))
       return false;
 
+   if (imm.isInteger(0))
+      return false;
+
    add->op = OP_SHLADD;
    add->setSrc(2, add->src(!s));
    // SHL can't have any modifiers, but the ADD source may have had
-- 
2.12.2



More information about the mesa-stable mailing list