nvc0/ir: optimize set & 1.0 to produce boolean-float sets
authorIlia Mirkin <imirkin@alum.mit.edu>
Mon, 4 May 2015 02:15:16 +0000 (22:15 -0400)
committerIlia Mirkin <imirkin@alum.mit.edu>
Fri, 22 May 2015 20:51:05 +0000 (16:51 -0400)
This has started to happen more now that the backend is producing
KILL_IF more often.

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Tobias Klausmann <tobias.johannes.klausmann@mni.thm.de>
src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
src/gallium/drivers/nouveau/codegen/nv50_ir_target_nv50.cpp

index 14446b6b53f7f4fc41f13c3c2ec079a7dc9e0e84..82e81482b5107ce83b9ead5592099cd18369b0f7 100644 (file)
@@ -973,6 +973,33 @@ ConstantFolding::opnd(Instruction *i, ImmediateValue &imm0, int s)
    }
       break;
 
+   case OP_AND:
+   {
+      CmpInstruction *cmp = i->getSrc(t)->getInsn()->asCmp();
+      if (!cmp || cmp->op == OP_SLCT || cmp->getDef(0)->refCount() > 1)
+         return;
+      if (!prog->getTarget()->isOpSupported(cmp->op, TYPE_F32))
+         return;
+      if (imm0.reg.data.f32 != 1.0)
+         return;
+      if (i->getSrc(t)->getInsn()->dType != TYPE_U32)
+         return;
+
+      i->getSrc(t)->getInsn()->dType = TYPE_F32;
+      if (i->src(t).mod != Modifier(0)) {
+         assert(i->src(t).mod == Modifier(NV50_IR_MOD_NOT));
+         i->src(t).mod = Modifier(0);
+         cmp->setCond = inverseCondCode(cmp->setCond);
+      }
+      i->op = OP_MOV;
+      i->setSrc(s, NULL);
+      if (t) {
+         i->setSrc(0, i->getSrc(t));
+         i->setSrc(t, NULL);
+      }
+   }
+      break;
+
    case OP_SHL:
    {
       if (s != 1 || i->src(0).mod != Modifier(0))
index a742162ad3cb2b3ef8c8d2a5d56e3c0236067d24..ca545a6024a1bd30c27822ee594f118e6e546124 100644 (file)
@@ -416,6 +416,8 @@ TargetNV50::isOpSupported(operation op, DataType ty) const
       return false;
    case OP_SAD:
       return ty == TYPE_S32;
+   case OP_SET:
+      return !isFloatType(ty);
    default:
       return true;
    }