From patchwork Sat May 12 00:42:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 135589 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp1566054lji; Fri, 11 May 2018 17:46:43 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrDqp1PYZUHYL1ZKWeW5vcWNZFFcvat6AtCj0CXKxbBf+mcBlCQRSU3wnn0fjd31av0OAvm X-Received: by 2002:ac8:2c49:: with SMTP id e9-v6mr272477qta.24.1526086003764; Fri, 11 May 2018 17:46:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526086003; cv=none; d=google.com; s=arc-20160816; b=VJmU+eeKRLxnwANm/SuroL9r3OtGSGQYEl3aHzr2voSvYk4QOL8IB8OMLUcjEOZGcY r6MEJhMfDTn1BzrWJ7vUDhqrVF5odMjA1bUyGdWRijFJELp4KWzFnjzVz5WhNe7ZR0kU T0MOzlYoguzXM585QN8FzertoroA0M2Rsf+qzvDp6Rh+scfAAtxQio/4lQDFnepW/GFF LkCJpxYcwzvVYvUdbArRgdIP8B4KnsJHxGz/z/e1Uggbe1P+sVFEB2yC5sBc8drbV89S +O0bmlXyqB0KMnPAXuNGJNSuUmao9iNuMyEDSDKky5C7oqo7z266TTHCz4NiolQDD7OH io3A== 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=KKM5+1s0S4RtYoVM9p3qzJTyULZIllGWLcjzz7/+Vb8=; b=pzB84gU25LpAXrFD94qbkuVHwa0ayIT07qaWSGxaj4El8ViBMY4qvCy9AqPlXIN/S9 tCXjUp1sidTE6i/+AdcFA7yJaEaf29gnn8IifU57F/ufi7iMdk07ERLukfB2/6k89Xdz w2mvEyarUS5TdwDPGaQF+s9i4jdJ+s4McPaUBqj9Rkju83QfMq4zYLPCNaADt8/J/N/3 CFm4ADuiOuog5nIv2faWzuFld2bgFPfREWsFWdfohlZNVKBLRTw07ERx1qhhXzjAlTDw yOPDx3cKvtwI2Hi560S5sZflKF40GxjSjHuDWpKu6Y7wyof+jyGhJctv5sEHijZPv7nB Q9Ww== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=ZzMWcyDJ; 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=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id t1-v6si4273345qvh.188.2018.05.11.17.46.43 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 11 May 2018 17:46:43 -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=@linaro.org header.s=google header.b=ZzMWcyDJ; 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=linaro.org Received: from localhost ([::1]:59101 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fHIgN-00072L-3z for patch@linaro.org; Fri, 11 May 2018 20:46:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33217) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fHId5-0003xa-GU for qemu-devel@nongnu.org; Fri, 11 May 2018 20:43:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fHId4-0002oV-PM for qemu-devel@nongnu.org; Fri, 11 May 2018 20:43:19 -0400 Received: from mail-pf0-x244.google.com ([2607:f8b0:400e:c00::244]:34145) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fHId4-0002oC-Jp for qemu-devel@nongnu.org; Fri, 11 May 2018 20:43:18 -0400 Received: by mail-pf0-x244.google.com with SMTP id a14-v6so3438958pfi.1 for ; Fri, 11 May 2018 17:43:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=KKM5+1s0S4RtYoVM9p3qzJTyULZIllGWLcjzz7/+Vb8=; b=ZzMWcyDJrf3CwrRApNOfJ9o01/yFnwBhT9M3f13naOUalPsU1lUvBCP6ykQJWv6BFP iQ84Oh2clnfh0vo1keFJ9Bt9CzLa0fcaBjg809VMYJW9o/8T4MvEDO6K75uQFDyRV2bu uloxvyLh0DqL7ynp+gkkt1pg0b1t5mdeFcKt4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=KKM5+1s0S4RtYoVM9p3qzJTyULZIllGWLcjzz7/+Vb8=; b=XzdREK+GU/AIhhg86CxrHVFRWFLh3U/3v5Fp9Kh1rxW7GRyQTDbYFO0zQ5toRl2hJm qj2EBHivCFhHQl5OJGx+8gQgRPACXPH3IdwRP2GLTwyMEXvJUKDeabMuVrPKAiy+tp32 Sy8/vDpoyeWUCr130TuiEoDdtP/eIcvjMEeSBJ6STFlnLEHpZa75FLfNFVm09pjKOwCQ vweLwK1xe4DawBpUH0JZpbw0q3ZUyT+QGye8IILwF1B7OpfKC5zmbn3OAvWH34CZH4cA TXdLsFEN6WN4l5JgbyVLqvGrnO0ujB9O+ehHPlYvFdvVOBuHmbF+2pWu19vCW1dCco1g /ysQ== X-Gm-Message-State: ALKqPwfKITE2E+iPAFePA4tHnRi83Qb3YaW2eBPA4+cgHD7FUtW5AVUl VkBTaJ6apD2g2Jy0ZhrhaI8cSw9JBAU= X-Received: by 2002:a65:5a81:: with SMTP id c1-v6mr1023675pgt.20.1526085797250; Fri, 11 May 2018 17:43:17 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-2-170.tukw.qwest.net. [97.113.2.170]) by smtp.gmail.com with ESMTPSA id k84-v6sm10756406pfh.93.2018.05.11.17.43.15 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 11 May 2018 17:43:16 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 11 May 2018 17:42:46 -0700 Message-Id: <20180512004311.9299-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180512004311.9299-1-richard.henderson@linaro.org> References: <20180512004311.9299-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::244 Subject: [Qemu-devel] [PATCH v2 02/27] 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@linaro.org, alex.bennee@linaro.org, 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 --- fpu/softfloat.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- 2.17.0 Reviewed-by: Richard Henderson diff --git a/fpu/softfloat.c b/fpu/softfloat.c index b39c0c6fbb..bc0f52fa54 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;