[llvm] r313176 - [LV] Avoid computing the register usage for default VF. NFC
Anna Thomas via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 13 12:35:46 PDT 2017
Author: annat
Date: Wed Sep 13 12:35:45 2017
New Revision: 313176
URL: http://llvm.org/viewvc/llvm-project?rev=313176&view=rev
Log:
[LV] Avoid computing the register usage for default VF. NFC
These are changes to reduce redundant computations when calculating a
feasible vectorization factor:
1. early return when target has no vector registers
2. don't compute register usage for the default VF.
Suggested during review for D37702.
Modified:
llvm/trunk/lib/Transforms/Vectorize/LoopVectorize.cpp
llvm/trunk/test/Transforms/LoopVectorize/X86/reg-usage.ll
Modified: llvm/trunk/lib/Transforms/Vectorize/LoopVectorize.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Vectorize/LoopVectorize.cpp?rev=313176&r1=313175&r2=313176&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Vectorize/LoopVectorize.cpp (original)
+++ llvm/trunk/lib/Transforms/Vectorize/LoopVectorize.cpp Wed Sep 13 12:35:45 2017
@@ -6241,6 +6241,7 @@ LoopVectorizationCostModel::computeFeasi
if (MaxVectorSize == 0) {
DEBUG(dbgs() << "LV: The target has no vector registers.\n");
MaxVectorSize = 1;
+ return MaxVectorSize;
} else if (ConstTripCount && ConstTripCount < MaxVectorSize &&
isPowerOf2_32(ConstTripCount)) {
// We need to clamp the VF to be the ConstTripCount. There is no point in
@@ -6253,10 +6254,11 @@ LoopVectorizationCostModel::computeFeasi
unsigned MaxVF = MaxVectorSize;
if (MaximizeBandwidth && !OptForSize) {
- // Collect all viable vectorization factors.
+ // Collect all viable vectorization factors larger than the default MaxVF
+ // (i.e. MaxVectorSize).
SmallVector<unsigned, 8> VFs;
unsigned NewMaxVectorSize = WidestRegister / SmallestType;
- for (unsigned VS = MaxVectorSize; VS <= NewMaxVectorSize; VS *= 2)
+ for (unsigned VS = MaxVectorSize * 2; VS <= NewMaxVectorSize; VS *= 2)
VFs.push_back(VS);
// For each VF calculate its register usage.
Modified: llvm/trunk/test/Transforms/LoopVectorize/X86/reg-usage.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/LoopVectorize/X86/reg-usage.ll?rev=313176&r1=313175&r2=313176&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/LoopVectorize/X86/reg-usage.ll (original)
+++ llvm/trunk/test/Transforms/LoopVectorize/X86/reg-usage.ll Wed Sep 13 12:35:45 2017
@@ -10,8 +10,6 @@ define i32 @foo() {
; register usage doesn't exceed 16.
;
; CHECK-LABEL: foo
-; CHECK: LV(REG): VF = 4
-; CHECK-NEXT: LV(REG): Found max usage: 4
; CHECK: LV(REG): VF = 8
; CHECK-NEXT: LV(REG): Found max usage: 7
; CHECK: LV(REG): VF = 16
@@ -48,8 +46,6 @@ define i32 @goo() {
; it will not have vector version and the vector register usage will not exceed the
; available vector register number.
; CHECK-LABEL: goo
-; CHECK: LV(REG): VF = 4
-; CHECK-NEXT: LV(REG): Found max usage: 4
; CHECK: LV(REG): VF = 8
; CHECK-NEXT: LV(REG): Found max usage: 7
; CHECK: LV(REG): VF = 16
More information about the llvm-commits
mailing list