[llvm] [TableGen] Make `!and` short-circuit when either of the operand is zero (PR #113963)
Min-Yih Hsu via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 29 10:15:27 PDT 2024
mshockwave wrote:
> all the operators that return integers or booleans have no side-effects, but that seems like something we should not rely on
Is there a case where side effects might be produced in a (bang operator) expression? To my best understandings bang operators are all designed to be very..."Lisp" without any side effect. And even if we intermix other TableGen constructions into the expression, like `!and(SomeClass<v>.field, ...)` , I can't think of a case where side effects are produced from those constructions.
More generally speaking, given the fact that our current `!or` and `!and` are for both bitwise and logical, I agree that short-circuit behavior should not be generally applicable to them. But `!and` with one of the operands being zero is the case that will always work regardless of being logical or bitwise (assuming we have no side, of course, which I'd commented above). That's why this patch is relatively specific to `!and`.
https://github.com/llvm/llvm-project/pull/113963
More information about the llvm-commits
mailing list