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.
Differential D19353
[GVN] Replace an inverted comparison with a logical not majnemer on Apr 20 2016, 9:29 PM. Authored by
Details
Diff Detail Event TimelineComment Actions Do you think this would be worth adding to EarlyCSE as well since it could lead to simplifications that could effect inlining decisions? Comment Actions 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. Comment Actions 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. Comment Actions My suggestion, given the comments on this thread, would be for someone to |