This is from code review comment from D49382. We already finish related optimization for add instruction in D49216 and sdiv instruction in D49382.
This patch is for srem instruction. for example:
define i32 @negated_operand(i32 %x) { %negx = sub i32 0, %x %rem = srem i32 %negx, %x ret i32 %rem }
can be folded to:
define i32 @negated_operand(i32 %x) { ret i32 0 }
Alive verification:
https://rise4fun.com/Alive/q20
https://rise4fun.com/Alive/h4o