Skip to content

Commit 04b85e2

Browse files
committed
Revert "[SLP] Make sure instructions are ordered when computing spill cost."
This seems to break http://lab.llvm.org:8011/builders/llvm-clang-x86_64-expensive-checks-win/builds/24371 This reverts commit eb46137.
1 parent bdc3134 commit 04b85e2

File tree

2 files changed

+13
-23
lines changed

2 files changed

+13
-23
lines changed

llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3760,24 +3760,11 @@ int BoUpSLP::getSpillCost() const {
37603760
SmallPtrSet<Instruction*, 4> LiveValues;
37613761
Instruction *PrevInst = nullptr;
37623762

3763-
// The entries in VectorizableTree are not necessarily ordered by their
3764-
// position in basic blocks. Collect them and order them by dominance so later
3765-
// instructions are guaranteed to be visited first. For instructions in
3766-
// different basic blocks, we only scan to the beginning of the block, so
3767-
// their order does not matter, as long as all instructions in a basic block
3768-
// are grouped together. Using dominance ensures a deterministic order.
3769-
SmallVector<Instruction *, 16> OrderedScalars;
37703763
for (const auto &TEPtr : VectorizableTree) {
37713764
Instruction *Inst = dyn_cast<Instruction>(TEPtr->Scalars[0]);
37723765
if (!Inst)
37733766
continue;
3774-
OrderedScalars.push_back(Inst);
3775-
}
3776-
llvm::stable_sort(OrderedScalars, [this](Instruction *A, Instruction *B) {
3777-
return !DT->dominates(A, B);
3778-
});
37793767

3780-
for (Instruction *Inst : OrderedScalars) {
37813768
if (!PrevInst) {
37823769
PrevInst = Inst;
37833770
continue;

llvm/test/Transforms/SLPVectorizer/AArch64/spillcost-order.ll

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,22 @@ define void @test(i64* %ptr, i64* noalias %res) {
1313
; CHECK-NEXT: br label [[FOR_BODY:%.*]]
1414
; CHECK: for.body:
1515
; CHECK-NEXT: [[CALL_I_I:%.*]] = call i32* @get_ptr()
16+
; CHECK-NEXT: [[L_0_0:%.*]] = load i32, i32* [[CALL_I_I]], align 2
1617
; CHECK-NEXT: [[GEP_1:%.*]] = getelementptr i32, i32* [[CALL_I_I]], i32 2
18+
; CHECK-NEXT: [[L_1_0:%.*]] = load i32, i32* [[GEP_1]], align 2
19+
; CHECK-NEXT: [[EXT_0_0:%.*]] = zext i32 [[L_0_0]] to i64
20+
; CHECK-NEXT: [[EXT_1_0:%.*]] = zext i32 [[L_1_0]] to i64
21+
; CHECK-NEXT: [[SUB_1:%.*]] = sub nsw i64 [[EXT_0_0]], [[EXT_1_0]]
1722
; CHECK-NEXT: [[GEP_2:%.*]] = getelementptr i32, i32* [[CALL_I_I]], i32 1
18-
; CHECK-NEXT: [[TMP0:%.*]] = bitcast i32* [[CALL_I_I]] to <2 x i32>*
19-
; CHECK-NEXT: [[TMP1:%.*]] = load <2 x i32>, <2 x i32>* [[TMP0]], align 2
23+
; CHECK-NEXT: [[L_0_1:%.*]] = load i32, i32* [[GEP_2]], align 2
2024
; CHECK-NEXT: [[GEP_3:%.*]] = getelementptr i32, i32* [[CALL_I_I]], i32 3
21-
; CHECK-NEXT: [[TMP2:%.*]] = bitcast i32* [[GEP_1]] to <2 x i32>*
22-
; CHECK-NEXT: [[TMP3:%.*]] = load <2 x i32>, <2 x i32>* [[TMP2]], align 2
23-
; CHECK-NEXT: [[TMP4:%.*]] = zext <2 x i32> [[TMP1]] to <2 x i64>
24-
; CHECK-NEXT: [[TMP5:%.*]] = zext <2 x i32> [[TMP3]] to <2 x i64>
25-
; CHECK-NEXT: [[TMP6:%.*]] = sub nsw <2 x i64> [[TMP4]], [[TMP5]]
26-
; CHECK-NEXT: [[RES_1:%.*]] = getelementptr i64, i64* [[RES:%.*]], i64 1
27-
; CHECK-NEXT: [[TMP7:%.*]] = bitcast i64* [[RES]] to <2 x i64>*
28-
; CHECK-NEXT: store <2 x i64> [[TMP6]], <2 x i64>* [[TMP7]], align 8
25+
; CHECK-NEXT: [[L_1_1:%.*]] = load i32, i32* [[GEP_3]], align 2
26+
; CHECK-NEXT: [[EXT_0_1:%.*]] = zext i32 [[L_0_1]] to i64
27+
; CHECK-NEXT: [[EXT_1_1:%.*]] = zext i32 [[L_1_1]] to i64
28+
; CHECK-NEXT: [[SUB_2:%.*]] = sub nsw i64 [[EXT_0_1]], [[EXT_1_1]]
29+
; CHECK-NEXT: store i64 [[SUB_1]], i64* [[RES:%.*]], align 8
30+
; CHECK-NEXT: [[RES_1:%.*]] = getelementptr i64, i64* [[RES]], i64 1
31+
; CHECK-NEXT: store i64 [[SUB_2]], i64* [[RES_1]], align 8
2932
; CHECK-NEXT: [[C:%.*]] = call i1 @cond()
3033
; CHECK-NEXT: br i1 [[C]], label [[FOR_BODY]], label [[EXIT:%.*]]
3134
; CHECK: exit:

0 commit comments

Comments
 (0)