gemini-code-assist[bot] commented on code in PR #19589:
URL: https://github.com/apache/tvm/pull/19589#discussion_r3266739647
##########
src/target/llvm/codegen_llvm.cc:
##########
@@ -1598,13 +1598,21 @@ llvm::Value* CodeGenLLVM::VisitExpr_(const ModNode* op)
{
llvm::Value* CodeGenLLVM::VisitExpr_(const MinNode* op) {
llvm::Value* a = MakeValue(op->a);
llvm::Value* b = MakeValue(op->b);
- return builder_->CreateSelect(CreateLT(op->a.dtype(), a, b), a, b);
+ if (op->a.dtype().is_int() || op->a.dtype().is_uint()) {
+ return builder_->CreateSelect(CreateLT(op->a.dtype(), a, b), a, b);
+ } else {
+ return builder_->CreateMinimum(a, b);
+ }
}
llvm::Value* CodeGenLLVM::VisitExpr_(const MaxNode* op) {
llvm::Value* a = MakeValue(op->a);
llvm::Value* b = MakeValue(op->b);
- return builder_->CreateSelect(CreateGT(op->a.dtype(), a, b), a, b);
+ if (op->a.dtype().is_int() || op->a.dtype().is_uint()) {
+ return builder_->CreateSelect(CreateGT(op->a.dtype(), a, b), a, b);
+ } else {
+ return builder_->CreateMaximum(a, b);
+ }
Review Comment:

The `CreateMaximum` method was introduced in LLVM 12. Using it without a
version guard will cause compilation errors on older LLVM versions supported by
TVM. Additionally, `CreateMaximum` is specifically for floating-point types;
it's safer to explicitly check for `is_float()` to avoid potential issues with
other types (like handles) that might reach this block.
```c
if (op->a.dtype().is_float()) {
#if TVM_LLVM_VERSION >= 120
return builder_->CreateMaximum(a, b);
#endif
}
return builder_->CreateSelect(CreateGT(op->a.dtype(), a, b), a, b);
```
##########
src/target/llvm/codegen_llvm.cc:
##########
@@ -1598,13 +1598,21 @@ llvm::Value* CodeGenLLVM::VisitExpr_(const ModNode* op)
{
llvm::Value* CodeGenLLVM::VisitExpr_(const MinNode* op) {
llvm::Value* a = MakeValue(op->a);
llvm::Value* b = MakeValue(op->b);
- return builder_->CreateSelect(CreateLT(op->a.dtype(), a, b), a, b);
+ if (op->a.dtype().is_int() || op->a.dtype().is_uint()) {
+ return builder_->CreateSelect(CreateLT(op->a.dtype(), a, b), a, b);
+ } else {
+ return builder_->CreateMinimum(a, b);
+ }
Review Comment:

The `CreateMinimum` method was introduced in LLVM 12. Using it without a
version guard will cause compilation errors on older LLVM versions supported by
TVM. Additionally, `CreateMinimum` is specifically for floating-point types;
it's safer to explicitly check for `is_float()` to avoid potential issues with
other types (like handles) that might reach this block.
```c
if (op->a.dtype().is_float()) {
#if TVM_LLVM_VERSION >= 120
return builder_->CreateMinimum(a, b);
#endif
}
return builder_->CreateSelect(CreateLT(op->a.dtype(), a, b), a, b);
```
--
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]