[PATCH] D52579: Vector Clone Tests for the loop vectorizer

Francesco Petrogalli via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 26 17:09:07 PDT 2018


fpetrogalli created this revision.
fpetrogalli added reviewers: mmasten, hfinkel.
Herald added a subscriber: llvm-commits.

These tests check the Loop Vectorizer interface with the Vector Clone pass on some of the x86 vector extensions.

In particular, they make sure that the correct vector function is selected when targeting each of the extensions.

The test is based on the work in progress patches at:

https://reviews.llvm.org/D40577
https://reviews.llvm.org/D40575
https://reviews.llvm.org/D22792


Repository:
  rL LLVM

https://reviews.llvm.org/D52579

Files:
  test/Transforms/LoopVectorize/vector-variant/loop-x86.ll


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" }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D52579.167215.patch
Type: text/x-patch
Size: 2962 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180927/3e05d955/attachment.bin>


More information about the llvm-commits mailing list