Skip to content

Commit bcbdeaf

Browse files
committed
Revert "[SLP]Need shrink the load vector after reordering."
This reverts commit 4284afd. This changes computed values in fused_batchnorm_test_cpu. Not equal to tolerance rtol=1e-06, atol=0.001 Mismatched value: a is different from b. not close where = (array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]), array([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]), array([0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1]), array([0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5])) not close lhs = [-0.6636615 -0.9804948 -1.148275 -0.68193716 -0.8572368 -0.65046215 -0.6993756 -1.2244141 -1.0938729 -0.50369143 -0.51830524 -0.738452 -0.7214286 -0.48115745 -0.9380924 -0.9341769 -0.5916775 -1.2896856 -0.7264182 -0.9746917 -0.783249 -0.7659018 -0.86214024 -0.47784212] not close rhs = [ 0.44102234 0.12418899 -0.04359123 0.42274666 0.24744703 0.45422167 0.40530816 -0.11973029 0.01081094 0.6009924 0.5863786 0.3662318 0.38325527 0.62352633 0.1665914 0.1705069 0.5130063 -0.18500176 0.37826565 0.12999213 0.3214348 0.338782 0.24254355 0.62684166] not close dif = [1.1046839 1.1046838 1.1046838 1.1046839 1.1046839 1.1046839 1.1046838 1.1046839 1.1046839 1.1046839 1.1046839 1.1046839 1.1046839 1.1046838 1.1046839 1.1046839 1.1046839 1.1046839 1.1046839 1.1046839 1.1046839 1.1046839 1.1046838 1.1046838] not close tol = [0.00100044 0.00100012 0.00100004 0.00100042 0.00100025 0.00100045 0.00100041 0.00100012 0.00100001 0.0010006 0.00100059 0.00100037 0.00100038 0.00100062 0.00100017 0.00100017 0.00100051 0.00100019 0.00100038 0.00100013 0.00100032 0.00100034 0.00100024 0.00100063]
1 parent 657db0c commit bcbdeaf

2 files changed

Lines changed: 13 additions & 9 deletions

File tree

‎llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp‎

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4260,13 +4260,18 @@ Value *BoUpSLP::vectorizeTree(ArrayRef<Value *> VL) {
42604260
if (E->isSame(VL)) {
42614261
Value *V = vectorizeTree(E);
42624262
if (VL.size() == E->Scalars.size() && !E->ReuseShuffleIndices.empty()) {
4263-
// Reshuffle to get only unique values.
4264-
SmallVector<int, 4> UniqueIdxs;
4265-
SmallSet<int, 4> UsedIdxs;
4266-
for (int Idx : E->ReuseShuffleIndices)
4267-
if (UsedIdxs.insert(Idx).second)
4268-
UniqueIdxs.emplace_back(Idx);
4269-
V = Builder.CreateShuffleVector(V, UniqueIdxs, "shrink.shuffle");
4263+
// We need to get the vectorized value but without shuffle.
4264+
if (auto *SV = dyn_cast<ShuffleVectorInst>(V)) {
4265+
V = SV->getOperand(0);
4266+
} else {
4267+
// Reshuffle to get only unique values.
4268+
SmallVector<int, 4> UniqueIdxs;
4269+
SmallSet<int, 4> UsedIdxs;
4270+
for (int Idx : E->ReuseShuffleIndices)
4271+
if (UsedIdxs.insert(Idx).second)
4272+
UniqueIdxs.emplace_back(Idx);
4273+
V = Builder.CreateShuffleVector(V, UniqueIdxs);
4274+
}
42704275
}
42714276
return V;
42724277
}

‎llvm/test/Transforms/SLPVectorizer/X86/shrink_after_reorder.ll‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ define void @wombat(i32* %ptr, i32* %ptr1) {
1010
; CHECK-NEXT: [[TMP1:%.*]] = load <2 x i32>, <2 x i32>* [[TMP0]], align 8
1111
; CHECK-NEXT: [[SHUFFLE:%.*]] = shufflevector <2 x i32> [[TMP1]], <2 x i32> poison, <4 x i32> <i32 1, i32 0, i32 1, i32 0>
1212
; CHECK-NEXT: [[TMP27:%.*]] = getelementptr inbounds i32, i32* [[PTR1:%.*]], i32 3
13-
; CHECK-NEXT: [[SHRINK_SHUFFLE:%.*]] = shufflevector <4 x i32> [[SHUFFLE]], <4 x i32> poison, <2 x i32> <i32 0, i32 1>
14-
; CHECK-NEXT: [[TMP2:%.*]] = add nsw <2 x i32> [[SHRINK_SHUFFLE]], <i32 -1, i32 -1>
13+
; CHECK-NEXT: [[TMP2:%.*]] = add nsw <2 x i32> [[TMP1]], <i32 -1, i32 -1>
1514
; CHECK-NEXT: [[SHUFFLE1:%.*]] = shufflevector <2 x i32> [[TMP2]], <2 x i32> poison, <4 x i32> <i32 0, i32 1, i32 0, i32 1>
1615
; CHECK-NEXT: [[TMP34:%.*]] = getelementptr inbounds i32, i32* [[PTR1]], i32 4
1716
; CHECK-NEXT: [[TMP40:%.*]] = getelementptr inbounds i32, i32* [[PTR1]], i32 5

0 commit comments

Comments
 (0)