[PATCH] D87506: [SystemZ] Make LibFunc_bcmp unavailable
Jonas Paulsson via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 11 04:28:21 PDT 2020
jonpa created this revision.
jonpa added a reviewer: uweigand.
Herald added a subscriber: hiraditya.
Herald added a project: LLVM.
jonpa requested review of this revision.
Memcmp has hardware support on SystemZ, so there is no need or benefit of sometimes using bcmp .
This patch makes bcmp unavailable on SystemZ, so that memcmp:s are not replaced by calls to it.
https://reviews.llvm.org/D87506
Files:
llvm/lib/Analysis/TargetLibraryInfo.cpp
llvm/test/Transforms/InstCombine/memcmp-3.ll
Index: llvm/test/Transforms/InstCombine/memcmp-3.ll
===================================================================
--- /dev/null
+++ llvm/test/Transforms/InstCombine/memcmp-3.ll
@@ -0,0 +1,18 @@
+; RUN: opt -S -O3 < %s | FileCheck %s
+; REQUIRES: systemz-registered-target
+;
+; Test that memcmp is not replaced with bcmp on SystemZ.
+
+target datalayout = "E-m:e-i1:8:16-i8:8:16-i64:64-f128:64-v128:64-a:8:16-n32:64"
+target triple = "s390x-unknown-linux-gnu"
+
+; CHECK-LABEL: @fun
+; CHECK: call signext i32 @memcmp
+define i32 @fun(i8* %0, i8* %1) {
+ %3 = call signext i32 @memcmp(i8* %0, i8* %1, i64 2)
+ %4 = icmp eq i32 %3, 0
+ %5 = zext i1 %4 to i32
+ ret i32 %5
+}
+
+declare dso_local signext i32 @memcmp(i8*, i8*, i64)
Index: llvm/lib/Analysis/TargetLibraryInfo.cpp
===================================================================
--- llvm/lib/Analysis/TargetLibraryInfo.cpp
+++ llvm/lib/Analysis/TargetLibraryInfo.cpp
@@ -143,7 +143,8 @@
TLI.setUnavailable(LibFunc_sincospif_stret);
}
- if (!hasBcmp(T))
+ // Memcmp has hardware support on SystemZ, so no need for bcmp.
+ if (!hasBcmp(T) || T.isSystemZ())
TLI.setUnavailable(LibFunc_bcmp);
if (T.isMacOSX() && T.getArch() == Triple::x86 &&
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D87506.291182.patch
Type: text/x-patch
Size: 1238 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200911/defa7e7e/attachment.bin>
More information about the llvm-commits
mailing list