diff options
Diffstat (limited to 'test/Transforms/SLPVectorizer/X86')
-rw-r--r-- | test/Transforms/SLPVectorizer/X86/addsub.ll | 133 | ||||
-rw-r--r-- | test/Transforms/SLPVectorizer/X86/atomics.ll | 31 | ||||
-rw-r--r-- | test/Transforms/SLPVectorizer/X86/bad_types.ll | 50 | ||||
-rw-r--r-- | test/Transforms/SLPVectorizer/X86/consecutive-access.ll | 2 | ||||
-rw-r--r-- | test/Transforms/SLPVectorizer/X86/crash_cmpop.ll | 56 | ||||
-rw-r--r-- | test/Transforms/SLPVectorizer/X86/crash_scheduling.ll | 4 | ||||
-rw-r--r-- | test/Transforms/SLPVectorizer/X86/debug_info.ll | 74 | ||||
-rw-r--r-- | test/Transforms/SLPVectorizer/X86/metadata.ll | 16 | ||||
-rw-r--r-- | test/Transforms/SLPVectorizer/X86/operandorder.ll | 110 | ||||
-rw-r--r-- | test/Transforms/SLPVectorizer/X86/pr16899.ll | 12 |
10 files changed, 434 insertions, 54 deletions
diff --git a/test/Transforms/SLPVectorizer/X86/addsub.ll b/test/Transforms/SLPVectorizer/X86/addsub.ll index 174d400..d082b07 100644 --- a/test/Transforms/SLPVectorizer/X86/addsub.ll +++ b/test/Transforms/SLPVectorizer/X86/addsub.ll @@ -10,6 +10,7 @@ target triple = "x86_64-unknown-linux-gnu" @fb = common global [4 x float] zeroinitializer, align 16 @fc = common global [4 x float] zeroinitializer, align 16 @fa = common global [4 x float] zeroinitializer, align 16 +@fd = common global [4 x float] zeroinitializer, align 16 ; CHECK-LABEL: @addsub ; CHECK: %5 = add nsw <4 x i32> %3, %4 @@ -177,5 +178,137 @@ entry: ret void } +; Check vectorization of following code for float data type- +; fc[0] = fb[0]+fa[0]; //swapped fb and fa +; fc[1] = fa[1]-fb[1]; +; fc[2] = fa[2]+fb[2]; +; fc[3] = fa[3]-fb[3]; + +; CHECK-LABEL: @reorder_alt +; CHECK: %3 = fadd <4 x float> %1, %2 +; CHECK: %4 = fsub <4 x float> %1, %2 +; CHECK: %5 = shufflevector <4 x float> %3, <4 x float> %4, <4 x i32> <i32 0, i32 5, i32 2, i32 7> +define void @reorder_alt() #0 { + %1 = load float* getelementptr inbounds ([4 x float]* @fb, i32 0, i64 0), align 4 + %2 = load float* getelementptr inbounds ([4 x float]* @fa, i32 0, i64 0), align 4 + %3 = fadd float %1, %2 + store float %3, float* getelementptr inbounds ([4 x float]* @fc, i32 0, i64 0), align 4 + %4 = load float* getelementptr inbounds ([4 x float]* @fa, i32 0, i64 1), align 4 + %5 = load float* getelementptr inbounds ([4 x float]* @fb, i32 0, i64 1), align 4 + %6 = fsub float %4, %5 + store float %6, float* getelementptr inbounds ([4 x float]* @fc, i32 0, i64 1), align 4 + %7 = load float* getelementptr inbounds ([4 x float]* @fa, i32 0, i64 2), align 4 + %8 = load float* getelementptr inbounds ([4 x float]* @fb, i32 0, i64 2), align 4 + %9 = fadd float %7, %8 + store float %9, float* getelementptr inbounds ([4 x float]* @fc, i32 0, i64 2), align 4 + %10 = load float* getelementptr inbounds ([4 x float]* @fa, i32 0, i64 3), align 4 + %11 = load float* getelementptr inbounds ([4 x float]* @fb, i32 0, i64 3), align 4 + %12 = fsub float %10, %11 + store float %12, float* getelementptr inbounds ([4 x float]* @fc, i32 0, i64 3), align 4 + ret void +} + +; Check vectorization of following code for float data type- +; fc[0] = fa[0]+(fb[0]-fd[0]); +; fc[1] = fa[1]-(fb[1]+fd[1]); +; fc[2] = fa[2]+(fb[2]-fd[2]); +; fc[3] = fa[3]-(fd[3]+fb[3]); //swapped fd and fb + +; CHECK-LABEL: @reorder_alt_subTree +; CHECK: %4 = fsub <4 x float> %3, %2 +; CHECK: %5 = fadd <4 x float> %3, %2 +; CHECK: %6 = shufflevector <4 x float> %4, <4 x float> %5, <4 x i32> <i32 0, i32 5, i32 2, i32 7> +; CHECK: %7 = fadd <4 x float> %1, %6 +; CHECK: %8 = fsub <4 x float> %1, %6 +; CHECK: %9 = shufflevector <4 x float> %7, <4 x float> %8, <4 x i32> <i32 0, i32 5, i32 2, i32 7> +define void @reorder_alt_subTree() #0 { + %1 = load float* getelementptr inbounds ([4 x float]* @fa, i32 0, i64 0), align 4 + %2 = load float* getelementptr inbounds ([4 x float]* @fb, i32 0, i64 0), align 4 + %3 = load float* getelementptr inbounds ([4 x float]* @fd, i32 0, i64 0), align 4 + %4 = fsub float %2, %3 + %5 = fadd float %1, %4 + store float %5, float* getelementptr inbounds ([4 x float]* @fc, i32 0, i64 0), align 4 + %6 = load float* getelementptr inbounds ([4 x float]* @fa, i32 0, i64 1), align 4 + %7 = load float* getelementptr inbounds ([4 x float]* @fb, i32 0, i64 1), align 4 + %8 = load float* getelementptr inbounds ([4 x float]* @fd, i32 0, i64 1), align 4 + %9 = fadd float %7, %8 + %10 = fsub float %6, %9 + store float %10, float* getelementptr inbounds ([4 x float]* @fc, i32 0, i64 1), align 4 + %11 = load float* getelementptr inbounds ([4 x float]* @fa, i32 0, i64 2), align 4 + %12 = load float* getelementptr inbounds ([4 x float]* @fb, i32 0, i64 2), align 4 + %13 = load float* getelementptr inbounds ([4 x float]* @fd, i32 0, i64 2), align 4 + %14 = fsub float %12, %13 + %15 = fadd float %11, %14 + store float %15, float* getelementptr inbounds ([4 x float]* @fc, i32 0, i64 2), align 4 + %16 = load float* getelementptr inbounds ([4 x float]* @fa, i32 0, i64 3), align 4 + %17 = load float* getelementptr inbounds ([4 x float]* @fd, i32 0, i64 3), align 4 + %18 = load float* getelementptr inbounds ([4 x float]* @fb, i32 0, i64 3), align 4 + %19 = fadd float %17, %18 + %20 = fsub float %16, %19 + store float %20, float* getelementptr inbounds ([4 x float]* @fc, i32 0, i64 3), align 4 + ret void +} + +; Check vectorization of following code for double data type- +; c[0] = (a[0]+b[0])-d[0]; +; c[1] = d[1]+(a[1]+b[1]); //swapped d[1] and (a[1]+b[1]) + +; CHECK-LABEL: @reorder_alt_rightsubTree +; CHECK: fadd <2 x double> +; CHECK: fsub <2 x double> +; CHECK: shufflevector <2 x double> +define void @reorder_alt_rightsubTree(double* nocapture %c, double* noalias nocapture readonly %a, double* noalias nocapture readonly %b, double* noalias nocapture readonly %d) { + %1 = load double* %a + %2 = load double* %b + %3 = fadd double %1, %2 + %4 = load double* %d + %5 = fsub double %3, %4 + store double %5, double* %c + %6 = getelementptr inbounds double* %d, i64 1 + %7 = load double* %6 + %8 = getelementptr inbounds double* %a, i64 1 + %9 = load double* %8 + %10 = getelementptr inbounds double* %b, i64 1 + %11 = load double* %10 + %12 = fadd double %9, %11 + %13 = fadd double %7, %12 + %14 = getelementptr inbounds double* %c, i64 1 + store double %13, double* %14 + ret void +} + +; Dont vectorization of following code for float data type as sub is not commutative- +; fc[0] = fb[0]+fa[0]; +; fc[1] = fa[1]-fb[1]; +; fc[2] = fa[2]+fb[2]; +; fc[3] = fb[3]-fa[3]; +; In the above code we can swap the 1st and 2nd operation as fadd is commutative +; but not 2nd or 4th as fsub is not commutative. + +; CHECK-LABEL: @no_vec_shuff_reorder +; CHECK-NOT: fadd <4 x float> +; CHECK-NOT: fsub <4 x float> +; CHECK-NOT: shufflevector +define void @no_vec_shuff_reorder() #0 { + %1 = load float* getelementptr inbounds ([4 x float]* @fb, i32 0, i64 0), align 4 + %2 = load float* getelementptr inbounds ([4 x float]* @fa, i32 0, i64 0), align 4 + %3 = fadd float %1, %2 + store float %3, float* getelementptr inbounds ([4 x float]* @fc, i32 0, i64 0), align 4 + %4 = load float* getelementptr inbounds ([4 x float]* @fa, i32 0, i64 1), align 4 + %5 = load float* getelementptr inbounds ([4 x float]* @fb, i32 0, i64 1), align 4 + %6 = fsub float %4, %5 + store float %6, float* getelementptr inbounds ([4 x float]* @fc, i32 0, i64 1), align 4 + %7 = load float* getelementptr inbounds ([4 x float]* @fa, i32 0, i64 2), align 4 + %8 = load float* getelementptr inbounds ([4 x float]* @fb, i32 0, i64 2), align 4 + %9 = fadd float %7, %8 + store float %9, float* getelementptr inbounds ([4 x float]* @fc, i32 0, i64 2), align 4 + %10 = load float* getelementptr inbounds ([4 x float]* @fb, i32 0, i64 3), align 4 + %11 = load float* getelementptr inbounds ([4 x float]* @fa, i32 0, i64 3), align 4 + %12 = fsub float %10, %11 + store float %12, float* getelementptr inbounds ([4 x float]* @fc, i32 0, i64 3), align 4 + ret void +} + + attributes #0 = { nounwind } diff --git a/test/Transforms/SLPVectorizer/X86/atomics.ll b/test/Transforms/SLPVectorizer/X86/atomics.ll new file mode 100644 index 0000000..6cb322e --- /dev/null +++ b/test/Transforms/SLPVectorizer/X86/atomics.ll @@ -0,0 +1,31 @@ +; RUN: opt < %s -basicaa -slp-vectorizer -S |FileCheck %s +target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128" + +@x = global [4 x i32] zeroinitializer, align 16 +@a = global [4 x i32] zeroinitializer, align 16 + +; The SLPVectorizer should not vectorize atomic stores and it should not +; schedule regular stores around atomic stores. + +; CHECK-LABEL: test +; CHECK: store i32 +; CHECK: store atomic i32 +; CHECK: store i32 +; CHECK: store atomic i32 +; CHECK: store i32 +; CHECK: store atomic i32 +; CHECK: store i32 +; CHECK: store atomic i32 +define void @test() { +entry: + store i32 0, i32* getelementptr inbounds ([4 x i32]* @a, i64 0, i64 0), align 16 + store atomic i32 0, i32* getelementptr inbounds ([4 x i32]* @x, i64 0, i64 0) release, align 16 + store i32 0, i32* getelementptr inbounds ([4 x i32]* @a, i64 0, i64 1), align 4 + store atomic i32 1, i32* getelementptr inbounds ([4 x i32]* @x, i64 0, i64 1) release, align 4 + store i32 0, i32* getelementptr inbounds ([4 x i32]* @a, i64 0, i64 2), align 8 + store atomic i32 2, i32* getelementptr inbounds ([4 x i32]* @x, i64 0, i64 2) release, align 8 + store i32 0, i32* getelementptr inbounds ([4 x i32]* @a, i64 0, i64 3), align 4 + store atomic i32 3, i32* getelementptr inbounds ([4 x i32]* @x, i64 0, i64 3) release, align 4 + ret void +} + diff --git a/test/Transforms/SLPVectorizer/X86/bad_types.ll b/test/Transforms/SLPVectorizer/X86/bad_types.ll new file mode 100644 index 0000000..38ed18d --- /dev/null +++ b/test/Transforms/SLPVectorizer/X86/bad_types.ll @@ -0,0 +1,50 @@ +; RUN: opt < %s -basicaa -slp-vectorizer -S -mcpu=corei7-avx | FileCheck %s + +target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-linux-gnu" + +define void @test1(x86_mmx %a, x86_mmx %b, i64* %ptr) { +; Ensure we can handle x86_mmx values which are primitive and can be bitcast +; with integer types but can't be put into a vector. +; +; CHECK-LABEL: @test1 +; CHECK: store i64 +; CHECK: store i64 +; CHECK: ret void +entry: + %a.cast = bitcast x86_mmx %a to i64 + %b.cast = bitcast x86_mmx %b to i64 + %a.and = and i64 %a.cast, 42 + %b.and = and i64 %b.cast, 42 + %gep = getelementptr i64* %ptr, i32 1 + store i64 %a.and, i64* %ptr + store i64 %b.and, i64* %gep + ret void +} + +define void @test2(x86_mmx %a, x86_mmx %b) { +; Same as @test1 but using phi-input vectorization instead of store +; vectorization. +; +; CHECK-LABEL: @test2 +; CHECK: and i64 +; CHECK: and i64 +; CHECK: ret void +entry: + br i1 undef, label %if.then, label %exit + +if.then: + %a.cast = bitcast x86_mmx %a to i64 + %b.cast = bitcast x86_mmx %b to i64 + %a.and = and i64 %a.cast, 42 + %b.and = and i64 %b.cast, 42 + br label %exit + +exit: + %a.phi = phi i64 [ 0, %entry ], [ %a.and, %if.then ] + %b.phi = phi i64 [ 0, %entry ], [ %b.and, %if.then ] + tail call void @f(i64 %a.phi, i64 %b.phi) + ret void +} + +declare void @f(i64, i64) diff --git a/test/Transforms/SLPVectorizer/X86/consecutive-access.ll b/test/Transforms/SLPVectorizer/X86/consecutive-access.ll index f4f112f..aa59429 100644 --- a/test/Transforms/SLPVectorizer/X86/consecutive-access.ll +++ b/test/Transforms/SLPVectorizer/X86/consecutive-access.ll @@ -172,4 +172,4 @@ attributes #0 = { nounwind ssp uwtable "less-precise-fpmad"="false" "no-frame-po !llvm.ident = !{!0} -!0 = metadata !{metadata !"clang version 3.5.0 "} +!0 = !{!"clang version 3.5.0 "} diff --git a/test/Transforms/SLPVectorizer/X86/crash_cmpop.ll b/test/Transforms/SLPVectorizer/X86/crash_cmpop.ll new file mode 100644 index 0000000..18a96e5 --- /dev/null +++ b/test/Transforms/SLPVectorizer/X86/crash_cmpop.ll @@ -0,0 +1,56 @@ +; RUN: opt < %s -basicaa -slp-vectorizer -S + +target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-apple-macosx10.10.0" + +define void @testfunc(float* nocapture %dest, float* nocapture readonly %src) { +entry: + br label %for.body + +for.body: + %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ] + %acc1.056 = phi float [ 0.000000e+00, %entry ], [ %add13, %for.body ] + %s1.055 = phi float [ 0.000000e+00, %entry ], [ %cond.i40, %for.body ] + %s0.054 = phi float [ 0.000000e+00, %entry ], [ %cond.i44, %for.body ] + %arrayidx = getelementptr inbounds float* %src, i64 %indvars.iv + %0 = load float* %arrayidx, align 4 + %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1 + %arrayidx2 = getelementptr inbounds float* %dest, i64 %indvars.iv + store float %acc1.056, float* %arrayidx2, align 4 + %add = fadd float %s0.054, %0 + %add3 = fadd float %s1.055, %0 + %mul = fmul float %s0.054, 0.000000e+00 + %add4 = fadd float %mul, %add3 + %mul5 = fmul float %s1.055, 0.000000e+00 + %add6 = fadd float %mul5, %add + %cmp.i = fcmp olt float %add6, 1.000000e+00 + %cond.i = select i1 %cmp.i, float %add6, float 1.000000e+00 + %cmp.i51 = fcmp olt float %cond.i, -1.000000e+00 + %cmp.i49 = fcmp olt float %add4, 1.000000e+00 + %cond.i50 = select i1 %cmp.i49, float %add4, float 1.000000e+00 + %cmp.i47 = fcmp olt float %cond.i50, -1.000000e+00 + %cond.i.op = fmul float %cond.i, 0.000000e+00 + %mul10 = select i1 %cmp.i51, float -0.000000e+00, float %cond.i.op + %cond.i50.op = fmul float %cond.i50, 0.000000e+00 + %mul11 = select i1 %cmp.i47, float -0.000000e+00, float %cond.i50.op + %add13 = fadd float %mul10, %mul11 + + ; The SLPVectorizer crashed in vectorizeChainsInBlock() because it tried + ; to access the second operand of the following cmp after the cmp itself + ; was already vectorized and deleted. + %cmp.i45 = fcmp olt float %add13, 1.000000e+00 + + %cond.i46 = select i1 %cmp.i45, float %add13, float 1.000000e+00 + %cmp.i43 = fcmp olt float %cond.i46, -1.000000e+00 + %cond.i44 = select i1 %cmp.i43, float -1.000000e+00, float %cond.i46 + %cmp.i41 = fcmp olt float %mul11, 1.000000e+00 + %cond.i42 = select i1 %cmp.i41, float %mul11, float 1.000000e+00 + %cmp.i39 = fcmp olt float %cond.i42, -1.000000e+00 + %cond.i40 = select i1 %cmp.i39, float -1.000000e+00, float %cond.i42 + %exitcond = icmp eq i64 %indvars.iv.next, 32 + br i1 %exitcond, label %for.end, label %for.body + +for.end: + ret void +} + diff --git a/test/Transforms/SLPVectorizer/X86/crash_scheduling.ll b/test/Transforms/SLPVectorizer/X86/crash_scheduling.ll index dddc1be..e6cc0f7 100644 --- a/test/Transforms/SLPVectorizer/X86/crash_scheduling.ll +++ b/test/Transforms/SLPVectorizer/X86/crash_scheduling.ll @@ -43,5 +43,5 @@ return: declare i32 @_xfn(<2 x double>) #4 -!3 = metadata !{metadata !"int", metadata !4, i64 0} -!4 = metadata !{metadata !3, metadata !3, i64 0} +!3 = !{!"int", !4, i64 0} +!4 = !{!3, !3, i64 0} diff --git a/test/Transforms/SLPVectorizer/X86/debug_info.ll b/test/Transforms/SLPVectorizer/X86/debug_info.ll index 1046087..21f51d7 100644 --- a/test/Transforms/SLPVectorizer/X86/debug_info.ll +++ b/test/Transforms/SLPVectorizer/X86/debug_info.ll @@ -18,16 +18,16 @@ target triple = "x86_64-apple-macosx10.7.0" ;CHECK: load <2 x double>* {{.*}}, !dbg ![[LOC]] ;CHECK: store <2 x double> {{.*}}, !dbg ![[LOC2:[0-9]+]] ;CHECK: ret -;CHECK: ![[LOC]] = metadata !{i32 4, i32 0, -;CHECK: ![[LOC2]] = metadata !{i32 7, i32 0, +;CHECK: ![[LOC]] = !MDLocation(line: 4, scope: +;CHECK: ![[LOC2]] = !MDLocation(line: 7, scope: define i32 @depth(double* nocapture %A, i32 %m) #0 { entry: - tail call void @llvm.dbg.value(metadata !{double* %A}, i64 0, metadata !12, metadata !{}), !dbg !19 - tail call void @llvm.dbg.value(metadata !{i32 %m}, i64 0, metadata !13, metadata !{}), !dbg !19 - tail call void @llvm.dbg.value(metadata !20, i64 0, metadata !14, metadata !{}), !dbg !21 - tail call void @llvm.dbg.value(metadata !22, i64 0, metadata !15, metadata !{}), !dbg !21 - tail call void @llvm.dbg.value(metadata !2, i64 0, metadata !16, metadata !{}), !dbg !23 + tail call void @llvm.dbg.value(metadata double* %A, i64 0, metadata !12, metadata !{}), !dbg !19 + tail call void @llvm.dbg.value(metadata i32 %m, i64 0, metadata !13, metadata !{}), !dbg !19 + tail call void @llvm.dbg.value(metadata i32 00, i64 0, metadata !14, metadata !{}), !dbg !21 + tail call void @llvm.dbg.value(metadata i32 02, i64 0, metadata !15, metadata !{}), !dbg !21 + tail call void @llvm.dbg.value(metadata i32 0, i64 0, metadata !16, metadata !{}), !dbg !23 %cmp8 = icmp sgt i32 %m, 0, !dbg !23 br i1 %cmp8, label %for.body.lr.ph, label %for.end, !dbg !23 @@ -57,33 +57,33 @@ attributes #1 = { nounwind readnone } !llvm.dbg.cu = !{!0} !llvm.module.flags = !{!18, !32} -!0 = metadata !{metadata !"0x11\0012\00clang version 3.4 (trunk 187335) (llvm/trunk 187335:187340M)\001\00\000\00\000", metadata !1, metadata !2, metadata !2, metadata !3, metadata !2, metadata !2} ; [ DW_TAG_compile_unit ] [/Users/nadav/file.c] [DW_LANG_C99] -!1 = metadata !{metadata !"file.c", metadata !"/Users/nadav"} -!2 = metadata !{i32 0} -!3 = metadata !{metadata !4} -!4 = metadata !{metadata !"0x2e\00depth\00depth\00\001\000\001\000\006\00256\001\001", metadata !1, metadata !5, metadata !6, null, i32 (double*, i32)* @depth, null, null, metadata !11} ; [ DW_TAG_subprogram ] [line 1] [def] [depth] -!5 = metadata !{metadata !"0x29", metadata !1} ; [ DW_TAG_file_type ] [/Users/nadav/file.c] -!6 = metadata !{metadata !"0x15\00\000\000\000\000\000\000", i32 0, null, null, metadata !7, null, null, null} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ] -!7 = metadata !{metadata !8, metadata !9, metadata !8} -!8 = metadata !{metadata !"0x24\00int\000\0032\0032\000\000\005", null, null} ; [ DW_TAG_base_type ] [int] [line 0, size 32, align 32, offset 0, enc DW_ATE_signed] -!9 = metadata !{metadata !"0xf\00\000\0064\0064\000\000", null, null, metadata !10} ; [ DW_TAG_pointer_type ] [line 0, size 64, align 64, offset 0] [from double] -!10 = metadata !{metadata !"0x24\00double\000\0064\0064\000\000\004", null, null} ; [ DW_TAG_base_type ] [double] [line 0, size 64, align 64, offset 0, enc DW_ATE_float] -!11 = metadata !{metadata !12, metadata !13, metadata !14, metadata !15, metadata !16} -!12 = metadata !{metadata !"0x101\00A\0016777217\000", metadata !4, metadata !5, metadata !9} ; [ DW_TAG_arg_variable ] [A] [line 1] -!13 = metadata !{metadata !"0x101\00m\0033554433\000", metadata !4, metadata !5, metadata !8} ; [ DW_TAG_arg_variable ] [m] [line 1] -!14 = metadata !{metadata !"0x100\00y0\002\000", metadata !4, metadata !5, metadata !10} ; [ DW_TAG_auto_variable ] [y0] [line 2] -!15 = metadata !{metadata !"0x100\00y1\002\000", metadata !4, metadata !5, metadata !10} ; [ DW_TAG_auto_variable ] [y1] [line 2] -!16 = metadata !{metadata !"0x100\00i\003\000", metadata !17, metadata !5, metadata !8} ; [ DW_TAG_auto_variable ] [i] [line 3] -!17 = metadata !{metadata !"0xb\003\000\000", metadata !1, metadata !4} ; [ DW_TAG_lexical_block ] [/Users/nadav/file.c] -!18 = metadata !{i32 2, metadata !"Dwarf Version", i32 2} -!19 = metadata !{i32 1, i32 0, metadata !4, null} -!20 = metadata !{double 0.000000e+00} -!21 = metadata !{i32 2, i32 0, metadata !4, null} -!22 = metadata !{double 1.000000e+00} -!23 = metadata !{i32 3, i32 0, metadata !17, null} -!24 = metadata !{i32 4, i32 0, metadata !25, null} -!25 = metadata !{metadata !"0xb\003\000\001", metadata !1, metadata !17} ; [ DW_TAG_lexical_block ] [/Users/nadav/file.c] -!29 = metadata !{i32 5, i32 0, metadata !25, null} -!30 = metadata !{i32 7, i32 0, metadata !4, null} -!31 = metadata !{i32 8, i32 0, metadata !4, null} -!32 = metadata !{i32 1, metadata !"Debug Info Version", i32 2} +!0 = !{!"0x11\0012\00clang version 3.4 (trunk 187335) (llvm/trunk 187335:187340M)\001\00\000\00\000", !1, !2, !2, !3, !2, !2} ; [ DW_TAG_compile_unit ] [/Users/nadav/file.c] [DW_LANG_C99] +!1 = !{!"file.c", !"/Users/nadav"} +!2 = !{i32 0} +!3 = !{!4} +!4 = !{!"0x2e\00depth\00depth\00\001\000\001\000\006\00256\001\001", !1, !5, !6, null, i32 (double*, i32)* @depth, null, null, !11} ; [ DW_TAG_subprogram ] [line 1] [def] [depth] +!5 = !{!"0x29", !1} ; [ DW_TAG_file_type ] [/Users/nadav/file.c] +!6 = !{!"0x15\00\000\000\000\000\000\000", i32 0, null, null, !7, null, null, null} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ] +!7 = !{!8, !9, !8} +!8 = !{!"0x24\00int\000\0032\0032\000\000\005", null, null} ; [ DW_TAG_base_type ] [int] [line 0, size 32, align 32, offset 0, enc DW_ATE_signed] +!9 = !{!"0xf\00\000\0064\0064\000\000", null, null, !10} ; [ DW_TAG_pointer_type ] [line 0, size 64, align 64, offset 0] [from double] +!10 = !{!"0x24\00double\000\0064\0064\000\000\004", null, null} ; [ DW_TAG_base_type ] [double] [line 0, size 64, align 64, offset 0, enc DW_ATE_float] +!11 = !{!12, !13, !14, !15, !16} +!12 = !{!"0x101\00A\0016777217\000", !4, !5, !9} ; [ DW_TAG_arg_variable ] [A] [line 1] +!13 = !{!"0x101\00m\0033554433\000", !4, !5, !8} ; [ DW_TAG_arg_variable ] [m] [line 1] +!14 = !{!"0x100\00y0\002\000", !4, !5, !10} ; [ DW_TAG_auto_variable ] [y0] [line 2] +!15 = !{!"0x100\00y1\002\000", !4, !5, !10} ; [ DW_TAG_auto_variable ] [y1] [line 2] +!16 = !{!"0x100\00i\003\000", !17, !5, !8} ; [ DW_TAG_auto_variable ] [i] [line 3] +!17 = !{!"0xb\003\000\000", !1, !4} ; [ DW_TAG_lexical_block ] [/Users/nadav/file.c] +!18 = !{i32 2, !"Dwarf Version", i32 2} +!19 = !MDLocation(line: 1, scope: !4) +!20 = !{double 0.000000e+00} +!21 = !MDLocation(line: 2, scope: !4) +!22 = !{double 1.000000e+00} +!23 = !MDLocation(line: 3, scope: !17) +!24 = !MDLocation(line: 4, scope: !25) +!25 = !{!"0xb\003\000\001", !1, !17} ; [ DW_TAG_lexical_block ] [/Users/nadav/file.c] +!29 = !MDLocation(line: 5, scope: !25) +!30 = !MDLocation(line: 7, scope: !4) +!31 = !MDLocation(line: 8, scope: !4) +!32 = !{i32 1, !"Debug Info Version", i32 2} diff --git a/test/Transforms/SLPVectorizer/X86/metadata.ll b/test/Transforms/SLPVectorizer/X86/metadata.ll index 5bd2fa4..e021cca 100644 --- a/test/Transforms/SLPVectorizer/X86/metadata.ll +++ b/test/Transforms/SLPVectorizer/X86/metadata.ll @@ -51,11 +51,11 @@ entry: ret void } -;CHECK-DAG: ![[TBAA]] = metadata !{metadata [[TYPEC:!.*]], metadata [[TYPEC]], i64 0} -;CHECK-DAG: ![[FP1]] = metadata !{float 5.000000e+00} -;CHECK-DAG: ![[FP2]] = metadata !{float 2.500000e+00} -!0 = metadata !{ float 5.0 } -!1 = metadata !{ float 2.5 } -!2 = metadata !{metadata !"Simple C/C++ TBAA"} -!3 = metadata !{metadata !"omnipotent char", metadata !2} -!4 = metadata !{metadata !"double", metadata !3} +;CHECK-DAG: ![[TBAA]] = !{[[TYPEC:!.*]], [[TYPEC]], i64 0} +;CHECK-DAG: ![[FP1]] = !{float 5.000000e+00} +;CHECK-DAG: ![[FP2]] = !{float 2.500000e+00} +!0 = !{ float 5.0 } +!1 = !{ float 2.5 } +!2 = !{!"Simple C/C++ TBAA"} +!3 = !{!"omnipotent char", !2} +!4 = !{!"double", !3} diff --git a/test/Transforms/SLPVectorizer/X86/operandorder.ll b/test/Transforms/SLPVectorizer/X86/operandorder.ll index c5322a8..cd446f0 100644 --- a/test/Transforms/SLPVectorizer/X86/operandorder.ll +++ b/test/Transforms/SLPVectorizer/X86/operandorder.ll @@ -232,3 +232,113 @@ for.body3: for.end: ret void } + +; Check vectorization of following code for double data type- +; c[0] = a[0]+b[0]; +; c[1] = b[1]+a[1]; // swapped b[1] and a[1] + +; CHECK-LABEL: load_reorder_double +; CHECK: load <2 x double>* +; CHECK: fadd <2 x double> +define void @load_reorder_double(double* nocapture %c, double* noalias nocapture readonly %a, double* noalias nocapture readonly %b){ + %1 = load double* %a + %2 = load double* %b + %3 = fadd double %1, %2 + store double %3, double* %c + %4 = getelementptr inbounds double* %b, i64 1 + %5 = load double* %4 + %6 = getelementptr inbounds double* %a, i64 1 + %7 = load double* %6 + %8 = fadd double %5, %7 + %9 = getelementptr inbounds double* %c, i64 1 + store double %8, double* %9 + ret void +} + +; Check vectorization of following code for float data type- +; c[0] = a[0]+b[0]; +; c[1] = b[1]+a[1]; // swapped b[1] and a[1] +; c[2] = a[2]+b[2]; +; c[3] = a[3]+b[3]; + +; CHECK-LABEL: load_reorder_float +; CHECK: load <4 x float>* +; CHECK: fadd <4 x float> +define void @load_reorder_float(float* nocapture %c, float* noalias nocapture readonly %a, float* noalias nocapture readonly %b){ + %1 = load float* %a + %2 = load float* %b + %3 = fadd float %1, %2 + store float %3, float* %c + %4 = getelementptr inbounds float* %b, i64 1 + %5 = load float* %4 + %6 = getelementptr inbounds float* %a, i64 1 + %7 = load float* %6 + %8 = fadd float %5, %7 + %9 = getelementptr inbounds float* %c, i64 1 + store float %8, float* %9 + %10 = getelementptr inbounds float* %a, i64 2 + %11 = load float* %10 + %12 = getelementptr inbounds float* %b, i64 2 + %13 = load float* %12 + %14 = fadd float %11, %13 + %15 = getelementptr inbounds float* %c, i64 2 + store float %14, float* %15 + %16 = getelementptr inbounds float* %a, i64 3 + %17 = load float* %16 + %18 = getelementptr inbounds float* %b, i64 3 + %19 = load float* %18 + %20 = fadd float %17, %19 + %21 = getelementptr inbounds float* %c, i64 3 + store float %20, float* %21 + ret void +} + +; Check we properly reorder the below code so that it gets vectorized optimally- +; a[0] = (b[0]+c[0])+d[0]; +; a[1] = d[1]+(b[1]+c[1]); +; a[2] = (b[2]+c[2])+d[2]; +; a[3] = (b[3]+c[3])+d[3]; + +; CHECK-LABEL: opcode_reorder +; CHECK: load <4 x float>* +; CHECK: fadd <4 x float> +define void @opcode_reorder(float* noalias nocapture %a, float* noalias nocapture readonly %b, + float* noalias nocapture readonly %c,float* noalias nocapture readonly %d){ + %1 = load float* %b + %2 = load float* %c + %3 = fadd float %1, %2 + %4 = load float* %d + %5 = fadd float %3, %4 + store float %5, float* %a + %6 = getelementptr inbounds float* %d, i64 1 + %7 = load float* %6 + %8 = getelementptr inbounds float* %b, i64 1 + %9 = load float* %8 + %10 = getelementptr inbounds float* %c, i64 1 + %11 = load float* %10 + %12 = fadd float %9, %11 + %13 = fadd float %7, %12 + %14 = getelementptr inbounds float* %a, i64 1 + store float %13, float* %14 + %15 = getelementptr inbounds float* %b, i64 2 + %16 = load float* %15 + %17 = getelementptr inbounds float* %c, i64 2 + %18 = load float* %17 + %19 = fadd float %16, %18 + %20 = getelementptr inbounds float* %d, i64 2 + %21 = load float* %20 + %22 = fadd float %19, %21 + %23 = getelementptr inbounds float* %a, i64 2 + store float %22, float* %23 + %24 = getelementptr inbounds float* %b, i64 3 + %25 = load float* %24 + %26 = getelementptr inbounds float* %c, i64 3 + %27 = load float* %26 + %28 = fadd float %25, %27 + %29 = getelementptr inbounds float* %d, i64 3 + %30 = load float* %29 + %31 = fadd float %28, %30 + %32 = getelementptr inbounds float* %a, i64 3 + store float %31, float* %32 + ret void +} diff --git a/test/Transforms/SLPVectorizer/X86/pr16899.ll b/test/Transforms/SLPVectorizer/X86/pr16899.ll index 8631bc9..c642f3c 100644 --- a/test/Transforms/SLPVectorizer/X86/pr16899.ll +++ b/test/Transforms/SLPVectorizer/X86/pr16899.ll @@ -23,9 +23,9 @@ do.body: ; preds = %do.body, %entry attributes #0 = { noreturn nounwind readonly "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf"="true" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" } -!0 = metadata !{metadata !"any pointer", metadata !1} -!1 = metadata !{metadata !"omnipotent char", metadata !2} -!2 = metadata !{metadata !"Simple C/C++ TBAA"} -!3 = metadata !{metadata !"int", metadata !1} -!4 = metadata !{metadata !0, metadata !0, i64 0} -!5 = metadata !{metadata !3, metadata !3, i64 0} +!0 = !{!"any pointer", !1} +!1 = !{!"omnipotent char", !2} +!2 = !{!"Simple C/C++ TBAA"} +!3 = !{!"int", !1} +!4 = !{!0, !0, i64 0} +!5 = !{!3, !3, i64 0} |