1 ; RUN: opt < %s -passes=slp-vectorizer -o - -S -slp-threshold=-1000 | FileCheck %s
3 target datalayout = "e-p:32:32-i64:64-v16:16-v32:32-n16:32:64"
4 target triple = "nvptx--nvidiacl"
6 ; Test that CTLZ can be vectorized currently even though the second argument is a scalar
8 define <2 x i8> @cltz_test(<2 x i8> %x) #0 {
9 ; CHECK-LABEL: @cltz_test(
10 ; CHECK: [[VEC:%.*]] = call <2 x i8> @llvm.ctlz.v2i8(<2 x i8> %{{.*}}, i1 false)
11 ; CHECK-NEXT: ret <2 x i8> [[VEC]]
14 %0 = extractelement <2 x i8> %x, i32 0
15 %call.i = call i8 @llvm.ctlz.i8(i8 %0, i1 false)
16 %vecinit = insertelement <2 x i8> undef, i8 %call.i, i32 0
17 %1 = extractelement <2 x i8> %x, i32 1
18 %call.i4 = call i8 @llvm.ctlz.i8(i8 %1, i1 false)
19 %vecinit2 = insertelement <2 x i8> %vecinit, i8 %call.i4, i32 1
20 ret <2 x i8> %vecinit2
24 define <2 x i8> @cltz_test_poison(<2 x i8> %x) #0 {
25 ; CHECK-LABEL: @cltz_test_poison(
26 ; CHECK: [[VEC:%.*]] = call <2 x i8> @llvm.ctlz.v2i8(<2 x i8> %{{.*}}, i1 false)
27 ; CHECK-NEXT: ret <2 x i8> [[VEC]]
30 %0 = extractelement <2 x i8> %x, i32 0
31 %call.i = call i8 @llvm.ctlz.i8(i8 %0, i1 false)
32 %vecinit = insertelement <2 x i8> poison, i8 %call.i, i32 0
33 %1 = extractelement <2 x i8> %x, i32 1
34 %call.i4 = call i8 @llvm.ctlz.i8(i8 %1, i1 false)
35 %vecinit2 = insertelement <2 x i8> %vecinit, i8 %call.i4, i32 1
36 ret <2 x i8> %vecinit2
39 declare i8 @llvm.ctlz.i8(i8, i1) #3
41 attributes #0 = { alwaysinline nounwind "less-precise-fpmad"="false" "frame-pointer"="all" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
42 attributes #1 = { nounwind readnone }