From be149a814874a7769c81197990a88780e408cb5a Mon Sep 17 00:00:00 2001 From: Simon Pilgrim Date: Fri, 3 Apr 2015 14:24:40 +0000 Subject: [PATCH] [X86] Added SSE4.2 CRC32 memory folding patterns + tests git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234013 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/X86/X86InstrInfo.cpp | 2 ++ test/CodeGen/X86/stack-folding-int-sse42.ll | 27 +++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/lib/Target/X86/X86InstrInfo.cpp b/lib/Target/X86/X86InstrInfo.cpp index 2292a548dde..0154afebb44 100644 --- a/lib/Target/X86/X86InstrInfo.cpp +++ b/lib/Target/X86/X86InstrInfo.cpp @@ -952,6 +952,8 @@ X86InstrInfo::X86InstrInfo(X86Subtarget &STI) { X86::CMPPSrri, X86::CMPPSrmi, TB_ALIGN_16 }, { X86::CMPSDrr, X86::CMPSDrm, 0 }, { X86::CMPSSrr, X86::CMPSSrm, 0 }, + { X86::CRC32r32r32, X86::CRC32r32m32, 0 }, + { X86::CRC32r64r64, X86::CRC32r64m64, 0 }, { X86::DIVPDrr, X86::DIVPDrm, TB_ALIGN_16 }, { X86::DIVPSrr, X86::DIVPSrm, TB_ALIGN_16 }, { X86::DIVSDrr, X86::DIVSDrm, 0 }, diff --git a/test/CodeGen/X86/stack-folding-int-sse42.ll b/test/CodeGen/X86/stack-folding-int-sse42.ll index 7c3de917dce..e814ae6df50 100644 --- a/test/CodeGen/X86/stack-folding-int-sse42.ll +++ b/test/CodeGen/X86/stack-folding-int-sse42.ll @@ -62,6 +62,33 @@ define <2 x i64> @stack_fold_aeskeygenassist(<2 x i64> %a0) { } declare <2 x i64> @llvm.x86.aesni.aeskeygenassist(<2 x i64>, i8) nounwind readnone +;TODO stack_fold_crc32_32_8 +declare i32 @llvm.x86.sse42.crc32.32.8(i32, i8) nounwind + +;TODO stack_fold_crc32_32_16 +declare i32 @llvm.x86.sse42.crc32.32.16(i32, i16) nounwind + +define i32 @stack_fold_crc32_32_32(i32 %a0, i32 %a1) { + ;CHECK-LABEL: stack_fold_crc32_32_32 + ;CHECK: crc32l {{-?[0-9]*}}(%rsp), %eax {{.*#+}} 4-byte Folded Reload + %1 = tail call <2 x i64> asm sideeffect "nop", "=x,~{rbx},~{rcx},~{rdx},~{rsi},~{rdi},~{rbp},~{r8},~{r9},~{r10},~{r11},~{r12},~{r13},~{r14},~{r15}"() + %2 = call i32 @llvm.x86.sse42.crc32.32.32(i32 %a0, i32 %a1) + ret i32 %2 +} +declare i32 @llvm.x86.sse42.crc32.32.32(i32, i32) nounwind + +;TODO stack_fold_crc32_64_8 +declare i64 @llvm.x86.sse42.crc32.64.8(i64, i8) nounwind + +define i64 @stack_fold_crc32_64_64(i64 %a0, i64 %a1) { + ;CHECK-LABEL: stack_fold_crc32_64_64 + ;CHECK: crc32q {{-?[0-9]*}}(%rsp), %rax {{.*#+}} 8-byte Folded Reload + %1 = tail call <2 x i64> asm sideeffect "nop", "=x,~{rbx},~{rcx},~{rdx},~{rsi},~{rdi},~{rbp},~{r8},~{r9},~{r10},~{r11},~{r12},~{r13},~{r14},~{r15}"() + %2 = call i64 @llvm.x86.sse42.crc32.64.64(i64 %a0, i64 %a1) + ret i64 %2 +} +declare i64 @llvm.x86.sse42.crc32.64.64(i64, i64) nounwind + define <4 x i32> @stack_fold_movd_load(i32 %a0) { ;CHECK-LABEL: stack_fold_movd_load ;CHECK: movd {{-?[0-9]*}}(%rsp), {{%xmm[0-9][0-9]*}} {{.*#+}} 4-byte Folded Reload -- 2.34.1