diff --git a/llvm/lib/AsmParser/LLParser.cpp b/llvm/lib/AsmParser/LLParser.cpp --- a/llvm/lib/AsmParser/LLParser.cpp +++ b/llvm/lib/AsmParser/LLParser.cpp @@ -6785,10 +6785,6 @@ ParseOptionalOperandBundles(BundleList, PFS)) return true; - if (FMF.any() && !RetType->isFPOrFPVectorTy()) - return Error(CallLoc, "fast-math-flags specified for call without " - "floating-point scalar or vector return type"); - // If RetType is a non-function pointer type, then this is the short syntax // for the call, which means that RetType is just the return type. Infer the // rest of the function argument types from the arguments that are present. @@ -6803,7 +6799,12 @@ return Error(RetTypeLoc, "Invalid result type for LLVM function"); Ty = FunctionType::get(RetType, ParamTypes, false); - } + } else + RetType = Ty->getReturnType(); + + if (FMF.any() && !RetType->isFPOrFPVectorTy()) + return Error(CallLoc, "fast-math-flags specified for call without " + "floating-point scalar or vector return type"); CalleeID.FTy = Ty; diff --git a/llvm/test/Assembler/fast-math-flags.ll b/llvm/test/Assembler/fast-math-flags.ll --- a/llvm/test/Assembler/fast-math-flags.ll +++ b/llvm/test/Assembler/fast-math-flags.ll @@ -189,3 +189,31 @@ ; CHECK: ret float %f ret float %f } + +; CHECK: @fmf_calls( +define float @fmf_calls(float %x, float %y) { +entry: +; CHECK: %vec = load <3 x float>, <3 x float>* @vec + %vec = load <3 x float>, <3 x float>* @vec +; CHECK: %select = load i1, i1* @select + %select = load i1, i1* @select +; CHECK: %arr = load [3 x float], [3 x float]* @arr + %arr = load [3 x float], [3 x float]* @arr + +; CHECK: %a = call nnan ninf afn float @extfunc(float %x, float %y) + %a = call ninf nnan afn float @extfunc(float %x, float %y) +; CHECK: %a_vec = call reassoc nnan <3 x float> @extfunc_vec(<3 x float> %vec, <3 x float> %vec) + %a_vec = call reassoc nnan <3 x float> @extfunc_vec(<3 x float> %vec, <3 x float> %vec) +; CHECK: %b = call nnan ninf afn float (...) @var_extfunc(float %x, float %y) + %b = call ninf nnan afn float (...) @var_extfunc(float %x, float %y) +; CHECK: %b_vec = call reassoc nnan <3 x float> (...) @var_extfunc_vec(<3 x float> %vec, <3 x float> %vec) + %b_vec = call reassoc nnan <3 x float> (...) @var_extfunc_vec(<3 x float> %vec, <3 x float> %vec) +; CHECK: ret float %a + ret float %a +} + +declare float @extfunc(float, float) +declare <3 x float> @extfunc_vec(<3 x float>, <3 x float>) +declare float @var_extfunc(...) +declare <3 x float> @var_extfunc_vec(...) +