From nobody Sat May 18 22:15:08 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of _spf.google.com designates 209.85.218.48 as permitted sender) client-ip=209.85.218.48; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-ej1-f48.google.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.218.48 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1612463347; cv=none; d=zohomail.com; s=zohoarc; b=niUgaGotTRIyntiyqKUEWixvH1yYUFLMf3RJD7Qa36y2Y8DsXJ+UDNAV8yg9/yMJGQu6t6Ps+jeVhYNOjoZWeCZUEhmGYW3tBZWeT/FFE4VKlHOZPusbNygtXudEjlUJJeacv3K5RZ3u9q6/Ub4T78yE9LTNQC1S7c4Orbtvp0Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612463347; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:MIME-Version:Message-ID:Sender:Subject:To; bh=rnBP+G+AfTb5HZhTrwyYmkaQSKMTs0uwOtrFD3BNUBk=; b=V6qIPRVcTle8jKZe82e37vqKKHSdfZpCvJzbamRfWY7HA/3Rg7O/yzKyZK222XNX82LgyQNW6RBKtV4KPGptP6Pn4xdvLubBem+QFgwSthfNXNRnuR5D5nLgRbon3f7NVU7EwKPdwQJNygJH4jNJs7+0NF182P+RJjsFHW/fRCI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of _spf.google.com designates 209.85.218.48 as permitted sender) smtp.mailfrom=philippe.mathieu.daude@gmail.com Received: from mail-ej1-f48.google.com (mail-ej1-f48.google.com [209.85.218.48]) by mx.zohomail.com with SMTPS id 1612463347373147.0944305307587; Thu, 4 Feb 2021 10:29:07 -0800 (PST) Received: by mail-ej1-f48.google.com with SMTP id lg21so7138222ejb.3 for ; Thu, 04 Feb 2021 10:29:06 -0800 (PST) Return-Path: Return-Path: Received: from x1w.redhat.com (107.red-83-59-163.dynamicip.rima-tde.net. [83.59.163.107]) by smtp.gmail.com with ESMTPSA id z2sm335523ejn.91.2021.02.04.10.29.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Feb 2021 10:29:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=rnBP+G+AfTb5HZhTrwyYmkaQSKMTs0uwOtrFD3BNUBk=; b=n/RmAlbf6KCtcuCrDD5Yc5YlA+8ZgURoa/4LPYRc/ujaNMNc8mrt/UAD+avNou4pmg VQzK8aX0kEhALDOgE1MsEN13kPS9UNJPc1Sw2ykSnkV+RRtFqOkBhnAb43h43Wd0u3ZK gIPrS0CmCaHAM6lRZ9pDQ+PTlhCHxnFPKrJ4ayaIfWTOr1J8fAza8l337q+ci9i8b2YT NR+t3/PXYn4VX1QnBX/2DKgwK+NtAxDqKPE62Fdri0KbJC8i/H53ewkyE98GmQDo7JW2 Vmldg+97AAsO3gct1KTlmQPxYNfg5ksyFXj8RJVTJFKfpQOAbLgFue1QJedUvJsv5XZY FxPg== 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 :mime-version:content-transfer-encoding; bh=rnBP+G+AfTb5HZhTrwyYmkaQSKMTs0uwOtrFD3BNUBk=; b=Eou4+X4qg7aYDfKJM1DFxezXJeNiZcBzkbCqbWav1+VDK3t7q16Q4Qm8YY4McUFa/8 CY090a0M0K/JoQOnf3HnLaD9sXqa81n3odLiRjEegppYiQ0oH4MrxKhhs/biwi+HPQaf 0VXmZotJ4N05inqQ6Z7KRX5ekISOzMyHbDEtZwe4o94Y3eNVxuIUwotQpibE7KaKJ+ew 8GEtceIN4eB9jS8vu1oMlkTKBdwMbrRnHTwOjU+VTobxOFR32K0mA6Nj/Kje8bytSEIG h8hBw7MsUoYTu/5oYA0xmhCjOOT8fUK6l1WApxPxptphybVkhl7+TT9gimYC+jin+x8B XfLg== X-Gm-Message-State: AOAM5317oK5OoQSHl+KIKbCqn5TSunF7LLnGJ5r2wNhfcDFPHB9ghqor Pe31GBJIqaHI/iwGwXbOnHs= X-Google-Smtp-Source: ABdhPJx5EZhtCiasnPKxZVjZfGCMk8a4BIKr8A64EmjO5gdGbFNqDpwjDy1WhEOFU+ECUhkbVAL6WA== X-Received: by 2002:a17:907:35ca:: with SMTP id ap10mr380183ejc.451.1612463345558; Thu, 04 Feb 2021 10:29:05 -0800 (PST) Sender: =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Richard Henderson , Cornelia Huck , Thomas Huth , qemu-s390x@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Miroslav Rezanina , "Richard W . M . Jones" , David Hildenbrand , Eric Blake Subject: [PATCH] tcg/s390: Fix compare instruction from extended-immediate facility Date: Thu, 4 Feb 2021 19:29:02 +0100 Message-Id: <20210204182902.1742826-1-f4bug@amsat.org> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) The code is currently comparing c2 to the type promotion of uint32_t and int32_t. That is, the conversion rules are as: (common_type) c2 =3D=3D (common_type) (uint32_t) (is_unsigned ? (uint32_t)c2 : (uint32_t)(int32_t)c2) In the signed case we lose the desired sign extensions because of the argument promotion rules of the ternary operator. Solve the problem by doing the round-trip parsing through the intermediate type and back to the desired common type (all at one expression). Fixes: a534bb15f30 ("tcg/s390: Use constant pool for cmpi") Reported-by: Miroslav Rezanina Reported-by: Richard W.M. Jones Suggested-by: David Hildenbrand Suggested-by: Eric Blake Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: David Hildenbrand Tested-by: Richard W.M. Jones --- tcg/s390/tcg-target.c.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tcg/s390/tcg-target.c.inc b/tcg/s390/tcg-target.c.inc index b67470137c4..695d7ee6523 100644 --- a/tcg/s390/tcg-target.c.inc +++ b/tcg/s390/tcg-target.c.inc @@ -1067,7 +1067,7 @@ static int tgen_cmp(TCGContext *s, TCGType type, TCGC= ond c, TCGReg r1, op =3D (is_unsigned ? RIL_CLFI : RIL_CFI); tcg_out_insn_RIL(s, op, r1, c2); goto exit; - } else if (c2 =3D=3D (is_unsigned ? (uint32_t)c2 : (int32_t)c2= )) { + } else if (c2 =3D=3D (is_unsigned ? (TCGArg)(uint32_t)c2 : (TC= GArg)(int32_t)c2)) { op =3D (is_unsigned ? RIL_CLGFI : RIL_CGFI); tcg_out_insn_RIL(s, op, r1, c2); goto exit; --=20 2.26.2