From: Christoph Bumiller Date: Sun, 8 Apr 2012 21:38:55 +0000 (+0200) Subject: nv50/ir: fix Instruction::isCommutationLegal for WAW X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=f8c3212cbb0cddbfcf1853b55e954de31e0ff555;p=mesa.git nv50/ir: fix Instruction::isCommutationLegal for WAW --- 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; }