[PATCH] D59593: [ExpandMemCmp] Trigger on bcmp too.
Clement Courbet via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 20 04:53:33 PDT 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rL356550: [ExpandMemCmp] Trigger on bcmp too. (authored by courbet, committed by ).
Changed prior to commit:
https://reviews.llvm.org/D59593?vs=191464&id=191478#toc
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D59593/new/
https://reviews.llvm.org/D59593
Files:
llvm/trunk/lib/CodeGen/ExpandMemCmp.cpp
llvm/trunk/test/CodeGen/X86/memcmp-optsize.ll
Index: llvm/trunk/lib/CodeGen/ExpandMemCmp.cpp
===================================================================
--- llvm/trunk/lib/CodeGen/ExpandMemCmp.cpp
+++ llvm/trunk/lib/CodeGen/ExpandMemCmp.cpp
@@ -823,7 +823,8 @@
}
LibFunc Func;
if (TLI->getLibFunc(ImmutableCallSite(CI), Func) &&
- Func == LibFunc_memcmp && expandMemCmp(CI, TTI, TL, &DL)) {
+ (Func == LibFunc_memcmp || Func == LibFunc_bcmp) &&
+ expandMemCmp(CI, TTI, TL, &DL)) {
return true;
}
}
Index: llvm/trunk/test/CodeGen/X86/memcmp-optsize.ll
===================================================================
--- llvm/trunk/test/CodeGen/X86/memcmp-optsize.ll
+++ llvm/trunk/test/CodeGen/X86/memcmp-optsize.ll
@@ -10,6 +10,7 @@
@.str = private constant [65 x i8] c"0123456789012345678901234567890123456789012345678901234567890123\00", align 1
declare i32 @memcmp(i8*, i8*, i64)
+declare i32 @bcmp(i8*, i8*, i64)
define i32 @length2(i8* %X, i8* %Y) nounwind optsize {
; X86-LABEL: length2:
@@ -982,3 +983,31 @@
ret i1 %c
}
+define i32 @bcmp_length2(i8* %X, i8* %Y) nounwind optsize {
+; X86-LABEL: bcmp_length2:
+; X86: # %bb.0:
+; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
+; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
+; X86-NEXT: movzwl (%ecx), %ecx
+; X86-NEXT: movzwl (%eax), %edx
+; X86-NEXT: rolw $8, %cx
+; X86-NEXT: rolw $8, %dx
+; X86-NEXT: movzwl %cx, %eax
+; X86-NEXT: movzwl %dx, %ecx
+; X86-NEXT: subl %ecx, %eax
+; X86-NEXT: retl
+;
+; X64-LABEL: bcmp_length2:
+; X64: # %bb.0:
+; X64-NEXT: movzwl (%rdi), %eax
+; X64-NEXT: movzwl (%rsi), %ecx
+; X64-NEXT: rolw $8, %ax
+; X64-NEXT: rolw $8, %cx
+; X64-NEXT: movzwl %ax, %eax
+; X64-NEXT: movzwl %cx, %ecx
+; X64-NEXT: subl %ecx, %eax
+; X64-NEXT: retq
+ %m = tail call i32 @bcmp(i8* %X, i8* %Y, i64 2) nounwind
+ ret i32 %m
+}
+
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D59593.191478.patch
Type: text/x-patch
Size: 1889 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190320/819e7aab/attachment.bin>
More information about the llvm-commits
mailing list