[llvm-branch-commits] [llvm] Bundle operands to specify denormal modes (PR #136501)

Serge Pavlov via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Mon Apr 21 09:32:08 PDT 2025


================
@@ -678,6 +682,71 @@ fp::ExceptionBehavior CallBase::getExceptionBehavior() const {
   return fp::ebIgnore;
 }
 
+DenormalMode::DenormalModeKind CallBase::getInputDenormMode() const {
+  if (auto InDenormBundle = getOperandBundle(LLVMContext::OB_fp_control)) {
+    auto DenormOperand =
+        getBundleOperandByPrefix(*InDenormBundle, "denorm.in=");
+    if (DenormOperand) {
+      if (auto Mode = parseDenormalKindFromOperandBundle(*DenormOperand))
+        return *Mode;
+    } else {
+      return DenormalMode::IEEE;
+    }
+  }
+
+  if (!getParent())
+    return DenormalMode::IEEE;
+  const Function *F = getFunction();
+  if (!F)
+    return DenormalMode::IEEE;
+
+  Type *Ty = nullptr;
+  for (auto &A : args())
+    if (auto *T = A.get()->getType(); T->isFPOrFPVectorTy()) {
+      Ty = T;
+      break;
+    }
+  assert(Ty && "Some input argument must be of floating-point type");
----------------
spavloff wrote:

It means that we have more than one denormal mode in a single instruction, so they need to be distinguish them somehow, by type in your case.

Is it possible that an instruction has multiple output denormal modes?

What about rounding mode? It it possible that evaluation of an instruction requires two different rounding modes?

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


More information about the llvm-branch-commits mailing list