blob: bedea9de5f92711eb9c06e4dc644e0c7ddcf7433 [file] [log] [blame]
Daniel Sanders8008de52015-10-15 14:34:23 +00001; RUN: llc -march=mipsel -mattr=mips16 -relocation-model=pic -O3 < %s | FileCheck %s -check-prefix=16
Reed Kotler740981e2012-10-29 19:39:04 +00002
3define i32 @sumc(i8* nocapture %to, i8* nocapture %from, i32) nounwind {
4entry:
5 %sext = shl i32 %0, 16
6 %conv = ashr exact i32 %sext, 16
7 %cmp8 = icmp eq i32 %conv, 0
8 br i1 %cmp8, label %for.end, label %for.body.lr.ph
9
10for.body.lr.ph: ; preds = %entry
David Blaikiea79ac142015-02-27 21:17:42 +000011 %.pre = load i8, i8* %to, align 1
Reed Kotler740981e2012-10-29 19:39:04 +000012 br label %for.body
13
14for.body: ; preds = %for.body.lr.ph, %for.body
15 %1 = phi i8 [ %.pre, %for.body.lr.ph ], [ %conv4, %for.body ]
16 %i.010 = phi i32 [ 0, %for.body.lr.ph ], [ %inc, %for.body ]
17 %from.addr.09 = phi i8* [ %from, %for.body.lr.ph ], [ %incdec.ptr, %for.body ]
David Blaikie79e6c742015-02-27 19:29:02 +000018 %incdec.ptr = getelementptr inbounds i8, i8* %from.addr.09, i32 1
David Blaikiea79ac142015-02-27 21:17:42 +000019 %2 = load i8, i8* %from.addr.09, align 1
Reed Kotler740981e2012-10-29 19:39:04 +000020 %conv27 = zext i8 %2 to i32
21 %conv36 = zext i8 %1 to i32
22 %add = add nsw i32 %conv36, %conv27
23 %conv4 = trunc i32 %add to i8
24 store i8 %conv4, i8* %to, align 1
25 %inc = add nsw i32 %i.010, 1
26 %cmp = icmp eq i32 %inc, %conv
27 br i1 %cmp, label %for.end, label %for.body
Stephen Lind24ab202013-07-14 06:24:09 +000028; 16-LABEL: sumc:
Reed Kotler740981e2012-10-29 19:39:04 +000029; 16: lbu ${{[0-9]+}}, 0(${{[0-9]+}})
30; 16: lbu ${{[0-9]+}}, 0(${{[0-9]+}})
Stephen Lind24ab202013-07-14 06:24:09 +000031; 16-LABEL: sum:
Reed Kotler740981e2012-10-29 19:39:04 +000032; 16: lhu ${{[0-9]+}}, 0(${{[0-9]+}})
33; 16: lhu ${{[0-9]+}}, 0(${{[0-9]+}})
34
35for.end: ; preds = %for.body, %entry
36 ret i32 undef
37}
38
39define i32 @sum(i16* nocapture %to, i16* nocapture %from, i32) nounwind {
40entry:
41 %sext = shl i32 %0, 16
42 %conv = ashr exact i32 %sext, 16
43 %cmp8 = icmp eq i32 %conv, 0
44 br i1 %cmp8, label %for.end, label %for.body.lr.ph
45
46for.body.lr.ph: ; preds = %entry
David Blaikiea79ac142015-02-27 21:17:42 +000047 %.pre = load i16, i16* %to, align 2
Reed Kotler740981e2012-10-29 19:39:04 +000048 br label %for.body
49
50for.body: ; preds = %for.body.lr.ph, %for.body
51 %1 = phi i16 [ %.pre, %for.body.lr.ph ], [ %conv4, %for.body ]
52 %i.010 = phi i32 [ 0, %for.body.lr.ph ], [ %inc, %for.body ]
53 %from.addr.09 = phi i16* [ %from, %for.body.lr.ph ], [ %incdec.ptr, %for.body ]
David Blaikie79e6c742015-02-27 19:29:02 +000054 %incdec.ptr = getelementptr inbounds i16, i16* %from.addr.09, i32 1
David Blaikiea79ac142015-02-27 21:17:42 +000055 %2 = load i16, i16* %from.addr.09, align 2
Reed Kotler740981e2012-10-29 19:39:04 +000056 %conv27 = zext i16 %2 to i32
57 %conv36 = zext i16 %1 to i32
58 %add = add nsw i32 %conv36, %conv27
59 %conv4 = trunc i32 %add to i16
60 store i16 %conv4, i16* %to, align 2
61 %inc = add nsw i32 %i.010, 1
62 %cmp = icmp eq i32 %inc, %conv
63 br i1 %cmp, label %for.end, label %for.body
64
65for.end: ; preds = %for.body, %entry
66 ret i32 undef
67}
68
69