4 Replies Latest reply on Sep 2, 2010 5:01 PM by malcolm3141

    neg modifier token in IL


      Where can I find syntax and semantics of the above modifier?

      The IL reference guide is a bit short on this.


          • neg modifier token in IL


            thanks a lot. There isn't too much info in this document either.

            So, for example, what does

            mov r0, r1.wzxy_neg(zw)


            Is the neg-operator pre- or post-swizzle?

            Plus, will a neg-operator consume additional clock cycles?


              • neg modifier token in IL

                Sorry, found it myself:

                swizzle takes precedence over neg.

                Additional question I would have:

                What's the correct way of using neg() for double-precision operands?

                Also, are there literals for double-precision constants?


                  • neg modifier token in IL

                    If you have a look at the ASM docs (Evergreen Family ISA), you'll get a better idea of what the modifier does. In general, it flips the MSB of the channel specified (post swizzle).

                    The specific rules I have worked out by trial and error are:

                    1. neg modifier on integer operations produces a ineg and then the operation (or an isub equivalent if on an iadd instruction).
                    2. neg modifier on float instructions works as expected (flips MSB)
                    3. neg modifier on non-float instructions (eg mov, cmov) works as float.
                    4. To get neg modifier working on double, you need _neg(y) or _neg(yw) which acts on the 64bit MSB (little endian).

                    Note that the same rules seem to apply to the abs modifier. Many of the other modifiers will make no sense for integer operations (eg _bx2), although I doubt the IL compiler will complain (it is not always self consistent in behaviour).