As we have discussed previously (e.g. in D63992 / D64090 / PR42457), sub instruction
can almost be considered non-canonical. While we do convert sub %x, C -> add %x, -C,
we sparsely do that for non-constants. But we should.
We know that neg is free if:
- We are negating an integral constant - https://rise4fun.com/Alive/6ploz
- The instruction in question has no users other than the negation itself. The rest of reasoning is recursive.
- It's a select - both hands must be negatible - https://rise4fun.com/Alive/MYge
- It's a shl - first operand must be negatible - https://rise4fun.com/Alive/7kA
- It's a sub - just swap the operands - https://rise4fun.com/Alive/eyI
- It's a add - both operands must be negatible - https://rise4fun.com/Alive/ou7
- It's a mul - either one of operands must be negatible - https://rise4fun.com/Alive/4tR
- It's a trunc - it's operand must be negatible - https://rise4fun.com/Alive/xOR
- (FIXME: there are likely more cases?)