From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by sourceware.org (Postfix) with ESMTPS id 39F10385803E for ; Tue, 3 May 2022 08:28:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 39F10385803E Received-SPF: SoftFail (mail2-relais-roc.national.inria.fr: domain of Paul.Zimmermann@inria.fr is inclined to not designate 152.81.10.51 as permitted sender) identity=mailfrom; client-ip=152.81.10.51; receiver=mail2-relais-roc.national.inria.fr; envelope-from="Paul.Zimmermann@inria.fr"; x-sender="Paul.Zimmermann@inria.fr"; x-conformance=spf_only; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:192.134.164.0/24 mx ~all" Received-SPF: None (mail2-relais-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@tomate) identity=helo; client-ip=152.81.10.51; receiver=mail2-relais-roc.national.inria.fr; envelope-from="Paul.Zimmermann@inria.fr"; x-sender="postmaster@tomate"; x-conformance=spf_only X-IronPort-AV: E=Sophos;i="5.91,194,1647298800"; d="scan'208";a="34414172" Received: from tomate.loria.fr (HELO tomate) ([152.81.10.51]) by mail2-relais-roc.national.inria.fr with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 03 May 2022 10:28:39 +0200 Date: Tue, 03 May 2022 10:28:39 +0200 Message-Id: From: Paul Zimmermann To: gcc-help@gcc.gnu.org CC: sibid@uvic.ca, stephane.glondu@inria.fr Subject: slowdown with -std=gnu18 with respect to -std=c99 X-Spam-Status: No, score=-3.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, KAM_NUMSUBJECT, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-help@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-help mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 May 2022 08:28:42 -0000 Hi, I observe a slowdown of some code compiled with gcc when I use -std=gnu18 instead of -std=c99. My computer is a i5-4590, and I use gcc version 11.3.0 (Debian 11.3.0-1). To reproduce: $ git clone https://gitlab.inria.fr/core-math/core-math.git $ cd core-math $ CORE_MATH_PERF_MODE=rdtsc CFLAGS="-O3 -march=native -ffinite-math-only -std=gnu18" ./perf.sh exp10f GNU libc version: 2.33 GNU libc release: release 31.746 11.780 $ CORE_MATH_PERF_MODE=rdtsc CFLAGS="-O3 -march=native -ffinite-math-only -std=c99" ./perf.sh exp10f GNU libc version: 2.33 GNU libc release: release 21.514 11.751 The difference is seen between the first figures in each run (31.746 and 21.514), which indicate the average number of cycles of the exp10f function from the core-math library. The code is very simple (a few dozen lines): https://gitlab.inria.fr/core-math/core-math/-/blob/master/src/binary32/exp10/exp10f.c Some more remarks: * this slowdown does not happen on all machines, for example it does not appear on an AMD EPYC 7282 with gcc gcc version 10.2.1 (Debian 10.2.1-6). * this slowdown disappears when I replace __builtin_expect(ex>(127+6), 0) by ex>(127+6) at line 45 of the code, however that branch is never taken in the above experiment. Does anyone have a clue? Best regards, Paul Zimmermann