Skip to content

Commit 1528ddb

Browse files
[ConstantFolding][SVE] Do not fold fcmp of denormal without known mode. (#150614)
This is a follow on to #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.
1 parent e8b7183 commit 1528ddb

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

llvm/lib/Analysis/ConstantFolding.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1373,7 +1373,7 @@ Constant *llvm::FlushFPConstant(Constant *Operand, const Instruction *Inst,
13731373
if (ConstantFP *CFP = dyn_cast<ConstantFP>(Operand))
13741374
return flushDenormalConstantFP(CFP, Inst, IsOutput);
13751375

1376-
if (isa<ConstantAggregateZero, UndefValue, ConstantExpr>(Operand))
1376+
if (isa<ConstantAggregateZero, UndefValue>(Operand))
13771377
return Operand;
13781378

13791379
Type *Ty = Operand->getType();
@@ -1389,6 +1389,9 @@ Constant *llvm::FlushFPConstant(Constant *Operand, const Instruction *Inst,
13891389
Ty = VecTy->getElementType();
13901390
}
13911391

1392+
if (isa<ConstantExpr>(Operand))
1393+
return Operand;
1394+
13921395
if (const auto *CV = dyn_cast<ConstantVector>(Operand)) {
13931396
SmallVector<Constant *, 16> NewElts;
13941397
for (unsigned i = 0, e = CV->getNumOperands(); i != e; ++i) {

llvm/test/Transforms/SCCP/no-fold-fcmp-dynamic-denormal-mode-issue114947.ll

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,11 @@ define <vscale x 2 x i1> @fold_fcmp_nondenormal_double_ieee_dynamic_scalable_vec
106106
ret <vscale x 2 x i1> %cmp
107107
}
108108

109-
define <vscale x 2 x i1> @no_fold_fcmp_denormal_double_ieee_dynamic_scalaable_vector_splat() #0 {
110-
; CHECK-LABEL: define <vscale x 2 x i1> @no_fold_fcmp_denormal_double_ieee_dynamic_scalaable_vector_splat(
109+
define <vscale x 2 x i1> @no_fold_fcmp_denormal_double_ieee_dynamic_scalable_vector_splat() #0 {
110+
; CHECK-LABEL: define <vscale x 2 x i1> @no_fold_fcmp_denormal_double_ieee_dynamic_scalable_vector_splat(
111111
; CHECK-SAME: ) #[[ATTR0]] {
112-
; CHECK-NEXT: ret <vscale x 2 x i1> splat (i1 true)
112+
; CHECK-NEXT: [[CMP:%.*]] = fcmp une <vscale x 2 x double> splat (double 0x8000000000000), zeroinitializer
113+
; CHECK-NEXT: ret <vscale x 2 x i1> [[CMP]]
113114
;
114115
%cmp = fcmp une <vscale x 2 x double> splat (double 0x8000000000000), zeroinitializer
115116
ret <vscale x 2 x i1> %cmp

0 commit comments

Comments
 (0)