1 ; RUN: opt -passes='loop-vectorize' -mcpu=z13 -force-vector-width=2 -S < %s | FileCheck %s
3 ; Forcing VF=2 to trigger vector code gen
5 ; This is a test case to exercise more cases in truncateToMinimalBitWidths().
6 ; Test passes if vector code is generated w/o hitting llvm_unreachable().
8 ; Performing minimal check in the output to ensure the loop is actually
13 target datalayout = "E-m:e-i1:8:16-i8:8:16-i64:64-f128:64-v128:64-a:8:16-n32:64"
14 target triple = "s390x-ibm-linux"
16 define void @test(i32 zeroext %width, ptr nocapture %row, i16 zeroext %src, ptr nocapture readonly %dst) {
18 %cmp10 = icmp eq i32 %width, 0
19 br i1 %cmp10, label %for.end, label %for.body.lr.ph
21 for.body.lr.ph: ; preds = %entry
22 %conv1 = zext i16 %src to i32
25 for.body: ; preds = %for.inc, %for.body.lr.ph
26 %i.012 = phi i32 [ 0, %for.body.lr.ph ], [ %inc, %for.inc ]
27 %sp.011 = phi ptr [ %row, %for.body.lr.ph ], [ %incdec.ptr, %for.inc ]
28 %0 = load i8, ptr %sp.011, align 1
29 %conv = zext i8 %0 to i32
30 %cmp2 = icmp eq i32 %conv, %conv1
31 br i1 %cmp2, label %if.then, label %for.inc
33 if.then: ; preds = %for.body
34 %1 = load i16, ptr %dst, align 2
35 %conv4 = trunc i16 %1 to i8
36 store i8 %conv4, ptr %sp.011, align 1
39 for.inc: ; preds = %for.body, %if.then
40 %inc = add nuw i32 %i.012, 1
41 %incdec.ptr = getelementptr inbounds i8, ptr %sp.011, i64 1
42 %exitcond = icmp eq i32 %inc, %width
43 br i1 %exitcond, label %for.end.loopexit, label %for.body
45 for.end.loopexit: ; preds = %for.inc
48 for.end: ; preds = %for.end.loopexit, %entry