[PATCH] D150443: [KnownBits] Define and use meet and join operations

Jay Foad via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat May 13 09:57:58 PDT 2023


foad added a comment.

> - Can we call this union and intersect instead of join and meet? I think this will be more obvious to most readers.

No because `union` is a keyword :-( Apart from that I think it is a good candidate. I did think seriously about `union`/`intersect`, as well as other options like `and`/`or`.

> - The fact that the instance methods modify the value in place rather than returning a new one is rather surprising -- isn't the usual convention for KnownBits methods to return the result?

Maybe but I don't think there is much consistency. I chose to do it this way for a couple of reasons:

1. It is based on the way we implement binary operators like `&`. The work is done in the assignment form of the operator, `&=`, and the various non-assignment forms are implemented in terms of that. (And this was based on me googling for best practice for overloading operators for value-like classes.)
2. The meet-assignment form seems to be very useful in practice.

But I don't mind changing it if there is consensus that having `A.meet(B)` modify `A` is surprising.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150443



More information about the llvm-commits mailing list