aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib
diff options
context:
space:
mode:
authorYingwei Zheng <dtcxzyw2333@gmail.com>2025-02-25 22:03:17 +0800
committerGitHub <noreply@github.com>2025-02-25 22:03:17 +0800
commit44d1dbd24c20a0ee93063dcf44d68e2b8f0bf77c (patch)
tree1057e960ffce2a0d813ee3ae519ff7235560926f /llvm/lib
parentd21b2e619a5e23fd2f4cb05f5929990ee517d164 (diff)
downloadllvm-44d1dbd24c20a0ee93063dcf44d68e2b8f0bf77c.zip
llvm-44d1dbd24c20a0ee93063dcf44d68e2b8f0bf77c.tar.gz
llvm-44d1dbd24c20a0ee93063dcf44d68e2b8f0bf77c.tar.bz2
[X86][DAGCombiner] Skip x87 fp80 values in `combineFMulOrFDivWithIntPow2` (#128618)
f80 is not a valid IEEE floating-point type. Closes https://github.com/llvm/llvm-project/issues/128528.
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp7
-rw-r--r--llvm/lib/Support/APFloat.cpp5
2 files changed, 10 insertions, 2 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index a83be13..6746a5d 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -17271,6 +17271,9 @@ SDValue DAGCombiner::visitFSUB(SDNode *N) {
// prefer it.
SDValue DAGCombiner::combineFMulOrFDivWithIntPow2(SDNode *N) {
EVT VT = N->getValueType(0);
+ if (!APFloat::isIEEELikeFP(VT.getFltSemantics()))
+ return SDValue();
+
SDValue ConstOp, Pow2Op;
std::optional<int> Mantissa;
@@ -17297,8 +17300,8 @@ SDValue DAGCombiner::combineFMulOrFDivWithIntPow2(SDNode *N) {
const APFloat &APF = CFP->getValueAPF();
- // Make sure we have normal/ieee constant.
- if (!APF.isNormal() || !APF.isIEEE())
+ // Make sure we have normal constant.
+ if (!APF.isNormal())
return false;
// Make sure the floats exponent is within the bounds that this transform
diff --git a/llvm/lib/Support/APFloat.cpp b/llvm/lib/Support/APFloat.cpp
index b0d92ae..cbee7f4 100644
--- a/llvm/lib/Support/APFloat.cpp
+++ b/llvm/lib/Support/APFloat.cpp
@@ -353,6 +353,11 @@ bool APFloatBase::semanticsHasNaN(const fltSemantics &semantics) {
return semantics.nonFiniteBehavior != fltNonfiniteBehavior::FiniteOnly;
}
+bool APFloatBase::isIEEELikeFP(const fltSemantics &semantics) {
+ // Keep in sync with Type::isIEEELikeFPTy
+ return SemanticsToEnum(semantics) <= S_IEEEquad;
+}
+
bool APFloatBase::isRepresentableAsNormalIn(const fltSemantics &Src,
const fltSemantics &Dst) {
// Exponent range must be larger.