From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from esa3.mentor.iphmx.com (esa3.mentor.iphmx.com [68.232.137.180]) by sourceware.org (Postfix) with ESMTPS id 3626C3858D28 for ; Wed, 21 Jun 2023 20:39:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 3626C3858D28 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=mentor.com X-IronPort-AV: E=Sophos;i="6.00,261,1681200000"; d="scan'208";a="9610008" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa3.mentor.iphmx.com with ESMTP; 21 Jun 2023 12:39:25 -0800 IronPort-SDR: 5eChtEk2PIC3RhoZ8xBUPKoFPlLbi8dd2EdkbMi33HlO40xSR0/rHhWfkBIOBx5H1qHvWdBDP5 78n9/OIi5XjcnMXhANSrlueNSIT9JsAeHjWUaGaFcv5zVI3/Pz4NvnOyp07SXUpHMgFHs11sv/ LlHPc2HgDAGCnb7MWohfcNc/uG1grtsUCsgOudQsTChDpaLvRP/ydtsWSgPNnlHkdfGnrijWbG nQ/G4sG2A4btZCPeCjXSP6+W01Frxxmx+A2CZ0XuavXfAGqtTcP/T4JKr2d3S8WIK6UG74/UO2 ZW8= Date: Wed, 21 Jun 2023 20:39:20 +0000 From: Joseph Myers To: Richard Biener CC: Richard Biener via Gcc-patches , liuhongt , , , Subject: Re: [PATCH] [vect]Use intermiediate integer type for float_expr/fix_trunc_expr when direct optab is not existed. In-Reply-To: Message-ID: <31edd667-fec7-7b0-a9af-5063d73922f@codesourcery.com> References: <20230602010015.2571612-1-hongtao.liu@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: svr-ies-mbx-15.mgc.mentorg.com (139.181.222.15) To svr-ies-mbx-10.mgc.mentorg.com (139.181.222.10) X-Spam-Status: No, score=-3105.9 required=5.0 tests=BAYES_00,HEADER_FROM_DIFFERENT_DOMAINS,KAM_DMARC_STATUS,SPF_HELO_PASS,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=no 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 Wed, 21 Jun 2023, Richard Biener via Gcc-patches wrote: > > > int32_t x = (int32_t)0x1.0p32; > > > int32_t y = (int32_t)(int64_t)0x1.0p32; > > > > > > sets x to 2147483647 and y to 0. > > Hmm, good question. GENERIC has a direct truncation to unsigned char > for example, the C standard generally says if the integral part cannot > be represented then the behavior is undefined. So I think we should be > safe here (0x1.0p32 doesn't fit an int). We should be following Annex F (unspecified value plus "invalid" exception for out-of-range floating-to-integer conversions rather than undefined behavior). But we don't achieve that very well at present (see bug 93806 comments 27-29 for examples of how such conversions produce wobbly values). -- Joseph S. Myers joseph@codesourcery.com