• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt < %s  -loop-vectorize -force-vector-interleave=1 -force-vector-width=4 -dce -instcombine -S -enable-if-conversion | FileCheck %s
2
3target 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"
4target triple = "x86_64-apple-macosx10.8.0"
5
6;CHECK: fc
7;CHECK: load <4 x i16>
8;CHECK-NEXT: shufflevector <4 x i16>
9;CHECK: select <4 x i1>
10;CHECK: store <4 x i16>
11;CHECK: ret
12define void @fc(i16* nocapture %p, i32 %n, i32 %size) nounwind uwtable ssp {
13entry:
14  br label %do.body
15
16do.body:                                          ; preds = %cond.end, %entry
17  %n.addr.0 = phi i32 [ %n, %entry ], [ %dec, %cond.end ]
18  %p.addr.0 = phi i16* [ %p, %entry ], [ %incdec.ptr, %cond.end ]
19  %incdec.ptr = getelementptr inbounds i16, i16* %p.addr.0, i64 -1
20  %0 = load i16, i16* %incdec.ptr, align 2
21  %conv = zext i16 %0 to i32
22  %cmp = icmp ult i32 %conv, %size
23  br i1 %cmp, label %cond.end, label %cond.true
24
25cond.true:                                        ; preds = %do.body
26  %sub = sub i32 %conv, %size
27  %phitmp = trunc i32 %sub to i16
28  br label %cond.end
29
30cond.end:                                         ; preds = %do.body, %cond.true
31  %cond = phi i16 [ %phitmp, %cond.true ], [ 0, %do.body ]
32  store i16 %cond, i16* %incdec.ptr, align 2
33  %dec = add i32 %n.addr.0, -1
34  %tobool = icmp eq i32 %dec, 0
35  br i1 %tobool, label %do.end, label %do.body
36
37do.end:                                           ; preds = %cond.end
38  ret void
39}
40
41;CHECK: example1
42;CHECK: load <4 x i32>
43;CHECK-NEXT: shufflevector <4 x i32>
44;CHECK: select <4 x i1>
45;CHECK: store <4 x i32>
46;CHECK: ret
47define void @example1(i32* nocapture %a, i32 %n, i32 %wsize) nounwind uwtable ssp {
48entry:
49  br label %do.body
50
51do.body:                                          ; preds = %do.body, %entry
52  %n.addr.0 = phi i32 [ %n, %entry ], [ %dec, %do.body ]
53  %p.0 = phi i32* [ %a, %entry ], [ %incdec.ptr, %do.body ]
54  %incdec.ptr = getelementptr inbounds i32, i32* %p.0, i64 -1
55  %0 = load i32, i32* %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, i32* %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
63
64do.end:                                           ; preds = %do.body
65  ret void
66}
67