From f8c3212cbb0cddbfcf1853b55e954de31e0ff555 Mon Sep 17 00:00:00 2001 From: Christoph Bumiller Date: Sun, 8 Apr 2012 23:38:55 +0200 Subject: nv50/ir: fix Instruction::isCommutationLegal for WAW --- src/gallium/drivers/nv50/codegen/nv50_ir.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'src/gallium/drivers/nv50') diff --git a/src/gallium/drivers/nv50/codegen/nv50_ir.cpp b/src/gallium/drivers/nv50/codegen/nv50_ir.cpp index d80fc85126a..19a90806c70 100644 --- a/src/gallium/drivers/nv50/codegen/nv50_ir.cpp +++ b/src/gallium/drivers/nv50/codegen/nv50_ir.cpp @@ -815,7 +815,7 @@ Instruction::writesPredicate() const } static bool -insnCheckCommutation(const Instruction *a, const Instruction *b) +insnCheckCommutationDefSrc(const Instruction *a, const Instruction *b) { for (int d = 0; a->defExists(d); ++d) for (int s = 0; b->srcExists(s); ++s) @@ -824,12 +824,22 @@ insnCheckCommutation(const Instruction *a, const Instruction *b) return true; } +static bool +insnCheckCommutationDefDef(const Instruction *a, const Instruction *b) +{ + for (int d = 0; a->defExists(d); ++d) + for (int c = 0; b->defExists(c); ++c) + if (a->getDef(d)->interfers(b->getDef(c))) + return false; + return true; +} + bool Instruction::isCommutationLegal(const Instruction *i) const { - bool ret = true; - ret = ret && insnCheckCommutation(this, i); - ret = ret && insnCheckCommutation(i, this); + bool ret = insnCheckCommutationDefDef(this, i); + ret = ret && insnCheckCommutationDefSrc(this, i); + ret = ret && insnCheckCommutationDefSrc(i, this); return ret; } -- cgit v1.2.3