File tree Expand file tree Collapse file tree 2 files changed +12
-7
lines changed
test/Transforms/SLPVectorizer/X86 Expand file tree Collapse file tree 2 files changed +12
-7
lines changed Original file line number Diff line number Diff line change @@ -10768,17 +10768,21 @@ InstructionCost BoUpSLP::getTreeCost(ArrayRef<Value *> VectorizedVals) {
1076810768 std::optional<DenseMap<Value *, unsigned>> ValueToExtUses;
1076910769 DenseMap<const TreeEntry *, DenseSet<Value *>> ExtractsCount;
1077010770 for (ExternalUser &EU : ExternalUses) {
10771+ // Uses by ephemeral values are free (because the ephemeral value will be
10772+ // removed prior to code generation, and so the extraction will be
10773+ // removed as well) as well as uses in unreachable blocks or in landing pads
10774+ // (rarely executed).
10775+ if (EphValues.count(EU.User) ||
10776+ (EU.User &&
10777+ (!DT->isReachableFromEntry(cast<Instruction>(EU.User)->getParent()) ||
10778+ cast<Instruction>(EU.User)->getParent()->isLandingPad())))
10779+ continue;
10780+
1077110781 // We only add extract cost once for the same scalar.
1077210782 if (!isa_and_nonnull<InsertElementInst>(EU.User) &&
1077310783 !ExtractCostCalculated.insert(EU.Scalar).second)
1077410784 continue;
1077510785
10776- // Uses by ephemeral values are free (because the ephemeral value will be
10777- // removed prior to code generation, and so the extraction will be
10778- // removed as well).
10779- if (EphValues.count(EU.User))
10780- continue;
10781-
1078210786 // No extract cost for vector "scalar"
1078310787 if (isa<FixedVectorType>(EU.Scalar->getType()))
1078410788 continue;
Original file line number Diff line number Diff line change @@ -5,7 +5,6 @@ define void @test(i32 %arg) {
55; CHECK-LABEL: define void @test(
66; CHECK-SAME: i32 [[ARG:%.*]]) {
77; CHECK-NEXT: bb:
8- ; CHECK-NEXT: [[TMP2:%.*]] = zext i32 [[ARG]] to i64
98; CHECK-NEXT: [[TMP0:%.*]] = insertelement <2 x i32> <i32 poison, i32 0>, i32 [[ARG]], i32 0
109; CHECK-NEXT: br label [[BB2:%.*]]
1110; CHECK: bb2:
@@ -15,6 +14,8 @@ define void @test(i32 %arg) {
1514; CHECK-NEXT: i32 1, label [[BB4:%.*]]
1615; CHECK-NEXT: ]
1716; CHECK: bb3:
17+ ; CHECK-NEXT: [[TMP1:%.*]] = extractelement <2 x i32> [[TMP0]], i32 0
18+ ; CHECK-NEXT: [[TMP2:%.*]] = zext i32 [[TMP1]] to i64
1819; CHECK-NEXT: switch i32 0, label [[BB10]] [
1920; CHECK-NEXT: i32 18, label [[BB7:%.*]]
2021; CHECK-NEXT: i32 1, label [[BB7]]
You can’t perform that action at this time.
0 commit comments