[llvm] 7ce48be - [LV] Inline CreateSplatIV call for scalar VFs (NFC).
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 13 01:34:43 PST 2022
Author: Florian Hahn
Date: 2022-01-13T09:34:31Z
New Revision: 7ce48be0fd83fb4fe3d0104f324bbbcfcc82983c
URL: https://github.com/llvm/llvm-project/commit/7ce48be0fd83fb4fe3d0104f324bbbcfcc82983c
DIFF: https://github.com/llvm/llvm-project/commit/7ce48be0fd83fb4fe3d0104f324bbbcfcc82983c.diff
LOG: [LV] Inline CreateSplatIV call for scalar VFs (NFC).
This is a NFC change split off from D116123, as suggested there.
D116123 will remove the last user of CreateSplatIV.
Added:
Modified:
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
llvm/test/Transforms/LoopVectorize/float-induction.ll
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 349a690bfaaa3..3e1e8d67af4d4 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -2580,7 +2580,26 @@ void InnerLoopVectorizer::widenIntOrFpInduction(
Value *Step = CreateStepValue(ID.getStep());
if (State.VF.isScalar()) {
Value *ScalarIV = CreateScalarIV(Step);
- CreateSplatIV(ScalarIV, Step);
+ Type *ScalarTy = IntegerType::get(ScalarIV->getContext(),
+ Step->getType()->getScalarSizeInBits());
+ for (unsigned Part = 0; Part < UF; ++Part) {
+ Value *StartIdx = ConstantInt::get(ScalarTy, Part);
+ Instruction::BinaryOps MulOp = Instruction::Mul;
+ if (Step->getType()->isFloatingPointTy()) {
+ StartIdx = Builder.CreateUIToFP(StartIdx, Step->getType());
+ MulOp = Instruction::FMul;
+ }
+
+ Value *Mul = Builder.CreateBinOp(MulOp, StartIdx, Step);
+ Value *EntryPart = Builder.CreateBinOp(ID.getInductionOpcode(), ScalarIV,
+ Mul, "induction");
+ State.set(Def, EntryPart, Part);
+ if (Trunc) {
+ assert(!Step->getType()->isFloatingPointTy() &&
+ "fp inductions shouldn't be truncated");
+ addMetadata(EntryPart, Trunc);
+ }
+ }
return;
}
diff --git a/llvm/test/Transforms/LoopVectorize/float-induction.ll b/llvm/test/Transforms/LoopVectorize/float-induction.ll
index ab243a1b9a925..00ae26cd6a83d 100644
--- a/llvm/test/Transforms/LoopVectorize/float-induction.ll
+++ b/llvm/test/Transforms/LoopVectorize/float-induction.ll
@@ -1603,11 +1603,11 @@ define void @non_primary_iv_float_scalar(float* %A, i64 %N) {
; VEC1_INTERL2-NEXT: br label [[PRED_STORE_CONTINUE]]
; VEC1_INTERL2: pred.store.continue:
; VEC1_INTERL2-NEXT: br i1 [[TMP6]], label [[PRED_STORE_IF4:%.*]], label [[PRED_STORE_CONTINUE5]]
-; VEC1_INTERL2: pred.store.if4:
+; VEC1_INTERL2: pred.store.if6:
; VEC1_INTERL2-NEXT: [[TMP7:%.*]] = fadd fast float [[TMP0]], 1.000000e+00
; VEC1_INTERL2-NEXT: store float [[TMP7]], float* [[TMP2]], align 4
; VEC1_INTERL2-NEXT: br label [[PRED_STORE_CONTINUE5]]
-; VEC1_INTERL2: pred.store.continue5:
+; VEC1_INTERL2: pred.store.continue7:
; VEC1_INTERL2-NEXT: [[INDEX_NEXT]] = add nuw i64 [[INDEX]], 2
; VEC1_INTERL2-NEXT: [[TMP8:%.*]] = icmp eq i64 [[INDEX_NEXT]], [[N_VEC]]
; VEC1_INTERL2-NEXT: br i1 [[TMP8]], label [[MIDDLE_BLOCK:%.*]], label [[VECTOR_BODY]], !llvm.loop [[LOOP11:![0-9]+]]
More information about the llvm-commits
mailing list