v3d: Translate f2i(fround_even) as FTOIN.
authorEric Anholt <eric@anholt.net>
Sat, 23 Feb 2019 19:21:26 +0000 (11:21 -0800)
committerEric Anholt <eric@anholt.net>
Tue, 5 Mar 2019 18:59:40 +0000 (10:59 -0800)
This appears to be just what the opcode does.  Needed for equivalence when
moving FF VPM stores into NIR.

src/broadcom/compiler/nir_to_vir.c

index d4f6088bcf2df471dfe2c43bccd0f905f90009d0..f5729ffa2387d2f7bab4a4bed4f26335f5b4bef5 100644 (file)
@@ -866,9 +866,16 @@ ntq_emit_alu(struct v3d_compile *c, nir_alu_instr *instr)
                 result = vir_FMAX(c, src[0], src[1]);
                 break;
 
-        case nir_op_f2i32:
-                result = vir_FTOIZ(c, src[0]);
+        case nir_op_f2i32: {
+                nir_alu_instr *src0_alu = ntq_get_alu_parent(instr->src[0].src);
+                if (src0_alu && src0_alu->op == nir_op_fround_even) {
+                        result = vir_FTOIN(c, ntq_get_alu_src(c, src0_alu, 0));
+                } else {
+                        result = vir_FTOIZ(c, src[0]);
+                }
                 break;
+        }
+
         case nir_op_f2u32:
                 result = vir_FTOUZ(c, src[0]);
                 break;