Add Thumb-2 support for TEQ amd TST.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74468 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
David Goodwin 2009-06-29 22:49:42 +00:00
parent 8ba221d5c5
commit baeb911d60
5 changed files with 196 additions and 1 deletions

View File

@ -621,7 +621,10 @@ def : T2Pat<(ARMcmp GPR:$src, t2_so_imm_neg:$imm),
def : T2Pat<(ARMcmpZ GPR:$src, t2_so_imm_neg:$imm),
(t2CMNri GPR:$src, t2_so_imm_neg:$imm)>;
// FIXME: TST, TEQ, etc.
defm t2TST : T2I_cmp_is<"tst",
BinOpFrag<(ARMcmpZ (and node:$LHS, node:$RHS), 0)>>;
defm t2TEQ : T2I_cmp_is<"teq",
BinOpFrag<(ARMcmpZ (xor node:$LHS, node:$RHS), 0)>>;
// A8.6.27 CBNZ, CBZ - Compare and branch on (non)zero.
// Short range conditional branch. Looks awesome for loops. Need to figure

View File

@ -0,0 +1,71 @@
; RUN: llvm-as < %s | llc -march=thumb -mattr=+thumb2 | grep {teq\\W*r\[0-9\],\\W*#\[0-9\]*} | grep {#187\\|#11141290\\|#3422604288\\|#1114112\\|#3722304989} | count 10
; 0x000000bb = 187
define i1 @f1(i32 %a) {
%tmp = xor i32 %a, 187
%tmp1 = icmp ne i32 %tmp, 0
ret i1 %tmp1
}
; 0x000000bb = 187
define i1 @f2(i32 %a) {
%tmp = xor i32 %a, 187
%tmp1 = icmp eq i32 0, %tmp
ret i1 %tmp1
}
; 0x00aa00aa = 11141290
define i1 @f3(i32 %a) {
%tmp = xor i32 %a, 11141290
%tmp1 = icmp eq i32 %tmp, 0
ret i1 %tmp1
}
; 0x00aa00aa = 11141290
define i1 @f4(i32 %a) {
%tmp = xor i32 %a, 11141290
%tmp1 = icmp ne i32 0, %tmp
ret i1 %tmp1
}
; 0xcc00cc00 = 3422604288
define i1 @f5(i32 %a) {
%tmp = xor i32 %a, 3422604288
%tmp1 = icmp ne i32 %tmp, 0
ret i1 %tmp1
}
; 0xcc00cc00 = 3422604288
define i1 @f6(i32 %a) {
%tmp = xor i32 %a, 3422604288
%tmp1 = icmp eq i32 0, %tmp
ret i1 %tmp1
}
; 0xdddddddd = 3722304989
define i1 @f7(i32 %a) {
%tmp = xor i32 %a, 3722304989
%tmp1 = icmp eq i32 %tmp, 0
ret i1 %tmp1
}
; 0xdddddddd = 3722304989
define i1 @f8(i32 %a) {
%tmp = xor i32 %a, 3722304989
%tmp1 = icmp ne i32 0, %tmp
ret i1 %tmp1
}
; 0x00110000 = 1114112
define i1 @f9(i32 %a) {
%tmp = xor i32 %a, 1114112
%tmp1 = icmp ne i32 %tmp, 0
ret i1 %tmp1
}
; 0x00110000 = 1114112
define i1 @f10(i32 %a) {
%tmp = xor i32 %a, 1114112
%tmp1 = icmp eq i32 0, %tmp
ret i1 %tmp1
}

View File

@ -0,0 +1,25 @@
; RUN: llvm-as < %s | llc -march=thumb -mattr=+thumb2 | grep {teq\\W*r\[0-9\],\\W*r\[0-9\]} | count 4
define i1 @f1(i32 %a, i32 %b) {
%tmp = xor i32 %a, %b
%tmp1 = icmp ne i32 %tmp, 0
ret i1 %tmp1
}
define i1 @f2(i32 %a, i32 %b) {
%tmp = xor i32 %a, %b
%tmp1 = icmp eq i32 %tmp, 0
ret i1 %tmp1
}
define i1 @f3(i32 %a, i32 %b) {
%tmp = xor i32 %a, %b
%tmp1 = icmp ne i32 0, %tmp
ret i1 %tmp1
}
define i1 @f4(i32 %a, i32 %b) {
%tmp = xor i32 %a, %b
%tmp1 = icmp eq i32 0, %tmp
ret i1 %tmp1
}

View File

@ -0,0 +1,71 @@
; RUN: llvm-as < %s | llc -march=thumb -mattr=+thumb2 | grep {tst\\W*r\[0-9\],\\W*#\[0-9\]*} | grep {#187\\|#11141290\\|#3422604288\\|#1114112\\|#3722304989} | count 10
; 0x000000bb = 187
define i1 @f1(i32 %a) {
%tmp = and i32 %a, 187
%tmp1 = icmp ne i32 %tmp, 0
ret i1 %tmp1
}
; 0x000000bb = 187
define i1 @f2(i32 %a) {
%tmp = and i32 %a, 187
%tmp1 = icmp eq i32 0, %tmp
ret i1 %tmp1
}
; 0x00aa00aa = 11141290
define i1 @f3(i32 %a) {
%tmp = and i32 %a, 11141290
%tmp1 = icmp eq i32 %tmp, 0
ret i1 %tmp1
}
; 0x00aa00aa = 11141290
define i1 @f4(i32 %a) {
%tmp = and i32 %a, 11141290
%tmp1 = icmp ne i32 0, %tmp
ret i1 %tmp1
}
; 0xcc00cc00 = 3422604288
define i1 @f5(i32 %a) {
%tmp = and i32 %a, 3422604288
%tmp1 = icmp ne i32 %tmp, 0
ret i1 %tmp1
}
; 0xcc00cc00 = 3422604288
define i1 @f6(i32 %a) {
%tmp = and i32 %a, 3422604288
%tmp1 = icmp eq i32 0, %tmp
ret i1 %tmp1
}
; 0xdddddddd = 3722304989
define i1 @f7(i32 %a) {
%tmp = and i32 %a, 3722304989
%tmp1 = icmp eq i32 %tmp, 0
ret i1 %tmp1
}
; 0xdddddddd = 3722304989
define i1 @f8(i32 %a) {
%tmp = and i32 %a, 3722304989
%tmp1 = icmp ne i32 0, %tmp
ret i1 %tmp1
}
; 0x00110000 = 1114112
define i1 @f9(i32 %a) {
%tmp = and i32 %a, 1114112
%tmp1 = icmp ne i32 %tmp, 0
ret i1 %tmp1
}
; 0x00110000 = 1114112
define i1 @f10(i32 %a) {
%tmp = and i32 %a, 1114112
%tmp1 = icmp eq i32 0, %tmp
ret i1 %tmp1
}

View File

@ -0,0 +1,25 @@
; RUN: llvm-as < %s | llc -march=thumb -mattr=+thumb2 | grep {tst\\W*r\[0-9\],\\W*r\[0-9\]} | count 4
define i1 @f1(i32 %a, i32 %b) {
%tmp = and i32 %a, %b
%tmp1 = icmp ne i32 %tmp, 0
ret i1 %tmp1
}
define i1 @f2(i32 %a, i32 %b) {
%tmp = and i32 %a, %b
%tmp1 = icmp eq i32 %tmp, 0
ret i1 %tmp1
}
define i1 @f3(i32 %a, i32 %b) {
%tmp = and i32 %a, %b
%tmp1 = icmp ne i32 0, %tmp
ret i1 %tmp1
}
define i1 @f4(i32 %a, i32 %b) {
%tmp = and i32 %a, %b
%tmp1 = icmp eq i32 0, %tmp
ret i1 %tmp1
}