[PATCH] D61091: Enable LoopVectorization by default.
Alina Sbirlea via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 24 14:01:43 PDT 2019
asbirlea created this revision.
asbirlea added reviewers: chandlerc, jgorbe.
Herald added a subscriber: jlebar.
Herald added a project: LLVM.
When refactoring vectorization flags, vectorization was disabled by default in the new pass manager.
This patch re-enables is for both managers, and changes the assumptions opt makes, based on the new defaults.
Comments in opt.cpp should clarify the intended use of all flags to enable/disable vectorization.
Repository:
rL LLVM
https://reviews.llvm.org/D61091
Files:
lib/Transforms/Vectorize/LoopVectorize.cpp
test/CodeGen/Hexagon/bug15515-shuffle.ll
test/Transforms/LoopVectorize/X86/metadata-enable.ll
test/Transforms/LoopVectorize/opt.ll
tools/opt/opt.cpp
Index: tools/opt/opt.cpp
===================================================================
--- tools/opt/opt.cpp
+++ tools/opt/opt.cpp
@@ -56,6 +56,7 @@
#include "llvm/Transforms/IPO/AlwaysInliner.h"
#include "llvm/Transforms/IPO/PassManagerBuilder.h"
#include "llvm/Transforms/Utils/Cloning.h"
+#include "llvm/Transforms/Vectorize/LoopVectorize.h"
#include <algorithm>
#include <memory>
using namespace llvm;
@@ -179,7 +180,7 @@
static cl::opt<bool>
DisableLoopVectorization("disable-loop-vectorization",
cl::desc("Disable the loop vectorization pass"),
- cl::init(false));
+ cl::init(true));
static cl::opt<bool>
DisableSLPVectorization("disable-slp-vectorization",
@@ -381,11 +382,21 @@
Builder.DisableUnrollLoops = (DisableLoopUnrolling.getNumOccurrences() > 0) ?
DisableLoopUnrolling : OptLevel == 0;
- // This is final, unless there is a #pragma vectorize enable
- if (DisableLoopVectorization)
+ // Check if option **explicitly** enabled or disabled via
+ // -disable-loop-vectorization=false or -vectorize-loops=false
+ // Both are true by default. The first (-disable-loop-vectorization) is only
+ // used to detect a specific user, because opt disables it unless:
+ // "OptLevel > 1 && SizeLevel < 2"
+ // The second (-vectorize-loops) enables vectorization in the LoopVectorize
+ // pass (on by default), and is used here to *disable* vectorization.
+ // The third flag that exists: -loop-vectorize, control adding the pass to the
+ // pass manager. If set, the pass is added, and there is no additional check
+ // here for it.
+ if (!EnableLoopVectorization)
Builder.LoopVectorize = false;
- // If option wasn't forced via cmd line (-vectorize-loops, -loop-vectorize)
- else if (!Builder.LoopVectorize)
+ else if (!DisableLoopVectorization)
+ Builder.LoopVectorize = true;
+ else
Builder.LoopVectorize = OptLevel > 1 && SizeLevel < 2;
// When #pragma vectorize is on for SLP, do the same as above
Index: test/Transforms/LoopVectorize/opt.ll
===================================================================
--- test/Transforms/LoopVectorize/opt.ll
+++ test/Transforms/LoopVectorize/opt.ll
@@ -1,5 +1,5 @@
; RUN: opt -S -O3 -force-vector-width=2 -force-vector-interleave=1 < %s | FileCheck --check-prefix=LOOPVEC %s
-; RUN: opt -S -O3 -disable-loop-vectorization -force-vector-width=2 -force-vector-interleave=1 < %s | FileCheck --check-prefix=NOLOOPVEC %s
+; RUN: opt -S -O3 -vectorize-loops=false -force-vector-width=2 -force-vector-interleave=1 < %s | FileCheck --check-prefix=NOLOOPVEC %s
target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
Index: test/Transforms/LoopVectorize/X86/metadata-enable.ll
===================================================================
--- test/Transforms/LoopVectorize/X86/metadata-enable.ll
+++ test/Transforms/LoopVectorize/X86/metadata-enable.ll
@@ -5,11 +5,11 @@
; RUN: opt < %s -mcpu=corei7 -O3 -S -unroll-allow-partial=0 | FileCheck %s --check-prefix=O3DEFAULT
; RUN: opt < %s -mcpu=corei7 -Os -S -unroll-allow-partial=0 | FileCheck %s --check-prefix=Os
; RUN: opt < %s -mcpu=corei7 -Oz -S -unroll-allow-partial=0 | FileCheck %s --check-prefix=Oz
-; RUN: opt < %s -mcpu=corei7 -O1 -vectorize-loops -S -unroll-allow-partial=0 | FileCheck %s --check-prefix=O1VEC
-; RUN: opt < %s -mcpu=corei7 -Oz -vectorize-loops -S -unroll-allow-partial=0 | FileCheck %s --check-prefix=OzVEC
+; RUN: opt < %s -mcpu=corei7 -O1 -disable-loop-vectorization=false -S -unroll-allow-partial=0 | FileCheck %s --check-prefix=O1VEC
+; RUN: opt < %s -mcpu=corei7 -Oz -disable-loop-vectorization=false -S -unroll-allow-partial=0 | FileCheck %s --check-prefix=OzVEC
; RUN: opt < %s -mcpu=corei7 -O1 -loop-vectorize -S -unroll-allow-partial=0 | FileCheck %s --check-prefix=O1VEC2
; RUN: opt < %s -mcpu=corei7 -Oz -loop-vectorize -S -unroll-allow-partial=0 | FileCheck %s --check-prefix=OzVEC2
-; RUN: opt < %s -mcpu=corei7 -O3 -unroll-threshold=150 -disable-loop-vectorization -S -unroll-allow-partial=0 | FileCheck %s --check-prefix=O3DIS
+; RUN: opt < %s -mcpu=corei7 -O3 -unroll-threshold=150 -vectorize-loops=false -S -unroll-allow-partial=0 | FileCheck %s --check-prefix=O3DIS
; This file tests the llvm.loop.vectorize.enable metadata forcing
; vectorization even when optimization levels are too low, or when
Index: test/CodeGen/Hexagon/bug15515-shuffle.ll
===================================================================
--- test/CodeGen/Hexagon/bug15515-shuffle.ll
+++ test/CodeGen/Hexagon/bug15515-shuffle.ll
@@ -1,4 +1,4 @@
-; RUN: opt -march=hexagon -O2 -vectorize-loops -S < %s
+; RUN: opt -march=hexagon -O2 -S < %s
; REQUIRES: asserts
;
; -fvectorize-loops infinite compile/memory
Index: lib/Transforms/Vectorize/LoopVectorize.cpp
===================================================================
--- lib/Transforms/Vectorize/LoopVectorize.cpp
+++ lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -281,7 +281,7 @@
"interleave-loops", cl::init(true), cl::Hidden,
cl::desc("Enable loop interleaving in Loop vectorization passes"));
cl::opt<bool> llvm::EnableLoopVectorization(
- "vectorize-loops", cl::init(false), cl::Hidden,
+ "vectorize-loops", cl::init(true), cl::Hidden,
cl::desc("Run the Loop vectorization passes"));
/// A helper function for converting Scalar types to vector types.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D61091.196517.patch
Type: text/x-patch
Size: 5539 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190424/f6593d74/attachment.bin>
More information about the llvm-commits
mailing list