From 2d5f025779f497c54d90ddabbf2ef5290576dfd2 Mon Sep 17 00:00:00 2001 From: Philip Reames Date: Fri, 26 Aug 2022 09:37:45 -0700 Subject: [PATCH] [LV] Extract utility for checking if VPValue is uniform [nfc] --- llvm/lib/Transforms/Vectorize/LoopVectorize.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp index efff051..68fab0f 100644 --- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp +++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp @@ -2721,6 +2721,14 @@ void InnerLoopVectorizer::vectorizeInterleaveGroup( } } +/// Return true if this VPValue represents a computation which is +/// uniform-per-part. +static bool isUniform(VPValue *VPV) { + if (VPReplicateRecipe *OperandR = dyn_cast(VPV)) + return OperandR->isUniform(); + return false; +} + void InnerLoopVectorizer::scalarizeInstruction(Instruction *Instr, VPReplicateRecipe *RepRecipe, const VPIteration &Instance, @@ -2758,8 +2766,7 @@ void InnerLoopVectorizer::scalarizeInstruction(Instruction *Instr, for (const auto &I : enumerate(RepRecipe->operands())) { auto InputInstance = Instance; VPValue *Operand = I.value(); - VPReplicateRecipe *OperandR = dyn_cast(Operand); - if (OperandR && OperandR->isUniform()) + if (isUniform(Operand)) InputInstance.Lane = VPLane::getFirstLane(); Cloned->setOperand(I.index(), State.get(Operand, InputInstance)); } @@ -9868,8 +9875,7 @@ Value *VPTransformState::get(VPValue *Def, unsigned Part) { return ScalarValue; } - auto *RepR = dyn_cast(Def); - bool IsUniform = RepR && RepR->isUniform(); + bool IsUniform = isUniform(Def); unsigned LastLane = IsUniform ? 0 : VF.getKnownMinValue() - 1; // Check if there is a scalar value for the selected lane. -- 2.7.4