From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by sourceware.org (Postfix) with ESMTPS id BD8803857007 for ; Thu, 16 Mar 2023 16:25:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BD8803857007 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=oracle.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=oracle.com Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 32GDo6o7030896; Thu, 16 Mar 2023 16:25:03 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : content-type : content-id : content-transfer-encoding : mime-version; s=corp-2022-7-12; bh=hHNmKnCIymhNZii+wEXW1BIj0EC50B/T0kROWfEfKWo=; b=YRw8O3/gpRkVRXHdUnItzWqePCytZqVqAA5mKnF0gwK85gembtGZ6zkRa0reM14KY9iF kvyxeCtYuU7MC1avE5LGStt+76cBmWsCJnWNNXnOIbYUP0qvqQasdvcxmBeB9Sub82eX Fdd5C90rfojb0i8NErRxgK95g9bowI03jjDPf2qW4S278W/63Rmnp8i0nKnQDrW6Doft V9pgv+Tjd7I3ztpyvLdel6RtcBJQ0XAd3DBhxqo87BX7gyIQUZpuVuE0FGk4Nqw4S8lT s0+L95N5DCCjfMWPFZdBqA74ucsqzmUe8lIJ77WibM3IlD/3NNWdlBhd7arej0wiKHSh Uw== Received: from phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (phxpaimrmta02.appoci.oracle.com [147.154.114.232]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3pbs28hmky-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 16 Mar 2023 16:25:02 +0000 Received: from pps.filterd (phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com [127.0.0.1]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (8.17.1.5/8.17.1.5) with ESMTP id 32GG5F2M029717; Thu, 16 Mar 2023 16:25:02 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2171.outbound.protection.outlook.com [104.47.55.171]) by phxpaimrmta02.imrmtpd1.prodappphxaev1.oraclevcn.com (PPS) with ESMTPS id 3pbqq5gva4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 16 Mar 2023 16:25:02 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hhAEQ82HGUuGh4/aCtuaAvk1KS0ADkoXP7p8PWgIoGCUlku5iApa/AFrqHdN1yxXrcYmUAMTg9zduV0z+V1uZin8afRcbnLdRTfKamIpi95DmSxzEU1TUqFQJNdKvy6rtu/mytRRqTFsIr7EXnIsZ6BwjOv3jbZmCKUB4Fhsc3HQfVUdSiIQOXq3XstCEq7uF8Rikv6gpfsQhB3MwV0Ka53tU8W28mGL8Bp47ouQ19Drzzz+56MDo58tOdhXx94Z35WPBOexfacNS7Wk1WcSEj9CgV/NSn6EmGflc93E5nZwfy3hN8o33DlK3a73bOo/eELYKeRyERsHY3uYc7IidA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=hHNmKnCIymhNZii+wEXW1BIj0EC50B/T0kROWfEfKWo=; b=XqldKvE18/cggAXXBXJcKT+4EBr/QQj289v6dsLYynXFz3bhEL+RAA5g7Wwyzy9RCtmdJSa4QShzcCZTq83rr2CpwGIEo5pM0TcIhtuNvs68bnrRPXSJp6szvzepcrjB9oCuGVji/cpVmGBVg/aOSFhso9dXC/7G5piF5VYkWmxyHSdYNDxzNdSzoTKq24v141iIJZCL6QuwszOSaz+nOL16Ld6INSDgO7cBxvvifMBwujFB+o2nHXWE2pkYZgJ2A6rrZ9goOcs8Ft9d3HfPw8AfW+0X/whc5NdC2C8kZuv/oZs6hHaIVLstPLeOfgn2pRaet/4mzoHNwGJxXutRAw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=hHNmKnCIymhNZii+wEXW1BIj0EC50B/T0kROWfEfKWo=; b=r4NdVYHTmDClucXiV1WsniAmsmoat7vv0wrS5WDZtVBOiyZiFi0odjnbnqJIVTzcjm+kSlcaIME+RKUd3rsonGh1f6+sqtEenLrbkFTMMHhfG1P/dw4OfCc/ITy0I7bLdO8AHLbdLfczbLGOwRRL1wAQe5s1EzsEdH6crHas50U= Received: from CH2PR10MB4344.namprd10.prod.outlook.com (2603:10b6:610:af::19) by CH0PR10MB7536.namprd10.prod.outlook.com (2603:10b6:610:184::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.24; Thu, 16 Mar 2023 16:24:57 +0000 Received: from CH2PR10MB4344.namprd10.prod.outlook.com ([fe80::7030:ed2e:20d0:cd5b]) by CH2PR10MB4344.namprd10.prod.outlook.com ([fe80::7030:ed2e:20d0:cd5b%8]) with mapi id 15.20.6178.029; Thu, 16 Mar 2023 16:24:57 +0000 From: Qing Zhao To: "richard.earnshaw@arm.com" CC: gcc Patches , Richard Sandiford Subject: Should -ffp-contract=off the default on GCC? Thread-Topic: Should -ffp-contract=off the default on GCC? Thread-Index: AQHZWCPZiydRtZY2n0eNKwgsci2pvg== Date: Thu, 16 Mar 2023 16:24:57 +0000 Message-ID: <6659A77B-DA2F-40A6-BDBD-E8B29B9E901D@oracle.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: Apple Mail (2.3696.120.41.1.2) x-ms-publictraffictype: Email x-ms-traffictypediagnostic: CH2PR10MB4344:EE_|CH0PR10MB7536:EE_ x-ms-office365-filtering-correlation-id: af813b9c-5e60-4ee5-3c0c-08db263afb92 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 41lHaqTSjQM1zLyFeM9LYzPUNynQ+JK+smGx55FkHE3qjSSTP0AcXzedgDh5aFXcn7CCnDkp3JlbkeYHltN/GDdX/CPRybCdmmR3jO/B8jBwtQLFPsaAZc9amNBiw1dF/rzz/fL6w7cmo+YFibgkFEPZzj9Ky127ToOUekOTKCeXGPqwrbsnhrnPFmEs5x+OAl00g08BiTKfm5urDvGPi9LEHZL21d9RVSDAaejFyOZVudI7+rcSJ7GBmTu0rMGHH97ElJg1tvWwMpU86w/1chHL8szSJBJOfDC5OttrY7olkmVvnrNOE/tcLE6Gpm52CCPowwtfmEM41iWElCMqEbfHJDRmMNXVtK4kbJcr4amFUaoNk1fsB23hdlvbw/SOJcVlLD58rEVwAqKLt8lmXDL/pnEEl5hMSGLr6QoLlCrjP+PZTZefxg7rpf+CzaFeVFiqHKJ5fTt1Hx84JYqHq1s62KYHQ7iDfV/8gQtjZ9VPigXg+5iTH3YPXDnZKIgGpEPFuubIoTFEHeaSYFQfENpsKPQ9yF2IVAu9Q35IQYd4qUkls7mgUy85oLbC47IcAbo0HbTih0AfzCQ3JG3dXEjOywk5IRnDJtQfSh1/tyOHsElKcOa2HEP3Ijm/1CVzpQqjldpEOGZt/htJR0kjhHOf6dFC5qeYcm/2VwQfif3e/7YgfjXsCxqY4lVfC34efSAKh+7Z7TSRFS5DEw41sxY/1OITdbpBK8Ep+NTh1NzMvZ5ExkYmeunlqp0sV6rTzC5QgAisTyj/+4rRTh4CNw== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CH2PR10MB4344.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(346002)(136003)(396003)(376002)(39860400002)(366004)(451199018)(122000001)(38100700002)(2906002)(478600001)(76116006)(316002)(86362001)(6506007)(2616005)(54906003)(966005)(6916009)(33656002)(36756003)(71200400001)(8676002)(66946007)(8936002)(66556008)(64756008)(186003)(6512007)(91956017)(4326008)(66476007)(66446008)(5660300002)(6486002)(44832011)(83380400001)(41300700001)(38070700005)(45980500001);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?LjNC38VIZaINoE0w7rAVCxPE75VJwrHGetfOXXDHPuEBAJKmtn6Hze0tDSMM?= =?us-ascii?Q?hml/ZKq2qNhrYgCp7gazas3RmYPOch/ehH8XZBvKggtM9zvtHx7KPxJ69X5E?= =?us-ascii?Q?e2zvQeQH506m+iSTFnrx/FJ1iSBbzr6sKRUQbmS5XREVZ+ZCAsuhXIO6FwDU?= =?us-ascii?Q?8ONqabk1RoWY7ZEoCQklr3eZdZR030KG0Qs0Qdzmgf0T35xX2xc0hHE9csFS?= =?us-ascii?Q?isuaktmH5cM4OOqQ6ILQ2jqRGBA5vmxIw+HU6ZS+kyz+mdRKnbauI5rLAm3O?= =?us-ascii?Q?z4vp4GmVBF7zEW3Qad4xdy9c+YrlydcmuZszzjDEag5DnoC77k1wsaOmzkyE?= =?us-ascii?Q?ry5CmtkfiQDwpS5LtqK0DIeusL9ft05YdyQINffqJ13sEgN4j43skgAQ88xQ?= =?us-ascii?Q?ZwdjvtO/4G9gkeASw0J2JTvW30Pfj5nkMdia61z2wpQ5dmGkP0UBnoXbs1sE?=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+OHQo5W6HU0fm+8yxTIplKKtPig?= =?us-ascii?Q?wXcEmVpVfZUaaPed7bX6lQmHPnxq/Pa7DHOkjv3L5TqKBUlCfKdZ0L7psxZ8?= =?us-ascii?Q?p0r6oHvbPGMRcsdBPis+dgoPyEv5n4sGSCDTuFW3VG8C1bqPsuDt+GD7Nv9F?= =?us-ascii?Q?sCBefDqvmEekQlT6HI8tuqnBWb55JAl3k70r4mJwEtzo/w3MDpj1dhMtee2w?= =?us-ascii?Q?Bq5vVLD4DKClCYARGUuLg4VsFmBeSfdmnHqKHYAXOCBtsUUdD3WlTlKJ0h7e?= =?us-ascii?Q?Vbk2r61e0WAMdnw3eVpZNUQ=3D?= Content-Type: text/plain; charset="us-ascii" Content-ID: <9C201B41EEDBE046BC2C369DC2FB5AE0@namprd10.prod.outlook.com> Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: Hn6GBikFI675pvEEh0iI2Q1zF/KzyaFDmJ0Y7kG19YLPBL+Wht7EpJXOtRUkPUyU+Q2LZwujdFQHkzZ468CP032rRS0QfXHzMbMloF1zp2Rteugm4836ZYMmhJvnn4aUn7gERwUyp/tjI6lKqlNL8u6gZK+wgRFzd2Hd5pxiGG8Zu9Er8PxxYc2vb4X76tzzFZ0Y18PcPmCHZvzMaTlVSZJsCYCEhbGcfdxjyIgE7rLuhAf7Vayr1nY6X5O6SKErzV19rMv/z+qieDgky1KpCw6EgC8mDxqspEMrXFnddpVE3slEOiNQvxU69Wkk4NC4Egbwoq6GyTr6yLY+nUkmTFujerwhho5Z9bpa4j8pQtHkyW07BFMJsI4kfjzNHAuP15KGC2NHPw0L16GTFDjgahkumydQRBs+Rc9qAq+6G7mG8p58DWD6Wy3y/0EcsVVbJgmb0QrgmaHgv2NYnQ+hRlJOijZ1pwGq07bCRqiSNsuqtFD8LAUmtICU2yT4qSAKgaQe+9F/Mzb2GW2XzVxonI5m/QVzuXF7W1bk2pq48s0OMWgCoC7i1GKmk3Ng4Uck2qsYrHpotoCtppiYF2TXUEZBepZIj28GZWxpCTCpn6b4VrO+UBTskpR9Q/zV2zvcU5p41LDSG5A1y1aQJauY7eeLcxUUS1XNbMqLkdKyFiYhIXUo+wPINjv0j0MvUET5DpZFr50Gw2SDXOAAV6jw3zaotk5MXRWeBRyodPISBZ8ksh0YRb2NBkblMAgNHp8Kmgn109Uhq4y0aK8tck9Ffg== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: CH2PR10MB4344.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: af813b9c-5e60-4ee5-3c0c-08db263afb92 X-MS-Exchange-CrossTenant-originalarrivaltime: 16 Mar 2023 16:24:57.3524 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: ip4Bo26wLVYwEqOhHu27S2JuTMce/P40RGdgIUsLtK/dltdyhvatyepipGVhiHI7AMEZYa8ITG+zu4whuwFeLw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR10MB7536 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-03-16_10,2023-03-16_01,2023-02-09_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxlogscore=844 bulkscore=0 mlxscore=0 adultscore=0 suspectscore=0 phishscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2303150002 definitions=main-2303160130 X-Proofpoint-GUID: PWJc6lyWgCjTV0X5uzCxiC4vV11cfSOG X-Proofpoint-ORIG-GUID: PWJc6lyWgCjTV0X5uzCxiC4vV11cfSOG X-Spam-Status: No, score=-5.4 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,KAM_SHORT,RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,TXREP 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: Hi, Recently, we discovered some floating point precision diffs when using GCC8= to build our=20 application on arm64: After some investigation, it turns out that this is d= ue to the=20 -ffp-contract=3Dfast option that is on by default. Therefore, we have to ex= plicitly add=20 -ffp-contract=3Doff and do a full-rebuild. =20 GCC by default turns -ffp-contract=3Dfast on. https://gcc.gnu.org/onlinedocs/gcc-8.5.0/gcc/Optimize-Options.html#Optimize= -Options https://gcc.gnu.org/onlinedocs/gcc-12.2.0/gcc/Optimize-Options.html#Optimiz= e-Options " -ffp-contract=3Dstyle -ffp-contract=3Doff disables floating-point expression contraction. -ffp-co= ntract=3Dfast enables floating-point expression contraction such as forming of fused multiply-add= operations if=20 the target has native support for them. -ffp-contract=3Don enables floating= -point expression contraction if allowed by the language standard. This is currently not impl= emented and=20 treated equal to -ffp-contract=3Doff. The default is -ffp-contract=3Dfast. " This can be shown by a small example for arm64 with gcc8.5 in https://godbo= lt.org/z/MxYfnG8TE.=20 Only when adding -std=3Dc89 explicitly, this transformaton is off. another exmaple also shows that Clang and MSVC only allow this transformati= on when speifiying ffast-math and fp:fast: https://godbolt.org/z/o54bYfPbP=20 When searching online, we found that there were similar discussions recentl= y on the exact same issue: https://github.com/dotnet/runtime/issues/64604 https://github.com/dotnet/runtime/issues/64591 a summary of these discussions is: 1. "fmadd" is a fused operation and will return a different result for many= inputs; =20 2. therefore, -ffp-contract=3Dfast is not a safe optimization to be on by d= efault; 3. Clang and MSVC only allow this when specifying ffast-math and fp:fast si= nce this is not an IEEE754 compliant optimization; 4. The reasons why GCC turns on this option by default are: A. GNU C language spec allows such transformation.=20 B. this did not expose real problem for most X86/X64 apps previously sinc= e FMA instructions didn't exist until 2013 when the FMA3 instruction set was added, and a= lso these instructions were not always available..=20 5. Arm64 has fused multiply-add instructions as "baseline" and are always a= vailable. therefore -ffp-contract=3Dfast exposed more serious problems on Arm64 platforms. =20 our major question: Should GCC turn off -ffp-contract=3Dfast by default since it's not IEEE754 = compliant and more modern processors have the FMA instructions available by default? Thanks. Qing=