[PATCH] D111873: [NFC][LoopVectorize] Allow getRuntimeVF to generate FP values
David Sherwood via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 15 03:51:53 PDT 2021
david-arm created this revision.
david-arm added reviewers: sdesmalen, RosieSumpter, kmclaughlin.
Herald added a subscriber: hiraditya.
david-arm requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Given there is already code in the vectoriser that sometimes needs
to create a floating-point value for the runtime VF, it makes sense
to move the logic for the int->FP conversions into getRuntimeVF
itself.
This will also be useful in future when we want to add tail-folding
support for scalable vectors.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D111873
Files:
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
Index: llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
===================================================================
--- llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -1113,9 +1113,18 @@
namespace llvm {
/// Return the runtime value for VF.
-Value *getRuntimeVF(IRBuilder<> &B, Type *Ty, ElementCount VF) {
+Value *getRuntimeVF(IRBuilder<> &B, Type *OrigTy, ElementCount VF) {
+ Type *Ty = OrigTy;
+ if (Ty->isFloatingPointTy())
+ Ty = IntegerType::get(Ty->getContext(), Ty->getScalarSizeInBits());
+
Constant *EC = ConstantInt::get(Ty, VF.getKnownMinValue());
- return VF.isScalable() ? B.CreateVScale(EC) : EC;
+ Value *Res = VF.isScalable() ? B.CreateVScale(EC) : EC;
+
+ if (OrigTy->isFloatingPointTy())
+ Res = B.CreateSIToFP(Res, OrigTy);
+
+ return Res;
}
void reportVectorizationFailure(const StringRef DebugMsg,
@@ -2303,13 +2312,7 @@
// Multiply the vectorization factor by the step using integer or
// floating-point arithmetic as appropriate.
- Type *StepType = Step->getType();
- if (Step->getType()->isFloatingPointTy())
- StepType = IntegerType::get(StepType->getContext(),
- StepType->getScalarSizeInBits());
- Value *RuntimeVF = getRuntimeVF(Builder, StepType, VF);
- if (Step->getType()->isFloatingPointTy())
- RuntimeVF = Builder.CreateSIToFP(RuntimeVF, Step->getType());
+ Value *RuntimeVF = getRuntimeVF(Builder, Step->getType(), VF);
Value *Mul = Builder.CreateBinOp(MulOp, Step, RuntimeVF);
// Create a vector splat to use in the induction update.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D111873.379956.patch
Type: text/x-patch
Size: 1615 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211015/08aa57f9/attachment-0001.bin>
More information about the llvm-commits
mailing list