From patchwork Fri Aug 2 12:43:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juergen Christ X-Patchwork-Id: 1968335 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=ibm.com header.i=@ibm.com header.a=rsa-sha256 header.s=pp1 header.b=Cy/yzqiZ; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Wb59J3KHyz1yYq for ; Fri, 2 Aug 2024 22:43:32 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A1F423858289 for ; Fri, 2 Aug 2024 12:43:30 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by sourceware.org (Postfix) with ESMTPS id 01FC13858D20 for ; Fri, 2 Aug 2024 12:43:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 01FC13858D20 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linux.ibm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 01FC13858D20 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=148.163.158.5 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722602591; cv=none; b=DfK8gJzeZpD++2UstzFEQtqmfpOgSKFF3u9MlVdXZgqjnaLmslKPcOpYWZg6nKuu6EOVvHgIkgOysoOX7dNhB/kr7UzJdcc8iMAkBu1AM621Dd//Mn2se6NhlW+QEPoVEcbgt53HeOv+WB0zrz1VFKTwB28qQoNc518nY8oWKj0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722602591; c=relaxed/simple; bh=wStWwcqqemChjUEP/lbGPKgUMEZRSyTnrnRnsWwTWLo=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=ILpJiSzoOFlKRV394JVyl0jk+haJGqAQXeMIEc7iWaI5IM0hiWlFxzvFSAdm4gQKpiVul4Cg+J4j14hHbEMTYhHOGSZ0kmgw3QowlwL/tl6KYpykj7kBOT/KiBKaIkZMi45TPb9TsxMA3cbUDXjA7wA20voCzdTEAPYiB9Ci8G0= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from pps.filterd (m0360072.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 472ASi0E020047 for ; Fri, 2 Aug 2024 12:43:09 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from :to:subject:date:message-id:mime-version :content-transfer-encoding; s=pp1; bh=v3QFVUpRnziNSC2kwQuMumhs0B GaMmfuDVswwPqs3PI=; b=Cy/yzqiZPRCbA8hWyDOEppnQeemuKKrJjDbtethJtM tqPViB+t7PpK27d8O1c91s7vRNS0q2Of8ERC6g7dCLPut6XttsqIXPmMgQ21ChIR zGHl+dGsEgWTxtJulnTkgSAcfVW6o0qVesip3Zy9L9KV5kFzAwi/DEdiVDx4ykxh 9aWskDRxv2dwhPX6OAhquX/70ykS9cmRr4Ih4v0xpvrgiw/jhcr7SXv2QHkFtYhi /TCMuOHQ8gVxfo2hWIAqPISfcd6ASr4he90OwXo9OM10K2mMeCgNh3QsV2HGlShl dM8POV+LB8Ew2q1c88aA3/OPahNS4LxmN+Pc25pwqJQw== Received: from ppma13.dal12v.mail.ibm.com (dd.9e.1632.ip4.static.sl-reverse.com [50.22.158.221]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 40rwqwr8bf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 02 Aug 2024 12:43:09 +0000 (GMT) Received: from pps.filterd (ppma13.dal12v.mail.ibm.com [127.0.0.1]) by ppma13.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 472BkMoK003935 for ; Fri, 2 Aug 2024 12:43:08 GMT Received: from smtprelay07.fra02v.mail.ibm.com ([9.218.2.229]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 40ndemxxwj-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 02 Aug 2024 12:43:08 +0000 Received: from smtpav06.fra02v.mail.ibm.com (smtpav06.fra02v.mail.ibm.com [10.20.54.105]) by smtprelay07.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 472Ch4jm40501552 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 2 Aug 2024 12:43:07 GMT Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DC2FB20049 for ; Fri, 2 Aug 2024 12:43:04 +0000 (GMT) Received: from smtpav06.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B6F8C20040 for ; Fri, 2 Aug 2024 12:43:04 +0000 (GMT) Received: from li-3a824ecc-34fe-11b2-a85c-eae455c7d911.ibm.com.com (unknown [9.171.13.175]) by smtpav06.fra02v.mail.ibm.com (Postfix) with ESMTP for ; Fri, 2 Aug 2024 12:43:04 +0000 (GMT) From: Juergen Christ To: gcc-patches@gcc.gnu.org Subject: [PATCH] vect: Multistep float->int conversion only with no trapping math Date: Fri, 2 Aug 2024 14:43:00 +0200 Message-ID: <20240802124300.29260-1-jchrist@linux.ibm.com> X-Mailer: git-send-email 2.43.5 MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: DPtGZuoySzxc3D3D74L59COYGdETFN49 X-Proofpoint-GUID: DPtGZuoySzxc3D3D74L59COYGdETFN49 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-08-02_08,2024-08-02_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 lowpriorityscore=0 malwarescore=0 mlxscore=0 clxscore=1011 priorityscore=1501 impostorscore=0 suspectscore=0 bulkscore=0 mlxlogscore=999 adultscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2407110000 definitions=main-2408020084 X-Spam-Status: No, score=-13.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, 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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org Do not convert floats to ints in multiple step if trapping math is enabled. This might hide some inexact signals. Also use correct sign (the sign of the target integer type) for the intermediate steps. This only affects undefined behaviour (casting floats to unsigned datatype where the float is negative). gcc/ChangeLog: * tree-vect-stmts.cc (vectorizable_conversion): multi-step float to int conversion only with trapping math and correct sign. Signed-off-by: Juergen Christ Bootstrapped and tested on x84 and s390. Ok for trunk? --- gcc/tree-vect-stmts.cc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc index fdcda0d2abae..2ddd13383193 100644 --- a/gcc/tree-vect-stmts.cc +++ b/gcc/tree-vect-stmts.cc @@ -5448,7 +5448,8 @@ vectorizable_conversion (vec_info *vinfo, break; cvt_type - = build_nonstandard_integer_type (GET_MODE_BITSIZE (rhs_mode), 0); + = build_nonstandard_integer_type (GET_MODE_BITSIZE (rhs_mode), + TYPE_UNSIGNED (lhs_type)); cvt_type = get_same_sized_vectype (cvt_type, vectype_in); if (cvt_type == NULL_TREE) goto unsupported; @@ -5505,10 +5506,11 @@ vectorizable_conversion (vec_info *vinfo, if (GET_MODE_SIZE (lhs_mode) >= GET_MODE_SIZE (rhs_mode)) goto unsupported; - if (code == FIX_TRUNC_EXPR) + if (code == FIX_TRUNC_EXPR && !flag_trapping_math) { cvt_type - = build_nonstandard_integer_type (GET_MODE_BITSIZE (rhs_mode), 0); + = build_nonstandard_integer_type (GET_MODE_BITSIZE (rhs_mode), + TYPE_UNSIGNED (lhs_type)); cvt_type = get_same_sized_vectype (cvt_type, vectype_in); if (cvt_type == NULL_TREE) goto unsupported;