x86: Replace __glibc_unlikely with __builtin_expect

Message ID CAMe9rOr2ZMexqSnpfGHFLJWGEteZAprv4xTgOKC-3U4-ogSLPQ@mail.gmail.com
State New
Headers show
Series
  • x86: Replace __glibc_unlikely with __builtin_expect
Related show

Commit Message

Jonathan Wakely via Gcc-patches July 14, 2020, 9:07 p.m.
On Mon, Jul 13, 2020 at 9:44 AM Jeff Law <law@redhat.com> wrote:
>

> On Sun, 2020-05-31 at 16:10 -0700, H.J. Lu via Gcc-patches wrote:

> > cmpstrnsi expander may pass the actual string length directly to cmpstrnqi

> > patterns.  For cmpstrnsi, one of the strings must be a constant and

> > expand_builtin_strncmp rewrites the length argument to be the minimum of

> > the const string length and the actual string length.  But it is not the

> > case for cmpmemsi.  Pass a copy of the string length to cmpstrnqi patterns

> > to avoid changing the actual string length by cmpstrnqi patterns.

> >

> > gcc/

> >

> >       PR target/95443

> >       * config/i386/i386.md (cmpstrnsi): Pass a copy of the string

> >       length to cmpstrnqi patterns.

> >

> > gcc/testsuite/

> >

> >       PR target/95443

> >       * gcc.target/i386/pr95443-1.c: New test.

> >       * gcc.target/i386/pr95443-2.c: Likewise.

> OK

> jeff

> >


I checked in this patch to replace glibc specific __glibc_unlikely with
__builtin_expect.

-- 
H.J.

Patch

From f80a36c44d3a9c92bd48981f2bc9e88abebafbc5 Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Tue, 14 Jul 2020 14:01:51 -0700
Subject: [PATCH] x86: Replace __glibc_unlikely with __builtin_expect

Replace glibc specific __glibc_unlikely with __builtin_expect.

	PR target/95443
	* gcc.target/i386/pr95443-1.c (simple_strstr): Replace
	__glibc_unlikely with __builtin_expect.
---
 gcc/testsuite/gcc.target/i386/pr95443-1.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gcc/testsuite/gcc.target/i386/pr95443-1.c b/gcc/testsuite/gcc.target/i386/pr95443-1.c
index 292ff16afdd..698dfa02189 100644
--- a/gcc/testsuite/gcc.target/i386/pr95443-1.c
+++ b/gcc/testsuite/gcc.target/i386/pr95443-1.c
@@ -49,7 +49,7 @@  simple_strstr (const char *haystack, const char *needle)
 
   while (1)
     {
-      if (__glibc_unlikely (hs > end))
+      if (__builtin_expect (hs > end, 0))
 	{
 	  end += strnlen ((const char*)end + m1 + 1, 2048);
 	  if (hs > end)
-- 
2.26.2