Message ID | 20250123134308.1785777-9-aleksandar.rakic@htecgroup.com (mailing list archive) |
---|---|
State | New |
Headers |
Return-Path: <libc-alpha-bounces~patchwork=sourceware.org@sourceware.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 114AA3858C48 for <patchwork@sourceware.org>; Thu, 23 Jan 2025 14:03:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 114AA3858C48 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=h88ptRMv X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by sourceware.org (Postfix) with ESMTPS id BDDFE3858282 for <libc-alpha@sourceware.org>; Thu, 23 Jan 2025 13:43:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BDDFE3858282 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org BDDFE3858282 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::336 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1737639818; cv=none; b=JAYxJOxCoLS2iPsC3O8nuqO6/ge1G+gMkkLNoicuWa6UTwVDGNpU0af+3Zlxi/JizSVvzJW9lKQvbfhLRzyuAEN0pFavtfbAviTPThUOeELfqD4phxttyVMFtg8m4+Ve9yzD3spv0C3RC1hWJ89fOLsQQGzeLiP1JKMXa5lOauk= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1737639818; c=relaxed/simple; bh=QDWud4zjgJ01CHQ7/mxdsO+BUmA3XrAcK/GdaVtTntg=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=MsQ5+ozQjKP1WVnWU/4HBQUM/2BEg4hmAYyxP3bvnC6BXWvVYvRSD3bN3LsyllBu8fdJAe2qQwbcCKxOHoerK4k6jjt9lDszWxEQO0HZA/fFloCknqRzdcpYy6AURINbTNI4GyTErozD5Nx8d2mlIzo+Uu2wHQWqLbsUcH/BbZA= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BDDFE3858282 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-4361e82e3c3so1033225e9.0 for <libc-alpha@sourceware.org>; Thu, 23 Jan 2025 05:43:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1737639816; x=1738244616; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=uteVyvy729/dkj5GAvhhE/0TjOWAtl55t75qCavBnI8=; b=h88ptRMv6KXShuUAeFhDWcDFfMH8KPrH+SWZWXMP1uW9/T3XdCtr2EenL38AWilfl5 8GubG4ZIlCw+mzpWFYgWYCD8wU0zslBCMT4+fqruL0PcepNZr/9ySSVROVLD2bgekOdO P7JDCwOQl71ahM+Xi1tA1KwTKUMUqM2XV4VFa9rG5agtpuJjYNFUuQBTvwvuDjz+oU6x Ja8Y9W58bXMiKwuovU3vFsiokEGe6yebwMv0K6TtS+OUYclKpsGRDENt28pkAsJ0f9JM GFtfIjOmLpvqm697l9F7ZL/ZCG/6FLA9iJTEu3dm7ZpZMH9q2ZL/qgP+C8hmGkZq872q 0BMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737639816; x=1738244616; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=uteVyvy729/dkj5GAvhhE/0TjOWAtl55t75qCavBnI8=; b=mo320Nk0RMXcbWt0IEdi1LnwnKD5wFvK9EomlG5qth14qS8UFqF18bKJlooiCj1P+t L8XmyoREw/YvN3b9jvj3B7lVAqvITY3rDQjnSNsZ/oP70Um4Il7IMEx3g6XXx3b+4uHF 0GwiO///mOfoq9gbhhX1idC648JNlkd1yZvIIRohHc5pqpDAYMENV+/UTrz9w+2XM/5Z 2bjmFBQrYgfaschPe76Z4IMLgarUuboHXxKUTiXbX2cdLTQYPvPviud6ohSeueHhkSTA NU9+ZRvBPYobQBtr9dPyM9TcX2J/8pPO87aklg0cTYTR3htWtybEhrI+O8ujhq5UoNqi CHyQ== X-Gm-Message-State: AOJu0Yy7IWYYLdI5wz/joudc4OjLCxBDJv6fPvF4y/VFPLRjkro/cyZi 72Vl6SIU1rsiUFuNKM8Ii7qkAlpsWxQgPfeopT4xAu5n/VOF0NoCBz72MA== X-Gm-Gg: ASbGnctes/zpKH46f7+2PDhgxFySM+l5W6o2R0sH8SPpRxRCfPQLLo5DIh4nwq4me5y 1DxV1n1tfrI0IbhkFvo/jNcVn2ujdqMmChVrw2wuXMoT9m3aQR5RSUYazKpX9CFd83ab8NYjRUk eHSpNnfkrilTWziZEed9+IMCKzswrElWe8E1OyhjwT6IbaHxGxC8PNBO9mdry7muz0plrwMe8/6 oi1S3HFuOwBjH1GlXzuyGltjH4oK15Z4U7rbEJyB3YSzqgWoT5Ua/9HovMPoszBvBHzXgHSa3zh jVgajjbvLVRML49hg61cofLMWVE5 X-Google-Smtp-Source: AGHT+IEuEIhQBPd9I6fNR/SewDH0/l+Pom16K6FHbtXP5FaZIGL+lUmif1IZLBAlDyPw8uPnx0BVYw== X-Received: by 2002:a05:600c:cc8:b0:42c:aeee:e603 with SMTP id 5b1f17b1804b1-4389db13a7fmr91611955e9.7.1737639816177; Thu, 23 Jan 2025 05:43:36 -0800 (PST) Received: from L-H2N0CV05D839062.. ([79.175.87.218]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-438b318c1a2sm64597575e9.7.2025.01.23.05.43.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Jan 2025 05:43:35 -0800 (PST) From: Aleksandar Rakic <rakicaleksandar1999@gmail.com> X-Google-Original-From: Aleksandar Rakic <aleksandar.rakic@htecgroup.com> To: libc-alpha@sourceware.org Cc: aleksandar.rakic@htecgroup.com, djordje.todorovic@htecgroup.com, cfu@mips.com, Faraz Shahbazker <fshahbazker@wavecomp.com> Subject: [PATCH 07/11] Fix strcmp bug for little endian target Date: Thu, 23 Jan 2025 14:43:03 +0100 Message-Id: <20250123134308.1785777-9-aleksandar.rakic@htecgroup.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250123134308.1785777-1-aleksandar.rakic@htecgroup.com> References: <20250123134308.1785777-1-aleksandar.rakic@htecgroup.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-8.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Libc-alpha mailing list <libc-alpha.sourceware.org> List-Unsubscribe: <https://sourceware.org/mailman/options/libc-alpha>, <mailto:libc-alpha-request@sourceware.org?subject=unsubscribe> List-Archive: <https://sourceware.org/pipermail/libc-alpha/> List-Post: <mailto:libc-alpha@sourceware.org> List-Help: <mailto:libc-alpha-request@sourceware.org?subject=help> List-Subscribe: <https://sourceware.org/mailman/listinfo/libc-alpha>, <mailto:libc-alpha-request@sourceware.org?subject=subscribe> Errors-To: libc-alpha-bounces~patchwork=sourceware.org@sourceware.org |
Series |
Improve Mips target
|
|
Checks
Context | Check | Description |
---|---|---|
redhat-pt-bot/TryBot-apply_patch | fail | Patch failed to apply to master at the time it was sent |
Commit Message
Aleksandar Rakic
Jan. 23, 2025, 1:43 p.m. UTC
Strcmp gives incorrect result for little endian targets under the following conditions: 1. Length of 1st string is 1 less than a multiple of 4 (i.e len%4=3) 2. First string is a prefix of the second string 3. The first differing character in the second string is extended ASCII (that is > 127) Cherry-picked 7c709e878f836069bbdbf42979937794623cfa68 from https://github.com/MIPS/glibc Signed-off-by: Faraz Shahbazker <fshahbazker@wavecomp.com> Signed-off-by: Aleksandar Rakic <aleksandar.rakic@htecgroup.com> --- sysdeps/mips/strcmp.S | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
Comments
On Thu, 23 Jan 2025, Aleksandar Rakic wrote: > Strcmp gives incorrect result for little endian targets under > the following conditions: > 1. Length of 1st string is 1 less than a multiple of 4 (i.e len%4=3) > 2. First string is a prefix of the second string > 3. The first differing character in the second string is extended > ASCII (that is > 127) Is there a test in the glibc testsuite that fails before and passes after this patch? If not, one should be added.
On 23/01/25 10:43, Aleksandar Rakic wrote: > Strcmp gives incorrect result for little endian targets under > the following conditions: > 1. Length of 1st string is 1 less than a multiple of 4 (i.e len%4=3) > 2. First string is a prefix of the second string > 3. The first differing character in the second string is extended > ASCII (that is > 127) > > Cherry-picked 7c709e878f836069bbdbf42979937794623cfa68 > from https://github.com/MIPS/glibc > > Signed-off-by: Faraz Shahbazker <fshahbazker@wavecomp.com> > Signed-off-by: Aleksandar Rakic <aleksandar.rakic@htecgroup.com> > --- > sysdeps/mips/strcmp.S | 7 +++++-- > 1 file changed, 5 insertions(+), 2 deletions(-) > > diff --git a/sysdeps/mips/strcmp.S b/sysdeps/mips/strcmp.S > index 4878cd3aac..8d1bab12ec 100644 > --- a/sysdeps/mips/strcmp.S > +++ b/sysdeps/mips/strcmp.S > @@ -225,10 +225,13 @@ L(worddiff): > beq a0, zero, L(wexit01) > bne a0, a1, L(wexit01) > > - /* The other bytes are identical, so just subract the 2 words > - and return the difference. */ > +# if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ > + srl a0, a2, 24 > + srl a1, a3, 24 > +# else /* __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ */ > move a0, a2 > move a1, a3 > +# endif /* __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ */ > > L(wexit01): > subu v0, a0, a1 Can't you use the generic implementation instead? If I understand correctly, mips optimizes only the aligned case, while generic code also do word size read for unaligned case (with the MERGE and shift tricks). The only trick I see that mips implementation does is loop unrolling, which I think you can do by adding some compiler flags on mips Makefile.
diff --git a/sysdeps/mips/strcmp.S b/sysdeps/mips/strcmp.S index 4878cd3aac..8d1bab12ec 100644 --- a/sysdeps/mips/strcmp.S +++ b/sysdeps/mips/strcmp.S @@ -225,10 +225,13 @@ L(worddiff): beq a0, zero, L(wexit01) bne a0, a1, L(wexit01) - /* The other bytes are identical, so just subract the 2 words - and return the difference. */ +# if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ + srl a0, a2, 24 + srl a1, a3, 24 +# else /* __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ */ move a0, a2 move a1, a3 +# endif /* __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ */ L(wexit01): subu v0, a0, a1