Index: test/Transforms/LoopVectorize/vector-variant/loop-x86.ll =================================================================== --- /dev/null +++ test/Transforms/LoopVectorize/vector-variant/loop-x86.ll @@ -0,0 +1,75 @@ +; RUN: opt < %s -S -loop-vectorize -force-vector-interleave=1 -mattr=+sse \ +; RUN: | FileCheck %s --check-prefix=SSE + +; RUN: opt < %s -S -loop-vectorize -force-vector-interleave=1 -mattr=+avx \ +; RUN: | FileCheck %s --check-prefix=AVX + +; RUN: opt < %s -S -loop-vectorize -force-vector-interleave=1 -mattr=+avx2 \ +; RUN: | FileCheck %s --check-prefix=AVX2 + +; RUN: opt < %s -S -loop-vectorize -force-vector-interleave=1 -mattr=+avx512f \ +; RUN: | FileCheck %s --check-prefix=AVX512 + +; This is targeting SSE, the other vector extensions are not used. +; SSE-NOT: @_ZGVc +; SSE-NOT: @_ZGVd +; SSE-NOT: @_ZGVe +; SSE-LABEL: void @loop +; SSE: call <2 x double> @_ZGVbN2v_foo + +; This is targeting AVX, the other vector extensions are not used. +; AVX-NOT: @_ZGVb +; AVX-NOT: @_ZGVd +; AVX-NOT: @_ZGVe +; AVX-LABEL: void @loop +; AVX: call <4 x double> @_ZGVcN4v_foo + +; This is targeting AVX2, the other vector extensions are not used. +; AVX2-NOT: @_ZGVb +; AVX2-NOT: @_ZGVc +; AVX2-NOT: @_ZGVe +; AVX2-LABEL: void @loop +; AVX2: call <4 x double> @_ZGVdN4v_foo + +; This is targeting AVX512, the other vector extensions are not used. +; AVX512-NOT: @_ZGVb +; AVX512-NOT: @_ZGVc +; AVX512-NOT: @_ZGVd +; AVX512-LABEL: void @loop +; AVX512: call <8 x double> @_ZGVeN8v_foo + +target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-linux-gnu" + +define double @foo(double %x) #0 { +entry: + %mul = fmul double %x, 2.000000e+00 + %add = fadd double %mul, 1.000000e+00 + ret double %add +} + +define void @loop(double* noalias nocapture readonly %x, double* nocapture %y, i32 %n) { +entry: + %cmp9 = icmp eq i32 %n, 0 + br i1 %cmp9, label %for.cond.cleanup, label %for.body.preheader + +for.body.preheader: ; preds = %entry + %wide.trip.count = zext i32 %n to i64 + br label %for.body + +for.cond.cleanup: ; preds = %for.body, %entry + ret void + +for.body: ; preds = %for.body, %for.body.preheader + %indvars.iv = phi i64 [ 0, %for.body.preheader ], [ %indvars.iv.next, %for.body ] + %arrayidx = getelementptr inbounds double, double* %x, i64 %indvars.iv + %0 = load double, double* %arrayidx, align 8 + %call = tail call double @foo(double %0) + %arrayidx3 = getelementptr inbounds double, double* %y, i64 %indvars.iv + store double %call, double* %arrayidx3, align 8 + %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1 + %exitcond = icmp eq i64 %indvars.iv.next, %wide.trip.count + br i1 %exitcond, label %for.cond.cleanup, label %for.body +} + +attributes #0 = { noinline "vector-variants"="_ZGVbN2v_foo, _ZGVcN4v_foo, _ZGVdN4v_foo, _ZGVeN8v_foo" }