From 11f7bfbb834e42cd53a81a84a1dfc118ae17c9c5 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Mon, 17 Sep 2007 14:35:24 +0000 Subject: [PATCH] Use "test reg,reg" in place of "cmp reg,0" for 64-bit operands. This was previously only done for 32-bit and smaller operands. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@42024 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/X86/X86InstrX86-64.td | 6 ++++++ test/CodeGen/X86/cmp0.ll | 7 +++++++ 2 files changed, 13 insertions(+) create mode 100644 test/CodeGen/X86/cmp0.ll diff --git a/lib/Target/X86/X86InstrX86-64.td b/lib/Target/X86/X86InstrX86-64.td index 0c02f19198d..89d952a5b05 100644 --- a/lib/Target/X86/X86InstrX86-64.td +++ b/lib/Target/X86/X86InstrX86-64.td @@ -1076,6 +1076,12 @@ def : Pat<(X86tailcall (i64 texternalsym:$dst)), def : Pat<(X86tailcall GR64:$dst), (CALL64r GR64:$dst)>; +// Comparisons. + +// TEST R,R is smaller than CMP R,0 +def : Pat<(X86cmp GR64:$src1, 0), + (TEST64rr GR64:$src1, GR64:$src1)>; + // {s|z}extload bool -> {s|z}extload byte def : Pat<(sextloadi64i1 addr:$src), (MOVSX64rm8 addr:$src)>; def : Pat<(zextloadi64i1 addr:$src), (MOVZX64rm8 addr:$src)>; diff --git a/test/CodeGen/X86/cmp0.ll b/test/CodeGen/X86/cmp0.ll new file mode 100644 index 00000000000..f66f90c0b0f --- /dev/null +++ b/test/CodeGen/X86/cmp0.ll @@ -0,0 +1,7 @@ +; RUN: llvm-as < %s | llc -march=x86-64 | grep -v cmp + +define i64 @foo(i64 %x) { + %t = icmp eq i64 %x, 0 + %r = zext i1 %t to i64 + ret i64 %r +} -- 2.34.1