llvm.org GIT mirror llvm / df9c9da
opt: Mirror vectorization presets of clang clang enables vectorization at optimization levels > 1 and size level < 2. opt should behave similarily. Loop vectorization and SLP vectorization can be disabled with the flags -disable-(loop/slp)-vectorization. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@196294 91177308-0d34-0410-b5e6-96231b3b80d8 Arnold Schwaighofer 5 years ago
3 changed file(s) with 72 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
0 ; RUN: opt -S -O3 -force-vector-width=2 -force-vector-unroll=1 < %s | FileCheck --check-prefix=LOOPVEC %s
1 ; RUN: opt -S -O3 -disable-loop-vectorization -force-vector-width=2 -force-vector-unroll=1 < %s | FileCheck --check-prefix=NOLOOPVEC %s
2
3 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"
4 target triple = "x86_64-apple-macosx10.8.0"
5
6 ; Make sure we can disable vectorization in opt.
7
8 ; LOOPVEC: add <2 x i32>
9 ; NOLOOPVEC-NOT: add <2 x i32>
10
11 define i32 @vect(i32* %a) {
12 entry:
13 br label %for.body
14
15 for.body:
16 %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
17 %red.05 = phi i32 [ 0, %entry ], [ %add, %for.body ]
18 %arrayidx = getelementptr inbounds i32* %a, i64 %indvars.iv
19 %0 = load i32* %arrayidx, align 4
20 %add = add nsw i32 %0, %red.05
21 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
22 %exitcond = icmp eq i64 %indvars.iv.next, 255
23 br i1 %exitcond, label %for.end, label %for.body
24
25 for.end:
26 ret i32 %add
27 }
0 ; RUN: opt < %s -O3 -S -mtriple=x86_64-apple-macosx10.8.0 -mcpu=corei7-avx | FileCheck %s --check-prefix=SLP
1 ; RUN: opt < %s -O3 -disable-slp-vectorization -S -mtriple=x86_64-apple-macosx10.8.0 -mcpu=corei7-avx | FileCheck %s --check-prefix=NOSLP
2
3 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"
4 target triple = "x86_64-apple-macosx10.8.0"
5
6 ; Make sure we can disable slp vectorization in opt.
7
8 ; SLP-LABEL: test1
9 ; SLP: store <2 x double>
10
11 ; NOSLP-LABEL: test1
12 ; NOSLP-NOT: store <2 x double>
13
14
15 define void @test1(double* %a, double* %b, double* %c) {
16 entry:
17 %i0 = load double* %a, align 8
18 %i1 = load double* %b, align 8
19 %mul = fmul double %i0, %i1
20 %arrayidx3 = getelementptr inbounds double* %a, i64 1
21 %i3 = load double* %arrayidx3, align 8
22 %arrayidx4 = getelementptr inbounds double* %b, i64 1
23 %i4 = load double* %arrayidx4, align 8
24 %mul5 = fmul double %i3, %i4
25 store double %mul, double* %c, align 8
26 %arrayidx5 = getelementptr inbounds double* %c, i64 1
27 store double %mul5, double* %arrayidx5, align 8
28 ret void
29 }
138138 DisableLoopUnrolling("disable-loop-unrolling",
139139 cl::desc("Disable loop unrolling in all relevant passes"),
140140 cl::init(false));
141 static cl::opt
142 DisableLoopVectorization("disable-loop-vectorization",
143 cl::desc("Disable the loop vectorization pass"),
144 cl::init(false));
145
146 static cl::opt
147 DisableSLPVectorization("disable-slp-vectorization",
148 cl::desc("Disable the slp vectorization pass"),
149 cl::init(false));
150
141151
142152 static cl::opt
143153 DisableSimplifyLibCalls("disable-simplify-libcalls",
460470 Builder.DisableUnrollLoops = (DisableLoopUnrolling.getNumOccurrences() > 0) ?
461471 DisableLoopUnrolling : OptLevel == 0;
462472
463 Builder.LoopVectorize = OptLevel > 1 && SizeLevel < 2;
464 Builder.SLPVectorize = true;
473 Builder.LoopVectorize =
474 DisableLoopVectorization ? false : OptLevel > 1 && SizeLevel < 2;
475 Builder.SLPVectorize =
476 DisableSLPVectorization ? false : OptLevel > 1 && SizeLevel < 2;
465477
466478 Builder.populateFunctionPassManager(FPM);
467479 Builder.populateModulePassManager(MPM);