1 ; RUN: opt < %s -passes=loop-vectorize,dce,instcombine -force-vector-interleave=1 -force-vector-width=4 -S -enable-if-conversion | FileCheck %s
3 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
7 ;CHECK-NEXT: shufflevector <4 x i16>
8 ;CHECK: select <4 x i1>
9 ;CHECK: store <4 x i16>
11 define void @fc(ptr nocapture %p, i32 %n, i32 %size) nounwind uwtable ssp {
15 do.body: ; preds = %cond.end, %entry
16 %n.addr.0 = phi i32 [ %n, %entry ], [ %dec, %cond.end ]
17 %p.addr.0 = phi ptr [ %p, %entry ], [ %incdec.ptr, %cond.end ]
18 %incdec.ptr = getelementptr inbounds i16, ptr %p.addr.0, i64 -1
19 %0 = load i16, ptr %incdec.ptr, align 2
20 %conv = zext i16 %0 to i32
21 %cmp = icmp ult i32 %conv, %size
22 br i1 %cmp, label %cond.end, label %cond.true
24 cond.true: ; preds = %do.body
25 %sub = sub i32 %conv, %size
26 %phitmp = trunc i32 %sub to i16
29 cond.end: ; preds = %do.body, %cond.true
30 %cond = phi i16 [ %phitmp, %cond.true ], [ 0, %do.body ]
31 store i16 %cond, ptr %incdec.ptr, align 2
32 %dec = add i32 %n.addr.0, -1
33 %tobool = icmp eq i32 %dec, 0
34 br i1 %tobool, label %do.end, label %do.body
36 do.end: ; preds = %cond.end
41 ;CHECK: load <4 x i32>
42 ;CHECK-NEXT: shufflevector <4 x i32>
43 ;CHECK: sub nsw <4 x i32>
44 ;CHECK: select <4 x i1>
45 ;CHECK: store <4 x i32>
47 define void @example1(ptr nocapture %a, i32 %n, i32 %wsize) nounwind uwtable ssp {
51 do.body: ; preds = %do.body, %entry
52 %n.addr.0 = phi i32 [ %n, %entry ], [ %dec, %do.body ]
53 %p.0 = phi ptr [ %a, %entry ], [ %incdec.ptr, %do.body ]
54 %incdec.ptr = getelementptr inbounds i32, ptr %p.0, i64 -1
55 %0 = load i32, ptr %incdec.ptr, align 4
56 %cmp = icmp slt i32 %0, %wsize
57 %sub = sub nsw i32 %0, %wsize
58 %cond = select i1 %cmp, i32 0, i32 %sub
59 store i32 %cond, ptr %incdec.ptr, align 4
60 %dec = add nsw i32 %n.addr.0, -1
61 %tobool = icmp eq i32 %dec, 0
62 br i1 %tobool, label %do.end, label %do.body
64 do.end: ; preds = %do.body