ARM: support TLS accesses on Darwin platforms
[oota-llvm.git] / test / CodeGen / X86 / stores-merging.ll
1 ; RUN: llc < %s | FileCheck %s
2
3 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
4 target triple = "x86_64-unknown-linux-gnu"
5
6 %structTy = type { i8, i32, i32 }
7
8 @e = common global %structTy zeroinitializer, align 4
9
10 ;; Ensure that MergeConsecutiveStores doesn't incorrectly reorder
11 ;; store operations.  The first test stores in increasing address
12 ;; order, the second in decreasing -- but in both cases should have
13 ;; the same result in memory in the end.
14
15 ; CHECK-LABEL: redundant_stores_merging:
16 ; CHECK:   movl    $123, e+8(%rip)
17 ; CHECK:   movabsq $1958505086977, %rax
18 ; CHECK:   movq    %rax, e+4(%rip)
19 define void @redundant_stores_merging() {
20 entry:
21   store i32 1, i32* getelementptr inbounds (%structTy, %structTy* @e, i64 0, i32 1), align 4
22   store i32 123, i32* getelementptr inbounds (%structTy, %structTy* @e, i64 0, i32 2), align 4
23   store i32 456, i32* getelementptr inbounds (%structTy, %structTy* @e, i64 0, i32 2), align 4
24   ret void
25 }
26
27 ;; This variant tests PR25154.
28 ; CHECK-LABEL: redundant_stores_merging_reverse:
29 ; CHECK:   movl    $123, e+8(%rip)
30 ; CHECK:   movabsq $1958505086977, %rax
31 ; CHECK:   movq    %rax, e+4(%rip)
32 define void @redundant_stores_merging_reverse() {
33 entry:
34   store i32 123, i32* getelementptr inbounds (%structTy, %structTy* @e, i64 0, i32 2), align 4
35   store i32 456, i32* getelementptr inbounds (%structTy, %structTy* @e, i64 0, i32 2), align 4
36   store i32 1, i32* getelementptr inbounds (%structTy, %structTy* @e, i64 0, i32 1), align 4
37   ret void
38 }
39
40 @b = common global [8 x i8] zeroinitializer, align 2
41
42 ;; The 2-byte store to offset 3 overlaps the 2-byte store to offset 2;
43 ;; these must not be reordered in MergeConsecutiveStores such that the
44 ;; store to 3 comes first (e.g. by merging the stores to 0 and 2 into
45 ;; a movl, after the store to 3).
46
47 ;; CHECK-LABEL: overlapping_stores_merging:
48 ;; CHECK:  movw    $0, b+2(%rip)
49 ;; CHECK:  movw    $2, b+3(%rip)
50 ;; CHECK:  movw    $1, b(%rip)
51 define void @overlapping_stores_merging() {
52 entry:
53   store i16 0, i16* bitcast (i8* getelementptr inbounds ([8 x i8], [8 x i8]* @b, i64 0, i64 2) to i16*), align 2
54   store i16 2, i16* bitcast (i8* getelementptr inbounds ([8 x i8], [8 x i8]* @b, i64 0, i64 3) to i16*), align 1
55   store i16 1, i16* bitcast (i8* getelementptr inbounds ([8 x i8], [8 x i8]* @b, i64 0, i64 0) to i16*), align 2
56   ret void
57 }