gemini-code-assist[bot] commented on code in PR #19797:
URL: https://github.com/apache/tvm/pull/19797#discussion_r3421312391


##########
src/arith/int_set.cc:
##########
@@ -133,7 +132,7 @@ inline IntervalSet Combine(AnalyzerObj* analyzer, 
IntervalSet a, IntervalSet b,
     return IntervalSet::SinglePoint(expr);
   }
   if (is_logical_op<Op>::value) {
-    return IntervalSet(make_const(dtype, 0), make_const(dtype, 1));
+    return IntervalSet(IntImm(dtype, 0), make_const(dtype, 1));

Review Comment:
   ![medium](https://www.gstatic.com/codereviewagent/medium-priority.svg)
   
   Since `dtype` is a scalar boolean type for logical operations, we can use 
`IntImm` directly instead of `make_const`.
   
   ```suggestion
       return IntervalSet(IntImm(dtype, 0), IntImm(dtype, 1));
   ```



##########
src/tirx/transform/vectorize_loop.cc:
##########
@@ -987,8 +986,10 @@ class Vectorizer : public StmtMutator, public 
ExprFunctor<PrimExpr(const PrimExp
         const RampNode* b_ramp = b.as<RampNode>();
         const RampNode* a_ramp = a.as<RampNode>();
         if (a.dtype().is_scalar() && b_ramp) {
+          // make_const can handle both vector and scalar types.
           return Ramp(fcompute(a, b_ramp->base),
-                      fcompute(make_zero(b_ramp->stride.dtype()), 
b_ramp->stride), b_ramp->lanes);
+                      fcompute(make_const(b_ramp->stride.dtype(), 0), 
b_ramp->stride),

Review Comment:
   ![medium](https://www.gstatic.com/codereviewagent/medium-priority.svg)
   
   Since `b_ramp->stride.dtype()` is guaranteed to be a scalar integer type (as 
it represents the stride of a `RampNode`), we can use `IntImm` directly instead 
of `make_const` to avoid the overhead of template resolution and runtime checks.
   
   ```suggestion
                         fcompute(IntImm(b_ramp->stride.dtype(), 0), 
b_ramp->stride),
   ```



##########
src/arith/iter_affine_map.cc:
##########
@@ -2256,14 +2256,14 @@ class SubspaceDivider {
 
     static DivisionResult Inner(const IterMapExpr& iter, const PrimExpr& 
extent) {
       auto dtype = iter.dtype();
-      return DivisionResult(IterSumExpr({}, make_const(dtype, 0)), 
make_const(dtype, 1), iter,
-                            extent, Kind::kInner);
+      return DivisionResult(IterSumExpr({}, IntImm(dtype, 0)), 
make_const(dtype, 1), iter, extent,
+                            Kind::kInner);
     }
 
     static DivisionResult Outer(const IterMapExpr& iter, const PrimExpr& 
extent) {
       auto dtype = iter.dtype();
-      return DivisionResult(iter, extent, IterSumExpr({}, make_const(dtype, 
0)),
-                            make_const(dtype, 1), Kind::kOuter);
+      return DivisionResult(iter, extent, IterSumExpr({}, IntImm(dtype, 0)), 
make_const(dtype, 1),
+                            Kind::kOuter);

Review Comment:
   ![medium](https://www.gstatic.com/codereviewagent/medium-priority.svg)
   
   Since `dtype` is a scalar integer type, we can use `IntImm` directly instead 
of `make_const`.
   
   ```suggestion
         return DivisionResult(iter, extent, IterSumExpr({}, IntImm(dtype, 0)), 
IntImm(dtype, 1),
                               Kind::kOuter);
   ```



##########
src/tirx/transform/tvm_ffi_binder.cc:
##########
@@ -369,7 +369,7 @@ void TVMFFIABIBuilder::BindBuffer(const Buffer& arg, const 
Buffer& value,
       if (arg->offset_factor > 1) {
         PrimExpr offset = value->elem_offset;
         PrimExpr factor = make_const(offset.dtype(), arg->offset_factor);
-        PrimExpr zero = make_zero(offset.dtype());
+        PrimExpr zero = IntImm(offset.dtype(), 0);

Review Comment:
   ![medium](https://www.gstatic.com/codereviewagent/medium-priority.svg)
   
   Since `offset.dtype()` is a scalar integer type, we can use `IntImm` 
directly instead of `make_const` for the `factor` constant.
   
   ```suggestion
           PrimExpr factor = IntImm(offset.dtype(), arg->offset_factor);
           PrimExpr zero = IntImm(offset.dtype(), 0);
   ```



##########
src/tirx/transform/vectorize_loop.cc:
##########
@@ -1067,9 +1069,9 @@ class LoopVectorizer : public StmtMutator {
     PrimExpr index = outer * scalable_lanes_index + inner_index;
     Stmt body = Substitute(op->body, {{op->loop_var, index}});
     Stmt guarded_body = IfThenElse(index < fixed_extent, body, std::nullopt, 
op->span);
-    Stmt vector_loop =
-        For(inner, make_const(lane_dtype, 0), scalable_lanes, 
ForKind::kVectorized, guarded_body,
-            std::nullopt, op->annotations, std::nullopt, op->span);
+    // make_const can handle both vector and scalar types.
+    Stmt vector_loop = For(inner, make_const(lane_dtype, 0), scalable_lanes, 
ForKind::kVectorized,
+                           guarded_body, std::nullopt, op->annotations, 
std::nullopt, op->span);

Review Comment:
   ![medium](https://www.gstatic.com/codereviewagent/medium-priority.svg)
   
   Since `lane_dtype` is a scalar integer type representing the loop variable's 
data type, we can use `IntImm` directly instead of `make_const`.
   
   ```suggestion
       Stmt vector_loop = For(inner, IntImm(lane_dtype, 0), scalable_lanes, 
ForKind::kVectorized,
                              guarded_body, std::nullopt, op->annotations, 
std::nullopt, op->span);
   ```



##########
src/arith/iter_affine_map.cc:
##########
@@ -2256,14 +2256,14 @@ class SubspaceDivider {
 
     static DivisionResult Inner(const IterMapExpr& iter, const PrimExpr& 
extent) {
       auto dtype = iter.dtype();
-      return DivisionResult(IterSumExpr({}, make_const(dtype, 0)), 
make_const(dtype, 1), iter,
-                            extent, Kind::kInner);
+      return DivisionResult(IterSumExpr({}, IntImm(dtype, 0)), 
make_const(dtype, 1), iter, extent,
+                            Kind::kInner);

Review Comment:
   ![medium](https://www.gstatic.com/codereviewagent/medium-priority.svg)
   
   Since `dtype` is a scalar integer type, we can use `IntImm` directly instead 
of `make_const`.
   
   ```suggestion
         return DivisionResult(IterSumExpr({}, IntImm(dtype, 0)), IntImm(dtype, 
1), iter, extent,
                               Kind::kInner);
   ```



##########
src/arith/iter_affine_map.cc:
##########
@@ -2288,7 +2288,7 @@ class SubspaceDivider {
     auto dtype = expr.dtype();
     if (expr->args.empty()) {
       // base
-      return DivisionResult(IterSumExpr({}, make_const(dtype, 0)), 
make_const(dtype, 1),
+      return DivisionResult(IterSumExpr({}, IntImm(dtype, 0)), 
make_const(dtype, 1),
                             IterSumExpr({}, expr->base), make_const(dtype, 1));

Review Comment:
   ![medium](https://www.gstatic.com/codereviewagent/medium-priority.svg)
   
   Since `dtype` is a scalar integer type, we can use `IntImm` directly instead 
of `make_const`.
   
   ```suggestion
         return DivisionResult(IterSumExpr({}, IntImm(dtype, 0)), IntImm(dtype, 
1),
                               IterSumExpr({}, expr->base), IntImm(dtype, 1));
   ```



##########
src/tirx/transform/tvm_ffi_binder.cc:
##########
@@ -714,7 +713,7 @@ void TVMFFIABIBuilder::DecodeParamDLTensor(const Buffer& 
buffer, const PrimExpr&
       if (buffer->offset_factor > 1) {
         PrimExpr offset = buffer->elem_offset;
         PrimExpr factor = make_const(offset.dtype(), buffer->offset_factor);
-        PrimExpr zero = make_zero(offset.dtype());
+        PrimExpr zero = IntImm(offset.dtype(), 0);

Review Comment:
   ![medium](https://www.gstatic.com/codereviewagent/medium-priority.svg)
   
   Since `offset.dtype()` is a scalar integer type, we can use `IntImm` 
directly instead of `make_const` for the `factor` constant.
   
   ```suggestion
           PrimExpr factor = IntImm(offset.dtype(), buffer->offset_factor);
           PrimExpr zero = IntImm(offset.dtype(), 0);
   ```



##########
src/arith/int_set.cc:
##########
@@ -349,12 +348,12 @@ inline IntervalSet Combine<tirx::FloorMod>(AnalyzerObj* 
analyzer, IntervalSet a,
             int64_t max_mod_result = max_quotient * gcd + (dividend_mod->base 
% gcd);
 
             if (max_mod_result >= 0 && max_mod_result < div_val) {
-              return IntervalSet(make_zero(op->dtype), make_const(op->dtype, 
max_mod_result));
+              return IntervalSet(IntImm(op->dtype, 0), make_const(op->dtype, 
max_mod_result));

Review Comment:
   ![medium](https://www.gstatic.com/codereviewagent/medium-priority.svg)
   
   Since `op->dtype` is a scalar integer type, we can use `IntImm` directly 
instead of `make_const`.
   
   ```suggestion
                 return IntervalSet(IntImm(op->dtype, 0), IntImm(op->dtype, 
max_mod_result));
   ```



##########
src/s_tir/transform/inject_double_buffer.cc:
##########
@@ -274,7 +274,7 @@ class DoubleBufferInjector : public StmtExprMutator {
     }
     StorageEntry& e = it->second;
     e.loop = loop_nest_.back();
-    PrimExpr zero = make_const(e.loop->loop_var.dtype(), 0);
+    PrimExpr zero = IntImm(e.loop->loop_var.dtype(), 0);
     PrimExpr one = make_const(e.loop->loop_var.dtype(), 1);
     PrimExpr two = make_const(e.loop->loop_var.dtype(), 2);

Review Comment:
   ![medium](https://www.gstatic.com/codereviewagent/medium-priority.svg)
   
   Since `e.loop->loop_var.dtype()` is a scalar integer type, we can use 
`IntImm` directly instead of `make_const` for both `one` and `two` constants.
   
   ```suggestion
       PrimExpr zero = IntImm(e.loop->loop_var.dtype(), 0);
       PrimExpr one = IntImm(e.loop->loop_var.dtype(), 1);
       PrimExpr two = IntImm(e.loop->loop_var.dtype(), 2);
   ```



-- 
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