[llvm] b0f2bfc - [VPlan] Use correct non-FMF constructor in VPInstructionWithType createNaryOp (#137632)

via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 29 05:35:24 PDT 2025


Author: Luke Lau
Date: 2025-04-29T20:35:19+08:00
New Revision: b0f2bfc7e45427b2df8d45f3cd40c833d1f3bab6

URL: https://github.com/llvm/llvm-project/commit/b0f2bfc7e45427b2df8d45f3cd40c833d1f3bab6
DIFF: https://github.com/llvm/llvm-project/commit/b0f2bfc7e45427b2df8d45f3cd40c833d1f3bab6.diff

LOG: [VPlan] Use correct non-FMF constructor in VPInstructionWithType createNaryOp (#137632)

Currently if we try to create a VPInstructionWithType without a FMF via
VPBuilder::createNaryOp we will use the constructor that asserts
`assert(isFPMathOp() && "this op can't take fast-math flags");`.

This fixes it by checking if FMFs have a value, similar to the other
createNaryOp overloads.

This is needed by #129508

Added: 
    

Modified: 
    llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h

Removed: 
    


################################################################################
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<FastMathFlags> 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,


        


More information about the llvm-commits mailing list