aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Walker <paul.walker@arm.com>2025-07-29 12:37:59 +0100
committerGitHub <noreply@github.com>2025-07-29 12:37:59 +0100
commit1528ddbe76acbd80e3da44b3f248fc566d6ab40b (patch)
treed883d50cd5b51e1f501a268c8360289553680ff2
parente8b7183d866f9d51511d5570f5f1f632046ef983 (diff)
downloadllvm-1528ddbe76acbd80e3da44b3f248fc566d6ab40b.zip
llvm-1528ddbe76acbd80e3da44b3f248fc566d6ab40b.tar.gz
llvm-1528ddbe76acbd80e3da44b3f248fc566d6ab40b.tar.bz2
[ConstantFolding][SVE] Do not fold fcmp of denormal without known mode. (#150614)
This is a follow on to https://github.com/llvm/llvm-project/pull/115407 that introduced code which bypasses the splat handling for scalable vectors. To maintain existing tests I have moved the early return until after the splat handling so all vector types are treated equally.
-rw-r--r--llvm/lib/Analysis/ConstantFolding.cpp5
-rw-r--r--llvm/test/Transforms/SCCP/no-fold-fcmp-dynamic-denormal-mode-issue114947.ll7
2 files changed, 8 insertions, 4 deletions
diff --git a/llvm/lib/Analysis/ConstantFolding.cpp b/llvm/lib/Analysis/ConstantFolding.cpp
index 759c553..7341dad 100644
--- a/llvm/lib/Analysis/ConstantFolding.cpp
+++ b/llvm/lib/Analysis/ConstantFolding.cpp
@@ -1373,7 +1373,7 @@ Constant *llvm::FlushFPConstant(Constant *Operand, const Instruction *Inst,
if (ConstantFP *CFP = dyn_cast<ConstantFP>(Operand))
return flushDenormalConstantFP(CFP, Inst, IsOutput);
- if (isa<ConstantAggregateZero, UndefValue, ConstantExpr>(Operand))
+ if (isa<ConstantAggregateZero, UndefValue>(Operand))
return Operand;
Type *Ty = Operand->getType();
@@ -1389,6 +1389,9 @@ Constant *llvm::FlushFPConstant(Constant *Operand, const Instruction *Inst,
Ty = VecTy->getElementType();
}
+ if (isa<ConstantExpr>(Operand))
+ return Operand;
+
if (const auto *CV = dyn_cast<ConstantVector>(Operand)) {
SmallVector<Constant *, 16> NewElts;
for (unsigned i = 0, e = CV->getNumOperands(); i != e; ++i) {
diff --git a/llvm/test/Transforms/SCCP/no-fold-fcmp-dynamic-denormal-mode-issue114947.ll b/llvm/test/Transforms/SCCP/no-fold-fcmp-dynamic-denormal-mode-issue114947.ll
index 1eb5417..285122d 100644
--- a/llvm/test/Transforms/SCCP/no-fold-fcmp-dynamic-denormal-mode-issue114947.ll
+++ b/llvm/test/Transforms/SCCP/no-fold-fcmp-dynamic-denormal-mode-issue114947.ll
@@ -106,10 +106,11 @@ define <vscale x 2 x i1> @fold_fcmp_nondenormal_double_ieee_dynamic_scalable_vec
ret <vscale x 2 x i1> %cmp
}
-define <vscale x 2 x i1> @no_fold_fcmp_denormal_double_ieee_dynamic_scalaable_vector_splat() #0 {
-; CHECK-LABEL: define <vscale x 2 x i1> @no_fold_fcmp_denormal_double_ieee_dynamic_scalaable_vector_splat(
+define <vscale x 2 x i1> @no_fold_fcmp_denormal_double_ieee_dynamic_scalable_vector_splat() #0 {
+; CHECK-LABEL: define <vscale x 2 x i1> @no_fold_fcmp_denormal_double_ieee_dynamic_scalable_vector_splat(
; CHECK-SAME: ) #[[ATTR0]] {
-; CHECK-NEXT: ret <vscale x 2 x i1> splat (i1 true)
+; CHECK-NEXT: [[CMP:%.*]] = fcmp une <vscale x 2 x double> splat (double 0x8000000000000), zeroinitializer
+; CHECK-NEXT: ret <vscale x 2 x i1> [[CMP]]
;
%cmp = fcmp une <vscale x 2 x double> splat (double 0x8000000000000), zeroinitializer
ret <vscale x 2 x i1> %cmp