[llvm] [VectorCombine] Pass flags during IR creation (PR #193271)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 28 00:31:26 PDT 2026
================
@@ -1445,19 +1445,45 @@ bool VectorCombine::scalarizeOpOrCmp(Instruction &I) {
cast<Constant>(VecC), Builder.getInt64(*Index));
Value *Scalar;
- if (CI)
- Scalar = Builder.CreateCmp(CI->getPredicate(), ScalarOps[0], ScalarOps[1]);
- else if (UO || BO)
- Scalar = Builder.CreateNAryOp(Opcode, ScalarOps);
- else
+ // We need to pass the flags during the creation of instrucitons. Constant
+ // folding might remove the instructions, so post setting the flags might
+ // pollute the later instructions.
+ if (CI) {
+ if (FPMathOperator *FPMO = dyn_cast<FPMathOperator>(&I))
+ Scalar = Builder.CreateFCmpFMF(CI->getPredicate(), ScalarOps[0],
+ ScalarOps[1], FPMO->getFastMathFlags(),
+ CI->getName() + ".scalar");
+ else
+ Scalar = Builder.CreateICmp(CI->getPredicate(), ScalarOps[0],
+ ScalarOps[1], CI->getName() + ".scalar");
+ } else if (UO) {
+ // FNeg is the only unary operator.
----------------
arsenm wrote:
maybe add a cast to fneg to be sure
https://github.com/llvm/llvm-project/pull/193271
More information about the llvm-commits
mailing list