[PATCH] D134142: [InstCombine] Handle integer extension in `select` patterns using the condition as value
Nikita Popov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 20 09:19:43 PDT 2022
nikic added a comment.
In D134142#3802765 <https://reviews.llvm.org/D134142#3802765>, @spatel wrote:
> In D134142#3802599 <https://reviews.llvm.org/D134142#3802599>, @nikic wrote:
>
>> This kinda looks like foldSelectValueEquivalence() with a trivial comparison (i.e. interpret `c` as `c == 1`).
>
> Agree - but we'd have to account for the missing icmp that code is expecting? Not sure that's worth the effort and reduced readability, so this patch LGTM.
It looks like we don't even need foldSelectValueEquivalence here -- we already have simplifyWithOpReplaced() folds for these. They are currently behind a guard for i1 selects, but if we move them outside we get most of the mileage: https://gist.github.com/nikic/86420628e72dd137aa56d2317f3825b0
The main caveat is that this does not handle vectors. Not that I actually care about vectors, but for the sake of propriety we should probably update simplifyWithOpReplaced() to allow vectors and only reject the problematic cross-lane operations inside.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D134142/new/
https://reviews.llvm.org/D134142
More information about the llvm-commits
mailing list