[llvm] [VPlan] Use correct non-FMF constructor in VPInstructionWithType createNaryOp (PR #137632)
Luke Lau via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 28 06:24:58 PDT 2025
https://github.com/lukel97 created https://github.com/llvm/llvm-project/pull/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
>From bdb2b5e67bb414acfa299955657baecef4d6aba2 Mon Sep 17 00:00:00 2001
From: Luke Lau <luke at igalia.com>
Date: Mon, 28 Apr 2025 21:16:43 +0800
Subject: [PATCH] [VPlan] Use correct non-FMF constructor in
VPInstructionWithType createNaryOp
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
---
llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
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