diff options
author | Serge Pavlov <sepavloff@gmail.com> | 2025-04-17 15:28:01 +0700 |
---|---|---|
committer | Serge Pavlov <sepavloff@gmail.com> | 2025-04-21 01:01:24 +0700 |
commit | 1e6b6bfcc612d400761b8f8e0d56530cb6d695ed (patch) | |
tree | 56aba7514c90627f7a2b5eba5ef150e4a32d5c24 /llvm/lib/IR/Instructions.cpp | |
parent | ad480e9de4015a9acc17b80d9f2d6ce5f39d13e5 (diff) | |
download | llvm-users/spavloff/fadd.zip llvm-users/spavloff/fadd.tar.gz llvm-users/spavloff/fadd.tar.bz2 |
Add constrained fadd to FP operationsusers/spavloff/fadd
Constrained intrinsics are treated as regular intrinsicss from the
perspective of FP operand bundle mechanism, meaning they can have FP
operand bundles. The FP bundle API functions will report properties
based on the operand bundles rather than metadata arguments.
These hybrid entities are temporary objects that exist while both
alternative mechanisms remain available. Nevertheless, they can be
useful for development:
* They can represent FP instructions with bundles. For example, while
there is currently no intrinsic that directly represents 'fadd'
instruction (and bundles cannot be attached to a plain 'fadd' since it
is not a call), a corresponding constrained intrinsic call can
represent the operation while still carrying operand bundles.
* Constrained intrinsic with bundles can be assigned properties that
otherwise cannot be expressed, such as denormal behavior.
This change adds 'experimental.constrained.fadd' to the list of FP
operations, enabling creation of tests for denormal behavior. It also
modifies methods `getRoundingMode` and `getExceptionBehavior` so that
they report information from metadata arguments if bundles are absent.
This adjustment should help incorporating constrained intrinsics into
algorithms based on operand bundles.
Diffstat (limited to 'llvm/lib/IR/Instructions.cpp')
-rw-r--r-- | llvm/lib/IR/Instructions.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/llvm/lib/IR/Instructions.cpp b/llvm/lib/IR/Instructions.cpp index 0e362d7..1073c29 100644 --- a/llvm/lib/IR/Instructions.cpp +++ b/llvm/lib/IR/Instructions.cpp @@ -636,6 +636,11 @@ RoundingMode CallBase::getRoundingMode() const { if (RM) return *RM; + // If this is a constrained intrinsic, get rounding mode from its metadata + // arguments. + if (auto *CI = dyn_cast<ConstrainedFPIntrinsic>(this)) + return CI->getRoundingMode().value_or(RoundingMode::Dynamic); + // No FP bundle, try to guess from the current mode. if (getParent()) if (auto *F = getFunction(); F) @@ -658,6 +663,11 @@ fp::ExceptionBehavior CallBase::getExceptionBehavior() const { if (EB) return *EB; + // If this is a constrained intrinsic, get exception behavior from its + // metadata arguments. + if (auto *CI = dyn_cast<ConstrainedFPIntrinsic>(this)) + return CI->getExceptionBehavior().value_or(fp::ebStrict); + // No FP bundle, try to guess from the current mode. if (getParent()) if (auto *F = getFunction(); F) |