Fix for codegen bug that could cause illegal cmn instruction generation
[oota-llvm.git] / test / CodeGen / Mips / mips64load-store-left-right.ll
1 ; RUN: llc -march=mips64el -mcpu=mips4 -mattr=n64 < %s | FileCheck  -check-prefix=EL %s
2 ; RUN: llc -march=mips64 -mcpu=mips4 -mattr=n64 < %s | FileCheck  -check-prefix=EB %s
3 ; RUN: llc -march=mips64el -mcpu=mips64 -mattr=n64 < %s | FileCheck  -check-prefix=EL %s
4 ; RUN: llc -march=mips64 -mcpu=mips64 -mattr=n64 < %s | FileCheck  -check-prefix=EB %s
5
6 %struct.SLL = type { i64 }
7 %struct.SI = type { i32 }
8 %struct.SUI = type { i32 }
9
10 @sll = common global %struct.SLL zeroinitializer, align 1
11 @si = common global %struct.SI zeroinitializer, align 1
12 @sui = common global %struct.SUI zeroinitializer, align 1
13
14 define i64 @foo_load_ll() nounwind readonly {
15 entry:
16 ; EL: ldl $[[R0:[0-9]+]], 7($[[R1:[0-9]+]])
17 ; EL: ldr $[[R0]], 0($[[R1]])
18 ; EB: ldl $[[R0:[0-9]+]], 0($[[R1:[0-9]+]])
19 ; EB: ldr $[[R0]], 7($[[R1]])
20
21   %0 = load i64* getelementptr inbounds (%struct.SLL* @sll, i64 0, i32 0), align 1
22   ret i64 %0
23 }
24
25 define i64 @foo_load_i() nounwind readonly {
26 entry:
27 ; EL: lwl $[[R0:[0-9]+]], 3($[[R1:[0-9]+]])
28 ; EL: lwr $[[R0]], 0($[[R1]])
29 ; EB: lwl $[[R0:[0-9]+]], 0($[[R1:[0-9]+]])
30 ; EB: lwr $[[R0]], 3($[[R1]])
31
32   %0 = load i32* getelementptr inbounds (%struct.SI* @si, i64 0, i32 0), align 1
33   %conv = sext i32 %0 to i64
34   ret i64 %conv
35 }
36
37 define i64 @foo_load_ui() nounwind readonly {
38 entry:
39 ; EL: lwl $[[R0:[0-9]+]], 3($[[R1:[0-9]+]])
40 ; EL: lwr $[[R0]], 0($[[R1]])
41 ; EL: daddiu $[[R2:[0-9]+]], $zero, 1
42 ; EL: dsll   $[[R3:[0-9]+]], $[[R2]], 32
43 ; EL: daddiu $[[R4:[0-9]+]], $[[R3]], -1
44 ; EL: and    ${{[0-9]+}}, $[[R0]], $[[R4]]
45 ; EB: lwl $[[R0:[0-9]+]], 0($[[R1:[0-9]+]])
46 ; EB: lwr $[[R0]], 3($[[R1]])
47
48
49   %0 = load i32* getelementptr inbounds (%struct.SUI* @sui, i64 0, i32 0), align 1
50   %conv = zext i32 %0 to i64
51   ret i64 %conv
52 }
53
54 define void @foo_store_ll(i64 %a) nounwind {
55 entry:
56 ; EL: sdl $[[R0:[0-9]+]], 7($[[R1:[0-9]+]])
57 ; EL: sdr $[[R0]], 0($[[R1]])
58 ; EB: sdl $[[R0:[0-9]+]], 0($[[R1:[0-9]+]])
59 ; EB: sdr $[[R0]], 7($[[R1]])
60
61   store i64 %a, i64* getelementptr inbounds (%struct.SLL* @sll, i64 0, i32 0), align 1
62   ret void
63 }
64
65 define void @foo_store_i(i32 %a) nounwind {
66 entry:
67 ; EL: swl $[[R0:[0-9]+]], 3($[[R1:[0-9]+]])
68 ; EL: swr $[[R0]], 0($[[R1]])
69 ; EB: swl $[[R0:[0-9]+]], 0($[[R1:[0-9]+]])
70 ; EB: swr $[[R0]], 3($[[R1]])
71
72   store i32 %a, i32* getelementptr inbounds (%struct.SI* @si, i64 0, i32 0), align 1
73   ret void
74 }
75