Refer to issue #51889. Folds:
- (icmp eq (trunc (shl 1, Y) to i[N]), 0) --> (icmp ugt Y, N-1)
- (icmp ne (trunc (shl 1, Y) to i[N]), 0) --> (icmp ult Y, N)
Differential D115480
[InstCombine] Fold icmp of truncated left shift spatel on Dec 9 2021, 4:16 PM. Authored by
Details Refer to issue #51889. Folds:
Diff Detail
Event Timeline
Comment Actions There are a lot of tests here using different bit-widths, but they don't add much value. As suggested, we'd get more impact by varying types/uses (hint: if you're only creating 1 instruction, then extra uses of the intermediate values are almost always ok). Also, as noted in the bug report, the compare to 0 is possibly a special-case of a more general pattern. Did you consider handling something like this: Finally, if you don't have commit access yet, you probably have enough commits now to request it: Comment Actions Reverse ping @hasyimibhar - do you plan to continue work on this patch, or should someone else commandeer it? Comment Actions Patch updated:
The diffs show that we can already fold some of these patterns via other transforms, but it is limited based on data type. That seems like an unnecessary restriction for this pattern since we can reduce to a single instruction (no one-use limits either). There are many TODO enhancements that can be done in follow-up patches. |