Message ID | 20231106132713.953501-7-adhemerval.zanella@linaro.org |
---|---|
State | Committed |
Commit | 80a40a9e14d9a01e3f70c5b37ecd1da83033b6de |
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 BFA583857C66 for <patchwork@sourceware.org>; Mon, 6 Nov 2023 13:28:02 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qk1-x730.google.com (mail-qk1-x730.google.com [IPv6:2607:f8b0:4864:20::730]) by sourceware.org (Postfix) with ESMTPS id F3FFB3858C53 for <libc-alpha@sourceware.org>; Mon, 6 Nov 2023 13:27:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org F3FFB3858C53 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org F3FFB3858C53 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::730 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699277251; cv=none; b=oKHngOQEc05UX4K0DleaHEoj2AW22JX9aCmZlS+Ul6WaNVuuJsjosMcMPVJE0VbfsD+2LqmHjCghhHk5nYPg8MyVCbJUB84Qk1NU2z7emoETTv47gLBMHdfJqrJpyGBTZF4NqToHTiItM7th5stK2xhP4JkEw+Qbu2RAyHe3Ay4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699277251; c=relaxed/simple; bh=U3TO7U68zV/VH1gLF1OEP+gE10yWlon2iqsc+5Y+0PU=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=eOsS/HfzCyzjU9KfMVwxjgVVxDdP8eRgltfb3ukcmHBlOiwRZ4iVEi7Elggj5gha9V+wqAaNYznq6BFNI88Oyl/S8fNYKlmCDdxbSoaESagjEpkbfkp620HdmlwXFwZrqmPfsTc0hFmyLIBI4V3Zha5IoVs5mHDfo11TErNPwRM= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-qk1-x730.google.com with SMTP id af79cd13be357-777754138bdso288384585a.1 for <libc-alpha@sourceware.org>; Mon, 06 Nov 2023 05:27:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1699277249; x=1699882049; darn=sourceware.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=ifhyVU0xuLEi9GZ7tRCQR01OfHuW0wdjDKCoj9nK3Cw=; b=XJY84i9ojXgeoIam+CO9yEATClt8FFciQsvum+xyJieu3+rmAZZejF1a0ppNEqJQBj NThvzPaPUDFAH38KYbUwp4mp9uHbd8LaglPItOh9AZ8p2zSAsbOXjtJzok3MmuTegS9f XVgHTdFk1lsbk86CNDNtkzc/3ZEx0buEDvDtV1DZ3npAodm67CxXQ3dLQ5YwiTpL+Luf mPqBF1VMQ9Qwnd2gbbCd4hcCgbkvMpe/vHhJhH1NzLDWMFNkDzFlpJxlclYkLjTOel3z 8dpVxT0SwT8TV8ivvikFZfM07wjXM+Cvj3GTJaTIjjzWCG+G4AH5OZFZXRJwoX0NjPjp QkzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699277249; x=1699882049; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ifhyVU0xuLEi9GZ7tRCQR01OfHuW0wdjDKCoj9nK3Cw=; b=KyaxIf4Z2edcMIdnqYySGF1JQjhmdRYfcjYtzF8Pu9NH8eecq6Gmd2VlbM8q1cxEsq K12IrB5gKrUKFwUQmprDAsKH/G09Gv6SoIXY4J5eVScCOBElVhfM8UzfqTB6YZ6NPMSK Up60YGfJ+ET+AcnlyMfJ9C7mE/A7ug4ecqBd5WvkpYSdwJxU9d0SP8FzdSJCf7iB5RKk aY0xUmnR3WaLcy5DDjaCQSjRWUsbedUaF8JDWPB2SoeaEidPwhLc1x5mJXzfUwNuhuvs IHgt9P0e0CCGbAPr2Ne+V80JF5Z+R+rLb0U2W5NXQQGIcjJnC6XrS4wwll9qDTK1uAqM qZcw== X-Gm-Message-State: AOJu0YzlJFMSlu6MDfaLeOFh8+AXp7GT3HSEfM0iOVesYjyfNklrv0pP RxNwYVLo3WpQcUmrEHRmFGvhH0rv1i8FJ/zV7yWx+g== X-Google-Smtp-Source: AGHT+IG7Do7W6teNDt70y+IkHmjfxGgVBoHBRlrsuXaRZ1BGEavJOM2SjZZ8Moo3fPzy4lB///yskA== X-Received: by 2002:a05:620a:2483:b0:76c:df5d:13a9 with SMTP id i3-20020a05620a248300b0076cdf5d13a9mr35907936qkn.58.1699277248687; Mon, 06 Nov 2023 05:27:28 -0800 (PST) Received: from mandiga.. ([2804:1b3:a7c0:a715:c1a0:7281:6384:2ee9]) by smtp.gmail.com with ESMTPSA id k3-20020a05620a142300b0076f12fcb0easm3272722qkj.2.2023.11.06.05.27.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Nov 2023 05:27:28 -0800 (PST) From: Adhemerval Zanella <adhemerval.zanella@linaro.org> To: libc-alpha@sourceware.org, Bruno Haible <bruno@clisp.org> Subject: [PATCH v2 6/7] alpha: Fix fesetexceptflag (BZ 30998) Date: Mon, 6 Nov 2023 10:27:12 -0300 Message-Id: <20231106132713.953501-7-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231106132713.953501-1-adhemerval.zanella@linaro.org> References: <20231106132713.953501-1-adhemerval.zanella@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-12.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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 |
Multiple floating-point environment fixes
|
|
Checks
Context | Check | Description |
---|---|---|
redhat-pt-bot/TryBot-apply_patch | success | Patch applied to master at the time it was sent |
linaro-tcwg-bot/tcwg_glibc_build--master-aarch64 | success | Testing passed |
linaro-tcwg-bot/tcwg_glibc_check--master-aarch64 | success | Testing passed |
linaro-tcwg-bot/tcwg_glibc_build--master-arm | success | Testing passed |
linaro-tcwg-bot/tcwg_glibc_check--master-arm | success | Testing passed |
Commit Message
Adhemerval Zanella
Nov. 6, 2023, 1:27 p.m. UTC
From: Bruno Haible <bruno@clisp.org>
It clears some exception flags that are outside the EXCEPTS argument.
It fixes math/test-fexcept on qemu-user.
---
sysdeps/alpha/fpu/fsetexcptflg.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
On 11/6/23 08:27, Adhemerval Zanella wrote: > From: Bruno Haible <bruno@clisp.org> > > It clears some exception flags that are outside the EXCEPTS argument. > > It fixes math/test-fexcept on qemu-user. > --- > sysdeps/alpha/fpu/fsetexcptflg.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/sysdeps/alpha/fpu/fsetexcptflg.c b/sysdeps/alpha/fpu/fsetexcptflg.c > index 70f3666a6e..63eb06845d 100644 > --- a/sysdeps/alpha/fpu/fsetexcptflg.c > +++ b/sysdeps/alpha/fpu/fsetexcptflg.c > @@ -27,7 +27,7 @@ __fesetexceptflag (const fexcept_t *flagp, int excepts) > tmp = __ieee_get_fp_control (); > > /* Set all the bits that were called for. */ > - tmp = (tmp & ~SWCR_STATUS_MASK) | (*flagp & excepts & SWCR_STATUS_MASK); > + tmp ^= (tmp ^ *flagp) & excepts & SWCR_STATUS_MASK; Does this actually work? Assume excepts is FE_INVALID, and *flagp bit 17 is 0. Assume currently bit 17 is 1. tmp ^ *flagp => bit 17 is still 1, even though bit 17 in flagp is 0. & excepts => bit 17 is still 1. & SWCR_STATUS_MASK => bit 17 is still 1. ^= => bit 17 is still 1. The operation will set a bit, but won't clear it? I would expect (taken from hppa code I wrote for that port): /* Clear all status bits we care about. */ tmp = tmp & ~(excepts & SWCR_STATUS_MASK); /* Install the new ones. */ tmp |= *flagp & excepts & SWCR_STATUS_MASK; > > /* And store it back. */ > __ieee_set_fp_control (tmp);
Carlos O'Donell wrote: > I would expect (taken from hppa code I wrote for that port): > > /* Clear all status bits we care about. */ > tmp = tmp & ~(excepts & SWCR_STATUS_MASK); > /* Install the new ones. */ > tmp |= *flagp & excepts & SWCR_STATUS_MASK; This code is correct. And, as I wrote in https://sourceware.org/bugzilla/show_bug.cgi?id=30998#c2 the code with the double-xor is faster, because it uses one less instruction. Basically the code you proposed masks the bits to clear and the bits to set separately. Whereas the code with the double-xor masks the bits to *change* - a single AND instead of two. > > /* Set all the bits that were called for. */ > > - tmp = (tmp & ~SWCR_STATUS_MASK) | (*flagp & excepts & SWCR_STATUS_MASK); > > + tmp ^= (tmp ^ *flagp) & excepts & SWCR_STATUS_MASK; > > Does this actually work? Yes: It computes the bits to *change*, then applies the mask, then applies the changes. For bits in the mask, it does tmp.bit[i] ^= tmp.bit[i] ^ (*flagp).bit[i]; which simplifies to tmp.bit[i] = (*flagp).bit[i]; For bits outside the mask, it does tmp.bit[i] ^= 0; i.e. it leaves the bit unchanged. I'm using this same idiom also in gnulib https://git.savannah.gnu.org/gitweb/?p=gnulib.git;a=blob;f=lib/fenv-except-state-set.c;h=2035f61e2714126e432c0c1f29450f18f58d81f1;hb=HEAD#l182 and I have verified that it works. > Assume excepts is FE_INVALID, and *flagp bit 17 is 0. > Assume currently bit 17 is 1. > > tmp ^ *flagp => bit 17 is still 1, even though bit 17 in flagp is 0. > & excepts => bit 17 is still 1. > & SWCR_STATUS_MASK => bit 17 is still 1. > ^= => bit 17 is still 1. In the last step: 1 xor 1 is 0. Bruno
On 11/6/23 12:36, Bruno Haible wrote: > I'm using this same idiom also in gnulib > https://git.savannah.gnu.org/gitweb/?p=gnulib.git;a=blob;f=lib/fenv-except-state-set.c;h=2035f61e2714126e432c0c1f29450f18f58d81f1;hb=HEAD#l182 > and I have verified that it works. That works for me. Thank you for verifying that. Reviewed-by: Carlos O'Donell <carlos@redhat.com>
diff --git a/sysdeps/alpha/fpu/fsetexcptflg.c b/sysdeps/alpha/fpu/fsetexcptflg.c index 70f3666a6e..63eb06845d 100644 --- a/sysdeps/alpha/fpu/fsetexcptflg.c +++ b/sysdeps/alpha/fpu/fsetexcptflg.c @@ -27,7 +27,7 @@ __fesetexceptflag (const fexcept_t *flagp, int excepts) tmp = __ieee_get_fp_control (); /* Set all the bits that were called for. */ - tmp = (tmp & ~SWCR_STATUS_MASK) | (*flagp & excepts & SWCR_STATUS_MASK); + tmp ^= (tmp ^ *flagp) & excepts & SWCR_STATUS_MASK; /* And store it back. */ __ieee_set_fp_control (tmp);