1 ; RUN: llc -fixup-byte-word-insts=1 < %s | \
2 ; RUN: FileCheck -check-prefix CHECK -check-prefix BWON %s
3 ; RUN: llc -fixup-byte-word-insts=0 < %s | \
4 ; RUN: FileCheck -check-prefix CHECK -check-prefix BWOFF %s
6 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 target triple = "x86_64-apple-macosx10.8.0"
9 %struct.A = type { i8, i8, i8, i8, i8, i8, i8, i8 }
11 ; This has byte loads interspersed with byte stores, in a single
12 ; basic-block loop. The upper portion should be dead, so the movb loads
13 ; should have been changed into movzbl instead.
26 define void @foo1(i32 %count,
27 ptr noalias nocapture %q,
28 ptr noalias nocapture %p)
29 nounwind uwtable noinline ssp {
30 %1 = icmp sgt i32 %count, 0
31 br i1 %1, label %.lr.ph, label %._crit_edge
34 %2 = getelementptr inbounds %struct.A, ptr %q, i64 0, i32 1
37 a4: ; preds = %3, %.lr.ph
38 %i.02 = phi i32 [ 0, %.lr.ph ], [ %a9, %a4 ]
39 %.01 = phi ptr [ %p, %.lr.ph ], [ %a10, %a4 ]
40 %a5 = load i8, ptr %q, align 1
41 store i8 %a5, ptr %.01, align 1
42 %a8 = getelementptr inbounds %struct.A, ptr %.01, i64 0, i32 1
43 %a6 = load i8, ptr %2, align 1
44 store i8 %a6, ptr %a8, align 1
45 %a9 = add nsw i32 %i.02, 1
46 %a10 = getelementptr inbounds %struct.A, ptr %.01, i64 1
47 %exitcond = icmp eq i32 %a9, %count
48 br i1 %exitcond, label %._crit_edge, label %a4
50 ._crit_edge: ; preds = %3, %0
54 %struct.B = type { i16, i16, i16, i16, i16, i16, i16, i16 }
56 ; This has word loads interspersed with word stores.
57 ; The upper portion should be dead, so the movw loads should have
58 ; been changed into movzwl instead.
71 define void @foo2(i32 %count,
72 ptr noalias nocapture %q,
73 ptr noalias nocapture %p)
74 nounwind uwtable noinline ssp {
75 %1 = icmp sgt i32 %count, 0
76 br i1 %1, label %.lr.ph, label %._crit_edge
79 %2 = getelementptr inbounds %struct.B, ptr %q, i64 0, i32 1
82 a4: ; preds = %3, %.lr.ph
83 %i.02 = phi i32 [ 0, %.lr.ph ], [ %a9, %a4 ]
84 %.01 = phi ptr [ %p, %.lr.ph ], [ %a10, %a4 ]
85 %a5 = load i16, ptr %q, align 2
86 store i16 %a5, ptr %.01, align 2
87 %a8 = getelementptr inbounds %struct.B, ptr %.01, i64 0, i32 1
88 %a6 = load i16, ptr %2, align 2
89 store i16 %a6, ptr %a8, align 2
90 %a9 = add nsw i32 %i.02, 1
91 %a10 = getelementptr inbounds %struct.B, ptr %.01, i64 1
92 %exitcond = icmp eq i32 %a9, %count
93 br i1 %exitcond, label %._crit_edge, label %a4
95 ._crit_edge: ; preds = %3, %0
99 ; This test contains nothing but a simple byte load and store.
100 ; movb encodes smaller, but we use movzbl for the load for better perf.
105 define void @foo3(ptr%dst, ptr%src) {
106 %t0 = load i8, ptr%src, align 1
107 store i8 %t0, ptr%dst, align 1
111 ; This test contains nothing but a simple word load and store. Since
112 ; movw and movzwl are the same size, we should always choose to use
118 define void @foo4(ptr%dst, ptr%src) {
119 %t0 = load i16, ptr%src, align 2
120 store i16 %t0, ptr%dst, align 2