Skip to content

Commit 9a6a723

Browse files
committed
[TTI] Change the prototype of preferInLoopReductionwq
1 parent 01f0425 commit 9a6a723

File tree

8 files changed

+15
-16
lines changed

8 files changed

+15
-16
lines changed

llvm/include/llvm/Analysis/TargetTransformInfo.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
#include "llvm/ADT/APInt.h"
2525
#include "llvm/ADT/ArrayRef.h"
26+
#include "llvm/Analysis/IVDescriptors.h"
2627
#include "llvm/IR/FMF.h"
2728
#include "llvm/IR/InstrTypes.h"
2829
#include "llvm/IR/PassManager.h"
@@ -1776,7 +1777,7 @@ class TargetTransformInfo {
17761777
bool preferAlternateOpcodeVectorization() const;
17771778

17781779
/// \returns True if the target prefers reductions in loop.
1779-
bool preferInLoopReduction(unsigned Opcode, Type *Ty) const;
1780+
bool preferInLoopReduction(RecurKind Kind, Type *Ty) const;
17801781

17811782
/// \returns True if the target prefers reductions select kept in the loop
17821783
/// when tail folding. i.e.
@@ -2326,7 +2327,7 @@ class TargetTransformInfo::Concept {
23262327
unsigned ChainSizeInBytes,
23272328
VectorType *VecTy) const = 0;
23282329
virtual bool preferFixedOverScalableIfEqualCost() const = 0;
2329-
virtual bool preferInLoopReduction(unsigned Opcode, Type *Ty) const = 0;
2330+
virtual bool preferInLoopReduction(RecurKind Kind, Type *Ty) const = 0;
23302331
virtual bool preferPredicatedReductionSelect(unsigned Opcode,
23312332
Type *Ty) const = 0;
23322333
virtual bool preferAlternateOpcodeVectorization() const = 0;
@@ -3137,8 +3138,8 @@ class TargetTransformInfo::Model final : public TargetTransformInfo::Concept {
31373138
bool preferFixedOverScalableIfEqualCost() const override {
31383139
return Impl.preferFixedOverScalableIfEqualCost();
31393140
}
3140-
bool preferInLoopReduction(unsigned Opcode, Type *Ty) const override {
3141-
return Impl.preferInLoopReduction(Opcode, Ty);
3141+
bool preferInLoopReduction(RecurKind Kind, Type *Ty) const override {
3142+
return Impl.preferInLoopReduction(Kind, Ty);
31423143
}
31433144
bool preferAlternateOpcodeVectorization() const override {
31443145
return Impl.preferAlternateOpcodeVectorization();

llvm/include/llvm/Analysis/TargetTransformInfoImpl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1006,7 +1006,7 @@ class TargetTransformInfoImplBase {
10061006

10071007
bool preferFixedOverScalableIfEqualCost() const { return false; }
10081008

1009-
bool preferInLoopReduction(unsigned Opcode, Type *Ty) const { return false; }
1009+
bool preferInLoopReduction(RecurKind Kind, Type *Ty) const { return false; }
10101010
bool preferAlternateOpcodeVectorization() const { return true; }
10111011

10121012
bool preferPredicatedReductionSelect(unsigned Opcode, Type *Ty) const {

llvm/lib/Analysis/TargetTransformInfo.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1379,9 +1379,9 @@ bool TargetTransformInfo::preferFixedOverScalableIfEqualCost() const {
13791379
return TTIImpl->preferFixedOverScalableIfEqualCost();
13801380
}
13811381

1382-
bool TargetTransformInfo::preferInLoopReduction(unsigned Opcode,
1382+
bool TargetTransformInfo::preferInLoopReduction(RecurKind Kind,
13831383
Type *Ty) const {
1384-
return TTIImpl->preferInLoopReduction(Opcode, Ty);
1384+
return TTIImpl->preferInLoopReduction(Kind, Ty);
13851385
}
13861386

13871387
bool TargetTransformInfo::preferAlternateOpcodeVectorization() const {

llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
#include "MCTargetDesc/AArch64AddressingModes.h"
1313
#include "Utils/AArch64SMEAttributes.h"
1414
#include "llvm/ADT/DenseMap.h"
15-
#include "llvm/Analysis/IVDescriptors.h"
1615
#include "llvm/Analysis/LoopInfo.h"
1716
#include "llvm/Analysis/TargetTransformInfo.h"
1817
#include "llvm/CodeGen/BasicTTIImpl.h"

llvm/lib/Target/ARM/ARMTargetTransformInfo.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2690,13 +2690,13 @@ void ARMTTIImpl::getPeelingPreferences(Loop *L, ScalarEvolution &SE,
26902690
BaseT::getPeelingPreferences(L, SE, PP);
26912691
}
26922692

2693-
bool ARMTTIImpl::preferInLoopReduction(unsigned Opcode, Type *Ty) const {
2693+
bool ARMTTIImpl::preferInLoopReduction(RecurKind Kind, Type *Ty) const {
26942694
if (!ST->hasMVEIntegerOps())
26952695
return false;
26962696

26972697
unsigned ScalarBits = Ty->getScalarSizeInBits();
2698-
switch (Opcode) {
2699-
case Instruction::Add:
2698+
switch (Kind) {
2699+
case RecurKind::Add:
27002700
return ScalarBits <= 64;
27012701
default:
27022702
return false;

llvm/lib/Target/ARM/ARMTargetTransformInfo.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ class ARMTTIImpl : public BasicTTIImplBase<ARMTTIImpl> {
223223
ArrayRef<const Value *> Args = {},
224224
const Instruction *CxtI = nullptr);
225225

226-
bool preferInLoopReduction(unsigned Opcode, Type *Ty) const;
226+
bool preferInLoopReduction(RecurKind Kind, Type *Ty) const;
227227

228228
bool preferPredicatedReductionSelect(unsigned Opcode, Type *Ty) const;
229229

llvm/lib/Target/RISCV/RISCVTargetTransformInfo.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
#include "RISCVSubtarget.h"
2020
#include "RISCVTargetMachine.h"
21-
#include "llvm/Analysis/IVDescriptors.h"
2221
#include "llvm/Analysis/TargetTransformInfo.h"
2322
#include "llvm/CodeGen/BasicTTIImpl.h"
2423
#include "llvm/IR/Function.h"

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4867,7 +4867,7 @@ void LoopVectorizationCostModel::collectElementTypesForWidening() {
48674867
const RecurrenceDescriptor &RdxDesc =
48684868
Legal->getReductionVars().find(PN)->second;
48694869
if (PreferInLoopReductions || useOrderedReductions(RdxDesc) ||
4870-
TTI.preferInLoopReduction(RdxDesc.getOpcode(),
4870+
TTI.preferInLoopReduction(RdxDesc.getRecurrenceKind(),
48714871
RdxDesc.getRecurrenceType()))
48724872
continue;
48734873
T = RdxDesc.getRecurrenceType();
@@ -7034,9 +7034,9 @@ void LoopVectorizationCostModel::collectInLoopReductions() {
70347034

70357035
// If the target would prefer this reduction to happen "in-loop", then we
70367036
// want to record it as such.
7037-
unsigned Opcode = RdxDesc.getOpcode();
7037+
RecurKind Kind = RdxDesc.getRecurrenceKind();
70387038
if (!PreferInLoopReductions && !useOrderedReductions(RdxDesc) &&
7039-
!TTI.preferInLoopReduction(Opcode, Phi->getType()))
7039+
!TTI.preferInLoopReduction(Kind, Phi->getType()))
70407040
continue;
70417041

70427042
// Check that we can correctly put the reductions into the loop, by

0 commit comments

Comments
 (0)