<p dir="ltr"><br>
On Nov 9, 2015 7:24 AM, "Connor Abbott" <<a href="mailto:cwabbott0@gmail.com">cwabbott0@gmail.com</a>> wrote:<br>
><br>
> On Mon, Nov 9, 2015 at 6:55 AM, Iago Toral <<a href="mailto:itoral@igalia.com">itoral@igalia.com</a>> wrote:<br>
> > Hi,<br>
> ><br>
> > Currently, NIR defines vecN operations as unsigned (integer). The fp64<br>
> > patches from Connor change this to float (I guess because we need to<br>
> > know the case where we are packing vectors of 64-bit floats). However,<br>
> > this makes it so that nir_lower_source_to_mods turns this:<br>
> ><br>
> > vec1 ssa_2 = fmov -ssa_1.y<br>
> > vec3 ssa_3 = vec3 ssa_1, ssa_2, ssa_0<br>
> ><br>
> > into:<br>
> ><br>
> > vec3 ssa_2 = vec3 ssa_1, -ssa_1.y, ssa_0<br>
> ><br>
> > This only happens because the vec3 operation is defined as a float<br>
> > operation now, otherwise it would not try to do this. It is not clear to<br>
> > me if this is by design, I mean, have this kind of things only kick-in<br>
> > for float/int and define vecN operations as unsigned to avoid this for<br>
> > them.<br>
> ><br>
> > The problem comes later when we call nir_lower_vec_to_movs in the i965<br>
> > vec4 backend. That pass generates a separate MOV for each component in<br>
> > the vector, but to do that properly when a negate is involved it needs<br>
> > to know if this is a float or an integer operand, which it does not<br>
> > know at this point. The current code always emits an imov, which won't<br>
> > work if the operand is a float.<br>
> ><br>
> > I can think of two solutions for this:<br>
> ><br>
> > 1) Change nir_lower_source_to_mods so it does not try to rewrite alu<br>
> > operations where a source comes from a fmov with a negate, or at least<br>
> > if the instruction we are trying to rewrite is a vecN operation (or<br>
> > maybe allow this in scalar mode only?)<br>
> ><br>
> > 2) In nir_lower_vec_to_movs, if a source is negated, check its<br>
> > parent_instr and try to guess its type from that (in this example, we<br>
> > would see it came from fmov and we can say it is a float and emit fmov<br>
> > instead of imov). Not sure if this would work in all possible scenarios<br>
> > though.<br>
> ><br>
> > Opinions?<br>
> ><br>
> > Iago<br>
> ><br>
> > _______________________________________________<br>
> > mesa-dev mailing list<br>
> > <a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
> > <a href="http://lists.freedesktop.org/mailman/listinfo/mesa-dev">http://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
><br>
> The only reason I changed vecN to produce floats is to avoid producing<br>
> 64-bit integer instructions, which at one point the constant folding<br>
> infrastructure couldn't support (but now it can), so you can just<br>
> revert the change. Ofc the i965 backend won't be able to express this<br>
> directly, but for now you can silently change 64-bit integers to<br>
> floats and assert that they only happen in things that copy data<br>
> around.</p>
<p dir="ltr">I would tend to agree. We could also make it unsigned so no source modifiers ever make sense. Meh.</p>
<p dir="ltr">If we did want to keep vecN float, the thing to do would be to make vec_to_move lower it to fmovs rather than imovs. But, like Connor said, just asserting no source modifiers for th 64-bit version in the backend is probably best.</p>
<p dir="ltr">--Jason</p>