[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:20:23 PDT 2024


================
@@ -1543,6 +1543,23 @@ const Init *BinOpInit::resolveReferences(Resolver &R) const {
   const Init *lhs = LHS->resolveReferences(R);
   const Init *rhs = RHS->resolveReferences(R);
 
+  if (getOpcode() == AND) {
----------------
mshockwave wrote:

Good point, I had thought this before. The problem is that since `!or` is for both logical and bitwise operation, we can't short circuit something like this `!or(true, <unknown / unresolved>)` until the second operand is resolved (in which case it's not a short circuit anymore) because we're not sure if the second operand is a int (bitwise OR) or a bit (logical OR).

That said, I think a separate logical OR / AND like you suggested might help us to apply short-circuit with more confidence.

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


More information about the llvm-commits mailing list