aboutsummaryrefslogtreecommitdiff
path: root/test/CodeGen/Mips
diff options
context:
space:
mode:
Diffstat (limited to 'test/CodeGen/Mips')
-rw-r--r--test/CodeGen/Mips/alloca.ll15
-rw-r--r--test/CodeGen/Mips/and1.ll17
-rw-r--r--test/CodeGen/Mips/fabs.ll10
-rw-r--r--test/CodeGen/Mips/fp-indexed-ls.ll12
-rw-r--r--test/CodeGen/Mips/helloworld.ll34
-rw-r--r--test/CodeGen/Mips/i64arg.ll4
-rw-r--r--test/CodeGen/Mips/inlineasm-operand-code.ll160
-rw-r--r--test/CodeGen/Mips/largeimmprinting.ll4
-rw-r--r--test/CodeGen/Mips/lb1.ll18
-rw-r--r--test/CodeGen/Mips/lbu1.ll19
-rw-r--r--test/CodeGen/Mips/lh1.ll18
-rw-r--r--test/CodeGen/Mips/lhu1.ll19
-rw-r--r--test/CodeGen/Mips/longbranch.ll10
-rw-r--r--test/CodeGen/Mips/mips64-fp-indexed-ls.ll12
-rw-r--r--test/CodeGen/Mips/neg1.ll15
-rw-r--r--test/CodeGen/Mips/not1.ll16
-rw-r--r--test/CodeGen/Mips/o32_cc_byval.ll48
-rw-r--r--test/CodeGen/Mips/o32_cc_vararg.ll69
-rw-r--r--test/CodeGen/Mips/or1.ll17
-rw-r--r--test/CodeGen/Mips/ra-allocatable.ll288
-rw-r--r--test/CodeGen/Mips/rdhwr-directives.ll15
-rw-r--r--test/CodeGen/Mips/return-vector-float4.ll12
-rw-r--r--test/CodeGen/Mips/return_address.ll23
-rw-r--r--test/CodeGen/Mips/sb1.ll20
-rw-r--r--test/CodeGen/Mips/selectcc.ll27
-rw-r--r--test/CodeGen/Mips/sh1.ll20
-rw-r--r--test/CodeGen/Mips/sitofp-selectcc-opt.ll22
-rw-r--r--test/CodeGen/Mips/sll1.ll19
-rw-r--r--test/CodeGen/Mips/sll2.ll19
-rw-r--r--test/CodeGen/Mips/sra1.ll15
-rw-r--r--test/CodeGen/Mips/sra2.ll17
-rw-r--r--test/CodeGen/Mips/srl1.ll18
-rw-r--r--test/CodeGen/Mips/srl2.ll20
-rw-r--r--test/CodeGen/Mips/sub1.ll15
-rw-r--r--test/CodeGen/Mips/sub2.ll17
-rw-r--r--test/CodeGen/Mips/swzero.ll1
-rw-r--r--test/CodeGen/Mips/xor1.ll17
37 files changed, 979 insertions, 123 deletions
diff --git a/test/CodeGen/Mips/alloca.ll b/test/CodeGen/Mips/alloca.ll
index 14288deb43..29f43c8afa 100644
--- a/test/CodeGen/Mips/alloca.ll
+++ b/test/CodeGen/Mips/alloca.ll
@@ -4,14 +4,10 @@ define i32 @twoalloca(i32 %size) nounwind {
entry:
; CHECK: subu $[[T0:[0-9]+]], $sp, $[[SZ:[0-9]+]]
; CHECK: addu $sp, $zero, $[[T0]]
-; CHECK: addiu $[[T1:[0-9]+]], $sp, [[OFF:[0-9]+]]
; CHECK: subu $[[T2:[0-9]+]], $sp, $[[SZ]]
; CHECK: addu $sp, $zero, $[[T2]]
-; CHECK: addiu $[[T3:[0-9]+]], $sp, [[OFF]]
-; CHECK: lw $[[T4:[0-9]+]], %call16(foo)
-; CHECK: addu $25, $zero, $[[T4]]
-; CHECK: addu $4, $zero, $[[T1]]
-; CHECK: jalr $25
+; CHECK: addu $4, $zero, $[[T0]]
+; CHECK: addu $4, $zero, $[[T2]]
%tmp1 = alloca i8, i32 %size, align 4
%add.ptr = getelementptr inbounds i8* %tmp1, i32 5
store i8 97, i8* %add.ptr, align 1
@@ -34,7 +30,6 @@ entry:
; CHECK: alloca2
; CHECK: subu $[[T0:[0-9]+]], $sp
; CHECK: addu $sp, $zero, $[[T0]]
-; CHECK: addiu $[[T1:[0-9]+]], $sp
%tmp1 = alloca i8, i32 %size, align 4
%0 = bitcast i8* %tmp1 to i32*
@@ -42,7 +37,7 @@ entry:
br i1 %cmp, label %if.then, label %if.else
if.then: ; preds = %entry
-; CHECK: addiu $4, $[[T1]], 40
+; CHECK: addiu $4, $[[T0]], 40
%add.ptr = getelementptr inbounds i8* %tmp1, i32 40
%1 = bitcast i8* %add.ptr to i32*
@@ -52,7 +47,7 @@ if.then: ; preds = %entry
br label %if.end
if.else: ; preds = %entry
-; CHECK: addiu $4, $[[T1]], 12
+; CHECK: addiu $4, $[[T0]], 12
%add.ptr5 = getelementptr inbounds i8* %tmp1, i32 12
%2 = bitcast i8* %add.ptr5 to i32*
@@ -60,7 +55,7 @@ if.else: ; preds = %entry
br label %if.end
if.end: ; preds = %if.else, %if.then
-; CHECK: lw $5, 0($[[T1]])
+; CHECK: lw $5, 0($[[T0]])
; CHECK: lw $25, %call16(printf)
%.pre-phi = phi i32* [ %2, %if.else ], [ %.pre, %if.then ]
diff --git a/test/CodeGen/Mips/and1.ll b/test/CodeGen/Mips/and1.ll
new file mode 100644
index 0000000000..4ff1204fe7
--- /dev/null
+++ b/test/CodeGen/Mips/and1.ll
@@ -0,0 +1,17 @@
+; RUN: llc -march=mipsel -mcpu=mips16 -relocation-model=pic -O3 < %s | FileCheck %s -check-prefix=16
+
+@x = global i32 65504, align 4
+@y = global i32 60929, align 4
+@.str = private unnamed_addr constant [7 x i8] c"%08x \0A\00", align 1
+
+define i32 @main() nounwind {
+entry:
+ %0 = load i32* @x, align 4
+ %1 = load i32* @y, align 4
+ %and = and i32 %0, %1
+; 16: and ${{[0-9]+}}, ${{[0-9]+}}
+ %call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([7 x i8]* @.str, i32 0, i32 0), i32 %and)
+ ret i32 0
+}
+
+declare i32 @printf(i8*, ...)
diff --git a/test/CodeGen/Mips/fabs.ll b/test/CodeGen/Mips/fabs.ll
index b296ab390d..49d8a7201e 100644
--- a/test/CodeGen/Mips/fabs.ll
+++ b/test/CodeGen/Mips/fabs.ll
@@ -1,8 +1,8 @@
-; RUN: llc < %s -march=mipsel -mcpu=mips32 | FileCheck %s -check-prefix=32
-; RUN: llc < %s -march=mipsel -mcpu=mips32r2 | FileCheck %s -check-prefix=32R2
-; RUN: llc < %s -march=mips64el -mcpu=mips64 -mattr=n64 | FileCheck %s -check-prefix=64
-; RUN: llc < %s -march=mips64el -mcpu=mips64r2 -mattr=n64 | FileCheck %s -check-prefix=64R2
-; RUN: llc < %s -march=mipsel -mcpu=mips32 -enable-no-nans-fp-math | FileCheck %s -check-prefix=NO-NAN
+; RUN: llc < %s -mtriple=mipsel-linux-gnu -mcpu=mips32 | FileCheck %s -check-prefix=32
+; RUN: llc < %s -mtriple=mipsel-linux-gnu -mcpu=mips32r2 | FileCheck %s -check-prefix=32R2
+; RUN: llc < %s -mtriple=mips64el-linux-gnu -mcpu=mips64 -mattr=n64 | FileCheck %s -check-prefix=64
+; RUN: llc < %s -mtriple=mips64el-linux-gnu -mcpu=mips64r2 -mattr=n64 | FileCheck %s -check-prefix=64R2
+; RUN: llc < %s -mtriple=mipsel-linux-gnu -mcpu=mips32 -enable-no-nans-fp-math | FileCheck %s -check-prefix=NO-NAN
define float @foo0(float %a) nounwind readnone {
entry:
diff --git a/test/CodeGen/Mips/fp-indexed-ls.ll b/test/CodeGen/Mips/fp-indexed-ls.ll
index 08bd6e72ae..1c4a3fdb4a 100644
--- a/test/CodeGen/Mips/fp-indexed-ls.ll
+++ b/test/CodeGen/Mips/fp-indexed-ls.ll
@@ -28,7 +28,7 @@ entry:
define float @foo2(i32 %b, i32 %c) nounwind readonly {
entry:
-; CHECK: luxc1
+; CHECK-NOT: luxc1
%arrayidx1 = getelementptr inbounds [4 x %struct.S]* @s, i32 0, i32 %b, i32 0, i32 %c
%0 = load float* %arrayidx1, align 1
ret float %0
@@ -54,7 +54,7 @@ entry:
define void @foo5(i32 %b, i32 %c) nounwind {
entry:
-; CHECK: suxc1
+; CHECK-NOT: suxc1
%0 = load float* @gf, align 4
%arrayidx1 = getelementptr inbounds [4 x %struct.S]* @s, i32 0, i32 %b, i32 0, i32 %c
store float %0, float* %arrayidx1, align 1
@@ -64,7 +64,7 @@ entry:
define double @foo6(i32 %b, i32 %c) nounwind readonly {
entry:
; CHECK: foo6
-; CHECK-NOT: ldxc1
+; CHECK-NOT: luxc1
%arrayidx1 = getelementptr inbounds [4 x %struct.S2]* @s2, i32 0, i32 %b, i32 0, i32 %c
%0 = load double* %arrayidx1, align 1
ret double %0
@@ -73,7 +73,7 @@ entry:
define void @foo7(i32 %b, i32 %c) nounwind {
entry:
; CHECK: foo7
-; CHECK-NOT: sdxc1
+; CHECK-NOT: suxc1
%0 = load double* @gd, align 8
%arrayidx1 = getelementptr inbounds [4 x %struct.S2]* @s2, i32 0, i32 %b, i32 0, i32 %c
store double %0, double* %arrayidx1, align 1
@@ -83,7 +83,7 @@ entry:
define float @foo8() nounwind readonly {
entry:
; CHECK: foo8
-; CHECK: luxc1
+; CHECK-NOT: luxc1
%0 = load float* getelementptr inbounds (%struct.S3* @s3, i32 0, i32 1), align 1
ret float %0
}
@@ -91,7 +91,7 @@ entry:
define void @foo9(float %f) nounwind {
entry:
; CHECK: foo9
-; CHECK: suxc1
+; CHECK-NOT: suxc1
store float %f, float* getelementptr inbounds (%struct.S3* @s3, i32 0, i32 1), align 1
ret void
}
diff --git a/test/CodeGen/Mips/helloworld.ll b/test/CodeGen/Mips/helloworld.ll
new file mode 100644
index 0000000000..bee93accd4
--- /dev/null
+++ b/test/CodeGen/Mips/helloworld.ll
@@ -0,0 +1,34 @@
+; RUN: llc -march=mipsel -mcpu=mips16 -relocation-model=pic -O3 < %s | FileCheck %s -check-prefix=C1
+; RUN: llc -march=mipsel -mcpu=mips16 -relocation-model=pic -O3 < %s | FileCheck %s -check-prefix=C2
+; RUN: llc -march=mipsel -mcpu=mips16 -relocation-model=pic -O3 < %s | FileCheck %s -check-prefix=PE
+;
+; re-enable this when mips16's jalr is fixed.
+; DISABLED: llc -march=mipsel -mcpu=mips16 -relocation-model=pic -O3 < %s | FileCheck %s -check-prefix=SR
+
+
+@.str = private unnamed_addr constant [13 x i8] c"hello world\0A\00", align 1
+
+define i32 @main() nounwind {
+entry:
+ %call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([13 x i8]* @.str, i32 0, i32 0))
+ ret i32 0
+
+; SR: .set mips16 # @main
+
+; SR: save $ra, [[FS:[0-9]+]]
+; PE: li $[[T1:[0-9]+]], %hi(_gp_disp)
+; PE: addiu $[[T2:[0-9]+]], $pc, %lo(_gp_disp)
+; PE: sll $[[T3:[0-9]+]], $[[T1]], 16
+; C1: lw ${{[0-9]+}}, %got($.str)(${{[0-9]+}})
+; C2: lw ${{[0-9]+}}, %call16(printf)(${{[0-9]+}})
+; C1: addiu ${{[0-9]+}}, %lo($.str)
+; C2: move $25, ${{[0-9]+}}
+; C1: move $gp, ${{[0-9]+}}
+; C1: jalr ${{[0-9]+}}
+; SR: restore $ra, [[FS]]
+; PE: li $2, 0
+; PE: jr $ra
+
+}
+
+declare i32 @printf(i8*, ...)
diff --git a/test/CodeGen/Mips/i64arg.ll b/test/CodeGen/Mips/i64arg.ll
index e33021f880..8b1f71b69f 100644
--- a/test/CodeGen/Mips/i64arg.ll
+++ b/test/CodeGen/Mips/i64arg.ll
@@ -10,8 +10,8 @@ entry:
; CHECK: jalr
tail call void @ff1(i32 %i, i64 1085102592623924856) nounwind
; CHECK: lw $25, %call16(ff2)
-; CHECK: lw $[[R2:[0-9]+]], 88($sp)
-; CHECK: lw $[[R3:[0-9]+]], 92($sp)
+; CHECK: lw $[[R2:[0-9]+]], 80($sp)
+; CHECK: lw $[[R3:[0-9]+]], 84($sp)
; CHECK: addu $4, $zero, $[[R2]]
; CHECK: addu $5, $zero, $[[R3]]
; CHECK: jalr $25
diff --git a/test/CodeGen/Mips/inlineasm-operand-code.ll b/test/CodeGen/Mips/inlineasm-operand-code.ll
index d75f7f2f80..01978994b2 100644
--- a/test/CodeGen/Mips/inlineasm-operand-code.ll
+++ b/test/CodeGen/Mips/inlineasm-operand-code.ll
@@ -1,51 +1,153 @@
; Positive test for inline register constraints
;
-; RUN: llc -march=mipsel < %s | FileCheck %s
+; RUN: llc -march=mipsel < %s | FileCheck -check-prefix=CHECK_LITTLE_32 %s
+; RUN: llc -march=mips < %s | FileCheck -check-prefix=CHECK_BIG_32 %s
-define i32 @main() nounwind {
-entry:
+%union.u_tag = type { i64 }
+%struct.anon = type { i32, i32 }
+@uval = common global %union.u_tag zeroinitializer, align 8
; X with -3
-;CHECK: #APP
-;CHECK: addi ${{[0-9]+}},${{[0-9]+}},0xfffffffffffffffd
-;CHECK: #NO_APP
- tail call i32 asm sideeffect "addi $0,$1,${2:X}", "=r,r,I"(i32 7, i32 -3) nounwind
+define i32 @constraint_X() nounwind {
+entry:
+;CHECK_LITTLE_32: constraint_X:
+;CHECK_LITTLE_32: #APP
+;CHECK_LITTLE_32: addi ${{[0-9]+}},${{[0-9]+}},0xfffffffffffffffd
+;CHECK_LITTLE_32: #NO_APP
+ tail call i32 asm sideeffect "addi $0,$1,${2:X}", "=r,r,I"(i32 7, i32 -3) ;
+ ret i32 0
+}
; x with -3
-;CHECK: #APP
-;CHECK: addi ${{[0-9]+}},${{[0-9]+}},0xfffd
-;CHECK: #NO_APP
- tail call i32 asm sideeffect "addi $0,$1,${2:x}", "=r,r,I"(i32 7, i32 -3) nounwind
+define i32 @constraint_x() nounwind {
+entry:
+;CHECK_LITTLE_32: constraint_x:
+;CHECK_LITTLE_32: #APP
+;CHECK_LITTLE_32: addi ${{[0-9]+}},${{[0-9]+}},0xfffd
+;CHECK_LITTLE_32: #NO_APP
+ tail call i32 asm sideeffect "addi $0,$1,${2:x}", "=r,r,I"(i32 7, i32 -3) ;
+ ret i32 0
+}
; d with -3
-;CHECK: #APP
-;CHECK: addi ${{[0-9]+}},${{[0-9]+}},-3
-;CHECK: #NO_APP
- tail call i32 asm sideeffect "addi $0,$1,${2:d}", "=r,r,I"(i32 7, i32 -3) nounwind
+define i32 @constraint_d() nounwind {
+entry:
+;CHECK_LITTLE_32: constraint_d:
+;CHECK_LITTLE_32: #APP
+;CHECK_LITTLE_32: addi ${{[0-9]+}},${{[0-9]+}},-3
+;CHECK_LITTLE_32: #NO_APP
+ tail call i32 asm sideeffect "addi $0,$1,${2:d}", "=r,r,I"(i32 7, i32 -3) ;
+ ret i32 0
+}
; m with -3
-;CHECK: #APP
-;CHECK: addi ${{[0-9]+}},${{[0-9]+}},-4
-;CHECK: #NO_APP
- tail call i32 asm sideeffect "addi $0,$1,${2:m}", "=r,r,I"(i32 7, i32 -3) nounwind
+define i32 @constraint_m() nounwind {
+entry:
+;CHECK_LITTLE_32: constraint_m:
+;CHECK_LITTLE_32: #APP
+;CHECK_LITTLE_32: addi ${{[0-9]+}},${{[0-9]+}},-4
+;CHECK_LITTLE_32: #NO_APP
+ tail call i32 asm sideeffect "addi $0,$1,${2:m}", "=r,r,I"(i32 7, i32 -3) ;
+ ret i32 0
+}
; z with -3
-;CHECK: #APP
-;CHECK: addi ${{[0-9]+}},${{[0-9]+}},-3
-;CHECK: #NO_APP
- tail call i32 asm sideeffect "addi $0,$1,${2:z}", "=r,r,I"(i32 7, i32 -3) nounwind
+define i32 @constraint_z() nounwind {
+entry:
+;CHECK_LITTLE_32: constraint_z:
+;CHECK_LITTLE_32: #APP
+;CHECK_LITTLE_32: addi ${{[0-9]+}},${{[0-9]+}},-3
+;CHECK_LITTLE_32: #NO_APP
+ tail call i32 asm sideeffect "addi $0,$1,${2:z}", "=r,r,I"(i32 7, i32 -3) ;
; z with 0
-;CHECK: #APP
-;CHECK: addi ${{[0-9]+}},${{[0-9]+}},$0
-;CHECK: #NO_APP
+;CHECK_LITTLE_32: #APP
+;CHECK_LITTLE_32: addi ${{[0-9]+}},${{[0-9]+}},$0
+;CHECK_LITTLE_32: #NO_APP
tail call i32 asm sideeffect "addi $0,$1,${2:z}", "=r,r,I"(i32 7, i32 0) nounwind
+ ret i32 0
+}
; a long long in 32 bit mode (use to assert)
-;CHECK: #APP
-;CHECK: addi ${{[0-9]+}},${{[0-9]+}},3
-;CHECK: #NO_APP
+define i32 @constraint_longlong() nounwind {
+entry:
+;CHECK_LITTLE_32: constraint_longlong:
+;CHECK_LITTLE_32: #APP
+;CHECK_LITTLE_32: addi ${{[0-9]+}},${{[0-9]+}},3
+;CHECK_LITTLE_32: #NO_APP
tail call i64 asm sideeffect "addi $0,$1,$2 \0A\09", "=r,r,X"(i64 1229801703532086340, i64 3) nounwind
+ ret i32 0
+}
+
+; D, in little endian the source reg will be 4 bytes into the long long
+define i32 @constraint_D() nounwind {
+entry:
+;CHECK_LITTLE_32: constraint_D:
+;CHECK_LITTLE_32: lw ${{[0-9]+}}, %got(uval)(${{[0-9,a-z]+}})
+;CHECK_LITTLE_32: lw $[[SECOND:[0-9]+]], 4(${{[0-9]+}})
+;CHECK_LITTLE_32: lw $[[FIRST:[0-9]+]], 0(${{[0-9]+}})
+;CHECK_LITTLE_32: #APP
+;CHECK_LITTLE_32: or ${{[0-9]+}},$[[SECOND]],${{[0-9]+}}
+;CHECK_LITTLE_32: #NO_APP
+
+; D, in big endian the source reg will also be 4 bytes into the long long
+;CHECK_BIG_32: constraint_D:
+;CHECK_BIG_32: lw ${{[0-9]+}}, %got(uval)(${{[0-9,a-z]+}})
+;CHECK_BIG_32: lw $[[SECOND:[0-9]+]], 4(${{[0-9]+}})
+;CHECK_BIG_32: lw $[[FIRST:[0-9]+]], 0(${{[0-9]+}})
+;CHECK_BIG_32: #APP
+;CHECK_BIG_32: or ${{[0-9]+}},$[[SECOND]],${{[0-9]+}}
+;CHECK_BIG_32: #NO_APP
+ %bosco = load i64* getelementptr inbounds (%union.u_tag* @uval, i32 0, i32 0), align 8
+ %trunc1 = trunc i64 %bosco to i32
+ tail call i32 asm sideeffect "or $0,${1:D},$2", "=r,r,r"(i64 %bosco, i32 %trunc1) nounwind
+ ret i32 0
+}
+; L, in little endian the source reg will be 0 bytes into the long long
+define i32 @constraint_L() nounwind {
+entry:
+;CHECK_LITTLE_32: constraint_L:
+;CHECK_LITTLE_32: lw ${{[0-9]+}}, %got(uval)(${{[0-9,a-z]+}})
+;CHECK_LITTLE_32: lw $[[SECOND:[0-9]+]], 4(${{[0-9]+}})
+;CHECK_LITTLE_32: lw $[[FIRST:[0-9]+]], 0(${{[0-9]+}})
+;CHECK_LITTLE_32: #APP
+;CHECK_LITTLE_32: or ${{[0-9]+}},$[[FIRST]],${{[0-9]+}}
+;CHECK_LITTLE_32: #NO_APP
+; L, in big endian the source reg will be 4 bytes into the long long
+;CHECK_BIG_32: constraint_L:
+;CHECK_BIG_32: lw ${{[0-9]+}}, %got(uval)(${{[0-9,a-z]+}})
+;CHECK_BIG_32: lw $[[SECOND:[0-9]+]], 4(${{[0-9]+}})
+;CHECK_BIG_32: lw $[[FIRST:[0-9]+]], 0(${{[0-9]+}})
+;CHECK_BIG_32: #APP
+;CHECK_BIG_32: or ${{[0-9]+}},$[[SECOND]],${{[0-9]+}}
+;CHECK_BIG_32: #NO_APP
+ %bosco = load i64* getelementptr inbounds (%union.u_tag* @uval, i32 0, i32 0), align 8
+ %trunc1 = trunc i64 %bosco to i32
+ tail call i32 asm sideeffect "or $0,${1:L},$2", "=r,r,r"(i64 %bosco, i32 %trunc1) nounwind
+ ret i32 0
+}
+
+; M, in little endian the source reg will be 4 bytes into the long long
+define i32 @constraint_M() nounwind {
+entry:
+;CHECK_LITTLE_32: constraint_M:
+;CHECK_LITTLE_32: lw ${{[0-9]+}}, %got(uval)(${{[0-9,a-z]+}})
+;CHECK_LITTLE_32: lw $[[SECOND:[0-9]+]], 4(${{[0-9]+}})
+;CHECK_LITTLE_32: lw $[[FIRST:[0-9]+]], 0(${{[0-9]+}})
+;CHECK_LITTLE_32: #APP
+;CHECK_LITTLE_32: or ${{[0-9]+}},$[[SECOND]],${{[0-9]+}}
+;CHECK_LITTLE_32: #NO_APP
+; M, in big endian the source reg will be 0 bytes into the long long
+;CHECK_BIG_32: constraint_M:
+;CHECK_BIG_32: lw ${{[0-9]+}}, %got(uval)(${{[0-9,a-z]+}})
+;CHECK_BIG_32: lw $[[SECOND:[0-9]+]], 4(${{[0-9]+}})
+;CHECK_BIG_32: lw $[[FIRST:[0-9]+]], 0(${{[0-9]+}})
+;CHECK_BIG_32: #APP
+;CHECK_BIG_32: or ${{[0-9]+}},$[[FIRST]],${{[0-9]+}}
+;CHECK_BIG_32: #NO_APP
+ %bosco = load i64* getelementptr inbounds (%union.u_tag* @uval, i32 0, i32 0), align 8
+ %trunc1 = trunc i64 %bosco to i32
+ tail call i32 asm sideeffect "or $0,${1:M},$2", "=r,r,r"(i64 %bosco, i32 %trunc1) nounwind
ret i32 0
}
diff --git a/test/CodeGen/Mips/largeimmprinting.ll b/test/CodeGen/Mips/largeimmprinting.ll
index c81cc764b4..2e548790cd 100644
--- a/test/CodeGen/Mips/largeimmprinting.ll
+++ b/test/CodeGen/Mips/largeimmprinting.ll
@@ -6,8 +6,8 @@
define void @f() nounwind {
entry:
-; CHECK: lui $at, 65534
-; CHECK: addiu $at, $at, -24
+; CHECK: lui $at, 65535
+; CHECK: addiu $at, $at, -16
; CHECK: addu $sp, $sp, $at
%agg.tmp = alloca %struct.S1, align 1
diff --git a/test/CodeGen/Mips/lb1.ll b/test/CodeGen/Mips/lb1.ll
new file mode 100644
index 0000000000..aac2767a4e
--- /dev/null
+++ b/test/CodeGen/Mips/lb1.ll
@@ -0,0 +1,18 @@
+; RUN: llc -march=mipsel -mcpu=mips16 -relocation-model=pic -O3 < %s | FileCheck %s -check-prefix=16
+
+@c = global i8 -1, align 1
+@.str = private unnamed_addr constant [5 x i8] c"%i \0A\00", align 1
+
+define i32 @main() nounwind {
+entry:
+ %i = alloca i32, align 4
+ %0 = load i8* @c, align 1
+; 16: lb ${{[0-9]+}}, 0(${{[0-9]+}})
+ %conv = sext i8 %0 to i32
+ store i32 %conv, i32* %i, align 4
+ %1 = load i32* %i, align 4
+ %call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([5 x i8]* @.str, i32 0, i32 0), i32 %1)
+ ret i32 0
+}
+
+declare i32 @printf(i8*, ...)
diff --git a/test/CodeGen/Mips/lbu1.ll b/test/CodeGen/Mips/lbu1.ll
new file mode 100644
index 0000000000..63e0cca168
--- /dev/null
+++ b/test/CodeGen/Mips/lbu1.ll
@@ -0,0 +1,19 @@
+; RUN: llc -march=mipsel -mcpu=mips16 -relocation-model=pic -O3 < %s | FileCheck %s -check-prefix=16
+
+@c = global i8 97, align 1
+@.str = private unnamed_addr constant [5 x i8] c"%c \0A\00", align 1
+
+define i32 @main() nounwind {
+entry:
+ %i = alloca i32, align 4
+ %0 = load i8* @c, align 1
+ %conv = zext i8 %0 to i32
+; 16: lbu ${{[0-9]+}}, 0(${{[0-9]+}})
+ store i32 %conv, i32* %i, align 4
+ %1 = load i8* @c, align 1
+ %conv1 = zext i8 %1 to i32
+ %call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([5 x i8]* @.str, i32 0, i32 0), i32 %conv1)
+ ret i32 0
+}
+
+declare i32 @printf(i8*, ...)
diff --git a/test/CodeGen/Mips/lh1.ll b/test/CodeGen/Mips/lh1.ll
new file mode 100644
index 0000000000..1f95b09034
--- /dev/null
+++ b/test/CodeGen/Mips/lh1.ll
@@ -0,0 +1,18 @@
+; RUN: llc -march=mipsel -mcpu=mips16 -relocation-model=pic -O3 < %s | FileCheck %s -check-prefix=16
+
+@s = global i16 -1, align 2
+@.str = private unnamed_addr constant [5 x i8] c"%i \0A\00", align 1
+
+define i32 @main() nounwind {
+entry:
+ %i = alloca i32, align 4
+ %0 = load i16* @s, align 2
+ %conv = sext i16 %0 to i32
+; 16: lh ${{[0-9]+}}, 0(${{[0-9]+}})
+ store i32 %conv, i32* %i, align 4
+ %1 = load i32* %i, align 4
+ %call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([5 x i8]* @.str, i32 0, i32 0), i32 %1)
+ ret i32 0
+}
+
+declare i32 @printf(i8*, ...)
diff --git a/test/CodeGen/Mips/lhu1.ll b/test/CodeGen/Mips/lhu1.ll
new file mode 100644
index 0000000000..0cfcede669
--- /dev/null
+++ b/test/CodeGen/Mips/lhu1.ll
@@ -0,0 +1,19 @@
+; RUN: llc -march=mipsel -mcpu=mips16 -relocation-model=pic -O3 < %s | FileCheck %s -check-prefix=16
+
+
+@s = global i16 255, align 2
+@.str = private unnamed_addr constant [5 x i8] c"%i \0A\00", align 1
+
+define i32 @main() nounwind {
+entry:
+ %i = alloca i32, align 4
+ %0 = load i16* @s, align 2
+ %conv = zext i16 %0 to i32
+; 16: lhu ${{[0-9]+}}, 0(${{[0-9]+}})
+ store i32 %conv, i32* %i, align 4
+ %1 = load i32* %i, align 4
+ %call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([5 x i8]* @.str, i32 0, i32 0), i32 %1)
+ ret i32 0
+}
+
+declare i32 @printf(i8*, ...)
diff --git a/test/CodeGen/Mips/longbranch.ll b/test/CodeGen/Mips/longbranch.ll
index ef95d0011c..0227b88fbc 100644
--- a/test/CodeGen/Mips/longbranch.ll
+++ b/test/CodeGen/Mips/longbranch.ll
@@ -1,12 +1,14 @@
-; RUN: llc -march=mipsel -force-mips-long-branch < %s | FileCheck %s
+; RUN: llc -march=mipsel -force-mips-long-branch < %s | FileCheck %s -check-prefix=O32
+; RUN: llc -march=mips64el -mcpu=mips64 -mattr=n64 -force-mips-long-branch < %s | FileCheck %s -check-prefix=N64
@g0 = external global i32
define void @foo1(i32 %s) nounwind {
entry:
-; CHECK: lw $[[R0:[a-z0-9]+]], %got($BB0_3)(${{[a-z0-9]+}})
-; CHECK: addiu $[[R1:[a-z0-9]+]], $[[R0]], %lo($BB0_3)
-; CHECK: jr $[[R1]]
+; O32: bal
+; N64: bal
+; N64: highest
+; N64: higher
%tobool = icmp eq i32 %s, 0
br i1 %tobool, label %if.end, label %if.then
diff --git a/test/CodeGen/Mips/mips64-fp-indexed-ls.ll b/test/CodeGen/Mips/mips64-fp-indexed-ls.ll
index 09745fb8f6..bbdc05cd2d 100644
--- a/test/CodeGen/Mips/mips64-fp-indexed-ls.ll
+++ b/test/CodeGen/Mips/mips64-fp-indexed-ls.ll
@@ -30,7 +30,7 @@ entry:
define float @foo2(i32 %b, i32 %c) nounwind readonly {
entry:
-; CHECK: luxc1
+; CHECK-NOT: luxc1
%idxprom = zext i32 %c to i64
%idxprom1 = zext i32 %b to i64
%arrayidx2 = getelementptr inbounds [4 x %struct.S]* @s, i64 0, i64 %idxprom1, i32 0, i64 %idxprom
@@ -60,7 +60,7 @@ entry:
define void @foo5(i32 %b, i32 %c) nounwind {
entry:
-; CHECK: suxc1
+; CHECK-NOT: suxc1
%0 = load float* @gf, align 4
%idxprom = zext i32 %c to i64
%idxprom1 = zext i32 %b to i64
@@ -72,7 +72,7 @@ entry:
define double @foo6(i32 %b, i32 %c) nounwind readonly {
entry:
; CHECK: foo6
-; CHECK-NOT: ldxc1
+; CHECK-NOT: luxc1
%idxprom = zext i32 %c to i64
%idxprom1 = zext i32 %b to i64
%arrayidx2 = getelementptr inbounds [4 x %struct.S2]* @s2, i64 0, i64 %idxprom1, i32 0, i64 %idxprom
@@ -83,7 +83,7 @@ entry:
define void @foo7(i32 %b, i32 %c) nounwind {
entry:
; CHECK: foo7
-; CHECK-NOT: sdxc1
+; CHECK-NOT: suxc1
%0 = load double* @gd, align 8
%idxprom = zext i32 %c to i64
%idxprom1 = zext i32 %b to i64
@@ -95,7 +95,7 @@ entry:
define float @foo8() nounwind readonly {
entry:
; CHECK: foo8
-; CHECK: luxc1
+; CHECK-NOT: luxc1
%0 = load float* getelementptr inbounds (%struct.S3* @s3, i64 0, i32 1), align 1
ret float %0
}
@@ -103,7 +103,7 @@ entry:
define void @foo9(float %f) nounwind {
entry:
; CHECK: foo9
-; CHECK: suxc1
+; CHECK-NOT: suxc1
store float %f, float* getelementptr inbounds (%struct.S3* @s3, i64 0, i32 1), align 1
ret void
}
diff --git a/test/CodeGen/Mips/neg1.ll b/test/CodeGen/Mips/neg1.ll
new file mode 100644
index 0000000000..281e626215
--- /dev/null
+++ b/test/CodeGen/Mips/neg1.ll
@@ -0,0 +1,15 @@
+; RUN: llc -march=mipsel -mcpu=mips16 -relocation-model=pic -O3 < %s | FileCheck %s -check-prefix=16
+
+@i = global i32 10, align 4
+@.str = private unnamed_addr constant [5 x i8] c"%i \0A\00", align 1
+
+define i32 @main() nounwind {
+entry:
+ %0 = load i32* @i, align 4
+ %sub = sub nsw i32 0, %0
+; 16: neg ${{[0-9]+}}, ${{[0-9]+}}
+ %call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([5 x i8]* @.str, i32 0, i32 0), i32 %sub)
+ ret i32 0
+}
+
+declare i32 @printf(i8*, ...)
diff --git a/test/CodeGen/Mips/not1.ll b/test/CodeGen/Mips/not1.ll
new file mode 100644
index 0000000000..2163b236c5
--- /dev/null
+++ b/test/CodeGen/Mips/not1.ll
@@ -0,0 +1,16 @@
+; RUN: llc -march=mipsel -mcpu=mips16 -relocation-model=pic -O3 < %s | FileCheck %s -check-prefix=16
+
+@x = global i32 65504, align 4
+@y = global i32 60929, align 4
+@.str = private unnamed_addr constant [7 x i8] c"%08x \0A\00", align 1
+
+define i32 @main() nounwind {
+entry:
+ %0 = load i32* @x, align 4
+ %neg = xor i32 %0, -1
+; 16: not ${{[0-9]+}}, ${{[0-9]+}}
+ %call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([7 x i8]* @.str, i32 0, i32 0), i32 %neg)
+ ret i32 0
+}
+
+declare i32 @printf(i8*, ...)
diff --git a/test/CodeGen/Mips/o32_cc_byval.ll b/test/CodeGen/Mips/o32_cc_byval.ll
index d5eac994c0..eac0d80c1c 100644
--- a/test/CodeGen/Mips/o32_cc_byval.ll
+++ b/test/CodeGen/Mips/o32_cc_byval.ll
@@ -43,16 +43,16 @@ declare void @callee3(float, %struct.S3* byval, %struct.S1* byval)
define void @f2(float %f, %struct.S1* nocapture byval %s1) nounwind {
entry:
-; CHECK: addiu $sp, $sp, -56
-; CHECK: sw $7, 68($sp)
-; CHECK: sw $6, 64($sp)
-; CHECK: lw $4, 88($sp)
-; CHECK: ldc1 $f[[F0:[0-9]+]], 80($sp)
-; CHECK: lw $[[R3:[0-9]+]], 72($sp)
-; CHECK: lw $[[R4:[0-9]+]], 76($sp)
-; CHECK: lw $[[R2:[0-9]+]], 68($sp)
-; CHECK: lh $[[R1:[0-9]+]], 66($sp)
-; CHECK: lb $[[R0:[0-9]+]], 64($sp)
+; CHECK: addiu $sp, $sp, -48
+; CHECK: sw $7, 60($sp)
+; CHECK: sw $6, 56($sp)
+; CHECK: lw $4, 80($sp)
+; CHECK: ldc1 $f[[F0:[0-9]+]], 72($sp)
+; CHECK: lw $[[R3:[0-9]+]], 64($sp)
+; CHECK: lw $[[R4:[0-9]+]], 68($sp)
+; CHECK: lw $[[R2:[0-9]+]], 60($sp)
+; CHECK: lh $[[R1:[0-9]+]], 58($sp)
+; CHECK: lb $[[R0:[0-9]+]], 56($sp)
; CHECK: sw $[[R0]], 32($sp)
; CHECK: sw $[[R1]], 28($sp)
; CHECK: sw $[[R2]], 24($sp)
@@ -80,13 +80,13 @@ declare void @callee4(i32, double, i64, i32, i16 signext, i8 signext, float)
define void @f3(%struct.S2* nocapture byval %s2) nounwind {
entry:
-; CHECK: addiu $sp, $sp, -56
-; CHECK: sw $7, 68($sp)
-; CHECK: sw $6, 64($sp)
-; CHECK: sw $5, 60($sp)
-; CHECK: sw $4, 56($sp)
-; CHECK: lw $4, 56($sp)
-; CHECK: lw $[[R0:[0-9]+]], 68($sp)
+; CHECK: addiu $sp, $sp, -48
+; CHECK: sw $7, 60($sp)
+; CHECK: sw $6, 56($sp)
+; CHECK: sw $5, 52($sp)
+; CHECK: sw $4, 48($sp)
+; CHECK: lw $4, 48($sp)
+; CHECK: lw $[[R0:[0-9]+]], 60($sp)
; CHECK: sw $[[R0]], 24($sp)
%arrayidx = getelementptr inbounds %struct.S2* %s2, i32 0, i32 0, i32 0
@@ -99,13 +99,13 @@ entry:
define void @f4(float %f, %struct.S3* nocapture byval %s3, %struct.S1* nocapture byval %s1) nounwind {
entry:
-; CHECK: addiu $sp, $sp, -56
-; CHECK: sw $7, 68($sp)
-; CHECK: sw $6, 64($sp)
-; CHECK: sw $5, 60($sp)
-; CHECK: lw $4, 68($sp)
-; CHECK: lw $[[R1:[0-9]+]], 88($sp)
-; CHECK: lb $[[R0:[0-9]+]], 60($sp)
+; CHECK: addiu $sp, $sp, -48
+; CHECK: sw $7, 60($sp)
+; CHECK: sw $6, 56($sp)
+; CHECK: sw $5, 52($sp)
+; CHECK: lw $4, 60($sp)
+; CHECK: lw $[[R1:[0-9]+]], 80($sp)
+; CHECK: lb $[[R0:[0-9]+]], 52($sp)
; CHECK: sw $[[R0]], 32($sp)
; CHECK: sw $[[R1]], 24($sp)
diff --git a/test/CodeGen/Mips/o32_cc_vararg.ll b/test/CodeGen/Mips/o32_cc_vararg.ll
index 49d614c820..35332b6550 100644
--- a/test/CodeGen/Mips/o32_cc_vararg.ll
+++ b/test/CodeGen/Mips/o32_cc_vararg.ll
@@ -1,6 +1,5 @@
; RUN: llc -march=mipsel -pre-RA-sched=source < %s | FileCheck %s
-
; All test functions do the same thing - they return the first variable
; argument.
@@ -29,11 +28,11 @@ entry:
ret i32 %tmp
; CHECK: va1:
-; CHECK: addiu $sp, $sp, -24
-; CHECK: sw $7, 36($sp)
-; CHECK: sw $6, 32($sp)
-; CHECK: sw $5, 28($sp)
-; CHECK: lw $2, 28($sp)
+; CHECK: addiu $sp, $sp, -16
+; CHECK: sw $7, 28($sp)
+; CHECK: sw $6, 24($sp)
+; CHECK: sw $5, 20($sp)
+; CHECK: lw $2, 20($sp)
}
; check whether the variable double argument will be accessed from the 8-byte
@@ -55,11 +54,11 @@ entry:
ret double %tmp
; CHECK: va2:
-; CHECK: addiu $sp, $sp, -24
-; CHECK: sw $7, 36($sp)
-; CHECK: sw $6, 32($sp)
-; CHECK: sw $5, 28($sp)
-; CHECK: addiu $[[R0:[0-9]+]], $sp, 28
+; CHECK: addiu $sp, $sp, -16
+; CHECK: sw $7, 28($sp)
+; CHECK: sw $6, 24($sp)
+; CHECK: sw $5, 20($sp)
+; CHECK: addiu $[[R0:[0-9]+]], $sp, 20
; CHECK: addiu $[[R1:[0-9]+]], $[[R0]], 7
; CHECK: addiu $[[R2:[0-9]+]], $zero, -8
; CHECK: and $[[R3:[0-9]+]], $[[R1]], $[[R2]]
@@ -83,10 +82,10 @@ entry:
ret i32 %tmp
; CHECK: va3:
-; CHECK: addiu $sp, $sp, -24
-; CHECK: sw $7, 36($sp)
-; CHECK: sw $6, 32($sp)
-; CHECK: lw $2, 32($sp)
+; CHECK: addiu $sp, $sp, -16
+; CHECK: sw $7, 28($sp)
+; CHECK: sw $6, 24($sp)
+; CHECK: lw $2, 24($sp)
}
; double
@@ -106,11 +105,11 @@ entry:
ret double %tmp
; CHECK: va4:
-; CHECK: addiu $sp, $sp, -32
-; CHECK: sw $7, 44($sp)
-; CHECK: sw $6, 40($sp)
-; CHECK: addiu ${{[0-9]+}}, $sp, 40
-; CHECK: ldc1 $f0, 40($sp)
+; CHECK: addiu $sp, $sp, -24
+; CHECK: sw $7, 36($sp)
+; CHECK: sw $6, 32($sp)
+; CHECK: addiu ${{[0-9]+}}, $sp, 32
+; CHECK: ldc1 $f0, 32($sp)
}
; int
@@ -134,9 +133,9 @@ entry:
ret i32 %tmp
; CHECK: va5:
-; CHECK: addiu $sp, $sp, -32
-; CHECK: sw $7, 44($sp)
-; CHECK: lw $2, 44($sp)
+; CHECK: addiu $sp, $sp, -24
+; CHECK: sw $7, 36($sp)
+; CHECK: lw $2, 36($sp)
}
; double
@@ -160,9 +159,9 @@ entry:
ret double %tmp
; CHECK: va6:
-; CHECK: addiu $sp, $sp, -32
-; CHECK: sw $7, 44($sp)
-; CHECK: addiu $[[R0:[0-9]+]], $sp, 44
+; CHECK: addiu $sp, $sp, -24
+; CHECK: sw $7, 36($sp)
+; CHECK: addiu $[[R0:[0-9]+]], $sp, 36
; CHECK: addiu $[[R1:[0-9]+]], $[[R0]], 7
; CHECK: addiu $[[R2:[0-9]+]], $zero, -8
; CHECK: and $[[R3:[0-9]+]], $[[R1]], $[[R2]]
@@ -188,8 +187,8 @@ entry:
ret i32 %tmp
; CHECK: va7:
-; CHECK: addiu $sp, $sp, -32
-; CHECK: lw $2, 48($sp)
+; CHECK: addiu $sp, $sp, -24
+; CHECK: lw $2, 40($sp)
}
; double
@@ -211,9 +210,9 @@ entry:
ret double %tmp
; CHECK: va8:
-; CHECK: addiu $sp, $sp, -40
-; CHECK: addiu ${{[0-9]+}}, $sp, 56
-; CHECK: ldc1 $f0, 56($sp)
+; CHECK: addiu $sp, $sp, -32
+; CHECK: addiu ${{[0-9]+}}, $sp, 48
+; CHECK: ldc1 $f0, 48($sp)
}
; int
@@ -237,8 +236,8 @@ entry:
ret i32 %tmp
; CHECK: va9:
-; CHECK: addiu $sp, $sp, -40
-; CHECK: lw $2, 60($sp)
+; CHECK: addiu $sp, $sp, -32
+; CHECK: lw $2, 52($sp)
}
; double
@@ -262,8 +261,8 @@ entry:
ret double %tmp
; CHECK: va10:
-; CHECK: addiu $sp, $sp, -40
-; CHECK: addiu $[[R0:[0-9]+]], $sp, 60
+; CHECK: addiu $sp, $sp, -32
+; CHECK: addiu $[[R0:[0-9]+]], $sp, 52
; CHECK: addiu $[[R1:[0-9]+]], $[[R0]], 7
; CHECK: addiu $[[R2:[0-9]+]], $zero, -8
; CHECK: and $[[R3:[0-9]+]], $[[R1]], $[[R2]]
diff --git a/test/CodeGen/Mips/or1.ll b/test/CodeGen/Mips/or1.ll
new file mode 100644
index 0000000000..b1c36961f9
--- /dev/null
+++ b/test/CodeGen/Mips/or1.ll
@@ -0,0 +1,17 @@
+; RUN: llc -march=mipsel -mcpu=mips16 -relocation-model=pic -O3 < %s | FileCheck %s -check-prefix=16
+
+@x = global i32 65504, align 4
+@y = global i32 60929, align 4
+@.str = private unnamed_addr constant [7 x i8] c"%08x \0A\00", align 1
+
+define i32 @main() nounwind {
+entry:
+ %0 = load i32* @x, align 4
+ %1 = load i32* @y, align 4
+ %or = or i32 %0, %1
+; 16: or ${{[0-9]+}}, ${{[0-9]+}}
+ %call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([7 x i8]* @.str, i32 0, i32 0), i32 %or)
+ ret i32 0
+}
+
+declare i32 @printf(i8*, ...)
diff --git a/test/CodeGen/Mips/ra-allocatable.ll b/test/CodeGen/Mips/ra-allocatable.ll
new file mode 100644
index 0000000000..7621788682
--- /dev/null
+++ b/test/CodeGen/Mips/ra-allocatable.ll
@@ -0,0 +1,288 @@
+; RUN: llc < %s -march=mipsel | FileCheck %s
+
+@a0 = external global i32
+@b0 = external global i32*
+@a1 = external global i32
+@b1 = external global i32*
+@a2 = external global i32
+@b2 = external global i32*
+@a3 = external global i32
+@b3 = external global i32*
+@a4 = external global i32
+@b4 = external global i32*
+@a5 = external global i32
+@b5 = external global i32*
+@a6 = external global i32
+@b6 = external global i32*
+@a7 = external global i32
+@b7 = external global i32*
+@a8 = external global i32
+@b8 = external global i32*
+@a9 = external global i32
+@b9 = external global i32*
+@a10 = external global i32
+@b10 = external global i32*
+@a11 = external global i32
+@b11 = external global i32*
+@a12 = external global i32
+@b12 = external global i32*
+@a13 = external global i32
+@b13 = external global i32*
+@a14 = external global i32
+@b14 = external global i32*
+@a15 = external global i32
+@b15 = external global i32*
+@a16 = external global i32
+@b16 = external global i32*
+@a17 = external global i32
+@b17 = external global i32*
+@a18 = external global i32
+@b18 = external global i32*
+@a19 = external global i32
+@b19 = external global i32*
+@a20 = external global i32
+@b20 = external global i32*
+@a21 = external global i32
+@b21 = external global i32*
+@a22 = external global i32
+@b22 = external global i32*
+@a23 = external global i32
+@b23 = external global i32*
+@a24 = external global i32
+@b24 = external global i32*
+@a25 = external global i32
+@b25 = external global i32*
+@a26 = external global i32
+@b26 = external global i32*
+@a27 = external global i32
+@b27 = external global i32*
+@a28 = external global i32
+@b28 = external global i32*
+@a29 = external global i32
+@b29 = external global i32*
+@c0 = external global i32*
+@c1 = external global i32*
+@c2 = external global i32*
+@c3 = external global i32*
+@c4 = external global i32*
+@c5 = external global i32*
+@c6 = external global i32*
+@c7 = external global i32*
+@c8 = external global i32*
+@c9 = external global i32*
+@c10 = external global i32*
+@c11 = external global i32*
+@c12 = external global i32*
+@c13 = external global i32*
+@c14 = external global i32*
+@c15 = external global i32*
+@c16 = external global i32*
+@c17 = external global i32*
+@c18 = external global i32*
+@c19 = external global i32*
+@c20 = external global i32*
+@c21 = external global i32*
+@c22 = external global i32*
+@c23 = external global i32*
+@c24 = external global i32*
+@c25 = external global i32*
+@c26 = external global i32*
+@c27 = external global i32*
+@c28 = external global i32*
+@c29 = external global i32*
+
+define i32 @f1() nounwind {
+entry:
+; CHECK: sw $ra, {{[0-9]+}}($sp) # 4-byte Folded Spill
+; CHECK: $ra
+; CHECK: lw $ra, {{[0-9]+}}($sp) # 4-byte Folded Reload
+; CHECK: jr $ra
+
+ %0 = load i32* @a0, align 4, !tbaa !0
+ %1 = load i32** @b0, align 4, !tbaa !3
+ store i32 %0, i32* %1, align 4, !tbaa !0
+ %2 = load i32* @a1, align 4, !tbaa !0
+ %3 = load i32** @b1, align 4, !tbaa !3
+ store i32 %2, i32* %3, align 4, !tbaa !0
+ %4 = load i32* @a2, align 4, !tbaa !0
+ %5 = load i32** @b2, align 4, !tbaa !3
+ store i32 %4, i32* %5, align 4, !tbaa !0
+ %6 = load i32* @a3, align 4, !tbaa !0
+ %7 = load i32** @b3, align 4, !tbaa !3
+ store i32 %6, i32* %7, align 4, !tbaa !0
+ %8 = load i32* @a4, align 4, !tbaa !0
+ %9 = load i32** @b4, align 4, !tbaa !3
+ store i32 %8, i32* %9, align 4, !tbaa !0
+ %10 = load i32* @a5, align 4, !tbaa !0
+ %11 = load i32** @b5, align 4, !tbaa !3
+ store i32 %10, i32* %11, align 4, !tbaa !0
+ %12 = load i32* @a6, align 4, !tbaa !0
+ %13 = load i32** @b6, align 4, !tbaa !3
+ store i32 %12, i32* %13, align 4, !tbaa !0
+ %14 = load i32* @a7, align 4, !tbaa !0
+ %15 = load i32** @b7, align 4, !tbaa !3
+ store i32 %14, i32* %15, align 4, !tbaa !0
+ %16 = load i32* @a8, align 4, !tbaa !0
+ %17 = load i32** @b8, align 4, !tbaa !3
+ store i32 %16, i32* %17, align 4, !tbaa !0
+ %18 = load i32* @a9, align 4, !tbaa !0
+ %19 = load i32** @b9, align 4, !tbaa !3
+ store i32 %18, i32* %19, align 4, !tbaa !0
+ %20 = load i32* @a10, align 4, !tbaa !0
+ %21 = load i32** @b10, align 4, !tbaa !3
+ store i32 %20, i32* %21, align 4, !tbaa !0
+ %22 = load i32* @a11, align 4, !tbaa !0
+ %23 = load i32** @b11, align 4, !tbaa !3
+ store i32 %22, i32* %23, align 4, !tbaa !0
+ %24 = load i32* @a12, align 4, !tbaa !0
+ %25 = load i32** @b12, align 4, !tbaa !3
+ store i32 %24, i32* %25, align 4, !tbaa !0
+ %26 = load i32* @a13, align 4, !tbaa !0
+ %27 = load i32** @b13, align 4, !tbaa !3
+ store i32 %26, i32* %27, align 4, !tbaa !0
+ %28 = load i32* @a14, align 4, !tbaa !0
+ %29 = load i32** @b14, align 4, !tbaa !3
+ store i32 %28, i32* %29, align 4, !tbaa !0
+ %30 = load i32* @a15, align 4, !tbaa !0
+ %31 = load i32** @b15, align 4, !tbaa !3
+ store i32 %30, i32* %31, align 4, !tbaa !0
+ %32 = load i32* @a16, align 4, !tbaa !0
+ %33 = load i32** @b16, align 4, !tbaa !3
+ store i32 %32, i32* %33, align 4, !tbaa !0
+ %34 = load i32* @a17, align 4, !tbaa !0
+ %35 = load i32** @b17, align 4, !tbaa !3
+ store i32 %34, i32* %35, align 4, !tbaa !0
+ %36 = load i32* @a18, align 4, !tbaa !0
+ %37 = load i32** @b18, align 4, !tbaa !3
+ store i32 %36, i32* %37, align 4, !tbaa !0
+ %38 = load i32* @a19, align 4, !tbaa !0
+ %39 = load i32** @b19, align 4, !tbaa !3
+ store i32 %38, i32* %39, align 4, !tbaa !0
+ %40 = load i32* @a20, align 4, !tbaa !0
+ %41 = load i32** @b20, align 4, !tbaa !3
+ store i32 %40, i32* %41, align 4, !tbaa !0
+ %42 = load i32* @a21, align 4, !tbaa !0
+ %43 = load i32** @b21, align 4, !tbaa !3
+ store i32 %42, i32* %43, align 4, !tbaa !0
+ %44 = load i32* @a22, align 4, !tbaa !0
+ %45 = load i32** @b22, align 4, !tbaa !3
+ store i32 %44, i32* %45, align 4, !tbaa !0
+ %46 = load i32* @a23, align 4, !tbaa !0
+ %47 = load i32** @b23, align 4, !tbaa !3
+ store i32 %46, i32* %47, align 4, !tbaa !0
+ %48 = load i32* @a24, align 4, !tbaa !0
+ %49 = load i32** @b24, align 4, !tbaa !3
+ store i32 %48, i32* %49, align 4, !tbaa !0
+ %50 = load i32* @a25, align 4, !tbaa !0
+ %51 = load i32** @b25, align 4, !tbaa !3
+ store i32 %50, i32* %51, align 4, !tbaa !0
+ %52 = load i32* @a26, align 4, !tbaa !0
+ %53 = load i32** @b26, align 4, !tbaa !3
+ store i32 %52, i32* %53, align 4, !tbaa !0
+ %54 = load i32* @a27, align 4, !tbaa !0
+ %55 = load i32** @b27, align 4, !tbaa !3
+ store i32 %54, i32* %55, align 4, !tbaa !0
+ %56 = load i32* @a28, align 4, !tbaa !0
+ %57 = load i32** @b28, align 4, !tbaa !3
+ store i32 %56, i32* %57, align 4, !tbaa !0
+ %58 = load i32* @a29, align 4, !tbaa !0
+ %59 = load i32** @b29, align 4, !tbaa !3
+ store i32 %58, i32* %59, align 4, !tbaa !0
+ %60 = load i32* @a0, align 4, !tbaa !0
+ %61 = load i32** @c0, align 4, !tbaa !3
+ store i32 %60, i32* %61, align 4, !tbaa !0
+ %62 = load i32* @a1, align 4, !tbaa !0
+ %63 = load i32** @c1, align 4, !tbaa !3
+ store i32 %62, i32* %63, align 4, !tbaa !0
+ %64 = load i32* @a2, align 4, !tbaa !0
+ %65 = load i32** @c2, align 4, !tbaa !3
+ store i32 %64, i32* %65, align 4, !tbaa !0
+ %66 = load i32* @a3, align 4, !tbaa !0
+ %67 = load i32** @c3, align 4, !tbaa !3
+ store i32 %66, i32* %67, align 4, !tbaa !0
+ %68 = load i32* @a4, align 4, !tbaa !0
+ %69 = load i32** @c4, align 4, !tbaa !3
+ store i32 %68, i32* %69, align 4, !tbaa !0
+ %70 = load i32* @a5, align 4, !tbaa !0
+ %71 = load i32** @c5, align 4, !tbaa !3
+ store i32 %70, i32* %71, align 4, !tbaa !0
+ %72 = load i32* @a6, align 4, !tbaa !0
+ %73 = load i32** @c6, align 4, !tbaa !3
+ store i32 %72, i32* %73, align 4, !tbaa !0
+ %74 = load i32* @a7, align 4, !tbaa !0
+ %75 = load i32** @c7, align 4, !tbaa !3
+ store i32 %74, i32* %75, align 4, !tbaa !0
+ %76 = load i32* @a8, align 4, !tbaa !0
+ %77 = load i32** @c8, align 4, !tbaa !3
+ store i32 %76, i32* %77, align 4, !tbaa !0
+ %78 = load i32* @a9, align 4, !tbaa !0
+ %79 = load i32** @c9, align 4, !tbaa !3
+ store i32 %78, i32* %79, align 4, !tbaa !0
+ %80 = load i32* @a10, align 4, !tbaa !0
+ %81 = load i32** @c10, align 4, !tbaa !3
+ store i32 %80, i32* %81, align 4, !tbaa !0
+ %82 = load i32* @a11, align 4, !tbaa !0
+ %83 = load i32** @c11, align 4, !tbaa !3
+ store i32 %82, i32* %83, align 4, !tbaa !0
+ %84 = load i32* @a12, align 4, !tbaa !0
+ %85 = load i32** @c12, align 4, !tbaa !3
+ store i32 %84, i32* %85, align 4, !tbaa !0
+ %86 = load i32* @a13, align 4, !tbaa !0
+ %87 = load i32** @c13, align 4, !tbaa !3
+ store i32 %86, i32* %87, align 4, !tbaa !0
+ %88 = load i32* @a14, align 4, !tbaa !0
+ %89 = load i32** @c14, align 4, !tbaa !3
+ store i32 %88, i32* %89, align 4, !tbaa !0
+ %90 = load i32* @a15, align 4, !tbaa !0
+ %91 = load i32** @c15, align 4, !tbaa !3
+ store i32 %90, i32* %91, align 4, !tbaa !0
+ %92 = load i32* @a16, align 4, !tbaa !0
+ %93 = load i32** @c16, align 4, !tbaa !3
+ store i32 %92, i32* %93, align 4, !tbaa !0
+ %94 = load i32* @a17, align 4, !tbaa !0
+ %95 = load i32** @c17, align 4, !tbaa !3
+ store i32 %94, i32* %95, align 4, !tbaa !0
+ %96 = load i32* @a18, align 4, !tbaa !0
+ %97 = load i32** @c18, align 4, !tbaa !3
+ store i32 %96, i32* %97, align 4, !tbaa !0
+ %98 = load i32* @a19, align 4, !tbaa !0
+ %99 = load i32** @c19, align 4, !tbaa !3
+ store i32 %98, i32* %99, align 4, !tbaa !0
+ %100 = load i32* @a20, align 4, !tbaa !0
+ %101 = load i32** @c20, align 4, !tbaa !3
+ store i32 %100, i32* %101, align 4, !tbaa !0
+ %102 = load i32* @a21, align 4, !tbaa !0
+ %103 = load i32** @c21, align 4, !tbaa !3
+ store i32 %102, i32* %103, align 4, !tbaa !0
+ %104 = load i32* @a22, align 4, !tbaa !0
+ %105 = load i32** @c22, align 4, !tbaa !3
+ store i32 %104, i32* %105, align 4, !tbaa !0
+ %106 = load i32* @a23, align 4, !tbaa !0
+ %107 = load i32** @c23, align 4, !tbaa !3
+ store i32 %106, i32* %107, align 4, !tbaa !0
+ %108 = load i32* @a24, align 4, !tbaa !0
+ %109 = load i32** @c24, align 4, !tbaa !3
+ store i32 %108, i32* %109, align 4, !tbaa !0
+ %110 = load i32* @a25, align 4, !tbaa !0
+ %111 = load i32** @c25, align 4, !tbaa !3
+ store i32 %110, i32* %111, align 4, !tbaa !0
+ %112 = load i32* @a26, align 4, !tbaa !0
+ %113 = load i32** @c26, align 4, !tbaa !3
+ store i32 %112, i32* %113, align 4, !tbaa !0
+ %114 = load i32* @a27, align 4, !tbaa !0
+ %115 = load i32** @c27, align 4, !tbaa !3
+ store i32 %114, i32* %115, align 4, !tbaa !0
+ %116 = load i32* @a28, align 4, !tbaa !0
+ %117 = load i32** @c28, align 4, !tbaa !3
+ store i32 %116, i32* %117, align 4, !tbaa !0
+ %118 = load i32* @a29, align 4, !tbaa !0
+ %119 = load i32** @c29, align 4, !tbaa !3
+ store i32 %118, i32* %119, align 4, !tbaa !0
+ %120 = load i32* @a0, align 4, !tbaa !0
+ ret i32 %120
+}
+
+!0 = metadata !{metadata !"int", metadata !1}
+!1 = metadata !{metadata !"omnipotent char", metadata !2}
+!2 = metadata !{metadata !"Simple C/C++ TBAA"}
+!3 = metadata !{metadata !"any pointer", metadata !1}
diff --git a/test/CodeGen/Mips/rdhwr-directives.ll b/test/CodeGen/Mips/rdhwr-directives.ll
new file mode 100644
index 0000000000..27010d4d36
--- /dev/null
+++ b/test/CodeGen/Mips/rdhwr-directives.ll
@@ -0,0 +1,15 @@
+; RUN: llc -march=mipsel -mcpu=mips32 -relocation-model=static < %s | FileCheck %s
+
+@a = external thread_local global i32
+
+define i32 @foo() nounwind readonly {
+entry:
+; CHECK: .set push
+; CHECK: .set mips32r2
+; CHECK: rdhwr
+; CHECK: .set pop
+
+ %0 = load i32* @a, align 4
+ ret i32 %0
+}
+
diff --git a/test/CodeGen/Mips/return-vector-float4.ll b/test/CodeGen/Mips/return-vector-float4.ll
new file mode 100644
index 0000000000..ae10f123e4
--- /dev/null
+++ b/test/CodeGen/Mips/return-vector-float4.ll
@@ -0,0 +1,12 @@
+; RUN: llc -march=mipsel -mattr=+android < %s | FileCheck %s
+
+define <4 x float> @retvec4() nounwind readnone {
+entry:
+; CHECK: lwc1 $f0
+; CHECK: lwc1 $f2
+; CHECK: lwc1 $f1
+; CHECK: lwc1 $f3
+
+ ret <4 x float> <float 1.000000e+00, float 2.000000e+00, float 3.000000e+00, float 4.000000e+00>
+}
+
diff --git a/test/CodeGen/Mips/return_address.ll b/test/CodeGen/Mips/return_address.ll
new file mode 100644
index 0000000000..e1c9241984
--- /dev/null
+++ b/test/CodeGen/Mips/return_address.ll
@@ -0,0 +1,23 @@
+; RUN: llc -march=mipsel < %s | FileCheck %s
+
+define i8* @f1() nounwind {
+entry:
+ %0 = call i8* @llvm.returnaddress(i32 0)
+ ret i8* %0
+
+; CHECK: addu $2, $zero, $ra
+}
+
+define i8* @f2() nounwind {
+entry:
+ call void @g()
+ %0 = call i8* @llvm.returnaddress(i32 0)
+ ret i8* %0
+
+; CHECK: addu $[[R0:[0-9]+]], $zero, $ra
+; CHECK: jal
+; CHECK: addu $2, $zero, $[[R0]]
+}
+
+declare i8* @llvm.returnaddress(i32) nounwind readnone
+declare void @g()
diff --git a/test/CodeGen/Mips/sb1.ll b/test/CodeGen/Mips/sb1.ll
new file mode 100644
index 0000000000..e1a28d4595
--- /dev/null
+++ b/test/CodeGen/Mips/sb1.ll
@@ -0,0 +1,20 @@
+; RUN: llc -march=mipsel -mcpu=mips16 -relocation-model=pic -O3 < %s | FileCheck %s -check-prefix=16
+
+@i = global i32 97, align 4
+@c = common global i8 0, align 1
+@.str = private unnamed_addr constant [8 x i8] c"%i %c \0A\00", align 1
+
+define i32 @main() nounwind {
+entry:
+ %0 = load i32* @i, align 4
+ %conv = trunc i32 %0 to i8
+ store i8 %conv, i8* @c, align 1
+ %1 = load i32* @i, align 4
+ %2 = load i8* @c, align 1
+ %conv1 = sext i8 %2 to i32
+; 16: sb ${{[0-9]+}}, 0(${{[0-9]+}})
+ %call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([8 x i8]* @.str, i32 0, i32 0), i32 %1, i32 %conv1)
+ ret i32 0
+}
+
+declare i32 @printf(i8*, ...)
diff --git a/test/CodeGen/Mips/selectcc.ll b/test/CodeGen/Mips/selectcc.ll
new file mode 100644
index 0000000000..a17517e7d1
--- /dev/null
+++ b/test/CodeGen/Mips/selectcc.ll
@@ -0,0 +1,27 @@
+; RUN: llc -march=mipsel < %s
+
+@gf0 = external global float
+@gf1 = external global float
+@gd0 = external global double
+@gd1 = external global double
+
+define float @select_cc_f32(float %a, float %b) nounwind {
+entry:
+ store float 0.000000e+00, float* @gf0, align 4
+ store float 1.000000e+00, float* @gf1, align 4
+ %cmp = fcmp olt float %a, %b
+ %conv = zext i1 %cmp to i32
+ %conv1 = sitofp i32 %conv to float
+ ret float %conv1
+}
+
+define double @select_cc_f64(double %a, double %b) nounwind {
+entry:
+ store double 0.000000e+00, double* @gd0, align 8
+ store double 1.000000e+00, double* @gd1, align 8
+ %cmp = fcmp olt double %a, %b
+ %conv = zext i1 %cmp to i32
+ %conv1 = sitofp i32 %conv to double
+ ret double %conv1
+}
+
diff --git a/test/CodeGen/Mips/sh1.ll b/test/CodeGen/Mips/sh1.ll
new file mode 100644
index 0000000000..1746ae284f
--- /dev/null
+++ b/test/CodeGen/Mips/sh1.ll
@@ -0,0 +1,20 @@
+; RUN: llc -march=mipsel -mcpu=mips16 -relocation-model=pic -O3 < %s | FileCheck %s -check-prefix=16
+
+@i = global i32 97, align 4
+@s = common global i16 0, align 2
+@.str = private unnamed_addr constant [9 x i8] c"%i %hi \0A\00", align 1
+
+define i32 @main() nounwind {
+entry:
+ %0 = load i32* @i, align 4
+ %conv = trunc i32 %0 to i16
+ store i16 %conv, i16* @s, align 2
+ %1 = load i32* @i, align 4
+ %2 = load i16* @s, align 2
+ %conv1 = sext i16 %2 to i32
+; 16: sh ${{[0-9]+}}, 0(${{[0-9]+}})
+ %call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([9 x i8]* @.str, i32 0, i32 0), i32 %1, i32 %conv1)
+ ret i32 0
+}
+
+declare i32 @printf(i8*, ...)
diff --git a/test/CodeGen/Mips/sitofp-selectcc-opt.ll b/test/CodeGen/Mips/sitofp-selectcc-opt.ll
new file mode 100644
index 0000000000..576cbd8e96
--- /dev/null
+++ b/test/CodeGen/Mips/sitofp-selectcc-opt.ll
@@ -0,0 +1,22 @@
+; RUN: llc -march=mipsel < %s | FileCheck %s
+
+@foo12.d4 = internal unnamed_addr global double 0.000000e+00, align 8
+
+define double @foo12(i32 %a, i32, i64 %b) nounwind {
+entry:
+; check that this transformation doesn't happen:
+; (sint_to_fp (setcc x, y, cc)) -> (select_cc x, y, -1.0, 0.0,, cc)
+;
+; CHECK-NOT: # double -1.000000e+00
+
+ %tobool1 = icmp ne i32 %a, 0
+ %not.tobool = icmp ne i64 %b, 0
+ %tobool1. = or i1 %tobool1, %not.tobool
+ %lor.ext = zext i1 %tobool1. to i32
+ %conv = sitofp i32 %lor.ext to double
+ %1 = load double* @foo12.d4, align 8
+ %add = fadd double %conv, %1
+ store double %add, double* @foo12.d4, align 8
+ ret double %add
+}
+
diff --git a/test/CodeGen/Mips/sll1.ll b/test/CodeGen/Mips/sll1.ll
new file mode 100644
index 0000000000..fdcd38c84b
--- /dev/null
+++ b/test/CodeGen/Mips/sll1.ll
@@ -0,0 +1,19 @@
+; RUN: llc -march=mipsel -mcpu=mips16 -relocation-model=pic -O3 < %s | FileCheck %s -check-prefix=16
+
+@i = global i32 10, align 4
+@j = global i32 0, align 4
+@.str = private unnamed_addr constant [5 x i8] c"%i \0A\00", align 1
+
+define i32 @main() nounwind {
+entry:
+; 16: sll ${{[0-9]+}}, ${{[0-9]+}}, {{[0-9]+}}
+ %0 = load i32* @i, align 4
+ %shl = shl i32 %0, 4
+; 16: sll ${{[0-9]+}}, ${{[0-9]+}}, {{[0-9]+}}
+ store i32 %shl, i32* @j, align 4
+ %1 = load i32* @j, align 4
+ %call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([5 x i8]* @.str, i32 0, i32 0), i32 %1)
+ ret i32 0
+}
+
+declare i32 @printf(i8*, ...)
diff --git a/test/CodeGen/Mips/sll2.ll b/test/CodeGen/Mips/sll2.ll
new file mode 100644
index 0000000000..c2af454cc8
--- /dev/null
+++ b/test/CodeGen/Mips/sll2.ll
@@ -0,0 +1,19 @@
+; RUN: llc -march=mipsel -mcpu=mips16 -relocation-model=pic -O3 < %s | FileCheck %s -check-prefix=16
+
+@i = global i32 10, align 4
+@j = global i32 4, align 4
+@.str = private unnamed_addr constant [5 x i8] c"%i \0A\00", align 1
+
+define i32 @main() nounwind {
+entry:
+ %0 = load i32* @i, align 4
+ %1 = load i32* @j, align 4
+ %shl = shl i32 %0, %1
+; 16: sllv ${{[0-9]+}}, ${{[0-9]+}}
+ store i32 %shl, i32* @i, align 4
+ %2 = load i32* @j, align 4
+ %call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([5 x i8]* @.str, i32 0, i32 0), i32 %2)
+ ret i32 0
+}
+
+declare i32 @printf(i8*, ...)
diff --git a/test/CodeGen/Mips/sra1.ll b/test/CodeGen/Mips/sra1.ll
new file mode 100644
index 0000000000..15bf8d644e
--- /dev/null
+++ b/test/CodeGen/Mips/sra1.ll
@@ -0,0 +1,15 @@
+; RUN: llc -march=mipsel -mcpu=mips16 -relocation-model=pic -O3 < %s | FileCheck %s -check-prefix=16
+
+@i = global i32 -354, align 4
+@.str = private unnamed_addr constant [5 x i8] c"%i \0A\00", align 1
+
+define i32 @main() nounwind {
+entry:
+ %0 = load i32* @i, align 4
+ %shr = ashr i32 %0, 3
+; 16: sra ${{[0-9]+}}, ${{[0-9]+}}, {{[0-9]+}}
+ %call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([5 x i8]* @.str, i32 0, i32 0), i32 %shr)
+ ret i32 0
+}
+
+declare i32 @printf(i8*, ...)
diff --git a/test/CodeGen/Mips/sra2.ll b/test/CodeGen/Mips/sra2.ll
new file mode 100644
index 0000000000..26bf19d440
--- /dev/null
+++ b/test/CodeGen/Mips/sra2.ll
@@ -0,0 +1,17 @@
+; RUN: llc -march=mipsel -mcpu=mips16 -relocation-model=pic -O3 < %s | FileCheck %s -check-prefix=16
+
+@i = global i32 -354, align 4
+@j = global i32 3, align 4
+@.str = private unnamed_addr constant [5 x i8] c"%i \0A\00", align 1
+
+define i32 @main() nounwind {
+entry:
+ %0 = load i32* @i, align 4
+ %1 = load i32* @j, align 4
+ %shr = ashr i32 %0, %1
+; 16: srav ${{[0-9]+}}, ${{[0-9]+}}
+ %call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([5 x i8]* @.str, i32 0, i32 0), i32 %shr)
+ ret i32 0
+}
+
+declare i32 @printf(i8*, ...)
diff --git a/test/CodeGen/Mips/srl1.ll b/test/CodeGen/Mips/srl1.ll
new file mode 100644
index 0000000000..3474283fae
--- /dev/null
+++ b/test/CodeGen/Mips/srl1.ll
@@ -0,0 +1,18 @@
+; RUN: llc -march=mipsel -mcpu=mips16 -relocation-model=pic -O3 < %s | FileCheck %s -check-prefix=16
+
+@i = global i32 10654, align 4
+@j = global i32 0, align 4
+@.str = private unnamed_addr constant [5 x i8] c"%i \0A\00", align 1
+
+define i32 @main() nounwind {
+entry:
+ %0 = load i32* @i, align 4
+ %shr = lshr i32 %0, 4
+; 16: srl ${{[0-9]+}}, ${{[0-9]+}}, {{[0-9]+}}
+ store i32 %shr, i32* @j, align 4
+ %1 = load i32* @j, align 4
+ %call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([5 x i8]* @.str, i32 0, i32 0), i32 %1)
+ ret i32 0
+}
+
+declare i32 @printf(i8*, ...)
diff --git a/test/CodeGen/Mips/srl2.ll b/test/CodeGen/Mips/srl2.ll
new file mode 100644
index 0000000000..26ec0927a5
--- /dev/null
+++ b/test/CodeGen/Mips/srl2.ll
@@ -0,0 +1,20 @@
+; RUN: llc -march=mipsel -mcpu=mips16 -relocation-model=pic -O3 < %s | FileCheck %s -check-prefix=16
+
+@i = global i32 10654, align 4
+@j = global i32 0, align 4
+@k = global i32 4, align 4
+@.str = private unnamed_addr constant [5 x i8] c"%i \0A\00", align 1
+
+define i32 @main() nounwind {
+entry:
+ %0 = load i32* @i, align 4
+ %1 = load i32* @k, align 4
+ %shr = lshr i32 %0, %1
+; 16: srlv ${{[0-9]+}}, ${{[0-9]+}}
+ store i32 %shr, i32* @j, align 4
+ %2 = load i32* @j, align 4
+ %call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([5 x i8]* @.str, i32 0, i32 0), i32 %2)
+ ret i32 0
+}
+
+declare i32 @printf(i8*, ...)
diff --git a/test/CodeGen/Mips/sub1.ll b/test/CodeGen/Mips/sub1.ll
new file mode 100644
index 0000000000..195750b805
--- /dev/null
+++ b/test/CodeGen/Mips/sub1.ll
@@ -0,0 +1,15 @@
+; RUN: llc -march=mipsel -mcpu=mips16 -relocation-model=pic -O3 < %s | FileCheck %s -check-prefix=16
+
+@i = global i32 10, align 4
+@.str = private unnamed_addr constant [4 x i8] c"%i\0A\00", align 1
+
+define i32 @main() nounwind {
+entry:
+ %0 = load i32* @i, align 4
+ %sub = sub nsw i32 %0, 5
+; 16: addiu ${{[0-9]+}}, -{{[0-9]+}}
+ %call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([4 x i8]* @.str, i32 0, i32 0), i32 %sub)
+ ret i32 0
+}
+
+declare i32 @printf(i8*, ...)
diff --git a/test/CodeGen/Mips/sub2.ll b/test/CodeGen/Mips/sub2.ll
new file mode 100644
index 0000000000..4f6bfccec4
--- /dev/null
+++ b/test/CodeGen/Mips/sub2.ll
@@ -0,0 +1,17 @@
+; RUN: llc -march=mipsel -mcpu=mips16 -relocation-model=pic -O3 < %s | FileCheck %s -check-prefix=16
+
+@i = global i32 10, align 4
+@j = global i32 20, align 4
+@.str = private unnamed_addr constant [4 x i8] c"%i\0A\00", align 1
+
+define i32 @main() nounwind {
+entry:
+ %0 = load i32* @j, align 4
+ %1 = load i32* @i, align 4
+ %sub = sub nsw i32 %0, %1
+; 16: subu ${{[0-9]+}}, ${{[0-9]+}}, ${{[0-9]+}}
+ %call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([4 x i8]* @.str, i32 0, i32 0), i32 %sub)
+ ret i32 0
+}
+
+declare i32 @printf(i8*, ...)
diff --git a/test/CodeGen/Mips/swzero.ll b/test/CodeGen/Mips/swzero.ll
index 2441ca29dd..9f91a3902d 100644
--- a/test/CodeGen/Mips/swzero.ll
+++ b/test/CodeGen/Mips/swzero.ll
@@ -4,6 +4,7 @@
define void @zero_u(%struct.unaligned* nocapture %p) nounwind {
entry:
+; CHECK: swl $zero
; CHECK: swr $zero
%x = getelementptr inbounds %struct.unaligned* %p, i32 0, i32 0
store i32 0, i32* %x, align 1
diff --git a/test/CodeGen/Mips/xor1.ll b/test/CodeGen/Mips/xor1.ll
new file mode 100644
index 0000000000..f2c13169cf
--- /dev/null
+++ b/test/CodeGen/Mips/xor1.ll
@@ -0,0 +1,17 @@
+; RUN: llc -march=mipsel -mcpu=mips16 -relocation-model=pic -O3 < %s | FileCheck %s -check-prefix=16
+
+@x = global i32 65504, align 4
+@y = global i32 60929, align 4
+@.str = private unnamed_addr constant [7 x i8] c"%08x \0A\00", align 1
+
+define i32 @main() nounwind {
+entry:
+ %0 = load i32* @x, align 4
+ %1 = load i32* @y, align 4
+ %xor = xor i32 %0, %1
+; 16: xor ${{[0-9]+}}, ${{[0-9]+}}
+ %call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([7 x i8]* @.str, i32 0, i32 0), i32 %xor)
+ ret i32 0
+}
+
+declare i32 @printf(i8*, ...)