[Mlir-commits] [mlir] [MLIR][NVVM][Refactor] Refactor intrinsic lowering for NVVM Ops (PR #157079)
    Srinivasa Ravi 
    llvmlistbot at llvm.org
       
    Tue Sep 16 10:21:33 PDT 2025
    
    
  
================
@@ -26,380 +26,6 @@ using namespace mlir;
 using namespace mlir::LLVM;
 using mlir::LLVM::detail::createIntrinsicCall;
 
-#define REDUX_F32_ID_IMPL(op, abs, hasNaN)                                     \
-  hasNaN ? llvm::Intrinsic::nvvm_redux_sync_f##op##abs##_NaN                   \
-         : llvm::Intrinsic::nvvm_redux_sync_f##op##abs
-
-#define GET_REDUX_F32_ID(op, hasAbs, hasNaN)                                   \
-  hasAbs ? REDUX_F32_ID_IMPL(op, _abs, hasNaN) : REDUX_F32_ID_IMPL(op, , hasNaN)
-
-static llvm::Intrinsic::ID getReduxIntrinsicId(llvm::Type *resultType,
-                                               NVVM::ReduxKind kind,
-                                               bool hasAbs, bool hasNaN) {
-  if (!(resultType->isIntegerTy(32) || resultType->isFloatTy()))
-    llvm_unreachable("unsupported data type for redux");
-
-  switch (kind) {
-  case NVVM::ReduxKind::ADD:
-    return llvm::Intrinsic::nvvm_redux_sync_add;
-  case NVVM::ReduxKind::UMAX:
-    return llvm::Intrinsic::nvvm_redux_sync_umax;
-  case NVVM::ReduxKind::UMIN:
-    return llvm::Intrinsic::nvvm_redux_sync_umin;
-  case NVVM::ReduxKind::AND:
-    return llvm::Intrinsic::nvvm_redux_sync_and;
-  case NVVM::ReduxKind::OR:
-    return llvm::Intrinsic::nvvm_redux_sync_or;
-  case NVVM::ReduxKind::XOR:
-    return llvm::Intrinsic::nvvm_redux_sync_xor;
-  case NVVM::ReduxKind::MAX:
-    return llvm::Intrinsic::nvvm_redux_sync_max;
-  case NVVM::ReduxKind::MIN:
-    return llvm::Intrinsic::nvvm_redux_sync_min;
-  case NVVM::ReduxKind::FMIN:
-    return GET_REDUX_F32_ID(min, hasAbs, hasNaN);
-  case NVVM::ReduxKind::FMAX:
-    return GET_REDUX_F32_ID(max, hasAbs, hasNaN);
-  }
-  llvm_unreachable("unknown redux kind");
-}
----------------
Wolfram70 wrote:
I kept that change in this PR as well since we are changing the signatures of these functions as well and making them static member functions of the Op (instead of static to this file) so that fits within the theme of the refactor and is not an NFC per se.
But please let me know if you think it is better to do this refactor + move in a seperate PR to do this refactor basically in 2 parts and reduce the footprint of this PR.
https://github.com/llvm/llvm-project/pull/157079
    
    
More information about the Mlir-commits
mailing list