From patchwork Mon Jul 23 20:17:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 142645 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp6509638ljj; Mon, 23 Jul 2018 14:22:29 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcIsfxX4/3ijstpBdy4Qh3GOcG62Lpqf8aQkY5QUJjZni+8ptcqSGJuMRURiMOfdmzthzz6 X-Received: by 2002:a0c:e792:: with SMTP id x18-v6mr12819910qvn.3.1532380949622; Mon, 23 Jul 2018 14:22:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532380949; cv=none; d=google.com; s=arc-20160816; b=X9Zc+dADH+xcAp8wjytk8RmkCHVoTLP4sk+bPRnwei+EpQMgDIJkk6PsZ0K3cb6tn8 cpZJJiFoz/LTJKhCVPM78ASNu4cmcTkSlLqekQ1z8vwiBMwWKJ+CyJNoZWV69EEAUZ3u Atr6b2uRLlM+6z5heLGHY4D5sn31O3bJf0pJz/quWS24vkt2mC1jXm3vZdo12Zt2ZWEs Ab2aR/3qSJcKKE+oJArZ5uUNHdGukr10YQz9osdlxv+kdK8PKfzFhMyxJmSvez+VsESf lBihhs5NATN7fCmPTAZqVlzC6eMQ4EIJx5KFRxOwUfRm/QI9GchjSG8eOy5MMt8ntBNY +liQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=79FhJ45C6ScQWoWPkygQVM7Ai2fm6uQPtNrO1Wa5grY=; b=syn0178kowaKwuj7LxG88zRs5/TPT2xUstFriuWFNjvO30FNnM9xLLaR2uxRlspQg8 Y/Hx8d9miGLUMrmN2rEeJyT1uPTYut0yLatURcI7X4o4pNXyQaMCoX4ugWkAQ98Ip0Ys 5cvfHl7fgp1WWv0PKMQ0uhO0azsgRVZmCfXacj+XvOeUn5vdHSNtYNUrelb00psIUj2H 2F/wzQ2ALN3aCzoiJwscJuQN+3aC2u79MbIPR5CE+GAL7QLwpTILtr7mQupREbcmSxmx 6HXWI0URUqK2aIKtnOSHkHiJuk5tP7DJYrQBAcdwnhi+qCd4V9wWOco+NskVEpklxAPx Mbdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b="ROoks/k7"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id w22-v6si9014613qtk.235.2018.07.23.14.22.29 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 23 Jul 2018 14:22:29 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b="ROoks/k7"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: from localhost ([::1]:36728 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhiHl-0007vQ-0W for patch@linaro.org; Mon, 23 Jul 2018 17:22:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42830) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fhhKM-0003Zm-Eo for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:21:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fhhKL-0005Db-F0 for qemu-devel@nongnu.org; Mon, 23 Jul 2018 16:21:06 -0400 Received: from mail-oi0-x241.google.com ([2607:f8b0:4003:c06::241]:43147) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fhhKL-0005DM-9j; Mon, 23 Jul 2018 16:21:05 -0400 Received: by mail-oi0-x241.google.com with SMTP id b15-v6so3468875oib.10; Mon, 23 Jul 2018 13:21:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=79FhJ45C6ScQWoWPkygQVM7Ai2fm6uQPtNrO1Wa5grY=; b=ROoks/k7y3PEuh7jvWLp+fKsWOZxK5neSHArAZbYLJF85G03sE8eNFLHSPGrcDRQwR vWNy+C553Xmtwn8uBBBZH+/Gzlp9nHMW679McO8lNhCi7sJih+DfcIXvrbLFbBAgeo9x kyQ0nu9EaYhSyUWFdk50B/PKBK/T6kyLZcBGI9VmIvyZQtoZ/WZqAiyO0no2oD1ESkZ0 03+azVv3IlbuAkIrli3nj8Aag1ci2HkI6cJj/KMkYRdiLjF6P2caCln1wzw14e8GXL9/ dR3VCfujLb8/XGPhr4m70IMiQ/iTqy7cK8ICbZFkX+buozoS/Cs81kLMjhwtQG0z4X0y mX9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=79FhJ45C6ScQWoWPkygQVM7Ai2fm6uQPtNrO1Wa5grY=; b=a/3PAQtduP10rzzyLp0yV/ZJGn8kk2+x74Y++qZNYhRRkYcEEVVEa+1YV6Um/kbJqk oWPKEQIzoWi/2gHLxaiUPlIz6Q+16mPRiFayPc0xaxtT2/nt8x/qpjAP89Y9tpe5tXJ1 VyCyf46W2DvYB/8YZ+jZnWShSlATcMIpc8rc0WLtiM0EnDKMY7ymWCAuvlDop3e22cA7 RdW+BMc031/thws7oHgiX38bRBXkyMZDqAzNRg6bwNvB5ogiroNRcXI+iqOuRBSuKJAu Lkiipq3JOQZJQOQiqLsXTIUsTd1f9wu+zjc4QqYSsDa1vr+RRqfQpyuf1NGu79Egx3Uu TM8g== X-Gm-Message-State: AOUpUlGkkve7FHG5HgcKBauUzP196rUYDhKU2XaW530ejlQ+ta1xUSwf mwA450nkc+VNDtaDZmcUT0jI1PIBLjJLrg== X-Received: by 2002:aca:ec46:: with SMTP id k67-v6mr312071oih.81.1532377264164; Mon, 23 Jul 2018 13:21:04 -0700 (PDT) Received: from localhost (76-251-165-188.lightspeed.austtx.sbcglobal.net. [76.251.165.188]) by smtp.gmail.com with ESMTPSA id a8-v6sm7948945oia.24.2018.07.23.13.21.02 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Jul 2018 13:21:03 -0700 (PDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 23 Jul 2018 15:17:19 -0500 Message-Id: <20180723201748.25573-71-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> References: <20180723201748.25573-1-mdroth@linux.vnet.ibm.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c06::241 Subject: [Qemu-devel] [PATCH 70/99] fpu/softfloat: Don't set Invalid for float-to-int(MAXINT) X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Peter Maydell In float-to-integer conversion, if the floating point input converts exactly to the largest or smallest integer that fits in to the result type, this is not an overflow. In this situation we were producing the correct result value, but were incorrectly setting the Invalid flag. For example for Arm A64, "FCVTAS w0, d0" on an input of 0x41dfffffffc00000 should produce 0x7fffffff and set no flags. Fix the boundary case to take the right half of the if() statements. This fixes a regression from 2.11 introduced by the softfloat refactoring. Cc: qemu-stable@nongnu.org Fixes: ab52f973a50 Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson Message-id: 20180510140141.12120-1-peter.maydell@linaro.org (cherry picked from commit 333583757c5e910b040bef793974773635ce1918) Signed-off-by: Michael Roth --- fpu/softfloat.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- 2.17.1 diff --git a/fpu/softfloat.c b/fpu/softfloat.c index 8401b37bd4..9bcaaebe4f 100644 --- a/fpu/softfloat.c +++ b/fpu/softfloat.c @@ -1368,14 +1368,14 @@ static int64_t round_to_int_and_pack(FloatParts in, int rmode, r = UINT64_MAX; } if (p.sign) { - if (r < -(uint64_t) min) { + if (r <= -(uint64_t) min) { return -r; } else { s->float_exception_flags = orig_flags | float_flag_invalid; return min; } } else { - if (r < max) { + if (r <= max) { return r; } else { s->float_exception_flags = orig_flags | float_flag_invalid;