gemini-code-assist[bot] commented on code in PR #19508:
URL: https://github.com/apache/tvm/pull/19508#discussion_r3192503430
##########
src/tirx/transform/common_subexpr_elim.cc:
##########
@@ -274,6 +280,14 @@ class CSEPlanner : public StmtExprVisitor {
}
if (IsForbiddenNode(expr)) return false;
if (expr.as<RampNode>() || expr.as<BroadcastNode>()) return false;
+ // Reject bool-typed expressions. Boolean predicates almost always feed an
+ // if / Select / assert, where reading the condition inline is clearer than
+ // going through a `cse_v: bool = (a < b)` temporary, and where downstream
+ // simplification (ProveCondition, branch elimination) benefits from seeing
+ // the predicate directly. BoolImm is already filtered above as an IntImm
+ // leaf, so this rule only affects compound bool expressions
+ // (LT/LE/GT/GE/EQ/NE/And/Or/Not/Cast-to-bool/Select-of-bool).
+ if (expr.dtype().is_bool()) return false;
Review Comment:

The current check `expr.dtype().is_bool()` only identifies scalar boolean
expressions (typically `uint1` with 1 lane). In TIR, boolean predicates are
frequently vectorized (e.g., `uint1x4` or `uint1x8`), especially when feeding
into vectorized `Select` nodes.
Since the stated goal is to keep predicates inline to facilitate downstream
simplification and readability, this logic should also apply to vectorized
boolean expressions. Downstream passes like `Simplify` or `ProveCondition`
often benefit from seeing the vectorized comparison directly within the
`Select` condition.
Consider checking for a 1-bit width to cover both scalar and vector boolean
types.
```suggestion
if (expr.dtype().bits() == 1) return false;
```
--
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]