If we have two comparisons:
%iszero = icmp eq i32 %A, 0 %isnotzero = icmp ne i32 %A, 0
we should be able to turn one into the logical not of the other:
%iszero = icmp eq i32 %A, 0 %isnotzero = xor i1 %iszero, true
This fixes PR27431.
majnemer on Apr 20 2016, 9:29 PM.Authored by
As a canonicalization, this makes sense, but I'm worried it will lead to bad code generation. Having to materialize a flag into a register to negate it seems potentially problematic. Do we already have code in the backend (CGP?) which undoes this transformation? If not, I think we're likely to need it.
Also, how does this impact the dominating condition optimizations in SimplifyCFG and JumpThreading? Those optimizations expect the dominated conditional branch to be fed by a compare rather than a not of the dominating compare.
My suggestion, given the comments on this thread, would be for someone to