diff options
author | Craig Topper <craig.topper@sifive.com> | 2022-02-18 21:55:48 -0800 |
---|---|---|
committer | Craig Topper <craig.topper@sifive.com> | 2022-02-18 21:55:49 -0800 |
commit | 1df8efae56b590a58123499d2bb8ffcd1f36fc40 (patch) | |
tree | edcf878e4ec6801ae7d5b98d0d39707c4463a83f /llvm/lib/CodeGen/TargetLoweringBase.cpp | |
parent | 39151717dbb494463cda59fe5d776870816790ce (diff) | |
download | llvm-1df8efae56b590a58123499d2bb8ffcd1f36fc40.zip llvm-1df8efae56b590a58123499d2bb8ffcd1f36fc40.tar.gz llvm-1df8efae56b590a58123499d2bb8ffcd1f36fc40.tar.bz2 |
[SelectionDAG][X86] Support f16 in getReciprocalOpName.
If the "reciprocal-estimates" attribute is present and it doesn't
contain "all", "none", or "default", we previously crashed on f16
operations.
This patch addes an 'h' suffix' to prevent the crash.
I've added simple tests that just enable the estimate for all
vec-sqrt and one test case that explicitly tests the new 'h' suffix
to override the default steps.
There may be some frontend change needed to, but I haven't checked
that yet.
Reviewed By: pengfei
Differential Revision: https://reviews.llvm.org/D120158
Diffstat (limited to 'llvm/lib/CodeGen/TargetLoweringBase.cpp')
-rw-r--r-- | llvm/lib/CodeGen/TargetLoweringBase.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/TargetLoweringBase.cpp b/llvm/lib/CodeGen/TargetLoweringBase.cpp index 3a7e82c..700c11a 100644 --- a/llvm/lib/CodeGen/TargetLoweringBase.cpp +++ b/llvm/lib/CodeGen/TargetLoweringBase.cpp @@ -2072,9 +2072,11 @@ static std::string getReciprocalOpName(bool IsSqrt, EVT VT) { Name += IsSqrt ? "sqrt" : "div"; - // TODO: Handle "half" or other float types? + // TODO: Handle other float types? if (VT.getScalarType() == MVT::f64) { Name += "d"; + } else if (VT.getScalarType() == MVT::f16) { + Name += "h"; } else { assert(VT.getScalarType() == MVT::f32 && "Unexpected FP type for reciprocal estimate"); |