HappenLee commented on code in PR #68308:
URL: https://github.com/apache/doris/pull/68308#discussion_r4060678577


##########
be/src/exprs/vcompound_pred.h:
##########
@@ -625,7 +625,8 @@ class VCompoundPred : public VectorizedFnCall {
             if constexpr (is_and) {
                 lhs[i] &= rhs[i];
             } else {
-                lhs[i] |= rhs[i];
+                // Logical OR must produce a canonical Boolean instead of 
preserving input bits.
+                lhs[i] = (lhs[i] != 0) || (rhs[i] != 0);

Review Comment:
   Please use `(lhs[i] | rhs[i]) != 0` here to retain efficient SIMD while 
still producing canonical Boolean bytes.
   
   For two non-constant, non-nullable Boolean columns containing mixed 
TRUE/FALSE values, the whole-column shortcuts do not apply and execution 
reaches this loop. With Clang 16.0.6 and 21.1.8 (`-O3 -DNDEBUG -mavx2`), I 
extracted the loop including its `__restrict` qualifiers and vectorization 
pragma. The `||` form is reported as vectorized, but its conditional RHS loads 
lower to many per-byte branches and vector extract/insert operations. The 
proposed expression instead generates packed OR, compare-to-zero, and mask 
operations without per-row conditional branches.
   
   A local kernel microbenchmark on a Xeon Platinum 8457C (8,192 rows × 8,192 
iterations, pinned to one CPU; median of three trials with rotated measurement 
order, Clang 21) measured:
   - Original bitwise OR: **1.51 ms**
   - Current logical OR: **44.39 ms**
   - Bitwise OR followed by `!= 0`: **1.87 ms**
   
   These are loop timings, not end-to-end SQL timings. I also exhaustively 
checked all 65,536 UInt8 input pairs: the proposed expression is equivalent to 
the current normalization and always returns 0 or 1.
   
   ```suggestion
                   lhs[i] = (lhs[i] | rhs[i]) != 0;
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to