2011-12-07 22:11:43 +00:00
|
|
|
; RUN: llc -march=mips < %s | FileCheck %s -check-prefix=O32
|
|
|
|
; RUN: llc -march=mips -regalloc=basic < %s | FileCheck %s -check-prefix=O32
|
|
|
|
; RUN: llc -march=mips64el -mcpu=mips64 -mattr=n64 < %s | FileCheck %s -check-prefix=N64
|
2010-12-07 19:00:20 +00:00
|
|
|
|
|
|
|
@i1 = global [3 x i32] [i32 1, i32 2, i32 3], align 4
|
|
|
|
@i3 = common global i32* null, align 4
|
|
|
|
|
2013-07-12 23:33:22 +00:00
|
|
|
; O32-DAG: lw $[[R0:[0-9]+]], %got(i3)
|
2013-07-12 23:47:38 +00:00
|
|
|
; O32-DAG: addiu $[[R1:[0-9]+]], ${{[0-9]+}}, %got(i1)
|
|
|
|
; O32: movn $[[R0]], $[[R1]], ${{[0-9]+}}
|
|
|
|
; N64-DAG: ldr $[[R0:[0-9]+]]
|
2013-07-12 23:33:22 +00:00
|
|
|
; N64-DAG: ld $[[R1:[0-9]+]], %got_disp(i1)
|
2013-07-12 23:47:38 +00:00
|
|
|
; N64: movn $[[R0]], $[[R1]], ${{[0-9]+}}
|
2010-12-07 19:00:20 +00:00
|
|
|
define i32* @cmov1(i32 %s) nounwind readonly {
|
|
|
|
entry:
|
|
|
|
%tobool = icmp ne i32 %s, 0
|
|
|
|
%tmp1 = load i32** @i3, align 4
|
|
|
|
%cond = select i1 %tobool, i32* getelementptr inbounds ([3 x i32]* @i1, i32 0, i32 0), i32* %tmp1
|
|
|
|
ret i32* %cond
|
|
|
|
}
|
|
|
|
|
2011-05-28 01:07:07 +00:00
|
|
|
@c = global i32 1, align 4
|
|
|
|
@d = global i32 0, align 4
|
|
|
|
|
2013-07-14 06:24:09 +00:00
|
|
|
; O32-LABEL: cmov2:
|
2012-05-12 03:25:16 +00:00
|
|
|
; O32: addiu $[[R1:[0-9]+]], ${{[a-z0-9]+}}, %got(d)
|
|
|
|
; O32: addiu $[[R0:[0-9]+]], ${{[a-z0-9]+}}, %got(c)
|
2011-12-07 22:11:43 +00:00
|
|
|
; O32: movn $[[R1]], $[[R0]], ${{[0-9]+}}
|
2013-07-14 06:24:09 +00:00
|
|
|
; N64-LABEL: cmov2:
|
2012-04-25 01:24:52 +00:00
|
|
|
; N64: daddiu $[[R1:[0-9]+]], ${{[0-9]+}}, %got_disp(d)
|
|
|
|
; N64: daddiu $[[R0:[0-9]+]], ${{[0-9]+}}, %got_disp(c)
|
2011-12-07 22:11:43 +00:00
|
|
|
; N64: movn $[[R1]], $[[R0]], ${{[0-9]+}}
|
2011-05-28 01:07:07 +00:00
|
|
|
define i32 @cmov2(i32 %s) nounwind readonly {
|
|
|
|
entry:
|
|
|
|
%tobool = icmp ne i32 %s, 0
|
|
|
|
%tmp1 = load i32* @c, align 4
|
|
|
|
%tmp2 = load i32* @d, align 4
|
|
|
|
%cond = select i1 %tobool, i32 %tmp1, i32 %tmp2
|
|
|
|
ret i32 %cond
|
|
|
|
}
|
|
|
|
|
2013-07-14 06:24:09 +00:00
|
|
|
; O32-LABEL: cmov3:
|
2012-05-09 02:29:29 +00:00
|
|
|
; O32: xori $[[R0:[0-9]+]], ${{[0-9]+}}, 234
|
|
|
|
; O32: movz ${{[0-9]+}}, ${{[0-9]+}}, $[[R0]]
|
|
|
|
define i32 @cmov3(i32 %a, i32 %b, i32 %c) nounwind readnone {
|
|
|
|
entry:
|
|
|
|
%cmp = icmp eq i32 %a, 234
|
|
|
|
%cond = select i1 %cmp, i32 %b, i32 %c
|
|
|
|
ret i32 %cond
|
|
|
|
}
|
|
|
|
|
2013-07-14 06:24:09 +00:00
|
|
|
; N64-LABEL: cmov4:
|
2012-05-09 02:29:29 +00:00
|
|
|
; N64: xori $[[R0:[0-9]+]], ${{[0-9]+}}, 234
|
|
|
|
; N64: movz ${{[0-9]+}}, ${{[0-9]+}}, $[[R0]]
|
|
|
|
define i64 @cmov4(i32 %a, i64 %b, i64 %c) nounwind readnone {
|
|
|
|
entry:
|
|
|
|
%cmp = icmp eq i32 %a, 234
|
|
|
|
%cond = select i1 %cmp, i64 %b, i64 %c
|
|
|
|
ret i64 %cond
|
|
|
|
}
|
|
|
|
|
2013-03-01 21:52:08 +00:00
|
|
|
; slti and conditional move.
|
|
|
|
;
|
|
|
|
; Check that, pattern
|
|
|
|
; (select (setgt a, N), t, f)
|
|
|
|
; turns into
|
|
|
|
; (movz t, (setlt a, N + 1), f)
|
|
|
|
; if N + 1 fits in 16-bit.
|
|
|
|
|
2013-07-14 06:24:09 +00:00
|
|
|
; O32-LABEL: slti0:
|
2013-03-01 21:52:08 +00:00
|
|
|
; O32: slti $[[R0:[0-9]+]], ${{[0-9]+}}, 32767
|
|
|
|
; O32: movz ${{[0-9]+}}, ${{[0-9]+}}, $[[R0]]
|
|
|
|
|
|
|
|
define i32 @slti0(i32 %a) {
|
|
|
|
entry:
|
|
|
|
%cmp = icmp sgt i32 %a, 32766
|
2013-12-05 12:07:05 +00:00
|
|
|
%cond = select i1 %cmp, i32 3, i32 5
|
2013-03-01 21:52:08 +00:00
|
|
|
ret i32 %cond
|
|
|
|
}
|
|
|
|
|
2013-07-14 06:24:09 +00:00
|
|
|
; O32-LABEL: slti1:
|
2013-03-01 21:52:08 +00:00
|
|
|
; O32: slt ${{[0-9]+}}
|
|
|
|
|
|
|
|
define i32 @slti1(i32 %a) {
|
|
|
|
entry:
|
|
|
|
%cmp = icmp sgt i32 %a, 32767
|
2013-12-05 12:07:05 +00:00
|
|
|
%cond = select i1 %cmp, i32 3, i32 5
|
2013-03-01 21:52:08 +00:00
|
|
|
ret i32 %cond
|
|
|
|
}
|
|
|
|
|
2013-07-14 06:24:09 +00:00
|
|
|
; O32-LABEL: slti2:
|
2013-03-01 21:52:08 +00:00
|
|
|
; O32: slti $[[R0:[0-9]+]], ${{[0-9]+}}, -32768
|
|
|
|
; O32: movz ${{[0-9]+}}, ${{[0-9]+}}, $[[R0]]
|
|
|
|
|
|
|
|
define i32 @slti2(i32 %a) {
|
|
|
|
entry:
|
|
|
|
%cmp = icmp sgt i32 %a, -32769
|
2013-12-05 12:07:05 +00:00
|
|
|
%cond = select i1 %cmp, i32 3, i32 5
|
2013-03-01 21:52:08 +00:00
|
|
|
ret i32 %cond
|
|
|
|
}
|
|
|
|
|
2013-07-14 06:24:09 +00:00
|
|
|
; O32-LABEL: slti3:
|
2013-03-01 21:52:08 +00:00
|
|
|
; O32: slt ${{[0-9]+}}
|
|
|
|
|
|
|
|
define i32 @slti3(i32 %a) {
|
|
|
|
entry:
|
|
|
|
%cmp = icmp sgt i32 %a, -32770
|
2013-12-05 12:07:05 +00:00
|
|
|
%cond = select i1 %cmp, i32 3, i32 5
|
2013-03-01 21:52:08 +00:00
|
|
|
ret i32 %cond
|
|
|
|
}
|
|
|
|
|
|
|
|
; 64-bit patterns.
|
|
|
|
|
2013-07-14 06:24:09 +00:00
|
|
|
; N64-LABEL: slti64_0:
|
2013-03-01 21:52:08 +00:00
|
|
|
; N64: slti $[[R0:[0-9]+]], ${{[0-9]+}}, 32767
|
|
|
|
; N64: movz ${{[0-9]+}}, ${{[0-9]+}}, $[[R0]]
|
|
|
|
|
|
|
|
define i64 @slti64_0(i64 %a) {
|
|
|
|
entry:
|
|
|
|
%cmp = icmp sgt i64 %a, 32766
|
|
|
|
%conv = select i1 %cmp, i64 3, i64 4
|
|
|
|
ret i64 %conv
|
|
|
|
}
|
|
|
|
|
2013-07-14 06:24:09 +00:00
|
|
|
; N64-LABEL: slti64_1:
|
2013-03-01 21:52:08 +00:00
|
|
|
; N64: slt ${{[0-9]+}}
|
|
|
|
|
|
|
|
define i64 @slti64_1(i64 %a) {
|
|
|
|
entry:
|
|
|
|
%cmp = icmp sgt i64 %a, 32767
|
|
|
|
%conv = select i1 %cmp, i64 3, i64 4
|
|
|
|
ret i64 %conv
|
|
|
|
}
|
|
|
|
|
2013-07-14 06:24:09 +00:00
|
|
|
; N64-LABEL: slti64_2:
|
2013-03-01 21:52:08 +00:00
|
|
|
; N64: slti $[[R0:[0-9]+]], ${{[0-9]+}}, -32768
|
|
|
|
; N64: movz ${{[0-9]+}}, ${{[0-9]+}}, $[[R0]]
|
|
|
|
|
|
|
|
define i64 @slti64_2(i64 %a) {
|
|
|
|
entry:
|
|
|
|
%cmp = icmp sgt i64 %a, -32769
|
|
|
|
%conv = select i1 %cmp, i64 3, i64 4
|
|
|
|
ret i64 %conv
|
|
|
|
}
|
|
|
|
|
2013-07-14 06:24:09 +00:00
|
|
|
; N64-LABEL: slti64_3:
|
2013-03-01 21:52:08 +00:00
|
|
|
; N64: slt ${{[0-9]+}}
|
|
|
|
|
|
|
|
define i64 @slti64_3(i64 %a) {
|
|
|
|
entry:
|
|
|
|
%cmp = icmp sgt i64 %a, -32770
|
|
|
|
%conv = select i1 %cmp, i64 3, i64 4
|
|
|
|
ret i64 %conv
|
|
|
|
}
|
|
|
|
|
|
|
|
; sltiu instructions.
|
|
|
|
|
2013-07-14 06:24:09 +00:00
|
|
|
; O32-LABEL: sltiu0:
|
2013-03-01 21:52:08 +00:00
|
|
|
; O32: sltiu $[[R0:[0-9]+]], ${{[0-9]+}}, 32767
|
|
|
|
; O32: movz ${{[0-9]+}}, ${{[0-9]+}}, $[[R0]]
|
|
|
|
|
|
|
|
define i32 @sltiu0(i32 %a) {
|
|
|
|
entry:
|
|
|
|
%cmp = icmp ugt i32 %a, 32766
|
2013-12-05 12:07:05 +00:00
|
|
|
%cond = select i1 %cmp, i32 3, i32 5
|
2013-03-01 21:52:08 +00:00
|
|
|
ret i32 %cond
|
|
|
|
}
|
|
|
|
|
2013-07-14 06:24:09 +00:00
|
|
|
; O32-LABEL: sltiu1:
|
2013-03-01 21:52:08 +00:00
|
|
|
; O32: sltu ${{[0-9]+}}
|
|
|
|
|
|
|
|
define i32 @sltiu1(i32 %a) {
|
|
|
|
entry:
|
|
|
|
%cmp = icmp ugt i32 %a, 32767
|
2013-12-05 12:07:05 +00:00
|
|
|
%cond = select i1 %cmp, i32 3, i32 5
|
2013-03-01 21:52:08 +00:00
|
|
|
ret i32 %cond
|
|
|
|
}
|
|
|
|
|
2013-07-14 06:24:09 +00:00
|
|
|
; O32-LABEL: sltiu2:
|
2013-03-01 21:52:08 +00:00
|
|
|
; O32: sltiu $[[R0:[0-9]+]], ${{[0-9]+}}, -32768
|
|
|
|
; O32: movz ${{[0-9]+}}, ${{[0-9]+}}, $[[R0]]
|
|
|
|
|
|
|
|
define i32 @sltiu2(i32 %a) {
|
|
|
|
entry:
|
|
|
|
%cmp = icmp ugt i32 %a, -32769
|
2013-12-05 12:07:05 +00:00
|
|
|
%cond = select i1 %cmp, i32 3, i32 5
|
2013-03-01 21:52:08 +00:00
|
|
|
ret i32 %cond
|
|
|
|
}
|
|
|
|
|
2013-07-14 06:24:09 +00:00
|
|
|
; O32-LABEL: sltiu3:
|
2013-03-01 21:52:08 +00:00
|
|
|
; O32: sltu ${{[0-9]+}}
|
|
|
|
|
|
|
|
define i32 @sltiu3(i32 %a) {
|
|
|
|
entry:
|
|
|
|
%cmp = icmp ugt i32 %a, -32770
|
2013-12-05 12:07:05 +00:00
|
|
|
%cond = select i1 %cmp, i32 3, i32 5
|
2013-03-01 21:52:08 +00:00
|
|
|
ret i32 %cond
|
|
|
|
}
|
2013-12-05 12:07:05 +00:00
|
|
|
|
|
|
|
; Check if
|
|
|
|
; (select (setxx a, N), x, x-1) or
|
|
|
|
; (select (setxx a, N), x-1, x)
|
|
|
|
; doesn't generate conditional moves
|
|
|
|
; for constant operands whose difference is |1|
|
|
|
|
|
|
|
|
define i32 @slti4(i32 %a) nounwind readnone {
|
|
|
|
%1 = icmp slt i32 %a, 7
|
|
|
|
%2 = select i1 %1, i32 4, i32 3
|
|
|
|
ret i32 %2
|
|
|
|
}
|
|
|
|
|
|
|
|
; O32-LABEL: slti4:
|
|
|
|
; O32-DAG: slti [[R1:\$[0-9]+]], $4, 7
|
|
|
|
; O32-DAG: addiu [[R2:\$[0-9]+]], [[R1]], 3
|
|
|
|
; O32-NOT: movn
|
|
|
|
; O32:.size slti4
|
|
|
|
|
|
|
|
define i32 @slti5(i32 %a) nounwind readnone {
|
|
|
|
%1 = icmp slt i32 %a, 7
|
|
|
|
%2 = select i1 %1, i32 -3, i32 -4
|
|
|
|
ret i32 %2
|
|
|
|
}
|
|
|
|
|
|
|
|
; O32-LABEL: slti5:
|
|
|
|
; O32-DAG: slti [[R1:\$[0-9]+]], $4, 7
|
|
|
|
; O32-DAG: addiu [[R3:\$[0-9]+]], [[R2:\$[a-z0-9]+]], -4
|
|
|
|
; O32-NOT: movn
|
|
|
|
; O32:.size slti5
|
|
|
|
|
|
|
|
define i32 @slti6(i32 %a) nounwind readnone {
|
|
|
|
%1 = icmp slt i32 %a, 7
|
|
|
|
%2 = select i1 %1, i32 3, i32 4
|
|
|
|
ret i32 %2
|
|
|
|
}
|
|
|
|
|
|
|
|
; O32-LABEL: slti6:
|
|
|
|
; O32-DAG: slti [[R1:\$[0-9]+]], $4, 7
|
|
|
|
; O32-DAG: xori [[R1]], [[R1]], 1
|
|
|
|
; O32-DAG: addiu [[R2:\$[0-9]+]], [[R1]], 3
|
|
|
|
; O32-NOT: movn
|
|
|
|
; O32:.size slti6
|