[llvm] [TableGen] Make `!and` short-circuit when either of the operand is zero (PR #113963)

Paul C. Anagnostopoulos via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 29 10:48:25 PDT 2024


Paul-C-Anagnostopoulos wrote:

Sheesh, of course you are right. C++ has both bitwise and logical operators. See what happens when I don't code any C/C++ for a year? It all goes right out of my brain.

I believe you are correct that no bang operators produce side-effects. So therefore it should be okay to short-circuit !and when a 0 argument is encountered, and !or when an all-1s argument is encountered.

Be sure to document this, or otherwise there is no point in doing it.

Or, in keeping with C++, we could leave !and and !or alone and add !land and !lor specifically for this purpose. They would accept only bit arguments. If we go this route, I'd add !lxor, too, even though it doesn't short-circuit.

https://github.com/llvm/llvm-project/pull/113963


More information about the llvm-commits mailing list