From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by sourceware.org (Postfix) with ESMTPS id BC4B63858D3C; Sun, 5 Nov 2023 15:58:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BC4B63858D3C Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=inria.fr Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=inria.fr ARC-Filter: OpenARC Filter v1.0.0 sourceware.org BC4B63858D3C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=192.134.164.104 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699199885; cv=none; b=Z9rs06IcI/zZPiSg0Fuo88qPAGNPIiI3/q3U4Cd+RlDFCAAH0GUduS6ZojAoLNcv5ojsReq4oGEMTgxhS3EAEkq6teac8bzelbvfhgBaZN2HwoZJDHOgro8sI9lRwFi5+sY6qputFfHEhcU9ewCaMItQ3PhKWoueT1FKziZeHlg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1699199885; c=relaxed/simple; bh=UALdLF711QegTBPH+1A57OYxyh6QXTvPzEaRPvgmoEo=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=sGRtH2eWlOhJh3MSmMTdZle3kS44alhADNGoUsvP9YK9E8KW29feACADGULJzm3D9MzS0FBdGJ08TAnCBN8Jind++SXUxCwbcvK5yWLxt7q1jvEWWWC0aazypM6zyGxVnDsFqHj18DcL2vKgMt6jfJz7qEV8rDDcM8sEbuRsxkI= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=inria.fr; s=dc; h=date:from:reply-to:to:cc:subject:in-reply-to:message-id: references:mime-version; bh=/3aMMNctbOILn74RvEZFWyHeycfpjod76autJsWmcF8=; b=cSDjo0gSA/Qdon0HW3JUDKIjtGPhiNoKnmLrXuN5W3UTMxJaY0bJOxFp bff7pMpFeGJ/eqSyQGpjwh998qEi7VUayRDrvccR7SNEFKBFl9rs9TkHH GT/yHLEqVNu2w7nxKnSqz4zalWfhjRMVDyqvepcJbFMuud8Y8eR+mH3wm I=; Authentication-Results: mail3-relais-sop.national.inria.fr; dkim=none (message not signed) header.i=none; spf=SoftFail smtp.mailfrom=marc.glisse@inria.fr; dmarc=fail (p=none dis=none) d=inria.fr X-IronPort-AV: E=Sophos;i="6.03,279,1694728800"; d="scan'208";a="70555944" Received: from 71.79.12.109.rev.sfr.net (HELO hippo) ([109.12.79.71]) by mail3-relais-sop.national.inria.fr with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Nov 2023 16:58:02 +0100 Date: Sun, 5 Nov 2023 16:58:01 +0100 (CET) From: Marc Glisse Reply-To: libstdc++@gcc.gnu.org To: Cassio Neri cc: libstdc++ , Gcc-patches Subject: Re: [PATCH] Remove unnecessary "& 1" in year_month_day_last::day() In-Reply-To: Message-ID: <2c114d39-4c87-65a1-3371-63e856cd0d37@inria.fr> References: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,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 List-Id: On Sun, 5 Nov 2023, Cassio Neri wrote: > When year_month_day_last::day() was implemented, Dr. Matthias Kretz realised > that the operation "& 1" wasn't necessary but we did not patch it at that > time. This patch removes the unnecessary operation. Is there an entry in gcc's bugzilla about having the optimizer handle this kind of optimization? unsigned f(unsigned x){ if(x>=32)__builtin_unreachable(); return 30|(x&1); // --> 30|x } (that optimization would come in addition to your patch, doing the optimization by hand is still a good idea) It looks like the criterion would be a|(b&c) when the possible 1 bits of b are included in the certainly 1 bits of a|c. -- Marc Glisse