[PATCH] D123962: [InstCombine] fold freeze of partial undef/poison vector constants

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 19 05:02:21 PDT 2022


spatel added a comment.

In D123962#3457645 <https://reviews.llvm.org/D123962#3457645>, @nikic wrote:

> For vector constants with some undef elements, wouldn't we be better off picking an existing (non-undef) vector element? That would be especially profitable if we can produce a splat vector constant.
>
> In D123962#3457622 <https://reviews.llvm.org/D123962#3457622>, @lebedev.ri wrote:
>
>> Given that we are replacing `freeze constant` with `constant`, and selecting the constant based on all the users,
>> can we instead go over all the users, and perform replacement for each one separately, always picking the best choice?
>
> Unless I'm misunderstanding what you're suggesting here, this is not legal: The value has to be chosen to be the same for all users.

Agree - looking back to D84948 <https://reviews.llvm.org/D84948>, this was discussed. The initial revision (this link is intended to show it):
https://reviews.llvm.org/D84948?vs=on&id=281923#toc
...added match of **one-use** freeze at various user sites; that would not work for multi-use.

So we could try harder for the one-use case by using binop identity or similar, but we need to end up with a common value for multi-use. Zero is the easy choice, but it looks like the current implementation could do better...for example, if all of the multiple users are "or" ops, we would generate a "-1".


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D123962/new/

https://reviews.llvm.org/D123962



More information about the llvm-commits mailing list