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 %struct.A* noalias nocapture %q,
28 %struct.A* 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, %struct.A* %q, i64 0, i32 0
35 %3 = getelementptr inbounds %struct.A, %struct.A* %q, i64 0, i32 1
38 a4: ; preds = %4, %.lr.ph
39 %i.02 = phi i32 [ 0, %.lr.ph ], [ %a9, %a4 ]
40 %.01 = phi %struct.A* [ %p, %.lr.ph ], [ %a10, %a4 ]
41 %a5 = load i8, i8* %2, align 1
42 %a7 = getelementptr inbounds %struct.A, %struct.A* %.01, i64 0, i32 0
43 store i8 %a5, i8* %a7, align 1
44 %a8 = getelementptr inbounds %struct.A, %struct.A* %.01, i64 0, i32 1
45 %a6 = load i8, i8* %3, align 1
46 store i8 %a6, i8* %a8, align 1
47 %a9 = add nsw i32 %i.02, 1
48 %a10 = getelementptr inbounds %struct.A, %struct.A* %.01, i64 1
49 %exitcond = icmp eq i32 %a9, %count
50 br i1 %exitcond, label %._crit_edge, label %a4
52 ._crit_edge: ; preds = %4, %0
56 %struct.B = type { i16, i16, i16, i16, i16, i16, i16, i16 }
58 ; This has word loads interspersed with word stores.
59 ; The upper portion should be dead, so the movw loads should have
60 ; been changed into movzwl instead.
73 define void @foo2(i32 %count,
74 %struct.B* noalias nocapture %q,
75 %struct.B* noalias nocapture %p)
76 nounwind uwtable noinline ssp {
77 %1 = icmp sgt i32 %count, 0
78 br i1 %1, label %.lr.ph, label %._crit_edge
81 %2 = getelementptr inbounds %struct.B, %struct.B* %q, i64 0, i32 0
82 %3 = getelementptr inbounds %struct.B, %struct.B* %q, i64 0, i32 1
85 a4: ; preds = %4, %.lr.ph
86 %i.02 = phi i32 [ 0, %.lr.ph ], [ %a9, %a4 ]
87 %.01 = phi %struct.B* [ %p, %.lr.ph ], [ %a10, %a4 ]
88 %a5 = load i16, i16* %2, align 2
89 %a7 = getelementptr inbounds %struct.B, %struct.B* %.01, i64 0, i32 0
90 store i16 %a5, i16* %a7, align 2
91 %a8 = getelementptr inbounds %struct.B, %struct.B* %.01, i64 0, i32 1
92 %a6 = load i16, i16* %3, align 2
93 store i16 %a6, i16* %a8, align 2
94 %a9 = add nsw i32 %i.02, 1
95 %a10 = getelementptr inbounds %struct.B, %struct.B* %.01, i64 1
96 %exitcond = icmp eq i32 %a9, %count
97 br i1 %exitcond, label %._crit_edge, label %a4
99 ._crit_edge: ; preds = %4, %0
103 ; This test contains nothing but a simple byte load and store. Since
104 ; movb encodes smaller, we do not want to use movzbl unless in a tight loop.
105 ; So this test checks that movb is used.
109 define void @foo3(i8 *%dst, i8 *%src) {
110 %t0 = load i8, i8 *%src, align 1
111 store i8 %t0, i8 *%dst, align 1
115 ; This test contains nothing but a simple word load and store. Since
116 ; movw and movzwl are the same size, we should always choose to use
122 define void @foo4(i16 *%dst, i16 *%src) {
123 %t0 = load i16, i16 *%src, align 2
124 store i16 %t0, i16 *%dst, align 2