diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h b/llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h index f639f0adb9c43..981ff7fc2364d 100644 --- a/llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h +++ b/llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h @@ -177,8 +177,11 @@ class VPBuilder { Type *ResultTy, std::optional FMFs = {}, DebugLoc DL = {}, const Twine &Name = "") { - return tryInsertInstruction(new VPInstructionWithType( - Opcode, Operands, ResultTy, FMFs.value_or(FastMathFlags()), DL, Name)); + if (FMFs) + return tryInsertInstruction(new VPInstructionWithType( + Opcode, Operands, ResultTy, *FMFs, DL, Name)); + return tryInsertInstruction( + new VPInstructionWithType(Opcode, Operands, ResultTy, DL, Name)); } VPInstruction *createOverflowingOp(unsigned Opcode,