If the incoming types are i1, then we don't have to pattern match any sext ops.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
Would it make sense to add "m_SExtOrBool" or something like that, which matches a value which matches either a sext or a value of boolean type? That seems like a cleaner way to generalize the transform.
If the boolean comes from an icmp, it seems likely that you'll end up with ((X == Y) & C) | ((X != Y) & D). I guess you can address that in a followup, if necessary.
lib/Transforms/InstCombine/InstCombineAndOrXor.cpp | ||
---|---|---|
1654 ↗ | (On Diff #61921) | Please don't get rid of this comment... you don't have any others which actually describe the transform in full. |
Not sure if that matcher would be generally useful. For the non-splat vectors scenarios that I'm seeing, I may need to add something to ValueTracking like 'isAllOnesOrAllZerosElts()' [return true if a scalar value is -1 or 0 or if all elements of a vector are -1 or 0 (but not necessarily that all elements are the same). So that would be an even more general way to catch these. I'd prefer to keep this patch simpler and then see what's needed for the 'TODO' comment.
lib/Transforms/InstCombine/InstCombineAndOrXor.cpp | ||
---|---|---|
1654 ↗ | (On Diff #61921) | Oops - that was an unintended delete. Let me restore it. |