From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx08-006a4e02.pphosted.com (mx08-006a4e02.pphosted.com [143.55.148.243]) by sourceware.org (Postfix) with ESMTPS id EA0083858C53 for ; Wed, 26 Apr 2023 06:45:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org EA0083858C53 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=iram.es Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=iram.es Received: from pps.filterd (m0316695.ppops.net [127.0.0.1]) by mx08-006a4e02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 33Q6aFb4007292; Wed, 26 Apr 2023 08:45:56 +0200 Received: from mta-out03.sim.rediris.es (mta-out03.sim.rediris.es [130.206.24.45]) by mx08-006a4e02.pphosted.com (PPS) with ESMTPS id 3q6k5md3gq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 26 Apr 2023 08:45:56 +0200 Received: from mta-out03.sim.rediris.es (localhost.localdomain [127.0.0.1]) by mta-out03.sim.rediris.es (Postfix) with ESMTPS id AE73B3122807; Wed, 26 Apr 2023 08:45:35 +0200 (CEST) Received: from localhost (localhost.localdomain [127.0.0.1]) by mta-out03.sim.rediris.es (Postfix) with ESMTP id 9BD143122808; Wed, 26 Apr 2023 08:45:35 +0200 (CEST) X-Amavis-Modified: Mail body modified (using disclaimer) - mta-out03.sim.rediris.es Received: from mta-out03.sim.rediris.es ([127.0.0.1]) by localhost (mta-out03.sim.rediris.es [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 0FmwkPgfqKUh; Wed, 26 Apr 2023 08:45:35 +0200 (CEST) Received: from lt-gp.iram.es (haproxy02.sim.rediris.es [130.206.24.70]) by mta-out03.sim.rediris.es (Postfix) with ESMTPA id 4B1EB3122807; Wed, 26 Apr 2023 08:45:35 +0200 (CEST) Date: Wed, 26 Apr 2023 08:45:33 +0200 From: Gabriel Paubert To: Andy Cc: Basile Starynkevitch , gcc@gcc.gnu.org Subject: Re: a small C (naive) program faster with clang than with gcc Message-ID: References: <279ab746-8a75-6396-2907-0c893ea1be1b@starynkevitch.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: Content-Transfer-Encoding: quoted-printable X-Proofpoint-GUID: woxW6PnXMbA4NT4eE5JVIhZzy6H5jUKm X-Proofpoint-ORIG-GUID: woxW6PnXMbA4NT4eE5JVIhZzy6H5jUKm X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-04-26_02,2023-04-25_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbounddefault_notspam policy=outbounddefault score=0 mlxlogscore=955 suspectscore=0 priorityscore=1501 bulkscore=0 spamscore=0 impostorscore=0 adultscore=0 malwarescore=0 mlxscore=0 phishscore=0 lowpriorityscore=0 clxscore=1011 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303200000 definitions=main-2304260061 X-Spam-Status: No, score=-1.6 required=5.0 tests=BAYES_00,KAM_DMARC_STATUS,RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H2,RDNS_DYNAMIC,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 Tue, Apr 25, 2023 at 06:01:22PM +0200, Andy via Gcc wrote: > I see it in godbolt > GCC compiles to: > movsx eax, BYTE PTR [rdi+2] > cmp al, 9 > ja .L42 > Clang: > movzx edx, byte ptr [rdi + 2] > cmp edx, 9 > ja .LBB0_40 >=20 >=20 > GCC extend with sign, Clang with zero. > cmp with 32 bit register is apparently faster than 8bit What happens if you compile with -funsigned-char? There may be also some alignment issue, after all cmp al,9 is 2 bytes while cmp edx,9 is 6. Gabriel >=20 > pon., 24 kwi 2023 o 17:34 Basile Starynkevitch > napisa=C5=82(a): > > > > Hello all, > > > > > > Consider the naive program (GPLv3+) to solve the cryptaddition > > > > `NEUF` + `DEUX` =3D `ONZE` > > > > onhttps://github.com/bstarynk/misc-basile/blob/master/CryptArithm/neu= f%2Bdeux%3Donze/naive0.c (commit0d1bd0e > > ) > > > > > > On Linux/x86-64 that source code compiled with gcc-12 -O3 is twice as > > slower as with clang -O3 > > > > (Debian/Sid or Ubuntu/22/10) > > > > Feel free to add it to some testsuite! > > > > > > Thanks > > > > > > -- > > Basile Starynkevitch > > (only mine opinions / les opinions sont miennes uniquement) > > 92340 Bourg-la-Reine, France > > web page: starynkevitch.net/Basile/ & refpersys.org