Skip to content

Commit 00a1032

Browse files
Clean up usages of asserting vector getters in Type
Summary: Remove usages of asserting vector getters in Type in preparation for the VectorType refactor. The existence of these functions complicates the refactor while adding little value. Reviewers: rriddle, sdesmalen, efriedma Reviewed By: sdesmalen Subscribers: hiraditya, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D77260
1 parent 5e7b98f commit 00a1032

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

llvm/lib/Transforms/Utils/LoopUtils.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -880,7 +880,7 @@ llvm::getOrderedReduction(IRBuilderBase &Builder, Value *Acc, Value *Src,
880880
unsigned Op,
881881
RecurrenceDescriptor::MinMaxRecurrenceKind MinMaxKind,
882882
ArrayRef<Value *> RedOps) {
883-
unsigned VF = Src->getType()->getVectorNumElements();
883+
unsigned VF = cast<VectorType>(Src->getType())->getNumElements();
884884

885885
// Extract and apply reduction ops in ascending order:
886886
// e.g. ((((Acc + Scl[0]) + Scl[1]) + Scl[2]) + ) ... + Scl[VF-1]
@@ -910,7 +910,7 @@ Value *
910910
llvm::getShuffleReduction(IRBuilderBase &Builder, Value *Src, unsigned Op,
911911
RecurrenceDescriptor::MinMaxRecurrenceKind MinMaxKind,
912912
ArrayRef<Value *> RedOps) {
913-
unsigned VF = Src->getType()->getVectorNumElements();
913+
unsigned VF = cast<VectorType>(Src->getType())->getNumElements();
914914
// VF is a power of 2 so we can emit the reduction using log2(VF) shuffles
915915
// and vector ops, reducing the set of values being computed by half each
916916
// round.
@@ -958,7 +958,7 @@ Value *llvm::createSimpleTargetReduction(
958958
IRBuilderBase &Builder, const TargetTransformInfo *TTI, unsigned Opcode,
959959
Value *Src, TargetTransformInfo::ReductionFlags Flags,
960960
ArrayRef<Value *> RedOps) {
961-
assert(isa<VectorType>(Src->getType()) && "Type must be a vector");
961+
auto *SrcVTy = cast<VectorType>(Src->getType());
962962

963963
std::function<Value *()> BuildFunc;
964964
using RD = RecurrenceDescriptor;
@@ -983,13 +983,13 @@ Value *llvm::createSimpleTargetReduction(
983983
case Instruction::FAdd:
984984
BuildFunc = [&]() {
985985
auto Rdx = Builder.CreateFAddReduce(
986-
Constant::getNullValue(Src->getType()->getVectorElementType()), Src);
986+
Constant::getNullValue(SrcVTy->getElementType()), Src);
987987
return Rdx;
988988
};
989989
break;
990990
case Instruction::FMul:
991991
BuildFunc = [&]() {
992-
Type *Ty = Src->getType()->getVectorElementType();
992+
Type *Ty = SrcVTy->getElementType();
993993
auto Rdx = Builder.CreateFMulReduce(ConstantFP::get(Ty, 1.0), Src);
994994
return Rdx;
995995
};

0 commit comments

Comments
 (0)