Add support for differentiation of bitwise operations
We allow differentiation of integral types and thus we should also allow differentiation of bitwise operators.
For example, we should support differentiation of statements such as these:
int i, j;
i <<=3;
i = i | j;
i ^= j;
Can you add several examples for this?
Can you add several examples for this?
Yes, I have added a few examples in the description.
How do we define the differentiation operation for bitwise operators? I understand that left shift and right shift operators can be viewed as multiplying and dividing by 2 respectively and hence, we can replace those instructions with integer multiplication and division instructions and perform differentiation. But what about bitwise and/or/xor?
Also in case we need to implement this, we need to add these features in the "VisitBinaryOperator" function in both the Forward and Reverse mode differentiation classes right?
I don't know how the |, & or ^ will be differentiated, but i would like to try adding support for the >> << and ~
I assume a>>b divides the integer a by 2^b for unsigned integers and ~a is the same as -(a+1) for signed integers. Not sure of how we handle other cases though
Right and left shifts (>> and <<) should be handled somewhere in VisitBinaryOperator with operator kinds Shr and Shl. Not (~) -- in VisitUnaryOperator.