OSDN Git Service

LoopVectorize: MaxVF should not be larger than the loop trip count
authorZvi Rackover <zvi.rackover@intel.com>
Mon, 4 Sep 2017 08:35:13 +0000 (08:35 +0000)
committerZvi Rackover <zvi.rackover@intel.com>
Mon, 4 Sep 2017 08:35:13 +0000 (08:35 +0000)
commit3438d07f09d5b86e5239fbe812a1d0a05f1b894b
tree9e487838ce16f1d1d7798b5cc3d149ca312d6f21
parent040fcc3883a5da8f0b81c138e55bbce4bef4dd79
LoopVectorize: MaxVF should not be larger than the loop trip count

Summary:
Improve how MaxVF is computed while taking into account that MaxVF should not be larger than the loop's trip count.

Other than saving on compile-time by pruning the possible MaxVF candidates, this patch fixes pr34438 which exposed the following flow:
1. Short trip count identified -> Don't bail out, set OptForSize:=True to avoid tail-loop and runtime checks.
2. Compute MaxVF returned 16 on a target supporting AVX512.
3. OptForSize -> choose VF:=MaxVF.
4. Bail out because TripCount = 8, VF = 16, TripCount % VF !=0 means we need a tail loop.

With this patch step 2. will choose MaxVF=8 based on TripCount.

Reviewers: Ayal, dorit, mkuper, hfinkel

Reviewed By: hfinkel

Subscribers: hfinkel, llvm-commits

Differential Revision: https://reviews.llvm.org/D37425

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@312472 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/Vectorize/LoopVectorize.cpp
test/Transforms/LoopVectorize/X86/pr34438.ll [new file with mode: 0644]