Skip to content

Commit 504f3e8

Browse files
committed
!fixup address comments
1 parent 825f1c7 commit 504f3e8

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

llvm/lib/Transforms/Vectorize/VectorCombine.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1856,20 +1856,19 @@ bool VectorCombine::scalarizeLoad(Instruction &I) {
18561856

18571857
auto *LI = cast<LoadInst>(&I);
18581858
auto *VecTy = cast<VectorType>(LI->getType());
1859-
if (!VecTy || LI->isVolatile() ||
1860-
!DL->typeSizeEqualsStoreSize(VecTy->getScalarType()))
1859+
if (LI->isVolatile() || !DL->typeSizeEqualsStoreSize(VecTy->getScalarType()))
18611860
return false;
18621861

1863-
// Check what type of users we have and ensure no memory modifications betwwen
1864-
// the load and its users.
18651862
bool AllExtracts = true;
18661863
bool AllBitcasts = true;
18671864
Instruction *LastCheckedInst = LI;
18681865
unsigned NumInstChecked = 0;
18691866

1867+
// Check what type of users we have and ensure no memory modifications betwwen
1868+
// the load and its users.
18701869
for (User *U : LI->users()) {
18711870
auto *UI = dyn_cast<Instruction>(U);
1872-
if (!UI || UI->getParent() != LI->getParent() || UI->use_empty())
1871+
if (!UI || UI->getParent() != LI->getParent())
18731872
return false;
18741873

18751874
// If any user is waiting to be erased, then bail out as this will
@@ -1909,18 +1908,18 @@ bool VectorCombine::scalarizeLoadExtract(LoadInst *LI, VectorType *VecTy,
19091908
if (!TTI.allowVectorElementIndexingUsingGEP())
19101909
return false;
19111910

1912-
InstructionCost OriginalCost =
1913-
TTI.getMemoryOpCost(Instruction::Load, VecTy, LI->getAlign(),
1914-
LI->getPointerAddressSpace(), CostKind);
1915-
InstructionCost ScalarizedCost = 0;
1916-
19171911
DenseMap<ExtractElementInst *, ScalarizationResult> NeedFreeze;
19181912
auto FailureGuard = make_scope_exit([&]() {
19191913
// If the transform is aborted, discard the ScalarizationResults.
19201914
for (auto &Pair : NeedFreeze)
19211915
Pair.second.discard();
19221916
});
19231917

1918+
InstructionCost OriginalCost =
1919+
TTI.getMemoryOpCost(Instruction::Load, VecTy, LI->getAlign(),
1920+
LI->getPointerAddressSpace(), CostKind);
1921+
InstructionCost ScalarizedCost = 0;
1922+
19241923
for (User *U : LI->users()) {
19251924
auto *UI = cast<ExtractElementInst>(U);
19261925

@@ -2011,7 +2010,7 @@ bool VectorCombine::scalarizeLoadBitcast(LoadInst *LI, VectorType *VecTy,
20112010
if (DestBitWidth != VecBitWidth)
20122011
return false;
20132012

2014-
// All bitcasts should target the same scalar type.
2013+
// All bitcasts must target the same scalar type.
20152014
if (!TargetScalarType)
20162015
TargetScalarType = DestTy;
20172016
else if (TargetScalarType != DestTy)
@@ -2024,6 +2023,7 @@ bool VectorCombine::scalarizeLoadBitcast(LoadInst *LI, VectorType *VecTy,
20242023

20252024
if (!TargetScalarType)
20262025
return false;
2026+
20272027
assert(!LI->user_empty() && "Unexpected load without bitcast users");
20282028
InstructionCost ScalarizedCost =
20292029
TTI.getMemoryOpCost(Instruction::Load, TargetScalarType, LI->getAlign(),

llvm/test/Transforms/VectorCombine/AArch64/load-ext-extract.ll renamed to llvm/test/Transforms/PhaseOrdering/AArch64/scalarize-load-ext-extract.ll

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 6
2-
; RUN: opt -passes=vector-combine,dce,vector-combine -mtriple=arm64-apple-darwinos -S %s | FileCheck %s
2+
; RUN: opt -O3 -mtriple=arm64-apple-darwinos -S %s | FileCheck %s
33

44
define noundef i32 @load_ext_extract(ptr %src) {
5-
; CHECK-LABEL: define noundef i32 @load_ext_extract(
6-
; CHECK-SAME: ptr [[SRC:%.*]]) {
5+
; CHECK-LABEL: define noundef range(i32 0, 1021) i32 @load_ext_extract(
6+
; CHECK-SAME: ptr readonly captures(none) [[SRC:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] {
77
; CHECK-NEXT: [[ENTRY:.*:]]
88
; CHECK-NEXT: [[TMP14:%.*]] = load i32, ptr [[SRC]], align 4
99
; CHECK-NEXT: [[TMP15:%.*]] = lshr i32 [[TMP14]], 24
@@ -12,9 +12,9 @@ define noundef i32 @load_ext_extract(ptr %src) {
1212
; CHECK-NEXT: [[TMP18:%.*]] = lshr i32 [[TMP14]], 8
1313
; CHECK-NEXT: [[TMP19:%.*]] = and i32 [[TMP18]], 255
1414
; CHECK-NEXT: [[TMP20:%.*]] = and i32 [[TMP14]], 255
15-
; CHECK-NEXT: [[ADD1:%.*]] = add i32 [[TMP20]], [[TMP19]]
16-
; CHECK-NEXT: [[ADD2:%.*]] = add i32 [[ADD1]], [[TMP17]]
17-
; CHECK-NEXT: [[ADD3:%.*]] = add i32 [[ADD2]], [[TMP15]]
15+
; CHECK-NEXT: [[ADD1:%.*]] = add nuw nsw i32 [[TMP20]], [[TMP19]]
16+
; CHECK-NEXT: [[ADD2:%.*]] = add nuw nsw i32 [[ADD1]], [[TMP17]]
17+
; CHECK-NEXT: [[ADD3:%.*]] = add nuw nsw i32 [[ADD2]], [[TMP15]]
1818
; CHECK-NEXT: ret i32 [[ADD3]]
1919
;
2020
entry:

0 commit comments

Comments
 (0)