From d73566609ea050ab73e0a3cda1c3840fd1a3d8fb Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Tue, 17 Mar 2009 02:17:27 +0000 Subject: [PATCH] Recognize "bswapq" as an alternate spelling for the bswap instruction. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@67071 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/X86/X86TargetAsmInfo.cpp | 4 ++-- test/CodeGen/X86/bswap-inline-asm.ll | 12 ++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 test/CodeGen/X86/bswap-inline-asm.ll diff --git a/lib/Target/X86/X86TargetAsmInfo.cpp b/lib/Target/X86/X86TargetAsmInfo.cpp index 226feb7c1e6..f3faa7022cd 100644 --- a/lib/Target/X86/X86TargetAsmInfo.cpp +++ b/lib/Target/X86/X86TargetAsmInfo.cpp @@ -411,8 +411,8 @@ bool X86TargetAsmInfo::ExpandInlineAsm(CallInst *CI) const { // bswap $0 if (AsmPieces.size() == 2 && - AsmPieces[0] == "bswap" && (AsmPieces[1] == "$0" || - AsmPieces[1] == "${0:q}")) { + (AsmPieces[0] == "bswap" || AsmPieces[0] == "bswapq") && + (AsmPieces[1] == "$0" || AsmPieces[1] == "${0:q}")) { // No need to check constraints, nothing other than the equivalent of // "=r,0" would be valid here. return LowerToBSwap(CI); diff --git a/test/CodeGen/X86/bswap-inline-asm.ll b/test/CodeGen/X86/bswap-inline-asm.ll new file mode 100644 index 00000000000..c44d845c832 --- /dev/null +++ b/test/CodeGen/X86/bswap-inline-asm.ll @@ -0,0 +1,12 @@ +; RUN: llvm-as < %s | llc -march=x86-64 > %t +; RUN: not grep APP %t +; RUN: grep bswapq %t | count 2 + +define i64 @foo(i64 %x) nounwind { + %asmtmp = tail call i64 asm "bswap $0", "=r,0,~{dirflag},~{fpsr},~{flags}"(i64 %x) nounwind + ret i64 %asmtmp +} +define i64 @bar(i64 %x) nounwind { + %asmtmp = tail call i64 asm "bswapq ${0:q}", "=r,0,~{dirflag},~{fpsr},~{flags}"(i64 %x) nounwind + ret i64 %asmtmp +}