[clang] [llvm] [NVPTX] Cleanup and document nvvm.fabs intrinsics, adding f16 support (PR #135644)

Artem Belevich via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 15 11:13:12 PDT 2025


================
@@ -411,6 +412,13 @@ static Instruction *convertNvvmIntrinsicToLlvm(InstCombiner &IC,
     }
     return nullptr;
   }
+  case SPC_Fabs: {
+    if (!II->getType()->isDoubleTy())
+      return nullptr;
+    auto *Fabs = Intrinsic::getOrInsertDeclaration(
+        II->getModule(), Intrinsic::fabs, II->getType());
+    return CallInst::Create(Fabs, II->getArgOperand(0));
----------------
Artem-B wrote:

Nit: the early return does not help us much here. A positive `if (II->getType()->isDoubleTy()) { return  stuff}` followed by `return nullptr` would make more sense, IMO. Bonus points that we would not need `{}` around the whole `case` expression.

https://github.com/llvm/llvm-project/pull/135644


More information about the llvm-commits mailing list