[Nouveau] [PATCH] nv50/ir: constant fold OP_SPLIT
Ilia Mirkin
imirkin at alum.mit.edu
Fri Sep 30 19:26:19 UTC 2016
On Fri, Sep 30, 2016 at 3:21 PM, Tobias Klausmann
<tobias.johannes.klausmann at mni.thm.de> wrote:
>
>
> On 28.09.2016 02:01, Ilia Mirkin wrote:
>>
>> On Tue, Sep 27, 2016 at 7:25 PM, Tobias Klausmann
>> <tobias.johannes.klausmann at mni.thm.de> wrote:
>>>
>>> Split the source immediate value into two new values and create OP_MOV
>>> instructions the two newly created values.
>>>
>>> Signed-off-by: Tobias Klausmann <tobias.johannes.klausmann at mni.thm.de>
>>> ---
>>> .../drivers/nouveau/codegen/nv50_ir_peephole.cpp | 23
>>> ++++++++++++++++++++++
>>> 1 file changed, 23 insertions(+)
>>>
>>> diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
>>> b/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
>>> index 74a5a85..fdddd71 100644
>>> --- a/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
>>> +++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_peephole.cpp
>>> @@ -920,6 +920,29 @@ ConstantFolding::opnd(Instruction *i, ImmediateValue
>>> &imm0, int s)
>>> Instruction *newi = i;
>>>
>>> switch (i->op) {
>>> + case OP_SPLIT: {
>>> + uint16_t shift = 0;
>>> + DataType type = TYPE_NONE;
>>> + bld.setPosition(i, false);
>>> + if (i->sType == TYPE_U64 || i->sType == TYPE_S64) {
>>> + shift = 32;
>>> + type = (i->sType == TYPE_U64) ? TYPE_U32 : TYPE_S32;
>>> + }
>>> + if (i->sType == TYPE_U32 || i->sType == TYPE_S32) {
>>> + shift = 16;
>>> + type = (i->sType == TYPE_U32) ? TYPE_U16 : TYPE_S16;
>>> + }
>>> + if (i->sType == TYPE_U16 || i->sType == TYPE_S16) {
>>> + shift = 8;
>>> + type = (i->sType == TYPE_U16) ? TYPE_U8 : TYPE_S8;
>>> + }
>>
>> shift = typeSizeOf(i->dType);
>>
>>> + if (type != TYPE_NONE) {
>>> + bld.mkMov(i->getDef(0), bld.mkImm(imm0.reg.data.u64 >> shift),
>>> type);
>>> + bld.mkMov(i->getDef(1), bld.mkImm(imm0.reg.data.u64), type);
>>
>> u64 val = ...u64;
>> for (d = 0; i->defExists(d); ++d) {
>> bld.mkMov(i->getDef(d), bld.mkImm(val & ((1 << shift) - 1));
>> val >>= shift;
>> }
>>
>> I think this will account for every case, and with a lot less
>> special-casing. What do you think?
>
>
> Well with this you'd not set the new type right: bld.mkMov(def, val,
>>>type<<), where you always would use TYPE_U32. Not sure if that is what we
> want... other than that that, shorten it like this would be nice!
pah-shaw :(
typeOfSize(shift / 2, isFloatType(i->dType), isSignedType(i->dType))
How's that :p
>
>
>>
>>> + delete_Instruction(prog, i);
>>> + }
>>> + }
>>> + break;
>>> case OP_MUL:
>>> if (i->dType == TYPE_F32)
>>> tryCollapseChainedMULs(i, s, imm0);
>>> --
>>> 2.10.0
>>>
>>> _______________________________________________
>>> Nouveau mailing list
>>> Nouveau at lists.freedesktop.org
>>> https://lists.freedesktop.org/mailman/listinfo/nouveau
>
>
More information about the Nouveau
mailing list