Skip to content

Commit ee764a2

Browse files
authored
[SLP] Remove -slp-optimize-identity-hor-reduction-ops option (#106238)
This code has been unchanged for two years; let's simplify the code and remove configurability which makes the code harder to follow.
1 parent 4c4908c commit ee764a2

File tree

3 files changed

+7
-45
lines changed

3 files changed

+7
-45
lines changed

llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -136,13 +136,6 @@ static cl::opt<bool> ShouldStartVectorizeHorAtStore(
136136
cl::desc(
137137
"Attempt to vectorize horizontal reductions feeding into a store"));
138138

139-
// NOTE: If AllowHorRdxIdenityOptimization is true, the optimization will run
140-
// even if we match a reduction but do not vectorize in the end.
141-
static cl::opt<bool> AllowHorRdxIdenityOptimization(
142-
"slp-optimize-identity-hor-reduction-ops", cl::init(true), cl::Hidden,
143-
cl::desc("Allow optimization of original scalar identity operations on "
144-
"matched horizontal reductions."));
145-
146139
static cl::opt<int>
147140
MaxVectorRegSizeOption("slp-max-reg-size", cl::init(128), cl::Hidden,
148141
cl::desc("Attempt to vectorize for this register size in bits"));
@@ -17599,10 +17592,9 @@ class HorizontalReduction {
1759917592
return Num + Vals.size();
1760017593
});
1760117594
NumReducedVals < ReductionLimit &&
17602-
(!AllowHorRdxIdenityOptimization ||
17603-
all_of(ReducedVals, [](ArrayRef<Value *> RedV) {
17595+
all_of(ReducedVals, [](ArrayRef<Value *> RedV) {
1760417596
return RedV.size() < 2 || !allConstant(RedV) || !isSplat(RedV);
17605-
}))) {
17597+
})) {
1760617598
for (ReductionOpsType &RdxOps : ReductionOps)
1760717599
for (Value *RdxOp : RdxOps)
1760817600
V.analyzedReductionRoot(cast<Instruction>(RdxOp));
@@ -17732,8 +17724,7 @@ class HorizontalReduction {
1773217724
}
1773317725

1773417726
// Emit code for constant values.
17735-
if (AllowHorRdxIdenityOptimization && Candidates.size() > 1 &&
17736-
allConstant(Candidates)) {
17727+
if (Candidates.size() > 1 && allConstant(Candidates)) {
1773717728
Value *Res = Candidates.front();
1773817729
++VectorizedVals.try_emplace(Candidates.front(), 0).first->getSecond();
1773917730
for (Value *VC : ArrayRef(Candidates).drop_front()) {
@@ -17748,15 +17739,14 @@ class HorizontalReduction {
1774817739

1774917740
unsigned NumReducedVals = Candidates.size();
1775017741
if (NumReducedVals < ReductionLimit &&
17751-
(NumReducedVals < 2 || !AllowHorRdxIdenityOptimization ||
17752-
!isSplat(Candidates)))
17742+
(NumReducedVals < 2 || !isSplat(Candidates)))
1775317743
continue;
1775417744

1775517745
// Check if we support repeated scalar values processing (optimization of
1775617746
// original scalar identity operations on matched horizontal reductions).
17757-
IsSupportedHorRdxIdentityOp =
17758-
AllowHorRdxIdenityOptimization && RdxKind != RecurKind::Mul &&
17759-
RdxKind != RecurKind::FMul && RdxKind != RecurKind::FMulAdd;
17747+
IsSupportedHorRdxIdentityOp = RdxKind != RecurKind::Mul &&
17748+
RdxKind != RecurKind::FMul &&
17749+
RdxKind != RecurKind::FMulAdd;
1776017750
// Gather same values.
1776117751
MapVector<Value *, unsigned> SameValuesCounter;
1776217752
if (IsSupportedHorRdxIdentityOp)

llvm/test/Transforms/SLPVectorizer/AArch64/buildvector-reduce.ll

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
22
; RUN: opt -S -passes=slp-vectorizer < %s -mtriple=arm64-apple-macosx | FileCheck %s
3-
; RUN: opt -S -passes=slp-vectorizer < %s -mtriple=arm64-apple-macosx -slp-optimize-identity-hor-reduction-ops=false | FileCheck %s --check-prefix=NO-IDENTITY
43

54
define i8 @test() {
65
; CHECK-LABEL: @test(
@@ -12,17 +11,6 @@ define i8 @test() {
1211
; CHECK-NEXT: [[TMP0]] = mul i32 [[CALL278]], 8
1312
; CHECK-NEXT: br label [[FOR_BODY]]
1413
;
15-
; NO-IDENTITY-LABEL: @test(
16-
; NO-IDENTITY-NEXT: entry:
17-
; NO-IDENTITY-NEXT: br label [[FOR_BODY:%.*]]
18-
; NO-IDENTITY: for.body:
19-
; NO-IDENTITY-NEXT: [[SUM:%.*]] = phi i32 [ [[TMP2:%.*]], [[FOR_BODY]] ], [ 0, [[ENTRY:%.*]] ]
20-
; NO-IDENTITY-NEXT: [[CALL278:%.*]] = call i32 @fn(i32 [[SUM]])
21-
; NO-IDENTITY-NEXT: [[TMP0:%.*]] = insertelement <8 x i32> poison, i32 [[CALL278]], i32 0
22-
; NO-IDENTITY-NEXT: [[TMP1:%.*]] = shufflevector <8 x i32> [[TMP0]], <8 x i32> poison, <8 x i32> zeroinitializer
23-
; NO-IDENTITY-NEXT: [[TMP2]] = call i32 @llvm.vector.reduce.add.v8i32(<8 x i32> [[TMP1]])
24-
; NO-IDENTITY-NEXT: br label [[FOR_BODY]]
25-
;
2614
entry:
2715
br label %for.body
2816

llvm/test/Transforms/SLPVectorizer/SystemZ/minbitwidth-non-vector-root.ll

Lines changed: 0 additions & 16 deletions
This file was deleted.

0 commit comments

Comments
 (0)