From patchwork Wed Jan 10 12:48:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 124087 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp5236004qgn; Wed, 10 Jan 2018 04:50:22 -0800 (PST) X-Google-Smtp-Source: ACJfBovYyUQY0AmzdHaMZp+6eqIbb99YpjLIKC/S6r9+BEnvTJ2vxa0i1GzixjcYukYh98pjTd7d X-Received: by 10.98.246.17 with SMTP id x17mr12279792pfh.46.1515588622349; Wed, 10 Jan 2018 04:50:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1515588622; cv=none; d=google.com; s=arc-20160816; b=c08UbLcIyag0kxDIobSZJXWgAMAiLOxMwS2dSC3AJcHQ8nOJTe/Lme5Ol8kpPvhAFI U3f4UGjO8DWx2Yj4nnv82FZlMCrO0m1PkaGLCwWQ5xCvs6wSvV0Sd2Yqix5ro0D2Dma+ yz2ARI1wTSvC2COpSqm5uMuq2p10q8wJiyiD1hQVTiEg/ITZqPUJUHHtbrp+Nihzm+Et n2uq+d2oRG71mB90ZtW6P1HIu3mpmQ+jj+hRxDR2oLqRn8gpa6TV6lDVNRqgO//d7T9W q2trID4n5XWxZjBmdnh98R5vGJC+UqiXZbv+74jn1zxZaKmCXH77fQOJopkRIGcK1WLm u+KA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :delivered-to:sender:list-help:list-post:list-archive:list-subscribe :list-unsubscribe:list-id:precedence:mailing-list:dkim-signature :domainkey-signature:arc-authentication-results; bh=xlyEGGeee0lWD17u8+dJYv6H/PU8HKCcKr38H0rrHXo=; b=golu565MSKUQiOR+AZAWghd0fH56oPb8KOPUokkTx/3jPoPmnqil4Zf8fWCgVBFIrI /tudikBKYm2G557Xe2DZVr8mFqagNU8OPrVdVsQuh5/PgxSwmC6lQshEvGFWmbXHddh2 4XCzFAkYRzTIyHI2mdwzIgFW1ph1S4Hns5J6yqTngD7Hps3SWomOZp1oeRcoxYP6//bQ SvDQfmNu9KRtfG/l/7Fb/AfdheO5IrF/a5hC2J70suopSKKiMO/ZQw2DGtVUFDVSGqiB D1jycVMf8kAL2vvPEPKgWtecAHE8wwIxq1ifRTrpl+405IwOZJa7tEagdDsdskY6k9QC xwLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=cdfKaYmr; spf=pass (google.com: domain of libc-alpha-return-89009-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-89009-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id d2si12060831pld.436.2018.01.10.04.50.22 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Jan 2018 04:50:22 -0800 (PST) Received-SPF: pass (google.com: domain of libc-alpha-return-89009-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=cdfKaYmr; spf=pass (google.com: domain of libc-alpha-return-89009-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-89009-patch=linaro.org@sourceware.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=Dd4gQPNg4EuUBDQ5L5HsEDfr7mWifS6 4NkgWzX888hgLQfwVILTMrmydFVT+1283dcH9d/QRCzuRmccxtFiCeqCzFDUIaza ekjihZlElgkasaq30rJBclr81gjVLHuBBuGSSZb6tq+WtG/RGzWW/8nRGPdeDWab G3gJJuuq8ZyE= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references; s=default; bh=HeNC8rpScw7REHZi9kFbjlbUbuk=; b=cdfKa YmrKb7ljhoZsibTHh4CX5jQCaELjthfTZc8n9r1ESysjts1VBSOfgW1ajzIyiS1S DE1XFhua716xAS5T9uZkYfHB3lCeFEGSudV/1MIqD+bJtvN+0dQAQjN6sBSkbSYI mYjc/n9fpaVg4oqtviJ6Cj2pzU54XBG4Unf0xw= Received: (qmail 130379 invoked by alias); 10 Jan 2018 12:48:43 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 127078 invoked by uid 89); 10 Jan 2018 12:48:39 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.9 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=Identify, leaves, basics X-HELO: mail-qt0-f193.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=xlyEGGeee0lWD17u8+dJYv6H/PU8HKCcKr38H0rrHXo=; b=eNhCSXoe5tbYvIQ+o54/gxmV2v9IRT132Ku3lOSE7FVlKYiJHpbHrv50RAWHV9D3uq kNgpKd27gFNgwFyhHmO+gFwLdUlpju0Yh2+tvbrEC8guFuK0Zi+kVkD3/eIh00l4BeKX HKOzxycyE819cFLe8RxGUYwnnOcBxVhVL6VLmYwuaUe0URCgOPANb7U7tFx2NdD+gXWt dRN2HF8AX8lCMjzYNQOnCjyuVYq15wQoQICFuuwY+7CrcZK1NaxaqZcoA9DNVd4KfkXd 48IYzDclhX8PYqAxixVRme0ibv4DKDNpafeCgeDe01oiFIi5um1TGTgmAZNYgfw7fbmu XewQ== X-Gm-Message-State: AKwxyteaYMBaN1cA6q2APYyibHpJPGAAqO8TVffaGZN6mlGu4REM3any v08yuta9eYlGo6XxKj5A5IMNVRD8Tl4= X-Received: by 10.237.42.21 with SMTP id c21mr2394133qtd.240.1515588513991; Wed, 10 Jan 2018 04:48:33 -0800 (PST) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Richard Henderson Subject: [PATCH v3 16/18] arm: Add string-fza.h Date: Wed, 10 Jan 2018 10:48:00 -0200 Message-Id: <1515588482-15744-17-git-send-email-adhemerval.zanella@linaro.org> In-Reply-To: <1515588482-15744-1-git-send-email-adhemerval.zanella@linaro.org> References: <1515588482-15744-1-git-send-email-adhemerval.zanella@linaro.org> From: Richard Henderson While arm has the more important string functions in assembly, there are still a few generic routines used. Use the UQSUB8 insn for testing of zeros. Checked on armv7-linux-gnueabihf Richard Henderson * sysdeps/arm/armv6t2/string-fza.h: New file. --- sysdeps/arm/armv6t2/string-fza.h | 69 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 sysdeps/arm/armv6t2/string-fza.h -- 2.7.4 diff --git a/sysdeps/arm/armv6t2/string-fza.h b/sysdeps/arm/armv6t2/string-fza.h new file mode 100644 index 0000000..8c38f87 --- /dev/null +++ b/sysdeps/arm/armv6t2/string-fza.h @@ -0,0 +1,69 @@ +/* Zero byte detection; basics. ARM version. + Copyright (C) 2018 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef STRING_FZA_H +#define STRING_FZA_H 1 + +#include + +/* This function returns at least one bit set within every byte + of X that is zero. */ + +static inline op_t +find_zero_all (op_t x) +{ + /* Use unsigned saturated subtraction from 1 in each byte. + That leaves 1 for every byte that was zero. */ + op_t ret, ones = (op_t)-1 / 0xff; + asm ("uqsub8 %0,%1,%2" : "=r"(ret) : "r"(ones), "r"(x)); + return ret; +} + +/* Identify bytes that are equal between X1 and X2. */ + +static inline op_t +find_eq_all (op_t x1, op_t x2) +{ + return find_zero_all (x1 ^ x2); +} + +/* Identify zero bytes in X1 or equality between X1 and X2. */ + +static inline op_t +find_zero_eq_all (op_t x1, op_t x2) +{ + return find_zero_all (x1) | find_zero_all (x1 ^ x2); +} + +/* Identify zero bytes in X1 or inequality between X1 and X2. */ + +static inline op_t +find_zero_ne_all (op_t x1, op_t x2) +{ + /* Make use of the fact that we'll already have ONES in a register. */ + op_t ones = (op_t)-1 / 0xff; + return find_zero_all (x1) | (find_zero_all (x1 ^ x2) ^ ones); +} + +/* Define the "inexact" versions in terms of the exact versions. */ +#define find_zero_low find_zero_all +#define find_eq_low find_eq_all +#define find_zero_eq_low find_zero_eq_all +#define find_zero_ne_low find_zero_ne_all + +#endif /* STRING_FZA_H */