diff --git a/llvm/lib/Analysis/ConstantFolding.cpp b/llvm/lib/Analysis/ConstantFolding.cpp index e9eea82d60116..3c64ad6f6b369 100644 --- a/llvm/lib/Analysis/ConstantFolding.cpp +++ b/llvm/lib/Analysis/ConstantFolding.cpp @@ -1357,7 +1357,8 @@ static ConstantFP *flushDenormalConstant(Type *Ty, const APFloat &APF, static DenormalMode getInstrDenormalMode(const Instruction *CtxI, Type *Ty) { if (!CtxI || !CtxI->getParent() || !CtxI->getFunction()) return DenormalMode::getDynamic(); - return CtxI->getFunction()->getDenormalMode(Ty->getFltSemantics()); + return CtxI->getFunction()->getDenormalMode( + Ty->getScalarType()->getFltSemantics()); } static ConstantFP *flushDenormalConstantFP(ConstantFP *CFP, diff --git a/llvm/test/Transforms/InstSimplify/constant-fold-fp-denormal.ll b/llvm/test/Transforms/InstSimplify/constant-fold-fp-denormal.ll index 16d5f0d2871b1..39465bc1e5fe5 100644 --- a/llvm/test/Transforms/InstSimplify/constant-fold-fp-denormal.ll +++ b/llvm/test/Transforms/InstSimplify/constant-fold-fp-denormal.ll @@ -1,5 +1,6 @@ ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py ; RUN: opt -S -passes=instsimplify < %s | FileCheck %s +; RUN: opt -S -passes=instsimplify -use-constant-fp-for-fixed-length-splat < %s | FileCheck %s ; Test cases for denormal handling mode when constant folding floating point ; operations. Input and output modes are checked separately. @@ -1149,6 +1150,14 @@ define i1 @fcmp_double_dynamic_ieee() #9 { ret i1 %cmp } +define <2 x i1> @fcmp_double_dynamic_ieee_vector() #9 { +; CHECK-LABEL: @fcmp_double_dynamic_ieee_vector( +; CHECK-NEXT: ret <2 x i1> splat (i1 true) +; + %cmp = fcmp une <2 x double> splat(double 0x0008000000000000), zeroinitializer + ret <2 x i1> %cmp +} + define i1 @fcmp_double_ieee_dynamic() #10 { ; CHECK-LABEL: @fcmp_double_ieee_dynamic( ; CHECK-NEXT: [[CMP:%.*]] = fcmp une double 0x8000000000000, 0.000000e+00 @@ -1158,6 +1167,15 @@ define i1 @fcmp_double_ieee_dynamic() #10 { ret i1 %cmp } +define <2 x i1> @fcmp_double_ieee_dynamic_vector() #10 { +; CHECK-LABEL: @fcmp_double_ieee_dynamic_vector( +; CHECK-NEXT: [[CMP:%.*]] = fcmp une <2 x double> splat (double 0x8000000000000), zeroinitializer +; CHECK-NEXT: ret <2 x i1> [[CMP]] +; + %cmp = fcmp une <2 x double> splat(double 0x0008000000000000), zeroinitializer + ret <2 x i1> %cmp +} + define i1 @fcmp_double_dynamic_dynamic() #11 { ; CHECK-LABEL: @fcmp_double_dynamic_dynamic( ; CHECK-NEXT: [[CMP:%.*]] = fcmp une double 0x8000000000000, 0.000000e+00