[InstCombine] Transform (A > 0) | (A < 0) -> zext (A != 0) fold
This extends foldCastedBitwiseLogic to handle the similar cases.
Actually, for (A > B) | (A < B), when B != 0, it can be optimized to zext( A != B ) by foldAndOrOfICmpsUsingRanges.
However, when B = 0, transformZExtICmp will transform zext(A < 0) to i32 into A >> 31,
which cannot be optimized by foldAndOrOfICmpsUsingRanges.
Because I'm new to LLVM and has no concise knowledge about how LLVM decides the order of optimization,
I choose to extend foldCastedBitwiseLogic to fold ( A >> (X - 1) ) | ((A > 0) zext to iX) -> (A != 0) zext to iX.
And the equivalent fold follows:
A >> (X - 1) ) | ((A > 0) zext to iX -> A < 0 | A > 0 -> (A != 0) zext to iX
It's proved by alive-tv
Related issue:
(a > b) | (a < b) is not simplified only for the case b=0
Style pred -> Pred.